Search in sources :

Example 76 with DocumentId

use of de.metas.ui.web.window.datatypes.DocumentId in project metasfresh-webui-api by metasfresh.

the class WEBUI_SalesOrder_Apply_Availability_Row method doIt.

@Override
protected String doIt() throws Exception {
    final // 
    Multimap<PurchaseRow, PurchaseRow> lineRows2availabilityRows = extractLineRow2availabilityRows();
    Check.errorIf(hasMultipleAvailabilityRowsPerLineRow(lineRows2availabilityRows), "The selected rows contain > 1 availability row for one line row; lineRows2availabilityRows={}", lineRows2availabilityRows);
    final Set<DocumentId> documentIdsToUpdate = new HashSet<>();
    for (final Entry<PurchaseRow, PurchaseRow> lineRow2availabilityRow : lineRows2availabilityRows.entries()) {
        final DocumentId groupRowDocumentId = updateLineAndGroupRow(lineRow2availabilityRow);
        documentIdsToUpdate.add(groupRowDocumentId);
    }
    ViewChangesCollector.getCurrentOrAutoflush().collectRowsChanged(getView(), DocumentIdsSelection.of(documentIdsToUpdate));
    return MSG_OK;
}
Also used : PurchaseRow(de.metas.ui.web.order.sales.purchasePlanning.view.PurchaseRow) DocumentId(de.metas.ui.web.window.datatypes.DocumentId) HashSet(java.util.HashSet)

Example 77 with DocumentId

use of de.metas.ui.web.window.datatypes.DocumentId in project metasfresh-webui-api by metasfresh.

the class WEBUI_SalesOrder_Apply_Availability_Row method updateLineAndGroupRow.

public DocumentId updateLineAndGroupRow(@NonNull final Entry<PurchaseRow, PurchaseRow> lineRow2availabilityRow) {
    final PurchaseRow lineRow = lineRow2availabilityRow.getKey();
    final PurchaseRowId lineRowId = PurchaseRowId.fromDocumentId(lineRow.getId());
    final DocumentId groupRowDocumentId = lineRowId.toGroupRowId().toDocumentId();
    final PurchaseRow groupRow = getView().getById(groupRowDocumentId);
    final PurchaseRow availabilityRow = lineRow2availabilityRow.getValue();
    if (availabilityRow.getDatePromised() != null) {
        groupRow.changeDatePromised(lineRowId, availabilityRow.getDatePromised());
    }
    groupRow.changeQtyToPurchase(lineRowId, availabilityRow.getQtyToPurchase());
    return groupRowDocumentId;
}
Also used : PurchaseRow(de.metas.ui.web.order.sales.purchasePlanning.view.PurchaseRow) DocumentId(de.metas.ui.web.window.datatypes.DocumentId) PurchaseRowId(de.metas.ui.web.order.sales.purchasePlanning.view.PurchaseRowId)

Example 78 with DocumentId

use of de.metas.ui.web.window.datatypes.DocumentId in project metasfresh-webui-api by metasfresh.

the class ASIRepository method commit.

private final void commit(final ASIDocument asiDoc) {
    final DocumentId asiDocId = asiDoc.getDocumentId();
    if (asiDoc.isCompleted()) {
        final ASIDocument asiDocRemoved = id2asiDoc.remove(asiDocId);
        logger.trace("Removed from repository by ID={}: {}", asiDocId, asiDocRemoved);
    } else {
        final ASIDocument asiDocReadonly = asiDoc.copy(CopyMode.CheckInReadonly, NullDocumentChangesCollector.instance);
        id2asiDoc.put(asiDocId, asiDocReadonly);
        logger.trace("Added to repository: {}", asiDocReadonly);
    }
}
Also used : DocumentId(de.metas.ui.web.window.datatypes.DocumentId)

Example 79 with DocumentId

use of de.metas.ui.web.window.datatypes.DocumentId in project metasfresh-webui-api by metasfresh.

the class ASIRestController method getAttributeTypeahead.

