Search in sources :

Example 1 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 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);
}
Also used : IBPartnerDAO(org.adempiere.bpartner.service.IBPartnerDAO) I_AD_User(org.compiere.model.I_AD_User) ArrayList(java.util.ArrayList) 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 2 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 3 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 4 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 -> {
        // 
        // 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);
}
Also used : CCache(org.compiere.util.CCache) 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) BigDecimal(java.math.BigDecimal) Evaluatee(org.compiere.util.Evaluatee) TableRecordReference(org.adempiere.util.lang.impl.TableRecordReference) JSONDocumentFilter(de.metas.ui.web.document.filter.json.JSONDocumentFilter) ImmutableSet(com.google.common.collect.ImmutableSet) ITranslatableString(de.metas.i18n.ITranslatableString) NonNull(lombok.NonNull) Collection(java.util.Collection) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) Set(java.util.Set) Objects(java.util.Objects) ITrxManager(org.adempiere.ad.trx.api.ITrxManager) Services(org.adempiere.util.Services) EntityNotFoundException(de.metas.ui.web.exceptions.EntityNotFoundException) List(java.util.List) Stream(java.util.stream.Stream) DocumentFieldWidgetType(de.metas.ui.web.window.descriptor.DocumentFieldWidgetType) ImmutableTranslatableString(de.metas.i18n.ImmutableTranslatableString) LogManager(de.metas.logging.LogManager) Iterables(com.google.common.collect.Iterables) DocumentPath(de.metas.ui.web.window.datatypes.DocumentPath) Getter(lombok.Getter) JSONDocumentChangedEvent(de.metas.ui.web.window.datatypes.json.JSONDocumentChangedEvent) DocumentFilterDescriptorsProvider(de.metas.ui.web.document.filter.DocumentFilterDescriptorsProvider) DocumentId(de.metas.ui.web.window.datatypes.DocumentId) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) SqlOptions(de.metas.ui.web.window.model.sql.SqlOptions) JSONViewDataType(de.metas.ui.web.view.json.JSONViewDataType) ExtendedMemorizingSupplier(org.adempiere.util.lang.ExtendedMemorizingSupplier) ArrayList(java.util.ArrayList) NullDocumentChangesCollector(de.metas.ui.web.window.model.NullDocumentChangesCollector) LinkedHashMap(java.util.LinkedHashMap) ImmutableList(com.google.common.collect.ImmutableList) Predicates(com.google.common.base.Predicates) DocumentFilter(de.metas.ui.web.document.filter.DocumentFilter) LookupValuesList(de.metas.ui.web.window.datatypes.LookupValuesList) DocumentQueryOrderBy(de.metas.ui.web.window.model.DocumentQueryOrderBy) Nullable(javax.annotation.Nullable) DocumentIdsSelection(de.metas.ui.web.window.datatypes.DocumentIdsSelection) Logger(org.slf4j.Logger) MoreObjects(com.google.common.base.MoreObjects) DocumentSaveStatus(de.metas.ui.web.window.model.DocumentSaveStatus) NumberUtils(org.adempiere.util.NumberUtils) AdempiereException(org.adempiere.exceptions.AdempiereException) ViewChangesCollector(de.metas.ui.web.view.event.ViewChangesCollector) ITrxManager(org.adempiere.ad.trx.api.ITrxManager) DocumentSaveStatus(de.metas.ui.web.window.model.DocumentSaveStatus) AdempiereException(org.adempiere.exceptions.AdempiereException) DocumentId(de.metas.ui.web.window.datatypes.DocumentId) DocumentPath(de.metas.ui.web.window.datatypes.DocumentPath) DocumentValidStatus(de.metas.ui.web.window.model.DocumentValidStatus) DocumentCollection(de.metas.ui.web.window.model.DocumentCollection)

Example 5 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)

Aggregations

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