use of com.runwaysdk.business.ontology.Term in project geoprism-registry by terraframe.
the class GeoObjectTypeMetadata method hasPrivateParents.
public boolean hasPrivateParents() {
List<ServerHierarchyType> hierarchyTypes = ServiceFactory.getMetadataCache().getAllHierarchyTypes();
final Universal root = Universal.getRoot();
for (ServerHierarchyType ht : hierarchyTypes) {
Collection<Term> uniParents = GeoEntityUtil.getOrderedAncestors(root, this.getUniversal(), ht.getUniversalType());
if (uniParents.size() > 1) {
for (Term uniParent : uniParents) {
if (!this.getKey().equals(uniParent.getKey()) && GeoObjectTypeMetadata.getByKey(uniParent.getKey()).getIsPrivate()) {
return true;
}
}
}
}
return false;
}
use of com.runwaysdk.business.ontology.Term in project geoprism-registry by terraframe.
the class PatchTerms method doIt.
@Transaction
private void doIt() {
ClassifierQuery gQuery = new ClassifierQuery(new QueryFactory());
Classifier clazz = this.getByClassifierId("CLASS");
BusinessDAO clazzDAO = BusinessDAO.get(clazz.getOid()).getBusinessDAO();
clazzDAO.setValue(Classifier.CLASSIFIERPACKAGE, RegistryConstants.REGISTRY_PACKAGE);
clazzDAO.setValue(Classifier.KEYNAME, "CLASS");
clazzDAO.apply();
Classifier root = this.getByClassifierId("ROOT");
BusinessDAO rootDAO = BusinessDAO.get(root.getOid()).getBusinessDAO();
rootDAO.setValue(Classifier.CLASSIFIERPACKAGE, "ROOT");
rootDAO.setValue(Classifier.KEYNAME, "ROOT");
rootDAO.apply();
try (OIterator<? extends Classifier> it = gQuery.getIterator()) {
while (it.hasNext()) {
Classifier classifier = it.next();
LinkedList<Term> parents = new LinkedList<>(GeoEntityUtil.getOrderedAncestors(root, classifier, ClassifierIsARelationship.CLASS));
Collections.reverse(parents);
// Root -> Class Root -> Class -> Attribute -> Option
if (parents.size() == 4) {
Iterator<Term> pit = parents.iterator();
// while (pit.hasNext())
// {
// Classifier p = (Classifier) pit.next();
//
// // logger.error("[" + p.getClassifierId() + "]: ");
// System.out.println(" Parent [" + p.getClassifierId() + "]: ");
// }
pit = parents.iterator();
pit.next();
Classifier parent = (Classifier) pit.next();
classifier.appLock();
classifier.setClassifierPackage(parent.getKey());
classifier.setKeyName(Classifier.buildKey(parent.getKey(), classifier.getClassifierId()));
classifier.apply();
} else if (!(classifier.getOid().equals(clazz.getOid()) || classifier.getOid().equals(root.getOid()))) {
classifier.appLock();
classifier.setClassifierPackage(RegistryConstants.REGISTRY_PACKAGE);
classifier.setKeyName(Classifier.buildKey(RegistryConstants.REGISTRY_PACKAGE, classifier.getClassifierId()));
classifier.apply();
}
}
}
}
use of com.runwaysdk.business.ontology.Term in project geoprism-registry by terraframe.
the class ServerHierarchyType method validateUniversalRelationship.
public void validateUniversalRelationship(ServerGeoObjectType childType, ServerGeoObjectType parentType) {
// Total hack for super types
Universal childUniversal = childType.getUniversal();
Universal parentUniversal = parentType.getUniversal();
List<Term> ancestors = childUniversal.getAllAncestors(this.getUniversalType()).getAll();
if (!ancestors.contains(parentUniversal)) {
ServerGeoObjectType superType = childType.getSuperType();
if (superType != null) {
ancestors = superType.getUniversal().getAllAncestors(this.getUniversalType()).getAll();
}
}
if (!ancestors.contains(parentUniversal)) {
InvalidGeoEntityUniversalException exception = new InvalidGeoEntityUniversalException();
exception.setChildUniversal(childUniversal.getDisplayLabel().getValue());
exception.setParentUniversal(parentUniversal.getDisplayLabel().getValue());
exception.apply();
throw exception;
}
}
Aggregations