Search in sources :

Example 6 with PolylineType

use of ch.interlis.ili2c.metamodel.PolylineType 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 7 with PolylineType

use of ch.interlis.ili2c.metamodel.PolylineType 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 8 with PolylineType

use of ch.interlis.ili2c.metamodel.PolylineType in project ili2db by claeis.

the class MultiLineMappings method addMultiLineAttr.

public void addMultiLineAttr(AttributeDef multiLineAttr) {
    String bagOfLinesAttrName = null;
    String lineAttrName = null;
    // validate structure
    // create mapping
    Type multiLineTypeo = multiLineAttr.getDomain();
    if (!(multiLineTypeo instanceof CompositionType)) {
        throw new IllegalArgumentException("not a valid multiline attribute " + multiLineAttr.getScopedName(null));
    } else {
        CompositionType multiLineType = (CompositionType) multiLineTypeo;
        Table multiLineStruct = multiLineType.getComponentType();
        Iterator<ViewableTransferElement> it = multiLineStruct.getAttributesAndRoles2();
        if (!it.hasNext()) {
            throw new IllegalArgumentException("not a valid multiline structure " + multiLineStruct.getScopedName(null));
        }
        ViewableTransferElement prop = it.next();
        if (!(prop.obj instanceof AttributeDef)) {
            throw new IllegalArgumentException("not a valid multiline structure " + multiLineStruct.getScopedName(null));
        }
        AttributeDef linesAttr = (AttributeDef) prop.obj;
        bagOfLinesAttrName = linesAttr.getName();
        Type linesTypeo = linesAttr.getDomain();
        if (!(linesTypeo instanceof CompositionType)) {
            throw new IllegalArgumentException("not a valid multiline structure " + multiLineStruct.getScopedName(null));
        } else {
            CompositionType linesType = (CompositionType) linesTypeo;
            Table lineStruct = linesType.getComponentType();
            Iterator<ViewableTransferElement> it2 = lineStruct.getAttributesAndRoles2();
            if (!it2.hasNext()) {
                throw new IllegalArgumentException("not a valid line structure " + lineStruct.getScopedName(null));
            }
            ViewableTransferElement prop2 = it2.next();
            if (!(prop2.obj instanceof AttributeDef)) {
                throw new IllegalArgumentException("not a valid line structure " + lineStruct.getScopedName(null));
            }
            AttributeDef lineAttr = (AttributeDef) prop2.obj;
            Type lineType = lineAttr.getDomainResolvingAliases();
            if (!(lineType instanceof PolylineType)) {
                throw new IllegalArgumentException("not a valid line structure " + lineStruct.getScopedName(null));
            }
            lineAttrName = lineAttr.getName();
        }
    }
    MultiLineMapping mapping = new MultiLineMapping(bagOfLinesAttrName, lineAttrName);
    mappings.put(multiLineAttr, mapping);
}
Also used : ViewableTransferElement(ch.interlis.ili2c.metamodel.ViewableTransferElement) PolylineType(ch.interlis.ili2c.metamodel.PolylineType) SurfaceType(ch.interlis.ili2c.metamodel.SurfaceType) PolylineType(ch.interlis.ili2c.metamodel.PolylineType) CompositionType(ch.interlis.ili2c.metamodel.CompositionType) Type(ch.interlis.ili2c.metamodel.Type) Table(ch.interlis.ili2c.metamodel.Table) AttributeDef(ch.interlis.ili2c.metamodel.AttributeDef) CompositionType(ch.interlis.ili2c.metamodel.CompositionType)

Aggregations

CompositionType (ch.interlis.ili2c.metamodel.CompositionType)8 PolylineType (ch.interlis.ili2c.metamodel.PolylineType)8 SurfaceType (ch.interlis.ili2c.metamodel.SurfaceType)8 Type (ch.interlis.ili2c.metamodel.Type)8 CoordType (ch.interlis.ili2c.metamodel.CoordType)7 EnumerationType (ch.interlis.ili2c.metamodel.EnumerationType)7 SurfaceOrAreaType (ch.interlis.ili2c.metamodel.SurfaceOrAreaType)7 ObjectType (ch.interlis.ili2c.metamodel.ObjectType)6 ReferenceType (ch.interlis.ili2c.metamodel.ReferenceType)6 AreaType (ch.interlis.ili2c.metamodel.AreaType)5 AttributeDef (ch.interlis.ili2c.metamodel.AttributeDef)5 BlackboxType (ch.interlis.ili2c.metamodel.BlackboxType)5 ViewableWrapper (ch.ehi.ili2db.mapping.ViewableWrapper)4 NumericType (ch.interlis.ili2c.metamodel.NumericType)4 ArrayMapping (ch.ehi.ili2db.mapping.ArrayMapping)3 MultiLineMapping (ch.ehi.ili2db.mapping.MultiLineMapping)3 MultiPointMapping (ch.ehi.ili2db.mapping.MultiPointMapping)3 MultiSurfaceMapping (ch.ehi.ili2db.mapping.MultiSurfaceMapping)3 Table (ch.interlis.ili2c.metamodel.Table)3 IomObject (ch.interlis.iom.IomObject)3