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