Search in sources :

Example 36 with ServerHierarchyType

use of net.geoprism.registry.model.ServerHierarchyType in project geoprism-registry by terraframe.

the class GeoObjectTypeRelationshipServiceTest method testAddChildOfAbstractType.

@Test(expected = AbstractParentException.class)
@Request
public void testAddChildOfAbstractType() {
    TestGeoObjectTypeInfo parentGot = new TestGeoObjectTypeInfo("HMST_Abstract", FastTestDataset.ORG_CGOV);
    parentGot.setAbstract(true);
    TestGeoObjectTypeInfo childGot = new TestGeoObjectTypeInfo("HMST_Child", FastTestDataset.ORG_CGOV);
    try {
        parentGot.apply();
        childGot.apply();
        ServerHierarchyType type = FastTestDataset.HIER_ADMIN.getServerObject();
        ServerGeoObjectType parentType = parentGot.getServerObject();
        ServerGeoObjectType childType = childGot.getServerObject();
        try {
            type.addToHierarchy(RootGeoObjectType.INSTANCE, parentType);
            type.addToHierarchy(parentType, childType);
        } finally {
            type.removeChild(RootGeoObjectType.INSTANCE, parentType, false);
        }
    } finally {
        parentGot.delete();
        childGot.delete();
    }
}
Also used : ServerHierarchyType(net.geoprism.registry.model.ServerHierarchyType) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) TestGeoObjectTypeInfo(net.geoprism.registry.test.TestGeoObjectTypeInfo) Test(org.junit.Test) Request(com.runwaysdk.session.Request)

Example 37 with ServerHierarchyType

use of net.geoprism.registry.model.ServerHierarchyType in project geoprism-registry by terraframe.

the class DHIS2ServiceTest method createSyncConfig.

@Request
public static SynchronizationConfig createSyncConfig(ExternalSystem system, DHIS2SyncLevel additionalLevel, boolean apply) {
    // Define reusable objects
    final ServerHierarchyType ht = AllAttributesDataset.HIER.getServerObject();
    final Organization org = AllAttributesDataset.ORG.getServerObject();
    // Create DHIS2 Sync Config
    DHIS2SyncConfig dhis2Config = new DHIS2SyncConfig();
    dhis2Config.setHierarchy(ht);
    dhis2Config.setHierarchyCode(ht.getCode());
    dhis2Config.setLabel(new LocalizedValue("DHIS2 Export Test Data"));
    dhis2Config.setOrganization(org);
    // Populate Levels
    SortedSet<DHIS2SyncLevel> levels = new TreeSet<DHIS2SyncLevel>();
    DHIS2SyncLevel level = new DHIS2SyncLevel();
    level.setGeoObjectType(AllAttributesDataset.GOT_ALL.getServerObject().getCode());
    level.setSyncType(DHIS2SyncLevel.Type.ALL);
    level.setMappings(getDefaultMappings());
    level.setLevel(0);
    levels.add(level);
    // Populate Attribute Mappings
    if (additionalLevel != null) {
        levels.add(additionalLevel);
    }
    dhis2Config.setLevels(levels);
    // Serialize the DHIS2 Config
    GsonBuilder builder = new GsonBuilder();
    String dhis2JsonConfig = builder.create().toJson(dhis2Config);
    // Create a SynchronizationConfig
    SynchronizationConfig config = new SynchronizationConfig();
    config.setConfiguration(dhis2JsonConfig);
    config.setOrganization(org);
    config.setHierarchy(ht.getMdTermRelationship());
    config.setSystem(system.getOid());
    config.getLabel().setValue("DHIS2 Export Test");
    if (apply) {
        config.apply();
    }
    return config;
}
Also used : ServerHierarchyType(net.geoprism.registry.model.ServerHierarchyType) Organization(net.geoprism.registry.Organization) LocalizedValue(org.commongeoregistry.adapter.dataaccess.LocalizedValue) GsonBuilder(com.google.gson.GsonBuilder) TreeSet(java.util.TreeSet) SynchronizationConfig(net.geoprism.registry.SynchronizationConfig) Request(com.runwaysdk.session.Request)

Example 38 with ServerHierarchyType

use of net.geoprism.registry.model.ServerHierarchyType in project geoprism-registry by terraframe.

the class InheritedHierarchyAnnotationTest method testGetByUniversalAndHierarchy.

