Search in sources :

Example 11 with ListTypeVersion

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

the class CurationService method page.

@Request(RequestType.SESSION)
public JsonObject page(String sessionId, String historyId, boolean onlyUnresolved, int pageSize, int pageNumber) {
    final ListCurationHistory hist = ListCurationHistory.get(historyId);
    final ListTypeVersion version = hist.getVersion();
    final ListType listType = version.getListType();
    final ServerGeoObjectType serverGOT = listType.getGeoObjectType();
    final String orgCode = listType.getOrganization().getCode();
    this.checkPermissions(orgCode, serverGOT);
    CurationProblemQuery query = new CurationProblemQuery(new QueryFactory());
    query.WHERE(query.getHistory().EQ(historyId));
    if (onlyUnresolved) {
        query.WHERE(query.getResolution().EQ(ErrorResolution.UNRESOLVED.name()));
    }
    query.ORDER_BY(query.getProblemType(), SortOrder.ASC);
    query.restrictRows(pageSize, pageNumber);
    try (OIterator<? extends CurationProblem> it = query.getIterator()) {
        List<CurationProblem> results = new LinkedList<>(it.getAll());
        return new Page<CurationProblem>(query.getCount(), query.getPageNumber(), query.getPageSize(), results).toJSON();
    }
}
Also used : QueryFactory(com.runwaysdk.query.QueryFactory) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) ListType(net.geoprism.registry.ListType) ListTypeVersion(net.geoprism.registry.ListTypeVersion) LinkedList(java.util.LinkedList) Request(com.runwaysdk.session.Request)

Example 12 with ListTypeVersion

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

the class FhirExportSynchronizationManager method generateBundle.

public Bundle generateBundle(FhirConnection connection) {
    SortedSet<FhirSyncLevel> levels = this.config.getLevels();
    int expectedLevel = 0;
    Bundle bundle = new Bundle();
    for (FhirSyncLevel level : levels) {
        if (level.getLevel() != expectedLevel) {
            throw new ProgrammingErrorException("Unexpected level number [" + level.getLevel() + "].");
        }
        ListTypeVersion version = ListTypeVersion.get(level.getVersionId());
        FhirDataPopulator populator = FhirFactory.getPopulator(level.getImplementation());
        ListTypeFhirExporter exporter = new ListTypeFhirExporter(version, connection, populator, false);
        exporter.populateBundle(bundle);
        expectedLevel++;
    }
    return bundle;
}
Also used : FhirSyncLevel(net.geoprism.registry.etl.FhirSyncLevel) Bundle(org.hl7.fhir.r4.model.Bundle) ListTypeVersion(net.geoprism.registry.ListTypeVersion) ProgrammingErrorException(com.runwaysdk.dataaccess.ProgrammingErrorException)

Example 13 with ListTypeVersion

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

the class ListTypeService method getGeospatialVersions.

