Skip to content
Permalink
Browse files

Model descriptor cleanup and icon fixes (using Material Design Icons)

  • Loading branch information...
richturner committed Sep 6, 2019
1 parent b1e8354 commit b7905e31f5375fa97972117708b1b26c1c8500c9
@@ -24,6 +24,12 @@
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import org.openremote.model.attribute.AttributeDescriptor;

/**
* Describes an {@link Asset} that can be added to the manager; the {@link #getType()} is the unique identifier.
* <p>
* A custom project can add its own descriptors through {@link org.openremote.model.asset.AssetModelProvider}.
* <p>
*/
@JsonFormat(shape = JsonFormat.Shape.OBJECT)
@JsonDeserialize(as = AssetDescriptorImpl.class)
public interface AssetDescriptor {
@@ -32,10 +38,6 @@
String getName();
@JsonProperty
String getType();

/**
* A HEX RGB color value {@link org.openremote.model.attribute.AttributeValueType#COLOR_HEX}
*/
@JsonProperty
String getIcon();
@JsonProperty
@@ -24,9 +24,6 @@

import java.util.Arrays;

/**
* This is used to store {@link Asset} hierarchy information before {@link Asset}s have been assigned IDs
*/
public class AssetTreeNode {

public Asset asset;
@@ -36,24 +36,24 @@

CUSTOM(null, "cube", null),

BUILDING(ASSET_NAMESPACE + ":building", "building", null,
BUILDING(ASSET_NAMESPACE + ":building", "office-building", null,
SURFACE_AREA,
GEO_STREET,
GEO_CITY,
GEO_COUNTRY,
GEO_POSTAL_CODE),

FLOOR(ASSET_NAMESPACE + ":floor", "bars", null),
FLOOR(ASSET_NAMESPACE + ":floor", "stairs", null),

RESIDENCE(ASSET_NAMESPACE + ":residence", "home", null),

ROOM(ASSET_NAMESPACE + ":room", "door-open", null),
ROOM(ASSET_NAMESPACE + ":room", "door", null),

AGENT(ASSET_NAMESPACE + ":agent", "cogs", null),

CONSOLE(ASSET_NAMESPACE + ":console", "bullseye", null),
CONSOLE(ASSET_NAMESPACE + ":console", "monitor-cellphone", null),

THING(ASSET_NAMESPACE + ":thing", "cube", null);
THING(ASSET_NAMESPACE + ":thing", "cube-outline", null);

final protected String type;
final protected String icon;
@@ -24,6 +24,13 @@
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import org.openremote.model.value.Value;

/**
* Describes an {@link Attribute} that can be added to an {@link org.openremote.model.asset.Asset};
* the {@link #getAttributeName} is the unique identifier.
* <p>
* A custom project can add its own descriptors through {@link org.openremote.model.asset.AssetModelProvider}.
* <p>
*/
@JsonDeserialize(as = AttributeDescriptorImpl.class)
@JsonFormat(shape = JsonFormat.Shape.OBJECT)
public interface AttributeDescriptor {
@@ -20,10 +20,16 @@
package org.openremote.model.attribute;

import org.openremote.model.value.Value;
import org.openremote.model.value.ValueType;
import org.openremote.model.value.Values;

import static org.openremote.model.Constants.ASSET_META_NAMESPACE;
import static org.openremote.model.attribute.MetaItemDescriptorImpl.metaItemObject;
import static org.openremote.model.attribute.MetaItemType.*;

/**
* This describes generic {@link Attribute}s that can be used on any {@link org.openremote.model.asset.Asset}.
*/
public enum AttributeType implements AttributeDescriptor {

CONSOLE_NAME("consoleName", AttributeValueType.STRING),
@@ -37,30 +43,37 @@
EMAIL("email", AttributeValueType.EMAIL, LABEL.withInitialValue(Values.create("Email"))),

GEO_CITY("city", AttributeValueType.STRING,
LABEL.withInitialValue(Values.create("City")),
ABOUT.withInitialValue(Values.create("http://project-haystack.org/tag/geoCity"))),
LABEL.withInitialValue(Values.create("City")),
ABOUT.withInitialValue(Values.create("http://project-haystack.org/tag/geoCity"))),

GEO_COUNTRY("country", AttributeValueType.STRING,
LABEL.withInitialValue(Values.create("Country")),
ABOUT.withInitialValue(Values.create("http://project-haystack.org/tag/geoCountry"))),
LABEL.withInitialValue(Values.create("Country")),
ABOUT.withInitialValue(Values.create("http://project-haystack.org/tag/geoCountry"))),

GEO_POSTAL_CODE("postalCode", AttributeValueType.NUMBER,
LABEL.withInitialValue(Values.create("Postal Code")),
ABOUT.withInitialValue(Values.create("http://project-haystack.org/tag/geoPostalCode"))),
LABEL.withInitialValue(Values.create("Postal Code")),
ABOUT.withInitialValue(Values.create("http://project-haystack.org/tag/geoPostalCode"))),

GEO_STREET("street", AttributeValueType.STRING,
LABEL.withInitialValue(Values.create("Street")),
ABOUT.withInitialValue(Values.create("http://project-haystack.org/tag/geoStreet"))),
LABEL.withInitialValue(Values.create("Street")),
ABOUT.withInitialValue(Values.create("http://project-haystack.org/tag/geoStreet"))),

LOCATION("location", AttributeValueType.GEO_JSON_POINT, LABEL.withInitialValue(Values.create("Location"))),

SURFACE_AREA(
"surfaceArea",
AttributeValueType.NUMBER,
LABEL.withInitialValue(Values.create("Surface Area")),
DESCRIPTION.withInitialValue(Values.create("Floor area of building measured in m²")),
ABOUT.withInitialValue(Values.create("http://project-haystack.org/tag/area")));

SURFACE_AREA("surfaceArea", AttributeValueType.NUMBER,
LABEL.withInitialValue(Values.create("Surface Area")),
DESCRIPTION.withInitialValue(Values.create("Floor area of building measured in m²")),
ABOUT.withInitialValue(Values.create("http://project-haystack.org/tag/area"))),

STATUS(
"status", AttributeValueType.ASSET_STATUS,
LABEL.withInitialValue(Values.create("Asset Status")),
DESCRIPTION.withInitialValue(Values.create("Defines an arbitrary status for the containing asset")),
metaItemObject(
ASSET_META_NAMESPACE + ":assetStatusColors",
new Access(true, false, true),
false,
null));

final protected String attributeName;
final protected AttributeValueDescriptor valueDescriptor;
@@ -202,7 +202,9 @@
),

