Search in sources :

Example 1 with Term

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;
}
Also used : Universal(com.runwaysdk.system.gis.geo.Universal) Term(com.runwaysdk.business.ontology.Term)

Example 2 with Term

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();
            }
        }
    }
}
Also used : ClassifierQuery(net.geoprism.ontology.ClassifierQuery) QueryFactory(com.runwaysdk.query.QueryFactory) BusinessDAO(com.runwaysdk.dataaccess.BusinessDAO) Classifier(net.geoprism.ontology.Classifier) Term(com.runwaysdk.business.ontology.Term) LinkedList(java.util.LinkedList) Transaction(com.runwaysdk.dataaccess.transaction.Transaction)

Example 3 with Term

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;
    }
}
Also used : InvalidGeoEntityUniversalException(com.runwaysdk.system.gis.geo.InvalidGeoEntityUniversalException) Universal(com.runwaysdk.system.gis.geo.Universal) Term(com.runwaysdk.business.ontology.Term)

Aggregations

Term (com.runwaysdk.business.ontology.Term)3 Universal (com.runwaysdk.system.gis.geo.Universal)2 BusinessDAO (com.runwaysdk.dataaccess.BusinessDAO)1 Transaction (com.runwaysdk.dataaccess.transaction.Transaction)1 QueryFactory (com.runwaysdk.query.QueryFactory)1 InvalidGeoEntityUniversalException (com.runwaysdk.system.gis.geo.InvalidGeoEntityUniversalException)1 LinkedList (java.util.LinkedList)1 Classifier (net.geoprism.ontology.Classifier)1 ClassifierQuery (net.geoprism.ontology.ClassifierQuery)1