use of ch.interlis.ili2c.metamodel.CompositionType 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.CompositionType 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 {
}
}
}
use of ch.interlis.ili2c.metamodel.CompositionType in project ili2db by claeis.
the class TransferFromXtf method getStructs_Helper.
private void getStructs_Helper(AbstractClassDef aclass, HashSet<AbstractClassDef> accu) {
if (accu.contains(aclass)) {
return;
}
java.util.Set seed = null;
if (aclass instanceof Table && !((Table) aclass).isIdentifiable()) {
// STRUCTURE
seed = aclass.getExtensions();
} else {
// CLASS
seed = new HashSet();
seed.add(aclass);
}
for (Object defo : seed) {
AbstractClassDef def = (AbstractClassDef) defo;
if (accu.contains(def)) {
continue;
}
if (def instanceof Table && !((Table) def).isIdentifiable()) {
accu.add(def);
}
while (def != null) {
Iterator attri = def.iterator();
while (attri.hasNext()) {
Object attro = attri.next();
if (attro instanceof AttributeDef) {
AttributeDef attr = (AttributeDef) attro;
Type type = attr.getDomain();
if (type instanceof CompositionType) {
CompositionType compType = (CompositionType) type;
getStructs_Helper(compType.getComponentType(), accu);
Iterator resti = compType.iteratorRestrictedTo();
while (resti.hasNext()) {
AbstractClassDef rest = (AbstractClassDef) resti.next();
getStructs_Helper(rest, accu);
}
}
}
}
// base viewable
def = (AbstractClassDef) def.getExtending();
if (accu.contains(def)) {
def = null;
}
}
}
}
use of ch.interlis.ili2c.metamodel.CompositionType in project ili2db by claeis.
the class Ili2cUtility method isPureChbaseMultiSuface.
public static boolean isPureChbaseMultiSuface(TransferDescription td, AttributeDef attr) {
Type typeo = attr.getDomain();
if (typeo instanceof CompositionType) {
CompositionType type = (CompositionType) typeo;
Table struct = type.getComponentType();
Table root = (Table) struct.getRootExtending();
if (root == null) {
root = struct;
}
String containerQName = root.getContainer().getScopedName(null);
if (containerQName.equals(IliNames.CHBASE1_GEOMETRYCHLV03) || containerQName.equals(IliNames.CHBASE1_GEOMETRYCHLV95)) {
if (root.getName().equals(IliNames.CHBASE1_GEOMETRY_MULTISURFACE)) {
java.util.Iterator it = struct.getAttributesAndRoles2();
int c = 0;
while (it.hasNext()) {
it.next();
c++;
}
if (c == 1) {
// only one attribute
return true;
}
}
}
}
return false;
}
use of ch.interlis.ili2c.metamodel.CompositionType in project ili2db by claeis.
the class Ili2cUtility method isPureChbaseMultilingualText.
private static boolean isPureChbaseMultilingualText(TransferDescription td, AttributeDef attr, String textType) {
Type typeo = attr.getDomain();
if (typeo instanceof CompositionType) {
CompositionType type = (CompositionType) typeo;
Table struct = type.getComponentType();
Table base = null;
if (struct.getContainer().getScopedName(null).equals(IliNames.CHBASE1_LOCALISATIONCH)) {
base = struct;
} else {
base = (Table) struct.getExtending();
if (base == null) {
base = struct;
}
while (base != null && !base.getContainer().getScopedName(null).equals(IliNames.CHBASE1_LOCALISATIONCH)) {
base = (Table) base.getExtending();
}
}
if (base == null) {
return false;
}
// ASSERT: base.getContainer().getScopedName(null).equals("LocalisationCH_V1"))
if (base.getName().equals(textType)) {
java.util.Iterator it = struct.getAttributesAndRoles2();
int c = 0;
while (it.hasNext()) {
it.next();
c++;
}
if (c == 1) {
// only one attribute LocalisedText
return true;
}
}
}
return false;
}
Aggregations