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);
}
}
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();
}
}
}
}
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]);
}
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();
}
}
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);
}
Aggregations