Search in sources :

Example 1 with Universal

use of com.runwaysdk.system.gis.geo.Universal in project geoprism-registry by terraframe.

the class HierarchicalRelationshipType method removeFromHierarchy.

@Transaction
public void removeFromHierarchy(ServerGeoObjectType parentType, ServerGeoObjectType childType, boolean migrateChildren) {
    Universal parent = parentType.getUniversal();
    Universal cUniversal = childType.getUniversal();
    removeLink(parent, cUniversal, this.getMdTermRelationship().definesType());
    if (migrateChildren) {
        TermAndRel[] tnrChildren = TermUtil.getDirectDescendants(cUniversal.getOid(), new String[] { this.getMdTermRelationship().definesType() });
        if (parent.getKey().equals(Universal.ROOT) && tnrChildren.length > 1) {
            MultipleHierarchyRootsException ex = new MultipleHierarchyRootsException();
            throw ex;
        }
        for (TermAndRel tnrChild : tnrChildren) {
            Universal child = (Universal) tnrChild.getTerm();
            removeLink(cUniversal, child, this.getMdTermRelationship().definesType());
            child.addLink(parent, this.getMdTermRelationship().definesType());
        }
    }
}
Also used : MultipleHierarchyRootsException(net.geoprism.registry.graph.MultipleHierarchyRootsException) Universal(com.runwaysdk.system.gis.geo.Universal) TermAndRel(com.runwaysdk.business.ontology.TermAndRel) Transaction(com.runwaysdk.dataaccess.transaction.Transaction)

Example 2 with Universal

use of com.runwaysdk.system.gis.geo.Universal in project geoprism-registry by terraframe.

the class HierarchicalRelationshipType method getChildren.

public List<ServerGeoObjectType> getChildren(ServerGeoObjectType parent) {
    Universal universal = parent.getUniversal();
    List<ServerGeoObjectType> children = new LinkedList<>();
    String mdRelationshipType = this.getMdTermRelationship().definesType();
    try (OIterator<? extends Business> iterator = universal.getDirectDescendants(mdRelationshipType)) {
        while (iterator.hasNext()) {
            Universal cUniversal = (Universal) iterator.next();
            children.add(ServerGeoObjectType.get(cUniversal));
        }
    }
    return children;
}
Also used : Universal(com.runwaysdk.system.gis.geo.Universal) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) LinkedList(java.util.LinkedList)

Example 3 with Universal

use of com.runwaysdk.system.gis.geo.Universal in project geoprism-registry by terraframe.

the class Organization method getGeoObjectTypes.

/**
 * Return a map of {@link GeoObjectType} codes and labels for this
 * {@link Organization}.
 *
 * @return a map of {@link GeoObjectType} codes and labels for this
 *         {@link Organization}.
 */
public Map<String, ServerGeoObjectType> getGeoObjectTypes() {
    // For performance, get all of the universals defined
    List<? extends EntityDAOIF> universalList = ObjectCache.getCachedEntityDAOs(Universal.CLASS);
    Map<String, ServerGeoObjectType> typeCodeMap = new HashMap<String, ServerGeoObjectType>();
    for (EntityDAOIF entityDAOIF : universalList) {
        Universal universal = (Universal) BusinessFacade.get(entityDAOIF);
        // Check to see if the universal is owned by the organization role.
        String ownerId = universal.getOwnerOid();
        Roles organizationRole = this.getRole();
        if (ownerId.equals(organizationRole.getOid())) {
            ServerGeoObjectType type = ServerGeoObjectType.get(universal);
            typeCodeMap.put(type.getCode(), type);
        }
    }
    return typeCodeMap;
}
Also used : Universal(com.runwaysdk.system.gis.geo.Universal) HashMap(java.util.HashMap) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) EntityDAOIF(com.runwaysdk.dataaccess.EntityDAOIF) Roles(com.runwaysdk.system.Roles)

Example 4 with Universal

use of com.runwaysdk.system.gis.geo.Universal 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 5 with Universal

use of com.runwaysdk.system.gis.geo.Universal in project geoprism-registry by terraframe.

the class PatchExistsAndInvalid method addAttributes.

