Search in sources :

Example 6 with SynchronizationConfig

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();
    }
}
Also used : DHIS2SyncConfig(net.geoprism.registry.etl.DHIS2SyncConfig) FhirExportSynchronizationManager(net.geoprism.registry.etl.fhir.FhirExportSynchronizationManager) DHIS2TransportServiceIF(net.geoprism.registry.etl.export.dhis2.DHIS2TransportServiceIF) FhirSyncImportConfig(net.geoprism.registry.etl.FhirSyncImportConfig) ExternalSystemSyncConfig(net.geoprism.registry.etl.ExternalSystemSyncConfig) DHIS2FeatureService(net.geoprism.registry.dhis2.DHIS2FeatureService) FhirSyncExportConfig(net.geoprism.registry.etl.FhirSyncExportConfig) FhirImportSynchronizationManager(net.geoprism.registry.etl.fhir.FhirImportSynchronizationManager) SynchronizationConfig(net.geoprism.registry.SynchronizationConfig) DHIS2SynchronizationManager(net.geoprism.registry.dhis2.DHIS2SynchronizationManager)

Example 7 with SynchronizationConfig

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();
}
Also used : ObjectHasDataException(net.geoprism.registry.ObjectHasDataException) SynchronizationConfig(net.geoprism.registry.SynchronizationConfig)

Example 8 with SynchronizationConfig

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.");
}
Also used : ServerHierarchyType(net.geoprism.registry.model.ServerHierarchyType) QueryFactory(com.runwaysdk.query.QueryFactory) DHIS2ExternalSystem(net.geoprism.registry.graph.DHIS2ExternalSystem) DHIS2ExternalSystem(net.geoprism.registry.graph.DHIS2ExternalSystem) ExternalSystem(net.geoprism.registry.graph.ExternalSystem) SynchronizationConfigQuery(net.geoprism.registry.SynchronizationConfigQuery) JsonObject(com.google.gson.JsonObject) SynchronizationConfig(net.geoprism.registry.SynchronizationConfig) MdTermRelationship(com.runwaysdk.system.metadata.MdTermRelationship) Transaction(com.runwaysdk.dataaccess.transaction.Transaction)

Example 9 with SynchronizationConfig

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();
}
Also used : FhirExportSynchronizationManager(net.geoprism.registry.etl.fhir.FhirExportSynchronizationManager) ExternalSystemSyncConfig(net.geoprism.registry.etl.ExternalSystemSyncConfig) FhirSyncExportConfig(net.geoprism.registry.etl.FhirSyncExportConfig) SynchronizationConfig(net.geoprism.registry.SynchronizationConfig) IOException(java.io.IOException) ProgrammingErrorException(com.runwaysdk.dataaccess.ProgrammingErrorException) Request(com.runwaysdk.session.Request)

Example 10 with SynchronizationConfig

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();
}
Also used : JsonElement(com.google.gson.JsonElement) SynchronizationConfig(net.geoprism.registry.SynchronizationConfig) Request(com.runwaysdk.session.Request)

Aggregations

SynchronizationConfig (net.geoprism.registry.SynchronizationConfig)14 Request (com.runwaysdk.session.Request)10 JsonObject (com.google.gson.JsonObject)5 Organization (net.geoprism.registry.Organization)4 ServerHierarchyType (net.geoprism.registry.model.ServerHierarchyType)4 LocalizedValue (org.commongeoregistry.adapter.dataaccess.LocalizedValue)4 JsonArray (com.google.gson.JsonArray)3 ExportHistory (net.geoprism.registry.etl.export.ExportHistory)3 Test (org.junit.Test)3 GsonBuilder (com.google.gson.GsonBuilder)2 Dhis2Payload (net.geoprism.registry.etl.DHIS2TestService.Dhis2Payload)2 ExternalSystemSyncConfig (net.geoprism.registry.etl.ExternalSystemSyncConfig)2 FhirSyncExportConfig (net.geoprism.registry.etl.FhirSyncExportConfig)2 BasicFhirResourceProcessor (net.geoprism.registry.etl.fhir.BasicFhirResourceProcessor)2 FhirExportSynchronizationManager (net.geoprism.registry.etl.fhir.FhirExportSynchronizationManager)2 DHIS2ExternalSystem (net.geoprism.registry.graph.DHIS2ExternalSystem)2 ExternalSystem (net.geoprism.registry.graph.ExternalSystem)2 SynchronizationConfigService (net.geoprism.registry.service.SynchronizationConfigService)2 IParser (ca.uhn.fhir.parser.IParser)1 JsonElement (com.google.gson.JsonElement)1