Search in sources :

Example 1 with ExternalSystem

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;
}
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 ExternalSystem

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;
    }
}
Also used : ExternalSystem(net.geoprism.registry.graph.ExternalSystem) ForgotPasswordOnOauthUser(net.geoprism.registry.session.ForgotPasswordOnOauthUser)

Example 3 with ExternalSystem

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;
}
Also used : DHIS2TransportServiceIF(net.geoprism.registry.etl.export.dhis2.DHIS2TransportServiceIF) DHIS2ExternalSystem(net.geoprism.registry.graph.DHIS2ExternalSystem) FhirExternalSystem(net.geoprism.registry.graph.FhirExternalSystem) DHIS2ExternalSystem(net.geoprism.registry.graph.DHIS2ExternalSystem) ExternalSystem(net.geoprism.registry.graph.ExternalSystem) JsonObject(com.google.gson.JsonObject) FhirExternalSystem(net.geoprism.registry.graph.FhirExternalSystem) Request(com.runwaysdk.session.Request)

Example 4 with ExternalSystem

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();
}
Also used : Organization(net.geoprism.registry.Organization) DHIS2ExternalSystem(net.geoprism.registry.graph.DHIS2ExternalSystem) FhirExternalSystem(net.geoprism.registry.graph.FhirExternalSystem) DHIS2ExternalSystem(net.geoprism.registry.graph.DHIS2ExternalSystem) ExternalSystem(net.geoprism.registry.graph.ExternalSystem) OauthExternalSystem(net.geoprism.registry.etl.OauthExternalSystem) OauthServer(net.geoprism.account.OauthServer) Request(com.runwaysdk.session.Request)

Example 5 with ExternalSystem

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;
}
Also used : JsonArray(com.google.gson.JsonArray) ServerHierarchyType(net.geoprism.registry.model.ServerHierarchyType) Organization(net.geoprism.registry.Organization) LocalizedValue(org.commongeoregistry.adapter.dataaccess.LocalizedValue) DHIS2ExternalSystem(net.geoprism.registry.graph.DHIS2ExternalSystem) ExternalSystem(net.geoprism.registry.graph.ExternalSystem) JsonObject(com.google.gson.JsonObject) SynchronizationConfig(net.geoprism.registry.SynchronizationConfig) Request(com.runwaysdk.session.Request)

Aggregations

ExternalSystem (net.geoprism.registry.graph.ExternalSystem)12 JsonObject (com.google.gson.JsonObject)6 DHIS2ExternalSystem (net.geoprism.registry.graph.DHIS2ExternalSystem)6 Request (com.runwaysdk.session.Request)4 Transaction (com.runwaysdk.dataaccess.transaction.Transaction)3 QueryFactory (com.runwaysdk.query.QueryFactory)3 FhirExternalSystem (net.geoprism.registry.graph.FhirExternalSystem)3 GsonBuilder (com.google.gson.GsonBuilder)2 JsonArray (com.google.gson.JsonArray)2 Organization (net.geoprism.registry.Organization)2 SynchronizationConfig (net.geoprism.registry.SynchronizationConfig)2 ExternalSystemSyncConfig (net.geoprism.registry.etl.ExternalSystemSyncConfig)2 OauthExternalSystem (net.geoprism.registry.etl.OauthExternalSystem)2 ServerHierarchyType (net.geoprism.registry.model.ServerHierarchyType)2 LocalizedValue (org.commongeoregistry.adapter.dataaccess.LocalizedValue)2 Gson (com.google.gson.Gson)1 UserDAO (com.runwaysdk.business.rbac.UserDAO)1 ProgrammingErrorException (com.runwaysdk.dataaccess.ProgrammingErrorException)1 LeftJoinEq (com.runwaysdk.query.LeftJoinEq)1 ValueQuery (com.runwaysdk.query.ValueQuery)1