Add description support for asset properties and update related models
This commit is contained in:
@@ -45,6 +45,8 @@ public class AssetProperty {
|
|||||||
private final boolean inputList;
|
private final boolean inputList;
|
||||||
/// Whether the property should be hidden in the overview.
|
/// Whether the property should be hidden in the overview.
|
||||||
private final boolean hideInOverview;
|
private final boolean hideInOverview;
|
||||||
|
/// A description of the property, if any.
|
||||||
|
private final String description;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enum representing the possible types of asset properties.
|
* Enum representing the possible types of asset properties.
|
||||||
@@ -90,6 +92,7 @@ public class AssetProperty {
|
|||||||
.required(annotation.required())
|
.required(annotation.required())
|
||||||
.inputList(property.isAnnotationPresent(InputList.class))
|
.inputList(property.isAnnotationPresent(InputList.class))
|
||||||
.hideInOverview(property.isAnnotationPresent(HideInOverview.class))
|
.hideInOverview(property.isAnnotationPresent(HideInOverview.class))
|
||||||
|
.description(property.isAnnotationPresent(Description.class) ? property.getAnnotation(Description.class).value() : "")
|
||||||
.setter((obj, value) -> {
|
.setter((obj, value) -> {
|
||||||
try {
|
try {
|
||||||
property.setAccessible(true);
|
property.setAccessible(true);
|
||||||
|
|||||||
20
src/main/java/be/seeseepuff/pcinv/meta/Description.java
Normal file
20
src/main/java/be/seeseepuff/pcinv/meta/Description.java
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
package be.seeseepuff.pcinv.meta;
|
||||||
|
|
||||||
|
import java.lang.annotation.ElementType;
|
||||||
|
import java.lang.annotation.Retention;
|
||||||
|
import java.lang.annotation.RetentionPolicy;
|
||||||
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Annotation to provide a description for an asset.
|
||||||
|
*/
|
||||||
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
@Target(ElementType.FIELD)
|
||||||
|
public @interface Description {
|
||||||
|
/**
|
||||||
|
* The description of the asset.
|
||||||
|
*
|
||||||
|
* @return The description text.
|
||||||
|
*/
|
||||||
|
String value() default "";
|
||||||
|
}
|
||||||
@@ -0,0 +1,48 @@
|
|||||||
|
package be.seeseepuff.pcinv.models;
|
||||||
|
|
||||||
|
import be.seeseepuff.pcinv.meta.*;
|
||||||
|
import jakarta.persistence.*;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents a RAM DIMM or similar memory asset in the inventory system.
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@Entity
|
||||||
|
@AssetInfo(
|
||||||
|
displayName = "Display Adapter",
|
||||||
|
pluralName = "Display Adapters",
|
||||||
|
type = "GPU"
|
||||||
|
)
|
||||||
|
@Table(name = "gpu_assets")
|
||||||
|
public class DisplayAdapterAsset implements Asset
|
||||||
|
{
|
||||||
|
@Id
|
||||||
|
@GeneratedValue
|
||||||
|
private long id;
|
||||||
|
|
||||||
|
/// The generic asset associated with this RAM.
|
||||||
|
@OneToOne(orphanRemoval = true)
|
||||||
|
private GenericAsset asset;
|
||||||
|
|
||||||
|
@Property("VRAM Capacity")
|
||||||
|
@Capacity
|
||||||
|
private Long vramCapacity;
|
||||||
|
|
||||||
|
@Description("The type of interface. E.g.: AGP, PCIe, ISA-8, etc...")
|
||||||
|
@Property("Interface")
|
||||||
|
@InputList
|
||||||
|
private String interfaceType;
|
||||||
|
|
||||||
|
@Description("The highest version of DirectX supported by this display adapter.")
|
||||||
|
@Property("DirectX Version")
|
||||||
|
@InputList
|
||||||
|
private String directXVersion;
|
||||||
|
|
||||||
|
@Description("The highest version of OpenGL supported by this display adapter.")
|
||||||
|
@Property("OpenGL Version")
|
||||||
|
@InputList
|
||||||
|
private String openGLVersion;
|
||||||
|
}
|
||||||
@@ -1,9 +1,6 @@
|
|||||||
package be.seeseepuff.pcinv.models;
|
package be.seeseepuff.pcinv.models;
|
||||||
|
|
||||||
import be.seeseepuff.pcinv.meta.AssetInfo;
|
import be.seeseepuff.pcinv.meta.*;
|
||||||
import be.seeseepuff.pcinv.meta.InputList;
|
|
||||||
import be.seeseepuff.pcinv.meta.HideInOverview;
|
|
||||||
import be.seeseepuff.pcinv.meta.Property;
|
|
||||||
import jakarta.persistence.*;
|
import jakarta.persistence.*;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
@@ -33,30 +30,26 @@ public class GenericAsset
|
|||||||
|
|
||||||
/// The QR code attached to the asset, used for identification.
|
/// The QR code attached to the asset, used for identification.
|
||||||
@Property(value = "QR", required = true)
|
@Property(value = "QR", required = true)
|
||||||
|
@Description("The QR code attached to the asset, used for identification.")
|
||||||
private long qr;
|
private long qr;
|
||||||
|
|
||||||
/// The type of asset
|
/// The type of asset
|
||||||
private String type;
|
private String type;
|
||||||
|
|
||||||
/// The brand of the asset.
|
|
||||||
@Property("Brand")
|
@Property("Brand")
|
||||||
@InputList
|
@InputList
|
||||||
private String brand;
|
private String brand;
|
||||||
|
|
||||||
/// The model of the asset
|
|
||||||
@Property("Model")
|
@Property("Model")
|
||||||
private String model;
|
private String model;
|
||||||
|
|
||||||
/// The asset's serial number.
|
|
||||||
@Property("Serial Number")
|
@Property("Serial Number")
|
||||||
private String serialNumber;
|
private String serialNumber;
|
||||||
|
|
||||||
/// A description of the asset, providing additional details.
|
|
||||||
@Property("Description")
|
@Property("Description")
|
||||||
@HideInOverview
|
@HideInOverview
|
||||||
private String description;
|
private String description;
|
||||||
|
|
||||||
/// The state of the asset, indicating its condition.
|
|
||||||
@Property("Condition")
|
@Property("Condition")
|
||||||
private AssetCondition condition;
|
private AssetCondition condition;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,6 @@
|
|||||||
package be.seeseepuff.pcinv.models;
|
package be.seeseepuff.pcinv.models;
|
||||||
|
|
||||||
import be.seeseepuff.pcinv.meta.AssetInfo;
|
import be.seeseepuff.pcinv.meta.*;
|
||||||
import be.seeseepuff.pcinv.meta.Capacity;
|
|
||||||
import be.seeseepuff.pcinv.meta.InputList;
|
|
||||||
import be.seeseepuff.pcinv.meta.Property;
|
|
||||||
import jakarta.persistence.*;
|
import jakarta.persistence.*;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
@@ -26,21 +23,19 @@ public class HddAsset implements Asset
|
|||||||
@GeneratedValue
|
@GeneratedValue
|
||||||
private long id;
|
private long id;
|
||||||
|
|
||||||
/// The generic asset associated with this HDD.
|
|
||||||
@OneToOne(orphanRemoval = true)
|
@OneToOne(orphanRemoval = true)
|
||||||
private GenericAsset asset;
|
private GenericAsset asset;
|
||||||
|
|
||||||
/// The capacity of the drive in bytes.
|
|
||||||
@Property("Capacity")
|
@Property("Capacity")
|
||||||
@Capacity(si = true, iec = true)
|
@Capacity(si = true, iec = true)
|
||||||
private Long capacity;
|
private Long capacity;
|
||||||
|
|
||||||
/// The drive's interface type, such as SATA, IDE, ISA-16, ...
|
@Description("The drive's interface type, such as SATA, IDE, ISA-16, ...")
|
||||||
@Property("Interface Type")
|
@Property("Interface Type")
|
||||||
@InputList
|
@InputList
|
||||||
private String interfaceType;
|
private String interfaceType;
|
||||||
|
|
||||||
/// The drive's form factor, such as 2.5", 3.5", etc.
|
@Description("The drive's form factor, such as 2.5\", 3.5\", etc.")
|
||||||
@Property("Form Factor")
|
@Property("Form Factor")
|
||||||
@InputList
|
@InputList
|
||||||
private String formFactor;
|
private String formFactor;
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
package be.seeseepuff.pcinv.models;
|
package be.seeseepuff.pcinv.models;
|
||||||
|
|
||||||
import be.seeseepuff.pcinv.meta.AssetInfo;
|
import be.seeseepuff.pcinv.meta.*;
|
||||||
import be.seeseepuff.pcinv.meta.Capacity;
|
|
||||||
import be.seeseepuff.pcinv.meta.Property;
|
|
||||||
import jakarta.persistence.*;
|
import jakarta.persistence.*;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
@@ -25,16 +23,15 @@ public class RamAsset implements Asset
|
|||||||
@GeneratedValue
|
@GeneratedValue
|
||||||
private long id;
|
private long id;
|
||||||
|
|
||||||
/// The generic asset associated with this RAM.
|
|
||||||
@OneToOne(orphanRemoval = true)
|
@OneToOne(orphanRemoval = true)
|
||||||
private GenericAsset asset;
|
private GenericAsset asset;
|
||||||
|
|
||||||
/// The capacity of the RAM in bytes.
|
|
||||||
@Property("Capacity")
|
@Property("Capacity")
|
||||||
@Capacity
|
@Capacity
|
||||||
private Long capacity;
|
private Long capacity;
|
||||||
|
|
||||||
/// The type of memory. E.g.: DDR2, SDRAM, ISA-8, etc...
|
@Description("The type of memory. E.g.: DDR2, SDRAM, ISA-8, etc...")
|
||||||
@Property("Type")
|
@Property("Type")
|
||||||
|
@InputList
|
||||||
private String type;
|
private String type;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,12 @@
|
|||||||
|
package be.seeseepuff.pcinv.repositories;
|
||||||
|
|
||||||
|
import be.seeseepuff.pcinv.models.DisplayAdapterAsset;
|
||||||
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
public interface DisplayAdapterRepository extends JpaRepository<DisplayAdapterAsset, Long>, AssetRepository<DisplayAdapterAsset> {
|
||||||
|
@Override
|
||||||
|
default Class<DisplayAdapterAsset> getAssetType() {
|
||||||
|
return DisplayAdapterAsset.class;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4,7 +4,7 @@ import be.seeseepuff.pcinv.models.HddAsset;
|
|||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
public interface HddAssetRepository extends JpaRepository<HddAsset, Long>, AssetRepository<HddAsset> {
|
public interface HddRepository extends JpaRepository<HddAsset, Long>, AssetRepository<HddAsset> {
|
||||||
@Override
|
@Override
|
||||||
default Class<HddAsset> getAssetType() {
|
default Class<HddAsset> getAssetType() {
|
||||||
return HddAsset.class;
|
return HddAsset.class;
|
||||||
@@ -4,7 +4,7 @@ import be.seeseepuff.pcinv.models.RamAsset;
|
|||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
public interface RamAssetRepository extends JpaRepository<RamAsset, Long>, AssetRepository<RamAsset> {
|
public interface RamRepository extends JpaRepository<RamAsset, Long>, AssetRepository<RamAsset> {
|
||||||
@Override
|
@Override
|
||||||
default Class<RamAsset> getAssetType() {
|
default Class<RamAsset> getAssetType() {
|
||||||
return RamAsset.class;
|
return RamAsset.class;
|
||||||
@@ -6,7 +6,7 @@
|
|||||||
<h2 th:text="${d.displayName}"></h2>
|
<h2 th:text="${d.displayName}"></h2>
|
||||||
<table border="1" cellpadding="4">
|
<table border="1" cellpadding="4">
|
||||||
<tr th:each="p : ${d.getProperties()}">
|
<tr th:each="p : ${d.getProperties()}">
|
||||||
<td bgcolor="#d3d3d3"><b><label th:text="${p.displayName}" th:for="${d.asString(p)}"></label></b></td>
|
<td bgcolor="#d3d3d3"><b><label th:text="${p.displayName}" th:for="${d.asString(p)}" th:title="${p.description}"></label></b></td>
|
||||||
<td th:switch="${p.type.nameOrEnum()}">
|
<td th:switch="${p.type.nameOrEnum()}">
|
||||||
<span th:case="STRING">
|
<span th:case="STRING">
|
||||||
<select th:if="${p.inputList}" th:id="${d.asString(p)+'-list'}" th:name="${d.asString(p)+'-list'}">
|
<select th:if="${p.inputList}" th:id="${d.asString(p)+'-list'}" th:name="${d.asString(p)+'-list'}">
|
||||||
|
|||||||
Reference in New Issue
Block a user