Search in sources :

Example 6 with ImportConfiguration

use of net.geoprism.registry.etl.upload.ImportConfiguration in project geoprism-registry by terraframe.

the class ETLService method doImport.

@Request(RequestType.SESSION)
public JsonObject doImport(String sessionId, String json) {
    ImportConfiguration config = ImportConfiguration.build(json);
    config.enforceExecutePermissions();
    ImportHistory hist;
    if (config.getHistoryId() != null && config.getHistoryId().length() > 0) {
        String historyId = config.getHistoryId();
        hist = ImportHistory.get(historyId);
        JobHistoryRecord record = hist.getAllJobRel().getAll().get(0);
        ExecutableJob execJob = record.getParent();
        execJob.resume(record);
    } else {
        DataImportJob job = new DataImportJob();
        job.setRunAsUserId(Session.getCurrentSession().getUser().getOid());
        job.apply();
        hist = job.start(config);
    }
    return JsonParser.parseString(hist.getConfigJson()).getAsJsonObject();
}
Also used : JobHistoryRecord(com.runwaysdk.system.scheduler.JobHistoryRecord) GeoObjectImportConfiguration(net.geoprism.registry.io.GeoObjectImportConfiguration) ImportConfiguration(net.geoprism.registry.etl.upload.ImportConfiguration) ExecutableJob(com.runwaysdk.system.scheduler.ExecutableJob) Request(com.runwaysdk.session.Request)

Example 7 with ImportConfiguration

use of net.geoprism.registry.etl.upload.ImportConfiguration in project geoprism-registry by terraframe.

the class PatchGotIntoImportHistory 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;
                    ServerGeoObjectType type = goConfig.getType();
                    hist.appLock();
                    hist.setOrganization(type.getOrganization());
                    hist.setGeoObjectTypeCode(type.getCode());
                    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) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) 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)

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