Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/BRMO-352' into BRMO-352
Browse files Browse the repository at this point in the history
  • Loading branch information
geertoff committed Mar 28, 2024
2 parents a723a24 + e419f5d commit b42aea9
Show file tree
Hide file tree
Showing 23 changed files with 248 additions and 155 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,11 @@ private void parseAttribute(SMInputCursor attribute, Map<String, Object> objectA
case "gebruiksdoel":
parseGebruiksdoel(attribute, objectAttributes);
break;
case "geconstateerd":
// Parse 'J' or 'N' to 'true' or 'false'
String jn = attribute.collectDescendantText().trim();
objectAttributes.put(attributeName, "J".equals(jn) ? "true" : "false");
break;
default:
// String attribute value as default

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ private void deletePreviousVersion(BAG2Object object) throws Exception {
try {
AttributeColumnMapping mapping = objectType.getAttributeByName(pk.getName());
Object attribute = object.getAttributes().get(pk.getName());
return mapping.toQueryParameter(attribute);
return mapping.toQueryParameter(attribute, getDialect());
} catch (Exception e) {
throw new RuntimeException(e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ private static Stream<Arguments> testAllFeatureTypes() throws ParseException {
{"postcode", "9649BW"},
{"typeAdresseerbaarObject", "Verblijfsobject"},
{"status", "Naamgeving uitgegeven"},
{"geconstateerd", "N"},
{"geconstateerd", "false"},
{"documentdatum", "2010-04-20"},
{"documentnummer", "430-2010"},
{"voorkomenidentificatie", "1"},
Expand All @@ -228,7 +228,7 @@ private static Stream<Arguments> testAllFeatureTypes() throws ParseException {
{"postcode", "9902RM"},
{"typeAdresseerbaarObject", "Verblijfsobject"},
{"status", "Naamgeving uitgegeven"},
{"geconstateerd", "N"},
{"geconstateerd", "false"},
{"documentdatum", "2012-12-20"},
{"documentnummer", "A2012-WFS-007B"},
{"voorkomenidentificatie", "4"},
Expand Down Expand Up @@ -256,7 +256,7 @@ private static Stream<Arguments> testAllFeatureTypes() throws ParseException {
"POLYGON ((119965.936 495377.184, 119954.426 495373.197, 119956.133 495368.268, 119967.643 495372.255, 119965.936 495377.184))")
},
{"status", "Plaats aangewezen"},
{"geconstateerd", "N"},
{"geconstateerd", "false"},
{"documentdatum", "2009-09-15"},
{"documentnummer", "09-3972"},
{"voorkomenidentificatie", "1"},
Expand All @@ -278,7 +278,7 @@ private static Stream<Arguments> testAllFeatureTypes() throws ParseException {
},
{"identificatie", "0513020000000044"},
{"status", "Plaats aangewezen"},
{"geconstateerd", "N"},
{"geconstateerd", "false"},
{"documentdatum", "2013-09-16"},
{"documentnummer", "BAG108"},
{"voorkomenidentificatie", "2"},
Expand All @@ -301,7 +301,7 @@ private static Stream<Arguments> testAllFeatureTypes() throws ParseException {
"POLYGON ((104082.641 468561.449, 104085.394 468562.007, 104083.664 468570.233, 104080.91 468569.65, 104082.641 468561.449))")
},
{"status", "Plaats aangewezen"},
{"geconstateerd", "N"},
{"geconstateerd", "false"},
{"documentdatum", "2010-09-10"},
{"documentnummer", "10.13520"},
{"voorkomenidentificatie", "1"},
Expand All @@ -323,7 +323,7 @@ private static Stream<Arguments> testAllFeatureTypes() throws ParseException {
"POLYGON ((181055.997 560924.816, 181073.938 560930.19, 181066.477 560952.584, 181049.241 560947.355, 181055.997 560924.816))")
},
{"status", "Plaats aangewezen"},
{"geconstateerd", "N"},
{"geconstateerd", "false"},
{"documentdatum", "2014-07-10"},
{"documentnummer", "07.155.2 10-07-14SP1"},
{"voorkomenidentificatie", "1"},
Expand All @@ -349,7 +349,7 @@ private static Stream<Arguments> testAllFeatureTypes() throws ParseException {
},
{"naam", "Ter Heijde"},
{"status", "Woonplaats aangewezen"},
{"geconstateerd", "N"},
{"geconstateerd", "false"},
{"documentdatum", "2009-06-10"},
{"documentnummer", "09-0022652"},
{"voorkomenidentificatie", "1"},
Expand All @@ -369,7 +369,7 @@ private static Stream<Arguments> testAllFeatureTypes() throws ParseException {
{"ligtIn", "2278"},
{"type", "Weg"},
{"status", "Naamgeving uitgegeven"},
{"geconstateerd", "N"},
{"geconstateerd", "false"},
{"documentdatum", "2010-04-20"},
{"documentnummer", "437-2010"},
{"voorkomenidentificatie", "1"},
Expand All @@ -392,7 +392,7 @@ private static Stream<Arguments> testAllFeatureTypes() throws ParseException {
},
{"oorspronkelijkBouwjaar", "2012"},
{"status", "Pand gesloopt"},
{"geconstateerd", "N"},
{"geconstateerd", "false"},
{"documentdatum", "2021-01-18"},
{"documentnummer", "D2021-01-002570"},
{"voorkomenidentificatie", "2"},
Expand All @@ -413,7 +413,7 @@ private static Stream<Arguments> testAllFeatureTypes() throws ParseException {
{"gebruiksdoel", Stream.of("woonfunctie").collect(Collectors.toSet())},
{"maaktDeelUitVan", Stream.of("1883100000010452").collect(Collectors.toSet())},
{"oppervlakte", "72"},
{"geconstateerd", "N"},
{"geconstateerd", "false"},
{"documentdatum", "2018-03-26"},
{"documentnummer", "BV05.00043-HLG"},
{"voorkomenidentificatie", "1"},
Expand All @@ -435,7 +435,7 @@ private static Stream<Arguments> testAllFeatureTypes() throws ParseException {
},
{"maaktDeelUitVan", Stream.of("0003100000118445").collect(Collectors.toSet())},
{"oppervlakte", "141"},
{"geconstateerd", "J"},
{"geconstateerd", "true"},
{"documentdatum", "2011-07-15"},
{"documentnummer", "2011/APVC001"},
{"voorkomenidentificatie", "2"},
Expand All @@ -455,7 +455,7 @@ private static Stream<Arguments> testAllFeatureTypes() throws ParseException {
{"gebruiksdoel", Stream.of("industriefunctie").collect(Collectors.toSet())},
{"maaktDeelUitVan", Stream.of("0010100000006543").collect(Collectors.toSet())},
{"oppervlakte", "3651"},
{"geconstateerd", "N"},
{"geconstateerd", "false"},
{"documentdatum", "2021-04-09"},
{"documentnummer", "E2021-BNU-086"},
{"voorkomenidentificatie", "4"},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
<null/>
<value><![CDATA[2010-09-21 00:00:00.0]]></value>
<value>AVGpvdb02</value>
<value>0</value>
<value>false</value>
<value><![CDATA[Woonplaats aangewezen]]></value>
<value>NIEUWKUIJK</value>
</row>
Expand All @@ -49,7 +49,7 @@
<null/>
<value><![CDATA[2011-09-01 00:00:00.0]]></value>
<value>AVGEL01092011-04</value>
<value>0</value>
<value>false</value>
<value><![CDATA[Woonplaats aangewezen]]></value>
<value>Nieuwkuijk</value>
</row>
Expand All @@ -67,7 +67,7 @@
<null/>
<value><![CDATA[2011-10-05 00:00:00.0]]></value>
<value>AVGSK05102011-01</value>
<value>0</value>
<value>false</value>
<value><![CDATA[Woonplaats aangewezen]]></value>
<value>Nieuwkuijk</value>
</row>
Expand All @@ -85,7 +85,7 @@
<null/>
<value><![CDATA[2022-05-23 00:00:00.0]]></value>
<value>2068944</value>
<value>0</value>
<value>false</value>
<value><![CDATA[Woonplaats aangewezen]]></value>
<value>Nieuwkuijk</value>
</row>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
<null/>
<value><![CDATA[2010-09-21 00:00:00.0]]></value>
<value>AVGpvdb02</value>
<value>0</value>
<value>false</value>
<value><![CDATA[Woonplaats aangewezen]]></value>
<value>NIEUWKUIJK</value>
</row>
Expand All @@ -49,7 +49,7 @@
<null/>
<value><![CDATA[2011-09-01 00:00:00.0]]></value>
<value>AVGEL01092011-04</value>
<value>0</value>
<value>false</value>
<value><![CDATA[Woonplaats aangewezen]]></value>
<value>Nieuwkuijk</value>
</row>
Expand All @@ -67,7 +67,7 @@
<null/>
<value><![CDATA[2011-10-05 00:00:00.0]]></value>
<value>AVGSK05102011-01</value>
<value>0</value>
<value>false</value>
<value><![CDATA[Woonplaats aangewezen]]></value>
<value>Nieuwkuijk</value>
</row>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ private void addObjectToBatch(SchemaObjectInstance object, boolean fromWorkerThr
for (AttributeColumnMapping attributeColumnMapping :
object.getObjectType().getDirectNonDefaultInsertAttributes()) {
Object attribute = attributes.get(attributeColumnMapping.getName());
params.add(attributeColumnMapping.toQueryParameter(attribute));
params.add(attributeColumnMapping.toQueryParameter(attribute, getDialect()));
}

// The main object batch must be executed before oneToMany and arrayAttribute batches which
Expand Down Expand Up @@ -430,7 +430,7 @@ private void insertArrayAttribute(SchemaObjectInstance object, ArrayAttributeMap
.map(
key -> {
try {
return key.toQueryParameter(object.getAttributes().get(key.getName()));
return key.toQueryParameter(object.getAttributes().get(key.getName()), getDialect());
} catch (Exception e) {
throw new RuntimeException(e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

package nl.b3p.brmo.schema.mapping;

import nl.b3p.brmo.sql.dialect.SQLDialect;

public class AttributeColumnMapping {
private final String name;
private final String type;
Expand Down Expand Up @@ -62,7 +64,7 @@ public boolean isDirectNonDefaultAttribute() {
return isDirectAttribute() && !isUseDefault();
}

public Object toQueryParameter(Object value) throws Exception {
public Object toQueryParameter(Object value, SQLDialect sqlDialect) throws Exception {
if (value == null) {
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@

package nl.b3p.brmo.schema.mapping;

import nl.b3p.brmo.sql.dialect.OracleDialect;
import nl.b3p.brmo.sql.dialect.SQLDialect;

public class BooleanAttributeColumnMapping extends AttributeColumnMapping {
public BooleanAttributeColumnMapping(String name, boolean notNull) {
super(name, "boolean", notNull, false);
Expand All @@ -16,11 +19,16 @@ public BooleanAttributeColumnMapping(String name) {
}

@Override
public Object toQueryParameter(Object value) {
if (value == null) {
return null;
public Object toQueryParameter(Object value, SQLDialect sqlDialect) throws Exception {
if (sqlDialect instanceof OracleDialect) {
// Use default string to have 'true' and 'false' in nvarchar2(5) column
return super.toQueryParameter(value, sqlDialect);
} else {
return Boolean.parseBoolean(value.toString());
if (value == null) {
return null;
} else {
return Boolean.parseBoolean(value.toString());
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

package nl.b3p.brmo.schema.mapping;

import nl.b3p.brmo.sql.dialect.SQLDialect;

public class DoubleAttributeColumnMapping extends AttributeColumnMapping {

public DoubleAttributeColumnMapping(String name, boolean notNull) {
Expand All @@ -17,7 +19,7 @@ public DoubleAttributeColumnMapping(String name) {
}

@Override
public Object toQueryParameter(Object value) {
public Object toQueryParameter(Object value, SQLDialect sqlDialect) {
if (value == null) {
return null;
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

package nl.b3p.brmo.schema.mapping;

import nl.b3p.brmo.sql.dialect.SQLDialect;
import org.locationtech.jts.geom.Geometry;

public class GeometryAttributeColumnMapping extends AttributeColumnMapping {
Expand All @@ -19,7 +20,7 @@ public GeometryAttributeColumnMapping(String name) {
}

@Override
public Geometry toQueryParameter(Object value) {
public Geometry toQueryParameter(Object value, SQLDialect sqlDialect) {
return (Geometry) value;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

package nl.b3p.brmo.schema.mapping;

import nl.b3p.brmo.sql.dialect.SQLDialect;

public class IntegerAttributeColumnMapping extends AttributeColumnMapping {
public IntegerAttributeColumnMapping(String name, boolean notNull, boolean primaryKey) {
super(name, "integer", notNull, primaryKey);
Expand All @@ -20,7 +22,7 @@ public IntegerAttributeColumnMapping(String name) {
}

@Override
public Object toQueryParameter(Object value) {
public Object toQueryParameter(Object value, SQLDialect sqlDialect) {
if (value == null) {
return null;
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

package nl.b3p.brmo.schema.mapping;

import nl.b3p.brmo.sql.dialect.SQLDialect;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
Expand Down Expand Up @@ -33,7 +35,7 @@ public SimpleDateFormatAttributeColumnMapping(
}

@Override
public Object toQueryParameter(Object value) throws ParseException {
public Object toQueryParameter(Object value, SQLDialect sqlDialect) throws ParseException {
if (value == null) {
return null;
} else {
Expand Down
Loading

0 comments on commit b42aea9

Please sign in to comment.