Search in sources :

Example 6 with DataNotFoundException

use of com.runwaysdk.dataaccess.cache.DataNotFoundException in project geoprism-registry by terraframe.

the class ListTypeService method remove.

@Request(RequestType.SESSION)
public void remove(String sessionId, String oid) {
    try {
        ListType listType = ListType.get(oid);
        this.enforceWritePermissions(listType);
        listType.delete();
        ((Session) Session.getCurrentSession()).reloadPermissions();
    } catch (DataNotFoundException e) {
    // Do nothing
    }
}
Also used : DataNotFoundException(com.runwaysdk.dataaccess.cache.DataNotFoundException) ListType(net.geoprism.registry.ListType) Session(com.runwaysdk.session.Session) Request(com.runwaysdk.session.Request)

Example 7 with DataNotFoundException

use of com.runwaysdk.dataaccess.cache.DataNotFoundException in project geoprism-registry by terraframe.

the class ClassificationTypeTest method testRemove.

@Test
@Request
public void testRemove() {
    ClassificationType type = ClassificationType.apply(createMock());
    type.delete();
    try {
        ClassificationType.getByCode(type.getCode());
        Assert.fail("Able to get type which should have been deleted");
    } catch (DataNotFoundException ex) {
    // Expected
    }
}
Also used : DataNotFoundException(com.runwaysdk.dataaccess.cache.DataNotFoundException) ClassificationType(net.geoprism.registry.model.ClassificationType) Test(org.junit.Test) Request(com.runwaysdk.session.Request)

Example 8 with DataNotFoundException

use of com.runwaysdk.dataaccess.cache.DataNotFoundException in project geoprism-registry by terraframe.

the class ListTypeVersion method getAttributesAsJson.

