Search in sources :

Example 1 with ImportHistory

use of net.geoprism.registry.etl.ImportHistory 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 2 with ImportHistory

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

the class SchedulerTestUtils method clearImportData.

@Request
public static void clearImportData() {
    List<JobHistoryRecord> stoppedJobs = SchedulerManager.interruptAllRunningJobs();
    if (stoppedJobs.size() > 0) {
        try {
            // Wait a few seconds for the job to stop
            Thread.sleep(2000);
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
    }
    ValidationProblemQuery vpq = new ValidationProblemQuery(new QueryFactory());
    OIterator<? extends ValidationProblem> vpit = vpq.getIterator();
    while (vpit.hasNext()) {
        ValidationProblem.lock(vpit.next().getOid()).delete();
    }
    ImportErrorQuery ieq = new ImportErrorQuery(new QueryFactory());
    OIterator<? extends ImportError> ieit = ieq.getIterator();
    while (ieit.hasNext()) {
        ImportError.lock(ieit.next().getOid()).delete();
    }
    JobHistoryRecordQuery query = new JobHistoryRecordQuery(new QueryFactory());
    OIterator<? extends JobHistoryRecord> jhrs = query.getIterator();
    while (jhrs.hasNext()) {
        JobHistoryRecord jhr = JobHistoryRecord.lock(jhrs.next().getOid());
        jhr.appLock();
        JobHistory hist = jhr.getChild();
        if (hist instanceof ImportHistory) {
            hist = ImportHistory.lock(hist.getOid());
            hist.appLock();
            ExecutableJob job = jhr.getParent();
            job.appLock();
            // If any tests are currently running, they will be errored out as a result of this.
            if (hist.getStatus().get(0).equals(AllJobStatus.RUNNING) || hist.getStatus().get(0).equals(AllJobStatus.NEW) || hist.getStatus().get(0).equals(AllJobStatus.QUEUED)) {
                logger.error("History with oid [" + hist.getOid() + "] currently has status [" + hist.getStatus().get(0).getEnumName() + "] which is concerning because it is about to be deleted. This will probably cause errors in the running job.");
            }
            // hist = ImportHistory.lock(hist.getOid());
            // hist.appLock();
            // hist = ImportHistory.lock(hist.getOid());
            // VaultFile vf = ( (ImportHistory) hist ).getImportFile();
            // hist.setValue(ImportHistory.IMPORTFILE, null);
            // JobHistoryHistoryComment comment = hist.getHistoryComment();
            // hist.setValue(JobHistory.HISTORYCOMMENT, null);
            // JobHistoryHistoryInformation information = hist.getHistoryInformation();
            // hist.setValue(JobHistory.HISTORYINFORMATION, null);
            // hist.apply();
            // vf.delete();
            // comment.delete();
            // information.delete();
            // hist = ImportHistory.lock(hist.getOid());
            // hist.appLock();
            // hist = ImportHistory.lock(hist.getOid());
            // hist.delete();
            // This will also delete the history.
            JobHistoryRecord.lock(jhr.getOid()).delete();
            ExecutableJob.lock(job.getOid()).delete();
        }
    }
    SynonymQuery sq = new SynonymQuery(new QueryFactory());
    sq.WHERE(sq.getDisplayLabel().localize().EQ("00"));
    OIterator<? extends Synonym> it = sq.getIterator();
    while (it.hasNext()) {
        Synonym.lock(it.next().getOid()).delete();
    }
}
Also used : QueryFactory(com.runwaysdk.query.QueryFactory) JobHistory(com.runwaysdk.system.scheduler.JobHistory) SynonymQuery(com.runwaysdk.system.gis.geo.SynonymQuery) JobHistoryRecordQuery(com.runwaysdk.system.scheduler.JobHistoryRecordQuery) ImportErrorQuery(net.geoprism.registry.etl.ImportErrorQuery) ExecutableJob(com.runwaysdk.system.scheduler.ExecutableJob) ImportHistory(net.geoprism.registry.etl.ImportHistory) JobHistoryRecord(com.runwaysdk.system.scheduler.JobHistoryRecord) ValidationProblemQuery(net.geoprism.registry.etl.ValidationProblemQuery) Request(com.runwaysdk.session.Request)

Example 3 with ImportHistory

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

the class BusinessObjectImporterTest method mockImport.

private ImportHistory mockImport(BusinessObjectImportConfiguration config) throws Throwable {
    if (config.getDate() == null) {
        config.setDate(new Date());
    }
    config.setImportStrategy(ImportStrategy.NEW_AND_UPDATE);
    DataImportJob job = new DataImportJob();
    job.apply();
    ImportHistory hist = (ImportHistory) job.createNewHistory();
    config.setHistoryId(hist.getOid());
    config.setJobId(job.getOid());
    BusinessType type = config.getType();
    hist.appLock();
    hist.setImportFileId(config.getVaultFileId());
    hist.setConfigJson(config.toJSON().toString());
    hist.setOrganization(type.getOrganization());
    hist.setGeoObjectTypeCode(type.getCode());
    hist.apply();
    ExecutionContext context = MockScheduler.executeJob(job, hist);
    hist = (ImportHistory) context.getHistory();
    return hist;
}
Also used : ExecutionContext(com.runwaysdk.system.scheduler.ExecutionContext) DataImportJob(net.geoprism.registry.etl.DataImportJob) BusinessType(net.geoprism.registry.BusinessType) Date(java.util.Date) ImportHistory(net.geoprism.registry.etl.ImportHistory)

Example 4 with ImportHistory

use of net.geoprism.registry.etl.ImportHistory 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

ImportHistory (net.geoprism.registry.etl.ImportHistory)4 QueryFactory (com.runwaysdk.query.QueryFactory)3 Transaction (com.runwaysdk.dataaccess.transaction.Transaction)2 ImportHistoryQuery (net.geoprism.registry.etl.ImportHistoryQuery)2 ImportConfiguration (net.geoprism.registry.etl.upload.ImportConfiguration)2 GeoObjectImportConfiguration (net.geoprism.registry.io.GeoObjectImportConfiguration)2 Request (com.runwaysdk.session.Request)1 SynonymQuery (com.runwaysdk.system.gis.geo.SynonymQuery)1 ExecutableJob (com.runwaysdk.system.scheduler.ExecutableJob)1 ExecutionContext (com.runwaysdk.system.scheduler.ExecutionContext)1 JobHistory (com.runwaysdk.system.scheduler.JobHistory)1 JobHistoryRecord (com.runwaysdk.system.scheduler.JobHistoryRecord)1 JobHistoryRecordQuery (com.runwaysdk.system.scheduler.JobHistoryRecordQuery)1 Date (java.util.Date)1 BusinessType (net.geoprism.registry.BusinessType)1 Organization (net.geoprism.registry.Organization)1 DataImportJob (net.geoprism.registry.etl.DataImportJob)1 ImportErrorQuery (net.geoprism.registry.etl.ImportErrorQuery)1 ValidationProblemQuery (net.geoprism.registry.etl.ValidationProblemQuery)1 ServerGeoObjectType (net.geoprism.registry.model.ServerGeoObjectType)1