Search in sources :

Example 16 with Universal

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

the class RegistryService method refreshMetadataCache.

public void refreshMetadataCache() {
    ServiceFactory.getMetadataCache().rebuild();
    QueryFactory qf = new QueryFactory();
    UniversalQuery uq = new UniversalQuery(qf);
    OIterator<? extends Universal> it = uq.getIterator();
    try {
        while (it.hasNext()) {
            Universal uni = it.next();
            if (uni.getKey().equals(Universal.ROOT_KEY)) {
                continue;
            }
            ServerGeoObjectType type = new ServerGeoObjectTypeConverter().build(uni);
            ServiceFactory.getMetadataCache().addGeoObjectType(type);
        }
    } finally {
        it.close();
    }
    // We must build the hierarchy types which are inherited first
    // Otherwise you will end up with a NPE when building the hierarchies
    // which inherit the inherited hierarchy if it hasn't been built
    HierarchicalRelationshipType.getInheritedTypes().forEach(relationship -> {
        ServerHierarchyType ht = new ServerHierarchyTypeBuilder().get(relationship, false);
        ServiceFactory.getMetadataCache().addHierarchyType(ht);
    });
    HierarchicalRelationshipType.getAll().forEach(relationship -> {
        ServerHierarchyType ht = new ServerHierarchyTypeBuilder().get(relationship, false);
        if (!ServiceFactory.getMetadataCache().getHierachyType(ht.getCode()).isPresent()) {
            ServiceFactory.getMetadataCache().addHierarchyType(ht);
        }
    });
    try {
        // This is, unfortunately, a big hack. Some patch items need to occur
        // before the organizaiton class is defined
        MdClassDAO.getMdClassDAO(Organization.CLASS);
        OrganizationQuery oQ = new OrganizationQuery(qf);
        OIterator<? extends Organization> it3 = oQ.getIterator();
        try {
            while (it3.hasNext()) {
                Organization organization = it3.next();
                ServiceFactory.getMetadataCache().addOrganization(organization);
            }
        } finally {
            it3.close();
        }
    } catch (com.runwaysdk.dataaccess.cache.DataNotFoundException e) {
    // skip for now
    }
}
Also used : ServerHierarchyType(net.geoprism.registry.model.ServerHierarchyType) QueryFactory(com.runwaysdk.query.QueryFactory) Universal(com.runwaysdk.system.gis.geo.Universal) ServerGeoObjectTypeConverter(net.geoprism.registry.conversion.ServerGeoObjectTypeConverter) Organization(net.geoprism.registry.Organization) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) OrganizationQuery(net.geoprism.registry.OrganizationQuery) ServerHierarchyTypeBuilder(net.geoprism.registry.conversion.ServerHierarchyTypeBuilder) UniversalQuery(com.runwaysdk.system.gis.geo.UniversalQuery)

Example 17 with Universal

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

the class TestGeoObjectTypeInfo method getServerObject.

public ServerGeoObjectType getServerObject(boolean forceFetch) {
    if (this.serverObject != null && !forceFetch) {
        return this.serverObject;
    } else {
        Optional<ServerGeoObjectType> got = ServiceFactory.getMetadataCache().getGeoObjectType(code);
        if (got.isPresent()) {
            this.serverObject = got.get();
            return this.serverObject;
        } else {
            Universal uni = TestDataSet.getUniversalIfExist(getCode());
            if (uni == null) {
                return null;
            }
            this.serverObject = new ServerGeoObjectTypeConverter().build(uni);
            return this.serverObject;
        }
    }
}
Also used : Universal(com.runwaysdk.system.gis.geo.Universal) ServerGeoObjectTypeConverter(net.geoprism.registry.conversion.ServerGeoObjectTypeConverter) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType)

Example 18 with Universal

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

the class MasterList method create.