private JsonArray getAttributesAsJson() {
    Collection<Locale> locales = LocalizationFacade.getInstalledLocales();
    ListType list = this.getListType();
    Map<String, JsonArray> dependencies = new HashMap<String, JsonArray>();
    Map<String, String> baseAttributes = new HashMap<String, String>();
    List<String> attributesOrder = new LinkedList<String>();
    JsonArray hierarchies = list.getHierarchiesAsJson();
    for (int i = 0; i < hierarchies.size(); i++) {
        JsonObject hierarchy = hierarchies.get(i).getAsJsonObject();
        List<String> pCodes = list.getParentCodes(hierarchy);
        if (pCodes.size() > 0) {
            String hCode = hierarchy.get(DefaultAttribute.CODE.getName()).getAsString();
            String previous = null;
            for (String pCode : pCodes) {
                String attributeName = hCode.toLowerCase() + pCode.toLowerCase();
                baseAttributes.put(attributeName, attributeName);
                baseAttributes.put(attributeName + DEFAULT_LOCALE, attributeName);
                for (Locale locale : locales) {
                    baseAttributes.put(attributeName + locale.toString(), attributeName);
                }
                attributesOrder.add(attributeName);
                attributesOrder.add(attributeName + DEFAULT_LOCALE);
                for (Locale locale : locales) {
                    attributesOrder.add(attributeName + locale.toString());
                }
                if (previous != null) {
                    addDependency(dependencies, attributeName, previous);
                    addDependency(dependencies, attributeName + DEFAULT_LOCALE, previous);
                    for (Locale locale : locales) {
                        addDependency(dependencies, attributeName + locale.toString(), previous);
                    }
                }
                previous = attributeName;
            }
            if (previous != null) {
                addDependency(dependencies, DefaultAttribute.CODE.getName(), previous);
                addDependency(dependencies, DefaultAttribute.DISPLAY_LABEL.getName() + DEFAULT_LOCALE, previous);
                for (Locale locale : locales) {
                    addDependency(dependencies, DefaultAttribute.DISPLAY_LABEL.getName() + locale.toString(), previous);
                }
            }
        }
    }
    baseAttributes.put(DefaultAttribute.CODE.getName(), DefaultAttribute.CODE.getName());
    baseAttributes.put(DefaultAttribute.DISPLAY_LABEL.getName() + DEFAULT_LOCALE, DefaultAttribute.CODE.getName());
    for (Locale locale : locales) {
        baseAttributes.put(DefaultAttribute.DISPLAY_LABEL.getName() + locale.toString(), DefaultAttribute.CODE.getName());
    }
    attributesOrder.add(DefaultAttribute.CODE.getName());
    attributesOrder.add(DefaultAttribute.DISPLAY_LABEL.getName() + DEFAULT_LOCALE);
    for (Locale locale : locales) {
        attributesOrder.add(DefaultAttribute.DISPLAY_LABEL.getName() + locale.toString());
    }
    JsonArray attributes = new JsonArray();
    String mdBusinessId = this.getMdBusinessOid();
    if (mdBusinessId != null && mdBusinessId.length() > 0) {
        MdBusinessDAOIF mdBusiness = MdBusinessDAO.get(mdBusinessId);
        List<? extends MdAttributeConcreteDAOIF> mdAttributes = mdBusiness.definesAttributesOrdered();
        Collections.sort(mdAttributes, new ListTypeAttributeComparator(attributesOrder, mdAttributes));
        MdAttributeConcreteDAOIF mdGeometry = mdBusiness.definesAttribute(RegistryConstants.GEOMETRY_ATTRIBUTE_NAME);
        if (mdGeometry instanceof MdAttributePointDAOIF) {
            JsonObject longitude = new JsonObject();
            longitude.addProperty(NAME, "longitude");
            longitude.addProperty(LABEL, LocalizationFacade.localize(GeoObjectImportConfiguration.LONGITUDE_KEY));
            longitude.addProperty(TYPE, "none");
            attributes.add(longitude);
            JsonObject latitude = new JsonObject();
            latitude.addProperty(NAME, "latitude");
            latitude.addProperty(LABEL, LocalizationFacade.localize(GeoObjectImportConfiguration.LATITUDE_KEY));
            latitude.addProperty(TYPE, "none");
            attributes.add(latitude);
        }
        for (MdAttributeConcreteDAOIF mdAttribute : mdAttributes) {
            if (this.isValid(mdAttribute)) {
                String attributeName = mdAttribute.definesAttribute();
                try {
                    ListTypeAttributeGroup group = ListTypeAttributeGroup.getByKey(mdAttribute.getOid());
                    if (group != null) {
                        baseAttributes.put(mdAttribute.definesAttribute(), group.getSourceAttribute().getAttributeName());
                    }
                } catch (DataNotFoundException e) {
                // Ignore
                }
                JsonObject attribute = new JsonObject();
                attribute.addProperty(NAME, attributeName);
                attribute.addProperty(LABEL, mdAttribute.getDisplayLabel(Session.getCurrentLocale()));
                attribute.addProperty(TYPE, baseAttributes.containsKey(attributeName) ? "list" : "input");
                attribute.addProperty(BASE, baseAttributes.containsKey(attributeName) ? baseAttributes.get(attributeName) : attributeName);
                attribute.add(DEPENDENCY, dependencies.containsKey(attributeName) ? dependencies.get(attributeName) : new JsonArray());
                if (mdAttribute instanceof MdAttributeMomentDAOIF) {
                    attribute.addProperty(TYPE, "date");
                    attribute.add(VALUE, new JsonObject());
                } else if (mdAttribute instanceof MdAttributeBooleanDAOIF) {
                    attribute.addProperty(TYPE, "boolean");
                } else if (mdAttribute instanceof MdAttributeNumberDAOIF) {
                    attribute.addProperty(TYPE, "number");
                }
                attributes.add(attribute);
            }
        }
    }
    return attributes;
}
Also used : Locale(java.util.Locale) MdAttributeBooleanDAOIF(com.runwaysdk.dataaccess.MdAttributeBooleanDAOIF) DataNotFoundException(com.runwaysdk.dataaccess.cache.DataNotFoundException) MdBusinessDAOIF(com.runwaysdk.dataaccess.MdBusinessDAOIF) HashMap(java.util.HashMap) JsonObject(com.google.gson.JsonObject) MdAttributeMultiLineString(com.runwaysdk.system.gis.metadata.MdAttributeMultiLineString) MdAttributeLineString(com.runwaysdk.system.gis.metadata.MdAttributeLineString) MdAttributeMomentDAOIF(com.runwaysdk.dataaccess.MdAttributeMomentDAOIF) LinkedList(java.util.LinkedList) MultiPoint(com.vividsolutions.jts.geom.MultiPoint) MdAttributePoint(com.runwaysdk.system.gis.metadata.MdAttributePoint) MdAttributeMultiPoint(com.runwaysdk.system.gis.metadata.MdAttributeMultiPoint) Point(com.vividsolutions.jts.geom.Point) JsonArray(com.google.gson.JsonArray) MdAttributePointDAOIF(com.runwaysdk.gis.dataaccess.MdAttributePointDAOIF) MdAttributeNumberDAOIF(com.runwaysdk.dataaccess.MdAttributeNumberDAOIF) ListTypeAttributeComparator(net.geoprism.registry.masterlist.ListTypeAttributeComparator) MdAttributeConcreteDAOIF(com.runwaysdk.dataaccess.MdAttributeConcreteDAOIF)

