use of de.metas.ui.web.window.datatypes.DocumentPath in project metasfresh-webui-api by metasfresh.
the class WEBUI_CreateRequest method createRequestFromBPartner.
private void createRequestFromBPartner(final I_C_BPartner bpartner) {
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, bpartner.getC_BPartner_ID()));
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);
}
use of de.metas.ui.web.window.datatypes.DocumentPath in project metasfresh-webui-api by metasfresh.
the class JSONCreateProcessInstanceRequest method createSelectedIncludedDocumentPaths.
private static final List<DocumentPath> createSelectedIncludedDocumentPaths(final WindowId windowId, final String documentIdStr, final JSONSelectedIncludedTab selectedTab) {
if (windowId == null || Check.isEmpty(documentIdStr, true) || selectedTab == null) {
return ImmutableList.of();
}
final DocumentId documentId = DocumentId.of(documentIdStr);
final DetailId selectedTabId = DetailId.fromJson(selectedTab.getTabId());
return selectedTab.getRowIds().stream().map(DocumentId::of).map(rowId -> DocumentPath.includedDocumentPath(windowId, documentId, selectedTabId, rowId)).collect(ImmutableList.toImmutableList());
}
use of de.metas.ui.web.window.datatypes.DocumentPath in project metasfresh-webui-api by metasfresh.
the class ASIViewRowAttributes method toJson.
@Override
public JSONViewRowAttributes toJson(final JSONOptions jsonOpts) {
final DocumentPath documentPath = getDocumentPath();
final JSONViewRowAttributes jsonDocument = new JSONViewRowAttributes(documentPath);
final List<JSONDocumentField> jsonFields = asiDoc.getFieldViews().stream().map(field -> toJSONDocumentField(field, jsonOpts)).collect(Collectors.toList());
jsonDocument.setFields(jsonFields);
return jsonDocument;
}
use of de.metas.ui.web.window.datatypes.DocumentPath in project metasfresh-webui-api by metasfresh.
the class DefaultView method getFieldDropdown.
@Override
public LookupValuesList getFieldDropdown(final RowEditingContext ctx, final String fieldName) {
final DocumentId rowId = ctx.getRowId();
final DocumentCollection documentsCollection = ctx.getDocumentsCollection();
final DocumentPath documentPath = getById(rowId).getDocumentPath();
return documentsCollection.forDocumentReadonly(documentPath, document -> document.getFieldLookupValues(fieldName));
}
use of de.metas.ui.web.window.datatypes.DocumentPath in project metasfresh-webui-api by metasfresh.
the class DefaultView method patchViewRow.
@Override
public void patchViewRow(final RowEditingContext ctx, final List<JSONDocumentChangedEvent> fieldChangeRequests) {
final DocumentId rowId = ctx.getRowId();
final DocumentCollection documentsCollection = ctx.getDocumentsCollection();
final DocumentPath documentPath = getById(rowId).getDocumentPath();
Services.get(ITrxManager.class).runInThreadInheritedTrx(() -> documentsCollection.forDocumentWritable(documentPath, NullDocumentChangesCollector.instance, document -> {
patchDocument(document, fieldChangeRequests);
return null;
}));
invalidateRowById(rowId);
ViewChangesCollector.getCurrentOrAutoflush().collectRowChanged(this, rowId);
documentsCollection.invalidateRootDocument(documentPath);
}
Aggregations