use of ch.interlis.ili2c.metamodel.SurfaceOrAreaType in project ili2db by claeis.
the class TransferToXtf method dumpItfTableObject.
private void dumpItfTableObject(IoxWriter out, AttributeDef attr, Long basketSqlId) {
String stmt = createItfLineTableQueryStmt(attr, basketSqlId, geomConv);
String sqlTabName = ili2sqlName.mapGeometryAsTable(attr);
EhiLogger.traceBackendCmd(stmt);
SurfaceOrAreaType type = (SurfaceOrAreaType) attr.getDomainResolvingAliases();
String geomAttrName = ch.interlis.iom_j.itf.ModelUtilities.getHelperTableGeomAttrName(attr);
String refAttrName = null;
if (type instanceof SurfaceType) {
refAttrName = ch.interlis.iom_j.itf.ModelUtilities.getHelperTableMainTableRef(attr);
}
java.sql.PreparedStatement dbstmt = null;
try {
dbstmt = conn.prepareStatement(stmt);
dbstmt.clearParameters();
int paramIdx = 1;
if (basketSqlId != null) {
dbstmt.setLong(paramIdx++, basketSqlId);
}
java.sql.ResultSet rs = dbstmt.executeQuery();
while (rs.next()) {
int valuei = 1;
long sqlid = rs.getLong(valuei);
valuei++;
String sqlIliTid = null;
if (writeIliTid) {
sqlIliTid = rs.getString(valuei);
valuei++;
} else {
sqlIliTid = Long.toString(sqlid);
}
Viewable aclass = (Viewable) attr.getContainer();
Iom_jObject iomObj;
iomObj = new Iom_jObject(aclass.getScopedName(null) + "_" + attr.getName(), sqlIliTid);
// geomAttr
Object geomobj = rs.getObject(valuei);
valuei++;
if (!rs.wasNull()) {
try {
boolean is3D = false;
IomObject polyline = geomConv.toIomPolyline(geomobj, ili2sqlName.getSqlColNameItfLineTableGeomAttr(attr, sqlTabName), is3D);
iomObj.addattrobj(geomAttrName, polyline);
} catch (ConverterException ex) {
EhiLogger.logError("Object " + sqlid + ": failed to convert polyline", ex);
}
}
// is of type SURFACE?
if (type instanceof SurfaceType) {
// -> mainTable
IomObject ref = iomObj.addattrobj(refAttrName, "REF");
long refSqlId = rs.getLong(valuei);
if (sqlidPool.containsSqlid(refSqlId)) {
String refTid = sqlidPool.getXtfid(refSqlId);
ref.setobjectrefoid(refTid);
} else {
EhiLogger.logError("unknown referenced object " + attr.getContainer().getScopedName(null) + " sqlid " + refSqlId + " referenced from " + sqlTabName + " " + colT_ID + " " + sqlid);
}
valuei++;
}
Table lineAttrTable = type.getLineAttributeStructure();
if (lineAttrTable != null) {
Iterator attri = lineAttrTable.getAttributes();
while (attri.hasNext()) {
AttributeDef lineattr = (AttributeDef) attri.next();
valuei = recConv.addAttrValue(rs, valuei, sqlid, iomObj, lineattr, null, class2wrapper.get(lineAttrTable), null);
}
}
if (out != null) {
// write object
ObjectEvent objEvent = new ObjectEvent(iomObj);
if (languageFilter != null) {
objEvent = (ObjectEvent) languageFilter.filter(objEvent);
}
if (exportBaseModelFilter != null) {
objEvent = (ObjectEvent) exportBaseModelFilter.filter(objEvent);
}
if (validator != null)
validator.validate(objEvent);
out.write(objEvent);
}
}
} catch (java.sql.SQLException ex) {
EhiLogger.logError("failed to query " + attr.getScopedName(null), ex);
} catch (ch.interlis.iox.IoxException ex) {
EhiLogger.logError("failed to write " + attr.getScopedName(null), ex);
} finally {
if (dbstmt != null) {
try {
dbstmt.close();
} catch (java.sql.SQLException ex) {
EhiLogger.logError("failed to close query of " + attr.getScopedName(null), ex);
}
}
}
}
use of ch.interlis.ili2c.metamodel.SurfaceOrAreaType in project ili2db by claeis.
the class FromXtfRecordConverter method addAttrValue.
public int addAttrValue(IomObject iomObj, String sqlType, long sqlId, String sqlTableName, PreparedStatement ps, int valuei, AttributeDef attr, ArrayList structQueue) throws SQLException, ConverterException {
if (attr.getExtending() == null) {
String attrName = attr.getName();
if (attr.isDomainBoolean()) {
String value = iomObj.getattrvalue(attrName);
if (value != null) {
if (value.equals("true")) {
geomConv.setBoolean(ps, valuei, true);
} else {
geomConv.setBoolean(ps, valuei, false);
}
} else {
ps.setNull(valuei, Types.BIT);
}
valuei++;
} else if (attr.isDomainIliUuid()) {
String value = iomObj.getattrvalue(attrName);
if (value == null) {
geomConv.setUuidNull(ps, valuei);
} else {
Object toInsertUUID = geomConv.fromIomUuid(value);
ps.setObject(valuei, toInsertUUID);
}
valuei++;
} else if (attr.isDomainIli1Date()) {
String value = iomObj.getattrvalue(attrName);
if (value != null) {
GregorianCalendar gdate = new GregorianCalendar(Integer.parseInt(value.substring(0, 4)), Integer.parseInt(value.substring(4, 6)) - 1, Integer.parseInt(value.substring(6, 8)));
java.sql.Date date = new java.sql.Date(gdate.getTimeInMillis());
geomConv.setDate(ps, valuei, date);
} else {
ps.setNull(valuei, Types.DATE);
}
valuei++;
} else if (attr.isDomainIli2Date()) {
String value = iomObj.getattrvalue(attrName);
if (value != null) {
XMLGregorianCalendar xmldate;
try {
xmldate = javax.xml.datatype.DatatypeFactory.newInstance().newXMLGregorianCalendar(value);
} catch (DatatypeConfigurationException e) {
throw new ConverterException(e);
}
java.sql.Date date = new java.sql.Date(xmldate.toGregorianCalendar().getTimeInMillis());
geomConv.setDate(ps, valuei, date);
} else {
ps.setNull(valuei, Types.DATE);
}
valuei++;
} else if (attr.isDomainIli2Time()) {
String value = iomObj.getattrvalue(attrName);
if (value != null) {
XMLGregorianCalendar xmldate;
try {
xmldate = javax.xml.datatype.DatatypeFactory.newInstance().newXMLGregorianCalendar(value);
} catch (DatatypeConfigurationException e) {
throw new ConverterException(e);
}
java.sql.Time time = new java.sql.Time(xmldate.toGregorianCalendar().getTimeInMillis());
geomConv.setTime(ps, valuei, time);
} else {
ps.setNull(valuei, Types.TIME);
}
valuei++;
} else if (attr.isDomainIli2DateTime()) {
String value = iomObj.getattrvalue(attrName);
if (value != null) {
XMLGregorianCalendar xmldate;
try {
xmldate = javax.xml.datatype.DatatypeFactory.newInstance().newXMLGregorianCalendar(value);
} catch (DatatypeConfigurationException e) {
throw new ConverterException(e);
}
java.sql.Timestamp datetime = new java.sql.Timestamp(xmldate.toGregorianCalendar().getTimeInMillis());
geomConv.setTimestamp(ps, valuei, datetime);
} else {
ps.setNull(valuei, Types.TIMESTAMP);
}
valuei++;
} else {
Type type = attr.getDomainResolvingAliases();
if (type instanceof CompositionType) {
int structc = iomObj.getattrvaluecount(attrName);
if (TrafoConfigNames.CATALOGUE_REF_TRAFO_COALESCE.equals(trafoConfig.getAttrConfig(attr, TrafoConfigNames.CATALOGUE_REF_TRAFO))) {
IomObject catref = iomObj.getattrobj(attrName, 0);
String refoid = null;
if (catref != null) {
IomObject structvalue = catref.getattrobj(IliNames.CHBASE1_CATALOGUEREFERENCE_REFERENCE, 0);
if (structvalue != null) {
refoid = structvalue.getobjectrefoid();
}
}
if (refoid != null) {
String targetClassName = IliNames.CHBASE1_CATALOGUES_ITEM;
long refsqlId = oidPool.getObjSqlId(targetClassName, refoid);
ps.setLong(valuei, refsqlId);
} else {
ps.setNull(valuei, Types.BIGINT);
}
valuei++;
} else if (TrafoConfigNames.MULTISURFACE_TRAFO_COALESCE.equals(trafoConfig.getAttrConfig(attr, TrafoConfigNames.MULTISURFACE_TRAFO))) {
IomObject iomValue = iomObj.getattrobj(attrName, 0);
IomObject iomMultisurface = null;
MultiSurfaceMapping attrMapping = null;
if (iomValue != null) {
attrMapping = multiSurfaceAttrs.getMapping(attr);
int surfacec = iomValue.getattrvaluecount(attrMapping.getBagOfSurfacesAttrName());
for (int surfacei = 0; surfacei < surfacec; surfacei++) {
IomObject iomSurfaceStructure = iomValue.getattrobj(attrMapping.getBagOfSurfacesAttrName(), surfacei);
IomObject iomPoly = iomSurfaceStructure.getattrobj(attrMapping.getSurfaceAttrName(), 0);
IomObject iomSurface = iomPoly.getattrobj("surface", 0);
if (iomMultisurface == null) {
iomMultisurface = new ch.interlis.iom_j.Iom_jObject("MULTISURFACE", null);
}
iomMultisurface.addattrobj("surface", iomSurface);
}
}
if (iomMultisurface != null) {
AttributeDef surfaceAttr = getMultiSurfaceAttrDef(type, attrMapping);
SurfaceType surface = ((SurfaceType) surfaceAttr.getDomainResolvingAliases());
CoordType coord = (CoordType) surface.getControlPointDomain().getType();
boolean is3D = coord.getDimensions().length == 3;
Object geomObj = geomConv.fromIomMultiSurface(iomMultisurface, getSrsid(surfaceAttr), surface.getLineAttributeStructure() != null, is3D, getP(surface));
ps.setObject(valuei, geomObj);
} else {
geomConv.setSurfaceNull(ps, valuei);
}
valuei++;
} else if (TrafoConfigNames.MULTILINE_TRAFO_COALESCE.equals(trafoConfig.getAttrConfig(attr, TrafoConfigNames.MULTILINE_TRAFO))) {
IomObject iomValue = iomObj.getattrobj(attrName, 0);
IomObject iomMultiline = null;
MultiLineMapping attrMapping = null;
if (iomValue != null) {
attrMapping = multiLineAttrs.getMapping(attr);
int polylinec = iomValue.getattrvaluecount(attrMapping.getBagOfLinesAttrName());
for (int polylinei = 0; polylinei < polylinec; polylinei++) {
IomObject iomPolylineStructure = iomValue.getattrobj(attrMapping.getBagOfLinesAttrName(), polylinei);
IomObject iomPoly = iomPolylineStructure.getattrobj(attrMapping.getLineAttrName(), 0);
if (iomMultiline == null) {
iomMultiline = new ch.interlis.iom_j.Iom_jObject(Wkb2iox.OBJ_MULTIPOLYLINE, null);
}
iomMultiline.addattrobj(Wkb2iox.ATTR_POLYLINE, iomPoly);
}
}
if (iomMultiline != null) {
AttributeDef polylineAttr = getMultiLineAttrDef(type, attrMapping);
PolylineType line = ((PolylineType) polylineAttr.getDomainResolvingAliases());
CoordType coord = (CoordType) line.getControlPointDomain().getType();
boolean is3D = coord.getDimensions().length == 3;
Object geomObj = geomConv.fromIomMultiPolyline(iomMultiline, getSrsid(polylineAttr), is3D, getP(line));
ps.setObject(valuei, geomObj);
} else {
geomConv.setPolylineNull(ps, valuei);
}
valuei++;
} else if (TrafoConfigNames.MULTIPOINT_TRAFO_COALESCE.equals(trafoConfig.getAttrConfig(attr, TrafoConfigNames.MULTIPOINT_TRAFO))) {
IomObject iomValue = iomObj.getattrobj(attrName, 0);
IomObject iomMultipoint = null;
MultiPointMapping attrMapping = null;
if (iomValue != null) {
attrMapping = multiPointAttrs.getMapping(attr);
int pointc = iomValue.getattrvaluecount(attrMapping.getBagOfPointsAttrName());
for (int pointi = 0; pointi < pointc; pointi++) {
IomObject iomPointStructure = iomValue.getattrobj(attrMapping.getBagOfPointsAttrName(), pointi);
IomObject iomPoint = iomPointStructure.getattrobj(attrMapping.getPointAttrName(), 0);
if (iomMultipoint == null) {
iomMultipoint = new ch.interlis.iom_j.Iom_jObject(Wkb2iox.OBJ_MULTIPOINT, null);
}
iomMultipoint.addattrobj(Wkb2iox.ATTR_COORD, iomPoint);
}
}
if (iomMultipoint != null) {
AttributeDef coordAttr = getMultiPointAttrDef(type, attrMapping);
CoordType coord = ((CoordType) coordAttr.getDomainResolvingAliases());
boolean is3D = coord.getDimensions().length == 3;
Object geomObj = geomConv.fromIomMultiCoord(iomMultipoint, getSrsid(coordAttr), is3D);
ps.setObject(valuei, geomObj);
} else {
geomConv.setCoordNull(ps, valuei);
}
valuei++;
} else if (TrafoConfigNames.ARRAY_TRAFO_COALESCE.equals(trafoConfig.getAttrConfig(attr, TrafoConfigNames.ARRAY_TRAFO))) {
int valuec = iomObj.getattrvaluecount(attrName);
String[] iomArray = new String[valuec];
ArrayMapping attrMapping = arrayAttrs.getMapping(attr);
for (int elei = 0; elei < valuec; elei++) {
IomObject iomValue = iomObj.getattrobj(attrName, elei);
String value = iomValue.getattrvalue(attrMapping.getValueAttr().getName());
iomArray[elei] = value;
}
if (iomArray.length > 0) {
Object geomObj = geomConv.fromIomArray(attrMapping.getValueAttr(), iomArray, enumTypes);
ps.setObject(valuei, geomObj);
} else {
geomConv.setArrayNull(ps, valuei);
}
valuei++;
} else if (TrafoConfigNames.MULTILINGUAL_TRAFO_EXPAND.equals(trafoConfig.getAttrConfig(attr, TrafoConfigNames.MULTILINGUAL_TRAFO))) {
IomObject iomMulti = iomObj.getattrobj(attrName, 0);
for (String sfx : DbNames.MULTILINGUAL_TXT_COL_SUFFIXS) {
if (iomMulti != null) {
String value = getMultilingualText(iomMulti, sfx);
if (value != null) {
ps.setString(valuei, value);
} else {
ps.setNull(valuei, Types.VARCHAR);
}
} else {
ps.setNull(valuei, Types.VARCHAR);
}
valuei++;
}
} else {
// enqueue struct values
for (int structi = 0; structi < structc; structi++) {
IomObject struct = iomObj.getattrobj(attrName, structi);
String sqlAttrName = ili2sqlName.mapIliAttributeDef(attr, sqlTableName, null);
enqueStructValue(structQueue, sqlId, sqlType, sqlAttrName, struct, structi, attr);
}
}
} else if (type instanceof PolylineType) {
IomObject value = iomObj.getattrobj(attrName, 0);
if (value != null) {
boolean is3D = ((CoordType) ((PolylineType) type).getControlPointDomain().getType()).getDimensions().length == 3;
ps.setObject(valuei, geomConv.fromIomPolyline(value, getSrsid(attr), is3D, getP((PolylineType) type)));
} else {
geomConv.setPolylineNull(ps, valuei);
}
valuei++;
} else if (type instanceof SurfaceOrAreaType) {
if (createItfLineTables) {
} else {
IomObject value = iomObj.getattrobj(attrName, 0);
if (value != null) {
boolean is3D = ((CoordType) ((SurfaceOrAreaType) type).getControlPointDomain().getType()).getDimensions().length == 3;
Object geomObj = geomConv.fromIomSurface(value, getSrsid(attr), ((SurfaceOrAreaType) type).getLineAttributeStructure() != null, is3D, getP((SurfaceOrAreaType) type));
ps.setObject(valuei, geomObj);
} else {
geomConv.setSurfaceNull(ps, valuei);
}
valuei++;
}
if (createItfAreaRef) {
if (type instanceof AreaType) {
IomObject value = null;
if (isItfReader) {
value = iomObj.getattrobj(attrName, 0);
} else {
value = iomObj.getattrobj(ItfReader2.SAVED_GEOREF_PREFIX + attrName, 0);
}
if (value != null) {
boolean is3D = ((CoordType) ((SurfaceOrAreaType) type).getControlPointDomain().getType()).getDimensions().length == 3;
ps.setObject(valuei, geomConv.fromIomCoord(value, getSrsid(attr), is3D));
} else {
geomConv.setCoordNull(ps, valuei);
}
valuei++;
}
}
} else if (type instanceof CoordType) {
IomObject value = iomObj.getattrobj(attrName, 0);
if (value != null) {
boolean is3D = ((CoordType) type).getDimensions().length == 3;
ps.setObject(valuei, geomConv.fromIomCoord(value, getSrsid(attr), is3D));
} else {
geomConv.setCoordNull(ps, valuei);
}
valuei++;
} else if (type instanceof NumericType) {
String value = iomObj.getattrvalue(attrName);
if (type.isAbstract()) {
} else {
PrecisionDecimal min = ((NumericType) type).getMinimum();
PrecisionDecimal max = ((NumericType) type).getMaximum();
if (min.getAccuracy() > 0) {
if (value != null) {
try {
ps.setDouble(valuei, Double.parseDouble(value));
} catch (java.lang.NumberFormatException ex) {
EhiLogger.logError(ex);
}
} else {
geomConv.setDecimalNull(ps, valuei);
}
} else {
if (value != null) {
try {
int val = (int) Math.round(Double.parseDouble(value));
ps.setInt(valuei, val);
} catch (java.lang.NumberFormatException ex) {
EhiLogger.logError(ex);
}
} else {
ps.setNull(valuei, Types.INTEGER);
}
}
valuei++;
}
} else if (type instanceof EnumerationType) {
String value = iomObj.getattrvalue(attrName);
if (createEnumColAsItfCode) {
if (value != null) {
int itfCode = mapXtfCode2ItfCode((EnumerationType) type, value);
ps.setInt(valuei, itfCode);
} else {
ps.setNull(valuei, Types.INTEGER);
}
} else {
if (value != null) {
ps.setString(valuei, value);
} else {
ps.setNull(valuei, Types.VARCHAR);
}
}
valuei++;
if (createEnumTxtCol) {
if (value != null) {
ps.setString(valuei, beautifyEnumDispName(value));
} else {
ps.setNull(valuei, Types.VARCHAR);
}
valuei++;
}
} else if (type instanceof ReferenceType) {
IomObject structvalue = iomObj.getattrobj(attrName, 0);
String refoid = null;
if (structvalue != null) {
refoid = structvalue.getobjectrefoid();
}
Holder<Integer> valueiRef = new Holder<Integer>(valuei);
setReferenceColumn(ps, ((ReferenceType) type).getReferred(), refoid, valueiRef);
valuei = valueiRef.value;
} else if (type instanceof BlackboxType) {
String value = iomObj.getattrvalue(attrName);
if (((BlackboxType) type).getKind() == BlackboxType.eXML) {
if (value == null) {
geomConv.setXmlNull(ps, valuei);
} else {
Object toInsertXml = geomConv.fromIomXml(value);
ps.setObject(valuei, toInsertXml);
}
valuei++;
} else {
if (value == null) {
geomConv.setBlobNull(ps, valuei);
} else {
Object toInsertBlob = geomConv.fromIomBlob(value);
ps.setObject(valuei, toInsertBlob);
}
valuei++;
}
} else {
String value = iomObj.getattrvalue(attrName);
if (value != null) {
ps.setString(valuei, value);
} else {
ps.setNull(valuei, Types.VARCHAR);
}
valuei++;
}
}
}
return valuei;
}
use of ch.interlis.ili2c.metamodel.SurfaceOrAreaType in project ili2db by claeis.
the class FromXtfRecordConverter method addAttrToInsertStmt.
public String addAttrToInsertStmt(boolean isUpdate, StringBuffer ret, StringBuffer values, String sep, AttributeDef attr, String sqlTableName) {
if (attr.getExtending() == null) {
Type type = attr.getDomainResolvingAliases();
String attrSqlName = ili2sqlName.mapIliAttributeDef(attr, sqlTableName, null);
if (attr.isDomainBoolean()) {
ret.append(sep);
ret.append(attrSqlName);
if (isUpdate) {
ret.append("=?");
} else {
values.append(",?");
}
sep = ",";
} else if (type instanceof CompositionType) {
if (TrafoConfigNames.CATALOGUE_REF_TRAFO_COALESCE.equals(trafoConfig.getAttrConfig(attr, TrafoConfigNames.CATALOGUE_REF_TRAFO))) {
ret.append(sep);
ret.append(attrSqlName);
if (isUpdate) {
ret.append("=?");
} else {
values.append(",?");
}
sep = ",";
} else if (TrafoConfigNames.MULTISURFACE_TRAFO_COALESCE.equals(trafoConfig.getAttrConfig(attr, TrafoConfigNames.MULTISURFACE_TRAFO))) {
ret.append(sep);
ret.append(attrSqlName);
multiSurfaceAttrs.addMultiSurfaceAttr(attr);
int srsid = getSrsid(getMultiSurfaceAttrDef(type, multiSurfaceAttrs.getMapping(attr)));
if (isUpdate) {
ret.append("=" + geomConv.getInsertValueWrapperMultiSurface("?", srsid));
} else {
values.append("," + geomConv.getInsertValueWrapperMultiSurface("?", srsid));
}
sep = ",";
} else if (TrafoConfigNames.MULTILINE_TRAFO_COALESCE.equals(trafoConfig.getAttrConfig(attr, TrafoConfigNames.MULTILINE_TRAFO))) {
ret.append(sep);
ret.append(attrSqlName);
multiLineAttrs.addMultiLineAttr(attr);
int srsid = getSrsid(getMultiLineAttrDef(type, multiLineAttrs.getMapping(attr)));
if (isUpdate) {
ret.append("=" + geomConv.getInsertValueWrapperMultiPolyline("?", srsid));
} else {
values.append("," + geomConv.getInsertValueWrapperMultiPolyline("?", srsid));
}
sep = ",";
} else if (TrafoConfigNames.MULTIPOINT_TRAFO_COALESCE.equals(trafoConfig.getAttrConfig(attr, TrafoConfigNames.MULTIPOINT_TRAFO))) {
ret.append(sep);
ret.append(attrSqlName);
multiPointAttrs.addMultiPointAttr(attr);
int srsid = getSrsid(getMultiPointAttrDef(type, multiPointAttrs.getMapping(attr)));
if (isUpdate) {
ret.append("=" + geomConv.getInsertValueWrapperMultiCoord("?", srsid));
} else {
values.append("," + geomConv.getInsertValueWrapperMultiCoord("?", srsid));
}
sep = ",";
} else if (TrafoConfigNames.ARRAY_TRAFO_COALESCE.equals(trafoConfig.getAttrConfig(attr, TrafoConfigNames.ARRAY_TRAFO))) {
ret.append(sep);
ret.append(attrSqlName);
arrayAttrs.addArrayAttr(attr);
if (isUpdate) {
ret.append("=" + geomConv.getInsertValueWrapperArray("?"));
} else {
values.append("," + geomConv.getInsertValueWrapperArray("?"));
}
sep = ",";
} else if (TrafoConfigNames.MULTILINGUAL_TRAFO_EXPAND.equals(trafoConfig.getAttrConfig(attr, TrafoConfigNames.MULTILINGUAL_TRAFO))) {
for (String sfx : DbNames.MULTILINGUAL_TXT_COL_SUFFIXS) {
ret.append(sep);
ret.append(attrSqlName + sfx);
if (isUpdate) {
ret.append("=?");
} else {
values.append(",?");
}
sep = ",";
}
}
} else if (type instanceof PolylineType) {
ret.append(sep);
ret.append(attrSqlName);
if (isUpdate) {
ret.append("=" + geomConv.getInsertValueWrapperPolyline("?", getSrsid(attr)));
} else {
values.append("," + geomConv.getInsertValueWrapperPolyline("?", getSrsid(attr)));
}
sep = ",";
} else if (type instanceof SurfaceOrAreaType) {
if (createItfLineTables) {
} else {
ret.append(sep);
ret.append(attrSqlName);
if (isUpdate) {
ret.append("=" + geomConv.getInsertValueWrapperSurface("?", getSrsid(attr)));
} else {
values.append("," + geomConv.getInsertValueWrapperSurface("?", getSrsid(attr)));
}
sep = ",";
}
if (createItfAreaRef) {
if (type instanceof AreaType) {
ret.append(sep);
ret.append(attrSqlName + DbNames.ITF_MAINTABLE_GEOTABLEREF_COL_SUFFIX);
if (isUpdate) {
ret.append("=" + geomConv.getInsertValueWrapperCoord("?", getSrsid(attr)));
} else {
values.append("," + geomConv.getInsertValueWrapperCoord("?", getSrsid(attr)));
}
sep = ",";
}
}
} else if (type instanceof CoordType) {
ret.append(sep);
ret.append(attrSqlName);
if (isUpdate) {
ret.append("=" + geomConv.getInsertValueWrapperCoord("?", getSrsid(attr)));
} else {
values.append("," + geomConv.getInsertValueWrapperCoord("?", getSrsid(attr)));
}
sep = ",";
} else if (type instanceof EnumerationType) {
ret.append(sep);
ret.append(attrSqlName);
if (isUpdate) {
ret.append("=?");
} else {
values.append(",?");
}
sep = ",";
if (createEnumTxtCol) {
ret.append(sep);
ret.append(attrSqlName + DbNames.ENUM_TXT_COL_SUFFIX);
if (isUpdate) {
ret.append("=?");
} else {
values.append(",?");
}
sep = ",";
}
} else if (type instanceof ReferenceType) {
ArrayList<ViewableWrapper> targetTables = getTargetTables(((ReferenceType) type).getReferred());
for (ViewableWrapper targetTable : targetTables) {
attrSqlName = ili2sqlName.mapIliAttributeDef(attr, sqlTableName, targetTable.getSqlTablename(), targetTables.size() > 1);
ret.append(sep);
ret.append(attrSqlName);
if (isUpdate) {
ret.append("=?");
} else {
values.append(",?");
}
sep = ",";
}
} else {
ret.append(sep);
ret.append(attrSqlName);
if (isUpdate) {
ret.append("=?");
} else {
values.append(",?");
}
sep = ",";
}
}
return sep;
}
use of ch.interlis.ili2c.metamodel.SurfaceOrAreaType in project ili2db by claeis.
the class TransferFromXtf method createItfLineTableInsertStmt.
private String createItfLineTableInsertStmt(AttributeDef attrDef) {
SurfaceOrAreaType type = (SurfaceOrAreaType) attrDef.getDomainResolvingAliases();
StringBuffer stmt = new StringBuffer();
StringBuffer values = new StringBuffer();
stmt.append("INSERT INTO ");
DbTableName sqlTabName = getSqlTableNameItfLineTable(attrDef);
stmt.append(sqlTabName.getQName());
String sep = " (";
// add T_Id
stmt.append(sep);
sep = ",";
stmt.append(colT_ID);
values.append("?");
// add T_basket
if (createBasketCol) {
stmt.append(sep);
sep = ",";
stmt.append(DbNames.T_BASKET_COL);
values.append(",?");
}
if (createDatasetCol) {
stmt.append(sep);
sep = ",";
stmt.append(DbNames.T_DATASET_COL);
values.append(",?");
}
if (readIliTid) {
stmt.append(sep);
sep = ",";
stmt.append(DbNames.T_ILI_TID_COL);
values.append(",?");
}
// POLYLINE
stmt.append(sep);
sep = ",";
stmt.append(ili2sqlName.getSqlColNameItfLineTableGeomAttr(attrDef, sqlTabName.getName()));
values.append("," + geomConv.getInsertValueWrapperPolyline("?", recConv.getSrsid(attrDef)));
// -> mainTable
if (type instanceof SurfaceType) {
stmt.append(sep);
sep = ",";
stmt.append(ili2sqlName.getSqlColNameItfLineTableRefAttr(attrDef, sqlTabName.getName()));
values.append(",?");
}
Table lineAttrTable = type.getLineAttributeStructure();
if (lineAttrTable != null) {
Iterator attri = lineAttrTable.getAttributes();
while (attri.hasNext()) {
AttributeDef lineattr = (AttributeDef) attri.next();
sep = recConv.addAttrToInsertStmt(false, stmt, values, sep, lineattr, sqlTabName.getName());
}
}
// stdcols
if (createStdCols) {
stmt.append(sep);
sep = ",";
stmt.append(DbNames.T_LAST_CHANGE_COL);
values.append(",?");
stmt.append(sep);
sep = ",";
stmt.append(DbNames.T_CREATE_DATE_COL);
values.append(",?");
stmt.append(sep);
sep = ",";
stmt.append(DbNames.T_USER_COL);
values.append(",?");
}
stmt.append(") VALUES (");
stmt.append(values);
stmt.append(")");
return stmt.toString();
}
use of ch.interlis.ili2c.metamodel.SurfaceOrAreaType in project ili2db by claeis.
the class TransferFromXtf method allReferencesKnownHelper.
private void allReferencesKnownHelper(IomObject iomObj, AttributeDef attr, FixIomObjectExtRefs extref) {
String attrName = attr.getName();
if (attr.isDomainBoolean()) {
} else if (attr.isDomainIli1Date()) {
} else if (attr.isDomainIli2Date()) {
} else if (attr.isDomainIli2Time()) {
} else if (attr.isDomainIli2DateTime()) {
} else {
Type type = attr.getDomainResolvingAliases();
if (type instanceof CompositionType) {
// enqueue struct values
int structc = iomObj.getattrvaluecount(attrName);
for (int structi = 0; structi < structc; structi++) {
IomObject struct = iomObj.getattrobj(attrName, structi);
allReferencesKnownHelper(struct, extref);
}
} else if (type instanceof PolylineType) {
} else if (type instanceof SurfaceOrAreaType) {
} else if (type instanceof CoordType) {
} else if (type instanceof NumericType) {
} else if (type instanceof EnumerationType) {
} else if (type instanceof ReferenceType) {
IomObject structvalue = iomObj.getattrobj(attrName, 0);
String refoid = null;
if (structvalue != null) {
refoid = structvalue.getobjectrefoid();
}
if (refoid != null) {
Viewable targetClass = ((ReferenceType) type).getReferred();
if (!oidPool.containsXtfid(Ili2cUtility.getRootViewable(targetClass).getScopedName(null), refoid)) {
extref.addFix(structvalue, targetClass);
}
}
} else {
}
}
}
Aggregations