Example 9 with DataNotFoundException

use of com.runwaysdk.dataaccess.cache.DataNotFoundException in project geoprism-registry by terraframe.

the class PatchHierarchicalRelationshipType method createHierarchicalRelationshipTypes.

public void createHierarchicalRelationshipTypes() {
    MdBusiness univMdBusiness = MdBusiness.getMdBusiness(Universal.CLASS);
    MdTermRelationshipQuery trq = new MdTermRelationshipQuery(new QueryFactory());
    trq.WHERE(trq.getParentMdBusiness().EQ(univMdBusiness).AND(trq.getChildMdBusiness().EQ(univMdBusiness)));
    try (OIterator<? extends MdTermRelationship> it = trq.getIterator()) {
        it.getAll().stream().filter(mdTermRel -> {
            if (!(mdTermRel.definesType().equals(IsARelationship.CLASS) || mdTermRel.getKey().equals(AllowedIn.CLASS) || mdTermRel.getKey().equals(LocatedIn.CLASS))) {
                return (HierarchicalRelationshipType.getByMdTermRelationship(mdTermRel) == null);
            }
            return false;
        }).forEach(mdTermRel -> {
            System.out.println("Creating HierarchicalRelationshipType for the MdTermRelationship [" + mdTermRel.definesType() + "]");
            String code = ServerHierarchyType.buildHierarchyKeyFromMdTermRelUniversal(mdTermRel.getKey());
            String geoEntityKey = ServerHierarchyType.buildMdTermRelGeoEntityKey(code);
            String mdEdgeKey = ServerHierarchyType.buildMdEdgeKey(code);
            MdEdgeDAOIF mdEdge = MdEdgeDAO.getMdEdgeDAO(mdEdgeKey);
            String ownerActerOid = mdTermRel.getOwnerId();
            String organizationCode = Organization.getRootOrganizationCode(ownerActerOid);
            Organization organization = Organization.getByCode(organizationCode);
            HierarchicalRelationshipType hierarchicalRelationship = new HierarchicalRelationshipType();
            hierarchicalRelationship.setCode(code);
            hierarchicalRelationship.setOrganization(organization);
            hierarchicalRelationship.setMdTermRelationshipId(mdTermRel.getOid());
            hierarchicalRelationship.setMdEdgeId(mdEdge.getOid());
            try {
                MdTermRelationship entityRelationship = MdTermRelationship.getByKey(geoEntityKey);
                LocalizedValue displayLabel = AttributeTypeConverter.convert(entityRelationship.getDisplayLabel());
                LocalizedValue description = AttributeTypeConverter.convert(entityRelationship.getDescription());
                LocalizedValueConverter.populate(hierarchicalRelationship.getDisplayLabel(), displayLabel);
                LocalizedValueConverter.populate(hierarchicalRelationship.getDescription(), description);
                entityRelationship.delete();
            } catch (DataNotFoundException | AttributeDoesNotExistException e) {
                logger.debug("The entity geo relationship was not found defaulting to the mdTermRel displayLabel and description");
                LocalizedValue displayLabel = AttributeTypeConverter.convert(mdTermRel.getDisplayLabel());
                LocalizedValue description = AttributeTypeConverter.convert(mdTermRel.getDescription());
                LocalizedValueConverter.populate(hierarchicalRelationship.getDisplayLabel(), displayLabel);
                LocalizedValueConverter.populate(hierarchicalRelationship.getDescription(), description);
            }
            try {
                BusinessDAOIF metadata = BusinessDAO.get("net.geoprism.registry.HierarchyMetadata", mdTermRel.getOid());
                hierarchicalRelationship.setAbstractDescription(metadata.getValue("abstractDescription"));
                hierarchicalRelationship.setAcknowledgement(metadata.getValue("acknowledgement"));
                hierarchicalRelationship.setDisclaimer(metadata.getValue("disclaimer"));
                hierarchicalRelationship.setContact(metadata.getValue("contact"));
                hierarchicalRelationship.setPhoneNumber(metadata.getValue("phoneNumber"));
                hierarchicalRelationship.setEmail(metadata.getValue("email"));
                hierarchicalRelationship.setProgress(metadata.getValue("progress"));
                hierarchicalRelationship.setAccessConstraints(metadata.getValue("accessConstraints"));
                hierarchicalRelationship.setUseConstraints(metadata.getValue("useConstraints"));
            } catch (DataNotFoundException | AttributeDoesNotExistException e) {
            }
            hierarchicalRelationship.apply();
        });
    }
}
Also used : Universal(com.runwaysdk.system.gis.geo.Universal) Transaction(com.runwaysdk.dataaccess.transaction.Transaction) LoggerFactory(org.slf4j.LoggerFactory) AllowedIn(com.runwaysdk.system.gis.geo.AllowedIn) MdEdgeDAOIF(com.runwaysdk.dataaccess.MdEdgeDAOIF) LocalizedValue(org.commongeoregistry.adapter.dataaccess.LocalizedValue) Request(com.runwaysdk.session.Request) MdTermRelationshipQuery(com.runwaysdk.system.metadata.MdTermRelationshipQuery) BusinessDAO(com.runwaysdk.dataaccess.BusinessDAO) HierarchyMetadata(net.geoprism.registry.HierarchyMetadata) Organization(net.geoprism.registry.Organization) LocalizedValueConverter(net.geoprism.registry.conversion.LocalizedValueConverter) HierarchicalRelationshipType(net.geoprism.registry.HierarchicalRelationshipType) QueryFactory(com.runwaysdk.query.QueryFactory) MdTermRelationship(com.runwaysdk.system.metadata.MdTermRelationship) InheritedHierarchyAnnotation(net.geoprism.registry.InheritedHierarchyAnnotation) InheritedHierarchyAnnotationQuery(net.geoprism.registry.InheritedHierarchyAnnotationQuery) ServerHierarchyType(net.geoprism.registry.model.ServerHierarchyType) Logger(org.slf4j.Logger) AttributeDoesNotExistException(com.runwaysdk.dataaccess.AttributeDoesNotExistException) MdEdgeDAO(com.runwaysdk.dataaccess.metadata.graph.MdEdgeDAO) AttributeTypeConverter(net.geoprism.registry.conversion.AttributeTypeConverter) OIterator(com.runwaysdk.query.OIterator) IsARelationship(com.runwaysdk.system.gis.geo.IsARelationship) DataNotFoundException(com.runwaysdk.dataaccess.cache.DataNotFoundException) MdBusinessDAO(com.runwaysdk.dataaccess.metadata.MdBusinessDAO) BusinessDAOIF(com.runwaysdk.dataaccess.BusinessDAOIF) MdBusiness(com.runwaysdk.system.metadata.MdBusiness) LocatedIn(com.runwaysdk.system.gis.geo.LocatedIn) DataNotFoundException(com.runwaysdk.dataaccess.cache.DataNotFoundException) QueryFactory(com.runwaysdk.query.QueryFactory) MdEdgeDAOIF(com.runwaysdk.dataaccess.MdEdgeDAOIF) Organization(net.geoprism.registry.Organization) MdBusiness(com.runwaysdk.system.metadata.MdBusiness) AttributeDoesNotExistException(com.runwaysdk.dataaccess.AttributeDoesNotExistException) MdTermRelationshipQuery(com.runwaysdk.system.metadata.MdTermRelationshipQuery) LocalizedValue(org.commongeoregistry.adapter.dataaccess.LocalizedValue) BusinessDAOIF(com.runwaysdk.dataaccess.BusinessDAOIF) HierarchicalRelationshipType(net.geoprism.registry.HierarchicalRelationshipType) MdTermRelationship(com.runwaysdk.system.metadata.MdTermRelationship)

