use of net.geoprism.registry.model.ServerHierarchyType in project geoprism-registry by terraframe.
the class HierarchyService method getHierarchyTypes.
/**
* Returns the {@link HierarchyType}s with the given codes or all
* {@link HierarchyType}s if no codes are provided.
*
* @param sessionId
* @param codes
* codes of the {@link HierarchyType}s.
* @param context
* @return the {@link HierarchyType}s with the given codes or all
* {@link HierarchyType}s if no codes are provided.
*/
@Request(RequestType.SESSION)
public HierarchyType[] getHierarchyTypes(String sessionId, String[] codes, PermissionContext context) {
final HierarchyTypePermissionServiceIF hierPermServ = ServiceFactory.getHierarchyPermissionService();
List<ServerHierarchyType> types = ServerHierarchyType.getAll();
if (codes != null && codes.length > 0) {
final List<String> list = Arrays.asList(codes);
types = types.stream().filter(type -> list.contains(type.getCode())).collect(Collectors.toList());
}
// Filter out what they're not allowed to see
List<HierarchyType> hierarchies = types.stream().filter(type -> {
Organization org = Organization.getByCode(type.getOrganizationCode());
return !((context.equals(PermissionContext.READ) && !hierPermServ.canRead(org.getCode())) || (context.equals(PermissionContext.WRITE) && !hierPermServ.canWrite(org.getCode())));
}).filter(type -> type.hasVisibleRoot()).map(type -> type.toHierarchyType(false)).collect(Collectors.toList());
return hierarchies.toArray(new HierarchyType[hierarchies.size()]);
}
use of net.geoprism.registry.model.ServerHierarchyType in project geoprism-registry by terraframe.
the class HierarchyService method setInheritedHierarchy.
/**
* Modifies a hierarchy to inherit from another hierarchy at the given
* GeoObjectType
*
* @param sessionId
* @param hierarchyTypeCode
* code of the {@link HierarchyType} being modified.
* @param inheritedHierarchyTypeCode
* code of the {@link HierarchyType} being inherited.
* @param geoObjectTypeCode
* code of the root {@link GeoObjectType}.
*/
@Request(RequestType.SESSION)
public HierarchyType setInheritedHierarchy(String sessionId, String hierarchyTypeCode, String inheritedHierarchyTypeCode, String geoObjectTypeCode) {
ServerHierarchyType forHierarchy = ServerHierarchyType.get(hierarchyTypeCode);
ServerHierarchyType inheritedHierarchy = ServerHierarchyType.get(inheritedHierarchyTypeCode);
ServerGeoObjectType childType = ServerGeoObjectType.get(geoObjectTypeCode);
ServiceFactory.getGeoObjectTypeRelationshipPermissionService().enforceCanAddChild(forHierarchy, null, childType);
ServerGeoObjectType type = ServerGeoObjectType.get(geoObjectTypeCode);
type.setInheritedHierarchy(forHierarchy, inheritedHierarchy);
forHierarchy.refresh();
return forHierarchy.toHierarchyType();
}
use of net.geoprism.registry.model.ServerHierarchyType in project geoprism-registry by terraframe.
the class HierarchyService method filterHierarchiesFromPermissions.
public static void filterHierarchiesFromPermissions(ServerGeoObjectType type, ServerParentTreeNodeOverTime pot) {
GeoObjectRelationshipPermissionServiceIF service = ServiceFactory.getGeoObjectRelationshipPermissionService();
Collection<ServerHierarchyType> hierarchies = pot.getHierarchies();
for (ServerHierarchyType hierarchy : hierarchies) {
Organization organization = hierarchy.getOrganization();
// null, type) ))
if (!service.canViewChild(organization.getCode(), null, type)) {
pot.remove(hierarchy);
}
}
}
use of net.geoprism.registry.model.ServerHierarchyType in project geoprism-registry by terraframe.
the class HierarchyService method removeFromHierarchy.
/**
* Removes the {@link GeoObjectType} with the given child code from the parent
* {@link GeoObjectType} with the given code for the given
* {@link HierarchyType} code.
*
* @param sessionId
* @param hierarchyCode
* code of the {@link HierarchyType} the child is being added to.
* @param parentGeoObjectTypeCode
* parent {@link GeoObjectType}.
* @param childGeoObjectTypeCode
* child {@link GeoObjectType}.
*/
@Request(RequestType.SESSION)
public HierarchyType removeFromHierarchy(String sessionId, String hierarchyTypeCode, String parentGeoObjectTypeCode, String childGeoObjectTypeCode, boolean migrateChildren) {
ServerHierarchyType type = ServerHierarchyType.get(hierarchyTypeCode);
ServerGeoObjectType parentType = ServerGeoObjectType.get(parentGeoObjectTypeCode);
ServerGeoObjectType childType = ServerGeoObjectType.get(childGeoObjectTypeCode);
ServiceFactory.getGeoObjectTypeRelationshipPermissionService().enforceCanRemoveChild(type, parentType, childType);
type.removeChild(parentType, childType, migrateChildren);
return type.toHierarchyType();
}
use of net.geoprism.registry.model.ServerHierarchyType in project geoprism-registry by terraframe.
the class VertexServerGeoObject method removeChild.
@Transaction
public void removeChild(ServerGeoObjectIF child, String hierarchyCode, Date startDate, Date endDate) {
ServerHierarchyType hierarchyType = ServerHierarchyType.get(hierarchyCode);
child.removeParent(this, hierarchyType, startDate, endDate);
}
Aggregations