Search in sources :

Example 11 with HierarchyType

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;
}
Also used : LocalizedValue(org.commongeoregistry.adapter.dataaccess.LocalizedValue) HierarchyType(org.commongeoregistry.adapter.metadata.HierarchyType)

Example 12 with 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;
}
Also used : HierarchyType(org.commongeoregistry.adapter.metadata.HierarchyType) ParentTreeNode(org.commongeoregistry.adapter.dataaccess.ParentTreeNode) GeoObject(org.commongeoregistry.adapter.dataaccess.GeoObject)

Example 13 with HierarchyType

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);
}
Also used : HierarchyType(org.commongeoregistry.adapter.metadata.HierarchyType) ServerHierarchyType(net.geoprism.registry.model.ServerHierarchyType) ServerHierarchyTypeBuilder(net.geoprism.registry.conversion.ServerHierarchyTypeBuilder) Request(com.runwaysdk.session.Request)

Example 14 with HierarchyType

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.");
}
Also used : ServerHierarchyType(net.geoprism.registry.model.ServerHierarchyType) HierarchyType(org.commongeoregistry.adapter.metadata.HierarchyType) HierarchyNode(org.commongeoregistry.adapter.metadata.HierarchyNode)

Example 15 with HierarchyType

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
        }
    }
}
Also used : TestUserInfo(net.geoprism.registry.test.TestUserInfo) ServerHierarchyType(net.geoprism.registry.model.ServerHierarchyType) HierarchyType(org.commongeoregistry.adapter.metadata.HierarchyType) LocalizedValue(org.commongeoregistry.adapter.dataaccess.LocalizedValue) SmartExceptionDTO(com.runwaysdk.business.SmartExceptionDTO) Test(org.junit.Test)

Aggregations

HierarchyType (org.commongeoregistry.adapter.metadata.HierarchyType)40 ServerHierarchyType (net.geoprism.registry.model.ServerHierarchyType)21 CustomSerializer (org.commongeoregistry.adapter.metadata.CustomSerializer)12 Endpoint (com.runwaysdk.mvc.Endpoint)11 RestBodyResponse (com.runwaysdk.mvc.RestBodyResponse)11 LocalizedValue (org.commongeoregistry.adapter.dataaccess.LocalizedValue)10 ServerGeoObjectType (net.geoprism.registry.model.ServerGeoObjectType)9 Test (org.junit.Test)9 JsonArray (com.google.gson.JsonArray)6 Request (com.runwaysdk.session.Request)6 JsonObject (com.google.gson.JsonObject)5 GeoObjectType (org.commongeoregistry.adapter.metadata.GeoObjectType)5 HierarchyNode (org.commongeoregistry.adapter.metadata.HierarchyNode)4 List (java.util.List)3 ServerHierarchyTypeBuilder (net.geoprism.registry.conversion.ServerHierarchyTypeBuilder)3 GeoObjectRelationshipPermissionServiceIF (net.geoprism.registry.permission.GeoObjectRelationshipPermissionServiceIF)3 TestUserInfo (net.geoprism.registry.test.TestUserInfo)3 SmartExceptionDTO (com.runwaysdk.business.SmartExceptionDTO)2 MdAttributeCharacterDAO (com.runwaysdk.dataaccess.metadata.MdAttributeCharacterDAO)2 MdAttributeUUIDDAO (com.runwaysdk.dataaccess.metadata.MdAttributeUUIDDAO)2