use of net.geoprism.registry.graph.ExternalSystem 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;
}
use of net.geoprism.registry.graph.ExternalSystem in project geoprism-registry by terraframe.
the class RegistryConfiguration method onInitiateForgotPasswordForUser.
@Override
public void onInitiateForgotPasswordForUser(GeoprismUser user, ForgotPasswordRequest req) {
UserInfo userInfo = UserInfo.getByUser(user);
if (userInfo.getExternalSystemOid() != null && userInfo.getExternalSystemOid().length() > 0) {
ExternalSystem system = ExternalSystem.get(userInfo.getExternalSystemOid());
ForgotPasswordOnOauthUser ex = new ForgotPasswordOnOauthUser();
ex.setUsername(user.getUsername());
ex.setOauthServer(system.getDisplayLabel().getValue());
throw ex;
}
}
use of net.geoprism.registry.graph.ExternalSystem in project geoprism-registry by terraframe.
the class DHIS2FeatureService method getSystemCapabilities.
@Request(RequestType.SESSION)
public JsonObject getSystemCapabilities(String sessionId, String systemJSON) {
JsonObject capabilities = new JsonObject();
JsonObject jo = JsonParser.parseString(systemJSON).getAsJsonObject();
ExternalSystem system = ExternalSystem.desieralize(jo);
if (system instanceof DHIS2ExternalSystem) {
DHIS2ExternalSystem dhis2System = (DHIS2ExternalSystem) system;
DHIS2TransportServiceIF dhis2 = getTransportService(dhis2System);
String version = dhis2.getVersionRemoteServer();
if (ArrayUtils.contains(DHIS2FeatureService.OAUTH_INCOMPATIBLE_VERSIONS, version)) {
capabilities.addProperty("oauth", false);
} else {
capabilities.addProperty("oauth", true);
}
} else if (system instanceof FhirExternalSystem) {
capabilities.addProperty("oauth", true);
} else {
capabilities.addProperty("oauth", false);
}
return capabilities;
}
use of net.geoprism.registry.graph.ExternalSystem in project geoprism-registry by terraframe.
the class ExternalSystemService method remove.
@Request(RequestType.SESSION)
public void remove(String sessionId, String oid) {
ExternalSystem system = ExternalSystem.get(oid);
Organization organization = system.getOrganization();
ServiceFactory.getRolePermissionService().enforceRA(organization.getCode());
if (system instanceof DHIS2ExternalSystem) {
DHIS2ExternalSystem dhis2Sys = (DHIS2ExternalSystem) system;
if (dhis2Sys.getOauthServer() != null) {
OauthServer dbServer = dhis2Sys.getOauthServer();
dbServer.delete();
}
}
system.delete();
}
use of net.geoprism.registry.graph.ExternalSystem 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;
}
Aggregations