From c2e4df03798a4feffd4070f622ba80a1ef25d8eb Mon Sep 17 00:00:00 2001 From: Ralph Soika Date: Fri, 9 May 2025 17:56:46 +0200 Subject: [PATCH] new DataView feature --- ...ontroller.java => DataViewController.java} | 80 ++++++++-- ...ava => DataViewDefinitionsController.java} | 4 +- .../layout/commandbox_admin_custom.xhtml | 2 +- ...inition.xhtml => dataViewDefinition.xhtml} | 137 ++++++++---------- ...itions.xhtml => dataViewDefinitions.xhtml} | 23 ++- 5 files changed, 147 insertions(+), 99 deletions(-) rename office-alexander-logistics-app/src/main/java/org/imixs/workflow/office/reporting/{ReportingController.java => DataViewController.java} (59%) rename office-alexander-logistics-app/src/main/java/org/imixs/workflow/office/views/{ReportingViewController.java => DataViewDefinitionsController.java} (88%) rename office-alexander-logistics-app/src/main/webapp/pages/admin/{reportingDefinition.xhtml => dataViewDefinition.xhtml} (58%) rename office-alexander-logistics-app/src/main/webapp/pages/admin/{reportingDefinitions.xhtml => dataViewDefinitions.xhtml} (83%) diff --git a/office-alexander-logistics-app/src/main/java/org/imixs/workflow/office/reporting/ReportingController.java b/office-alexander-logistics-app/src/main/java/org/imixs/workflow/office/reporting/DataViewController.java similarity index 59% rename from office-alexander-logistics-app/src/main/java/org/imixs/workflow/office/reporting/ReportingController.java rename to office-alexander-logistics-app/src/main/java/org/imixs/workflow/office/reporting/DataViewController.java index 5f91ee0..77c7d55 100644 --- a/office-alexander-logistics-app/src/main/java/org/imixs/workflow/office/reporting/ReportingController.java +++ b/office-alexander-logistics-app/src/main/java/org/imixs/workflow/office/reporting/DataViewController.java @@ -25,6 +25,7 @@ package org.imixs.workflow.office.reporting; import java.io.Serializable; import java.util.ArrayList; +import java.util.Collections; import java.util.List; import java.util.Map; import java.util.logging.Logger; @@ -32,6 +33,9 @@ import java.util.logging.Logger; import org.imixs.workflow.ItemCollection; import org.imixs.workflow.engine.DocumentEvent; import org.imixs.workflow.engine.DocumentService; +import org.imixs.workflow.office.forms.ChildItemController; + +import com.oracle.svm.core.annotate.Inject; import jakarta.annotation.PostConstruct; import jakarta.ejb.EJB; @@ -48,7 +52,7 @@ import jakarta.inject.Named; @Named @SessionScoped -public class ReportingController implements Serializable { +public class DataViewController implements Serializable { private static final long serialVersionUID = 1L; @@ -57,7 +61,10 @@ public class ReportingController implements Serializable { @EJB DocumentService documentService; - private static Logger logger = Logger.getLogger(ReportingController.class.getName()); + @Inject + ChildItemController childItemController; + + private static Logger logger = Logger.getLogger(DataViewController.class.getName()); /** * @@ -68,9 +75,9 @@ public class ReportingController implements Serializable { } - public void setAttributeList(List attributeList) { - this.attributeList = attributeList; - } + // public void setAttributeList(List attributeList) { + // this.attributeList = attributeList; + // } public List getAttributeList() { return attributeList; @@ -88,22 +95,25 @@ public class ReportingController implements Serializable { } // update attribute list if (event.getEventType() == DocumentEvent.ON_DOCUMENT_SAVE) { + // convert the option ItemCollection elements into a List of Map if (attributeList != null) { List mapItemList = new ArrayList(); logger.fine("Convert option items into Map..."); // iterate over all items.. for (ItemCollection attrItem : attributeList) { - mapItemList.add(attrItem.getAllItems()); + ItemCollection ding = (ItemCollection) attrItem.clone(); + mapItemList.add(ding.getAllItems()); } - event.getDocument().replaceItemValue("attributes", mapItemList); + event.getDocument().replaceItemValue("report.items", mapItemList); + } } // update attribute list if (event.getEventType() == DocumentEvent.ON_DOCUMENT_LOAD) { attributeList = new ArrayList(); - List mapItems = event.getDocument().getItemValue("attributes"); + List mapItems = event.getDocument().getItemValue("report.items"); for (Object mapOderItem : mapItems) { if (mapOderItem instanceof Map) { ItemCollection itemCol = new ItemCollection((Map) mapOderItem); @@ -132,13 +142,61 @@ public class ReportingController implements Serializable { */ public void removeAttribute(String name) { if (name != null && attributeList != null) { - for (ItemCollection dbtr : attributeList) { - if (name.equals(dbtr.getItemValueString("name"))) { - attributeList.remove(dbtr); + for (ItemCollection item : attributeList) { + if (name.equals(item.getItemValueString("item.name"))) { + attributeList.remove(item); break; } } } } + /** + * Moves an attribute item up in the list + * + * List attributeList + * + * @param name - name of attribute + */ + public void moveAttributeUp(String name) { + if (name != null && attributeList != null) { + logger.info("move up: " + name); + for (int i = 0; i < attributeList.size(); i++) { + ItemCollection item = attributeList.get(i); + if (name.equals(item.getItemValueString("item.name"))) { + // Check if it's not already at the top + if (i > 0) { + // Swap with previous element + Collections.swap(attributeList, i, i - 1); + } + break; // Exit loop once found and processed + } + } + } + } + + /** + * Moves an attribute item up down the list + * + * List attributeList + * + * @param name - name of attribute + */ + public void moveAttributeDown(String name) { + if (name != null && attributeList != null) { + logger.info("move down: " + name); + for (int i = 0; i < attributeList.size(); i++) { + ItemCollection item = attributeList.get(i); + if (name.equals(item.getItemValueString("item.name"))) { + // Check if it's not already at the bottom + if (i < attributeList.size() - 1) { + // Swap with next element + Collections.swap(attributeList, i, i + 1); + } + break; // Exit loop once found and processed + } + } + } + } + } diff --git a/office-alexander-logistics-app/src/main/java/org/imixs/workflow/office/views/ReportingViewController.java b/office-alexander-logistics-app/src/main/java/org/imixs/workflow/office/views/DataViewDefinitionsController.java similarity index 88% rename from office-alexander-logistics-app/src/main/java/org/imixs/workflow/office/views/ReportingViewController.java rename to office-alexander-logistics-app/src/main/java/org/imixs/workflow/office/views/DataViewDefinitionsController.java index 012ecd9..6752405 100644 --- a/office-alexander-logistics-app/src/main/java/org/imixs/workflow/office/views/ReportingViewController.java +++ b/office-alexander-logistics-app/src/main/java/org/imixs/workflow/office/views/DataViewDefinitionsController.java @@ -11,7 +11,7 @@ import jakarta.inject.Named; @Named @ViewScoped -public class ReportingViewController extends ViewController { +public class DataViewDefinitionsController extends ViewController { private static final long serialVersionUID = 1L; @@ -26,7 +26,7 @@ public class ReportingViewController extends ViewController { @PostConstruct public void init() { super.init(); - this.setQuery("(type:\"reporting\")"); + this.setQuery("(type:\"dataview\")"); this.setSortBy("txtname"); this.setSortReverse(false); this.setPageSize(adminViewPageSize); diff --git a/office-alexander-logistics-app/src/main/webapp/layout/commandbox_admin_custom.xhtml b/office-alexander-logistics-app/src/main/webapp/layout/commandbox_admin_custom.xhtml index 68a4fd0..3837618 100644 --- a/office-alexander-logistics-app/src/main/webapp/layout/commandbox_admin_custom.xhtml +++ b/office-alexander-logistics-app/src/main/webapp/layout/commandbox_admin_custom.xhtml @@ -15,7 +15,7 @@ Analyse Rechnungseingang
  • - Reportings + Data Views
  • diff --git a/office-alexander-logistics-app/src/main/webapp/pages/admin/reportingDefinition.xhtml b/office-alexander-logistics-app/src/main/webapp/pages/admin/dataViewDefinition.xhtml similarity index 58% rename from office-alexander-logistics-app/src/main/webapp/pages/admin/reportingDefinition.xhtml rename to office-alexander-logistics-app/src/main/webapp/pages/admin/dataViewDefinition.xhtml index e23fddb..9bb297e 100644 --- a/office-alexander-logistics-app/src/main/webapp/pages/admin/reportingDefinition.xhtml +++ b/office-alexander-logistics-app/src/main/webapp/pages/admin/dataViewDefinition.xhtml @@ -18,7 +18,7 @@

    - +

    @@ -39,7 +39,7 @@
    -

    Query Definition

    +

    Query Definition

    A Query Defintion defines a custom data list based on the + style="height: 14em; font-family: 'Courier New', Courier, monospace; autocomplete: off;" />

    @@ -97,58 +97,54 @@ aggregator.

    - + - - - - - - + + + + - + - - - - - - - - - - - - @@ -159,7 +155,7 @@ + actionListener="#{dataViewController.addAttribute}"> @@ -174,22 +170,20 @@
    -

    Form Definition

    -

    - The Form Definition defines query and filter parameters. -

    +

    Form Definition

    +

    + The Form Definition defines query and filter parameters. +

    +
    - Form: * - - + Form:
    -
    + style="height: 27em; font-family: 'Courier New', Courier, monospace; autocomplete: off;" />
    @@ -198,39 +192,30 @@
    - - -
    -
    - -

    Template

    +

    Template

    -
    #{message['form.minutes.description']}:
    -
    - - - - - - +
    +
    + POI Update: +
    +
    - + value="#{documentController.document.item['poi.update']}" + style="height: 27em; font-family: 'Courier New', Courier, monospace; autocomplete: off;" /> +
    +
    -
    - +
    + -
    +
    + -
    @@ -242,15 +227,15 @@
    IDBank - *IBANBICReport (optional) - + ItemLabelConvertFormat +
    - - - - - - + - + actionListener="#{dataViewController.moveAttributeDown(attribute.item['item.name'])}"> + + onevent="updateAttributeList" /> + + + + + + + +