use of net.geoprism.registry.permission.AllowAllGeoObjectPermissionService in project geoprism-registry by terraframe.
the class AddChildAction method apply.
@Override
public void apply() {
ServerGeoObjectIF parent = new ServerGeoObjectService(new AllowAllGeoObjectPermissionService()).getGeoObject(this.getParentId(), this.getParentTypeCode());
ServerGeoObjectIF child = new ServerGeoObjectService().getGeoObject(this.getChildId(), this.getChildTypeCode());
ServerHierarchyType ht = ServerHierarchyType.get(this.getHierarchyTypeCode());
ServiceFactory.getGeoObjectRelationshipPermissionService().enforceCanAddChildCR(ht.getOrganization().getCode(), parent.getType(), child.getType());
super.apply();
}
use of net.geoprism.registry.permission.AllowAllGeoObjectPermissionService in project geoprism-registry by terraframe.
the class RemoveChildAction method apply.
@Override
public void apply() {
ServerGeoObjectIF parent = new ServerGeoObjectService(new AllowAllGeoObjectPermissionService()).getGeoObject(this.getParentId(), this.getParentTypeCode());
ServerGeoObjectIF child = new ServerGeoObjectService().getGeoObject(this.getChildId(), this.getChildTypeCode());
ServerHierarchyType ht = ServerHierarchyType.get(this.getHierarchyTypeCode());
ServiceFactory.getGeoObjectRelationshipPermissionService().enforceCanRemoveChildCR(ht.getOrganization().getCode(), parent.getType(), child.getType());
super.apply();
}
use of net.geoprism.registry.permission.AllowAllGeoObjectPermissionService in project geoprism-registry by terraframe.
the class RemoveChildAction method execute.
@Override
public void execute() {
ServerGeoObjectIF parent = new ServerGeoObjectService(new AllowAllGeoObjectPermissionService()).getGeoObject(this.getParentId(), this.getParentTypeCode());
ServerGeoObjectIF child = new ServerGeoObjectService().getGeoObject(this.getChildId(), this.getChildTypeCode());
ServerHierarchyType ht = ServerHierarchyType.get(this.getHierarchyTypeCode());
ServiceFactory.getGeoObjectRelationshipPermissionService().enforceCanRemoveChild(ht.getOrganization().getCode(), parent.getType(), child.getType());
parent.removeChild(child, this.getHierarchyTypeCode(), null, null);
}
use of net.geoprism.registry.permission.AllowAllGeoObjectPermissionService in project geoprism-registry by terraframe.
the class ShapefileServiceTest method testImportShapefileWithBadParentCode.
@Test
@Request
public void testImportShapefileWithBadParentCode() throws Throwable {
GeoObject geoObj = ServiceFactory.getRegistryService().newGeoObjectInstance(testData.clientRequest.getSessionId(), USATestData.COUNTRY.getCode());
geoObj.setCode("00");
geoObj.setDisplayLabel(LocalizedValue.DEFAULT_LOCALE, "Test Label");
geoObj.setUid(ServiceFactory.getIdService().getUids(1)[0]);
ServerGeoObjectIF serverGO = new ServerGeoObjectService(new AllowAllGeoObjectPermissionService()).apply(geoObj, TestDataSet.DEFAULT_OVER_TIME_DATE, TestDataSet.DEFAULT_END_TIME_DATE, true, false);
geoObj = RegistryService.getInstance().getGeoObjectByCode(Session.getCurrentSession().getOid(), serverGO.getCode(), serverGO.getType().getCode(), TestDataSet.DEFAULT_OVER_TIME_DATE);
InputStream istream = this.getClass().getResourceAsStream("/cb_2017_us_state_500k.zip.test");
Assert.assertNotNull(istream);
ShapefileService service = new ShapefileService();
GeoObjectImportConfiguration config = this.getTestConfiguration(istream, service, null, ImportStrategy.NEW_AND_UPDATE);
ServerHierarchyType hierarchyType = ServerHierarchyType.get(USATestData.HIER_ADMIN.getCode());
config.setHierarchy(hierarchyType);
config.addParent(new Location(USATestData.COUNTRY.getServerObject(), hierarchyType, new BasicColumnFunction("GEOID"), ParentMatchStrategy.CODE));
ImportHistory hist = mockImport(config);
Assert.assertTrue(hist.getStatus().get(0).equals(AllJobStatus.FEEDBACK));
hist = ImportHistory.get(hist.getOid());
Assert.assertEquals(new Long(56), hist.getWorkTotal());
Assert.assertEquals(new Long(56), hist.getWorkProgress());
Assert.assertEquals(new Long(0), hist.getImportedRecords());
Assert.assertEquals(ImportStage.VALIDATION_RESOLVE, hist.getStage().get(0));
final GeoObjectImportConfiguration test = new GeoObjectImportConfiguration();
test.fromJSON(hist.getConfigJson(), false);
// TODO
// Assert.assertEquals(config.getParentLookupType(),
// test.getParentLookupType());
// JSONArray errors = new JSONArray(hist.getErrorJson());
//
// Assert.assertEquals(0, errors.length());
// Ensure the geo objects were not created
ServerGeoObjectQuery query = new ServerGeoObjectService().createQuery(USATestData.STATE.getServerObject(), config.getStartDate());
query.setRestriction(new ServerCodeRestriction("01"));
Assert.assertNull(query.getSingleResult());
}
use of net.geoprism.registry.permission.AllowAllGeoObjectPermissionService in project geoprism-registry by terraframe.
the class AddChildAction method execute.
@Override
public void execute() {
ServerGeoObjectIF parent = new ServerGeoObjectService(new AllowAllGeoObjectPermissionService()).getGeoObject(this.getParentId(), this.getParentTypeCode());
ServerGeoObjectIF child = new ServerGeoObjectService().getGeoObject(this.getChildId(), this.getChildTypeCode());
ServerHierarchyType ht = ServerHierarchyType.get(this.getHierarchyTypeCode());
ServiceFactory.getGeoObjectRelationshipPermissionService().enforceCanAddChild(ht.getOrganization().getCode(), parent.getType(), child.getType());
parent.addChild(child, ht);
}
Aggregations