use of net.geoprism.registry.action.ChangeRequest in project geoprism-registry by terraframe.
the class ChangeRequestSortingPatch method doIt.
@Transaction
private void doIt() {
ChangeRequestQuery crq = new ChangeRequestQuery(new QueryFactory());
OIterator<? extends ChangeRequest> it = crq.getIterator();
for (ChangeRequest cr : it) {
LocalizedValue goLabel = cr.getGeoObjectDisplayLabel();
ServerGeoObjectType type = cr.getGeoObjectType();
cr.appLock();
cr.getGeoObjectLabel().setLocaleMap(goLabel.getLocaleMap());
cr.getGeoObjectTypeLabel().setLocaleMap(type.getLabel().getLocaleMap());
cr.apply();
}
}
use of net.geoprism.registry.action.ChangeRequest in project geoprism-registry by terraframe.
the class GeoObjectEditorControllerNoOverTime method applyInTransaction.
@Transaction
private GeoObject applyInTransaction(String sessionId, String sPtn, String sGo, Boolean isNew, String masterListId) {
final Date startDate = new Date();
final Date endDate = ValueOverTime.INFINITY_END_DATE;
GeoObject go;
Map<String, String> roles = Session.getCurrentSession().getUserRoles();
if (roles.keySet().contains(RegistryConstants.REGISTRY_CONTRIBUTOR_ROLE)) {
Instant base = Instant.now();
int sequence = 0;
ChangeRequest request = new ChangeRequest();
request.addApprovalStatus(AllGovernanceStatus.PENDING);
request.apply();
if (!isNew) {
UpdateGeoObjectAction action = new UpdateGeoObjectAction();
action.addApprovalStatus(AllGovernanceStatus.PENDING);
action.setCreateActionDate(Date.from(base.plus(sequence++, ChronoUnit.MINUTES)));
action.setGeoObjectJson(sGo);
action.setApiVersion(CGRAdapterProperties.getApiVersion());
action.apply();
request.addAction(action).apply();
} else {
CreateGeoObjectAction action = new CreateGeoObjectAction();
action.addApprovalStatus(AllGovernanceStatus.PENDING);
action.setCreateActionDate(Date.from(base.plus(sequence++, ChronoUnit.MINUTES)));
action.setGeoObjectJson(sGo);
action.setApiVersion(CGRAdapterProperties.getApiVersion());
action.apply();
request.addAction(action).apply();
}
ParentTreeNode ptn = ParentTreeNode.fromJSON(sPtn.toString(), ServiceFactory.getAdapter());
applyChangeRequest(sessionId, request, ptn, isNew, base, sequence, startDate, endDate);
} else {
if (!isNew) {
go = RegistryService.getInstance().updateGeoObject(sessionId, sGo.toString(), startDate, endDate);
} else {
go = RegistryService.getInstance().createGeoObject(sessionId, sGo.toString(), startDate, endDate);
}
ParentTreeNode ptn = ParentTreeNode.fromJSON(sPtn.toString(), ServiceFactory.getAdapter());
applyPtn(sessionId, ptn, startDate, endDate);
// Update the master list record
if (masterListId != null) {
ServerGeoObjectService service = new ServerGeoObjectService();
ServerGeoObjectIF geoObject = service.getGeoObject(go);
if (!isNew) {
ListTypeVersion.get(masterListId).updateRecord(geoObject);
} else {
ListTypeVersion.get(masterListId).publishRecord(geoObject);
}
}
return go;
}
return null;
}
use of net.geoprism.registry.action.ChangeRequest in project geoprism-registry by terraframe.
the class ChangeRequestTestDataGenerator method deleteAllChangeRequests.
@Request
public static void deleteAllChangeRequests() {
ChangeRequestQuery crq = new ChangeRequestQuery(new QueryFactory());
OIterator<? extends ChangeRequest> it = crq.getIterator();
while (it.hasNext()) {
it.next().delete();
}
}
use of net.geoprism.registry.action.ChangeRequest in project geoprism-registry by terraframe.
the class ChangeRequestTestDataGenerator method submitChangeRequest.
private static void submitChangeRequest(String sJson) {
ChangeRequest cr = new ChangeRequest();
cr.addApprovalStatus(AllGovernanceStatus.PENDING);
cr.apply();
List<AbstractActionDTO> actionDTOs = AbstractActionDTO.parseActions(sJson);
for (AbstractActionDTO actionDTO : actionDTOs) {
AbstractAction ra = AbstractAction.dtoToRegistry(actionDTO);
ra.addApprovalStatus(AllGovernanceStatus.PENDING);
ra.apply();
cr.addAction(ra).apply();
}
}
use of net.geoprism.registry.action.ChangeRequest in project geoprism-registry by terraframe.
the class ServerGeoObjectService method createGeoObjectInTrans.
@Transaction
public JsonObject createGeoObjectInTrans(String sPtn, String sTimeGo, String masterListId, String notes) {
GeoObjectOverTime timeGO = GeoObjectOverTime.fromJSON(ServiceFactory.getAdapter(), sTimeGo);
ServerGeoObjectType serverGOT = ServerGeoObjectType.get(timeGO.getType());
RolePermissionService perms = ServiceFactory.getRolePermissionService();
final String orgCode = serverGOT.getOrganization().getCode();
if (perms.isSRA() || perms.isRA(orgCode) || perms.isRM(orgCode, serverGOT)) {
ServerGeoObjectService service = new ServerGeoObjectService();
ServerGeoObjectIF serverGO = service.apply(timeGO, true, false);
final ServerGeoObjectType type = serverGO.getType();
if (sPtn != null) {
ServerParentTreeNodeOverTime ptnOt = ServerParentTreeNodeOverTime.fromJSON(type, sPtn);
serverGO.setParents(ptnOt);
}
// Update the master list record
if (masterListId != null) {
ListTypeVersion.get(masterListId).publishRecord(serverGO);
}
JsonObject resp = new JsonObject();
resp.addProperty("isChangeRequest", false);
resp.add("geoObject", serverGO.toGeoObjectOverTime().toJSON(ServiceFactory.getRegistryService().serializer(Session.getCurrentSession().getOid())));
return resp;
} else if (ServiceFactory.getRolePermissionService().isRC(orgCode, serverGOT)) {
Instant base = Instant.now();
int sequence = 0;
ChangeRequest request = new ChangeRequest();
request.addApprovalStatus(AllGovernanceStatus.PENDING);
request.setContributorNotes(notes);
request.setGeoObjectCode(timeGO.getCode());
request.setGeoObjectTypeCode(timeGO.getType().getCode());
request.setOrganizationCode(orgCode);
request.apply();
CreateGeoObjectAction action = new CreateGeoObjectAction();
action.addApprovalStatus(AllGovernanceStatus.PENDING);
action.setCreateActionDate(Date.from(base.plus(sequence++, ChronoUnit.MINUTES)));
action.setGeoObjectJson(sTimeGo);
action.setParentJson(sPtn);
action.setApiVersion(CGRAdapterProperties.getApiVersion());
action.setContributorNotes(notes);
action.apply();
request.addAction(action).apply();
JsonObject resp = new JsonObject();
resp.addProperty("isChangeRequest", true);
resp.addProperty("changeRequestId", request.getOid());
return resp;
} else {
throw new CGRPermissionException();
}
}
Aggregations