Search in sources :

Example 1 with Request

use of com.runwaysdk.session.Request in project geoprism-registry by terraframe.

the class ETLService method getValidationProblems.

@Request(RequestType.SESSION)
public JsonObject getValidationProblems(String sessionId, String historyId, boolean onlyUnresolved, int pageSize, int pageNumber) {
    ImportHistory hist = ImportHistory.get(historyId);
    ValidationProblemQuery vpq = new ValidationProblemQuery(new QueryFactory());
    vpq.WHERE(vpq.getHistory().EQ(hist));
    vpq.restrictRows(pageSize, pageNumber);
    vpq.ORDER_BY(vpq.getSeverity(), SortOrder.DESC);
    vpq.ORDER_BY(vpq.getAffectedRows(), SortOrder.ASC);
    if (onlyUnresolved) {
        vpq.WHERE(vpq.getResolution().EQ(ErrorResolution.UNRESOLVED.name()));
    }
    try (OIterator<? extends ValidationProblem> it = vpq.getIterator()) {
        List<ValidationProblem> results = new LinkedList<>(it.getAll());
        return new Page<ValidationProblem>(vpq.getCount(), vpq.getPageNumber(), vpq.getPageSize(), results).toJSON();
    }
}
Also used : QueryFactory(com.runwaysdk.query.QueryFactory) LinkedList(java.util.LinkedList) Request(com.runwaysdk.session.Request)

Example 2 with Request

use of com.runwaysdk.session.Request 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 3 with Request

use of com.runwaysdk.session.Request in project geoprism-registry by terraframe.

the class ETLService method importEdgeJson.

@Request(RequestType.SESSION)
public void importEdgeJson(String sessionId, String relationshipType, String graphTypeCode, Date startDate, Date endDate, InputStream stream) {
    try {
        GraphType graphType = GraphType.getByCode(relationshipType, graphTypeCode);
        EdgeJsonImporter importer = new EdgeJsonImporter(stream, graphType, startDate, endDate);
        importer.importData();
    } catch (JsonSyntaxException | IOException e) {
        throw new ProgrammingErrorException(e);
    }
}
Also used : JsonSyntaxException(com.google.gson.JsonSyntaxException) GraphType(net.geoprism.registry.model.GraphType) IOException(java.io.IOException) ProgrammingErrorException(com.runwaysdk.dataaccess.ProgrammingErrorException) Request(com.runwaysdk.session.Request)

Example 4 with Request

use of com.runwaysdk.session.Request in project geoprism-registry by terraframe.

the class ETLService method getImportDetails.

// @Request(RequestType.SESSION)
// public JSONObject getReferenceValidationProblems(String sessionId, String
// historyId, boolean onlyUnresolved, int pageSize, int pageNumber)
// {
// ImportHistory hist = ImportHistory.get(historyId);
// 
// ValidationProblemQuery vpq = new ValidationProblemQuery(new
// QueryFactory());
// vpq.WHERE(vpq.getHistory().EQ(hist).AND(vpq.getType().EQ(ParentReferenceProblem.CLASS).OR(vpq.getType().EQ(TermReferenceProblem.CLASS))));
// vpq.restrictRows(pageSize, pageNumber);
// vpq.ORDER_BY(vpq.getCreateDate(), SortOrder.ASC);
// 
// if (onlyUnresolved)
// {
// vpq.WHERE(vpq.getResolution().EQ(ErrorResolution.UNRESOLVED.name()));
// }
// 
// JSONObject page = new JSONObject();
// page.put("count", vpq.getCount());
// page.put("pageNumber", vpq.getPageNumber());
// page.put("pageSize", vpq.getPageSize());
// 
// JSONArray jaVP = new JSONArray();
// 
// OIterator<? extends ValidationProblem> it = vpq.getIterator();
// try
// {
// while (it.hasNext())
// {
// ValidationProblem vp = it.next();
// 
// jaVP.put(vp.toJSON());
// }
// }
// finally
// {
// it.close();
// }
// 
// page.put("results", jaVP);
// 
// return page;
// }
// 
// @Request(RequestType.SESSION)
// public JSONObject getRowValidationProblems(String sessionId, String
// historyId, boolean onlyUnresolved, int pageSize, int pageNumber)
// {
// ImportHistory hist = ImportHistory.get(historyId);
// 
// RowValidationProblemQuery vpq = new RowValidationProblemQuery(new
// QueryFactory());
// vpq.WHERE(vpq.getHistory().EQ(hist));
// vpq.restrictRows(pageSize, pageNumber);
// vpq.ORDER_BY(vpq.getRowNum(), SortOrder.ASC);
// 
// if (onlyUnresolved)
// {
// vpq.WHERE(vpq.getResolution().EQ(ErrorResolution.UNRESOLVED.name()));
// }
// 
// JSONObject page = new JSONObject();
// page.put("count", vpq.getCount());
// page.put("pageNumber", vpq.getPageNumber());
// page.put("pageSize", vpq.getPageSize());
// 
// JSONArray jaVP = new JSONArray();
// 
// OIterator<? extends ValidationProblem> it = vpq.getIterator();
// try
// {
// while (it.hasNext())
// {
// ValidationProblem vp = it.next();
// 
// jaVP.put(vp.toJSON());
// }
// }
// finally
// {
// it.close();
// }
// 
// page.put("results", jaVP);
// 
// return page;
// }
@Request(RequestType.SESSION)
public JsonObject getImportDetails(String sessionId, String historyId, boolean onlyUnresolved, int pageSize, int pageNumber) {
    ImportHistory hist = ImportHistory.get(historyId);
    DataImportJob job = (DataImportJob) hist.getAllJob().getAll().get(0);
    GeoprismUser user = GeoprismUser.get(job.getRunAsUser().getOid());
    hist.getConfig().enforceExecutePermissions();
    JsonObject jo = this.serializeHistory(hist, user, job);
    if (hist.getStage().get(0).equals(ImportStage.IMPORT_RESOLVE) && hist.hasImportErrors()) {
        jo.add("importErrors", this.getImportErrors(sessionId, historyId, onlyUnresolved, pageSize, pageNumber));
    } else if (hist.getStage().get(0).equals(ImportStage.VALIDATION_RESOLVE)) {
        jo.add("problems", this.getValidationProblems(sessionId, historyId, onlyUnresolved, pageSize, pageNumber));
    }
    return jo;
}
Also used : JsonObject(com.google.gson.JsonObject) GeoprismUser(net.geoprism.GeoprismUser) Request(com.runwaysdk.session.Request)

