Search in sources :

Example 1 with JsonWrapper

use of net.geoprism.registry.view.JsonWrapper in project geoprism-registry by terraframe.

the class ETLService method getActiveImports.

@Request(RequestType.SESSION)
public JsonObject getActiveImports(String sessionId, int pageSize, int pageNumber, String sortAttr, boolean isAscending) {
    JsonArray ja = new JsonArray();
    QueryFactory qf = new QueryFactory();
    ImportHistoryQuery ihq = new ImportHistoryQuery(qf);
    ihq.WHERE(ihq.getStatus().containsExactly(AllJobStatus.RUNNING).OR(ihq.getStatus().containsExactly(AllJobStatus.NEW)).OR(ihq.getStatus().containsExactly(AllJobStatus.QUEUED)).OR(ihq.getStatus().containsExactly(AllJobStatus.FEEDBACK)));
    this.filterHistoryQueryBasedOnPermissions(ihq);
    ihq.restrictRows(pageSize, pageNumber);
    ihq.ORDER_BY(ihq.get(sortAttr), isAscending ? SortOrder.ASC : SortOrder.DESC);
    try (OIterator<? extends ImportHistory> it = ihq.getIterator()) {
        List<JsonWrapper> results = it.getAll().stream().map(hist -> {
            DataImportJob job = (DataImportJob) hist.getAllJob().getAll().get(0);
            GeoprismUser user = GeoprismUser.get(job.getRunAsUser().getOid());
            return new JsonWrapper(serializeHistory(hist, user, job));
        }).collect(Collectors.toList());
        return new Page<JsonWrapper>(ihq.getCount(), ihq.getPageNumber(), ihq.getPageSize(), results).toJSON();
    }
}
Also used : JsonArray(com.google.gson.JsonArray) JsonObject(com.google.gson.JsonObject) SortOrder(com.runwaysdk.query.OrderBy.SortOrder) Date(java.util.Date) ErrorResolution(net.geoprism.registry.etl.ImportError.ErrorResolution) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) Request(com.runwaysdk.session.Request) Condition(com.runwaysdk.query.Condition) DataExportJob(net.geoprism.registry.etl.export.DataExportJob) Organization(net.geoprism.registry.Organization) JsonWrapper(net.geoprism.registry.view.JsonWrapper) Optional(org.commongeoregistry.adapter.Optional) ServerParentTreeNodeOverTime(net.geoprism.registry.view.ServerParentTreeNodeOverTime) RoleDAOIF(com.runwaysdk.business.rbac.RoleDAOIF) JobHistory(com.runwaysdk.system.scheduler.JobHistory) Collectors(java.util.stream.Collectors) ExportHistory(net.geoprism.registry.etl.export.ExportHistory) Page(net.geoprism.registry.view.Page) List(java.util.List) JsonArray(com.google.gson.JsonArray) GraphType(net.geoprism.registry.model.GraphType) AllJobStatus(com.runwaysdk.system.scheduler.AllJobStatus) SingleActorDAOIF(com.runwaysdk.business.rbac.SingleActorDAOIF) RegistryIdService(net.geoprism.registry.service.RegistryIdService) GeoObjectImportConfiguration(net.geoprism.registry.io.GeoObjectImportConfiguration) JobHistoryRecord(com.runwaysdk.system.scheduler.JobHistoryRecord) RegistryRole(org.commongeoregistry.adapter.metadata.RegistryRole) ProgrammingErrorException(com.runwaysdk.dataaccess.ProgrammingErrorException) Transaction(com.runwaysdk.dataaccess.transaction.Transaction) GeoSynonymService(net.geoprism.registry.service.GeoSynonymService) RequestType(com.runwaysdk.session.RequestType) SimpleDateFormat(java.text.SimpleDateFormat) ExecutableJob(com.runwaysdk.system.scheduler.ExecutableJob) JsonParser(com.google.gson.JsonParser) RegistryService(net.geoprism.registry.service.RegistryService) ServiceFactory(net.geoprism.registry.service.ServiceFactory) ArrayList(java.util.ArrayList) QueryFactory(com.runwaysdk.query.QueryFactory) LinkedList(java.util.LinkedList) ImportConfiguration(net.geoprism.registry.etl.upload.ImportConfiguration) GeoObjectOverTime(org.commongeoregistry.adapter.dataaccess.GeoObjectOverTime) ServerGeoObjectIF(net.geoprism.registry.model.ServerGeoObjectIF) JsonSyntaxException(com.google.gson.JsonSyntaxException) ExportError(net.geoprism.registry.etl.export.ExportError) ServerGeoObjectService(net.geoprism.registry.geoobject.ServerGeoObjectService) IOException(java.io.IOException) ValidationResolution(net.geoprism.registry.etl.ValidationProblem.ValidationResolution) MultipartFileParameter(com.runwaysdk.controller.MultipartFileParameter) ExportErrorQuery(net.geoprism.registry.etl.export.ExportErrorQuery) OIterator(com.runwaysdk.query.OIterator) VaultFile(com.runwaysdk.system.VaultFile) GeoprismUser(net.geoprism.GeoprismUser) Session(com.runwaysdk.session.Session) RolePermissionService(net.geoprism.registry.permission.RolePermissionService) InputStream(java.io.InputStream) DataUploader(net.geoprism.DataUploader) QueryFactory(com.runwaysdk.query.QueryFactory) JsonWrapper(net.geoprism.registry.view.JsonWrapper) GeoprismUser(net.geoprism.GeoprismUser) Request(com.runwaysdk.session.Request)

