dataview draft

This commit is contained in:
Ralph Soika 2025-05-11 10:32:38 +02:00
parent db478a5b4e
commit 372c7887fb
3 changed files with 97 additions and 76 deletions

View file

@ -26,20 +26,27 @@ package org.imixs.workflow.office.dataview;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import org.imixs.workflow.ItemCollection; import org.imixs.workflow.ItemCollection;
import org.imixs.workflow.exceptions.AccessDeniedException; import org.imixs.workflow.engine.DocumentService;
import org.imixs.workflow.exceptions.ModelException; import org.imixs.workflow.exceptions.ModelException;
import org.imixs.workflow.faces.data.AbstractDataController; import org.imixs.workflow.exceptions.QueryException;
import org.imixs.workflow.faces.data.ViewController;
import org.imixs.workflow.faces.data.ViewHandler;
import org.imixs.workflow.office.forms.CustomFormController; import org.imixs.workflow.office.forms.CustomFormController;
import org.imixs.workflow.office.forms.CustomFormSection; import org.imixs.workflow.office.forms.CustomFormSection;
import jakarta.annotation.PostConstruct; import jakarta.annotation.PostConstruct;
import jakarta.enterprise.context.Conversation;
import jakarta.enterprise.context.ConversationScoped; import jakarta.enterprise.context.ConversationScoped;
import jakarta.faces.context.FacesContext;
import jakarta.inject.Inject; import jakarta.inject.Inject;
import jakarta.inject.Named; import jakarta.inject.Named;
import jakarta.servlet.http.HttpServletRequest;
/** /**
* The DataViewController is used to display a data view * The DataViewController is used to display a data view
@ -47,29 +54,46 @@ import jakarta.inject.Named;
* @author rsoika * @author rsoika
* @version 1.0 * @version 1.0
*/ */
// @Named
// @ConversationScoped
// public class DataViewController extends AbstractDataController {
@Named @Named
@ConversationScoped @ConversationScoped
public class DataViewController extends AbstractDataController { // @ViewScoped
public class DataViewController extends ViewController {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private List<CustomFormSection> sections; private List<CustomFormSection> sections;
private String errorMessage; private String errorMessage;
@Inject
private Conversation conversation;
@Inject
private DocumentService documentService;
@Inject @Inject
CustomFormController customFormController; CustomFormController customFormController;
@Inject
ViewHandler viewHandler;
protected ItemCollection data = null;
private ItemCollection filter; private ItemCollection filter;
private String query; private String query;
private static Logger logger = Logger.getLogger(DataViewController.class.getName()); private static Logger logger = Logger.getLogger(DataViewController.class.getName());
/** @Override
*
*
*/
@PostConstruct @PostConstruct
public void init() { public void init() {
super.init();
// this.setQuery(dataViewController.getQuery());
this.setSortBy("$modified");
this.setSortReverse(false);
this.setPageSize(100);
this.setLoadStubs(false);
} }
public ItemCollection getDefinition() { public ItemCollection getDefinition() {
@ -83,11 +107,25 @@ public class DataViewController extends AbstractDataController {
/** /**
* This method loads the custom form sections * This method loads the custom form sections
*/ */
@Override
public void onLoad() { public void onLoad() {
filter = new ItemCollection(); filter = new ItemCollection();
super.onLoad(); // super.onLoad();
startConversation(); startConversation();
FacesContext facesContext = FacesContext.getCurrentInstance();
if (!facesContext.isPostback() && !facesContext.isValidationFailed()) {
// ...
FacesContext fc = FacesContext.getCurrentInstance();
Map<String, String> paramMap = fc.getExternalContext().getRequestParameterMap();
// try to extract the uniqueid form the query string...
String uniqueid = paramMap.get("id");
if (uniqueid == null || uniqueid.isEmpty()) {
// alternative 'workitem=...'
uniqueid = paramMap.get("workitem");
}
data = documentService.load(uniqueid);
}
try { try {
// Init new Filter.... // Init new Filter....
if (data != null) { if (data != null) {
@ -125,12 +163,12 @@ public class DataViewController extends AbstractDataController {
* elements with the values from the filter * elements with the values from the filter
* *
* *
* @throws AccessDeniedException - if user has insufficient access rights. * @throws QueryException
*/ */
public void run() throws AccessDeniedException { public void run() throws QueryException {
reset();
Date date = filter.getItemValueDate("date.from"); Date date = filter.getItemValueDate("date.from");
logger.info(" date=" + date); logger.info("x date=" + date);
query = data.getItemValueString("query"); query = data.getItemValueString("query");
@ -156,6 +194,9 @@ public class DataViewController extends AbstractDataController {
} }
logger.info("query=" + query); logger.info("query=" + query);
// Prefetch data to update total count and page count
viewHandler.getData(this);
} }
/** /**
@ -191,4 +232,17 @@ public class DataViewController extends AbstractDataController {
} }
/**
* Starts a new conversation
*/
protected void startConversation() {
if (conversation.isTransient()) {
conversation.setTimeout(
((HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest())
.getSession().getMaxInactiveInterval() * 1000);
conversation.begin();
logger.log(Level.FINEST, "......start new conversation, id={0}", conversation.getId());
}
}
} }

View file

@ -1,39 +0,0 @@
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();
}
}

View file

@ -13,13 +13,8 @@
<ui:define name="content"> <ui:define name="content">
<f:view> <f:view>
<h:form id="textblock_form_id" pt:autocomplete="on"> <h:form id="dataview_id" pt:autocomplete="on">
<ui:param name="searchresult" value="#{viewHandler.getData(dataViewSearchController)}"></ui:param>
<ui:param name="searchresultCount" value="#{dataViewSearchController.getTotalCount()}"></ui:param>
<ui:param name="searchPage"
value="#{(dataViewSearchController.getPageIndex()+1)}/#{(dataViewSearchController.getTotalPages())}">
</ui:param>
<div class="imixs-form"> <div class="imixs-form">
@ -30,9 +25,9 @@
</h1> </h1>
</div> </div>
<div class="imixs-form-panel"> <h:panelGroup styleClass="imixs-form-panel imixs-view" layout="block" id="dataview_form_id">
<div class="imixs-form-section"> <div class=" imixs-form-section">
<ui:include src="/pages/workitems/forms/custom_sections.xhtml"> <ui:include src="/pages/workitems/forms/custom_sections.xhtml">
<ui:param name="customFormSections" value="#{customFormController.sections}" /> <ui:param name="customFormSections" value="#{customFormController.sections}" />
@ -42,19 +37,24 @@
</div> </div>
</h:panelGroup>
</div>
<h:panelGroup styleClass="imixs-view imixs-search" layout="block" id="dataview_result_id">
<ui:param name="searchResult" value="#{viewHandler.getData(dataViewController)}" />
<ui:param name="searchPage"
value="#{(dataViewController.getPageIndex()+1)}/#{(dataViewController.getTotalPages())}" />
<h:panelGroup styleClass="imixs-view imixs-search" layout="block" id="search_view">
<!-- Buttons --> <!-- Buttons -->
<div class="imixs-form-section"> <div class="imixs-form-section">
<div style="float:left;"> <div style="float:left;">
<h:commandButton value="Anzeigen" action="#{dataViewController.run()}"> <h:commandButton value="Anzeigen" action="#{dataViewController.run()}">
<f:ajax render="@form" execute="@form" onevent="updateSearchForm" /> <f:ajax execute="@form dataview_result_id" render="dataview_result_id"
onevent="updateDataView" />
</h:commandButton> </h:commandButton>
<h:commandButton value="Excel Export" action="#{dataViewController.run()}" /> <h:commandButton value="Excel Export" action="#{dataViewController.run()}" />
@ -63,6 +63,9 @@
<!-- Sort Order --> <!-- Sort Order -->
<div class="pull-right "> <div class="pull-right ">
<span class="search-result-summary">#{message.total_result}
#{dataViewController.getTotalCount()}
#{message.serach_hits}</span>
<div class=" ui-button ui-widget ui-state-default ui-corner-all" <div class=" ui-button ui-widget ui-state-default ui-corner-all"
style="padding: 0 10px;"> style="padding: 0 10px;">
<h:outputText title="#{message['worklist.sortorder_help']}" <h:outputText title="#{message['worklist.sortorder_help']}"
@ -86,17 +89,16 @@
</span> </span>
</div> </div>
<h:commandButton actionListener="#{viewHandler.back(dataViewSearchController)}" <h:commandButton actionListener="#{viewHandler.back(dataViewController)}"
style="height: 31px;" disabled="#{dataViewSearchController.pageIndex==0}" style="height: 31px;" disabled="#{dataViewController.pageIndex==0}"
value="◀◀ #{message.prev}"> value="◀◀ #{message.prev}">
<f:ajax render="search_view" <f:ajax render="dataview_result_id" onevent="updateDataView" />
onevent="function(data) { imixsOfficeMain.layoutAjaxEvent(data, '#{component.parent.parent.clientId}') }" />
</h:commandButton> </h:commandButton>
<h:commandButton actionListener="#{viewHandler.forward(dataViewSearchController)}" <h:commandButton actionListener="#{viewHandler.forward(dataViewController)}"
style="height: 31px;" disabled="#{dataViewSearchController.endOfList}" style="height: 31px;"
disabled="#{dataViewController.endOfList or dataViewController.getTotalPages() le 1}"
value="#{message.next} ▶▶"> value="#{message.next} ▶▶">
<f:ajax render="search_view" <f:ajax render="dataview_result_id" onevent="updateDataView" />
onevent="function(data) { imixsOfficeMain.layoutAjaxEvent(data, '#{component.parent.parent.clientId}') }" />
</h:commandButton> </h:commandButton>
@ -106,9 +108,7 @@
<div class="imixs-form-section"> <div class="imixs-form-section">
<div class="search-result-summary">#{message.total_result} #{searchresultCount} <h:dataTable id="view_body" styleClass="imixsdatatable" value="#{searchResult}"
#{message.serach_hits}</div>
<h:dataTable id="view_body" styleClass="imixsdatatable" value="#{searchresult}"
var="record"> var="record">
<h:column> <h:column>
@ -148,6 +148,12 @@
}); });
//ajax refresh...
function updateDataView(data, context) {
if (data.status === 'success') {
imixsOfficeMain.layoutAjaxEvent(data);
}
}
/*]]>*/ /*]]>*/
</script> </script>