Search in sources :

Example 1 with ImportConfiguration

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);
    }
}
Also used : ImportConfiguration(net.geoprism.registry.etl.upload.ImportConfiguration)

Example 2 with ImportConfiguration

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();
}
Also used : InputStream(java.io.InputStream) VaultFile(com.runwaysdk.system.VaultFile) GeoObjectImportConfiguration(net.geoprism.registry.io.GeoObjectImportConfiguration) ImportConfiguration(net.geoprism.registry.etl.upload.ImportConfiguration) IOException(java.io.IOException) Transaction(com.runwaysdk.dataaccess.transaction.Transaction)

Example 3 with ImportConfiguration

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();
    }
}
Also used : QueryFactory(com.runwaysdk.query.QueryFactory) GeoObjectImportConfiguration(net.geoprism.registry.io.GeoObjectImportConfiguration) Organization(net.geoprism.registry.Organization) GeoObjectImportConfiguration(net.geoprism.registry.io.GeoObjectImportConfiguration) ImportConfiguration(net.geoprism.registry.etl.upload.ImportConfiguration) ImportHistoryQuery(net.geoprism.registry.etl.ImportHistoryQuery) ImportHistory(net.geoprism.registry.etl.ImportHistory) Transaction(com.runwaysdk.dataaccess.transaction.Transaction)

Example 4 with ImportConfiguration

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();
}
Also used : ImportConfiguration(net.geoprism.registry.etl.upload.ImportConfiguration) GeoObjectImportConfiguration(net.geoprism.registry.io.GeoObjectImportConfiguration) Request(com.runwaysdk.session.Request)

Example 5 with ImportConfiguration

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();
    }
}
Also used : QueryFactory(com.runwaysdk.query.QueryFactory) GeoObjectImportConfiguration(net.geoprism.registry.io.GeoObjectImportConfiguration) ImportConfiguration(net.geoprism.registry.etl.upload.ImportConfiguration) ProgrammingErrorException(com.runwaysdk.dataaccess.ProgrammingErrorException) Transaction(com.runwaysdk.dataaccess.transaction.Transaction)

Aggregations

ImportConfiguration (net.geoprism.registry.etl.upload.ImportConfiguration)7 GeoObjectImportConfiguration (net.geoprism.registry.io.GeoObjectImportConfiguration)6 Transaction (com.runwaysdk.dataaccess.transaction.Transaction)4 QueryFactory (com.runwaysdk.query.QueryFactory)3 Request (com.runwaysdk.session.Request)2 ImportHistory (net.geoprism.registry.etl.ImportHistory)2 ImportHistoryQuery (net.geoprism.registry.etl.ImportHistoryQuery)2 ProgrammingErrorException (com.runwaysdk.dataaccess.ProgrammingErrorException)1 VaultFile (com.runwaysdk.system.VaultFile)1 ExecutableJob (com.runwaysdk.system.scheduler.ExecutableJob)1 JobHistoryRecord (com.runwaysdk.system.scheduler.JobHistoryRecord)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 Organization (net.geoprism.registry.Organization)1 ServerGeoObjectType (net.geoprism.registry.model.ServerGeoObjectType)1