Search in sources :

Example 41 with DocumentId

use of de.metas.ui.web.window.datatypes.DocumentId in project metasfresh-webui-api by metasfresh.

the class MenuTreeLoader method createMenuNodeBuilder.

private MenuNode.Builder createMenuNodeBuilder(final MTreeNode nodeModel, final int depth) {
    // shall not be empty
    final String captionBreadcrumb = nodeModel.getName();
    String caption = nodeModel.getWEBUI_NameBrowse();
    if (Check.isEmpty(caption, true)) {
        caption = captionBreadcrumb;
    }
    final MenuNode.Builder builder = MenuNode.builder().setAD_Menu_ID(nodeModel.getNode_ID()).setCaption(caption).setCaptionBreadcrumb(captionBreadcrumb).setMainTableName(nodeModel.getMainTableName());
    final String action = nodeModel.getImageIndiactor();
    if (nodeModel.isSummary()) {
        builder.setTypeGroup();
    } else if (depth == DEPTH_RootChildren) {
        logger.warn("Skip creating leaf nodes for root: {}", nodeModel);
        return null;
    } else if (X_AD_Menu.ACTION_Window.equals(action)) {
        final DocumentId elementId = DocumentId.of(nodeModel.getAD_Window_ID());
        builder.setType(MenuNodeType.Window, elementId);
    } else if (X_AD_Menu.ACTION_Process.equals(action)) {
        final DocumentId elementId = ProcessId.ofAD_Process_ID(nodeModel.getAD_Process_ID()).toDocumentId();
        builder.setType(MenuNodeType.Process, elementId);
    } else if (X_AD_Menu.ACTION_Report.equals(action)) {
        final DocumentId elementId = ProcessId.ofAD_Process_ID(nodeModel.getAD_Process_ID()).toDocumentId();
        builder.setType(MenuNodeType.Report, elementId);
    } else if (X_AD_Menu.ACTION_Board.equals(action)) {
        final DocumentId elementId = DocumentId.of(nodeModel.getWEBUI_Board_ID());
        builder.setType(MenuNodeType.Board, elementId);
    } else {
        return null;
    }
    return builder;
}
Also used : DocumentId(de.metas.ui.web.window.datatypes.DocumentId)

Example 42 with DocumentId

use of de.metas.ui.web.window.datatypes.DocumentId in project metasfresh-webui-api by metasfresh.

the class HUReportProcessInstancesRepository method createNewProcessInstance.

@Override
public HUReportProcessInstance createNewProcessInstance(final CreateProcessInstanceRequest request) {
    final WebuiHUProcessDescriptor descriptor = getWebuiHUProcessDescriptor(request.getProcessId());
    final DocumentId instanceId = nextPInstanceId();
    final Document parameters = Document.builder(descriptor.getParametersDescriptor()).initializeAsNewDocument(instanceId, /* version */
    "0");
    final HUReportProcessInstance instance = HUReportProcessInstance.builder().instanceId(instanceId).viewRowIdsSelection(request.getViewRowIdsSelection()).reportADProcessId(descriptor.getReportADProcessId()).parameters(parameters).build();
    instance.setCopies(1);
    putInstance(instance);
    return instance;
}
Also used : DocumentId(de.metas.ui.web.window.datatypes.DocumentId) Document(de.metas.ui.web.window.model.Document)

Example 43 with DocumentId

use of de.metas.ui.web.window.datatypes.DocumentId in project metasfresh-webui-api by metasfresh.

the class HUEditorRowAttributesProvider method createRowAttributes.

private HUEditorRowAttributes createRowAttributes(final ViewRowAttributesKey key) {
    final int huId = key.getHuId().toInt();
    final I_M_HU hu = InterfaceWrapperHelper.create(Env.getCtx(), huId, I_M_HU.class, ITrx.TRXNAME_None);
    if (hu == null) {
        throw new IllegalArgumentException("No HU found for M_HU_ID=" + huId);
    }
    final IAttributeStorage attributesStorage = getAttributeStorageFactory().getAttributeStorage(hu);
    attributesStorage.setSaveOnChange(true);
    final DocumentId documentTypeId = DocumentId.of(huId);
    final DocumentId huEditorRowId = key.getHuEditorRowId();
    final DocumentPath documentPath = DocumentPath.rootDocumentPath(DocumentType.ViewRecordAttributes, documentTypeId, huEditorRowId);
    final boolean rowAttributesReadonly = // readonly if the provider shall provide readonly attributes
    isReadonly() || // or, readonly if not Planning, see https://github.com/metasfresh/metasfresh-webui-api/issues/314
    !X_M_HU.HUSTATUS_Planning.equals(hu.getHUStatus());
    return new HUEditorRowAttributes(documentPath, attributesStorage, rowAttributesReadonly);
}
Also used : IAttributeStorage(de.metas.handlingunits.attribute.storage.IAttributeStorage) I_M_HU(de.metas.handlingunits.model.I_M_HU) DocumentId(de.metas.ui.web.window.datatypes.DocumentId) DocumentPath(de.metas.ui.web.window.datatypes.DocumentPath)

Example 44 with DocumentId

use of de.metas.ui.web.window.datatypes.DocumentId in project metasfresh-webui-api by metasfresh.

the class WEBUI_M_ReceiptSchedule_CreateEmptiesReturns_Base method createDraftEmptiesDocument.

private int createDraftEmptiesDocument() {
    final DocumentPath documentPath = DocumentPath.builder().setDocumentType(WindowId.of(getTargetWindowId())).setDocumentId(DocumentId.NEW_ID_STRING).allowNewDocumentId().build();
    final DocumentId documentId = documentsRepo.forDocumentWritable(documentPath, NullDocumentChangesCollector.instance, document -> {
        huEmptiesService.newReturnsInOutProducer(getCtx()).setMovementType(getReturnMovementType()).setMovementDate(SystemTime.asDayTimestamp()).fillReturnsInOutHeader(InterfaceWrapperHelper.create(document, I_M_InOut.class));
        return document.getDocumentId();
    });
    return documentId.toInt();
}
Also used : I_M_InOut(org.compiere.model.I_M_InOut) DocumentId(de.metas.ui.web.window.datatypes.DocumentId) DocumentPath(de.metas.ui.web.window.datatypes.DocumentPath)

Example 45 with DocumentId

use of de.metas.ui.web.window.datatypes.DocumentId in project metasfresh-webui-api by metasfresh.

the class PurchaseRowIdTest method fromDocumentId_NotAvailable.

@Test
public void fromDocumentId_NotAvailable() {
    final DocumentId documentId = DocumentId.ofString("1000007-2156423-32311-NOT_AVAILABLE-11");
    final PurchaseRowId purchaseRowId = PurchaseRowId.fromDocumentId(documentId);
    assertThat(purchaseRowId.getSalesOrderLineId()).isEqualTo(1000007);
    assertThat(purchaseRowId.getVendorBPartnerId()).isEqualTo(2156423);
    assertThat(purchaseRowId.getProcessedPurchaseCandidateId()).isEqualTo(32311);
    assertThat(purchaseRowId.getAvailabilityType()).isEqualTo(Type.NOT_AVAILABLE);
}
Also used : DocumentId(de.metas.ui.web.window.datatypes.DocumentId) Test(org.junit.Test)

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