Search in sources :

Example 1 with ServerHierarchyType

use of net.geoprism.registry.model.ServerHierarchyType in project geoprism-registry by terraframe.

the class GeoRegistryUtil method createHierarchyType.

@Authenticate
public static String createHierarchyType(String htJSON) {
    RegistryAdapter adapter = ServiceFactory.getAdapter();
    HierarchyType hierarchyType = HierarchyType.fromJSON(htJSON, adapter);
    ServiceFactory.getHierarchyPermissionService().enforceCanCreate(hierarchyType.getOrganizationCode());
    ServerHierarchyType sType = new ServerHierarchyTypeBuilder().createHierarchyType(hierarchyType);
    // The transaction did not error out, so it is safe to put into the cache.
    ServiceFactory.getMetadataCache().addHierarchyType(sType);
    return hierarchyType.getCode();
}
Also used : ServerHierarchyType(net.geoprism.registry.model.ServerHierarchyType) ServerHierarchyType(net.geoprism.registry.model.ServerHierarchyType) HierarchyType(org.commongeoregistry.adapter.metadata.HierarchyType) ServerHierarchyTypeBuilder(net.geoprism.registry.conversion.ServerHierarchyTypeBuilder) RegistryAdapter(org.commongeoregistry.adapter.RegistryAdapter) Authenticate(com.runwaysdk.business.rbac.Authenticate)

Example 2 with ServerHierarchyType

use of net.geoprism.registry.model.ServerHierarchyType in project geoprism-registry by terraframe.

the class HierarchyMetadata method getHierarchyType.

public static ServerHierarchyType getHierarchyType(String key) {
    HierarchyMetadata hierarchy = HierarchyMetadata.getByKey(key);
    MdTermRelationship mdTermRelationship = hierarchy.getMdTermRelationship();
    ServerHierarchyType hierarchyType = ServerHierarchyType.get(mdTermRelationship);
    return hierarchyType;
}
Also used : ServerHierarchyType(net.geoprism.registry.model.ServerHierarchyType) MdTermRelationship(com.runwaysdk.system.metadata.MdTermRelationship)

Example 3 with ServerHierarchyType

use of net.geoprism.registry.model.ServerHierarchyType in project geoprism-registry by terraframe.

the class ListType method markAsInvalid.

public void markAsInvalid(ServerHierarchyType hierarchyType, ServerGeoObjectType type) {
    boolean isValid = true;
    JsonArray hierarchies = this.getHierarchiesAsJson();
    ServerGeoObjectType masterlistType = this.getGeoObjectType();
    for (int i = 0; i < hierarchies.size(); i++) {
        JsonObject hierarchy = hierarchies.get(i).getAsJsonObject();
        String hCode = hierarchy.get("code").getAsString();
        Optional<ServerHierarchyType> ht = ServiceFactory.getMetadataCache().getHierachyType(hCode);
        if (ht.isPresent()) {
            ServerHierarchyType actualHierarchy = masterlistType.findHierarchy(ht.get(), type);
            if (hCode.equals(hierarchyType.getCode()) || actualHierarchy.getCode().equals(hierarchyType.getCode())) {
                List<String> pCodes = this.getParentCodes(hierarchy);
                if (pCodes.contains(type.getCode()) || type.getCode().equals(masterlistType.getCode())) {
                    isValid = false;
                }
            }
        } else {
            isValid = false;
        }
    }
    if (!isValid) {
        this.appLock();
        this.setValid(false);
        this.apply();
    }
}
Also used : JsonArray(com.google.gson.JsonArray) ServerHierarchyType(net.geoprism.registry.model.ServerHierarchyType) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) JsonObject(com.google.gson.JsonObject)

Example 4 with ServerHierarchyType

use of net.geoprism.registry.model.ServerHierarchyType in project geoprism-registry by terraframe.

the class ListTypeVersion method publishRecord.

