Search in sources :

Example 31 with Viewable

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

the class Viewable2TableMapper method doSmartOff.

private void doSmartOff(List<Element> eles) {
    /*
		 * Alle Klassen mit NewClass-Strategie abbilden
		 */
    for (Element ele : eles) {
        if (!(ele instanceof Viewable)) {
        // not a Viewable; skip it
        } else {
            // a Viewable
            Viewable aclass = (Viewable) ele;
            if (trafoConfig.getViewableConfig(aclass, TrafoConfigNames.INHERITANCE_TRAFO) == null) {
                // newClass
                trafoConfig.setViewableConfig(aclass, TrafoConfigNames.INHERITANCE_TRAFO, TrafoConfigNames.INHERITANCE_TRAFO_NEWCLASS);
            }
            String sqlTablename = nameMapping.mapIliClassDef(aclass);
            EhiLogger.traceState("viewable " + aclass.getScopedName(null) + " " + trafoConfig.getViewableConfig(aclass, TrafoConfigNames.INHERITANCE_TRAFO) + ", " + sqlTablename);
        }
    }
}
Also used : ViewableTransferElement(ch.interlis.ili2c.metamodel.ViewableTransferElement) Element(ch.interlis.ili2c.metamodel.Element) Viewable(ch.interlis.ili2c.metamodel.Viewable)

Example 32 with Viewable

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

the class Viewable2TableMapper method doSmart2.

private void doSmart2(List<Element> eles) {
    /*
		 * Alle abstrakten Klassen werden mit einer
		 * SubClass-Strategie abgebildet. 
		 * Alle konkreten Klassen werden mit einer NewAndSubClass-Strategie 
		 * abgebildet.
		 */
    for (Element ele : eles) {
        if (!(ele instanceof Viewable)) {
        // not a Viewable; skip it
        } else {
            // a Viewable
            Viewable aclass = (Viewable) ele;
            if (trafoConfig.getViewableConfig(aclass, TrafoConfigNames.INHERITANCE_TRAFO) == null) {
                if (aclass.isAbstract()) {
                    // subClass
                    trafoConfig.setViewableConfig(aclass, TrafoConfigNames.INHERITANCE_TRAFO, TrafoConfigNames.INHERITANCE_TRAFO_SUBCLASS);
                } else {
                    // newAndSubClass
                    trafoConfig.setViewableConfig(aclass, TrafoConfigNames.INHERITANCE_TRAFO, TrafoConfigNames.INHERITANCE_TRAFO_NEWANDSUBCLASS);
                }
            }
            String sqlTablename = nameMapping.mapIliClassDef(aclass);
            EhiLogger.traceState("viewable " + aclass.getScopedName(null) + " " + trafoConfig.getViewableConfig(aclass, TrafoConfigNames.INHERITANCE_TRAFO) + ", " + sqlTablename);
        }
    }
}
Also used : ViewableTransferElement(ch.interlis.ili2c.metamodel.ViewableTransferElement) Element(ch.interlis.ili2c.metamodel.Element) Viewable(ch.interlis.ili2c.metamodel.Viewable)

Example 33 with Viewable

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

the class Viewable2TableMapper method doSmart1.

