Search in sources :

Example 1 with JobHistoryRecord

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

the class ListCurationJob method startInTrans.

@Transaction
private JobHistoryRecord startInTrans(ListTypeVersion version) {
    final ListType listType = version.getListType();
    final ServerGeoObjectType type = listType.getGeoObjectType();
    final Organization org = listType.getOrganization();
    RolePermissionService perms = ServiceFactory.getRolePermissionService();
    if (perms.isRA()) {
        perms.enforceRA(org.getCode());
    } else if (perms.isRM()) {
        perms.enforceRM(org.getCode(), type);
    } else {
        perms.enforceRM();
    }
    ListCurationHistory history = (ListCurationHistory) this.createNewHistory();
    history.appLock();
    history.setVersion(version);
    history.apply();
    JobHistoryRecord record = new JobHistoryRecord(this, history);
    record.apply();
    return record;
}
Also used : RolePermissionService(net.geoprism.registry.permission.RolePermissionService) Organization(net.geoprism.registry.Organization) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) JobHistoryRecord(com.runwaysdk.system.scheduler.JobHistoryRecord) ListType(net.geoprism.registry.ListType) Transaction(com.runwaysdk.dataaccess.transaction.Transaction)

Example 2 with JobHistoryRecord

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

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

the class CurationTest method createTestInstanceData.

@Request
private void createTestInstanceData() {
    list = new SingleListType();
    list.setUniversal(FastTestDataset.PROVINCE.getUniversal());
    list.getDisplayLabel().setValue("Test List");
    list.setCode("TEST_CODE");
    list.setOrganization(FastTestDataset.ORG_CGOV.getServerObject());
    list.getDescription().setValue("My Overal Description");
    list.setValidOn(TestDataSet.DEFAULT_OVER_TIME_DATE);
    list.getListDescription().setValue("My Abstract");
    list.getListProcess().setValue("Process");
    list.getListProgress().setValue("Progress");
    list.getListAccessConstraints().setValue("Access Contraints");
    list.getListUseConstraints().setValue("User Constraints");
    list.getListAcknowledgements().setValue("Acknowledgements");
    list.getListDisclaimer().setValue("Disclaimer");
    list.setListContactName("Contact Name");
    list.setListTelephoneNumber("Telephone Number");
    list.setListEmail("Email");
    list.apply();
    entry = ListTypeEntry.create(list, TestDataSet.DEFAULT_OVER_TIME_DATE, null);
    entry.createVersion(ListTypeTest.createVersionMetadata()).publishNoAuth();
    List<ListTypeVersion> versions = entry.getVersions();
    Assert.assertEquals(2, versions.size());
    version = versions.get(0);
    job = new ListCurationJob();
    job.setRunAsUser(TestDataSet.USER_ADMIN.getGeoprismUser());
    job.apply();
    history = (ListCurationHistory) job.createNewHistory();
    history.appLock();
    history.clearStatus();
    history.addStatus(AllJobStatus.RUNNING);
    history.setVersion(version);
    history.apply();
    historyId = history.getOid();
    jobHistoryRecord = new JobHistoryRecord(job, history);
    jobHistoryRecord.apply();
    curationProblem = new GeoObjectProblem();
    curationProblem.setHistory(history);
    curationProblem.setResolution(CurationResolution.UNRESOLVED.name());
    curationProblem.setProblemType(GeoObjectProblemType.NO_GEOMETRY.name());
    curationProblem.setTypeCode(FastTestDataset.PROVINCE.getCode());
    curationProblem.setGoCode(FastTestDataset.PROV_CENTRAL.getCode());
    curationProblem.apply();
    curationProblemId = curationProblem.getOid();
}
Also used : JobHistoryRecord(com.runwaysdk.system.scheduler.JobHistoryRecord) SingleListType(net.geoprism.registry.SingleListType) ListTypeVersion(net.geoprism.registry.ListTypeVersion) Request(com.runwaysdk.session.Request)

Example 4 with JobHistoryRecord

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

the class ListCurationJob method executableJobStart.

private ListCurationHistory executableJobStart(ListTypeVersion version) {
    JobHistoryRecord record = startInTrans(version);
    this.getQuartzJob().start(record);
    return (ListCurationHistory) record.getChild();
}
Also used : JobHistoryRecord(com.runwaysdk.system.scheduler.JobHistoryRecord)

Example 5 with JobHistoryRecord

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

the class DataImportJob method executableJobStart.

private ImportHistory executableJobStart(ImportConfiguration configuration) {
    JobHistoryRecord record = startInTrans(configuration);
    this.getQuartzJob().start(record);
    return (ImportHistory) record.getChild();
}
Also used : JobHistoryRecord(com.runwaysdk.system.scheduler.JobHistoryRecord)

Aggregations

JobHistoryRecord (com.runwaysdk.system.scheduler.JobHistoryRecord)10 Transaction (com.runwaysdk.dataaccess.transaction.Transaction)3 Request (com.runwaysdk.session.Request)3 QueryFactory (com.runwaysdk.query.QueryFactory)2 ExecutableJob (com.runwaysdk.system.scheduler.ExecutableJob)2 JobHistory (com.runwaysdk.system.scheduler.JobHistory)2 ServerGeoObjectType (net.geoprism.registry.model.ServerGeoObjectType)2 BusinessDAO (com.runwaysdk.dataaccess.BusinessDAO)1 MdBusinessDAO (com.runwaysdk.dataaccess.metadata.MdBusinessDAO)1 SynonymQuery (com.runwaysdk.system.gis.geo.SynonymQuery)1 JobHistoryRecordQuery (com.runwaysdk.system.scheduler.JobHistoryRecordQuery)1 Date (java.util.Date)1 Locale (java.util.Locale)1 ListType (net.geoprism.registry.ListType)1 ListTypeVersion (net.geoprism.registry.ListTypeVersion)1 MasterListVersion (net.geoprism.registry.MasterListVersion)1 MasterListVersionQuery (net.geoprism.registry.MasterListVersionQuery)1 Organization (net.geoprism.registry.Organization)1 SingleListType (net.geoprism.registry.SingleListType)1 ImportErrorQuery (net.geoprism.registry.etl.ImportErrorQuery)1