Search in sources :

Example 6 with GeoprismUser

use of net.geoprism.GeoprismUser in project geoprism-registry by terraframe.

the class FhirExportJob method toJson.

public JsonObject toJson() {
    SimpleDateFormat format = new SimpleDateFormat(GeoObjectImportConfiguration.DATE_FORMAT);
    format.setTimeZone(GeoRegistryUtil.SYSTEM_TIMEZONE);
    final MasterListVersion version = this.getVersion();
    final MasterList masterlist = version.getMasterlist();
    final ServerGeoObjectType type = masterlist.getGeoObjectType();
    final JobHistory history = this.getAllJobHistory().getAll().get(0);
    final GeoprismUser user = GeoprismUser.get(this.getRunAsUser().getOid());
    try {
        final JsonObject object = new JsonObject();
        object.addProperty(FhirExportJob.OID, this.getOid());
        object.add(FhirExportJob.VERSION, this.getVersion().toJSON(false));
        object.addProperty(FhirExportJob.IMPLEMENTATION, this.getImplementation());
        object.addProperty(FhirExportJob.TYPE, type.getLabel().getValue());
        object.addProperty(JobHistory.STATUS, history.getStatus().get(0).getDisplayLabel());
        object.addProperty("date", format.format(version.getPublishDate()));
        object.addProperty("author", user.getUsername());
        object.addProperty("createDate", format.format(history.getCreateDate()));
        object.addProperty("lastUpdateDate", format.format(history.getLastUpdateDate()));
        object.addProperty("workProgress", history.getWorkProgress());
        object.addProperty("workTotal", history.getWorkTotal());
        object.addProperty("historyoryId", history.getOid());
        if (history.getErrorJson() != null && history.getErrorJson().length() > 0) {
            object.addProperty("message", history.getLocalizedError(Session.getCurrentLocale()));
        }
        return object;
    } catch (JSONException e) {
        throw new ProgrammingErrorException(e);
    }
}
Also used : MasterList(net.geoprism.registry.MasterList) JobHistory(com.runwaysdk.system.scheduler.JobHistory) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) JsonObject(com.google.gson.JsonObject) JSONException(org.json.JSONException) MasterListVersion(net.geoprism.registry.MasterListVersion) GeoprismUser(net.geoprism.GeoprismUser) SimpleDateFormat(java.text.SimpleDateFormat) ProgrammingErrorException(com.runwaysdk.dataaccess.ProgrammingErrorException)

Example 7 with GeoprismUser

use of net.geoprism.GeoprismUser in project geoprism-registry by terraframe.

the class UserInfoPatch method doIt.

@Transaction
private void doIt() {
    UserInfoQuery query = new UserInfoQuery(new QueryFactory());
    try (OIterator<? extends UserInfo> it = query.getIterator()) {
        while (it.hasNext()) {
            UserInfo info = it.next();
            info.appLock();
            info.apply();
        }
    }
    // Ensure all geoprism users have a user info
    GeoprismUserQuery gQuery = new GeoprismUserQuery(new QueryFactory());
    try (OIterator<? extends GeoprismUser> it = gQuery.getIterator()) {
        while (it.hasNext()) {
            GeoprismUser user = it.next();
            UserInfo info = UserInfo.getByUser(user);
            if (info == null) {
                info = new UserInfo();
                info.setGeoprismUser(user);
                info.apply();
            }
        }
    }
}
Also used : QueryFactory(com.runwaysdk.query.QueryFactory) GeoprismUserQuery(net.geoprism.GeoprismUserQuery) UserInfo(net.geoprism.registry.UserInfo) GeoprismUser(net.geoprism.GeoprismUser) UserInfoQuery(net.geoprism.registry.UserInfoQuery) Transaction(com.runwaysdk.dataaccess.transaction.Transaction)

Example 8 with GeoprismUser

use of net.geoprism.GeoprismUser in project geoprism-registry by terraframe.

the class AccountService method getRolesForUser.

/**
 * @param organizationCodes
 *          comma delimited list of registry codes. Returns all registry roles
 *          if empty.
 *
 * @return all of the roles are set to assigned equals false
 */
@Request(RequestType.SESSION)
public RegistryRole[] getRolesForUser(String sessionId, String userOID) {
    GeoprismUser geoPrismUser = GeoprismUser.get(userOID);
    List<RegistryRole> registryRoles = new LinkedList<RegistryRole>();
    Set<String> roleNameSet = new HashSet<String>();
    OIterator<? extends com.runwaysdk.system.Roles> roleIterator = geoPrismUser.getAllAssignedRole();
    for (Roles role : roleIterator) {
        RegistryRole registryRole = new RegistryRoleConverter().build(role);
        if (registryRole != null) {
            registryRole.setAssigned(true);
            LocalizedValueConverter.populateOrganizationDisplayLabel(registryRole);
            LocalizedValueConverter.populateGeoObjectTypeLabel(registryRole);
            registryRoles.add(registryRole);
            roleNameSet.add(registryRole.getName());
        }
    }
    // Add the registry roles that the user can be a member of based on their
    // organization affiliation
    OIterator<? extends Business> organizationIterators = geoPrismUser.getParents(OrganizationUser.CLASS);
    for (Business business : organizationIterators) {
        Organization organization = (Organization) business;
        List<RegistryRole> orgRoleIterator = this.getRolesForOrganization(organization.getCode());
        for (RegistryRole registryRole : orgRoleIterator) {
            if (!roleNameSet.contains(registryRole.getName())) {
                registryRoles.add(registryRole);
            }
        }
    }
    if (!roleNameSet.contains(RegistryConstants.REGISTRY_SUPER_ADMIN_ROLE)) {
        Roles sra = Roles.findRoleByName(RegistryConstants.REGISTRY_SUPER_ADMIN_ROLE);
        RegistryRole rrSRA = new RegistryRoleConverter().build(sra);
        rrSRA.setAssigned(false);
        registryRoles.add(rrSRA);
    }
    return registryRoles.stream().sorted(Comparator.comparing(RegistryRole::getOrganizationCode).thenComparing(RegistryRole::getGeoObjectTypeCode)).toArray(size -> new RegistryRole[size]);
}
Also used : RegistryRole(org.commongeoregistry.adapter.metadata.RegistryRole) Organization(net.geoprism.registry.Organization) Roles(com.runwaysdk.system.Roles) LinkedList(java.util.LinkedList) RegistryRoleConverter(net.geoprism.registry.conversion.RegistryRoleConverter) GeoprismUser(net.geoprism.GeoprismUser) HashSet(java.util.HashSet) Business(com.runwaysdk.business.Business) Request(com.runwaysdk.session.Request)

