use of net.geoprism.registry.etl.upload.ImportConfiguration in project geoprism-registry by terraframe.
the class DataImportJob method execute.
@Override
public void execute(ExecutionContext executionContext) throws MalformedURLException, InvocationTargetException {
try {
Thread.currentThread().setPriority(Thread.MIN_PRIORITY);
ImportHistory history = (ImportHistory) executionContext.getJobHistoryRecord().getChild();
ImportStage stage = history.getStage().get(0);
ImportConfiguration config = ImportConfiguration.build(history.getConfigJson());
process(executionContext, history, stage, config);
} finally {
Thread.currentThread().setPriority(Thread.NORM_PRIORITY);
}
}
use of net.geoprism.registry.etl.upload.ImportConfiguration in project geoprism-registry by terraframe.
the class ETLService method reImportInTrans.
@Transaction
public void reImportInTrans(MultipartFileParameter file, String json) {
ImportConfiguration config = ImportConfiguration.build(json);
ImportHistory hist = ImportHistory.get(config.getHistoryId());
hist.getConfig().enforceExecutePermissions();
VaultFile vf = VaultFile.get(config.getVaultFileId());
vf.delete();
VaultFile vf2 = null;
try (InputStream is = file.getInputStream()) {
vf2 = VaultFile.createAndApply(file.getFilename(), is);
} catch (IOException e) {
throw new RuntimeException(e);
}
config.setVaultFileId(vf2.getOid());
config.setFileName(file.getFilename());
hist = ImportHistory.lock(config.getHistoryId());
hist.setImportFile(vf2);
hist.setConfigJson(config.toJSON().toString());
hist.apply();
}
use of net.geoprism.registry.etl.upload.ImportConfiguration in project geoprism-registry by terraframe.
the class PatchOrgIntoImportHistory method doIt.
@Transaction
private void doIt() {
ImportHistoryQuery ihq = new ImportHistoryQuery(new QueryFactory());
OIterator<? extends ImportHistory> it = ihq.getIterator();
try {
for (ImportHistory hist : it) {
try {
ImportConfiguration config = hist.getConfig();
if (config instanceof GeoObjectImportConfiguration) {
GeoObjectImportConfiguration goConfig = (GeoObjectImportConfiguration) config;
Organization org = goConfig.getType().getOrganization();
hist.appLock();
hist.setOrganization(org);
hist.apply();
}
} catch (net.geoprism.registry.DataNotFoundException e) {
logger.error("ImportHistory references object which does not exist", e);
}
}
} finally {
it.close();
}
}
use of net.geoprism.registry.etl.upload.ImportConfiguration in project geoprism-registry by terraframe.
the class ShapefileService method cancelImport.
@Request(RequestType.SESSION)
public void cancelImport(String sessionId, String json) {
ImportConfiguration config = ImportConfiguration.build(json);
String id = config.getVaultFileId();
VaultFile.get(id).delete();
}
use of net.geoprism.registry.etl.upload.ImportConfiguration in project geoprism-registry by terraframe.
the class ETLService method cancelImportInTrans.
@Transaction
private void cancelImportInTrans(String sessionId, String json) {
ImportConfiguration config = ImportConfiguration.build(json);
String id = config.getVaultFileId();
VaultFile.get(id).delete();
if (config.getHistoryId() != null && config.getHistoryId().length() > 0) {
String historyId = config.getHistoryId();
ImportHistory hist = ImportHistory.get(historyId);
hist.getConfig().enforceExecutePermissions();
if (!hist.getStage().get(0).equals(ImportStage.VALIDATION_RESOLVE)) {
throw new ProgrammingErrorException("Import jobs can only be canceled if they are in " + ImportStage.VALIDATION_RESOLVE.name() + " stage.");
}
ValidationProblemQuery vpq = new ValidationProblemQuery(new QueryFactory());
vpq.WHERE(vpq.getHistory().EQ(historyId));
OIterator<? extends ValidationProblem> it = vpq.getIterator();
try {
while (it.hasNext()) {
it.next().delete();
}
} finally {
it.close();
}
hist = ImportHistory.lock(historyId);
hist.clearStage();
hist.addStage(ImportStage.COMPLETE);
hist.clearStatus();
hist.addStatus(AllJobStatus.CANCELED);
hist.setImportedRecords(0L);
hist.apply();
}
}
Aggregations