@GetMapping("/{asiDocId}/field/{attributeName}/typeahead")
public JSONLookupValuesList getAttributeTypeahead(// 
@PathVariable("asiDocId") final String asiDocIdStr, // 
@PathVariable("attributeName") final String attributeName, // 
@RequestParam(name = "query", required = true) final String query) {
    userSession.assertLoggedIn();
    final DocumentId asiDocId = DocumentId.of(asiDocIdStr);
    return asiRepo.forASIDocumentReadonly(asiDocId, asiDoc -> asiDoc.getFieldLookupValuesForQuery(attributeName, query)).transform(JSONLookupValuesList::ofLookupValuesList);
}
Also used : JSONOptions(de.metas.ui.web.window.datatypes.json.JSONOptions) PathVariable(org.springframework.web.bind.annotation.PathVariable) PostMapping(org.springframework.web.bind.annotation.PostMapping) RequestParam(org.springframework.web.bind.annotation.RequestParam) WebConfig(de.metas.ui.web.config.WebConfig) Execution(de.metas.ui.web.window.controller.Execution) JSONDocumentChangedEvent(de.metas.ui.web.window.datatypes.json.JSONDocumentChangedEvent) DocumentId(de.metas.ui.web.window.datatypes.DocumentId) Autowired(org.springframework.beans.factory.annotation.Autowired) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) JSONCreateASIRequest(de.metas.ui.web.pattribute.json.JSONCreateASIRequest) RestController(org.springframework.web.bind.annotation.RestController) JSONLookupValuesList(de.metas.ui.web.window.datatypes.json.JSONLookupValuesList) PatchMapping(org.springframework.web.bind.annotation.PatchMapping) RequestBody(org.springframework.web.bind.annotation.RequestBody) UserSession(de.metas.ui.web.session.UserSession) List(java.util.List) IDocumentChangesCollector(de.metas.ui.web.window.model.IDocumentChangesCollector) GetMapping(org.springframework.web.bind.annotation.GetMapping) JSONASILayout(de.metas.ui.web.pattribute.json.JSONASILayout) Api(io.swagger.annotations.Api) JSONDocument(de.metas.ui.web.window.datatypes.json.JSONDocument) JSONLookupValue(de.metas.ui.web.window.datatypes.json.JSONLookupValue) DocumentId(de.metas.ui.web.window.datatypes.DocumentId) JSONLookupValuesList(de.metas.ui.web.window.datatypes.json.JSONLookupValuesList) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Example 80 with DocumentId

use of de.metas.ui.web.window.datatypes.DocumentId in project metasfresh-webui-api by metasfresh.

the class ASIRestController method getAttributeDropdown.

@GetMapping("/{asiDocId}/field/{attributeName}/dropdown")
public JSONLookupValuesList getAttributeDropdown(// 
@PathVariable("asiDocId") final String asiDocIdStr, // 
@PathVariable("attributeName") final String attributeName) {
    userSession.assertLoggedIn();
    final DocumentId asiDocId = DocumentId.of(asiDocIdStr);
    return asiRepo.forASIDocumentReadonly(asiDocId, asiDoc -> asiDoc.getFieldLookupValues(attributeName)).transform(JSONLookupValuesList::ofLookupValuesList);
}
Also used : JSONOptions(de.metas.ui.web.window.datatypes.json.JSONOptions) PathVariable(org.springframework.web.bind.annotation.PathVariable) PostMapping(org.springframework.web.bind.annotation.PostMapping) RequestParam(org.springframework.web.bind.annotation.RequestParam) WebConfig(de.metas.ui.web.config.WebConfig) Execution(de.metas.ui.web.window.controller.Execution) JSONDocumentChangedEvent(de.metas.ui.web.window.datatypes.json.JSONDocumentChangedEvent) DocumentId(de.metas.ui.web.window.datatypes.DocumentId) Autowired(org.springframework.beans.factory.annotation.Autowired) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) JSONCreateASIRequest(de.metas.ui.web.pattribute.json.JSONCreateASIRequest) RestController(org.springframework.web.bind.annotation.RestController) JSONLookupValuesList(de.metas.ui.web.window.datatypes.json.JSONLookupValuesList) PatchMapping(org.springframework.web.bind.annotation.PatchMapping) RequestBody(org.springframework.web.bind.annotation.RequestBody) UserSession(de.metas.ui.web.session.UserSession) List(java.util.List) IDocumentChangesCollector(de.metas.ui.web.window.model.IDocumentChangesCollector) GetMapping(org.springframework.web.bind.annotation.GetMapping) JSONASILayout(de.metas.ui.web.pattribute.json.JSONASILayout) Api(io.swagger.annotations.Api) JSONDocument(de.metas.ui.web.window.datatypes.json.JSONDocument) JSONLookupValue(de.metas.ui.web.window.datatypes.json.JSONLookupValue) DocumentId(de.metas.ui.web.window.datatypes.DocumentId) JSONLookupValuesList(de.metas.ui.web.window.datatypes.json.JSONLookupValuesList) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Aggregations

DocumentId (de.metas.ui.web.window.datatypes.DocumentId)99 DocumentPath (de.metas.ui.web.window.datatypes.DocumentPath)18 DocumentIdsSelection (de.metas.ui.web.window.datatypes.DocumentIdsSelection)14 List (java.util.List)14 ImmutableList (com.google.common.collect.ImmutableList)12 GetMapping (org.springframework.web.bind.annotation.GetMapping)12 AdempiereException (org.adempiere.exceptions.AdempiereException)11 JSONLookupValuesList (de.metas.ui.web.window.datatypes.json.JSONLookupValuesList)9 ArrayList (java.util.ArrayList)9 Set (java.util.Set)9 NonNull (lombok.NonNull)9 Test (org.junit.Test)9 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)9 UserSession (de.metas.ui.web.session.UserSession)8 ViewId (de.metas.ui.web.view.ViewId)8 DocumentEntityDescriptor (de.metas.ui.web.window.descriptor.DocumentEntityDescriptor)8 Document (de.metas.ui.web.window.model.Document)8 IDocumentChangesCollector (de.metas.ui.web.window.model.IDocumentChangesCollector)8 TableRecordReference (org.adempiere.util.lang.impl.TableRecordReference)8 Autowired (org.springframework.beans.factory.annotation.Autowired)8