Example 2 with JsonWrapper

use of net.geoprism.registry.view.JsonWrapper in project geoprism-registry by terraframe.

the class TaskService method getTasksForCurrentUser.

@Request(RequestType.SESSION)
public static JsonObject getTasksForCurrentUser(String sessionId, String orderBy, int pageNum, int pageSize, String whereStatus) {
    QueryFactory qf = new QueryFactory();
    ValueQuery vq = new ValueQuery(qf);
    TaskHasRoleQuery thrq = new TaskHasRoleQuery(vq);
    TaskQuery tq = new TaskQuery(vq);
    vq.WHERE(thrq.getParent().EQ(tq));
    if (whereStatus != null) {
        vq.WHERE(tq.getStatus().EQ(whereStatus));
    }
    RolesQuery rq = new RolesQuery(vq);
    vq.WHERE(thrq.getChild().EQ(rq));
    Condition cond = null;
    // Map<String, String> roles = Session.getCurrentSession().getUserRoles();
    Set<RoleDAOIF> roles = Session.getCurrentSession().getUser().assignedRoles();
    // for (String roleName : roles.keySet())
    for (RoleDAOIF role : roles) {
        String roleName = role.getRoleName();
        if (roleName.equals(DefaultConfiguration.ADMIN)) {
            continue;
        }
        if (cond == null) {
            cond = rq.getRoleName().EQ(roleName);
        } else {
            cond = cond.OR(rq.getRoleName().EQ(roleName));
        }
    }
    vq.WHERE(cond);
    LocalizedValueStoreQuery lvsqTemplate = new LocalizedValueStoreQuery(vq);
    vq.WHERE(tq.getTemplate().EQ(lvsqTemplate));
    LocalizedValueStoreQuery lvsqTitle = new LocalizedValueStoreQuery(vq);
    vq.WHERE(tq.getTitle().EQ(lvsqTitle));
    vq.SELECT(tq.getOid("oid"));
    vq.SELECT(lvsqTemplate.getStoreKey("templateKey"));
    vq.SELECT(tq.getMessage().localize("msg"));
    vq.SELECT(lvsqTitle.getStoreValue().localize("title"));
    vq.SELECT(tq.getStatus("status"));
    vq.SELECT(tq.getCreateDate("createDate"));
    vq.SELECT(tq.getLastUpdateDate("completedDate"));
    vq.ORDER_BY(tq.get(orderBy), SortOrder.DESC);
    vq.restrictRows(pageSize, pageNum);
    try (OIterator<ValueObject> it = vq.getIterator()) {
        List<JsonWrapper> results = it.getAll().stream().map(vo -> {
            JsonObject jo = new JsonObject();
            jo.addProperty("id", vo.getValue("oid"));
            jo.addProperty("templateKey", vo.getValue("templateKey"));
            jo.addProperty("msg", vo.getValue("msg"));
            jo.addProperty("title", vo.getValue("title"));
            jo.addProperty("status", vo.getValue("status"));
            jo.addProperty("createDate", ETLService.formatDate(MdAttributeDateTimeUtil.getTypeSafeValue(vo.getValue("createDate"))));
            jo.addProperty("completedDate", vo.getValue("status").equals(TaskStatus.RESOLVED.name()) ? ETLService.formatDate(MdAttributeDateTimeUtil.getTypeSafeValue(vo.getValue("completedDate"))) : null);
            return new JsonWrapper(jo);
        }).collect(Collectors.toList());
        return new Page<JsonWrapper>(vq.getCount(), pageNum, pageSize, results).toJSON();
    }
}
Also used : ValueQuery(com.runwaysdk.query.ValueQuery) Condition(com.runwaysdk.query.Condition) JsonObject(com.google.gson.JsonObject) SortOrder(com.runwaysdk.query.OrderBy.SortOrder) ProgrammingErrorException(com.runwaysdk.dataaccess.ProgrammingErrorException) RequestType(com.runwaysdk.session.RequestType) RoleDAOIF(com.runwaysdk.business.rbac.RoleDAOIF) Set(java.util.Set) ValueObject(com.runwaysdk.dataaccess.ValueObject) LocalizedValueStoreQuery(com.runwaysdk.localization.LocalizedValueStoreQuery) MdAttributeDateTimeUtil(com.runwaysdk.constants.MdAttributeDateTimeUtil) Collectors(java.util.stream.Collectors) Request(com.runwaysdk.session.Request) RolesQuery(com.runwaysdk.system.RolesQuery) DefaultConfiguration(net.geoprism.DefaultConfiguration) ETLService(net.geoprism.registry.etl.ETLService) OIterator(com.runwaysdk.query.OIterator) Page(net.geoprism.registry.view.Page) ValueQuery(com.runwaysdk.query.ValueQuery) List(java.util.List) Condition(com.runwaysdk.query.Condition) JsonWrapper(net.geoprism.registry.view.JsonWrapper) QueryFactory(com.runwaysdk.query.QueryFactory) Session(com.runwaysdk.session.Session) TaskStatus(net.geoprism.registry.task.Task.TaskStatus) QueryFactory(com.runwaysdk.query.QueryFactory) JsonObject(com.google.gson.JsonObject) JsonWrapper(net.geoprism.registry.view.JsonWrapper) RolesQuery(com.runwaysdk.system.RolesQuery) ValueObject(com.runwaysdk.dataaccess.ValueObject) RoleDAOIF(com.runwaysdk.business.rbac.RoleDAOIF) LocalizedValueStoreQuery(com.runwaysdk.localization.LocalizedValueStoreQuery) Request(com.runwaysdk.session.Request)

