Search in sources :

Example 1 with ExternalSystemSyncConfig

use of net.geoprism.registry.etl.ExternalSystemSyncConfig in project geoprism-registry by terraframe.

the class SynchronizationConfig method toJSON.

@Override
public JsonObject toJSON() {
    GsonBuilder builder = new GsonBuilder();
    builder.registerTypeAdapter(FhirSyncLevel.class, new FhirSyncLevel.Serializer());
    builder.registerTypeAdapter(DHIS2AttributeMapping.class, new DHIS2AttributeMapping.DHIS2AttributeMappingDeserializer());
    Gson gson = builder.create();
    JsonObject object = new JsonObject();
    object.addProperty(SynchronizationConfig.OID, this.getOid());
    object.addProperty(SynchronizationConfig.ORGANIZATION, this.getOrganization().getCode());
    object.addProperty(SynchronizationConfig.SYSTEM, this.getSystem());
    object.add(SynchronizationConfig.LABEL, LocalizedValueConverter.convert(this.getLabel()).toJSON());
    object.addProperty(SynchronizationConfig.ISIMPORT, this.getIsImport() != null ? this.getIsImport() : false);
    ExternalSystemSyncConfig config = this.buildConfiguration();
    object.add(SynchronizationConfig.CONFIGURATION, gson.toJsonTree(config));
    ExternalSystem system = this.getExternalSystem();
    if (system != null) {
        LocalizedValue label = LocalizedValueConverter.convert(system.getEmbeddedComponent(ExternalSystem.LABEL));
        object.addProperty(SynchronizationConfig.TYPE, system.getClass().getSimpleName());
        object.addProperty(SynchronizationConfig.SYSTEM_LABEL, label.getValue());
    }
    return object;
}
Also used : FhirSyncLevel(net.geoprism.registry.etl.FhirSyncLevel) LocalizedValue(org.commongeoregistry.adapter.dataaccess.LocalizedValue) GsonBuilder(com.google.gson.GsonBuilder) ExternalSystemSyncConfig(net.geoprism.registry.etl.ExternalSystemSyncConfig) ExternalSystem(net.geoprism.registry.graph.ExternalSystem) Gson(com.google.gson.Gson) JsonObject(com.google.gson.JsonObject) DHIS2AttributeMapping(net.geoprism.registry.etl.DHIS2AttributeMapping)

Example 2 with ExternalSystemSyncConfig

use of net.geoprism.registry.etl.ExternalSystemSyncConfig in project geoprism-registry by terraframe.

the class SynchronizationConfig method buildConfiguration.

public ExternalSystemSyncConfig buildConfiguration() {
    ExternalSystem system = this.getExternalSystem();
    ExternalSystemSyncConfig config = system.configuration(this.getIsImport());
    config.setSystem(system);
    config.populate(this);
    return config;
}
Also used : ExternalSystemSyncConfig(net.geoprism.registry.etl.ExternalSystemSyncConfig) ExternalSystem(net.geoprism.registry.graph.ExternalSystem)

Example 3 with ExternalSystemSyncConfig

use of net.geoprism.registry.etl.ExternalSystemSyncConfig 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 4 with ExternalSystemSyncConfig

use of net.geoprism.registry.etl.ExternalSystemSyncConfig 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)

Aggregations

ExternalSystemSyncConfig (net.geoprism.registry.etl.ExternalSystemSyncConfig)4 SynchronizationConfig (net.geoprism.registry.SynchronizationConfig)2 FhirSyncExportConfig (net.geoprism.registry.etl.FhirSyncExportConfig)2 FhirExportSynchronizationManager (net.geoprism.registry.etl.fhir.FhirExportSynchronizationManager)2 ExternalSystem (net.geoprism.registry.graph.ExternalSystem)2 Gson (com.google.gson.Gson)1 GsonBuilder (com.google.gson.GsonBuilder)1 JsonObject (com.google.gson.JsonObject)1 ProgrammingErrorException (com.runwaysdk.dataaccess.ProgrammingErrorException)1 Request (com.runwaysdk.session.Request)1 IOException (java.io.IOException)1 DHIS2FeatureService (net.geoprism.registry.dhis2.DHIS2FeatureService)1 DHIS2SynchronizationManager (net.geoprism.registry.dhis2.DHIS2SynchronizationManager)1 DHIS2AttributeMapping (net.geoprism.registry.etl.DHIS2AttributeMapping)1 DHIS2SyncConfig (net.geoprism.registry.etl.DHIS2SyncConfig)1 FhirSyncImportConfig (net.geoprism.registry.etl.FhirSyncImportConfig)1 FhirSyncLevel (net.geoprism.registry.etl.FhirSyncLevel)1 DHIS2TransportServiceIF (net.geoprism.registry.etl.export.dhis2.DHIS2TransportServiceIF)1 FhirImportSynchronizationManager (net.geoprism.registry.etl.fhir.FhirImportSynchronizationManager)1 LocalizedValue (org.commongeoregistry.adapter.dataaccess.LocalizedValue)1