Search in sources :

Example 6 with JobHistoryRecord

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

the class DataImportJob method startInTrans.

@Transaction
private JobHistoryRecord startInTrans(ImportConfiguration configuration) {
    configuration.enforceCreatePermissions();
    ImportHistory history = (ImportHistory) this.createNewHistory();
    configuration.setHistoryId(history.getOid());
    configuration.setJobId(this.getOid());
    history.appLock();
    history.setConfigJson(configuration.toJSON().toString());
    history.setImportFileId(configuration.getVaultFileId());
    configuration.populate(history);
    history.apply();
    JobHistoryRecord record = new JobHistoryRecord(this, history);
    record.apply();
    return record;
}
Also used : JobHistoryRecord(com.runwaysdk.system.scheduler.JobHistoryRecord) Transaction(com.runwaysdk.dataaccess.transaction.Transaction)

Example 7 with JobHistoryRecord

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

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

the class DataExportJob method executableJobStart.

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

Example 9 with JobHistoryRecord

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

the class DataExportJob method startInTrans.

@Transaction
private JobHistoryRecord startInTrans(SynchronizationConfig configuration) {
    ExportHistory history = (ExportHistory) this.createNewHistory();
    JobHistoryRecord record = new JobHistoryRecord(this, history);
    record.apply();
    return record;
}
Also used : JobHistoryRecord(com.runwaysdk.system.scheduler.JobHistoryRecord) Transaction(com.runwaysdk.dataaccess.transaction.Transaction)

Example 10 with JobHistoryRecord

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

the class PatchExistsAndInvalid method patchMasterlistVersions.

private void patchMasterlistVersions() {
    final Collection<Locale> locales = LocalizationFacade.getInstalledLocales();
    MasterListVersionQuery query = new MasterListVersionQuery(new QueryFactory());
    try (OIterator<? extends MasterListVersion> it = query.getIterator()) {
        for (MasterListVersion version : it) {
            // ServerGeoObjectType type = version.getMasterlist().getGeoObjectType();
            // We are accessing it in this weird way because MasterList was changed to have new localized attributes. If we run this patch
            // before masterlist is patched then simply instantiating a MasterList object will throw an error when it tries to load the structs.
            BusinessDAO versionDAO = (BusinessDAO) BusinessDAO.get(version.getOid());
            String masterListOid = versionDAO.getValue(MasterListVersion.MASTERLIST);
            BusinessDAO masterListDAO = (BusinessDAO) BusinessDAO.get(masterListOid);
            String universalOid = masterListDAO.getValue(MasterList.UNIVERSAL);
            ServerGeoObjectType type = ServerGeoObjectType.get(Universal.get(universalOid));
            // Patch metadata
            // AttributeType existsAttr = type.getAttribute(DefaultAttribute.EXISTS.getName()).get();
            // MasterListVersion.createMdAttributeFromAttributeType(version, type, existsAttr, locales);
            AttributeType invalidAttr = type.getAttribute(DefaultAttribute.INVALID.getName()).get();
            MasterListVersion.createMdAttributeFromAttributeType(version, type, invalidAttr, locales);
            // Instance data is too hard to patch. We're just going to republish all the lists
            logger.info("Master list version [" + version.getKey() + "] has been queued for republishing.");
            PublishMasterListVersionJob job = new PublishMasterListVersionJob();
            job.setMasterListVersion(version);
            job.setMasterListId(masterListOid);
            job.apply();
            // job.start();
            // JobHistory history = job.createNewHistory();
            JobHistory history = new JobHistory();
            history.setStartTime(new Date());
            history.addStatus(AllJobStatus.QUEUED);
            history.apply();
            JobHistoryRecord record = new JobHistoryRecord(job, history);
            record.apply();
        }
    }
}
Also used : Locale(java.util.Locale) QueryFactory(com.runwaysdk.query.QueryFactory) BusinessDAO(com.runwaysdk.dataaccess.BusinessDAO) MdBusinessDAO(com.runwaysdk.dataaccess.metadata.MdBusinessDAO) JobHistory(com.runwaysdk.system.scheduler.JobHistory) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) MasterListVersion(net.geoprism.registry.MasterListVersion) PublishMasterListVersionJob(net.geoprism.registry.etl.PublishMasterListVersionJob) Date(java.util.Date) MasterListVersionQuery(net.geoprism.registry.MasterListVersionQuery) AttributeType(org.commongeoregistry.adapter.metadata.AttributeType) 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