Example 9 with GeoprismUser

use of net.geoprism.GeoprismUser in project geoprism-registry by terraframe.

the class SynchronizationConfigService method getJobs.

@Request(RequestType.SESSION)
public JsonObject getJobs(String sessionId, String configId, Integer pageSize, Integer pageNumber) {
    QueryFactory qf = new QueryFactory();
    DataExportJobQuery jQuery = new DataExportJobQuery(qf);
    jQuery.WHERE(jQuery.getConfig().EQ(configId));
    ExportHistoryQuery ihq = new ExportHistoryQuery(qf);
    ihq.WHERE(ihq.job(jQuery));
    ihq.restrictRows(pageSize, pageNumber);
    ihq.ORDER_BY_DESC(ihq.getCreateDate());
    try (OIterator<? extends ExportHistory> it = ihq.getIterator()) {
        LinkedList<JsonWrapper> results = new LinkedList<JsonWrapper>();
        while (it.hasNext()) {
            ExportHistory hist = it.next();
            DataExportJob job = (DataExportJob) hist.getAllJob().getAll().get(0);
            GeoprismUser user = GeoprismUser.get(job.getRunAsUser().getOid());
            results.add(new JsonWrapper(serializeHistory(hist, user, job)));
        }
        return new Page<JsonWrapper>(ihq.getCount(), pageNumber, pageSize, results).toJSON();
    }
}
Also used : QueryFactory(com.runwaysdk.query.QueryFactory) JsonWrapper(net.geoprism.registry.view.JsonWrapper) ExportHistoryQuery(net.geoprism.registry.etl.export.ExportHistoryQuery) ExportHistory(net.geoprism.registry.etl.export.ExportHistory) GeoprismUser(net.geoprism.GeoprismUser) DataExportJobQuery(net.geoprism.registry.etl.export.DataExportJobQuery) LinkedList(java.util.LinkedList) DataExportJob(net.geoprism.registry.etl.export.DataExportJob) Request(com.runwaysdk.session.Request)

Example 10 with GeoprismUser

use of net.geoprism.GeoprismUser in project geoprism-registry by terraframe.

the class SynchronizationConfigService method run.

@Request(RequestType.SESSION)
public JsonObject run(String sessionId, String oid) {
    SynchronizationConfig config = SynchronizationConfig.get(oid);
    ServiceFactory.getRolePermissionService().enforceRA(config.getOrganization().getCode());
    List<? extends DataExportJob> jobs = config.getJobs();
    DataExportJob job = jobs.get(0);
    job.appLock();
    job.setRunAsUserId(Session.getCurrentSession().getUser().getOid());
    job.apply();
    ExportHistory hist = job.start(config);
    GeoprismUser user = GeoprismUser.get(job.getRunAsUser().getOid());
    return serializeHistory(hist, user, job);
}
Also used : ExportHistory(net.geoprism.registry.etl.export.ExportHistory) SynchronizationConfig(net.geoprism.registry.SynchronizationConfig) GeoprismUser(net.geoprism.GeoprismUser) DataExportJob(net.geoprism.registry.etl.export.DataExportJob) Request(com.runwaysdk.session.Request)

Aggregations

GeoprismUser (net.geoprism.GeoprismUser)22 Transaction (com.runwaysdk.dataaccess.transaction.Transaction)9 JsonObject (com.google.gson.JsonObject)8 Request (com.runwaysdk.session.Request)8 QueryFactory (com.runwaysdk.query.QueryFactory)7 ServerGeoObjectType (net.geoprism.registry.model.ServerGeoObjectType)6 ProgrammingErrorException (com.runwaysdk.dataaccess.ProgrammingErrorException)5 JobHistory (com.runwaysdk.system.scheduler.JobHistory)5 SimpleDateFormat (java.text.SimpleDateFormat)5 LinkedList (java.util.LinkedList)5 DataExportJob (net.geoprism.registry.etl.export.DataExportJob)5 ExportHistory (net.geoprism.registry.etl.export.ExportHistory)5 RoleDAOIF (com.runwaysdk.business.rbac.RoleDAOIF)4 SingleActorDAOIF (com.runwaysdk.business.rbac.SingleActorDAOIF)3 ArrayList (java.util.ArrayList)3 RegistryRole (org.commongeoregistry.adapter.metadata.RegistryRole)3 JsonArray (com.google.gson.JsonArray)2 JsonParser (com.google.gson.JsonParser)2 JsonSyntaxException (com.google.gson.JsonSyntaxException)2 MultipartFileParameter (com.runwaysdk.controller.MultipartFileParameter)2