Search in sources :

Example 11 with DocumentPath

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

the class DocumentAttachmentsRestController method getAttachments.

@GetMapping
public List<JSONAttachment> getAttachments(// 
@PathVariable("windowId") final String windowIdStr, // 
@PathVariable("documentId") final String documentId) {
    userSession.assertLoggedIn();
    final DocumentPath documentPath = DocumentPath.rootDocumentPath(WindowId.fromJson(windowIdStr), documentId);
    if (documentPath.isComposedKey()) {
        // document with composed keys does not support attachments
        return ImmutableList.of();
    }
    final boolean allowDelete = isAllowDeletingAttachments();
    final List<JSONAttachment> attachments = getDocumentAttachments(documentPath).toJson();
    attachments.forEach(attachment -> attachment.setAllowDelete(allowDelete));
    return attachments;
}
Also used : DocumentPath(de.metas.ui.web.window.datatypes.DocumentPath) JSONAttachment(de.metas.ui.web.attachments.json.JSONAttachment) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Example 12 with DocumentPath

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

the class HUEditorRowAttributesProvider method createRowAttributes.

private HUEditorRowAttributes createRowAttributes(final ViewRowAttributesKey key) {
    final I_M_HU hu = extractHU(key);
    final IAttributeStorage attributesStorage = getAttributeStorageFactory().getAttributeStorage(hu);
    attributesStorage.setSaveOnChange(true);
    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());
    final IHandlingUnitsBL handlingUnitsBL = Services.get(IHandlingUnitsBL.class);
    final IHUStorageFactory storageFactory = handlingUnitsBL.getStorageFactory();
    final IHUStorage storage = storageFactory.getStorage(hu);
    final ImmutableSet<ProductId> productIDs = storage.getProductStorages().stream().map(IHUProductStorage::getProductId).collect(ImmutableSet.toImmutableSet());
    final DocumentPath documentPath = createDocumentPath(key);
    return new HUEditorRowAttributes(documentPath, attributesStorage, productIDs, rowAttributesReadonly);
}
Also used : IAttributeStorage(de.metas.handlingunits.attribute.storage.IAttributeStorage) IHandlingUnitsBL(de.metas.handlingunits.IHandlingUnitsBL) I_M_HU(de.metas.handlingunits.model.I_M_HU) IHUStorageFactory(de.metas.handlingunits.storage.IHUStorageFactory) IHUStorage(de.metas.handlingunits.storage.IHUStorage) DocumentPath(de.metas.ui.web.window.datatypes.DocumentPath) ProductId(de.metas.product.ProductId)

Example 13 with DocumentPath

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

the class JSONProcessInstanceResult method toJSONResultAction.

/**
 * Converts {@link ResultAction} to JSON
 */
private static final JSONResultAction toJSONResultAction(final ResultAction resultAction) {
    if (resultAction == null) {
        return null;
    } else if (resultAction instanceof OpenReportAction) {
        final OpenReportAction openReportAction = (OpenReportAction) resultAction;
        return new JSONOpenReportAction(openReportAction.getFilename(), openReportAction.getContentType());
    } else if (resultAction instanceof OpenViewAction) {
        final OpenViewAction openViewAction = (OpenViewAction) resultAction;
        return new JSONOpenViewAction(openViewAction.getViewId(), openViewAction.getProfileId(), openViewAction.isModalOverlay());
    } else if (resultAction instanceof OpenIncludedViewAction) {
        final OpenIncludedViewAction openIncludedViewAction = (OpenIncludedViewAction) resultAction;
        return new JSONOpenIncludedViewAction(openIncludedViewAction.getViewId(), openIncludedViewAction.getProfileId());
    } else if (resultAction instanceof OpenSingleDocument) {
        final OpenSingleDocument openDocumentAction = (OpenSingleDocument) resultAction;
        final DocumentPath documentPath = openDocumentAction.getDocumentPath();
        return new JSONOpenSingleDocumentAction(documentPath.getWindowId(), documentPath.getDocumentId().toJson(), openDocumentAction.isModal());
    } else if (resultAction instanceof SelectViewRowsAction) {
        final SelectViewRowsAction selectViewRowsAction = (SelectViewRowsAction) resultAction;
        return new JSONSelectViewRowsAction(selectViewRowsAction.getViewId(), selectViewRowsAction.getRowIds());
    } else if (resultAction instanceof DisplayQRCodeAction) {
        final DisplayQRCodeAction displayQRCodeAction = (DisplayQRCodeAction) resultAction;
        return new JSONDisplayQRCodeAction(displayQRCodeAction.getCode());
    } else {
        logger.warn("Unknown result action: {}. Ignoring it.", resultAction);
        return null;
    }
}
Also used : OpenViewAction(de.metas.ui.web.process.ProcessInstanceResult.OpenViewAction) SelectViewRowsAction(de.metas.ui.web.process.ProcessInstanceResult.SelectViewRowsAction) OpenSingleDocument(de.metas.ui.web.process.ProcessInstanceResult.OpenSingleDocument) OpenIncludedViewAction(de.metas.ui.web.process.ProcessInstanceResult.OpenIncludedViewAction) DocumentPath(de.metas.ui.web.window.datatypes.DocumentPath) DisplayQRCodeAction(de.metas.ui.web.process.ProcessInstanceResult.DisplayQRCodeAction) OpenReportAction(de.metas.ui.web.process.ProcessInstanceResult.OpenReportAction)