private void doSmart1(List<Element> eles) {
    /*
		 * Fuer Klassen, die referenziert werden und deren Basisklassen nicht mit
		 * einer NewClass-Strategie abgebildet werden, wird die
		 * NewClass-Strategie verwendet. Abstrakte Klassen werden mit einer
		 * SubClass-Strategie abgebildet. Konkrete Klassen, ohne Basisklasse
		 * oder deren direkte Basisklassen mit einer SubClass-Strategie
		 * abgebildet werden, werden mit einer NewClass-Strategie abgebildet.
		 * Alle anderen Klassen werden mit einer SuperClass-Strategie
		 * abgebildet.
		 */
    for (Element ele : eles) {
        if (!(ele instanceof Viewable)) {
        // not a Viewable; skip it
        } else {
            // a Viewable
            Viewable aclass = (Viewable) ele;
            if (trafoConfig.getViewableConfig(aclass, TrafoConfigNames.INHERITANCE_TRAFO) == null) {
                if (isReferenced(aclass) && noBaseIsNewClass(trafoConfig, aclass)) {
                    // newClass
                    trafoConfig.setViewableConfig(aclass, TrafoConfigNames.INHERITANCE_TRAFO, TrafoConfigNames.INHERITANCE_TRAFO_NEWCLASS);
                } else if (aclass.isAbstract()) {
                    // subClass
                    trafoConfig.setViewableConfig(aclass, TrafoConfigNames.INHERITANCE_TRAFO, TrafoConfigNames.INHERITANCE_TRAFO_SUBCLASS);
                } else {
                    Viewable base = (Viewable) aclass.getExtending();
                    if (base == null || TrafoConfigNames.INHERITANCE_TRAFO_SUBCLASS.equals(trafoConfig.getViewableConfig(base, TrafoConfigNames.INHERITANCE_TRAFO))) {
                        // newClass
                        trafoConfig.setViewableConfig(aclass, TrafoConfigNames.INHERITANCE_TRAFO, TrafoConfigNames.INHERITANCE_TRAFO_NEWCLASS);
                    } else {
                        // superClass
                        trafoConfig.setViewableConfig(aclass, TrafoConfigNames.INHERITANCE_TRAFO, TrafoConfigNames.INHERITANCE_TRAFO_SUPERCLASS);
                    }
                }
            }
            String sqlTablename = nameMapping.mapIliClassDef(aclass);
            EhiLogger.traceState("viewable " + aclass.getScopedName(null) + " " + trafoConfig.getViewableConfig(aclass, TrafoConfigNames.INHERITANCE_TRAFO) + ", " + sqlTablename);
        }
    }
}
Also used : ViewableTransferElement(ch.interlis.ili2c.metamodel.ViewableTransferElement) Element(ch.interlis.ili2c.metamodel.Element) Viewable(ch.interlis.ili2c.metamodel.Viewable)

Example 34 with Viewable

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

the class Viewable2TableMapper method noBaseIsNewClass.

private static boolean noBaseIsNewClass(TrafoConfig trafoConfig, Viewable aclass) {
    Viewable base = (Viewable) aclass.getExtending();
    while (base != null) {
        String baseInheritanceStrategy = trafoConfig.getViewableConfig(base, TrafoConfigNames.INHERITANCE_TRAFO);
        if (TrafoConfigNames.INHERITANCE_TRAFO_NEWCLASS.equals(baseInheritanceStrategy)) {
            return false;
        }
        base = (Viewable) base.getExtending();
    }
    return true;
}
Also used : Viewable(ch.interlis.ili2c.metamodel.Viewable)

Example 35 with Viewable

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

the class ViewableWrapper method getOid.

public Domain getOid() {
    if (isSecondaryTable()) {
        return null;
    }
    Viewable def = getViewable();
    if (!(def instanceof AbstractClassDef)) {
        return null;
    }
    if ((def instanceof Table) && !((Table) def).isIdentifiable()) {
        return null;
    }
    AbstractClassDef aclass = (AbstractClassDef) def;
    if (aclass.getOid() != null) {
        return aclass.getOid();
    }
    for (Object exto : aclass.getExtensions()) {
        AbstractClassDef ext = (AbstractClassDef) exto;
        if (ext.getOid() != null) {
            return ext.getOid();
        }
    }
    return null;
}
Also used : Table(ch.interlis.ili2c.metamodel.Table) Viewable(ch.interlis.ili2c.metamodel.Viewable) AbstractClassDef(ch.interlis.ili2c.metamodel.AbstractClassDef)

Aggregations

Viewable (ch.interlis.ili2c.metamodel.Viewable)36 Iterator (java.util.Iterator)16 AttributeDef (ch.interlis.ili2c.metamodel.AttributeDef)14 IomObject (ch.interlis.iom.IomObject)13 ViewableWrapper (ch.ehi.ili2db.mapping.ViewableWrapper)11 SurfaceOrAreaType (ch.interlis.ili2c.metamodel.SurfaceOrAreaType)10 EnumerationType (ch.interlis.ili2c.metamodel.EnumerationType)9 ArrayList (java.util.ArrayList)9 CompositionType (ch.interlis.ili2c.metamodel.CompositionType)8 SurfaceType (ch.interlis.ili2c.metamodel.SurfaceType)8 ViewableTransferElement (ch.interlis.ili2c.metamodel.ViewableTransferElement)8 Topic (ch.interlis.ili2c.metamodel.Topic)7 Type (ch.interlis.ili2c.metamodel.Type)7 HashSet (java.util.HashSet)7 Ili2dbException (ch.ehi.ili2db.base.Ili2dbException)6 Model (ch.interlis.ili2c.metamodel.Model)6 ObjectType (ch.interlis.ili2c.metamodel.ObjectType)6 DbTableName (ch.ehi.sqlgen.repository.DbTableName)5 CoordType (ch.interlis.ili2c.metamodel.CoordType)5 NumericType (ch.interlis.ili2c.metamodel.NumericType)5