Search in sources :

Example 1 with MasterListVersion

use of net.geoprism.registry.MasterListVersion in project geoprism-registry by terraframe.

the class FhirExportJob method toJson.

public JsonObject toJson() {
    SimpleDateFormat format = new SimpleDateFormat(GeoObjectImportConfiguration.DATE_FORMAT);
    format.setTimeZone(GeoRegistryUtil.SYSTEM_TIMEZONE);
    final MasterListVersion version = this.getVersion();
    final MasterList masterlist = version.getMasterlist();
    final ServerGeoObjectType type = masterlist.getGeoObjectType();
    final JobHistory history = this.getAllJobHistory().getAll().get(0);
    final GeoprismUser user = GeoprismUser.get(this.getRunAsUser().getOid());
    try {
        final JsonObject object = new JsonObject();
        object.addProperty(FhirExportJob.OID, this.getOid());
        object.add(FhirExportJob.VERSION, this.getVersion().toJSON(false));
        object.addProperty(FhirExportJob.IMPLEMENTATION, this.getImplementation());
        object.addProperty(FhirExportJob.TYPE, type.getLabel().getValue());
        object.addProperty(JobHistory.STATUS, history.getStatus().get(0).getDisplayLabel());
        object.addProperty("date", format.format(version.getPublishDate()));
        object.addProperty("author", user.getUsername());
        object.addProperty("createDate", format.format(history.getCreateDate()));
        object.addProperty("lastUpdateDate", format.format(history.getLastUpdateDate()));
        object.addProperty("workProgress", history.getWorkProgress());
        object.addProperty("workTotal", history.getWorkTotal());
        object.addProperty("historyoryId", history.getOid());
        if (history.getErrorJson() != null && history.getErrorJson().length() > 0) {
            object.addProperty("message", history.getLocalizedError(Session.getCurrentLocale()));
        }
        return object;
    } catch (JSONException e) {
        throw new ProgrammingErrorException(e);
    }
}
Also used : MasterList(net.geoprism.registry.MasterList) JobHistory(com.runwaysdk.system.scheduler.JobHistory) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) JsonObject(com.google.gson.JsonObject) JSONException(org.json.JSONException) MasterListVersion(net.geoprism.registry.MasterListVersion) GeoprismUser(net.geoprism.GeoprismUser) SimpleDateFormat(java.text.SimpleDateFormat) ProgrammingErrorException(com.runwaysdk.dataaccess.ProgrammingErrorException)

Example 2 with MasterListVersion

use of net.geoprism.registry.MasterListVersion in project geoprism-registry by terraframe.

the class PublishShapefileJob method toJson.

public JsonObject toJson() {
    SimpleDateFormat format = new SimpleDateFormat(GeoObjectImportConfiguration.DATE_FORMAT);
    format.setTimeZone(GeoRegistryUtil.SYSTEM_TIMEZONE);
    final MasterListVersion version = this.getVersion();
    final MasterList masterlist = version.getMasterlist();
    final ServerGeoObjectType type = masterlist.getGeoObjectType();
    final JobHistory history = this.getAllJobHistory().getAll().get(0);
    final GeoprismUser user = GeoprismUser.get(this.getRunAsUser().getOid());
    try {
        final JsonObject object = new JsonObject();
        object.addProperty(PublishShapefileJob.OID, this.getOid());
        object.add(PublishShapefileJob.VERSION, this.getVersion().toJSON(false));
        object.addProperty(PublishShapefileJob.TYPE, type.getLabel().getValue());
        object.addProperty(JobHistory.STATUS, history.getStatus().get(0).getDisplayLabel());
        object.addProperty("date", format.format(version.getPublishDate()));
        object.addProperty("author", user.getUsername());
        object.addProperty("createDate", format.format(history.getCreateDate()));
        object.addProperty("lastUpdateDate", format.format(history.getLastUpdateDate()));
        object.addProperty("workProgress", history.getWorkProgress());
        object.addProperty("workTotal", history.getWorkTotal());
        object.addProperty("historyoryId", history.getOid());
        return object;
    } catch (JSONException e) {
        throw new ProgrammingErrorException(e);
    }
}
Also used : MasterList(net.geoprism.registry.MasterList) JobHistory(com.runwaysdk.system.scheduler.JobHistory) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) JsonObject(com.google.gson.JsonObject) JSONException(org.json.JSONException) MasterListVersion(net.geoprism.registry.MasterListVersion) GeoprismUser(net.geoprism.GeoprismUser) SimpleDateFormat(java.text.SimpleDateFormat) ProgrammingErrorException(com.runwaysdk.dataaccess.ProgrammingErrorException)

Example 3 with MasterListVersion

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

JobHistory (com.runwaysdk.system.scheduler.JobHistory)3 MasterListVersion (net.geoprism.registry.MasterListVersion)3 ServerGeoObjectType (net.geoprism.registry.model.ServerGeoObjectType)3 JsonObject (com.google.gson.JsonObject)2 ProgrammingErrorException (com.runwaysdk.dataaccess.ProgrammingErrorException)2 SimpleDateFormat (java.text.SimpleDateFormat)2 GeoprismUser (net.geoprism.GeoprismUser)2 MasterList (net.geoprism.registry.MasterList)2 JSONException (org.json.JSONException)2 BusinessDAO (com.runwaysdk.dataaccess.BusinessDAO)1 MdBusinessDAO (com.runwaysdk.dataaccess.metadata.MdBusinessDAO)1 QueryFactory (com.runwaysdk.query.QueryFactory)1 JobHistoryRecord (com.runwaysdk.system.scheduler.JobHistoryRecord)1 Date (java.util.Date)1 Locale (java.util.Locale)1 MasterListVersionQuery (net.geoprism.registry.MasterListVersionQuery)1 PublishMasterListVersionJob (net.geoprism.registry.etl.PublishMasterListVersionJob)1 AttributeType (org.commongeoregistry.adapter.metadata.AttributeType)1