Example 10 with DataNotFoundException

use of com.runwaysdk.dataaccess.cache.DataNotFoundException in project geoprism-registry by terraframe.

the class ServerGeoObjectTypeConverter method build.

public ServerGeoObjectType build(Universal universal) {
    MdBusiness mdBusiness = universal.getMdBusiness();
    MdGeoVertexDAO mdVertex = GeoVertexType.getMdGeoVertex(universal.getUniversalId());
    com.runwaysdk.system.gis.geo.GeometryType geoPrismgeometryType = universal.getGeometryType().get(0);
    org.commongeoregistry.adapter.constants.GeometryType cgrGeometryType = GeometryTypeFactory.get(geoPrismgeometryType);
    LocalizedValue label = convert(universal.getDisplayLabel());
    LocalizedValue description = convert(universal.getDescription());
    String ownerActerOid = universal.getOwnerOid();
    String organizationCode = Organization.getRootOrganizationCode(ownerActerOid);
    MdGeoVertexDAOIF superType = mdVertex.getSuperClass();
    GeoObjectType geoObjType = new GeoObjectType(universal.getUniversalId(), cgrGeometryType, label, description, universal.getIsGeometryEditable(), organizationCode, ServiceFactory.getAdapter());
    geoObjType.setIsAbstract(mdBusiness.getIsAbstract());
    try {
        GeoObjectTypeMetadata metadata = GeoObjectTypeMetadata.getByKey(universal.getKey());
        geoObjType.setIsPrivate(metadata.getIsPrivate());
    } catch (DataNotFoundException | AttributeDoesNotExistException e) {
        geoObjType.setIsPrivate(false);
    }
    if (superType != null && !superType.definesType().equals(GeoVertex.CLASS)) {
        String parentCode = superType.getTypeName();
        geoObjType.setSuperTypeCode(parentCode);
    }
    geoObjType = this.convertAttributeTypes(universal, geoObjType, mdBusiness);
    return new ServerGeoObjectType(geoObjType, universal, mdBusiness, mdVertex);
}
Also used : GeoObjectTypeMetadata(net.geoprism.registry.model.GeoObjectTypeMetadata) DataNotFoundException(com.runwaysdk.dataaccess.cache.DataNotFoundException) MdBusiness(com.runwaysdk.system.metadata.MdBusiness) MdGeoVertexDAOIF(com.runwaysdk.gis.dataaccess.MdGeoVertexDAOIF) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) AttributeDoesNotExistException(com.runwaysdk.dataaccess.AttributeDoesNotExistException) LocalizedValue(org.commongeoregistry.adapter.dataaccess.LocalizedValue) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) GeoObjectType(org.commongeoregistry.adapter.metadata.GeoObjectType) MdGeoVertexDAO(com.runwaysdk.gis.dataaccess.metadata.graph.MdGeoVertexDAO)

