Search in sources :

Example 11 with RoleDef

use of ch.interlis.ili2c.metamodel.RoleDef 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)

Example 12 with RoleDef

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

the class Viewable2TableMapper method isReferenced.

private static boolean isReferenced(Viewable viewable) {
    if (viewable instanceof AbstractClassDef) {
        AbstractClassDef aclass = (AbstractClassDef) viewable;
        Iterator<RoleDef> rolei = aclass.getDefinedTargetForRoles();
        while (rolei.hasNext()) {
            RoleDef role = rolei.next();
            AssociationDef assoc = (AssociationDef) role.getContainer();
            if (!assoc.isLightweight()) {
                return true;
            }
            if (!role.isAssociationEmbedded()) {
                // opposide role is embedded into opposide class, so opposide class references this viewable
                return true;
            }
        }
    }
    return false;
}
Also used : RoleDef(ch.interlis.ili2c.metamodel.RoleDef) AssociationDef(ch.interlis.ili2c.metamodel.AssociationDef) AbstractClassDef(ch.interlis.ili2c.metamodel.AbstractClassDef)

Aggregations

RoleDef (ch.interlis.ili2c.metamodel.RoleDef)12 AssociationDef (ch.interlis.ili2c.metamodel.AssociationDef)10 AttributeDef (ch.interlis.ili2c.metamodel.AttributeDef)10 ViewableTransferElement (ch.interlis.ili2c.metamodel.ViewableTransferElement)10 Iterator (java.util.Iterator)9 CompositionType (ch.interlis.ili2c.metamodel.CompositionType)8 CoordType (ch.interlis.ili2c.metamodel.CoordType)8 EnumerationType (ch.interlis.ili2c.metamodel.EnumerationType)8 PolylineType (ch.interlis.ili2c.metamodel.PolylineType)8 SurfaceOrAreaType (ch.interlis.ili2c.metamodel.SurfaceOrAreaType)8 SurfaceType (ch.interlis.ili2c.metamodel.SurfaceType)8 Type (ch.interlis.ili2c.metamodel.Type)8 ObjectType (ch.interlis.ili2c.metamodel.ObjectType)7 ReferenceType (ch.interlis.ili2c.metamodel.ReferenceType)7 HashSet (java.util.HashSet)7 AreaType (ch.interlis.ili2c.metamodel.AreaType)6 BlackboxType (ch.interlis.ili2c.metamodel.BlackboxType)6 NumericType (ch.interlis.ili2c.metamodel.NumericType)5 ViewableWrapper (ch.ehi.ili2db.mapping.ViewableWrapper)4 LineType (ch.interlis.ili2c.metamodel.LineType)3