@Transaction
public static MasterList create(JsonObject object) {
    MasterList list = MasterList.fromJSON(object);
    if (Session.getCurrentSession() != null && Session.getCurrentSession().getUser() != null) {
        list.enforceActorHasPermission(Operation.CREATE);
    }
    if (list.getIsMaster() != null && list.getIsMaster()) {
        Universal universal = list.getUniversal();
        MasterListQuery query = new MasterListQuery(new QueryFactory());
        query.WHERE(query.getUniversal().EQ(universal));
        query.AND(query.getOrganization().EQ(list.getOrganization()));
        query.AND(query.getIsMaster().EQ(true));
        if (!list.isNew()) {
            query.AND(query.getOid().NE(list.getOid()));
        }
        if (query.getCount() > 0) {
            DuplicateMasterListException ex = new DuplicateMasterListException();
            ex.setGeoObjectType(universal.getDisplayLabel().getValue());
            throw ex;
        }
    }
    list.apply();
    return list;
}
Also used : Universal(com.runwaysdk.system.gis.geo.Universal) QueryFactory(com.runwaysdk.query.QueryFactory) Transaction(com.runwaysdk.dataaccess.transaction.Transaction)

Example 19 with Universal

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

the class GeoObjectTypeMetadata method isReferencedInPublicListTypes.

private boolean isReferencedInPublicListTypes() {
    Universal uni = this.getUniversal();
    ServerGeoObjectType type = this.getServerType();
    QueryFactory qf = new QueryFactory();
    ListTypeVersionQuery versionQuery = new ListTypeVersionQuery(qf);
    versionQuery.WHERE(versionQuery.getListVisibility().EQ(ListType.PUBLIC));
    versionQuery.OR(versionQuery.getGeospatialVisibility().EQ(ListType.PUBLIC));
    ListTypeQuery mlq = new ListTypeQuery(qf);
    mlq.WHERE(mlq.EQ(versionQuery.getListType()));
    OIterator<? extends ListType> it = mlq.getIterator();
    while (it.hasNext()) {
        ListType list = it.next();
        if (list.getUniversal().getOid().equals(uni.getOid())) {
            PrivateTypeIsReferencedInPublicMasterLists ex = new PrivateTypeIsReferencedInPublicMasterLists();
            ex.setTypeLabel(this.getServerType().getLabel().getValue());
            throw ex;
        } else {
            JsonArray hierarchies = list.getHierarchiesAsJson();
            for (int i = 0; i < hierarchies.size(); i++) {
                JsonObject hierarchy = hierarchies.get(i).getAsJsonObject();
                JsonArray parents = hierarchy.get("parents").getAsJsonArray();
                for (int j = 0; j < parents.size(); ++j) {
                    JsonObject parent = parents.get(j).getAsJsonObject();
                    if (parent.has("selected") && parent.get("selected").getAsBoolean()) {
                        if (parent.has("code") && parent.get("code").getAsString().equals(type.getCode())) {
                            return true;
                        }
                    }
                }
            }
        }
    }
    return false;
}
Also used : JsonArray(com.google.gson.JsonArray) Universal(com.runwaysdk.system.gis.geo.Universal) QueryFactory(com.runwaysdk.query.QueryFactory) PrivateTypeIsReferencedInPublicMasterLists(net.geoprism.registry.geoobjecttype.PrivateTypeIsReferencedInPublicMasterLists) ListType(net.geoprism.registry.ListType) ListTypeQuery(net.geoprism.registry.ListTypeQuery) JsonObject(com.google.gson.JsonObject) ListTypeVersionQuery(net.geoprism.registry.ListTypeVersionQuery)

Example 20 with Universal

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

the class CRAttributePatch method getUniversals.

public static List<Universal> getUniversals() {
    QueryFactory qf = new QueryFactory();
    UniversalQuery uq = new UniversalQuery(qf);
    @SuppressWarnings("unchecked") List<Universal> unis = (List<Universal>) uq.getIterator().getAll();
    Iterator<Universal> it = unis.iterator();
    while (it.hasNext()) {
        Universal uni = it.next();
        if (uni.getKey().equals(Universal.ROOT_KEY)) {
            it.remove();
            continue;
        }
    // MdGeoVertexDAOIF superType = GeoVertexType.getMdGeoVertex(uni.getUniversalId()).getSuperClass();
    // 
    // if (superType != null && !superType.definesType().equals(GeoVertex.CLASS))
    // {
    // it.remove();
    // continue;
    // }
    }
    return unis;
}
Also used : QueryFactory(com.runwaysdk.query.QueryFactory) Universal(com.runwaysdk.system.gis.geo.Universal) List(java.util.List) UniversalQuery(com.runwaysdk.system.gis.geo.UniversalQuery)

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