Aggregations

DataNotFoundException (com.runwaysdk.dataaccess.cache.DataNotFoundException)12 Request (com.runwaysdk.session.Request)5 MdAttributeConcreteDAOIF (com.runwaysdk.dataaccess.MdAttributeConcreteDAOIF)4 Classifier (net.geoprism.ontology.Classifier)4 JsonObject (com.google.gson.JsonObject)3 Transaction (com.runwaysdk.dataaccess.transaction.Transaction)3 JsonArray (com.google.gson.JsonArray)2 AttributeDoesNotExistException (com.runwaysdk.dataaccess.AttributeDoesNotExistException)2 MdAttributeMomentDAOIF (com.runwaysdk.dataaccess.MdAttributeMomentDAOIF)2 MdAttributeMultiTermDAOIF (com.runwaysdk.dataaccess.MdAttributeMultiTermDAOIF)2 MdAttributeTermDAOIF (com.runwaysdk.dataaccess.MdAttributeTermDAOIF)2 MdBusinessDAOIF (com.runwaysdk.dataaccess.MdBusinessDAOIF)2 MdAttributePointDAOIF (com.runwaysdk.gis.dataaccess.MdAttributePointDAOIF)2 Session (com.runwaysdk.session.Session)2 MdAttributeLineString (com.runwaysdk.system.gis.metadata.MdAttributeLineString)2 MdAttributeMultiLineString (com.runwaysdk.system.gis.metadata.MdAttributeMultiLineString)2 MdAttributeMultiPoint (com.runwaysdk.system.gis.metadata.MdAttributeMultiPoint)2 MdAttributePoint (com.runwaysdk.system.gis.metadata.MdAttributePoint)2 MdBusiness (com.runwaysdk.system.metadata.MdBusiness)2 HashMap (java.util.HashMap)2