Skip to content

Commit

Permalink
removed support for root_id column of property table
Browse files Browse the repository at this point in the history
  • Loading branch information
clausnagel committed Nov 29, 2023
1 parent 70f2e91 commit 1dadb91
Show file tree
Hide file tree
Showing 10 changed files with 90 additions and 107 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ WITH RECURSIVE FEATURE_HIERARCHY AS
(SELECT NULL::bigint AS ID,
ID AS FEATURE_ID,
NULL::bigint AS PARENT_ID,
NULL::bigint AS ROOT_ID,
NULL::int AS DATATYPE_ID,
NULL::int AS NAMESPACE_ID,
NULL AS NAME,
Expand Down Expand Up @@ -32,7 +31,6 @@ WITH RECURSIVE FEATURE_HIERARCHY AS
P.ID,
P.FEATURE_ID,
P.PARENT_ID,
P.ROOT_ID,
P.DATATYPE_ID,
P.NAMESPACE_ID,
P.NAME,
Expand Down Expand Up @@ -62,7 +60,6 @@ SELECT
H.ID,
H.FEATURE_ID,
H.PARENT_ID,
H.ROOT_ID,
H.DATATYPE_ID,
H.NAMESPACE_ID,
H.NAME,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
public class PropertyDescriptor extends DatabaseDescriptor {
private final long featureId;
private long parentId;
private long rootId;

private PropertyDescriptor(long id, long featureId) {
super(id);
Expand All @@ -49,13 +48,4 @@ public PropertyDescriptor setParentId(long parentId) {
public long getParentId() {
return parentId;
}

public PropertyDescriptor setRootId(long rootId) {
this.rootId = rootId;
return this;
}

public long getRootId() {
return rootId;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,7 @@ public PropertyStub doExport(long featureId, ResultSet rs) throws ExportExceptio
.setGenericContent(rs.getString("val_content"))
.setGenericContentMimeType(rs.getString("val_content_mime_type"))
.setDescriptor(PropertyDescriptor.of(rs.getLong("id"), featureId)
.setParentId(rs.getLong("parent_id"))
.setRootId(rs.getLong("root_id")));
.setParentId(rs.getLong("parent_id")));
} else {
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,34 +44,34 @@ public AddressPropertyImporter(ImportHelper helper) throws SQLException {
@Override
protected String getInsertStatement() {
return "insert into " + tableHelper.getPrefixedTableName(table) +
"(id, feature_id, parent_id, root_id, datatype_id, namespace_id, name, " +
"(id, feature_id, parent_id, datatype_id, namespace_id, name, " +
"val_address_id, val_reference_type) " +
"values (" + String.join(",", Collections.nCopies(9, "?")) + ")";
"values (" + String.join(",", Collections.nCopies(8, "?")) + ")";
}

public PropertyDescriptor doImport(AddressProperty property, long featureId) throws ImportException, SQLException {
long propertyId = nextSequenceValue(Sequence.PROPERTY);
return doImport(property, propertyId, propertyId, propertyId, featureId);
return doImport(property, propertyId, propertyId, featureId);
}

PropertyDescriptor doImport(AddressProperty property, long parentId, long rootId, long featureId) throws ImportException, SQLException {
return doImport(property, nextSequenceValue(Sequence.PROPERTY), parentId, rootId, featureId);
PropertyDescriptor doImport(AddressProperty property, long parentId, long featureId) throws ImportException, SQLException {
return doImport(property, nextSequenceValue(Sequence.PROPERTY), parentId, featureId);
}

PropertyDescriptor doImport(AddressProperty property, long propertyId, long parentId, long rootId, long featureId) throws ImportException, SQLException {
PropertyDescriptor doImport(AddressProperty property, long propertyId, long parentId, long featureId) throws ImportException, SQLException {
Address address = property.getObject().orElse(null);
if (address != null) {
stmt.setLong(8, tableHelper.getOrCreateImporter(AddressImporter.class)
stmt.setLong(7, tableHelper.getOrCreateImporter(AddressImporter.class)
.doImport(address)
.getId());
stmt.setNull(9, Types.INTEGER);
stmt.setNull(8, Types.INTEGER);
} else if (property.getReference().isPresent()) {
Reference reference = property.getReference().get();
cacheReference(CacheType.ADDRESS, reference, propertyId);
stmt.setNull(8, Types.BIGINT);
stmt.setInt(9, reference.getType().getDatabaseValue());
stmt.setNull(7, Types.BIGINT);
stmt.setInt(8, reference.getType().getDatabaseValue());
}

return super.doImport(property, propertyId, parentId, rootId, featureId);
return super.doImport(property, propertyId, parentId, featureId);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,25 +40,25 @@ public AppearancePropertyImporter(ImportHelper helper) throws SQLException {
@Override
protected String getInsertStatement() {
return "insert into " + tableHelper.getPrefixedTableName(table) +
"(id, feature_id, parent_id, root_id, datatype_id, namespace_id, name, " +
"(id, feature_id, parent_id, datatype_id, namespace_id, name, " +
"val_appearance_id) " +
"values (" + String.join(",", Collections.nCopies(8, "?")) + ")";
"values (" + String.join(",", Collections.nCopies(7, "?")) + ")";
}

public PropertyDescriptor doImport(AppearanceProperty property, long featureId) throws ImportException, SQLException {
long propertyId = nextSequenceValue(Sequence.PROPERTY);
return doImport(property, propertyId, propertyId, propertyId, featureId);
return doImport(property, propertyId, propertyId, featureId);
}

PropertyDescriptor doImport(AppearanceProperty property, long parentId, long rootId, long featureId) throws ImportException, SQLException {
return doImport(property, nextSequenceValue(Sequence.PROPERTY), parentId, rootId, featureId);
PropertyDescriptor doImport(AppearanceProperty property, long parentId, long featureId) throws ImportException, SQLException {
return doImport(property, nextSequenceValue(Sequence.PROPERTY), parentId, featureId);
}

PropertyDescriptor doImport(AppearanceProperty property, long propertyId, long parentId, long rootId, long featureId) throws ImportException, SQLException {
stmt.setLong(8, tableHelper.getOrCreateImporter(AppearanceImporter.class)
PropertyDescriptor doImport(AppearanceProperty property, long propertyId, long parentId, long featureId) throws ImportException, SQLException {
stmt.setLong(7, tableHelper.getOrCreateImporter(AppearanceImporter.class)
.doImport(property.getObject(), featureId, AppearanceImporter.Type.FEATURE)
.getId());

return super.doImport(property, propertyId, parentId, rootId, featureId);
return super.doImport(property, propertyId, parentId, featureId);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,84 +42,84 @@ public AttributeImporter(ImportHelper helper) throws SQLException {
@Override
protected String getInsertStatement() {
return "insert into " + tableHelper.getPrefixedTableName(table) +
"(id, feature_id, parent_id, root_id, datatype_id, namespace_id, name, " +
"(id, feature_id, parent_id, datatype_id, namespace_id, name, " +
"val_int, val_double, val_string, val_timestamp, val_uri, val_codespace, val_uom, val_array, " +
"val_content, val_content_mime_type) " +
"values (" + String.join(",", Collections.nCopies(17, "?")) + ")";
"values (" + String.join(",", Collections.nCopies(16, "?")) + ")";
}

public PropertyDescriptor doImport(Attribute attribute, long featureId) throws ImportException, SQLException {
long propertyId = nextSequenceValue(Sequence.PROPERTY);
return doImport(attribute, propertyId, propertyId, propertyId, featureId);
return doImport(attribute, propertyId, propertyId, featureId);
}

PropertyDescriptor doImport(Attribute attribute, long parentId, long rootId, long featureId) throws ImportException, SQLException {
return doImport(attribute, nextSequenceValue(Sequence.PROPERTY), parentId, rootId, featureId);
PropertyDescriptor doImport(Attribute attribute, long parentId, long featureId) throws ImportException, SQLException {
return doImport(attribute, nextSequenceValue(Sequence.PROPERTY), parentId, featureId);
}

private PropertyDescriptor doImport(Attribute attribute, long propertyId, long parentId, long rootId, long featureId) throws ImportException, SQLException {
private PropertyDescriptor doImport(Attribute attribute, long propertyId, long parentId, long featureId) throws ImportException, SQLException {
Long intValue = attribute.getIntValue().orElse(null);
if (intValue != null) {
stmt.setLong(8, intValue);
stmt.setLong(7, intValue);
} else {
stmt.setNull(8, Types.BIGINT);
stmt.setNull(7, Types.BIGINT);
}

Double doubleValue = attribute.getDoubleValue().orElse(null);
if (doubleValue != null) {
stmt.setDouble(9, doubleValue);
stmt.setDouble(8, doubleValue);
} else {
stmt.setNull(9, Types.DOUBLE);
stmt.setNull(8, Types.DOUBLE);
}

stmt.setString(10, attribute.getStringValue().orElse(null));
stmt.setString(9, attribute.getStringValue().orElse(null));

OffsetDateTime timestamp = attribute.getTimeStamp().orElse(null);
if (timestamp != null) {
stmt.setObject(11, timestamp);
stmt.setObject(10, timestamp);
} else {
stmt.setNull(11, Types.TIMESTAMP);
stmt.setNull(10, Types.TIMESTAMP);
}

stmt.setString(12, attribute.getURI().orElse(null));
stmt.setString(13, attribute.getCodeSpace().orElse(null));
stmt.setString(14, attribute.getUom().orElse(null));
stmt.setString(11, attribute.getURI().orElse(null));
stmt.setString(12, attribute.getCodeSpace().orElse(null));
stmt.setString(13, attribute.getUom().orElse(null));

String arrayValue = attribute.getArrayValue()
.map(array -> JSONArray.copyOf(array.getValues().stream()
.map(Value::rawValue)
.collect(Collectors.toList())).toString())
.orElse(null);
if (arrayValue != null) {
stmt.setObject(15, arrayValue, Types.OTHER);
stmt.setObject(14, arrayValue, Types.OTHER);
} else {
stmt.setNull(15, Types.OTHER);
stmt.setNull(14, Types.OTHER);
}

stmt.setString(16, attribute.getGenericContent().orElse(null));
stmt.setString(17, attribute.getGenericContentMimeType().orElse(null));
stmt.setString(15, attribute.getGenericContent().orElse(null));
stmt.setString(16, attribute.getGenericContentMimeType().orElse(null));

PropertyDescriptor descriptor = super.doImport(attribute, propertyId, parentId, rootId, featureId);
PropertyDescriptor descriptor = super.doImport(attribute, propertyId, parentId, featureId);

if (attribute.hasProperties()) {
for (Property<?> property : attribute.getProperties().getAll()) {
if (property instanceof Attribute) {
doImport((Attribute) property, parentId, rootId, featureId);
doImport((Attribute) property, parentId, featureId);
} else if (property instanceof FeatureProperty) {
tableHelper.getOrCreateImporter(FeaturePropertyImporter.class)
.doImport((FeatureProperty) property, parentId, rootId, featureId);
.doImport((FeatureProperty) property, parentId, featureId);
} else if (property instanceof GeometryProperty) {
tableHelper.getOrCreateImporter(GeometryPropertyImporter.class)
.doImport((GeometryProperty) property, parentId, rootId, featureId);
.doImport((GeometryProperty) property, parentId, featureId);
} else if (property instanceof ImplicitGeometryProperty) {
tableHelper.getOrCreateImporter(ImplicitGeometryPropertyImporter.class)
.doImport((ImplicitGeometryProperty) property, parentId, rootId, featureId);
.doImport((ImplicitGeometryProperty) property, parentId, featureId);
} else if (property instanceof AppearanceProperty) {
tableHelper.getOrCreateImporter(AppearancePropertyImporter.class)
.doImport((AppearanceProperty) property, parentId, rootId, featureId);
.doImport((AppearanceProperty) property, parentId, featureId);
} else if (property instanceof AddressProperty) {
tableHelper.getOrCreateImporter(AddressPropertyImporter.class)
.doImport((AddressProperty) property, parentId, rootId, featureId);
.doImport((AddressProperty) property, parentId, featureId);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,34 +44,34 @@ public FeaturePropertyImporter(ImportHelper helper) throws SQLException {
@Override
protected String getInsertStatement() {
return "insert into " + tableHelper.getPrefixedTableName(table) +
"(id, feature_id, parent_id, root_id, datatype_id, namespace_id, name, " +
"(id, feature_id, parent_id, datatype_id, namespace_id, name, " +
"val_feature_id, val_reference_type) " +
"values (" + String.join(",", Collections.nCopies(9, "?")) + ")";
"values (" + String.join(",", Collections.nCopies(8, "?")) + ")";
}

public PropertyDescriptor doImport(FeatureProperty property, long featureId) throws ImportException, SQLException {
long propertyId = nextSequenceValue(Sequence.PROPERTY);
return doImport(property, propertyId, propertyId, propertyId, featureId);
return doImport(property, propertyId, propertyId, featureId);
}

PropertyDescriptor doImport(FeatureProperty property, long parentId, long rootId, long featureId) throws ImportException, SQLException {
return doImport(property, nextSequenceValue(Sequence.PROPERTY), parentId, rootId, featureId);
PropertyDescriptor doImport(FeatureProperty property, long parentId, long featureId) throws ImportException, SQLException {
return doImport(property, nextSequenceValue(Sequence.PROPERTY), parentId, featureId);
}

private PropertyDescriptor doImport(FeatureProperty property, long propertyId, long parentId, long rootId, long featureId) throws ImportException, SQLException {
private PropertyDescriptor doImport(FeatureProperty property, long propertyId, long parentId, long featureId) throws ImportException, SQLException {
Feature feature = property.getObject().orElse(null);
if (feature != null) {
stmt.setLong(8, tableHelper.getOrCreateImporter(FeatureImporter.class)
stmt.setLong(7, tableHelper.getOrCreateImporter(FeatureImporter.class)
.doImport(feature)
.getId());
stmt.setNull(9, Types.INTEGER);
stmt.setNull(8, Types.INTEGER);
} else if (property.getReference().isPresent()) {
Reference reference = property.getReference().get();
cacheReference(CacheType.FEATURE, reference, propertyId);
stmt.setNull(8, Types.BIGINT);
stmt.setInt(9, reference.getType().getDatabaseValue());
stmt.setNull(7, Types.BIGINT);
stmt.setInt(8, reference.getType().getDatabaseValue());
}

return super.doImport(property, propertyId, parentId, rootId, featureId);
return super.doImport(property, propertyId, parentId, featureId);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,26 +40,26 @@ public GeometryPropertyImporter(ImportHelper helper) throws SQLException {
@Override
protected String getInsertStatement() {
return "insert into " + tableHelper.getPrefixedTableName(table) +
"(id, feature_id, parent_id, root_id, datatype_id, namespace_id, name, " +
"(id, feature_id, parent_id, datatype_id, namespace_id, name, " +
"val_lod, val_geometry_id) " +
"values (" + String.join(",", Collections.nCopies(9, "?")) + ")";
"values (" + String.join(",", Collections.nCopies(8, "?")) + ")";
}

public PropertyDescriptor doImport(GeometryProperty property, long featureId) throws ImportException, SQLException {
long propertyId = nextSequenceValue(Sequence.PROPERTY);
return doImport(property, propertyId, propertyId, propertyId, featureId);
return doImport(property, propertyId, propertyId, featureId);
}

PropertyDescriptor doImport(GeometryProperty property, long parentId, long rootId, long featureId) throws ImportException, SQLException {
return doImport(property, nextSequenceValue(Sequence.PROPERTY), parentId, rootId, featureId);
PropertyDescriptor doImport(GeometryProperty property, long parentId, long featureId) throws ImportException, SQLException {
return doImport(property, nextSequenceValue(Sequence.PROPERTY), parentId, featureId);
}

PropertyDescriptor doImport(GeometryProperty property, long propertyId, long parentId, long rootId, long featureId) throws ImportException, SQLException {
stmt.setString(8, property.getLod().orElse(null));
stmt.setLong(9, tableHelper.getOrCreateImporter(GeometryImporter.class)
PropertyDescriptor doImport(GeometryProperty property, long propertyId, long parentId, long featureId) throws ImportException, SQLException {
stmt.setString(7, property.getLod().orElse(null));
stmt.setLong(8, tableHelper.getOrCreateImporter(GeometryImporter.class)
.doImport(property.getObject(), false, featureId)
.getId());

return super.doImport(property, propertyId, parentId, rootId, featureId);
return super.doImport(property, propertyId, parentId, featureId);
}
}
Loading

0 comments on commit 1dadb91

Please sign in to comment.