use of org.commongeoregistry.adapter.metadata.HierarchyType in project geoprism-registry by terraframe.
the class ServerHierarchyType method toHierarchyType.
public HierarchyType toHierarchyType(boolean includePrivateTypes) {
LocalizedValue description = LocalizedValueConverter.convert(this.getDescription());
final HierarchyType hierarchyType = new HierarchyType(this.getCode(), getLabel(), description, this.getOrganizationCode());
hierarchyType.setAbstractDescription(this.hierarchicalRelationship.getAbstractDescription());
hierarchyType.setAcknowledgement(this.hierarchicalRelationship.getAcknowledgement());
hierarchyType.setDisclaimer(this.hierarchicalRelationship.getDisclaimer());
hierarchyType.setContact(this.hierarchicalRelationship.getContact());
hierarchyType.setPhoneNumber(this.hierarchicalRelationship.getPhoneNumber());
hierarchyType.setEmail(this.hierarchicalRelationship.getEmail());
hierarchyType.setProgress(this.hierarchicalRelationship.getProgress());
hierarchyType.setAccessConstraints(this.hierarchicalRelationship.getAccessConstraints());
hierarchyType.setUseConstraints(this.hierarchicalRelationship.getUseConstraints());
this.getRootGeoObjectTypes(includePrivateTypes).forEach(rootType -> hierarchyType.addRootGeoObjects(rootType));
return hierarchyType;
}
use of org.commongeoregistry.adapter.metadata.HierarchyType in project geoprism-registry by terraframe.
the class ServerParentTreeNode method toNode.
public ParentTreeNode toNode(boolean enforcePermissions) {
GeoObject geoObject = this.getGeoObject().toGeoObject(this.getStartDate());
HierarchyType ht = this.getHierarchyType() != null ? this.getHierarchyType().toHierarchyType() : null;
ParentTreeNode node = new ParentTreeNode(geoObject, ht);
String orgCode = geoObject.getType().getOrganizationCode();
ServerGeoObjectType type = ServerGeoObjectType.get(geoObject.getType());
for (ServerParentTreeNode parent : this.parents) {
if (!enforcePermissions || ServiceFactory.getGeoObjectRelationshipPermissionService().canViewChild(orgCode, parent.getGeoObject().getType(), type)) {
node.addParent(parent.toNode(enforcePermissions));
}
}
return node;
}
use of org.commongeoregistry.adapter.metadata.HierarchyType in project geoprism-registry by terraframe.
the class TestHierarchyTypeInfo method apply.
@Request
public void apply() {
if (this.getServerObject(true) != null) {
return;
}
HierarchyType dto = this.toDTO();
this.serverObj = new ServerHierarchyTypeBuilder().createHierarchyType(dto);
}
use of org.commongeoregistry.adapter.metadata.HierarchyType in project geoprism-registry by terraframe.
the class GeoObjectTypeRelationshipServiceTest method addChild.
private void addChild(TestRegistryAdapterClient adapter, TestGeoObjectTypeInfo parent, TestGeoObjectTypeInfo child) {
String parentCode = (parent == null) ? Universal.ROOT : parent.getCode();
HierarchyType ht = adapter.addToHierarchy(TEST_HT.getCode(), parentCode, child.getCode());
List<HierarchyNode> rootGots = ht.getRootGeoObjectTypes();
for (HierarchyNode node : rootGots) {
if (node.getGeoObjectType().getCode().equals(child.getCode())) {
return;
}
}
Assert.fail("We did not find the child we just added.");
}
use of org.commongeoregistry.adapter.metadata.HierarchyType in project geoprism-registry by terraframe.
the class HierarchyServiceTest method testUpdateHierarchyTypeAsBadRole.
@Test
public void testUpdateHierarchyTypeAsBadRole() {
HierarchyType reportingDivision = FastTestDataset.HIER_ADMIN.toDTO();
reportingDivision.setLabel(new LocalizedValue("Reporting Division 2"));
reportingDivision.setDescription(new LocalizedValue("The rporting division hieracy 2"));
final String updateJSON = reportingDivision.toJSON().toString();
TestUserInfo[] users = new TestUserInfo[] { FastTestDataset.USER_MOHA_RA, FastTestDataset.USER_CGOV_RC, FastTestDataset.USER_CGOV_AC, FastTestDataset.USER_CGOV_RM };
for (TestUserInfo user : users) {
try {
FastTestDataset.runAsUser(user, (request, adapter) -> {
ServiceFactory.getHierarchyService().updateHierarchyType(request.getSessionId(), updateJSON);
});
Assert.fail("Able to update a geo object type as a user with bad roles");
} catch (SmartExceptionDTO e) {
// This is expected
}
}
}
Aggregations