use of de.metas.ui.web.window.datatypes.DocumentId in project metasfresh-webui-api by metasfresh.
the class ProcessRestController method processParametersChangeEvents.
@RequestMapping(value = "/{processId}/{pinstanceId}", method = RequestMethod.PATCH)
public List<JSONDocument> processParametersChangeEvents(//
@PathVariable("processId") final String processIdStr, //
@PathVariable("pinstanceId") final String pinstanceIdStr, //
@RequestBody final List<JSONDocumentChangedEvent> events) {
userSession.assertLoggedIn();
Check.assumeNotEmpty(events, "events is not empty");
final ProcessId processId = ProcessId.fromJson(processIdStr);
final DocumentId pinstanceId = DocumentId.of(pinstanceIdStr);
final IProcessInstancesRepository instancesRepository = getRepository(processId);
return Execution.callInNewExecution("", () -> {
// get our collector to fill with the changes that we will record
final IDocumentChangesCollector changesCollector = Execution.getCurrentDocumentChangesCollectorOrNull();
instancesRepository.forProcessInstanceWritable(pinstanceId, changesCollector, processInstance -> {
processInstance.processParameterValueChanges(events, REASON_Value_DirectSetFromCommitAPI);
// void
return null;
});
return JSONDocument.ofEvents(changesCollector, newJSONOptions());
});
}
use of de.metas.ui.web.window.datatypes.DocumentId in project metasfresh-webui-api by metasfresh.
the class ADProcessInstancesRepository method createNewProcessInstance0.
/**
* @param request
* @param shadowParentDocumentEvaluatee optional shadowParentDocumentEvaluatee which will be
* @return
*/
private IProcessInstanceController createNewProcessInstance0(@NonNull final CreateProcessInstanceRequest request, @Nullable final IDocumentEvaluatee evalCtx) {
//
// Save process info together with it's parameters and get the the newly created AD_PInstance_ID
final ProcessInfo processInfo = createProcessInfo(request);
Services.get(IADPInstanceDAO.class).saveProcessInfo(processInfo);
final DocumentId adPInstanceId = DocumentId.of(processInfo.getAD_PInstance_ID());
final Object processClassInstance = processInfo.newProcessClassInstanceOrNull();
try (final IAutoCloseable c = JavaProcess.temporaryChangeCurrentInstance(processClassInstance)) {
//
// Build the parameters document
final ProcessDescriptor processDescriptor = getProcessDescriptor(request.getProcessId());
final DocumentEntityDescriptor parametersDescriptor = processDescriptor.getParametersDescriptor();
final Document parametersDoc = ADProcessParametersRepository.instance.createNewParametersDocument(parametersDescriptor, adPInstanceId, evalCtx);
final int windowNo = parametersDoc.getWindowNo();
// Set parameters's default values
ProcessDefaultParametersUpdater.newInstance().addDefaultParametersProvider(processClassInstance instanceof IProcessDefaultParametersProvider ? (IProcessDefaultParametersProvider) processClassInstance : null).onDefaultValue((parameter, value) -> parametersDoc.processValueChange(parameter.getColumnName(), value, () -> "default parameter value")).updateDefaultValue(parametersDoc.getFieldViews(), field -> DocumentFieldAsProcessDefaultParameter.of(windowNo, field));
//
// Create (webui) process instance and add it to our internal cache.
final ADProcessInstanceController pinstance = ADProcessInstanceController.builder().caption(processDescriptor.getCaption()).instanceId(adPInstanceId).parameters(parametersDoc).processClassInstance(processClassInstance).contextSingleDocumentPath(request.getSingleDocumentPath()).viewId(request.getViewRowIdsSelection() != null ? request.getViewRowIdsSelection().getViewId() : null).build();
processInstances.put(adPInstanceId, pinstance.copyReadonly());
return pinstance;
}
}
use of de.metas.ui.web.window.datatypes.DocumentId in project metasfresh-webui-api by metasfresh.
the class PickingSlotsClearingViewBasedProcess method getSingleSelectedPackingHUsRow.
protected final HUEditorRow getSingleSelectedPackingHUsRow() {
final DocumentIdsSelection selectedRowIds = getSelectedPackingHUsRowIds();
final DocumentId rowId = selectedRowIds.getSingleDocumentId();
return getPackingHUsView().getById(rowId);
}
use of de.metas.ui.web.window.datatypes.DocumentId in project metasfresh-webui-api by metasfresh.
the class ViewBasedProcessTemplate method getChildViewSingleSelectedRow.
protected IViewRow getChildViewSingleSelectedRow() {
final DocumentIdsSelection selectedRowIds = getChildViewSelectedRowIds();
final DocumentId rowId = selectedRowIds.getSingleDocumentId();
return getChildView(IView.class).getById(rowId);
}
use of de.metas.ui.web.window.datatypes.DocumentId in project metasfresh-webui-api by metasfresh.
the class PickingSlotRowId method toDocumentId.
public DocumentId toDocumentId() {
DocumentId id = _documentId;
if (id == null) {
final String idStr = DOCUMENT_ID_JOINER.join(pickingSlotId, huId > 0 ? huId : null, huStorageProductId > 0 ? huStorageProductId : null);
id = _documentId = DocumentId.ofString(idStr);
}
return id;
}
Aggregations