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;
}
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);
}
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;
}
}
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);
}
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);
}
Aggregations