Search in sources :

Example 56 with IomObject

use of ch.interlis.iom.IomObject in project ili2db by claeis.

the class Fgdb2iox method read.

/**
 * Reads a {@link Geometry} from an {@link InStream).
 *
 * @param is the stream to read from
 * @return the Geometry read
 * @throws IOException
 * @throws ParseException
 * @throws IoxException
 */
public IomObject read(InStream is) throws IOException, ParseException, IoxException {
    dis.setInStream(is);
    IomObject g = readGeometry();
    return g;
}
Also used : IomObject(ch.interlis.iom.IomObject)

Example 57 with IomObject

use of ch.interlis.iom.IomObject in project ili2db by claeis.

the class FromXtfRecordConverter method writeRecord.

public void writeRecord(long basketSqlId, IomObject iomObj, Viewable iomClass, StructWrapper structEle, ViewableWrapper aclass, String sqlType, long sqlId, boolean updateObj, PreparedStatement ps, ArrayList structQueue) throws SQLException, ConverterException {
    int valuei = 1;
    if (updateObj) {
    // if update, t_id is last param
    // ps.setInt(valuei, sqlId);
    // valuei++;
    } else {
        ps.setLong(valuei, sqlId);
        valuei++;
    }
    if (createBasketCol) {
        ps.setLong(valuei, basketSqlId);
        valuei++;
    }
    if (createDatasetCol) {
        ps.setString(valuei, datasetName);
        valuei++;
    }
    if (!aclass.isSecondaryTable()) {
        if (aclass.getExtending() == null) {
            if (createTypeDiscriminator || aclass.includesMultipleTypes()) {
                ps.setString(valuei, sqlType);
                valuei++;
            }
            // if class
            if (structEle == null) {
                if (!updateObj) {
                    if (!aclass.isStructure()) {
                        if (createIliTidCol || aclass.getOid() != null) {
                            // import TID from transfer file
                            if (AbstractRecordConverter.isUuidOid(td, aclass.getOid())) {
                                Object toInsertUUID = geomConv.fromIomUuid(iomObj.getobjectoid());
                                ps.setObject(valuei, toInsertUUID);
                            } else {
                                ps.setString(valuei, iomObj.getobjectoid());
                            }
                            valuei++;
                        }
                    }
                }
            }
            // if struct, add ref to parent
            if (structEle != null) {
                ps.setLong(valuei, structEle.getParentSqlId());
                valuei++;
                if (createGenericStructRef) {
                    ps.setString(valuei, structEle.getParentSqlType());
                    valuei++;
                    // T_ParentAttr
                    ps.setString(valuei, structEle.getParentSqlAttr());
                    valuei++;
                }
                // T_Seq
                ps.setInt(valuei, structEle.getStructi());
                valuei++;
            }
        }
    }
    HashSet attrs = getIomObjectAttrs(iomClass);
    Iterator iter = aclass.getAttrIterator();
    while (iter.hasNext()) {
        ViewableTransferElement obj = (ViewableTransferElement) iter.next();
        if (obj.obj instanceof AttributeDef) {
            AttributeDef attr = (AttributeDef) obj.obj;
            if (attrs.contains(attr)) {
                if (!attr.isTransient()) {
                    Type proxyType = attr.getDomain();
                    if (proxyType != null && (proxyType instanceof ObjectType)) {
                    // skip implicit particles (base-viewables) of views
                    } else {
                        valuei = addAttrValue(iomObj, sqlType, sqlId, aclass.getSqlTablename(), ps, valuei, attr, structQueue);
                    }
                }
            }
        }
        if (obj.obj instanceof RoleDef) {
            RoleDef role = (RoleDef) obj.obj;
            if (role.getExtending() == null) {
                if (attrs.contains(role)) {
                    String refoid = null;
                    String roleName = role.getName();
                    // a role of an embedded association?
                    if (obj.embedded) {
                        AssociationDef roleOwner = (AssociationDef) role.getContainer();
                        if (roleOwner.getDerivedFrom() == null) {
                            // not just a link?
                            IomObject structvalue = iomObj.getattrobj(roleName, 0);
                            if (roleOwner.getAttributes().hasNext() || roleOwner.getLightweightAssociations().iterator().hasNext()) {
                            // TODO handle attributes of link
                            }
                            if (structvalue != null) {
                                refoid = structvalue.getobjectrefoid();
                                long orderPos = structvalue.getobjectreforderpos();
                                if (orderPos != 0) {
                                // refoid,orderPos
                                // ret.setStringAttribute(roleName, refoid);
                                // ret.setStringAttribute(roleName+".orderPos", Long.toString(orderPos));
                                } else {
                                // refoid
                                // ret.setStringAttribute(roleName, refoid);
                                }
                            } else {
                                refoid = null;
                            }
                        }
                    } else {
                        IomObject structvalue = iomObj.getattrobj(roleName, 0);
                        refoid = structvalue.getobjectrefoid();
                        long orderPos = structvalue.getobjectreforderpos();
                        if (orderPos != 0) {
                        // refoid,orderPos
                        // ret.setStringAttribute(roleName, refoid);
                        // ret.setStringAttribute(roleName+".orderPos", Long.toString(orderPos));
                        } else {
                        // refoid
                        // ret.setStringAttribute(roleName, refoid);
                        }
                    }
                    Holder<Integer> valueiRef = new Holder<Integer>(valuei);
                    setReferenceColumn(ps, role.getDestination(), refoid, valueiRef);
                    valuei = valueiRef.value;
                }
            }
        }
    }
    if (createStdCols) {
        // T_LastChange
        ps.setTimestamp(valuei, today);
        valuei++;
        // T_CreateDate
        if (!updateObj) {
            ps.setTimestamp(valuei, today);
            valuei++;
        }
        // T_User
        ps.setString(valuei, dbusr);
        valuei++;
    }
    if (updateObj) {
        // if update, t_id is last param
        ps.setLong(valuei, sqlId);
        valuei++;
    } else {
    // if insert, t_id is first param
    // ps.setInt(valuei, sqlId);
    // valuei++;
    }
}
Also used : ViewableTransferElement(ch.interlis.ili2c.metamodel.ViewableTransferElement) RoleDef(ch.interlis.ili2c.metamodel.RoleDef) Holder(javax.xml.ws.Holder) ObjectType(ch.interlis.ili2c.metamodel.ObjectType) 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) IomObject(ch.interlis.iom.IomObject) Iterator(java.util.Iterator) AssociationDef(ch.interlis.ili2c.metamodel.AssociationDef) IomObject(ch.interlis.iom.IomObject) AttributeDef(ch.interlis.ili2c.metamodel.AttributeDef) HashSet(java.util.HashSet)

