Skip to content

Commit 6ca47c1

Browse files
committed
type and property descriptions are available through the schema mapping
1 parent cd33295 commit 6ca47c1

File tree

5 files changed

+32
-16
lines changed

5 files changed

+32
-16
lines changed

citydb-database/src/main/java/org/citydb/database/schema/DataType.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,19 +31,20 @@
3131

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

3636
private final Value value;
3737

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

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

6566
try {
66-
return new DataType(id, identifier, name, table, isAbstract, superTypeId,
67+
return new DataType(id, identifier, name, table, description, isAbstract, superTypeId,
6768
propertiesArray != null ? Type.buildProperties(propertiesArray) : null,
6869
valueObject != null ? Value.of(valueObject) : null,
6970
joinObject != null ? Join.of(joinObject) : null,

citydb-database/src/main/java/org/citydb/database/schema/FeatureType.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,19 +30,21 @@
3030

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

3535
private final boolean isTopLevel;
3636

37-
private FeatureType(int id, String identifier, Name name, Table table, boolean isAbstract, boolean isTopLevel,
38-
Integer superTypeId, Map<Name, Property> properties, Join join, JoinTable joinTable) {
39-
super(id, identifier, name, table, isAbstract, superTypeId, properties, join, joinTable);
37+
private FeatureType(int id, String identifier, Name name, Table table, String description, boolean isAbstract,
38+
boolean isTopLevel, Integer superTypeId, Map<Name, Property> properties, Join join,
39+
JoinTable joinTable) {
40+
super(id, identifier, name, table, description, isAbstract, superTypeId, properties, join, joinTable);
4041
this.isTopLevel = isTopLevel;
4142
}
4243

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

6365
try {
64-
return new FeatureType(id, identifier, name, table, isAbstract, isTopLevel, superTypeId,
66+
return new FeatureType(id, identifier, name, table, description, isAbstract, isTopLevel, superTypeId,
6567
propertiesArray != null ? Type.buildProperties(propertiesArray) : null,
6668
joinObject != null ? Join.of(joinObject) : null,
6769
joinTableObject != null ? JoinTable.of(joinTableObject) : null);

citydb-database/src/main/java/org/citydb/database/schema/Property.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131

3232
public class Property implements ValueObject, Typeable, Joinable {
3333
private final Name name;
34+
private final String description;
3435
private final Integer parentIndex;
3536
private final Value value;
3637
private final String typeIdentifier;
@@ -42,9 +43,10 @@ public class Property implements ValueObject, Typeable, Joinable {
4243
private Map<Name, Property> properties;
4344
private Join join;
4445

45-
private Property(Name name, Integer parentIndex, Value value, String typeIdentifier, String targetIdentifier,
46-
Join join, JoinTable joinTable) {
46+
private Property(Name name, String description, Integer parentIndex, Value value, String typeIdentifier,
47+
String targetIdentifier, Join join, JoinTable joinTable) {
4748
this.name = name;
49+
this.description = description;
4850
this.parentIndex = parentIndex;
4951
this.value = value;
5052
this.typeIdentifier = typeIdentifier;
@@ -55,6 +57,7 @@ private Property(Name name, Integer parentIndex, Value value, String typeIdentif
5557

5658
static Property of(JSONObject object) throws SchemaException {
5759
String propertyName = object.getString("name");
60+
String description = object.getString("description");
5861
String namespace = object.getString("namespace");
5962
Integer parentIndex = object.getInteger("parent");
6063
JSONObject valueObject = object.getJSONObject("value");
@@ -86,7 +89,7 @@ static Property of(JSONObject object) throws SchemaException {
8689
};
8790
}
8891

89-
return new Property(Name.of(propertyName, namespace), parentIndex,
92+
return new Property(Name.of(propertyName, namespace), description, parentIndex,
9093
valueObject != null ? Value.of(valueObject) : null,
9194
typeIdentifier, targetIdentifier,
9295
joinObject != null ? Join.of(joinObject) : null,
@@ -98,6 +101,10 @@ public Name getName() {
98101
return name;
99102
}
100103

104+
public Optional<String> getDescription() {
105+
return Optional.ofNullable(description);
106+
}
107+
101108
Integer getParentIndex() {
102109
return parentIndex;
103110
}

citydb-database/src/main/java/org/citydb/database/schema/Type.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,19 +32,21 @@ public abstract class Type<T extends Type<T>> implements Joinable {
3232
final String identifier;
3333
final Name name;
3434
final Table table;
35+
final String description;
3536
final boolean isAbstract;
3637
final Integer superTypeId;
3738
final Map<Name, Property> properties;
3839
final Join join;
3940
final JoinTable joinTable;
4041
T superType;
4142

42-
Type(int id, String identifier, Name name, Table table, boolean isAbstract, Integer superTypeId,
43-
Map<Name, Property> properties, Join join, JoinTable joinTable) {
43+
Type(int id, String identifier, Name name, Table table, String description, boolean isAbstract,
44+
Integer superTypeId, Map<Name, Property> properties, Join join, JoinTable joinTable) {
4445
this.id = id;
4546
this.identifier = identifier;
4647
this.name = name;
4748
this.table = table;
49+
this.description = description;
4850
this.isAbstract = isAbstract;
4951
this.superTypeId = superTypeId;
5052
this.properties = properties;
@@ -90,6 +92,10 @@ public Table getTable() {
9092
return table;
9193
}
9294

95+
public Optional<String> getDescription() {
96+
return Optional.ofNullable(description);
97+
}
98+
9399
public boolean isAbstract() {
94100
return isAbstract;
95101
}

resources/3dcitydb/postgresql/sql-scripts/schema/datatype-instances.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ INSERT INTO datatype (ID, SUPERTYPE_ID, TYPENAME, IS_ABSTRACT, NAMESPACE_ID, SCH
3333
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"}]}}');
3434

3535
INSERT INTO datatype (ID, SUPERTYPE_ID, TYPENAME, IS_ABSTRACT, NAMESPACE_ID, SCHEMA)
36-
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"}}');
36+
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"}}');
3737

3838
INSERT INTO datatype (ID, SUPERTYPE_ID, TYPENAME, IS_ABSTRACT, NAMESPACE_ID, SCHEMA)
3939
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"}}');

0 commit comments

Comments
 (0)