@Transaction
private void addAttributes() {
    List<Universal> unis = getUniversals();
    for (Universal uni : unis) {
        MdBusinessDAO bizDAO = (MdBusinessDAO) BusinessFacade.getEntityDAO(uni.getMdBusiness());
        MdAttributeConcreteDAO postgresStatusAttr = (MdAttributeConcreteDAO) bizDAO.definesAttribute(STATUS_ATTRIBUTE_NAME);
        if (postgresStatusAttr != null) {
            postgresStatusAttr.delete();
        }
        MdGeoVertexDAO mdVertex = GeoVertexType.getMdGeoVertex(uni.getUniversalId());
        MdAttributeEnumerationDAO statusMdAttr = (MdAttributeEnumerationDAO) mdVertex.definesAttribute(STATUS_ATTRIBUTE_NAME);
        if (statusMdAttr != null) {
            statusMdAttr.delete();
        }
    }
    for (Universal uni : unis) {
        ServerGeoObjectType type = new ServerGeoObjectTypeConverter().build(uni);
        MdGraphClassDAOIF mdClass = type.getMdVertex();
        MdAttributeDAOIF existing = mdClass.definesAttribute(DefaultAttribute.EXISTS.getName());
        if (existing == null) {
            logger.info("Adding new attributes to [" + mdClass.getKey() + "].");
            MdAttributeBooleanDAO existsMdAttr = MdAttributeBooleanDAO.newInstance();
            existsMdAttr.setValue(MdAttributeConcreteInfo.NAME, DefaultAttribute.EXISTS.getName());
            existsMdAttr.setStructValue(MdAttributeConcreteInfo.DISPLAY_LABEL, MdAttributeLocalInfo.DEFAULT_LOCALE, DefaultAttribute.EXISTS.getDefaultLocalizedName());
            existsMdAttr.setStructValue(MdAttributeConcreteInfo.DESCRIPTION, MdAttributeLocalInfo.DEFAULT_LOCALE, DefaultAttribute.EXISTS.getDefaultDescription());
            existsMdAttr.setValue(MdAttributeConcreteInfo.DEFINING_MD_CLASS, mdClass.getOid());
            existsMdAttr.setValue(MdAttributeConcreteInfo.REQUIRED, MdAttributeBooleanInfo.FALSE);
            existsMdAttr.setValue(MdAttributeConcreteInfo.DEFAULT_VALUE, MdAttributeBooleanInfo.FALSE);
            existsMdAttr.addItem(MdAttributeConcreteInfo.INDEX_TYPE, IndexTypes.NON_UNIQUE_INDEX.getOid());
            existsMdAttr.apply();
            MdAttributeBooleanDAO invalidMdAttr = MdAttributeBooleanDAO.newInstance();
            invalidMdAttr.setValue(MdAttributeConcreteInfo.NAME, DefaultAttribute.INVALID.getName());
            invalidMdAttr.setStructValue(MdAttributeConcreteInfo.DISPLAY_LABEL, MdAttributeLocalInfo.DEFAULT_LOCALE, DefaultAttribute.INVALID.getDefaultLocalizedName());
            invalidMdAttr.setStructValue(MdAttributeConcreteInfo.DESCRIPTION, MdAttributeLocalInfo.DEFAULT_LOCALE, DefaultAttribute.INVALID.getDefaultDescription());
            invalidMdAttr.setValue(MdAttributeConcreteInfo.DEFINING_MD_CLASS, mdClass.getOid());
            invalidMdAttr.setValue(MdAttributeConcreteInfo.REQUIRED, MdAttributeBooleanInfo.FALSE);
            invalidMdAttr.setValue(MdAttributeConcreteInfo.DEFAULT_VALUE, MdAttributeBooleanInfo.FALSE);
            invalidMdAttr.addItem(MdAttributeConcreteInfo.INDEX_TYPE, IndexTypes.NON_UNIQUE_INDEX.getOid());
            invalidMdAttr.apply();
        }
    }
    patchMasterlistVersions();
// TODO : We can't actually set this field to required unfortunately because of many different graph bugs.
// If we set it to required immediately when it's created, orientdb throws an error saying that objects
// don't have a required field. If we try to update the field to set it as required after the instance
// data has been patched, Runway tries to create the attribute twice because the MdAttribute in the cache
// still has the 'isNew' flag set to true. We can't do this in a separate transaction because the patching
// transaction is controlled at a higher level than we have access to here.
// enforceInvalidRequired();
}
Also used : MdAttributeConcreteDAO(com.runwaysdk.dataaccess.metadata.MdAttributeConcreteDAO) Universal(com.runwaysdk.system.gis.geo.Universal) MdAttributeEnumerationDAO(com.runwaysdk.dataaccess.metadata.MdAttributeEnumerationDAO) ServerGeoObjectTypeConverter(net.geoprism.registry.conversion.ServerGeoObjectTypeConverter) MdBusinessDAO(com.runwaysdk.dataaccess.metadata.MdBusinessDAO) MdAttributeDAOIF(com.runwaysdk.dataaccess.MdAttributeDAOIF) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) MdAttributeBooleanDAO(com.runwaysdk.dataaccess.metadata.MdAttributeBooleanDAO) MdGraphClassDAOIF(com.runwaysdk.dataaccess.MdGraphClassDAOIF) MdGeoVertexDAO(com.runwaysdk.gis.dataaccess.metadata.graph.MdGeoVertexDAO) Transaction(com.runwaysdk.dataaccess.transaction.Transaction)

Aggregations

Universal (com.runwaysdk.system.gis.geo.Universal)26 ServerGeoObjectType (net.geoprism.registry.model.ServerGeoObjectType)8 QueryFactory (com.runwaysdk.query.QueryFactory)7 LinkedList (java.util.LinkedList)7 ServerGeoObjectTypeConverter (net.geoprism.registry.conversion.ServerGeoObjectTypeConverter)6 Transaction (com.runwaysdk.dataaccess.transaction.Transaction)5 UniversalQuery (com.runwaysdk.system.gis.geo.UniversalQuery)5 JsonObject (com.google.gson.JsonObject)3 MdGraphClassDAOIF (com.runwaysdk.dataaccess.MdGraphClassDAOIF)3 MdGeoVertexDAO (com.runwaysdk.gis.dataaccess.metadata.graph.MdGeoVertexDAO)3 JsonArray (com.google.gson.JsonArray)2 Term (com.runwaysdk.business.ontology.Term)2 MdAttributeDAOIF (com.runwaysdk.dataaccess.MdAttributeDAOIF)2 ValueOverTime (com.runwaysdk.dataaccess.graph.attributes.ValueOverTime)2 MdAttributeTerm (com.runwaysdk.system.metadata.MdAttributeTerm)2 List (java.util.List)2 Organization (net.geoprism.registry.Organization)2 GeoObjectTypeMetadata (net.geoprism.registry.model.GeoObjectTypeMetadata)2 Term (org.commongeoregistry.adapter.Term)2 GeoObjectType (org.commongeoregistry.adapter.metadata.GeoObjectType)2