Search in sources :

Example 11 with ListType

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

the class ListTypeTest method testCreateMultipleNonMaster.

// @Test
// @Request
// public void testCreateMultiple()
// {
// JsonObject json = getJson(USATestData.ORG_NPS.getServerObject(),
// USATestData.HIER_ADMIN, USATestData.STATE, ListType.PUBLIC, true);
// 
// ListType test1 = ListType.apply(json);
// 
// try
// {
// json.addProperty(ListType.CODE, "CODE_2");
// 
// ListType test2 = ListType.apply(json);
// test2.delete();
// 
// Assert.fail("Able to apply multiple masterlists with the same universal");
// }
// catch (DuplicateListTypeException e)
// {
// test1.delete();
// }
// }
// 
@Test
@Request
public void testCreateMultipleNonMaster() {
    JsonObject json = getJson(USATestData.ORG_NPS.getServerObject(), USATestData.HIER_ADMIN, USATestData.STATE);
    ListType test1 = ListType.apply(json);
    try {
        json.addProperty(ListType.CODE, "CODE_2");
        ListType test2 = ListType.apply(json);
        test2.delete();
    } catch (DuplicateDataDatabaseException e) {
        test1.delete();
        Assert.fail("Not able to apply multiple masterlists with the same universal when list is not a master");
    }
}
Also used : SingleListType(net.geoprism.registry.SingleListType) IntervalListType(net.geoprism.registry.IntervalListType) ListType(net.geoprism.registry.ListType) IncrementalListType(net.geoprism.registry.IncrementalListType) JsonObject(com.google.gson.JsonObject) DuplicateDataDatabaseException(com.runwaysdk.dataaccess.database.DuplicateDataDatabaseException) ClassificationTypeTest(net.geoprism.registry.classification.ClassificationTypeTest) Test(org.junit.Test) Request(com.runwaysdk.session.Request)

Example 12 with ListType

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

the class GeoObjectTypeMetadata method isReferencedInPublicListTypes.

private boolean isReferencedInPublicListTypes() {
    Universal uni = this.getUniversal();
    ServerGeoObjectType type = this.getServerType();
    QueryFactory qf = new QueryFactory();
    ListTypeVersionQuery versionQuery = new ListTypeVersionQuery(qf);
    versionQuery.WHERE(versionQuery.getListVisibility().EQ(ListType.PUBLIC));
    versionQuery.OR(versionQuery.getGeospatialVisibility().EQ(ListType.PUBLIC));
    ListTypeQuery mlq = new ListTypeQuery(qf);
    mlq.WHERE(mlq.EQ(versionQuery.getListType()));
    OIterator<? extends ListType> it = mlq.getIterator();
    while (it.hasNext()) {
        ListType list = it.next();
        if (list.getUniversal().getOid().equals(uni.getOid())) {
            PrivateTypeIsReferencedInPublicMasterLists ex = new PrivateTypeIsReferencedInPublicMasterLists();
            ex.setTypeLabel(this.getServerType().getLabel().getValue());
            throw ex;
        } else {
            JsonArray hierarchies = list.getHierarchiesAsJson();
            for (int i = 0; i < hierarchies.size(); i++) {
                JsonObject hierarchy = hierarchies.get(i).getAsJsonObject();
                JsonArray parents = hierarchy.get("parents").getAsJsonArray();
                for (int j = 0; j < parents.size(); ++j) {
                    JsonObject parent = parents.get(j).getAsJsonObject();
                    if (parent.has("selected") && parent.get("selected").getAsBoolean()) {
                        if (parent.has("code") && parent.get("code").getAsString().equals(type.getCode())) {
                            return true;
                        }
                    }
                }
            }
        }
    }
    return false;
}
Also used : JsonArray(com.google.gson.JsonArray) Universal(com.runwaysdk.system.gis.geo.Universal) QueryFactory(com.runwaysdk.query.QueryFactory) PrivateTypeIsReferencedInPublicMasterLists(net.geoprism.registry.geoobjecttype.PrivateTypeIsReferencedInPublicMasterLists) ListType(net.geoprism.registry.ListType) ListTypeQuery(net.geoprism.registry.ListTypeQuery) JsonObject(com.google.gson.JsonObject) ListTypeVersionQuery(net.geoprism.registry.ListTypeVersionQuery)

