Search in sources :

Example 41 with AttributeDef

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

the class MultiSurfaceMappings method addMultiSurfaceAttr.

public void addMultiSurfaceAttr(AttributeDef multiSurfaceAttr) {
    String bagOfSurfacesAttrName = null;
    String surfaceAttrName = null;
    // validate structure
    // create mapping
    Type multiSurfaceTypeo = multiSurfaceAttr.getDomain();
    if (!(multiSurfaceTypeo instanceof CompositionType)) {
        throw new IllegalArgumentException("not a valid multisurface attribute " + multiSurfaceAttr.getScopedName(null));
    } else {
        CompositionType multiSurfaceType = (CompositionType) multiSurfaceTypeo;
        Table multiSurfaceStruct = multiSurfaceType.getComponentType();
        Iterator<ViewableTransferElement> it = multiSurfaceStruct.getAttributesAndRoles2();
        if (!it.hasNext()) {
            throw new IllegalArgumentException("not a valid multisurface structure " + multiSurfaceStruct.getScopedName(null));
        }
        ViewableTransferElement prop = it.next();
        if (!(prop.obj instanceof AttributeDef)) {
            throw new IllegalArgumentException("not a valid multisurface structure " + multiSurfaceStruct.getScopedName(null));
        }
        AttributeDef surfacesAttr = (AttributeDef) prop.obj;
        bagOfSurfacesAttrName = surfacesAttr.getName();
        Type surfacesTypeo = surfacesAttr.getDomain();
        if (!(surfacesTypeo instanceof CompositionType)) {
            throw new IllegalArgumentException("not a valid multisurface structure " + multiSurfaceStruct.getScopedName(null));
        } else {
            CompositionType surfacesType = (CompositionType) surfacesTypeo;
            Table surfaceStruct = surfacesType.getComponentType();
            Iterator<ViewableTransferElement> it2 = surfaceStruct.getAttributesAndRoles2();
            if (!it2.hasNext()) {
                throw new IllegalArgumentException("not a valid surface structure " + surfaceStruct.getScopedName(null));
            }
            ViewableTransferElement prop2 = it2.next();
            if (!(prop2.obj instanceof AttributeDef)) {
                throw new IllegalArgumentException("not a valid surface structure " + surfaceStruct.getScopedName(null));
            }
            AttributeDef surfaceAttr = (AttributeDef) prop2.obj;
            Type surfaceType = surfaceAttr.getDomainResolvingAliases();
            if (!(surfaceType instanceof SurfaceType)) {
                throw new IllegalArgumentException("not a valid surface structure " + surfaceStruct.getScopedName(null));
            }
            surfaceAttrName = surfaceAttr.getName();
        }
    }
    MultiSurfaceMapping mapping = new MultiSurfaceMapping(bagOfSurfacesAttrName, surfaceAttrName);
    mappings.put(multiSurfaceAttr, mapping);
}
Also used : ViewableTransferElement(ch.interlis.ili2c.metamodel.ViewableTransferElement) SurfaceType(ch.interlis.ili2c.metamodel.SurfaceType) CompositionType(ch.interlis.ili2c.metamodel.CompositionType) Type(ch.interlis.ili2c.metamodel.Type) Table(ch.interlis.ili2c.metamodel.Table) AttributeDef(ch.interlis.ili2c.metamodel.AttributeDef) CompositionType(ch.interlis.ili2c.metamodel.CompositionType) SurfaceType(ch.interlis.ili2c.metamodel.SurfaceType)

Aggregations

AttributeDef (ch.interlis.ili2c.metamodel.AttributeDef)41 Iterator (java.util.Iterator)25 CompositionType (ch.interlis.ili2c.metamodel.CompositionType)22 SurfaceOrAreaType (ch.interlis.ili2c.metamodel.SurfaceOrAreaType)21 SurfaceType (ch.interlis.ili2c.metamodel.SurfaceType)21 EnumerationType (ch.interlis.ili2c.metamodel.EnumerationType)19 Type (ch.interlis.ili2c.metamodel.Type)18 Table (ch.interlis.ili2c.metamodel.Table)16 CoordType (ch.interlis.ili2c.metamodel.CoordType)15 IomObject (ch.interlis.iom.IomObject)15 Viewable (ch.interlis.ili2c.metamodel.Viewable)14 ViewableTransferElement (ch.interlis.ili2c.metamodel.ViewableTransferElement)14 PolylineType (ch.interlis.ili2c.metamodel.PolylineType)13 HashSet (java.util.HashSet)13 ViewableWrapper (ch.ehi.ili2db.mapping.ViewableWrapper)12 ObjectType (ch.interlis.ili2c.metamodel.ObjectType)12 AssociationDef (ch.interlis.ili2c.metamodel.AssociationDef)11 ReferenceType (ch.interlis.ili2c.metamodel.ReferenceType)11 RoleDef (ch.interlis.ili2c.metamodel.RoleDef)10 DbTableName (ch.ehi.sqlgen.repository.DbTableName)9