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