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