@Request(RequestType.SESSION)
public JsonArray getGeospatialVersions(String sessionId, String startDate, String endDate) {
    ListTypeVersionQuery query = new ListTypeVersionQuery(new QueryFactory());
    if (startDate != null && startDate.length() > 0) {
        query.AND(query.getForDate().GE(GeoRegistryUtil.parseDate(startDate)));
    }
    if (endDate != null && endDate.length() > 0) {
        query.AND(query.getForDate().LE(GeoRegistryUtil.parseDate(endDate)));
    }
    query.ORDER_BY_DESC(query.getListType());
    query.ORDER_BY_DESC(query.getForDate());
    query.ORDER_BY_DESC(query.getVersionNumber());
    Map<String, Set<String>> orgMap = new LinkedHashMap<String, Set<String>>();
    Map<String, Set<String>> typeMap = new LinkedHashMap<String, Set<String>>();
    Map<String, JsonObject> listMap = new LinkedHashMap<String, JsonObject>();
    try (OIterator<? extends ListTypeVersion> it = query.getIterator()) {
        while (it.hasNext()) {
            ListTypeVersion version = it.next();
            ListType listType = version.getListType();
            final boolean isMember = Organization.isMember(listType.getOrganization());
            if ((version.getWorking() && listType.doesActorHaveExploratoryPermission()) || (isMember || version.getGeospatialVisibility().equals(ListType.PUBLIC))) {
                if (!listMap.containsKey(listType.getOid())) {
                    JsonObject object = new JsonObject();
                    object.addProperty("label", listType.getDisplayLabel().getValue());
                    object.addProperty("oid", listType.getOid());
                    object.add("versions", new JsonArray());
                    listMap.put(listType.getOid(), object);
                    String gotCode = listType.getGeoObjectType().getCode();
                    if (!typeMap.containsKey(gotCode)) {
                        typeMap.put(gotCode, new HashSet<String>());
                    }
                    typeMap.get(gotCode).add(listType.getOid());
                    String orgCode = listType.getOrganization().getCode();
                    if (!orgMap.containsKey(orgCode)) {
                        orgMap.put(orgCode, new HashSet<String>());
                    }
                    orgMap.get(orgCode).add(gotCode);
                }
                JsonObject object = new JsonObject();
                object.addProperty("oid", version.getOid());
                object.addProperty("forDate", GeoRegistryUtil.formatDate(version.getForDate(), false));
                object.addProperty("versionNumber", version.getVersionNumber());
                listMap.get(listType.getOid()).get("versions").getAsJsonArray().add(object);
            }
        }
    }
    JsonArray jaOrgs = new JsonArray();
    for (String orgCode : orgMap.keySet()) {
        Organization org = ServiceFactory.getMetadataCache().getOrganization(orgCode).get();
        JsonObject joOrg = new JsonObject();
        joOrg.addProperty("orgCode", orgCode);
        joOrg.add("orgLabel", LocalizedValueConverter.convertNoAutoCoalesce(org.getDisplayLabel()).toJSON());
        JsonArray jaTypes = new JsonArray();
        for (String gotCode : orgMap.get(orgCode)) {
            ServerGeoObjectType type = ServiceFactory.getMetadataCache().getGeoObjectType(gotCode).get();
            JsonObject joType = new JsonObject();
            joType.addProperty("typeCode", gotCode);
            joType.add("typeLabel", type.getLabel().toJSON());
            JsonArray jaLists = new JsonArray();
            for (String listOid : typeMap.get(gotCode)) {
                JsonObject joListType = listMap.get(listOid);
                JsonArray jaVersions = joListType.get("versions").getAsJsonArray();
                if (jaVersions.size() > 0) {
                    jaLists.add(joListType);
                }
            }
            joType.add("lists", jaLists);
            if (jaLists.size() > 0) {
                jaTypes.add(joType);
            }
        }
        joOrg.add("types", jaTypes);
        if (jaTypes.size() > 0) {
            jaOrgs.add(joOrg);
        }
    }
    return jaOrgs;
}
Also used : QueryFactory(com.runwaysdk.query.QueryFactory) Set(java.util.Set) HashSet(java.util.HashSet) Organization(net.geoprism.registry.Organization) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) JsonObject(com.google.gson.JsonObject) ListTypeVersion(net.geoprism.registry.ListTypeVersion) ListTypeVersionQuery(net.geoprism.registry.ListTypeVersionQuery) LinkedHashMap(java.util.LinkedHashMap) JsonArray(com.google.gson.JsonArray) ListType(net.geoprism.registry.ListType) Request(com.runwaysdk.session.Request)

Example 14 with ListTypeVersion

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

the class ListTypeService method publishVersion.

