use of net.geoprism.registry.SynchronizationConfig in project geoprism-registry by terraframe.
the class SynchronizationConfigService method remove.
@Request(RequestType.SESSION)
public void remove(String sessionId, String oid) {
SynchronizationConfig config = SynchronizationConfig.get(oid);
Organization organization = config.getOrganization();
ServiceFactory.getRolePermissionService().enforceRA(organization.getCode());
config.delete();
}
use of net.geoprism.registry.SynchronizationConfig in project geoprism-registry by terraframe.
the class SynchronizationConfigService method run.
@Request(RequestType.SESSION)
public JsonObject run(String sessionId, String oid) {
SynchronizationConfig config = SynchronizationConfig.get(oid);
ServiceFactory.getRolePermissionService().enforceRA(config.getOrganization().getCode());
List<? extends DataExportJob> jobs = config.getJobs();
DataExportJob job = jobs.get(0);
job.appLock();
job.setRunAsUserId(Session.getCurrentSession().getUser().getOid());
job.apply();
ExportHistory hist = job.start(config);
GeoprismUser user = GeoprismUser.get(job.getRunAsUser().getOid());
return serializeHistory(hist, user, job);
}
use of net.geoprism.registry.SynchronizationConfig in project geoprism-registry by terraframe.
the class SynchronizationConfigService method edit.
@Request(RequestType.SESSION)
public JsonObject edit(String sessionId, String oid) {
JsonObject response = new JsonObject();
if (oid != null && oid.length() > 0) {
SynchronizationConfig config = SynchronizationConfig.lock(oid);
response.add("config", config.toJSON());
}
JsonArray orgs = new JsonArray();
List<Organization> organizations = Organization.getUserAdminOrganizations();
for (Organization organization : organizations) {
JsonArray hierarchies = new JsonArray();
List<ServerHierarchyType> sHierachies = ServerHierarchyType.getForOrganization(organization);
for (ServerHierarchyType hierarchy : sHierachies) {
JsonObject object = new JsonObject();
object.addProperty("label", hierarchy.getDisplayLabel().getValue());
object.addProperty("code", hierarchy.getCode());
hierarchies.add(object);
}
JsonArray systems = new JsonArray();
List<ExternalSystem> esystems = ExternalSystem.getForOrganization(organization);
for (ExternalSystem system : esystems) {
if (system.isExportSupported()) {
LocalizedValue label = LocalizedValueConverter.convert(system.getEmbeddedComponent(ExternalSystem.LABEL));
JsonObject object = new JsonObject();
object.addProperty("label", label.getValue());
object.addProperty("oid", system.getOid());
object.addProperty("type", system.getMdClass().getTypeName());
systems.add(object);
}
}
JsonObject object = new JsonObject();
object.addProperty("label", organization.getDisplayLabel().getValue());
object.addProperty("code", organization.getCode());
object.add("hierarchies", hierarchies);
object.add("systems", systems);
orgs.add(object);
}
response.add("orgs", orgs);
return response;
}
use of net.geoprism.registry.SynchronizationConfig in project geoprism-registry by terraframe.
the class FhirImportTest method testBasicImport.
@Request
@Test
public void testBasicImport() throws InterruptedException {
try {
FhirExternalSystem system = createExternalSystem();
SynchronizationConfig config = createSyncConfig(system);
FhirSyncImportConfig iConfig = (FhirSyncImportConfig) config.buildConfiguration();
FhirResourceProcessor processor = FhirFactory.getProcessor(iConfig.getImplementation());
IParser parser = FhirContext.forR4().newJsonParser();
Bundle bundle = new Bundle();
bundle.addEntry(new BundleEntryComponent().setResource((Resource) parser.parseResource(this.getClass().getResourceAsStream("/fhir/organization.json"))));
bundle.addEntry(new BundleEntryComponent().setResource((Resource) parser.parseResource(this.getClass().getResourceAsStream("/fhir/location.json"))));
FhirResourceImporter importer = new FhirResourceImporter(new BasicFhirConnection(system), processor, null, null);
importer.synchronize(bundle);
ServerGeoObjectIF geoobject = new ServerGeoObjectService().getGeoObjectByCode("USATestDataHsTwo", "USATestDataHealthStop");
geoobject.setDate(new Date());
LocalizedValue displayLabel = geoobject.getDisplayLabel();
Assert.assertEquals("USATestDataHsTwo ZZZZZZZ", displayLabel.getValue());
} finally {
TestDataSet.deleteExternalSystems("FHIRImportTest");
}
}
use of net.geoprism.registry.SynchronizationConfig 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;
}
Aggregations