use of net.geoprism.registry.SynchronizationConfigQuery in project geoprism-registry by terraframe.
the class DeleteSyncConfigs method doIt.
@Transaction
private void doIt() {
SynchronizationConfigQuery query = new SynchronizationConfigQuery(new QueryFactory());
OIterator<? extends SynchronizationConfig> it = query.getIterator();
it.forEach(config -> {
config.delete();
});
}
use of net.geoprism.registry.SynchronizationConfigQuery 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.");
}
Aggregations