@Request(RequestType.SESSION)
public JsonObject publishVersion(String sessionId, String oid) {
    ListTypeVersion version = ListTypeVersion.get(oid);
    // Only a working version can be republished.
    if (!version.getWorking()) {
        throw new UnsupportedOperationException();
    }
    this.enforceReadPermissions(version.getListType());
    QueryFactory factory = new QueryFactory();
    PublishListTypeVersionJobQuery query = new PublishListTypeVersionJobQuery(factory);
    query.WHERE(query.getVersion().EQ(version));
    JobHistoryQuery q = new JobHistoryQuery(factory);
    q.WHERE(q.getStatus().containsAny(AllJobStatus.NEW, AllJobStatus.QUEUED, AllJobStatus.RUNNING));
    q.AND(q.job(query));
    if (q.getCount() > 0) {
        throw new DuplicateJobException("This version has already been queued for publishing");
    }
    PublishListTypeVersionJob job = new PublishListTypeVersionJob();
    job.setRunAsUserId(Session.getCurrentSession().getUser().getOid());
    job.setVersion(version);
    job.setListType(version.getListType());
    job.apply();
    NotificationFacade.queue(new GlobalNotificationMessage(MessageType.PUBLISH_JOB_CHANGE, null));
    final JobHistory history = job.start();
    JsonObject resp = new JsonObject();
    resp.addProperty("jobOid", history.getOid());
    return resp;
}
Also used : PublishListTypeVersionJob(net.geoprism.registry.etl.PublishListTypeVersionJob) QueryFactory(com.runwaysdk.query.QueryFactory) JobHistoryQuery(com.runwaysdk.system.scheduler.JobHistoryQuery) DuplicateJobException(net.geoprism.registry.etl.DuplicateJobException) JobHistory(com.runwaysdk.system.scheduler.JobHistory) PublishListTypeVersionJobQuery(net.geoprism.registry.etl.PublishListTypeVersionJobQuery) JsonObject(com.google.gson.JsonObject) ListTypeVersion(net.geoprism.registry.ListTypeVersion) GlobalNotificationMessage(net.geoprism.registry.ws.GlobalNotificationMessage) Request(com.runwaysdk.session.Request)

Example 15 with ListTypeVersion

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

the class ListTypeService method getPublicVersions.

@Request(RequestType.SESSION)
public JsonArray getPublicVersions(String sessionId, String listOid) {
    JsonArray response = new JsonArray();
    ListType listType = ListType.get(listOid);
    final boolean isMember = Organization.isMember(listType.getOrganization());
    ListTypeVersionQuery query = new ListTypeVersionQuery(new QueryFactory());
    query.WHERE(query.getListType().EQ(listType));
    query.AND(query.getWorking().EQ(false));
    query.ORDER_BY_DESC(query.getListType());
    query.ORDER_BY_DESC(query.getForDate());
    query.ORDER_BY_DESC(query.getVersionNumber());
    try (OIterator<? extends ListTypeVersion> it = query.getIterator()) {
        while (it.hasNext()) {
            ListTypeVersion list = it.next();
            if (isMember || list.getListVisibility().equals(ListType.PUBLIC)) {
                response.add(list.toJSON(false));
            }
        }
    }
    return response;
}
Also used : JsonArray(com.google.gson.JsonArray) QueryFactory(com.runwaysdk.query.QueryFactory) ListType(net.geoprism.registry.ListType) ListTypeVersion(net.geoprism.registry.ListTypeVersion) ListTypeVersionQuery(net.geoprism.registry.ListTypeVersionQuery) Request(com.runwaysdk.session.Request)

Aggregations

ListTypeVersion (net.geoprism.registry.ListTypeVersion)20 Request (com.runwaysdk.session.Request)15 ListType (net.geoprism.registry.ListType)11 JsonObject (com.google.gson.JsonObject)9 ServerGeoObjectType (net.geoprism.registry.model.ServerGeoObjectType)5 QueryFactory (com.runwaysdk.query.QueryFactory)4 MdBusinessDAOIF (com.runwaysdk.dataaccess.MdBusinessDAOIF)3 ListTypeEntry (net.geoprism.registry.ListTypeEntry)3 SingleListType (net.geoprism.registry.SingleListType)3 JsonArray (com.google.gson.JsonArray)2 ProgrammingErrorException (com.runwaysdk.dataaccess.ProgrammingErrorException)2 Session (com.runwaysdk.session.Session)2 IncrementalListType (net.geoprism.registry.IncrementalListType)2 IntervalListType (net.geoprism.registry.IntervalListType)2 InvalidMasterListException (net.geoprism.registry.InvalidMasterListException)2 ListTypeVersionQuery (net.geoprism.registry.ListTypeVersionQuery)2 FhirSyncLevel (net.geoprism.registry.etl.FhirSyncLevel)2 ServerGeoObjectService (net.geoprism.registry.geoobject.ServerGeoObjectService)2 JsonSerializable (net.geoprism.registry.view.JsonSerializable)2 GlobalNotificationMessage (net.geoprism.registry.ws.GlobalNotificationMessage)2