@Transaction
public void publishRecord(ServerGeoObjectIF object) {
    // Only working lists can be updated from changes to the graph objects
    if (this.getWorking()) {
        object.setDate(this.getForDate());
        // Delete tile cache
        ListTileCache.deleteTiles(this);
        ListType masterlist = this.getListType();
        MdBusinessDAO mdBusiness = MdBusinessDAO.get(this.getMdBusinessOid()).getBusinessDAO();
        Collection<Locale> locales = LocalizationFacade.getInstalledLocales();
        // Add the type ancestor fields
        ServerGeoObjectType type = ServerGeoObjectType.get(masterlist.getUniversal());
        Map<ServerHierarchyType, List<ServerGeoObjectType>> ancestorMap = masterlist.getAncestorMap(type);
        Set<ServerHierarchyType> hierarchiesOfSubTypes = type.getHierarchiesOfSubTypes();
        Collection<AttributeType> attributes = type.getAttributeMap().values();
        Business business = new Business(mdBusiness.definesType());
        this.publish(masterlist, type, object, business, attributes, ancestorMap, hierarchiesOfSubTypes, locales);
    }
}
Also used : Locale(java.util.Locale) ServerHierarchyType(net.geoprism.registry.model.ServerHierarchyType) MdBusinessDAO(com.runwaysdk.dataaccess.metadata.MdBusinessDAO) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) AttributeType(org.commongeoregistry.adapter.metadata.AttributeType) List(java.util.List) LinkedList(java.util.LinkedList) MdBusiness(com.runwaysdk.system.metadata.MdBusiness) Business(com.runwaysdk.business.Business) Transaction(com.runwaysdk.dataaccess.transaction.Transaction)

Example 5 with ServerHierarchyType

use of net.geoprism.registry.model.ServerHierarchyType in project geoprism-registry by terraframe.

the class ListTypeVersion method updateRecord.

@Transaction
public void updateRecord(ServerGeoObjectIF object) {
    // Only working lists can be updated from changes to the graph objects
    if (this.getWorking()) {
        object.setDate(this.getForDate());
        // Delete tile cache
        ListTileCache.deleteTiles(this);
        ListType masterlist = this.getListType();
        MdBusinessDAO mdBusiness = MdBusinessDAO.get(this.getMdBusinessOid()).getBusinessDAO();
        Collection<Locale> locales = LocalizationFacade.getInstalledLocales();
        // Add the type ancestor fields
        ServerGeoObjectType type = ServerGeoObjectType.get(masterlist.getUniversal());
        Set<ServerHierarchyType> hierarchiesOfSubTypes = type.getHierarchiesOfSubTypes();
        Map<ServerHierarchyType, List<ServerGeoObjectType>> ancestorMap = masterlist.getAncestorMap(type);
        Collection<AttributeType> attributes = type.getAttributeMap().values();
        BusinessQuery query = new QueryFactory().businessQuery(mdBusiness.definesType());
        query.WHERE(query.aCharacter(DefaultAttribute.CODE.getName()).EQ(object.getCode()));
        List<Business> records = query.getIterator().getAll();
        for (Business record : records) {
            try {
                record.appLock();
                this.publish(masterlist, type, object, record, attributes, ancestorMap, hierarchiesOfSubTypes, locales);
            } finally {
                record.unlock();
            }
        }
    }
}
Also used : Locale(java.util.Locale) BusinessQuery(com.runwaysdk.business.BusinessQuery) ServerHierarchyType(net.geoprism.registry.model.ServerHierarchyType) QueryFactory(com.runwaysdk.query.QueryFactory) MdBusinessDAO(com.runwaysdk.dataaccess.metadata.MdBusinessDAO) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) AttributeType(org.commongeoregistry.adapter.metadata.AttributeType) List(java.util.List) LinkedList(java.util.LinkedList) MdBusiness(com.runwaysdk.system.metadata.MdBusiness) Business(com.runwaysdk.business.Business) Transaction(com.runwaysdk.dataaccess.transaction.Transaction)

Aggregations

ServerHierarchyType (net.geoprism.registry.model.ServerHierarchyType)86 ServerGeoObjectType (net.geoprism.registry.model.ServerGeoObjectType)55 Request (com.runwaysdk.session.Request)38 JsonObject (com.google.gson.JsonObject)20 ServerGeoObjectIF (net.geoprism.registry.model.ServerGeoObjectIF)18 Test (org.junit.Test)17 JsonArray (com.google.gson.JsonArray)16 LinkedList (java.util.LinkedList)14 List (java.util.List)14 Transaction (com.runwaysdk.dataaccess.transaction.Transaction)12 GeoObjectType (org.commongeoregistry.adapter.metadata.GeoObjectType)12 GeoObject (org.commongeoregistry.adapter.dataaccess.GeoObject)11 AttributeType (org.commongeoregistry.adapter.metadata.AttributeType)11 Locale (java.util.Locale)10 Point (com.vividsolutions.jts.geom.Point)9 ServerParentTreeNode (net.geoprism.registry.model.ServerParentTreeNode)9 MdBusinessDAO (com.runwaysdk.dataaccess.metadata.MdBusinessDAO)8 MdBusiness (com.runwaysdk.system.metadata.MdBusiness)8 InheritedHierarchyAnnotation (net.geoprism.registry.InheritedHierarchyAnnotation)8 Organization (net.geoprism.registry.Organization)8