use of net.geoprism.registry.model.ServerHierarchyType in project geoprism-registry by terraframe.
the class HierarchyService method removeInheritedHierarchy.
/**
* Modifies a hierarchy to remove inheritance from another hierarchy for the
* given root
*
* @param sessionId
* @param hierarchyTypeCode
* code of the {@link HierarchyType} being modified.
* @param geoObjectTypeCode
* code of the root {@link GeoObjectType}.
*/
@Request(RequestType.SESSION)
public HierarchyType removeInheritedHierarchy(String sessionId, String hierarchyTypeCode, String geoObjectTypeCode) {
ServerHierarchyType forHierarchy = ServerHierarchyType.get(hierarchyTypeCode);
ServerGeoObjectType childType = ServerGeoObjectType.get(geoObjectTypeCode);
ServiceFactory.getGeoObjectTypeRelationshipPermissionService().enforceCanAddChild(forHierarchy, null, childType);
ServerGeoObjectType type = ServerGeoObjectType.get(geoObjectTypeCode);
type.removeInheritedHierarchy(forHierarchy);
forHierarchy.refresh();
return forHierarchy.toHierarchyType();
}
use of net.geoprism.registry.model.ServerHierarchyType in project geoprism-registry by terraframe.
the class HierarchyService method getHierarchyGroupedTypes.
@Request(RequestType.SESSION)
public JsonArray getHierarchyGroupedTypes(String sessionId) {
final HierarchyTypePermissionServiceIF hierarchyPermissions = ServiceFactory.getHierarchyPermissionService();
final GeoObjectTypePermissionServiceIF typePermissions = ServiceFactory.getGeoObjectTypePermissionService();
final RolePermissionService rps = ServiceFactory.getRolePermissionService();
final boolean isSRA = rps.isSRA();
JsonArray allHiers = new JsonArray();
List<ServerHierarchyType> shts = ServiceFactory.getMetadataCache().getAllHierarchyTypes();
for (ServerHierarchyType sht : shts) {
final String htOrgCode = sht.getOrganizationCode();
if (hierarchyPermissions.canRead(htOrgCode) && (isSRA || rps.isRA(htOrgCode) || rps.isRM(htOrgCode))) {
JsonObject hierView = new JsonObject();
hierView.addProperty("code", sht.getCode());
hierView.addProperty("label", sht.getDisplayLabel().getValue());
hierView.addProperty("orgCode", sht.getOrganizationCode());
JsonArray allHierTypes = new JsonArray();
List<ServerGeoObjectType> types = sht.getAllTypes();
for (ServerGeoObjectType type : types) {
final String gotOrgCode = type.getOrganizationCode();
if (typePermissions.canRead(gotOrgCode, type, type.getIsPrivate()) && (isSRA || rps.isRA(gotOrgCode) || rps.isRM(gotOrgCode, type))) {
if (type.getIsAbstract()) {
JsonObject superView = new JsonObject();
superView.addProperty("code", type.getCode());
superView.addProperty("label", type.getLabel().getValue());
superView.addProperty("orgCode", type.getOrganizationCode());
superView.addProperty("isAbstract", true);
List<ServerGeoObjectType> subtypes = type.getSubtypes();
for (ServerGeoObjectType subtype : subtypes) {
JsonObject typeView = new JsonObject();
typeView.addProperty("code", subtype.getCode());
typeView.addProperty("label", subtype.getLabel().getValue());
typeView.addProperty("orgCode", subtype.getOrganization().getCode());
typeView.add("super", superView);
allHierTypes.add(typeView);
}
} else {
JsonObject typeView = new JsonObject();
typeView.addProperty("code", type.getCode());
typeView.addProperty("label", type.getLabel().getValue());
typeView.addProperty("orgCode", type.getOrganizationCode());
allHierTypes.add(typeView);
}
}
}
hierView.add("types", allHierTypes);
allHiers.add(hierView);
}
}
return allHiers;
}
use of net.geoprism.registry.model.ServerHierarchyType in project geoprism-registry by terraframe.
the class HierarchyService method updateHierarchyType.
/**
* Updates the given {@link HierarchyType} represented as JSON.
*
* @param sessionId
* @param gtJSON
* JSON of the {@link HierarchyType} to be updated.
*/
@Request(RequestType.SESSION)
public HierarchyType updateHierarchyType(String sessionId, String htJSON) {
HierarchyType hierarchyType = HierarchyType.fromJSON(htJSON, ServiceFactory.getAdapter());
ServerHierarchyType type = ServerHierarchyType.get(hierarchyType);
ServiceFactory.getHierarchyPermissionService().enforceCanWrite(type.getOrganization().getCode());
type.update(hierarchyType);
return type.toHierarchyType();
}
use of net.geoprism.registry.model.ServerHierarchyType in project geoprism-registry by terraframe.
the class HierarchyService method insertBetweenTypes.
/**
* Inserts the {@link GeoObjectType} 'middleGeoObjectTypeCode' into the
* hierarchy as the child of 'parentGeoObjectTypeCode' and the new parent for
* 'youngestGeoObjectTypeCode'. If an existing parent/child relationship
* already exists between 'youngestGeoObjectTypeCode' and
* 'parentgeoObjectTypeCode', it will first be removed.
* youngestGeoObjectTypeCode can also be an array (comma separated list).
*
* @param sessionId
* @param hierarchyTypeCode
* code of the {@link HierarchyType}
* @param parentGeoObjectTypeCode
* parent {@link GeoObjectType}.
* @param middleGeoObjectTypeCode
* middle child {@link GeoObjectType} after this method returns
* @param youngestGeoObjectTypeCode
* youngest child {@link GeoObjectType} after this method returns
*/
@Request(RequestType.SESSION)
public HierarchyType insertBetweenTypes(String sessionId, String hierarchyTypeCode, String parentGeoObjectTypeCode, String middleGeoObjectTypeCode, String youngestGeoObjectTypeCode) {
ServerHierarchyType type = ServerHierarchyType.get(hierarchyTypeCode);
ServerGeoObjectType parentType = ServerGeoObjectType.get(parentGeoObjectTypeCode);
ServerGeoObjectType middleType = ServerGeoObjectType.get(middleGeoObjectTypeCode);
List<ServerGeoObjectType> youngestTypes = Arrays.asList(youngestGeoObjectTypeCode.split(",")).stream().map(code -> ServerGeoObjectType.get(code.trim())).collect(Collectors.toList());
ServiceFactory.getGeoObjectTypeRelationshipPermissionService().enforceCanAddChild(type, parentType, middleType);
type.insertBetween(parentType, middleType, youngestTypes);
return type.toHierarchyType();
}
use of net.geoprism.registry.model.ServerHierarchyType in project geoprism-registry by terraframe.
the class HierarchyService method deleteHierarchyType.
/**
* Deletes the {@link HierarchyType} with the given code.
*
* @param sessionId
* @param code
* code of the {@link HierarchyType} to delete.
*/
@Request(RequestType.SESSION)
public void deleteHierarchyType(String sessionId, String code) {
ServerHierarchyType type = ServerHierarchyType.get(code);
ServiceFactory.getHierarchyPermissionService().enforceCanDelete(type.getOrganization().getCode());
type.delete();
}
Aggregations