Examples of EnumerationType


Examples of ch.interlis.ili2c.metamodel.EnumerationType

                    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();

                                                String enumName = "enum__"
                                                        + tableName + "_"
                                                        + attrName;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.