Example 3 with JsonWrapper

use of net.geoprism.registry.view.JsonWrapper 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 4 with JsonWrapper

use of net.geoprism.registry.view.JsonWrapper in project geoprism-registry by terraframe.

the class ETLService method getCompletedImports.

@Request(RequestType.SESSION)
public JsonObject getCompletedImports(String sessionId, int pageSize, int pageNumber, String sortAttr, boolean isAscending) {
    QueryFactory qf = new QueryFactory();
    ImportHistoryQuery ihq = new ImportHistoryQuery(qf);
    ihq.WHERE(ihq.getStatus().containsExactly(AllJobStatus.SUCCESS).OR(ihq.getStatus().containsExactly(AllJobStatus.FAILURE)).OR(ihq.getStatus().containsExactly(AllJobStatus.CANCELED)));
    this.filterHistoryQueryBasedOnPermissions(ihq);
    ihq.restrictRows(pageSize, pageNumber);
    ihq.ORDER_BY(ihq.get(sortAttr), isAscending ? SortOrder.ASC : SortOrder.DESC);
    try (OIterator<? extends ImportHistory> it = ihq.getIterator()) {
        List<JsonWrapper> results = it.getAll().stream().map(hist -> {
            DataImportJob job = (DataImportJob) hist.getAllJob().getAll().get(0);
            GeoprismUser user = GeoprismUser.get(job.getRunAsUser().getOid());
            return new JsonWrapper(serializeHistory(hist, user, job));
        }).collect(Collectors.toList());
        return new Page<JsonWrapper>(ihq.getCount(), ihq.getPageNumber(), ihq.getPageSize(), results).toJSON();
    }
}
Also used : JsonObject(com.google.gson.JsonObject) SortOrder(com.runwaysdk.query.OrderBy.SortOrder) Date(java.util.Date) ErrorResolution(net.geoprism.registry.etl.ImportError.ErrorResolution) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) Request(com.runwaysdk.session.Request) Condition(com.runwaysdk.query.Condition) DataExportJob(net.geoprism.registry.etl.export.DataExportJob) Organization(net.geoprism.registry.Organization) JsonWrapper(net.geoprism.registry.view.JsonWrapper) Optional(org.commongeoregistry.adapter.Optional) ServerParentTreeNodeOverTime(net.geoprism.registry.view.ServerParentTreeNodeOverTime) RoleDAOIF(com.runwaysdk.business.rbac.RoleDAOIF) JobHistory(com.runwaysdk.system.scheduler.JobHistory) Collectors(java.util.stream.Collectors) ExportHistory(net.geoprism.registry.etl.export.ExportHistory) Page(net.geoprism.registry.view.Page) List(java.util.List) JsonArray(com.google.gson.JsonArray) GraphType(net.geoprism.registry.model.GraphType) AllJobStatus(com.runwaysdk.system.scheduler.AllJobStatus) SingleActorDAOIF(com.runwaysdk.business.rbac.SingleActorDAOIF) RegistryIdService(net.geoprism.registry.service.RegistryIdService) GeoObjectImportConfiguration(net.geoprism.registry.io.GeoObjectImportConfiguration) JobHistoryRecord(com.runwaysdk.system.scheduler.JobHistoryRecord) RegistryRole(org.commongeoregistry.adapter.metadata.RegistryRole) ProgrammingErrorException(com.runwaysdk.dataaccess.ProgrammingErrorException) Transaction(com.runwaysdk.dataaccess.transaction.Transaction) GeoSynonymService(net.geoprism.registry.service.GeoSynonymService) RequestType(com.runwaysdk.session.RequestType) SimpleDateFormat(java.text.SimpleDateFormat) ExecutableJob(com.runwaysdk.system.scheduler.ExecutableJob) JsonParser(com.google.gson.JsonParser) RegistryService(net.geoprism.registry.service.RegistryService) ServiceFactory(net.geoprism.registry.service.ServiceFactory) ArrayList(java.util.ArrayList) QueryFactory(com.runwaysdk.query.QueryFactory) LinkedList(java.util.LinkedList) ImportConfiguration(net.geoprism.registry.etl.upload.ImportConfiguration) GeoObjectOverTime(org.commongeoregistry.adapter.dataaccess.GeoObjectOverTime) ServerGeoObjectIF(net.geoprism.registry.model.ServerGeoObjectIF) JsonSyntaxException(com.google.gson.JsonSyntaxException) ExportError(net.geoprism.registry.etl.export.ExportError) ServerGeoObjectService(net.geoprism.registry.geoobject.ServerGeoObjectService) IOException(java.io.IOException) ValidationResolution(net.geoprism.registry.etl.ValidationProblem.ValidationResolution) MultipartFileParameter(com.runwaysdk.controller.MultipartFileParameter) ExportErrorQuery(net.geoprism.registry.etl.export.ExportErrorQuery) OIterator(com.runwaysdk.query.OIterator) VaultFile(com.runwaysdk.system.VaultFile) GeoprismUser(net.geoprism.GeoprismUser) Session(com.runwaysdk.session.Session) RolePermissionService(net.geoprism.registry.permission.RolePermissionService) InputStream(java.io.InputStream) DataUploader(net.geoprism.DataUploader) QueryFactory(com.runwaysdk.query.QueryFactory) JsonWrapper(net.geoprism.registry.view.JsonWrapper) GeoprismUser(net.geoprism.GeoprismUser) Request(com.runwaysdk.session.Request)

Aggregations

QueryFactory (com.runwaysdk.query.QueryFactory)4 Request (com.runwaysdk.session.Request)4 JsonObject (com.google.gson.JsonObject)3 RoleDAOIF (com.runwaysdk.business.rbac.RoleDAOIF)3 ProgrammingErrorException (com.runwaysdk.dataaccess.ProgrammingErrorException)3 Condition (com.runwaysdk.query.Condition)3 OIterator (com.runwaysdk.query.OIterator)3 SortOrder (com.runwaysdk.query.OrderBy.SortOrder)3 RequestType (com.runwaysdk.session.RequestType)3 Session (com.runwaysdk.session.Session)3 LinkedList (java.util.LinkedList)3 List (java.util.List)3 Collectors (java.util.stream.Collectors)3 GeoprismUser (net.geoprism.GeoprismUser)3 DataExportJob (net.geoprism.registry.etl.export.DataExportJob)3 ExportHistory (net.geoprism.registry.etl.export.ExportHistory)3 JsonWrapper (net.geoprism.registry.view.JsonWrapper)3 JsonArray (com.google.gson.JsonArray)2 JsonParser (com.google.gson.JsonParser)2 JsonSyntaxException (com.google.gson.JsonSyntaxException)2