diff --git a/.vscode/settings.json b/.vscode/settings.json index c7a7554..0fbb2f0 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -8,8 +8,5 @@ "editor.codeActionsOnSave": { "source.organizeImports": "explicit" }, - "java.checkstyle.version": "8.44", - "java.checkstyle.autocheck": true, - "java.checkstyle.configuration": "https://raw.githubusercontent.com/imixs/imixs-workflow/master/imixs-checkstyle-8.44.xml", - "java.configuration.updateBuildConfiguration": "automatic" + "java.format.settings.url": "https://raw.githubusercontent.com/imixs/imixs-workflow/refs/heads/master/imixs-code-style.xml" } \ No newline at end of file diff --git a/office-alexander-logistics-app/src/main/java/org/imixs/workflow/office/dataview/DataViewController.java b/office-alexander-logistics-app/src/main/java/org/imixs/workflow/office/dataview/DataViewController.java new file mode 100644 index 0000000..08094be --- /dev/null +++ b/office-alexander-logistics-app/src/main/java/org/imixs/workflow/office/dataview/DataViewController.java @@ -0,0 +1,194 @@ +/******************************************************************************* + * Imixs Workflow Technology + * Copyright (C) 2003, 2008 Imixs Software Solutions GmbH, + * http://www.imixs.com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You can receive a copy of the GNU General Public + * License at http://www.gnu.org/licenses/gpl.html + * + * Contributors: + * Imixs Software Solutions GmbH - initial API and implementation + * Ralph Soika + * + *******************************************************************************/ +package org.imixs.workflow.office.dataview; + +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.List; +import java.util.logging.Logger; +import java.util.regex.Pattern; + +import org.imixs.workflow.ItemCollection; +import org.imixs.workflow.exceptions.AccessDeniedException; +import org.imixs.workflow.exceptions.ModelException; +import org.imixs.workflow.faces.data.AbstractDataController; +import org.imixs.workflow.office.forms.CustomFormController; +import org.imixs.workflow.office.forms.CustomFormSection; + +import jakarta.annotation.PostConstruct; +import jakarta.enterprise.context.ConversationScoped; +import jakarta.inject.Inject; +import jakarta.inject.Named; + +/** + * The DataViewController is used to display a data view + * + * @author rsoika + * @version 1.0 + */ +@Named +@ConversationScoped +public class DataViewController extends AbstractDataController { + + private static final long serialVersionUID = 1L; + private List sections; + private String errorMessage; + + @Inject + CustomFormController customFormController; + + private ItemCollection filter; + private String query; + + private static Logger logger = Logger.getLogger(DataViewController.class.getName()); + + /** + * + * + */ + @PostConstruct + public void init() { + + } + + public ItemCollection getDefinition() { + return data; + } + + public List getSections() { + return sections; + } + + /** + * This method loads the custom form sections + */ + @Override + public void onLoad() { + filter = new ItemCollection(); + super.onLoad(); + startConversation(); + try { + // Init new Filter.... + if (data != null) { + filter.setItemValue("txtWorkflowEditorCustomForm", data.getItemValue("form")); + customFormController.computeFieldDefinition(filter); + sections = customFormController.getSections(); + } + } catch (ModelException e) { + logger.warning("Failed to load dataview definition: " + e.getMessage()); + } + + } + + public ItemCollection getFilter() { + return filter; + } + + public void setFilter(ItemCollection filter) { + this.filter = filter; + } + + public String getErrorMessage() { + return errorMessage; + } + + public void setErrorMessage(String errorMessage) { + this.errorMessage = errorMessage; + } + + /** + * This helper method builds a query from the query definition and the current + * filter criteria. + * + * The method loads the query form the definition and replaces all {} + * elements with the values from the filter + * + * + * @throws AccessDeniedException - if user has insufficient access rights. + */ + public void run() throws AccessDeniedException { + + Date date = filter.getItemValueDate("date.from"); + logger.info(" date=" + date); + + query = data.getItemValueString("query"); + + List filterItems = filter.getItemNames(); + for (String itemName : filterItems) { + String itemValue = filter.getItemValueString(itemName); + + // is date? + if (filter.getItemValueDate(itemName) != null) { + String sDateFrom = "191401070000"; // because * did not work here + String sDateTo = "211401070000"; + SimpleDateFormat dateformat = new SimpleDateFormat("yyyyMMddHHmm"); + + itemValue = dateformat.format(filter.getItemValueDate(itemName)); + + } + + // Create regex pattern to match {itemName} (case-sensitive) + // The Pattern.quote is used to escape any special regex characters in the + // itemName + // Replace all occurrences in the query case-insensitive. + query = query.replaceAll("(?i)\\{" + Pattern.quote(itemName) + "\\}", itemValue); + } + logger.info("query=" + query); + + } + + /** + * Returns the current query + * + * @return + */ + public String getQuery() { + return query; + } + + /** + * Returns the current workItem. If no workitem is defined the method + * Instantiates a empty ItemCollection. + * + * @return - current workItem or null if not set + */ + public ItemCollection getData() { + // do initialize an empty workItem here if null + if (data == null) { + reset(); + } + return data; + } + + /** + * Set the current worktItem + * + * @param workitem - new reference or null to clear the current workItem. + */ + public void setData(ItemCollection document) { + this.data = document; + + } + +} diff --git a/office-alexander-logistics-app/src/main/java/org/imixs/workflow/office/reporting/DataViewController.java b/office-alexander-logistics-app/src/main/java/org/imixs/workflow/office/dataview/DataViewDefinitionController.java similarity index 65% rename from office-alexander-logistics-app/src/main/java/org/imixs/workflow/office/reporting/DataViewController.java rename to office-alexander-logistics-app/src/main/java/org/imixs/workflow/office/dataview/DataViewDefinitionController.java index 77c7d55..d723578 100644 --- a/office-alexander-logistics-app/src/main/java/org/imixs/workflow/office/reporting/DataViewController.java +++ b/office-alexander-logistics-app/src/main/java/org/imixs/workflow/office/dataview/DataViewDefinitionController.java @@ -21,9 +21,8 @@ * Ralph Soika * *******************************************************************************/ -package org.imixs.workflow.office.reporting; +package org.imixs.workflow.office.dataview; -import java.io.Serializable; import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -32,39 +31,41 @@ 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.exceptions.AccessDeniedException; +import org.imixs.workflow.faces.data.AbstractDataController; +import org.imixs.workflow.faces.data.DocumentController; import org.imixs.workflow.office.forms.ChildItemController; import com.oracle.svm.core.annotate.Inject; import jakarta.annotation.PostConstruct; -import jakarta.ejb.EJB; -import jakarta.enterprise.context.SessionScoped; +import jakarta.enterprise.context.ConversationScoped; import jakarta.enterprise.event.Observes; +import jakarta.faces.context.ExternalContext; +import jakarta.faces.context.FacesContext; import jakarta.inject.Named; /** - * The ReportingConfigController is used to configure a reporting definition + * The DataViewDefinitionController is used to configure a dataview definition * * @author rsoika * @version 1.0 */ - @Named -@SessionScoped -public class DataViewController implements Serializable { +@ConversationScoped +public class DataViewDefinitionController extends AbstractDataController { private static final long serialVersionUID = 1L; protected List attributeList = null; - @EJB - DocumentService documentService; - @Inject ChildItemController childItemController; - private static Logger logger = Logger.getLogger(DataViewController.class.getName()); + @Inject + DocumentController documentController; + + private static Logger logger = Logger.getLogger(DataViewDefinitionController.class.getName()); /** * @@ -75,9 +76,60 @@ public class DataViewController implements Serializable { } - // public void setAttributeList(List attributeList) { - // this.attributeList = attributeList; - // } + /** + * Returns the current workItem. If no workitem is defined the method + * Instantiates a empty ItemCollection. + * + * @return - current workItem or null if not set + */ + public ItemCollection getData() { + // do initialize an empty workItem here if null + if (data == null) { + reset(); + } + return data; + } + + /** + * Set the current worktItem + * + * @param workitem - new reference or null to clear the current workItem. + */ + public void setData(ItemCollection document) { + this.data = document; + + attributeList = new ArrayList(); + List mapItems = data.getItemValue("dataview.items"); + for (Object mapOderItem : mapItems) { + if (mapOderItem instanceof Map) { + ItemCollection itemCol = new ItemCollection((Map) mapOderItem); + attributeList.add(itemCol); + } + } + + } + + /** + * This method saves the current document. + * + * @throws AccessDeniedException - if user has insufficient access rights. + */ + public void save() throws AccessDeniedException { + // save definition ... + FacesContext context = FacesContext.getCurrentInstance(); + ExternalContext externalContext = context + .getExternalContext(); + String sUser = externalContext.getRemoteUser(); + data.replaceItemValue("$editor", sUser); + data = this.getDocumentService().save(data); + + logger.finest("......ItemCollection saved"); + } + + public String openTestView() { + this.save(); + return "/pages/dataviews/data.xhtml?id=" + data.getUniqueID() + "&faces-redirect=true"; + } public List getAttributeList() { return attributeList; @@ -90,7 +142,7 @@ public class DataViewController implements Serializable { */ public void onEvent(@Observes DocumentEvent event) { - if (event == null || event.getDocument() == null || !"reporting".equals(event.getDocument().getType())) { + if (event == null || event.getDocument() == null || !"dataview".equals(event.getDocument().getType())) { return; } // update attribute list @@ -105,21 +157,14 @@ public class DataViewController implements Serializable { ItemCollection ding = (ItemCollection) attrItem.clone(); mapItemList.add(ding.getAllItems()); } - event.getDocument().replaceItemValue("report.items", mapItemList); + event.getDocument().replaceItemValue("dataview.items", mapItemList); } } // update attribute list if (event.getEventType() == DocumentEvent.ON_DOCUMENT_LOAD) { - attributeList = new ArrayList(); - List mapItems = event.getDocument().getItemValue("report.items"); - for (Object mapOderItem : mapItems) { - if (mapOderItem instanceof Map) { - ItemCollection itemCol = new ItemCollection((Map) mapOderItem); - attributeList.add(itemCol); - } - } + } } @@ -187,7 +232,8 @@ public class DataViewController implements Serializable { 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"))) { + 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 diff --git a/office-alexander-logistics-app/src/main/java/org/imixs/workflow/office/views/DataViewDefinitionsController.java b/office-alexander-logistics-app/src/main/java/org/imixs/workflow/office/dataview/DataViewDefinitionsController.java similarity index 84% rename from office-alexander-logistics-app/src/main/java/org/imixs/workflow/office/views/DataViewDefinitionsController.java rename to office-alexander-logistics-app/src/main/java/org/imixs/workflow/office/dataview/DataViewDefinitionsController.java index 6752405..ba44786 100644 --- a/office-alexander-logistics-app/src/main/java/org/imixs/workflow/office/views/DataViewDefinitionsController.java +++ b/office-alexander-logistics-app/src/main/java/org/imixs/workflow/office/dataview/DataViewDefinitionsController.java @@ -1,8 +1,7 @@ -package org.imixs.workflow.office.views; +package org.imixs.workflow.office.dataview; import org.eclipse.microprofile.config.inject.ConfigProperty; import org.imixs.workflow.faces.data.ViewController; -import org.imixs.workflow.faces.util.LoginController; import jakarta.annotation.PostConstruct; import jakarta.faces.view.ViewScoped; @@ -15,9 +14,6 @@ public class DataViewDefinitionsController extends ViewController { private static final long serialVersionUID = 1L; - @Inject - LoginController loginController; - @Inject @ConfigProperty(name = "admin.view.entries.max", defaultValue = "999") transient int adminViewPageSize; diff --git a/office-alexander-logistics-app/src/main/java/org/imixs/workflow/office/dataview/DataViewSearchController.java b/office-alexander-logistics-app/src/main/java/org/imixs/workflow/office/dataview/DataViewSearchController.java new file mode 100644 index 0000000..d5990a9 --- /dev/null +++ b/office-alexander-logistics-app/src/main/java/org/imixs/workflow/office/dataview/DataViewSearchController.java @@ -0,0 +1,39 @@ +package org.imixs.workflow.office.dataview; + +import java.util.logging.Logger; + +import org.imixs.workflow.faces.data.ViewController; + +import jakarta.annotation.PostConstruct; +import jakarta.faces.view.ViewScoped; +import jakarta.inject.Inject; +import jakarta.inject.Named; + +@Named +@ViewScoped +public class DataViewSearchController extends ViewController { + + private static final long serialVersionUID = 1L; + private static Logger logger = Logger.getLogger(DataViewSearchController.class.getName()); + + @Inject + DataViewController dataViewController; + + @Override + @PostConstruct + public void init() { + super.init(); + this.setQuery(dataViewController.getQuery()); + this.setSortBy("$modified"); + this.setSortReverse(false); + this.setPageSize(100); + this.setLoadStubs(false); + } + + @Override + public String getQuery() { + logger.fine("query: " + dataViewController.getQuery()); + return dataViewController.getQuery(); + } + +} diff --git a/office-alexander-logistics-app/src/main/webapp/pages/admin/dataViewDefinition.xhtml b/office-alexander-logistics-app/src/main/webapp/pages/admin/dataViewDefinition.xhtml index 9bb297e..612b3c6 100644 --- a/office-alexander-logistics-app/src/main/webapp/pages/admin/dataViewDefinition.xhtml +++ b/office-alexander-logistics-app/src/main/webapp/pages/admin/dataViewDefinition.xhtml @@ -7,7 +7,7 @@ - + @@ -19,7 +19,7 @@

- +

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

Query Definition

+

Query Definition + + Test View + + +

A Query Defintion defines a custom data list based on the + value="#{dataViewDefinitionController.data.item['Name']}" />

-
Description:
-
+ value="#{dataViewDefinitionController.data.item['description']}" />
@@ -76,7 +82,8 @@
-
@@ -88,11 +95,11 @@ -

Attributes

+

View Items

- Optional attribute definition for the report result. A attributes reduces - the size of a report result and can adapt single item values. Each item of + Attribute definitions for the vew result. An attribute can adapt single item + values. Each item of the attribute list can define an optional label, converter, format and aggregator. @@ -109,7 +116,8 @@ - + + actionListener="#{dataViewDefinitionController.moveAttributeDown(attribute.item['item.name'])}"> + actionListener="#{dataViewDefinitionController.moveAttributeUp(attribute.item['item.name'])}"> + actionListener="#{dataViewDefinitionController.removeAttribute(attribute.item['item.name'])}"> @@ -155,7 +163,7 @@ + actionListener="#{dataViewDefinitionController.addAttribute}"> @@ -171,7 +179,14 @@

-

Form Definition

+

Form Definition + Test View + +

The Form Definition defines query and filter parameters.

@@ -182,7 +197,8 @@ Form:
-
@@ -194,7 +210,14 @@
-

Template

+

Template + Test View + +

@@ -202,52 +225,39 @@
- - + workitem="#{dataViewDefinitionController.data}" + context_url="#{facesContext.externalContext.requestContextPath}/api/snapshot/#{dataViewDefinitionController.data.item['$uniqueid']}" />
- -
- -
-
- - - + + + + + + + \ No newline at end of file diff --git a/pom.xml b/pom.xml index 581cf6b..659b70f 100644 --- a/pom.xml +++ b/pom.xml @@ -129,14 +129,14 @@ - + + office-alexander-logistics