Search in sources :

Example 1 with ExecutableJob

use of com.runwaysdk.system.scheduler.ExecutableJob in project geoprism-registry by terraframe.

the class MasterListVersion method getJobs.

public List<ExecutableJob> getJobs() {
    LinkedList<ExecutableJob> jobs = new LinkedList<ExecutableJob>();
    PublishShapefileJobQuery psjq = new PublishShapefileJobQuery(new QueryFactory());
    psjq.WHERE(psjq.getVersion().EQ(this));
    try (OIterator<? extends PublishShapefileJob> it = psjq.getIterator()) {
        jobs.addAll(it.getAll());
    }
    PublishMasterListVersionJobQuery pmlvj = new PublishMasterListVersionJobQuery(new QueryFactory());
    pmlvj.WHERE(pmlvj.getMasterListVersion().EQ(this));
    try (OIterator<? extends PublishMasterListVersionJob> it = pmlvj.getIterator()) {
        jobs.addAll(it.getAll());
    }
    return jobs;
}
Also used : QueryFactory(com.runwaysdk.query.QueryFactory) PublishMasterListVersionJobQuery(net.geoprism.registry.etl.PublishMasterListVersionJobQuery) ExecutableJob(com.runwaysdk.system.scheduler.ExecutableJob) PublishShapefileJobQuery(net.geoprism.registry.etl.PublishShapefileJobQuery) LinkedList(java.util.LinkedList)

Example 2 with ExecutableJob

use of com.runwaysdk.system.scheduler.ExecutableJob 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 ExecutableJob

use of com.runwaysdk.system.scheduler.ExecutableJob in project geoprism-registry by terraframe.

the class MasterListVersion method delete.

@Override
@Transaction
public void delete() {
    // Delete all jobs
    List<ExecutableJob> jobs = this.getJobs();
    for (ExecutableJob job : jobs) {
        job.delete();
    }
    // Delete tile cache
    TileCache.deleteTiles(this);
    MasterListAttributeGroup.deleteAll(this);
    MdBusiness mdTable = this.getMdBusiness();
    super.delete();
    if (mdTable != null) {
        MdBusinessDAO mdBusiness = MdBusinessDAO.get(this.getMdBusinessOid()).getBusinessDAO();
        mdBusiness.deleteAllRecords();
        mdTable.delete();
    }
    if (this.getVersionType().equals(MasterListVersion.PUBLISHED)) {
    // new GeoserverRemoveWMSCommand(this).doIt();
    }
}
Also used : MdBusinessDAO(com.runwaysdk.dataaccess.metadata.MdBusinessDAO) MdBusiness(com.runwaysdk.system.metadata.MdBusiness) ExecutableJob(com.runwaysdk.system.scheduler.ExecutableJob) Transaction(com.runwaysdk.dataaccess.transaction.Transaction)

Example 4 with ExecutableJob

use of com.runwaysdk.system.scheduler.ExecutableJob 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)

Aggregations

ExecutableJob (com.runwaysdk.system.scheduler.ExecutableJob)4 QueryFactory (com.runwaysdk.query.QueryFactory)2 Request (com.runwaysdk.session.Request)2 JobHistoryRecord (com.runwaysdk.system.scheduler.JobHistoryRecord)2 MdBusinessDAO (com.runwaysdk.dataaccess.metadata.MdBusinessDAO)1 Transaction (com.runwaysdk.dataaccess.transaction.Transaction)1 SynonymQuery (com.runwaysdk.system.gis.geo.SynonymQuery)1 MdBusiness (com.runwaysdk.system.metadata.MdBusiness)1 JobHistory (com.runwaysdk.system.scheduler.JobHistory)1 JobHistoryRecordQuery (com.runwaysdk.system.scheduler.JobHistoryRecordQuery)1 LinkedList (java.util.LinkedList)1 ImportErrorQuery (net.geoprism.registry.etl.ImportErrorQuery)1 ImportHistory (net.geoprism.registry.etl.ImportHistory)1 PublishMasterListVersionJobQuery (net.geoprism.registry.etl.PublishMasterListVersionJobQuery)1 PublishShapefileJobQuery (net.geoprism.registry.etl.PublishShapefileJobQuery)1 ValidationProblemQuery (net.geoprism.registry.etl.ValidationProblemQuery)1 ImportConfiguration (net.geoprism.registry.etl.upload.ImportConfiguration)1 GeoObjectImportConfiguration (net.geoprism.registry.io.GeoObjectImportConfiguration)1