Search in sources :

Example 1 with AttributeDoesNotExistException

use of com.runwaysdk.dataaccess.AttributeDoesNotExistException 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 2 with AttributeDoesNotExistException

use of com.runwaysdk.dataaccess.AttributeDoesNotExistException 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

AttributeDoesNotExistException (com.runwaysdk.dataaccess.AttributeDoesNotExistException)2 DataNotFoundException (com.runwaysdk.dataaccess.cache.DataNotFoundException)2 MdBusiness (com.runwaysdk.system.metadata.MdBusiness)2 LocalizedValue (org.commongeoregistry.adapter.dataaccess.LocalizedValue)2 BusinessDAO (com.runwaysdk.dataaccess.BusinessDAO)1 BusinessDAOIF (com.runwaysdk.dataaccess.BusinessDAOIF)1 MdEdgeDAOIF (com.runwaysdk.dataaccess.MdEdgeDAOIF)1 MdBusinessDAO (com.runwaysdk.dataaccess.metadata.MdBusinessDAO)1 MdEdgeDAO (com.runwaysdk.dataaccess.metadata.graph.MdEdgeDAO)1 Transaction (com.runwaysdk.dataaccess.transaction.Transaction)1 MdGeoVertexDAOIF (com.runwaysdk.gis.dataaccess.MdGeoVertexDAOIF)1 MdGeoVertexDAO (com.runwaysdk.gis.dataaccess.metadata.graph.MdGeoVertexDAO)1 OIterator (com.runwaysdk.query.OIterator)1 QueryFactory (com.runwaysdk.query.QueryFactory)1 Request (com.runwaysdk.session.Request)1 AllowedIn (com.runwaysdk.system.gis.geo.AllowedIn)1 IsARelationship (com.runwaysdk.system.gis.geo.IsARelationship)1 LocatedIn (com.runwaysdk.system.gis.geo.LocatedIn)1 Universal (com.runwaysdk.system.gis.geo.Universal)1 MdTermRelationship (com.runwaysdk.system.metadata.MdTermRelationship)1