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);
}
}
}
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);
}
}
}
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);
}
}
}
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;
}
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;
}
Aggregations