Example 13 with ListType

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

the class CurationService method details.

@Request(RequestType.SESSION)
public JsonObject details(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 ListCurationJob job = (ListCurationJob) hist.getAllJob().getAll().get(0);
    final GeoprismUser user = GeoprismUser.get(job.getRunAsUser().getOid());
    final ServerGeoObjectType serverGOT = listType.getGeoObjectType();
    final String orgCode = listType.getOrganization().getCode();
    this.checkPermissions(orgCode, serverGOT);
    JsonObject jo = this.serializeHistory(hist, user, job);
    jo.add("page", this.page(sessionId, historyId, onlyUnresolved, pageSize, pageNumber));
    return jo;
}
Also used : ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) ListType(net.geoprism.registry.ListType) JsonObject(com.google.gson.JsonObject) GeoprismUser(net.geoprism.GeoprismUser) ListTypeVersion(net.geoprism.registry.ListTypeVersion) Request(com.runwaysdk.session.Request)

Example 14 with ListType

use of net.geoprism.registry.ListType 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 15 with ListType

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

the class CurationService method getListCurationInfo.

public JsonObject getListCurationInfo(ListTypeVersion version) {
    final ListType listType = version.getListType();
    final ServerGeoObjectType serverGOT = listType.getGeoObjectType();
    final String orgCode = listType.getOrganization().getCode();
    this.checkPermissions(orgCode, serverGOT);
    JsonObject json = new JsonObject();
    ListCurationHistory history = ListCurationJob.getMostRecent(version.getOid());
    boolean isRunning = false;
    if (history != null) {
        if (history.getStatus().contains(AllJobStatus.RUNNING)) {
            isRunning = true;
        }
        json.addProperty("lastRun", GeoRegistryUtil.formatDate(history.getCreateDate(), false));
        json.addProperty("curationId", history.getOid());
    }
    final RolePermissionService perms = ServiceFactory.getRolePermissionService();
    boolean hasRunPermission = perms.isSRA() || perms.isRA(orgCode) || perms.isRM(orgCode, serverGOT);
    json.addProperty("canRun", !isRunning && hasRunPermission);
    return json;
}
Also used : RolePermissionService(net.geoprism.registry.permission.RolePermissionService) ServerGeoObjectType(net.geoprism.registry.model.ServerGeoObjectType) ListType(net.geoprism.registry.ListType) JsonObject(com.google.gson.JsonObject)

Aggregations

ListType (net.geoprism.registry.ListType)28 Request (com.runwaysdk.session.Request)21 JsonObject (com.google.gson.JsonObject)19 ListTypeVersion (net.geoprism.registry.ListTypeVersion)11 Test (org.junit.Test)10 IncrementalListType (net.geoprism.registry.IncrementalListType)9 IntervalListType (net.geoprism.registry.IntervalListType)9 SingleListType (net.geoprism.registry.SingleListType)9 DuplicateDataDatabaseException (com.runwaysdk.dataaccess.database.DuplicateDataDatabaseException)8 ClassificationTypeTest (net.geoprism.registry.classification.ClassificationTypeTest)8 ServerGeoObjectType (net.geoprism.registry.model.ServerGeoObjectType)8 JsonArray (com.google.gson.JsonArray)5 ListTypeEntry (net.geoprism.registry.ListTypeEntry)5 QueryFactory (com.runwaysdk.query.QueryFactory)4 Session (com.runwaysdk.session.Session)4 MdBusinessDAOIF (com.runwaysdk.dataaccess.MdBusinessDAOIF)3 InvalidMasterListException (net.geoprism.registry.InvalidMasterListException)3 ListTypeVersionQuery (net.geoprism.registry.ListTypeVersionQuery)3 Geometry (com.vividsolutions.jts.geom.Geometry)2 Organization (net.geoprism.registry.Organization)2