Search in sources :

Example 16 with CompositionType

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;
}
Also used : PolylineType(ch.interlis.ili2c.metamodel.PolylineType) NumericalType(ch.interlis.ili2c.metamodel.NumericalType) PolylineType(ch.interlis.ili2c.metamodel.PolylineType) Type(ch.interlis.ili2c.metamodel.Type) ReferenceType(ch.interlis.ili2c.metamodel.ReferenceType) SurfaceOrAreaType(ch.interlis.ili2c.metamodel.SurfaceOrAreaType) SurfaceType(ch.interlis.ili2c.metamodel.SurfaceType) CompositionType(ch.interlis.ili2c.metamodel.CompositionType) EnumerationType(ch.interlis.ili2c.metamodel.EnumerationType) NumericType(ch.interlis.ili2c.metamodel.NumericType) BlackboxType(ch.interlis.ili2c.metamodel.BlackboxType) AreaType(ch.interlis.ili2c.metamodel.AreaType) LineType(ch.interlis.ili2c.metamodel.LineType) ObjectType(ch.interlis.ili2c.metamodel.ObjectType) CoordType(ch.interlis.ili2c.metamodel.CoordType) SurfaceOrAreaType(ch.interlis.ili2c.metamodel.SurfaceOrAreaType) EnumerationType(ch.interlis.ili2c.metamodel.EnumerationType) ViewableWrapper(ch.ehi.ili2db.mapping.ViewableWrapper) CompositionType(ch.interlis.ili2c.metamodel.CompositionType) SurfaceOrAreaType(ch.interlis.ili2c.metamodel.SurfaceOrAreaType) AreaType(ch.interlis.ili2c.metamodel.AreaType) ReferenceType(ch.interlis.ili2c.metamodel.ReferenceType) CoordType(ch.interlis.ili2c.metamodel.CoordType)

Example 17 with CompositionType

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 {
        }
    }
}
Also used : PolylineType(ch.interlis.ili2c.metamodel.PolylineType) NumericType(ch.interlis.ili2c.metamodel.NumericType) PolylineType(ch.interlis.ili2c.metamodel.PolylineType) Type(ch.interlis.ili2c.metamodel.Type) ReferenceType(ch.interlis.ili2c.metamodel.ReferenceType) SurfaceOrAreaType(ch.interlis.ili2c.metamodel.SurfaceOrAreaType) SurfaceType(ch.interlis.ili2c.metamodel.SurfaceType) CompositionType(ch.interlis.ili2c.metamodel.CompositionType) EnumerationType(ch.interlis.ili2c.metamodel.EnumerationType) NumericType(ch.interlis.ili2c.metamodel.NumericType) ObjectType(ch.interlis.ili2c.metamodel.ObjectType) CoordType(ch.interlis.ili2c.metamodel.CoordType) IomObject(ch.interlis.iom.IomObject) SurfaceOrAreaType(ch.interlis.ili2c.metamodel.SurfaceOrAreaType) EnumerationType(ch.interlis.ili2c.metamodel.EnumerationType) Viewable(ch.interlis.ili2c.metamodel.Viewable) CompositionType(ch.interlis.ili2c.metamodel.CompositionType) ReferenceType(ch.interlis.ili2c.metamodel.ReferenceType) CoordType(ch.interlis.ili2c.metamodel.CoordType)

Example 18 with CompositionType

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;
            }
        }
    }
}
Also used : PolylineType(ch.interlis.ili2c.metamodel.PolylineType) Type(ch.interlis.ili2c.metamodel.Type) ReferenceType(ch.interlis.ili2c.metamodel.ReferenceType) SurfaceOrAreaType(ch.interlis.ili2c.metamodel.SurfaceOrAreaType) SurfaceType(ch.interlis.ili2c.metamodel.SurfaceType) CompositionType(ch.interlis.ili2c.metamodel.CompositionType) EnumerationType(ch.interlis.ili2c.metamodel.EnumerationType) NumericType(ch.interlis.ili2c.metamodel.NumericType) ObjectType(ch.interlis.ili2c.metamodel.ObjectType) CoordType(ch.interlis.ili2c.metamodel.CoordType) Table(ch.interlis.ili2c.metamodel.Table) Iterator(java.util.Iterator) IomObject(ch.interlis.iom.IomObject) AttributeDef(ch.interlis.ili2c.metamodel.AttributeDef) AbstractClassDef(ch.interlis.ili2c.metamodel.AbstractClassDef) CompositionType(ch.interlis.ili2c.metamodel.CompositionType) HashSet(java.util.HashSet)

Example 19 with CompositionType

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;
}
Also used : CompositionType(ch.interlis.ili2c.metamodel.CompositionType) Type(ch.interlis.ili2c.metamodel.Type) Table(ch.interlis.ili2c.metamodel.Table) CompositionType(ch.interlis.ili2c.metamodel.CompositionType)

Example 20 with CompositionType

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;
}
Also used : CompositionType(ch.interlis.ili2c.metamodel.CompositionType) Type(ch.interlis.ili2c.metamodel.Type) Table(ch.interlis.ili2c.metamodel.Table) CompositionType(ch.interlis.ili2c.metamodel.CompositionType)

Aggregations

CompositionType (ch.interlis.ili2c.metamodel.CompositionType)23 Type (ch.interlis.ili2c.metamodel.Type)17 Table (ch.interlis.ili2c.metamodel.Table)15 AttributeDef (ch.interlis.ili2c.metamodel.AttributeDef)14 CoordType (ch.interlis.ili2c.metamodel.CoordType)10 EnumerationType (ch.interlis.ili2c.metamodel.EnumerationType)10 SurfaceType (ch.interlis.ili2c.metamodel.SurfaceType)10 PolylineType (ch.interlis.ili2c.metamodel.PolylineType)9 SurfaceOrAreaType (ch.interlis.ili2c.metamodel.SurfaceOrAreaType)9 ObjectType (ch.interlis.ili2c.metamodel.ObjectType)7 ReferenceType (ch.interlis.ili2c.metamodel.ReferenceType)7 IomObject (ch.interlis.iom.IomObject)6 ViewableWrapper (ch.ehi.ili2db.mapping.ViewableWrapper)5 AreaType (ch.interlis.ili2c.metamodel.AreaType)5 BlackboxType (ch.interlis.ili2c.metamodel.BlackboxType)5 NumericType (ch.interlis.ili2c.metamodel.NumericType)5 ViewableTransferElement (ch.interlis.ili2c.metamodel.ViewableTransferElement)5 Viewable (ch.interlis.ili2c.metamodel.Viewable)4 ArrayMapping (ch.ehi.ili2db.mapping.ArrayMapping)3 MultiLineMapping (ch.ehi.ili2db.mapping.MultiLineMapping)3