Search in sources :

Example 16 with EnumerationType

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

use of ch.interlis.ili2c.metamodel.EnumerationType 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)

Aggregations

EnumerationType (ch.interlis.ili2c.metamodel.EnumerationType)17 AttributeDef (ch.interlis.ili2c.metamodel.AttributeDef)10 CompositionType (ch.interlis.ili2c.metamodel.CompositionType)9 NumericType (ch.interlis.ili2c.metamodel.NumericType)9 SurfaceOrAreaType (ch.interlis.ili2c.metamodel.SurfaceOrAreaType)9 Type (ch.interlis.ili2c.metamodel.Type)9 BlackboxType (ch.interlis.ili2c.metamodel.BlackboxType)8 Iterator (java.util.Iterator)8 CoordType (ch.interlis.ili2c.metamodel.CoordType)7 PolylineType (ch.interlis.ili2c.metamodel.PolylineType)7 SurfaceType (ch.interlis.ili2c.metamodel.SurfaceType)7 IomObject (ch.interlis.iom.IomObject)7 ObjectType (ch.interlis.ili2c.metamodel.ObjectType)6 ReferenceType (ch.interlis.ili2c.metamodel.ReferenceType)6 Viewable (ch.interlis.ili2c.metamodel.Viewable)6 ViewableWrapper (ch.ehi.ili2db.mapping.ViewableWrapper)5 AreaType (ch.interlis.ili2c.metamodel.AreaType)5 Domain (ch.interlis.ili2c.metamodel.Domain)5 PrecisionDecimal (ch.interlis.ili2c.metamodel.PrecisionDecimal)5 TextType (ch.interlis.ili2c.metamodel.TextType)5