Search in sources :

Example 16 with ViewableTransferElement

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

the class MultiLineMappings method addMultiLineAttr.

public void addMultiLineAttr(AttributeDef multiLineAttr) {
    String bagOfLinesAttrName = null;
    String lineAttrName = null;
    // validate structure
    // create mapping
    Type multiLineTypeo = multiLineAttr.getDomain();
    if (!(multiLineTypeo instanceof CompositionType)) {
        throw new IllegalArgumentException("not a valid multiline attribute " + multiLineAttr.getScopedName(null));
    } else {
        CompositionType multiLineType = (CompositionType) multiLineTypeo;
        Table multiLineStruct = multiLineType.getComponentType();
        Iterator<ViewableTransferElement> it = multiLineStruct.getAttributesAndRoles2();
        if (!it.hasNext()) {
            throw new IllegalArgumentException("not a valid multiline structure " + multiLineStruct.getScopedName(null));
        }
        ViewableTransferElement prop = it.next();
        if (!(prop.obj instanceof AttributeDef)) {
            throw new IllegalArgumentException("not a valid multiline structure " + multiLineStruct.getScopedName(null));
        }
        AttributeDef linesAttr = (AttributeDef) prop.obj;
        bagOfLinesAttrName = linesAttr.getName();
        Type linesTypeo = linesAttr.getDomain();
        if (!(linesTypeo instanceof CompositionType)) {
            throw new IllegalArgumentException("not a valid multiline structure " + multiLineStruct.getScopedName(null));
        } else {
            CompositionType linesType = (CompositionType) linesTypeo;
            Table lineStruct = linesType.getComponentType();
            Iterator<ViewableTransferElement> it2 = lineStruct.getAttributesAndRoles2();
            if (!it2.hasNext()) {
                throw new IllegalArgumentException("not a valid line structure " + lineStruct.getScopedName(null));
            }
            ViewableTransferElement prop2 = it2.next();
            if (!(prop2.obj instanceof AttributeDef)) {
                throw new IllegalArgumentException("not a valid line structure " + lineStruct.getScopedName(null));
            }
            AttributeDef lineAttr = (AttributeDef) prop2.obj;
            Type lineType = lineAttr.getDomainResolvingAliases();
            if (!(lineType instanceof PolylineType)) {
                throw new IllegalArgumentException("not a valid line structure " + lineStruct.getScopedName(null));
            }
            lineAttrName = lineAttr.getName();
        }
    }
    MultiLineMapping mapping = new MultiLineMapping(bagOfLinesAttrName, lineAttrName);
    mappings.put(multiLineAttr, mapping);
}
Also used : ViewableTransferElement(ch.interlis.ili2c.metamodel.ViewableTransferElement) PolylineType(ch.interlis.ili2c.metamodel.PolylineType) SurfaceType(ch.interlis.ili2c.metamodel.SurfaceType) PolylineType(ch.interlis.ili2c.metamodel.PolylineType) 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)

Example 17 with ViewableTransferElement

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

ViewableTransferElement (ch.interlis.ili2c.metamodel.ViewableTransferElement)17 AttributeDef (ch.interlis.ili2c.metamodel.AttributeDef)14 CompositionType (ch.interlis.ili2c.metamodel.CompositionType)13 Type (ch.interlis.ili2c.metamodel.Type)13 SurfaceType (ch.interlis.ili2c.metamodel.SurfaceType)11 CoordType (ch.interlis.ili2c.metamodel.CoordType)10 RoleDef (ch.interlis.ili2c.metamodel.RoleDef)10 AssociationDef (ch.interlis.ili2c.metamodel.AssociationDef)9 EnumerationType (ch.interlis.ili2c.metamodel.EnumerationType)9 PolylineType (ch.interlis.ili2c.metamodel.PolylineType)9 SurfaceOrAreaType (ch.interlis.ili2c.metamodel.SurfaceOrAreaType)9 Iterator (java.util.Iterator)9 ObjectType (ch.interlis.ili2c.metamodel.ObjectType)8 ReferenceType (ch.interlis.ili2c.metamodel.ReferenceType)7 AreaType (ch.interlis.ili2c.metamodel.AreaType)6 BlackboxType (ch.interlis.ili2c.metamodel.BlackboxType)6 HashSet (java.util.HashSet)6 NumericType (ch.interlis.ili2c.metamodel.NumericType)5 Table (ch.interlis.ili2c.metamodel.Table)5 Viewable (ch.interlis.ili2c.metamodel.Viewable)5