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 List<JSONDocumentChangedEvent> events = new ArrayList<>();
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, 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 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 -> {
//
// Process changes and the save the document
document.processValueChanges(fieldChangeRequests, ReasonSupplier.NONE);
document.saveIfValidAndHasChanges();
//
// Important: before allowing the document to be stored back in documents collection,
// we need to make sure it's valid and saved.
final DocumentValidStatus validStatus = document.getValidStatus();
if (!validStatus.isValid()) {
throw new AdempiereException(validStatus.getReason());
}
final DocumentSaveStatus saveStatus = document.getSaveStatus();
if (saveStatus.isNotSaved()) {
throw new AdempiereException(saveStatus.getReason());
}
// nothing/not important
return null;
}));
invalidateRowById(rowId);
ViewChangesCollector.getCurrentOrAutoflush().collectRowChanged(this, rowId);
documentsCollection.invalidateRootDocument(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);
}
Aggregations