Example 58 with IomObject

use of ch.interlis.iom.IomObject in project ili2db by claeis.

the class FromXtfRecordConverter method getMultilingualText.

private String getMultilingualText(IomObject iomMulti, String sfx) {
    if (sfx.length() > 0) {
        // remove leading '_'
        sfx = sfx.substring(LEN_LANG_PREFIX);
    }
    int txtc = iomMulti.getattrvaluecount(IliNames.CHBASE1_LOCALISEDTEXT);
    for (int txti = 0; txti < txtc; txti++) {
        IomObject iomTxt = iomMulti.getattrobj(IliNames.CHBASE1_LOCALISEDTEXT, txti);
        String lang = iomTxt.getattrvalue(IliNames.CHBASE1_LOCALISEDTEXT_LANGUAGE);
        if (lang == null)
            lang = "";
        if (lang.equals(sfx)) {
            return iomTxt.getattrvalue(IliNames.CHBASE1_LOCALISEDTEXT_TEXT);
        }
    }
    return null;
}
Also used : IomObject(ch.interlis.iom.IomObject)

Example 59 with IomObject

use of ch.interlis.iom.IomObject 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;
}
Also used : NumericType(ch.interlis.ili2c.metamodel.NumericType) ConverterException(ch.ehi.ili2db.converter.ConverterException) SurfaceOrAreaType(ch.interlis.ili2c.metamodel.SurfaceOrAreaType) CompositionType(ch.interlis.ili2c.metamodel.CompositionType) SurfaceOrAreaType(ch.interlis.ili2c.metamodel.SurfaceOrAreaType) AreaType(ch.interlis.ili2c.metamodel.AreaType) ReferenceType(ch.interlis.ili2c.metamodel.ReferenceType) PrecisionDecimal(ch.interlis.ili2c.metamodel.PrecisionDecimal) IomObject(ch.interlis.iom.IomObject) AttributeDef(ch.interlis.ili2c.metamodel.AttributeDef) PolylineType(ch.interlis.ili2c.metamodel.PolylineType) MultiPointMapping(ch.ehi.ili2db.mapping.MultiPointMapping) BlackboxType(ch.interlis.ili2c.metamodel.BlackboxType) Holder(javax.xml.ws.Holder) GregorianCalendar(java.util.GregorianCalendar) XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) EnumerationType(ch.interlis.ili2c.metamodel.EnumerationType) SurfaceType(ch.interlis.ili2c.metamodel.SurfaceType) MultiSurfaceMapping(ch.ehi.ili2db.mapping.MultiSurfaceMapping) XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) DatatypeConfigurationException(javax.xml.datatype.DatatypeConfigurationException) 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) ArrayMapping(ch.ehi.ili2db.mapping.ArrayMapping) IomObject(ch.interlis.iom.IomObject) MultiLineMapping(ch.ehi.ili2db.mapping.MultiLineMapping) CoordType(ch.interlis.ili2c.metamodel.CoordType)

