use of ch.interlis.ili2c.metamodel.PathElAssocRole in project ili2db by claeis.
the class FromIliRecordConverter method getUniqueAttrs.
private HashSet getUniqueAttrs(UniquenessConstraint cnstr, HashSet wrapperCols) {
if (cnstr.getLocal()) {
return null;
}
HashSet ret = new HashSet();
UniqueEl attribs = cnstr.getElements();
Iterator attri = attribs.iteratorAttribute();
for (; attri.hasNext(); ) {
ObjectPath path = (ObjectPath) attri.next();
PathEl[] pathEles = path.getPathElements();
if (pathEles.length != 1) {
return null;
}
PathEl pathEle = pathEles[0];
if (pathEle instanceof AttributeRef) {
AttributeDef attr = ((AttributeRef) pathEle).getAttr();
while (attr.getExtending() != null) {
attr = (AttributeDef) attr.getExtending();
}
if (!wrapperCols.contains(attr)) {
return null;
}
ret.add(attr);
} else if (pathEle instanceof PathElAssocRole) {
RoleDef role = ((PathElAssocRole) pathEle).getRole();
while (role.getExtending() != null) {
role = (RoleDef) role.getExtending();
}
if (!wrapperCols.contains(role)) {
return null;
}
ret.add(role);
} else {
return null;
}
}
return ret;
}
Aggregations