Search in sources :

Example 21 with DocumentId

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());
    });
}
Also used : DocumentId(de.metas.ui.web.window.datatypes.DocumentId) IDocumentChangesCollector(de.metas.ui.web.window.model.IDocumentChangesCollector) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 22 with DocumentId

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;
    }
}
Also used : Env(org.compiere.util.Env) Autowired(org.springframework.beans.factory.annotation.Autowired) DocumentCollection(de.metas.ui.web.window.model.DocumentCollection) ProcessDefaultParametersUpdater(de.metas.process.ProcessDefaultParametersUpdater) IProcessInstancesRepository(de.metas.ui.web.process.IProcessInstancesRepository) IView(de.metas.ui.web.view.IView) IRangeAwareParams(org.adempiere.util.api.IRangeAwareParams) ProcessDescriptor(de.metas.ui.web.process.descriptor.ProcessDescriptor) TableRecordReference(org.adempiere.util.lang.impl.TableRecordReference) ImmutableSet(com.google.common.collect.ImmutableSet) ProcessInfoBuilder(de.metas.process.ProcessInfo.ProcessInfoBuilder) NonNull(lombok.NonNull) Set(java.util.Set) JavaProcess(de.metas.process.JavaProcess) UserSession(de.metas.ui.web.session.UserSession) Services(org.adempiere.util.Services) I_AD_Process(org.compiere.model.I_AD_Process) Stream(java.util.stream.Stream) ProcessId(de.metas.ui.web.process.ProcessId) IDocumentChangesCollector(de.metas.ui.web.window.model.IDocumentChangesCollector) CacheBuilder(com.google.common.cache.CacheBuilder) IProcessInstanceController(de.metas.ui.web.process.IProcessInstanceController) IViewsRepository(de.metas.ui.web.view.IViewsRepository) ProcessInfo(de.metas.process.ProcessInfo) DocumentPath(de.metas.ui.web.window.datatypes.DocumentPath) CreateProcessInstanceRequest(de.metas.ui.web.process.CreateProcessInstanceRequest) DocumentId(de.metas.ui.web.window.datatypes.DocumentId) SqlOptions(de.metas.ui.web.window.model.sql.SqlOptions) IDocumentEvaluatee(de.metas.ui.web.window.model.IDocumentEvaluatee) Function(java.util.function.Function) NullDocumentChangesCollector(de.metas.ui.web.window.model.NullDocumentChangesCollector) Strings(com.google.common.base.Strings) SqlDocumentEntityDataBindingDescriptor(de.metas.ui.web.window.descriptor.sql.SqlDocumentEntityDataBindingDescriptor) DocumentEntityDescriptor(de.metas.ui.web.window.descriptor.DocumentEntityDescriptor) Nullable(javax.annotation.Nullable) DocumentIdsSelection(de.metas.ui.web.window.datatypes.DocumentIdsSelection) ViewRowIdsSelection(de.metas.ui.web.view.ViewRowIdsSelection) DocumentDescriptorFactory(de.metas.ui.web.window.descriptor.factory.DocumentDescriptorFactory) IUserRolePermissions(org.adempiere.ad.security.IUserRolePermissions) IADPInstanceDAO(de.metas.process.IADPInstanceDAO) IAutoCloseable(org.adempiere.util.lang.IAutoCloseable) WebuiRelatedProcessDescriptor(de.metas.ui.web.process.descriptor.WebuiRelatedProcessDescriptor) ExecutionException(java.util.concurrent.ExecutionException) TimeUnit(java.util.concurrent.TimeUnit) Component(org.springframework.stereotype.Component) AdempiereException(org.adempiere.exceptions.AdempiereException) WebuiPreconditionsContext(de.metas.ui.web.process.WebuiPreconditionsContext) Check(de.metas.printing.esb.base.util.Check) IProcessDefaultParametersProvider(de.metas.process.IProcessDefaultParametersProvider) Cache(com.google.common.cache.Cache) Document(de.metas.ui.web.window.model.Document) ViewId(de.metas.ui.web.view.ViewId) IProcessDefaultParametersProvider(de.metas.process.IProcessDefaultParametersProvider) DocumentId(de.metas.ui.web.window.datatypes.DocumentId) IAutoCloseable(org.adempiere.util.lang.IAutoCloseable) ProcessDescriptor(de.metas.ui.web.process.descriptor.ProcessDescriptor) WebuiRelatedProcessDescriptor(de.metas.ui.web.process.descriptor.WebuiRelatedProcessDescriptor) ProcessInfo(de.metas.process.ProcessInfo) IADPInstanceDAO(de.metas.process.IADPInstanceDAO) DocumentEntityDescriptor(de.metas.ui.web.window.descriptor.DocumentEntityDescriptor) Document(de.metas.ui.web.window.model.Document)

Example 23 with DocumentId

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);
}
Also used : DocumentIdsSelection(de.metas.ui.web.window.datatypes.DocumentIdsSelection) DocumentId(de.metas.ui.web.window.datatypes.DocumentId)

Example 24 with DocumentId

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);
}
Also used : IView(de.metas.ui.web.view.IView) DocumentIdsSelection(de.metas.ui.web.window.datatypes.DocumentIdsSelection) DocumentId(de.metas.ui.web.window.datatypes.DocumentId)

Example 25 with DocumentId

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;
}
Also used : DocumentId(de.metas.ui.web.window.datatypes.DocumentId)

Aggregations

DocumentId (de.metas.ui.web.window.datatypes.DocumentId)99 DocumentPath (de.metas.ui.web.window.datatypes.DocumentPath)18 DocumentIdsSelection (de.metas.ui.web.window.datatypes.DocumentIdsSelection)14 List (java.util.List)14 ImmutableList (com.google.common.collect.ImmutableList)12 GetMapping (org.springframework.web.bind.annotation.GetMapping)12 AdempiereException (org.adempiere.exceptions.AdempiereException)11 JSONLookupValuesList (de.metas.ui.web.window.datatypes.json.JSONLookupValuesList)9 ArrayList (java.util.ArrayList)9 Set (java.util.Set)9 NonNull (lombok.NonNull)9 Test (org.junit.Test)9 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)9 UserSession (de.metas.ui.web.session.UserSession)8 ViewId (de.metas.ui.web.view.ViewId)8 DocumentEntityDescriptor (de.metas.ui.web.window.descriptor.DocumentEntityDescriptor)8 Document (de.metas.ui.web.window.model.Document)8 IDocumentChangesCollector (de.metas.ui.web.window.model.IDocumentChangesCollector)8 TableRecordReference (org.adempiere.util.lang.impl.TableRecordReference)8 Autowired (org.springframework.beans.factory.annotation.Autowired)8