use of net.geoprism.registry.etl.export.DataExportJob in project geoprism-registry by terraframe.
the class SynchronizationConfig method apply.
@Override
@Transaction
public void apply() {
SessionIF session = Session.getCurrentSession();
Organization organization = this.getOrganization();
if (session != null && organization != null) {
ServiceFactory.getRolePermissionService().enforceRA(organization.getCode());
}
super.apply();
if (this.isNew()) {
DataExportJob job = new DataExportJob();
job.setConfig(this);
job.apply();
}
}
use of net.geoprism.registry.etl.export.DataExportJob in project geoprism-registry by terraframe.
the class SynchronizationConfig method delete.
@Override
@Transaction
public void delete() {
List<? extends DataExportJob> jobs = getJobs();
for (DataExportJob job : jobs) {
job.delete();
}
super.delete();
}
use of net.geoprism.registry.etl.export.DataExportJob in project geoprism-registry by terraframe.
the class ETLService method serializeHistory.
protected JsonObject serializeHistory(JobHistory hist, GeoprismUser user, ExecutableJob job) {
JsonObject jo = new JsonObject();
jo.addProperty("jobType", job.getType());
jo.addProperty("status", hist.getStatus().get(0).name());
jo.addProperty("author", user.getUsername());
jo.addProperty("createDate", formatDate(hist.getCreateDate()));
jo.addProperty("lastUpdateDate", formatDate(hist.getLastUpdateDate()));
jo.addProperty("workProgress", hist.getWorkProgress());
jo.addProperty("workTotal", hist.getWorkTotal());
jo.addProperty("historyId", hist.getOid());
jo.addProperty("jobId", job.getOid());
if (hist instanceof ImportHistory) {
ImportHistory iHist = (ImportHistory) hist;
jo.addProperty("importedRecords", iHist.getImportedRecords());
jo.addProperty("stage", iHist.getStage().get(0).name());
JsonObject config = JsonParser.parseString(iHist.getConfigJson()).getAsJsonObject();
jo.addProperty("fileName", config.get(ImportConfiguration.FILE_NAME).getAsString());
jo.add("configuration", JsonParser.parseString(config.toString()));
} else if (hist instanceof ExportHistory) {
ExportHistory eHist = (ExportHistory) hist;
jo.addProperty("exportedRecords", eHist.getExportedRecords());
jo.addProperty("stage", eHist.getStage().get(0).name());
}
if (job instanceof DataExportJob) {
jo.addProperty("configuration", ((DataExportJob) job).getConfigOid());
}
if (hist.getStatus().get(0).equals(AllJobStatus.FAILURE) && hist.getErrorJson().length() > 0) {
JsonObject exception = new JsonObject();
exception.add("type", JsonParser.parseString(hist.getErrorJson()).getAsJsonObject().get("type"));
exception.addProperty("message", hist.getLocalizedError(Session.getCurrentLocale()));
jo.add("exception", exception);
}
return jo;
}
use of net.geoprism.registry.etl.export.DataExportJob 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.registry.etl.export.DataExportJob 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