Example 60 with IomObject

use of ch.interlis.iom.IomObject in project ili2db by claeis.

the class TransferFromXtf method getAssociationId.

private String getAssociationId(IomObject iomObj, AssociationDef modelele) {
    String tag = modelele.getScopedName(null);
    String tid;
    Iterator<ViewableTransferElement> rolei = modelele.getAttributesAndRoles2();
    String sep = "";
    tid = "";
    while (rolei.hasNext()) {
        ViewableTransferElement prop = rolei.next();
        if (prop.obj instanceof RoleDef && !prop.embedded) {
            String roleName = ((RoleDef) prop.obj).getName();
            IomObject refObj = iomObj.getattrobj(roleName, 0);
            String ref = null;
            if (refObj != null) {
                ref = refObj.getobjectrefoid();
            }
            if (ref != null) {
                tid = tid + sep + ref;
                sep = ":";
            } else {
                throw new IllegalStateException("REF required (" + tag + "/" + roleName + ")");
            }
        }
    }
    return tid;
}
Also used : ViewableTransferElement(ch.interlis.ili2c.metamodel.ViewableTransferElement) IomObject(ch.interlis.iom.IomObject) RoleDef(ch.interlis.ili2c.metamodel.RoleDef)

Aggregations

IomObject (ch.interlis.iom.IomObject)66 EndBasketEvent (ch.interlis.iox.EndBasketEvent)35 EndTransferEvent (ch.interlis.iox.EndTransferEvent)35 IoxEvent (ch.interlis.iox.IoxEvent)35 StartTransferEvent (ch.interlis.iox.StartTransferEvent)35 File (java.io.File)35 HashMap (java.util.HashMap)35 Config (ch.ehi.ili2db.gui.Config)34 ObjectEvent (ch.interlis.iox.ObjectEvent)34 StartBasketEvent (ch.interlis.iox.StartBasketEvent)34 Connection (java.sql.Connection)34 XtfReader (ch.interlis.iom_j.xtf.XtfReader)30 Test (org.junit.Test)29 IoxException (ch.interlis.iox.IoxException)12 AttributeDef (ch.interlis.ili2c.metamodel.AttributeDef)11 Iom_jObject (ch.interlis.iom_j.Iom_jObject)9 CompositionType (ch.interlis.ili2c.metamodel.CompositionType)8 EnumerationType (ch.interlis.ili2c.metamodel.EnumerationType)8 SurfaceOrAreaType (ch.interlis.ili2c.metamodel.SurfaceOrAreaType)8 SurfaceType (ch.interlis.ili2c.metamodel.SurfaceType)8