use of net.geoprism.registry.SynchronizationConfig in project geoprism-registry by terraframe.
the class DataExportJob method execute.
@Override
public void execute(ExecutionContext executionContext) throws Throwable {
ExportHistory history = (ExportHistory) executionContext.getJobHistoryRecord().getChild();
this.setStage(history, ExportStage.EXPORT);
SynchronizationConfig c = this.getConfig();
ExternalSystemSyncConfig config = c.buildConfiguration();
if (config instanceof DHIS2SyncConfig) {
DHIS2SyncConfig dhis2Config = (DHIS2SyncConfig) config;
DHIS2TransportServiceIF dhis2 = DHIS2ServiceFactory.buildDhis2TransportService(dhis2Config.getSystem());
DHIS2FeatureService dhis2FeatureService = new DHIS2FeatureService();
dhis2FeatureService.setExternalSystemDhis2Version(dhis2, dhis2Config.getSystem());
new DHIS2SynchronizationManager(dhis2, dhis2Config, history).synchronize();
} else if (config instanceof FhirSyncExportConfig) {
FhirExportSynchronizationManager manager = new FhirExportSynchronizationManager((FhirSyncExportConfig) config, history);
manager.synchronize();
} else if (config instanceof FhirSyncImportConfig) {
FhirImportSynchronizationManager manager = new FhirImportSynchronizationManager(c, (FhirSyncImportConfig) config, history);
manager.synchronize();
}
}
use of net.geoprism.registry.SynchronizationConfig in project geoprism-registry by terraframe.
the class ExternalSystem method delete.
public void delete(Boolean checkReferencedData) {
if (checkReferencedData && getReferencedDataCount() > 0) {
throw new ObjectHasDataException();
}
List<SynchronizationConfig> configs = SynchronizationConfig.getAll(this);
for (SynchronizationConfig config : configs) {
config.delete();
}
super.delete();
}
use of net.geoprism.registry.SynchronizationConfig in project geoprism-registry by terraframe.
the class SynchronizationConfigPatch method patchJobs.
@Transaction
private void patchJobs() {
SynchronizationConfigQuery query = new SynchronizationConfigQuery(new QueryFactory());
logger.info("Attempting to patch " + query.getCount() + " synchronization configs.");
long count = 0;
try (OIterator<? extends SynchronizationConfig> iterator = query.getIterator()) {
while (iterator.hasNext()) {
SynchronizationConfig config = iterator.next();
ExternalSystem system = config.getExternalSystem();
if (system instanceof DHIS2ExternalSystem) {
JsonObject json = config.getConfigurationJson();
ServerHierarchyType hierarchy = null;
MdTermRelationship universalRelationship = config.getHierarchy();
if (universalRelationship != null) {
hierarchy = ServerHierarchyType.get(universalRelationship);
} else if (json.has("hierarchy")) {
hierarchy = ServerHierarchyType.get(json.get("hierarchy").getAsString());
} else if (json.has("hierarchyCode")) {
hierarchy = ServerHierarchyType.get(json.get("hierarchyCode").getAsString());
}
if (hierarchy != null) {
json.remove("hierarchy");
json.addProperty(DHIS2SyncConfig.HIERARCHY, hierarchy.getCode());
config.appLock();
config.setConfiguration(json.toString());
config.apply();
count++;
} else {
logger.error("Skipping " + config.getKey() + " because we couldn't resolve a hierarchy.");
}
}
}
}
logger.info("Successfully patched " + count + " synchronization configs.");
}
use of net.geoprism.registry.SynchronizationConfig in project geoprism-registry by terraframe.
the class SynchronizationConfigService method generateFile.
@Request(RequestType.SESSION)
public InputStream generateFile(String sessionId, String oid) {
SynchronizationConfig synchorinzation = SynchronizationConfig.get(oid);
ServiceFactory.getRolePermissionService().enforceRA(synchorinzation.getOrganization().getCode());
ExternalSystemSyncConfig config = synchorinzation.buildConfiguration();
if (config instanceof FhirSyncExportConfig) {
try {
FhirExportSynchronizationManager manager = new FhirExportSynchronizationManager((FhirSyncExportConfig) config, null);
return manager.generateZipFile();
} catch (IOException e) {
throw new ProgrammingErrorException(e);
}
}
throw new UnsupportedOperationException();
}
use of net.geoprism.registry.SynchronizationConfig in project geoprism-registry by terraframe.
the class SynchronizationConfigService method apply.
@Request(RequestType.SESSION)
public JsonObject apply(String sessionId, String json) throws JSONException {
JsonElement element = JsonParser.parseString(json);
SynchronizationConfig config = SynchronizationConfig.deserialize(element.getAsJsonObject());
config.apply();
return config.toJSON();
}
Aggregations