Example 5 with Request

use of com.runwaysdk.session.Request in project geoprism-registry by terraframe.

the class ETLService method getImportErrors.

@Request(RequestType.SESSION)
public JsonObject getImportErrors(String sessionId, String historyId, boolean onlyUnresolved, int pageSize, int pageNumber) {
    ImportErrorQuery query = new ImportErrorQuery(new QueryFactory());
    query.WHERE(query.getHistory().EQ(historyId));
    if (onlyUnresolved) {
        query.WHERE(query.getResolution().EQ(ErrorResolution.UNRESOLVED.name()));
    }
    query.ORDER_BY(query.getRowIndex(), SortOrder.ASC);
    query.restrictRows(pageSize, pageNumber);
    try (OIterator<? extends ImportError> it = query.getIterator()) {
        List<ImportError> results = new LinkedList<>(it.getAll());
        return new Page<ImportError>(query.getCount(), query.getPageNumber(), query.getPageSize(), results).toJSON();
    }
}
Also used : QueryFactory(com.runwaysdk.query.QueryFactory) LinkedList(java.util.LinkedList) Request(com.runwaysdk.session.Request)

Aggregations

Request (com.runwaysdk.session.Request)340 Test (org.junit.Test)145 JsonObject (com.google.gson.JsonObject)85 ServerGeoObjectIF (net.geoprism.registry.model.ServerGeoObjectIF)73 ServerGeoObjectType (net.geoprism.registry.model.ServerGeoObjectType)73 LocalizedValue (org.commongeoregistry.adapter.dataaccess.LocalizedValue)53 ServerHierarchyType (net.geoprism.registry.model.ServerHierarchyType)40 JsonArray (com.google.gson.JsonArray)36 Date (java.util.Date)33 ChangeRequest (net.geoprism.registry.action.ChangeRequest)32 OAuthClientRequest (org.apache.oltu.oauth2.client.request.OAuthClientRequest)31 QueryFactory (com.runwaysdk.query.QueryFactory)30 ValueOverTime (com.runwaysdk.dataaccess.graph.attributes.ValueOverTime)26 ValueOverTimeCollection (com.runwaysdk.dataaccess.graph.attributes.ValueOverTimeCollection)22 ListType (net.geoprism.registry.ListType)21 SimpleDateFormat (java.text.SimpleDateFormat)19 Classification (net.geoprism.registry.model.Classification)19 VertexServerGeoObject (net.geoprism.registry.model.graph.VertexServerGeoObject)19 ClassificationTypeTest (net.geoprism.registry.classification.ClassificationTypeTest)17 TransitionEvent (net.geoprism.registry.graph.transition.TransitionEvent)17