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");
}
}
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;
}
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;
}
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();
}
}
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;
}
Aggregations