// TODO Implement "Saved Filter/Searches" properly, see AssetResourceImpl
RULES_TEMPLATE_FILTER("filter", ValueType.ARRAY);
RULES_TEMPLATE_FILTER("filter", ValueType.ARRAY),

ASSET_STATUS("heart-pulse", ValueType.STRING);


public enum AttributeValueTypeFailureReason implements ValidationFailure.Reason {
@@ -34,7 +34,14 @@
import java.util.Objects;
import java.util.Optional;
import java.util.function.Function;

/**
* Describes a {@link MetaItem} that can be added to an {@link Attribute}; the URN should be URI and is the unique
* identifier.
* <p>
* A custom project can add its own descriptors through {@link org.openremote.model.asset.AssetModelProvider}.
* <p>
* TODO https://people.eecs.berkeley.edu/~arka/papers/buildsys2015_metadatasurvey.pdf
*/
@JsonFormat(shape = JsonFormat.Shape.OBJECT)
@JsonDeserialize(as = MetaItemDescriptorImpl.class)
public interface MetaItemDescriptor extends HasUniqueResourceName {
@@ -39,12 +39,7 @@
import static org.openremote.model.util.TextUtil.REGEXP_PATTERN_INTEGER_POSITIVE_NON_ZERO;

/**
* Asset attribute meta item name is an arbitrary string. It should be URI. This enum contains the well-known URIs for
* functionality we can depend on in our platform.
* <p>
* A custom project can add its own asset meta items through {@link AssetModelProvider}.
* <p>
* TODO https://people.eecs.berkeley.edu/~arka/papers/buildsys2015_metadatasurvey.pdf
* This describes generic {@link MetaItem}s that can be used on any {@link Attribute}.
*/
public enum MetaItemType implements MetaItemDescriptor {

0 comments on commit b7905e3

Please sign in to comment.
You can’t perform that action at this time.