As we transition to the new Hyland Community, some post links may be temporarily disrupted as we finalize redirects. We apologize for the inconvenience and are working to resolve this as quickly as possible. Details.
<f:verbatim> <table width="100%"> <tr> <td colspan="7" align="right"> </f:verbatim> <a:actionLink id="col-history" style="font-weight:bold;font-family:Verdana;color:red;" value="Filter \"WORK COMPLETION\" read." action="dialog:historyTask" rendered="#{!NavigationBean.currentUser.admin}"> </a:actionLink> <f:verbatim> </td> </tr> </table> </f:verbatim>
<dialog name="historyTask" page="/jsp/workflow/history-task-dialog.jsp" managed-bean="HistoryTaskDialog" icon="/images/icons/manage_workflow_task_large.gif" description-id="manage_task_desc" />
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%> <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%> <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> <%@ taglib uri="/WEB-INF/alfresco.tld" prefix="a"%> <%@ taglib uri="/WEB-INF/repo.tld" prefix="r"%> <%@ page buffer="32kb" contentType="text/html;charset=UTF-8"%> <%@ page isELIgnored="false"%> <h:outputText value="Please input date for execute (Note: toDate <= toDay - 30 )." styleClass="mainSubTitle" /> <f:verbatim> <br /> </f:verbatim> <h:outputText value="Click Yes for filter the tasks is WORK COMPLETION, click No or Logout to reset the results. " /> <f:verbatim> <p /> </f:verbatim> <h:outputText value="From date:" styleClass="mainSubTitle" /> <h:inputText id="from-date" size="25" value="#{HistoryTaskDialog.fromDate}" maxlength="20"></h:inputText> <h:outputText value="To date:" styleClass="mainSubTitle" /> <h:inputText id="to-date" size="29" value="#{HistoryTaskDialog.toDate}" maxlength="20"></h:inputText> <f:verbatim> <p /> </f:verbatim>
package org.alfresco.web.bean.workflow; import java.text.MessageFormat; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Date; import java.util.List; import java.util.Map; import javax.faces.component.UIForm; import javax.faces.component.UIInput; import javax.faces.context.FacesContext; import javax.faces.event.ActionEvent; import org.alfresco.repo.workflow.jbpm.JBPMEngine; import org.alfresco.service.cmr.workflow.WorkflowException; import org.alfresco.service.cmr.workflow.WorkflowInstance; import org.alfresco.service.cmr.workflow.WorkflowService; import org.alfresco.service.cmr.workflow.WorkflowTask; import org.alfresco.service.cmr.workflow.WorkflowTaskState; import org.alfresco.web.app.Application; import org.alfresco.web.bean.dialog.BaseDialogBean; import org.alfresco.web.bean.repository.User; import org.alfresco.web.ui.common.Utils; import org.alfresco.web.ui.common.component.UIActionLink; import org.alfresco.web.ui.repo.component.property.UIPropertySheet; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.springframework.beans.factory.access.BeanFactoryLocator; import org.springframework.beans.factory.access.BeanFactoryReference; import org.springmodules.workflow.jbpm31.JbpmFactoryLocator; import com.ibm.icu.util.Calendar; public class HistoryTaskDialog extends BaseDialogBean { /** Alfresco JBPM Engine */ private static JBPMEngine jbpmEngine = null; private String fromDate; private String toDate; private JBPMEngine getJBPMEngine() { if (jbpmEngine == null) { BeanFactoryLocator factoryLocator = new JbpmFactoryLocator(); BeanFactoryReference factory = factoryLocator.useBeanFactory(null); jbpmEngine = (JBPMEngine) factory.getFactory().getBean( "jbpm_engine"); if (jbpmEngine == null) { throw new WorkflowException( "Failed to retrieve JBPMEngine component"); } } return jbpmEngine; } // —————————————————————————— // Dialog implementation @Override public void init(Map<String, String> parameters) { super.init(parameters); this.isFinished = false; } @Override protected String finishImpl(FacesContext context, String outcome) throws Exception { try { Date frDate = new Date(this.getFromDate()); Date tDate = new Date(this.getToDate()); if(frDate.before(tDate) && tDate.before(new Date())) { getJBPMEngine().setFromDate(this.getFromDate()); getJBPMEngine().setToDate(this.getToDate()); if(checkDate(toDate)) { this.isFinished = true; } else { Utils.addErrorMessage("[WARNING]: toDate <= toDay - 30"); isFinished = false; outcome = null; } } else { Utils.addErrorMessage("[ERROR]: fromDate > toDate Or toDate < toDay"); isFinished = false; outcome = null; } } catch (Throwable ex) { Utils.addErrorMessage(MessageFormat.format( "Date input uncorrect please try again.", ex)); isFinished = false; outcome = null; } return outcome; } // vinaxwater added for check distance 60 day. private boolean checkDate(String toDate) { Date dt = new Date(); SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy"); String[] arrFrom = sdf.format(dt).split("-"); Date tD = new Date(toDate); String[] arrTo = sdf.format(tD).split("-"); double date = Integer.valueOf(arrFrom[0]).intValue() - Integer.valueOf(arrTo[0]).intValue(); double month = Integer.valueOf(arrFrom[1]).intValue() - Integer.valueOf(arrTo[1]).intValue(); double year = Integer.valueOf(arrFrom[2]).intValue() - Integer.valueOf(arrTo[2]).intValue(); if(year > 0) return true; else if(month >= 2) return true; return ((date + 30) > 30); } @Override public boolean getFinishButtonDisabled() { return false; } @Override public String getCancelButtonLabel() { return Application.getMessage(FacesContext.getCurrentInstance(), "no"); } @Override public String getFinishButtonLabel() { return Application.getMessage(FacesContext.getCurrentInstance(), "yes"); } // —————————————————————————— // Bean Getters and Setters public String getFromDate() { return fromDate; } public void setFromDate(String fromDate) { this.fromDate = fromDate; } public String getToDate() { return toDate; } public void setToDate(String toDate) { this.toDate = toDate; } }
List<TaskInstance> result = new ArrayList<TaskInstance>(); /* code added */ List<TaskInstance> union = new ArrayList<TaskInstance>(); /* code added */ try { Session session = jbpmContext.getSession(); Query query = session.createQuery(COMPLETED_TASKS_QUERY); query.setString("actorId", actorId); result = query.list(); /* code added */ if (fromDate != null && toDate != null)//20-OCT-2010 { String COMPLETED_TASKS_QUERY_ADVANDCE = COMPLETED_TASKS_QUERY_USER + " and trunc(ti.end) >= '" + fromDate + "' " + "and trunc(ti.end) <= '" + toDate + "' "; //"and sysdate-to_date('"+toDate+"','DD-MON-RRRR')>60"; query = session.createQuery(COMPLETED_TASKS_QUERY_ADVANDCE); query.setString("actorId", actorId); union = query.list(); result.addAll(union); } /* code added */ } catch (Exception e) { throw new JbpmException("Couldn't get completed task instances list for actor '" + actorId + "'", e); } return result;