Search in sources :

Example 16 with DocumentPath

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

Example 17 with DocumentPath

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());
}
Also used : JsonProperty(com.fasterxml.jackson.annotation.JsonProperty) ViewRowIdsSelection(de.metas.ui.web.view.ViewRowIdsSelection) ImmutableSet(com.google.common.collect.ImmutableSet) DocumentPath(de.metas.ui.web.window.datatypes.DocumentPath) NonNull(lombok.NonNull) DocumentId(de.metas.ui.web.window.datatypes.DocumentId) Set(java.util.Set) Visibility(com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility) MoreObjects(com.google.common.base.MoreObjects) WindowId(de.metas.ui.web.window.datatypes.WindowId) JsonAutoDetect(com.fasterxml.jackson.annotation.JsonAutoDetect) List(java.util.List) ImmutableList(com.google.common.collect.ImmutableList) ProcessId(de.metas.ui.web.process.ProcessId) Check(de.metas.printing.esb.base.util.Check) JsonCreator(com.fasterxml.jackson.annotation.JsonCreator) JsonIgnore(com.fasterxml.jackson.annotation.JsonIgnore) DetailId(de.metas.ui.web.window.descriptor.DetailId) Data(lombok.Data) JsonInclude(com.fasterxml.jackson.annotation.JsonInclude) ViewId(de.metas.ui.web.view.ViewId) DocumentIdsSelection(de.metas.ui.web.window.datatypes.DocumentIdsSelection) DetailId(de.metas.ui.web.window.descriptor.DetailId) DocumentId(de.metas.ui.web.window.datatypes.DocumentId)

Example 18 with DocumentPath

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;
}
Also used : JSONOptions(de.metas.ui.web.window.datatypes.json.JSONOptions) DocumentPath(de.metas.ui.web.window.datatypes.DocumentPath) JSONLayoutWidgetType(de.metas.ui.web.window.datatypes.json.JSONLayoutWidgetType) JSONDocumentChangedEvent(de.metas.ui.web.window.datatypes.json.JSONDocumentChangedEvent) ASILayout(de.metas.ui.web.pattribute.ASILayout) DocumentId(de.metas.ui.web.window.datatypes.DocumentId) Collectors(java.util.stream.Collectors) JSONViewRowAttributes(de.metas.ui.web.view.json.JSONViewRowAttributes) List(java.util.List) ViewRowAttributesLayout(de.metas.ui.web.view.descriptor.ViewRowAttributesLayout) IDocumentFieldView(de.metas.ui.web.window.model.IDocumentFieldView) DocumentFieldWidgetType(de.metas.ui.web.window.descriptor.DocumentFieldWidgetType) JSONDocumentField(de.metas.ui.web.window.datatypes.json.JSONDocumentField) LookupValuesList(de.metas.ui.web.window.datatypes.LookupValuesList) ASIDocument(de.metas.ui.web.pattribute.ASIDocument) DocumentType(de.metas.ui.web.window.datatypes.DocumentType) JSONViewRowAttributes(de.metas.ui.web.view.json.JSONViewRowAttributes) DocumentPath(de.metas.ui.web.window.datatypes.DocumentPath) JSONDocumentField(de.metas.ui.web.window.datatypes.json.JSONDocumentField)

Example 19 with DocumentPath

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));
}
Also used : DocumentId(de.metas.ui.web.window.datatypes.DocumentId) DocumentPath(de.metas.ui.web.window.datatypes.DocumentPath) DocumentCollection(de.metas.ui.web.window.model.DocumentCollection)

Example 20 with DocumentPath

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);
}
Also used : DocumentValidStatus(de.metas.ui.web.window.model.DocumentValidStatus) DocumentCollection(de.metas.ui.web.window.model.DocumentCollection) ReasonSupplier(de.metas.ui.web.window.model.IDocumentChangesCollector.ReasonSupplier) TableRecordReferenceSet(org.adempiere.util.lang.impl.TableRecordReferenceSet) BigDecimal(java.math.BigDecimal) Evaluatee(org.compiere.util.Evaluatee) Page(de.metas.util.collections.PagedIterator.Page) DocumentFilterList(de.metas.ui.web.document.filter.DocumentFilterList) ImmutableSet(com.google.common.collect.ImmutableSet) DocumentQueryOrderByList(de.metas.ui.web.window.model.DocumentQueryOrderByList) ITranslatableString(de.metas.i18n.ITranslatableString) NonNull(lombok.NonNull) Collection(java.util.Collection) Set(java.util.Set) ITrxManager(org.adempiere.ad.trx.api.ITrxManager) Objects(java.util.Objects) EntityNotFoundException(de.metas.ui.web.exceptions.EntityNotFoundException) List(java.util.List) Stream(java.util.stream.Stream) DocumentFieldWidgetType(de.metas.ui.web.window.descriptor.DocumentFieldWidgetType) TranslatableStrings(de.metas.i18n.TranslatableStrings) LogManager(de.metas.logging.LogManager) DocumentPath(de.metas.ui.web.window.datatypes.DocumentPath) Getter(lombok.Getter) JSONDocumentChangedEvent(de.metas.ui.web.window.datatypes.json.JSONDocumentChangedEvent) DocumentId(de.metas.ui.web.window.datatypes.DocumentId) SqlOptions(de.metas.ui.web.window.model.sql.SqlOptions) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) JSONViewDataType(de.metas.ui.web.view.json.JSONViewDataType) NullDocumentChangesCollector(de.metas.ui.web.window.model.NullDocumentChangesCollector) HashSet(java.util.HashSet) LinkedHashMap(java.util.LinkedHashMap) FacetFilterViewCacheMap(de.metas.ui.web.document.filter.provider.standard.FacetFilterViewCacheMap) IteratorUtils(de.metas.util.collections.IteratorUtils) ImmutableList(com.google.common.collect.ImmutableList) DocumentFilter(de.metas.ui.web.document.filter.DocumentFilter) LookupValuesList(de.metas.ui.web.window.datatypes.LookupValuesList) Nullable(javax.annotation.Nullable) DocumentIdsSelection(de.metas.ui.web.window.datatypes.DocumentIdsSelection) Logger(org.slf4j.Logger) MoreObjects(com.google.common.base.MoreObjects) DocumentFilterDescriptorsProvider(de.metas.ui.web.document.filter.provider.DocumentFilterDescriptorsProvider) DocumentSaveStatus(de.metas.ui.web.window.model.DocumentSaveStatus) CCache(de.metas.cache.CCache) Services(de.metas.util.Services) NumberUtils(de.metas.util.NumberUtils) Consumer(java.util.function.Consumer) AdempiereException(org.adempiere.exceptions.AdempiereException) ViewChangesCollector(de.metas.ui.web.view.event.ViewChangesCollector) Document(de.metas.ui.web.window.model.Document) ITrxManager(org.adempiere.ad.trx.api.ITrxManager) DocumentId(de.metas.ui.web.window.datatypes.DocumentId) DocumentPath(de.metas.ui.web.window.datatypes.DocumentPath) DocumentCollection(de.metas.ui.web.window.model.DocumentCollection)

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