Package ch.interlis.ili2c.metamodel

Examples of ch.interlis.ili2c.metamodel.Type


                                while (attri.hasNext()) {
                                    ch.interlis.ili2c.metamodel.ViewableTransferElement attrObj = (ch.interlis.ili2c.metamodel.ViewableTransferElement) attri
                                            .next();
                                    if (attrObj.obj instanceof AttributeDef) {
                                        AttributeDef attrdefObj = (AttributeDef) attrObj.obj;
                                        Type type = attrdefObj
                                                .getDomainResolvingAliases();

                                        if (type instanceof PolylineType) {
                                            typeBuilder.add(attrdefObj
                                                    .getName().toLowerCase(),
View Full Code Here


                                    ch.interlis.ili2c.metamodel.ViewableTransferElement attrObj = (ch.interlis.ili2c.metamodel.ViewableTransferElement) attri
                                            .next();

                                    if (attrObj.obj instanceof AttributeDef) {
                                        AttributeDef attrdefObj = (AttributeDef) attrObj.obj;
                                        Type type = attrdefObj
                                                .getDomainResolvingAliases();
                                        String attrName = attrdefObj.getName()
                                                .toLowerCase();

                                        if (type instanceof PolylineType
View Full Code Here

                    ViewableTransferElement obj = (ViewableTransferElement) attri
                            .next();

                    if (obj.obj instanceof AttributeDef) {
                        AttributeDef attr = (AttributeDef) obj.obj;
                        Type type = attr.getDomainResolvingAliases();
                        String attrName = attr.getName();

                        // what is this good for?
                        if (type instanceof CompositionType) {
                            logger.debug("CompositionType");
                            int valuec = iomObj.getattrvaluecount(attrName);
                            for (int valuei = 0; valuei < valuec; valuei++) {
                                IomObject value = iomObj.getattrobj(attrName,
                                        valuei);
                                if (value != null) {
                                    // do nothing...
                                }
                            }
                        } else if (type instanceof PolylineType) {
                            IomObject value = iomObj.getattrobj(attrName, 0);
                            if (value != null) {
                                featBuilder.set(attrName.toLowerCase(),
                                        Iox2wkt.polyline2jts(value, 0));
                            } else {
                                featBuilder.set(attrName.toLowerCase(), null);
                            }
                        } else if (type instanceof SurfaceType) {
                            isSurfaceMain = true;
                            geomName = attrName.toLowerCase();
                        } else if (type instanceof AreaType) {
                            isAreaMain = true;
                            IomObject value = iomObj.getattrobj(attrName, 0);
                            try {
                                Point point = new GeometryFactory()
                                        .createPoint(Iox2jts.coord2JTS(value));
                                // point.setSRID( Integer.parseInt(this.epsg) );
                                featBuilder.set(attrName.toLowerCase()
                                        + "_point", point);
                                geomName = attrName.toLowerCase();
                            } catch (Iox2jtsException e) {
                                e.printStackTrace();
                                logger.warn(e.getMessage());
                            }
                        } else if (type instanceof CoordType) {
                            IomObject value = iomObj.getattrobj(attrName, 0);
                            if (value != null) {
                                if (!value.getobjecttag().equals("COORD")) {
                                    logger.warn("object tag <> COORD");
                                } else {
                                    try {
                                        Point point = new GeometryFactory()
                                                .createPoint(Iox2jts
                                                        .coord2JTS(value));
                                        featBuilder.set(attrName.toLowerCase(),
                                                point);
                                    } catch (Iox2jtsException e) {
                                        e.printStackTrace();
                                        logger.warn(e.getMessage());
                                    }
                                }
                            }
                        } else if (type instanceof NumericType) {
                            String value = iomObj.getattrvalue(attrName);
                            if (value != null) {
                                featBuilder.set(attrName.toLowerCase(),
                                        Double.valueOf(value));
                            } else {
                                featBuilder.set(attrName.toLowerCase(), null);
                            }
                        } else if (type instanceof EnumerationType) {
                            String value = iomObj.getattrvalue(attrName);
                            if (value != null) {
                                featBuilder.set(attrName.toLowerCase(),
                                        Integer.valueOf(value));
                                if (true == true) {
                                    featBuilder.set(attrName.toLowerCase()
                                            + "_txt", enumCodeMapper
                                            .mapItfCode2XtfCode(
                                                    (EnumerationType) type,
                                                    value));
                                }
                            } else {
                                featBuilder.set(attrName.toLowerCase(), null);
                                if (true) {
                                    featBuilder.set(attrName.toLowerCase()
                                            + "_txt", null);
                                }
                            }
                        } else {
                            String value = iomObj.getattrvalue(attrName);
                            if (value != null) {
                                featBuilder.set(attrName.toLowerCase(), value);
                            } else {
                                featBuilder.set(attrName.toLowerCase(), null);
                            }
                        }
                    }
                    if (obj.obj instanceof RoleDef) {
                        RoleDef role = (RoleDef) obj.obj;
                        String roleName = role.getName();

                        IomObject structvalue = iomObj.getattrobj(roleName, 0);
                        String refoid = "";
                        if (structvalue != null) {
                            if (((ItfReader) ioxReader).isRenumberTids()) {
                                refoid = getTidOrRef(structvalue
                                        .getobjectrefoid());
                            } else {
                                refoid = structvalue.getobjectrefoid();
                            }
                        }
                        featBuilder.set(roleName.toLowerCase(),
                                refoid.toString());
                    }
                }
            } else if (tableObj instanceof LocalAttribute) {
                LocalAttribute localAttr = (LocalAttribute) tag2class
                        .get(iomObj.getobjecttag());
                Type type = localAttr.getDomainResolvingAliases();

                if (type instanceof SurfaceType) {
                    isSurfaceHelper = true;
                    geomName = localAttr.getName().toLowerCase();
View Full Code Here

                if (model instanceof PredefinedModel) {
                    Iterator topici = model.iterator();
                    while (topici.hasNext()) {
                        Object tObj = topici.next();
                        if (tObj instanceof Domain) {
                            Type domainType = ((Domain) tObj).getType();
                            if (domainType instanceof EnumerationType) {
                                EnumerationType enumerationType = (EnumerationType) domainType;
                                ch.interlis.ili2c.metamodel.Enumeration enumerations = (ch.interlis.ili2c.metamodel.Enumeration) enumerationType
                                        .getConsolidatedEnumeration();

                                String enumName = "enum__"
                                        + model.getName().toLowerCase()
                                        + "_"
                                        + ((Domain) tObj).getName()
                                                .toLowerCase();

                                enums.append("\n");
                                enums.append("CREATE TABLE " + schema + "."
                                        + enumName);
                                enums.append("\n");
                                enums.append("(");
                                enums.append("\n ");
                                enums.append("ogc_fid SERIAL PRIMARY KEY, \n ");
                                enums.append("code INTEGER, \n ");
                                enums.append("code_txt VARCHAR \n ");
                                enums.append(")\n");
                                enums.append("WITH (OIDS=FALSE);\n");
                                enums.append("ALTER TABLE " + schema + "."
                                        + enumName + " OWNER TO " + grantUser
                                        + ";\n");
                                enums.append("GRANT ALL ON " + schema + "."
                                        + enumName + " TO " + grantUser + ";\n");
                                enums.append("GRANT SELECT ON " + schema + "."
                                        + enumName + " TO " + selectUser
                                        + ";\n\n");

                                ArrayList ev = new ArrayList();
                                ch.interlis.iom_j.itf.ModelUtilities
                                        .buildEnumList(
                                                ev,
                                                "",
                                                ((EnumerationType) domainType)
                                                        .getConsolidatedEnumeration());

                                for (int i = 0; i < ev.size(); i++) {
                                    String sql = "INSERT INTO " + schema + "."
                                            + enumName
                                            + "(code, code_txt) VALUES (" + i
                                            + ", '" + ev.get(i) + "');\n";
                                    enums.append(sql);
                                }
                            }
                        }
                    }
                    continue;
                }
                Iterator topici = model.iterator();
                while (topici.hasNext()) {
                    Object tObj = topici.next();
                    if (tObj instanceof Domain) {
                        Type domainType = ((Domain) tObj).getType();
                        if (domainType instanceof EnumerationType) {
                            EnumerationType enumerationType = (EnumerationType) domainType;
                            ch.interlis.ili2c.metamodel.Enumeration enumerations = (ch.interlis.ili2c.metamodel.Enumeration) enumerationType
                                    .getConsolidatedEnumeration();

                            String enumName = "enum__"
                                    + model.getName().toLowerCase() + "_"
                                    + ((Domain) tObj).getName().toLowerCase();

                            enums.append("\n");
                            enums.append("CREATE TABLE " + schema + "."
                                    + enumName);
                            enums.append("\n");
                            enums.append("(");
                            enums.append("\n ");
                            enums.append("ogc_fid SERIAL PRIMARY KEY, \n ");
                            enums.append("code INTEGER, \n ");
                            enums.append("code_txt VARCHAR \n ");
                            enums.append(")\n");
                            enums.append("WITH (OIDS=FALSE);\n");
                            enums.append("ALTER TABLE " + schema + "."
                                    + enumName + " OWNER TO " + grantUser
                                    + ";\n");
                            enums.append("GRANT ALL ON " + schema + "."
                                    + enumName + " TO " + grantUser + ";\n");
                            enums.append("GRANT SELECT ON " + schema + "."
                                    + enumName + " TO " + selectUser + ";\n\n");

                            ArrayList ev = new ArrayList();
                            ch.interlis.iom_j.itf.ModelUtilities.buildEnumList(
                                    ev, "", ((EnumerationType) domainType)
                                            .getConsolidatedEnumeration());

                            for (int i = 0; i < ev.size(); i++) {
                                String sql = "INSERT INTO " + schema + "."
                                        + enumName
                                        + "(code, code_txt) VALUES (" + i
                                        + ", '" + ev.get(i) + "');\n";
                                enums.append(sql);
                            }
                        }
                    }

                    if (tObj instanceof Topic) {
                        Topic topic = (Topic) tObj;

                        Iterator iter = topic.iterator();

                        while (iter.hasNext()) {
                            Object obj = iter.next();

                            if (obj instanceof Domain) {
                                Type domainType = ((Domain) obj).getType();
                                if (domainType instanceof EnumerationType) {
                                    EnumerationType enumerationType = (EnumerationType) domainType;
                                    ch.interlis.ili2c.metamodel.Enumeration enumerations = (ch.interlis.ili2c.metamodel.Enumeration) enumerationType
                                            .getConsolidatedEnumeration();

                                    String enumName = "enum__"
                                            + topic.getName().toLowerCase()
                                            + "_"
                                            + ((Domain) obj).getName()
                                                    .toLowerCase();

                                    enums.append("\n");
                                    enums.append("CREATE TABLE " + schema + "."
                                            + enumName);
                                    enums.append("\n");
                                    enums.append("(");
                                    enums.append("\n ");
                                    enums.append("ogc_fid SERIAL PRIMARY KEY, \n ");
                                    enums.append("code INTEGER, \n ");
                                    enums.append("code_txt VARCHAR \n ");
                                    enums.append(")\n");
                                    enums.append("WITH (OIDS=FALSE);\n");
                                    enums.append("ALTER TABLE " + schema + "."
                                            + enumName + " OWNER TO "
                                            + grantUser + ";\n");
                                    enums.append("GRANT ALL ON " + schema + "."
                                            + enumName + " TO " + grantUser
                                            + ";\n");
                                    enums.append("GRANT SELECT ON " + schema
                                            + "." + enumName + " TO "
                                            + selectUser + ";\n\n");

                                    ArrayList ev = new ArrayList();
                                    ch.interlis.iom_j.itf.ModelUtilities
                                            .buildEnumList(
                                                    ev,
                                                    "",
                                                    ((EnumerationType) domainType)
                                                            .getConsolidatedEnumeration());

                                    for (int i = 0; i < ev.size(); i++) {
                                        String sql = "INSERT INTO " + schema
                                                + "." + enumName
                                                + "(code, code_txt) VALUES ("
                                                + i + ", '" + ev.get(i)
                                                + "');\n";
                                        enums.append(sql);
                                    }
                                }
                            }

                            if (obj instanceof Viewable) {
                                Viewable v = (Viewable) obj;

                                if (isPureRefAssoc(v)) {
                                    continue;
                                }
                                String className = v.getScopedName(null);

                                // Array für btree Index
                                ArrayList btree_idx = new ArrayList();

                                String tableName = (className
                                        .substring(className.indexOf(".") + 1))
                                        .replace(".", "_").toLowerCase();

                                tables.append("-------------- New Table --------------\n\n");

                                tables.append("CREATE TABLE " + schema + "."
                                        + tableName);
                                tables.append("\n");
                                tables.append("(");
                                tables.append("\n ");
                                tables.append("ogc_fid SERIAL PRIMARY KEY, \n ");
                                tables.append("tid VARCHAR, \n");

                                btree_idx.add("ogc_fid");
                                btree_idx.add("tid");

                                // Arrays werden gebraucht für Index
                                // und geometry columns inserts.
                                ArrayList geomName = new ArrayList();
                                ArrayList geomType = new ArrayList();
                                String srid = epsg;

                                java.util.List attrv = ch.interlis.iom_j.itf.ModelUtilities
                                        .getIli1AttrList((AbstractClassDef) v);
                                Iterator attri = attrv.iterator();

                                while (attri.hasNext()) {
                                    ch.interlis.ili2c.metamodel.ViewableTransferElement attrObj = (ch.interlis.ili2c.metamodel.ViewableTransferElement) attri
                                            .next();

                                    if (attrObj.obj instanceof AttributeDef) {
                                        AttributeDef attrdefObj = (AttributeDef) attrObj.obj;
                                        Type type = attrdefObj
                                                .getDomainResolvingAliases();

                                        String attrName = attrdefObj.getName()
                                                .toLowerCase();

                                        if (type instanceof PolylineType) {
                                            tables.append(" ");
                                            tables.append(attrName + " ");
                                            tables.append("geometry(LINESTRING, "
                                                    + epsg + "),\n");

                                            geomType.add("LINESTRING");
                                            geomName.add(attrName);
                                        } else if (type instanceof SurfaceType) {
                                            tables.append(" ");
                                            tables.append(attrName + " ");
                                            tables.append("geometry(POLYGON, "
                                                    + epsg + "),\n");

                                            geomType.add("POLYGON");
                                            geomName.add(attrName);
                                        } else if (type instanceof AreaType) {
                                            tables.append(" ");
                                            tables.append(attrName + " ");
                                            tables.append("geometry(POLYGON, "
                                                    + epsg + "),\n");

                                            geomType.add("POLYGON");
                                            geomName.add(attrName);
                                        } else if (type instanceof CoordType) {
                                            tables.append(" ");
                                            tables.append(attrName + " ");
                                            tables.append("geometry(POINT, "
                                                    + epsg + "),\n");

                                            geomType.add("POINT");
                                            geomName.add(attrName);
                                        } else if (type instanceof NumericType) {
                                            tables.append(" ");
                                            tables.append(attrName + " ");
                                            tables.append("DOUBLE PRECISION,\n");
                                        } else if (type instanceof EnumerationType) {
                                            tables.append(" ");
                                            tables.append(attrName + " ");
                                            tables.append("INTEGER,\n");

                                            // append also the text
                                            // representation of the enumeration
                                            if (true) {
                                                tables.append(" ");
                                                tables.append(attrName
                                                        + "_txt ");
                                                tables.append("VARCHAR,\n");
                                            }

                                            Type attrType = (Type) attrdefObj
                                                    .getDomain();
                                            if (attrType instanceof EnumerationType) {
                                                EnumerationType enumerationType = (EnumerationType) attrType;
                                                ch.interlis.ili2c.metamodel.Enumeration enumerations = (ch.interlis.ili2c.metamodel.Enumeration) enumerationType
                                                        .getConsolidatedEnumeration();
View Full Code Here

TOP

Related Classes of ch.interlis.ili2c.metamodel.Type

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.