@Test
@Request
public void testGetByUniversalAndHierarchy() {
    ServerGeoObjectType sGOT = FastTestDataset.PROVINCE.getServerObject();
    ServerHierarchyType forHierarchy = TEST_HT.getServerObject();
    ServerHierarchyType inheritedHierarchy = FastTestDataset.HIER_ADMIN.getServerObject();
    InheritedHierarchyAnnotation annotation = sGOT.setInheritedHierarchy(forHierarchy, inheritedHierarchy);
    try {
        InheritedHierarchyAnnotation test = InheritedHierarchyAnnotation.get(sGOT.getUniversal(), forHierarchy.getHierarchicalRelationshipType());
        Assert.assertNotNull(test);
        Assert.assertEquals(test.getOid(), annotation.getOid());
    } finally {
        annotation.delete();
    }
}
Also used : ServerHierarchyType(net.geoprism.registry.model.ServerHierarchyType) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) InheritedHierarchyAnnotation(net.geoprism.registry.InheritedHierarchyAnnotation) Test(org.junit.Test) Request(com.runwaysdk.session.Request)

Example 39 with ServerHierarchyType

use of net.geoprism.registry.model.ServerHierarchyType in project geoprism-registry by terraframe.

the class InheritedHierarchyAnnotationTest method testRemove.

@Test
@Request
public void testRemove() {
    ServerGeoObjectType sGOT = FastTestDataset.PROVINCE.getServerObject();
    ServerHierarchyType forHierarchy = TEST_HT.getServerObject();
    ServerHierarchyType inheritedHierarchy = FastTestDataset.HIER_ADMIN.getServerObject();
    sGOT.setInheritedHierarchy(forHierarchy, inheritedHierarchy);
    sGOT.removeInheritedHierarchy(forHierarchy);
    InheritedHierarchyAnnotation test = InheritedHierarchyAnnotation.get(sGOT.getUniversal(), forHierarchy.getHierarchicalRelationshipType());
    try {
        Assert.assertNull(test);
    } finally {
        if (test != null) {
            test.delete();
        }
    }
}
Also used : ServerHierarchyType(net.geoprism.registry.model.ServerHierarchyType) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) InheritedHierarchyAnnotation(net.geoprism.registry.InheritedHierarchyAnnotation) Test(org.junit.Test) Request(com.runwaysdk.session.Request)

Example 40 with ServerHierarchyType

use of net.geoprism.registry.model.ServerHierarchyType in project geoprism-registry by terraframe.

the class InheritedHierarchyAnnotationTest method testGetTypeAncestors.

@Test
@Request
public void testGetTypeAncestors() {
    ServerGeoObjectType sGOT = FastTestDataset.PROVINCE.getServerObject();
    ServerHierarchyType forHierarchy = TEST_HT.getServerObject();
    ServerHierarchyType inheritedHierarchy = FastTestDataset.HIER_ADMIN.getServerObject();
    InheritedHierarchyAnnotation annotation = sGOT.setInheritedHierarchy(forHierarchy, inheritedHierarchy);
    try {
        ServerGeoObjectType childType = TEST_CHILD.getServerObject();
        List<GeoObjectType> results = childType.getTypeAncestors(TEST_HT.getServerObject(), false);
        Assert.assertEquals(1, results.size());
    } finally {
        annotation.delete();
    }
}
Also used : ServerHierarchyType(net.geoprism.registry.model.ServerHierarchyType) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) GeoObjectType(org.commongeoregistry.adapter.metadata.GeoObjectType) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) InheritedHierarchyAnnotation(net.geoprism.registry.InheritedHierarchyAnnotation) Test(org.junit.Test) Request(com.runwaysdk.session.Request)

Aggregations

ServerHierarchyType (net.geoprism.registry.model.ServerHierarchyType)86 ServerGeoObjectType (net.geoprism.registry.model.ServerGeoObjectType)55 Request (com.runwaysdk.session.Request)38 JsonObject (com.google.gson.JsonObject)20 ServerGeoObjectIF (net.geoprism.registry.model.ServerGeoObjectIF)18 Test (org.junit.Test)17 JsonArray (com.google.gson.JsonArray)16 LinkedList (java.util.LinkedList)14 List (java.util.List)14 Transaction (com.runwaysdk.dataaccess.transaction.Transaction)12 GeoObjectType (org.commongeoregistry.adapter.metadata.GeoObjectType)12 GeoObject (org.commongeoregistry.adapter.dataaccess.GeoObject)11 AttributeType (org.commongeoregistry.adapter.metadata.AttributeType)11 Locale (java.util.Locale)10 Point (com.vividsolutions.jts.geom.Point)9 ServerParentTreeNode (net.geoprism.registry.model.ServerParentTreeNode)9 MdBusinessDAO (com.runwaysdk.dataaccess.metadata.MdBusinessDAO)8 MdBusiness (com.runwaysdk.system.metadata.MdBusiness)8 InheritedHierarchyAnnotation (net.geoprism.registry.InheritedHierarchyAnnotation)8 Organization (net.geoprism.registry.Organization)8