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();
}
}
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;
}
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();
}
}
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();
}
}
}
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();
}
}
Aggregations