Search in sources :

Example 1 with IRangeAwareParams

use of org.adempiere.util.api.IRangeAwareParams in project metasfresh-webui-api by metasfresh.

the class WEBUI_M_HU_MoveToDirectWarehouse_Mass method prepare.

@Override
protected void prepare() {
    final IRangeAwareParams parameterAsIParams = getParameterAsIParams();
    p_M_Warehouse_ID = parameterAsIParams.getParameterAsInt("M_Warehouse_ID");
    p_huWhereClause = parameterAsIParams.getParameterAsString("WhereClause");
    p_MovementDate = parameterAsIParams.getParameterAsTimestamp("MovementDate");
    p_Description = parameterAsIParams.getParameterAsString("Description");
}
Also used : IRangeAwareParams(org.adempiere.util.api.IRangeAwareParams)

Example 2 with IRangeAwareParams

use of org.adempiere.util.api.IRangeAwareParams in project metasfresh-webui-api by metasfresh.

the class ADProcessInstancesRepository method retrieveProcessInstance.

private ADProcessInstanceController retrieveProcessInstance(final DocumentId adPInstanceId) {
    Check.assumeNotNull(adPInstanceId, "Parameter adPInstanceId is not null");
    Check.assume(adPInstanceId.toInt() > 0, "adPInstanceId > 0");
    // 
    // Load process info
    final ProcessInfo processInfo = ProcessInfo.builder().setCtx(Env.getCtx()).setCreateTemporaryCtx().setAD_PInstance_ID(adPInstanceId.toInt()).build();
    final Object processClassInstance = processInfo.newProcessClassInstanceOrNull();
    try (final IAutoCloseable c = JavaProcess.temporaryChangeCurrentInstance(processClassInstance)) {
        // 
        // Build the parameters document
        final ProcessId processId = ProcessId.ofAD_Process_ID(processInfo.getAD_Process_ID());
        final ProcessDescriptor processDescriptor = getProcessDescriptor(processId);
        // 
        // Build the parameters (as document)
        final DocumentEntityDescriptor parametersDescriptor = processDescriptor.getParametersDescriptor();
        final Document parametersDoc = parametersDescriptor.getDataBinding().getDocumentsRepository().retrieveDocumentById(parametersDescriptor, adPInstanceId, NullDocumentChangesCollector.instance);
        // TODO: handle the case when the process was already executed
        // In that case we need to load the result and provide it to ProcessInstance constructor
        // 
        // View informations
        final IRangeAwareParams processInfoParams = processInfo.getParameterAsIParams();
        final String viewIdStr = processInfoParams.getParameterAsString(ViewBasedProcessTemplate.PARAM_ViewId);
        final ViewId viewId = Strings.isNullOrEmpty(viewIdStr) ? null : ViewId.ofViewIdString(viewIdStr);
        // 
        return ADProcessInstanceController.builder().caption(processDescriptor.getCaption()).instanceId(adPInstanceId).parameters(parametersDoc).processClassInstance(processClassInstance).viewId(viewId).build();
    }
}
Also used : IRangeAwareParams(org.adempiere.util.api.IRangeAwareParams) IAutoCloseable(org.adempiere.util.lang.IAutoCloseable) ViewId(de.metas.ui.web.view.ViewId) ProcessDescriptor(de.metas.ui.web.process.descriptor.ProcessDescriptor) WebuiRelatedProcessDescriptor(de.metas.ui.web.process.descriptor.WebuiRelatedProcessDescriptor) ProcessInfo(de.metas.process.ProcessInfo) ProcessId(de.metas.ui.web.process.ProcessId) DocumentEntityDescriptor(de.metas.ui.web.window.descriptor.DocumentEntityDescriptor) Document(de.metas.ui.web.window.model.Document)

Aggregations

IRangeAwareParams (org.adempiere.util.api.IRangeAwareParams)2 ProcessInfo (de.metas.process.ProcessInfo)1 ProcessId (de.metas.ui.web.process.ProcessId)1 ProcessDescriptor (de.metas.ui.web.process.descriptor.ProcessDescriptor)1 WebuiRelatedProcessDescriptor (de.metas.ui.web.process.descriptor.WebuiRelatedProcessDescriptor)1 ViewId (de.metas.ui.web.view.ViewId)1 DocumentEntityDescriptor (de.metas.ui.web.window.descriptor.DocumentEntityDescriptor)1 Document (de.metas.ui.web.window.model.Document)1 IAutoCloseable (org.adempiere.util.lang.IAutoCloseable)1