Search in sources :

Example 21 with CompositionType

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

the class Ili2cUtility method isPureChbaseMultiLine.

public static boolean isPureChbaseMultiLine(TransferDescription td, AttributeDef attr) {
    Type typeo = attr.getDomain();
    if (typeo instanceof CompositionType) {
        CompositionType type = (CompositionType) typeo;
        Table struct = type.getComponentType();
        Table root = (Table) struct.getRootExtending();
        if (root == null) {
            root = struct;
        }
        String containerQName = root.getContainer().getScopedName(null);
        if (containerQName.equals(IliNames.CHBASE1_GEOMETRYCHLV03) || containerQName.equals(IliNames.CHBASE1_GEOMETRYCHLV95)) {
            if (root.getName().equals(IliNames.CHBASE1_GEOMETRY_MULTILINE) || root.getName().equals(IliNames.CHBASE1_GEOMETRY_MULTIDIRECTEDLINE)) {
                java.util.Iterator it = struct.getAttributesAndRoles2();
                int c = 0;
                while (it.hasNext()) {
                    it.next();
                    c++;
                }
                if (c == 1) {
                    // only one attribute
                    return true;
                }
            }
        }
    }
    return false;
}
Also used : CompositionType(ch.interlis.ili2c.metamodel.CompositionType) Type(ch.interlis.ili2c.metamodel.Type) Table(ch.interlis.ili2c.metamodel.Table) CompositionType(ch.interlis.ili2c.metamodel.CompositionType)

Example 22 with CompositionType

use of ch.interlis.ili2c.metamodel.CompositionType 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 23 with CompositionType

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

CompositionType (ch.interlis.ili2c.metamodel.CompositionType)23 Type (ch.interlis.ili2c.metamodel.Type)17 Table (ch.interlis.ili2c.metamodel.Table)15 AttributeDef (ch.interlis.ili2c.metamodel.AttributeDef)14 CoordType (ch.interlis.ili2c.metamodel.CoordType)10 EnumerationType (ch.interlis.ili2c.metamodel.EnumerationType)10 SurfaceType (ch.interlis.ili2c.metamodel.SurfaceType)10 PolylineType (ch.interlis.ili2c.metamodel.PolylineType)9 SurfaceOrAreaType (ch.interlis.ili2c.metamodel.SurfaceOrAreaType)9 ObjectType (ch.interlis.ili2c.metamodel.ObjectType)7 ReferenceType (ch.interlis.ili2c.metamodel.ReferenceType)7 IomObject (ch.interlis.iom.IomObject)6 ViewableWrapper (ch.ehi.ili2db.mapping.ViewableWrapper)5 AreaType (ch.interlis.ili2c.metamodel.AreaType)5 BlackboxType (ch.interlis.ili2c.metamodel.BlackboxType)5 NumericType (ch.interlis.ili2c.metamodel.NumericType)5 ViewableTransferElement (ch.interlis.ili2c.metamodel.ViewableTransferElement)5 Viewable (ch.interlis.ili2c.metamodel.Viewable)4 ArrayMapping (ch.ehi.ili2db.mapping.ArrayMapping)3 MultiLineMapping (ch.ehi.ili2db.mapping.MultiLineMapping)3