Skip to content

Commit

Permalink
type and property descriptions are available through the schema mapping
Browse files Browse the repository at this point in the history
  • Loading branch information
clausnagel committed Dec 18, 2024
1 parent cd33295 commit 6ca47c1
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,20 @@

public class DataType extends Type<DataType> implements ValueObject {
public static final DataType UNDEFINED = new DataType(1, "core:Undefined", Name.of("Undefined", Namespaces.CORE),
Table.PROPERTY, false, null, null, null, null, null);
Table.PROPERTY, null, false, null, null, null, null, null);

private final Value value;

private DataType(int id, String identifier, Name name, Table table, boolean isAbstract, Integer superTypeId,
Map<Name, Property> properties, Value value, Join join, JoinTable joinTable) {
super(id, identifier, name, table, isAbstract, superTypeId, properties, join, joinTable);
private DataType(int id, String identifier, Name name, Table table, String description, boolean isAbstract,
Integer superTypeId, Map<Name, Property> properties, Value value, Join join, JoinTable joinTable) {
super(id, identifier, name, table, description, isAbstract, superTypeId, properties, join, joinTable);
this.value = value;
}

static DataType of(int id, Name name, boolean isAbstract, Integer superTypeId, JSONObject object) throws SchemaException {
String identifier = object.getString("identifier");
String tableName = object.getString("table");
String description = object.getString("description");
JSONArray propertiesArray = object.getJSONArray("properties");
JSONObject valueObject = object.getJSONObject("value");
JSONObject joinObject = object.getJSONObject("join");
Expand All @@ -63,7 +64,7 @@ static DataType of(int id, Name name, boolean isAbstract, Integer superTypeId, J
}

try {
return new DataType(id, identifier, name, table, isAbstract, superTypeId,
return new DataType(id, identifier, name, table, description, isAbstract, superTypeId,
propertiesArray != null ? Type.buildProperties(propertiesArray) : null,
valueObject != null ? Value.of(valueObject) : null,
joinObject != null ? Join.of(joinObject) : null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,21 @@

public class FeatureType extends Type<FeatureType> {
public static final FeatureType UNDEFINED = new FeatureType(1, "core:Undefined",
Name.of("Undefined", Namespaces.CORE), Table.FEATURE, false, false, null, null, null, null);
Name.of("Undefined", Namespaces.CORE), Table.FEATURE, null, false, false, null, null, null, null);

private final boolean isTopLevel;

private FeatureType(int id, String identifier, Name name, Table table, boolean isAbstract, boolean isTopLevel,
Integer superTypeId, Map<Name, Property> properties, Join join, JoinTable joinTable) {
super(id, identifier, name, table, isAbstract, superTypeId, properties, join, joinTable);
private FeatureType(int id, String identifier, Name name, Table table, String description, boolean isAbstract,
boolean isTopLevel, Integer superTypeId, Map<Name, Property> properties, Join join,
JoinTable joinTable) {
super(id, identifier, name, table, description, isAbstract, superTypeId, properties, join, joinTable);
this.isTopLevel = isTopLevel;
}

static FeatureType of(int id, Name name, boolean isAbstract, boolean isTopLevel, Integer superTypeId, JSONObject object) throws SchemaException {
String identifier = object.getString("identifier");
String tableName = object.getString("table");
String description = object.getString("description");
JSONArray propertiesArray = object.getJSONArray("properties");
JSONObject joinObject = object.getJSONObject("join");
JSONObject joinTableObject = object.getJSONObject("joinTable");
Expand All @@ -61,7 +63,7 @@ static FeatureType of(int id, Name name, boolean isAbstract, boolean isTopLevel,
}

try {
return new FeatureType(id, identifier, name, table, isAbstract, isTopLevel, superTypeId,
return new FeatureType(id, identifier, name, table, description, isAbstract, isTopLevel, superTypeId,
propertiesArray != null ? Type.buildProperties(propertiesArray) : null,
joinObject != null ? Join.of(joinObject) : null,
joinTableObject != null ? JoinTable.of(joinTableObject) : null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@

public class Property implements ValueObject, Typeable, Joinable {
private final Name name;
private final String description;
private final Integer parentIndex;
private final Value value;
private final String typeIdentifier;
Expand All @@ -42,9 +43,10 @@ public class Property implements ValueObject, Typeable, Joinable {
private Map<Name, Property> properties;
private Join join;

private Property(Name name, Integer parentIndex, Value value, String typeIdentifier, String targetIdentifier,
Join join, JoinTable joinTable) {
private Property(Name name, String description, Integer parentIndex, Value value, String typeIdentifier,
String targetIdentifier, Join join, JoinTable joinTable) {
this.name = name;
this.description = description;
this.parentIndex = parentIndex;
this.value = value;
this.typeIdentifier = typeIdentifier;
Expand All @@ -55,6 +57,7 @@ private Property(Name name, Integer parentIndex, Value value, String typeIdentif

static Property of(JSONObject object) throws SchemaException {
String propertyName = object.getString("name");
String description = object.getString("description");
String namespace = object.getString("namespace");
Integer parentIndex = object.getInteger("parent");
JSONObject valueObject = object.getJSONObject("value");
Expand Down Expand Up @@ -86,7 +89,7 @@ static Property of(JSONObject object) throws SchemaException {
};
}

return new Property(Name.of(propertyName, namespace), parentIndex,
return new Property(Name.of(propertyName, namespace), description, parentIndex,
valueObject != null ? Value.of(valueObject) : null,
typeIdentifier, targetIdentifier,
joinObject != null ? Join.of(joinObject) : null,
Expand All @@ -98,6 +101,10 @@ public Name getName() {
return name;
}

public Optional<String> getDescription() {
return Optional.ofNullable(description);
}

Integer getParentIndex() {
return parentIndex;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,21 @@ public abstract class Type<T extends Type<T>> implements Joinable {
final String identifier;
final Name name;
final Table table;
final String description;
final boolean isAbstract;
final Integer superTypeId;
final Map<Name, Property> properties;
final Join join;
final JoinTable joinTable;
T superType;

Type(int id, String identifier, Name name, Table table, boolean isAbstract, Integer superTypeId,
Map<Name, Property> properties, Join join, JoinTable joinTable) {
Type(int id, String identifier, Name name, Table table, String description, boolean isAbstract,
Integer superTypeId, Map<Name, Property> properties, Join join, JoinTable joinTable) {
this.id = id;
this.identifier = identifier;
this.name = name;
this.table = table;
this.description = description;
this.isAbstract = isAbstract;
this.superTypeId = superTypeId;
this.properties = properties;
Expand Down Expand Up @@ -90,6 +92,10 @@ public Table getTable() {
return table;
}

public Optional<String> getDescription() {
return Optional.ofNullable(description);
}

public boolean isAbstract() {
return isAbstract;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ INSERT INTO datatype (ID, SUPERTYPE_ID, TYPENAME, IS_ABSTRACT, NAMESPACE_ID, SCH
VALUES (10, null, 'FeatureProperty', 0, 1, '{"identifier":"core:FeatureProperty","description":"FeatureProperty links a feature or property to a feature.","table":"property","join":{"table":"feature","fromColumn":"val_feature_id","toColumn":"id","conditions":[{"column":"objectclass_id","value":"@target.objectclass_id@","type":"integer"}]}}');

INSERT INTO datatype (ID, SUPERTYPE_ID, TYPENAME, IS_ABSTRACT, NAMESPACE_ID, SCHEMA)
VALUES (11, null, 'GeometryProperty', 0, 1, '{"identifier":"core:GeometryProperty","description":"GeometryProperty links a feature or property to a geometry.","table":"property","properties":[{"name":"lod","namespace":"http://3dcitydb.org/3dcitydb/core/5.0","value":{"column":"val_lod","type":"string"}}],"join":{"table":"geometry_data","fromColumn":"val_geometry_id","toColumn":"id"}}');
VALUES (11, null, 'GeometryProperty', 0, 1, '{"identifier":"core:GeometryProperty","description":"GeometryProperty links a feature or property to a geometry.","table":"property","properties":[{"name":"lod","namespace":"http://3dcitydb.org/3dcitydb/core/5.0","description":"Specifies the Level of Detail of the geometry.","value":{"column":"val_lod","type":"string"}}],"join":{"table":"geometry_data","fromColumn":"val_geometry_id","toColumn":"id"}}');

INSERT INTO datatype (ID, SUPERTYPE_ID, TYPENAME, IS_ABSTRACT, NAMESPACE_ID, SCHEMA)
VALUES (12, null, 'Reference', 0, 1, '{"identifier":"core:Reference","description":"Reference links a feature or property to a remote resource identified by a URI.","table":"property","value":{"column":"val_uri","type":"uri"}}');
Expand Down

0 comments on commit 6ca47c1

Please sign in to comment.