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