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();
});
}
}
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);
}
Aggregations