Example 14 with DocumentPath

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

the class QuickInputPath method of.

public static final // 
QuickInputPath of(// 
final String windowIdStr, // 
final String documentIdStr, // 
final String tabIdStr, // 
final String quickInputIdStr) {
    final DocumentPath rootDocumentPath = DocumentPath.rootDocumentPath(WindowId.fromJson(windowIdStr), documentIdStr);
    final DetailId detailId = DetailId.fromJson(tabIdStr);
    final DocumentId quickInputId = DocumentId.of(quickInputIdStr);
    return new QuickInputPath(rootDocumentPath, detailId, quickInputId);
}
Also used : DetailId(de.metas.ui.web.window.descriptor.DetailId) DocumentId(de.metas.ui.web.window.datatypes.DocumentId) DocumentPath(de.metas.ui.web.window.datatypes.DocumentPath)

Example 15 with DocumentPath

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

the class WEBUI_CreateRequest method createRequestFromShipment.

private void createRequestFromShipment(final I_M_InOut shipment) {
    final I_C_BPartner bPartner = bPartnerDAO.getById(shipment.getC_BPartner_ID());
    final I_AD_User defaultContact = Services.get(IBPartnerDAO.class).retrieveDefaultContactOrNull(bPartner, I_AD_User.class);
    final ImmutableList.Builder<JSONDocumentChangedEvent> events = ImmutableList.builder();
    events.add(JSONDocumentChangedEvent.replace(I_R_Request.COLUMNNAME_SalesRep_ID, getAD_User_ID()));
    events.add(JSONDocumentChangedEvent.replace(I_R_Request.COLUMNNAME_C_BPartner_ID, shipment.getC_BPartner_ID()));
    events.add(JSONDocumentChangedEvent.replace(I_R_Request.COLUMNNAME_M_InOut_ID, shipment.getM_InOut_ID()));
    events.add(JSONDocumentChangedEvent.replace(I_R_Request.COLUMNNAME_DateDelivered, shipment.getMovementDate()));
    if (defaultContact != null) {
        events.add(JSONDocumentChangedEvent.replace(I_R_Request.COLUMNNAME_AD_User_ID, defaultContact.getAD_User_ID()));
    }
    final DocumentPath documentPath = DocumentPath.builder().setDocumentType(WindowConstants.WINDOWID_R_Request).setDocumentId(DocumentId.NEW_ID_STRING).allowNewDocumentId().build();
    final DocumentId documentId = documentCollection.forDocumentWritable(documentPath, NullDocumentChangesCollector.instance, document -> {
        document.processValueChanges(events.build(), ReasonSupplier.NONE);
        return document.getDocumentId();
    });
    getResult().setRecordToOpen(TableRecordReference.of(I_R_Request.Table_Name, documentId.toInt()), documentPath.getWindowId().toInt(), OpenTarget.SingleDocumentModal);
}
Also used : IBPartnerDAO(de.metas.bpartner.service.IBPartnerDAO) I_AD_User(org.compiere.model.I_AD_User) ImmutableList(com.google.common.collect.ImmutableList) DocumentId(de.metas.ui.web.window.datatypes.DocumentId) DocumentPath(de.metas.ui.web.window.datatypes.DocumentPath) JSONDocumentChangedEvent(de.metas.ui.web.window.datatypes.json.JSONDocumentChangedEvent) I_C_BPartner(org.compiere.model.I_C_BPartner)

Aggregations

DocumentPath (de.metas.ui.web.window.datatypes.DocumentPath)65 WindowId (de.metas.ui.web.window.datatypes.WindowId)29 JSONDocumentPath (de.metas.ui.web.window.datatypes.json.JSONDocumentPath)22 DocumentId (de.metas.ui.web.window.datatypes.DocumentId)20 GetMapping (org.springframework.web.bind.annotation.GetMapping)14 List (java.util.List)13 ImmutableList (com.google.common.collect.ImmutableList)12 ImmutableSet (com.google.common.collect.ImmutableSet)12 DetailId (de.metas.ui.web.window.descriptor.DetailId)12 Set (java.util.Set)11 NonNull (lombok.NonNull)10 TableRecordReference (org.adempiere.util.lang.impl.TableRecordReference)10 AdempiereException (org.adempiere.exceptions.AdempiereException)9 PostMapping (org.springframework.web.bind.annotation.PostMapping)9 DocumentIdsSelection (de.metas.ui.web.window.datatypes.DocumentIdsSelection)8 DocumentEntityDescriptor (de.metas.ui.web.window.descriptor.DocumentEntityDescriptor)8 Document (de.metas.ui.web.window.model.Document)7 ViewId (de.metas.ui.web.view.ViewId)6 Services (de.metas.util.Services)6 EntityNotFoundException (de.metas.ui.web.exceptions.EntityNotFoundException)5