Search in sources :

Example 91 with DocumentId

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

the class SqlViewRowIdsOrderedSelectionFactory method addRowIdsToSelection.

@Override
public ViewRowIdsOrderedSelection addRowIdsToSelection(final ViewRowIdsOrderedSelection selection, final DocumentIdsSelection rowIds) {
    if (rowIds.isEmpty()) {
        // nothing changed
        return selection;
    } else if (rowIds.isAll()) {
        throw new IllegalArgumentException("Cannot add ALL to selection");
    }
    // 
    // Add
    boolean hasChanges = false;
    final String selectionId = selection.getSelectionId();
    // TODO: add all rowIds in one query!!! Not so urgent because usually there are added just a couple of rowIds, not much
    for (final DocumentId rowId : rowIds.toSet()) {
        final SqlAndParams sqlAdd = newSqlViewSelectionQueryBuilder().buildSqlAddRowIdsFromSelection(selectionId, rowId);
        final int added = DB.executeUpdateEx(sqlAdd.getSql(), sqlAdd.getSqlParamsArray(), ITrx.TRXNAME_ThreadInherited);
        if (added <= 0) {
            continue;
        }
        hasChanges = true;
    }
    if (!hasChanges) {
        // nothing changed
        return selection;
    }
    // 
    // Retrieve current size
    // NOTE: we are querying it instead of adding how many we added to current "size" because it might be that the size is staled
    final int size = retrieveSize(selectionId);
    return selection.toBuilder().setSize(size).build();
}
Also used : DocumentId(de.metas.ui.web.window.datatypes.DocumentId) SqlAndParams(de.metas.ui.web.view.descriptor.SqlAndParams) WindowMaxQueryRecordsConstraint(org.adempiere.ad.security.permissions.WindowMaxQueryRecordsConstraint)

Example 92 with DocumentId

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

the class QuickInputDescriptorFactoryService method getQuickInputEntityDescriptor.

public QuickInputDescriptor getQuickInputEntityDescriptor(final DocumentEntityDescriptor includedDocumentDescriptor) {
    final DocumentType documentType = includedDocumentDescriptor.getDocumentType();
    final DocumentId documentTypeId = includedDocumentDescriptor.getDocumentTypeId();
    final String tableName = includedDocumentDescriptor.getTableNameOrNull();
    final DetailId detailId = includedDocumentDescriptor.getDetailId();
    final Optional<Boolean> soTrx = includedDocumentDescriptor.getIsSOTrx();
    return getQuickInputEntityDescriptor(documentType, documentTypeId, tableName, detailId, soTrx);
}
Also used : DetailId(de.metas.ui.web.window.descriptor.DetailId) DocumentId(de.metas.ui.web.window.datatypes.DocumentId) DocumentType(de.metas.ui.web.window.datatypes.DocumentType)

Example 93 with DocumentId

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

the class ViewRowAttributesRestController method getData.

@GetMapping
public JSONViewRowAttributes getData(// 
@PathVariable(PARAM_WindowId) final String windowIdStr, // 
@PathVariable(PARAM_ViewId) final String viewIdStr, // 
@PathVariable(PARAM_RowId) final String rowIdStr) {
    userSession.assertLoggedIn();
    final ViewId viewId = ViewId.of(windowIdStr, viewIdStr);
    final DocumentId rowId = DocumentId.of(rowIdStr);
    return viewsRepo.getView(viewId).getById(rowId).getAttributes().toJson(newJSONOptions());
}
Also used : DocumentId(de.metas.ui.web.window.datatypes.DocumentId) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Example 94 with DocumentId

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

the class ViewRowAttributesRestController method processChanges.

@PatchMapping
public List<JSONDocument> processChanges(// 
@PathVariable(PARAM_WindowId) final String windowIdStr, // 
@PathVariable(PARAM_ViewId) final String viewIdStr, // 
@PathVariable(PARAM_RowId) final String rowIdStr, // 
@RequestBody final List<JSONDocumentChangedEvent> events) {
    userSession.assertLoggedIn();
    final ViewId viewId = ViewId.of(windowIdStr, viewIdStr);
    final DocumentId rowId = DocumentId.of(rowIdStr);
    return Execution.callInNewExecution("processChanges", () -> {
        viewsRepo.getView(viewId).getById(rowId).getAttributes().processChanges(events);
        return JSONDocument.ofEvents(Execution.getCurrentDocumentChangesCollectorOrNull(), newJSONOptions());
    });
}
Also used : DocumentId(de.metas.ui.web.window.datatypes.DocumentId) PatchMapping(org.springframework.web.bind.annotation.PatchMapping)

Example 95 with DocumentId

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

the class ViewRowAttributesRestController method getAttributeTypeahead.

@GetMapping("/attribute/{attributeName}/typeahead")
public JSONLookupValuesList getAttributeTypeahead(// 
@PathVariable(PARAM_WindowId) final String windowIdStr, // 
@PathVariable(PARAM_ViewId) final String viewIdStr, // 
@PathVariable(PARAM_RowId) final String rowIdStr, // 
@PathVariable("attributeName") final String attributeName, // 
@RequestParam(name = "query", required = true) final String query) {
    userSession.assertLoggedIn();
    final ViewId viewId = ViewId.of(windowIdStr, viewIdStr);
    final DocumentId rowId = DocumentId.of(rowIdStr);
    return viewsRepo.getView(viewId).getById(rowId).getAttributes().getAttributeTypeahead(attributeName, query).transform(JSONLookupValuesList::ofLookupValuesList);
}
Also used : 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