Search in sources :

Example 1 with MasterList

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

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

the class PublishMasterListJob method toJson.

public JsonObject toJson() {
    SimpleDateFormat format = new SimpleDateFormat(GeoObjectImportConfiguration.DATE_FORMAT);
    format.setTimeZone(GeoRegistryUtil.SYSTEM_TIMEZONE);
    final MasterList masterlist = this.getMasterList();
    final ServerGeoObjectType type = masterlist.getGeoObjectType();
    List<? extends JobHistory> allHist = this.getAllJobHistory().getAll();
    final GeoprismUser user = GeoprismUser.get(this.getRunAsUser().getOid());
    try {
        final JsonObject object = new JsonObject();
        object.addProperty(PublishMasterListJob.OID, this.getOid());
        object.addProperty(PublishMasterListJob.MASTERLIST, this.getMasterListOid());
        object.addProperty(PublishMasterListJob.TYPE, type.getLabel().getValue());
        if (allHist.size() > 0) {
            final JobHistory history = allHist.get(0);
            object.addProperty(JobHistory.STATUS, history.getStatus().get(0).getDisplayLabel());
            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.getStatus().get(0).equals(AllJobStatus.FAILURE) && history.getErrorJson().length() > 0) {
                String errorJson = history.getErrorJson();
                JsonObject error = JsonParser.parseString(errorJson).getAsJsonObject();
                JsonObject exception = new JsonObject();
                exception.addProperty("type", error.get("type").getAsString());
                exception.addProperty("message", history.getLocalizedError(Session.getCurrentLocale()));
                object.add("exception", exception);
            }
        }
        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) GeoprismUser(net.geoprism.GeoprismUser) SimpleDateFormat(java.text.SimpleDateFormat) ProgrammingErrorException(com.runwaysdk.dataaccess.ProgrammingErrorException)

Example 3 with MasterList

use of net.geoprism.registry.MasterList 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 4 with MasterList

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

the class LocalizeListMetadataFieldsPatch method migrateExistingLists.

private void migrateExistingLists() {
    MasterListQuery mlq = new MasterListQuery(new QueryFactory());
    logger.info("Migrating metadata for " + mlq.getCount() + " existing lists.");
    try (OIterator<? extends MasterList> it = mlq.getIterator()) {
        while (it.hasNext()) {
            MasterList list = it.next();
            BusinessDAO listDAO = (BusinessDAO) BusinessFacade.getEntityDAO(list);
            list.getDescriptionLocal().setDefaultValue(listDAO.getValue(LISTABSTRACT));
            list.getProcessLocal().setDefaultValue(listDAO.getValue(PROCESS));
            list.getProgressLocal().setDefaultValue(listDAO.getValue(PROGRESS));
            list.getAccessConstraintsLocal().setDefaultValue(listDAO.getValue(ACCESSCONSTRAINTS));
            list.getUseConstraintsLocal().setDefaultValue(listDAO.getValue(USECONSTRAINTS));
            list.getAcknowledgementsLocal().setDefaultValue(listDAO.getValue(ACKNOWLEDGEMENTS));
            list.getDisclaimerLocal().setDefaultValue(listDAO.getValue(DISCLAIMER));
            list.apply();
        }
    }
}
Also used : MasterListQuery(net.geoprism.registry.MasterListQuery) QueryFactory(com.runwaysdk.query.QueryFactory) BusinessDAO(com.runwaysdk.dataaccess.BusinessDAO) MasterList(net.geoprism.registry.MasterList)

Aggregations

MasterList (net.geoprism.registry.MasterList)4 JsonObject (com.google.gson.JsonObject)3 ProgrammingErrorException (com.runwaysdk.dataaccess.ProgrammingErrorException)3 JobHistory (com.runwaysdk.system.scheduler.JobHistory)3 SimpleDateFormat (java.text.SimpleDateFormat)3 GeoprismUser (net.geoprism.GeoprismUser)3 ServerGeoObjectType (net.geoprism.registry.model.ServerGeoObjectType)3 JSONException (org.json.JSONException)3 MasterListVersion (net.geoprism.registry.MasterListVersion)2 BusinessDAO (com.runwaysdk.dataaccess.BusinessDAO)1 QueryFactory (com.runwaysdk.query.QueryFactory)1 MasterListQuery (net.geoprism.registry.MasterListQuery)1