|
|
@ -1,6 +1,7 @@ |
|
|
|
package it.tref.liferay.portos.kaleo.hook.struts; |
|
|
|
package it.tref.liferay.portos.kaleo.hook.struts; |
|
|
|
|
|
|
|
|
|
|
|
import it.tref.liferay.portos.bo.model.ControlloPratica; |
|
|
|
import it.tref.liferay.portos.bo.model.ControlloPratica; |
|
|
|
|
|
|
|
import it.tref.liferay.portos.bo.model.IntPratica; |
|
|
|
import it.tref.liferay.portos.bo.service.ControlloPraticaLocalServiceUtil; |
|
|
|
import it.tref.liferay.portos.bo.service.ControlloPraticaLocalServiceUtil; |
|
|
|
import it.tref.liferay.portos.bo.service.IntPraticaLocalServiceUtil; |
|
|
|
import it.tref.liferay.portos.bo.service.IntPraticaLocalServiceUtil; |
|
|
|
import it.tref.liferay.portos.bo.shared.util.StatoPraticaConstants; |
|
|
|
import it.tref.liferay.portos.bo.shared.util.StatoPraticaConstants; |
|
|
@ -13,7 +14,6 @@ import it.tref.liferay.portos.kaleo.util.WorkflowUtil; |
|
|
|
import java.io.IOException; |
|
|
|
import java.io.IOException; |
|
|
|
import java.io.Serializable; |
|
|
|
import java.io.Serializable; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.Arrays; |
|
|
|
|
|
|
|
import java.util.Calendar; |
|
|
|
import java.util.Calendar; |
|
|
|
import java.util.Date; |
|
|
|
import java.util.Date; |
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.HashMap; |
|
|
@ -56,6 +56,8 @@ import com.liferay.portal.kernel.util.Validator; |
|
|
|
import com.liferay.portal.kernel.util.WebKeys; |
|
|
|
import com.liferay.portal.kernel.util.WebKeys; |
|
|
|
import com.liferay.portal.kernel.workflow.WorkflowConstants; |
|
|
|
import com.liferay.portal.kernel.workflow.WorkflowConstants; |
|
|
|
import com.liferay.portal.kernel.workflow.WorkflowException; |
|
|
|
import com.liferay.portal.kernel.workflow.WorkflowException; |
|
|
|
|
|
|
|
import com.liferay.portal.kernel.workflow.WorkflowInstance; |
|
|
|
|
|
|
|
import com.liferay.portal.kernel.workflow.WorkflowInstanceManagerUtil; |
|
|
|
import com.liferay.portal.kernel.workflow.WorkflowLog; |
|
|
|
import com.liferay.portal.kernel.workflow.WorkflowLog; |
|
|
|
import com.liferay.portal.kernel.workflow.WorkflowLogManagerUtil; |
|
|
|
import com.liferay.portal.kernel.workflow.WorkflowLogManagerUtil; |
|
|
|
import com.liferay.portal.kernel.workflow.WorkflowTask; |
|
|
|
import com.liferay.portal.kernel.workflow.WorkflowTask; |
|
|
@ -68,14 +70,17 @@ import com.liferay.portal.model.LayoutTypePortlet; |
|
|
|
import com.liferay.portal.model.Organization; |
|
|
|
import com.liferay.portal.model.Organization; |
|
|
|
import com.liferay.portal.model.Portlet; |
|
|
|
import com.liferay.portal.model.Portlet; |
|
|
|
import com.liferay.portal.model.User; |
|
|
|
import com.liferay.portal.model.User; |
|
|
|
|
|
|
|
import com.liferay.portal.model.WorkflowInstanceLink; |
|
|
|
import com.liferay.portal.security.auth.PrincipalException; |
|
|
|
import com.liferay.portal.security.auth.PrincipalException; |
|
|
|
import com.liferay.portal.service.GroupLocalServiceUtil; |
|
|
|
import com.liferay.portal.service.GroupLocalServiceUtil; |
|
|
|
import com.liferay.portal.service.OrganizationLocalServiceUtil; |
|
|
|
import com.liferay.portal.service.OrganizationLocalServiceUtil; |
|
|
|
import com.liferay.portal.service.PortletLocalServiceUtil; |
|
|
|
import com.liferay.portal.service.PortletLocalServiceUtil; |
|
|
|
|
|
|
|
import com.liferay.portal.service.RoleLocalServiceUtil; |
|
|
|
import com.liferay.portal.service.ServiceContext; |
|
|
|
import com.liferay.portal.service.ServiceContext; |
|
|
|
import com.liferay.portal.service.ServiceContextFactory; |
|
|
|
import com.liferay.portal.service.ServiceContextFactory; |
|
|
|
import com.liferay.portal.service.UserGroupRoleLocalServiceUtil; |
|
|
|
import com.liferay.portal.service.UserGroupRoleLocalServiceUtil; |
|
|
|
import com.liferay.portal.service.UserLocalServiceUtil; |
|
|
|
import com.liferay.portal.service.UserLocalServiceUtil; |
|
|
|
|
|
|
|
import com.liferay.portal.service.WorkflowInstanceLinkLocalServiceUtil; |
|
|
|
import com.liferay.portal.theme.ThemeDisplay; |
|
|
|
import com.liferay.portal.theme.ThemeDisplay; |
|
|
|
import com.liferay.portal.util.PortalUtil; |
|
|
|
import com.liferay.portal.util.PortalUtil; |
|
|
|
import com.liferay.portal.workflow.kaleo.model.KaleoInstance; |
|
|
|
import com.liferay.portal.workflow.kaleo.model.KaleoInstance; |
|
|
@ -86,10 +91,17 @@ import com.liferay.portal.workflow.kaleo.service.KaleoTaskInstanceTokenLocalServ |
|
|
|
public class EditWorkflowTaskAction extends BaseStrutsPortletAction { |
|
|
|
public class EditWorkflowTaskAction extends BaseStrutsPortletAction { |
|
|
|
|
|
|
|
|
|
|
|
private final static Log _log = LogFactoryUtil.getLog(EditWorkflowTaskAction.class); |
|
|
|
private final static Log _log = LogFactoryUtil.getLog(EditWorkflowTaskAction.class); |
|
|
|
private final static List<String> valoriAmmessi = Arrays.asList(StatoPraticaConstants.ANNULLATA, |
|
|
|
@SuppressWarnings("serial") |
|
|
|
StatoPraticaConstants.CONFORME, StatoPraticaConstants.INTEGRAZIONE, |
|
|
|
private final static List<String> valoriAmmessi = new ArrayList<String>() { |
|
|
|
StatoPraticaConstants.NON_CONFORME, StatoPraticaConstants.NO_PARERE, |
|
|
|
{ |
|
|
|
StatoPraticaConstants.PREAVVISO_CONTRARIO); |
|
|
|
add(StatoPraticaConstants.ANNULLATA); |
|
|
|
|
|
|
|
add(StatoPraticaConstants.CONFORME); |
|
|
|
|
|
|
|
add(StatoPraticaConstants.INTEGRAZIONE); |
|
|
|
|
|
|
|
add(StatoPraticaConstants.NON_CONFORME); |
|
|
|
|
|
|
|
add(StatoPraticaConstants.NO_PARERE); |
|
|
|
|
|
|
|
add(StatoPraticaConstants.PREAVVISO_CONTRARIO); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void processAction(StrutsPortletAction originalStrutsPortletAction, PortletConfig portletConfig, |
|
|
|
public void processAction(StrutsPortletAction originalStrutsPortletAction, PortletConfig portletConfig, |
|
|
@ -158,6 +170,7 @@ public class EditWorkflowTaskAction extends BaseStrutsPortletAction { |
|
|
|
|
|
|
|
|
|
|
|
String transitionName = ParamUtil.getString(actionRequest, "transitionName"); |
|
|
|
String transitionName = ParamUtil.getString(actionRequest, "transitionName"); |
|
|
|
String comment = ParamUtil.getString(actionRequest, "comment"); |
|
|
|
String comment = ParamUtil.getString(actionRequest, "comment"); |
|
|
|
|
|
|
|
boolean aggiorna = true; |
|
|
|
|
|
|
|
|
|
|
|
// ADT: bug mancata problema assegnazione WF
|
|
|
|
// ADT: bug mancata problema assegnazione WF
|
|
|
|
checkPresenzaIstruttore(transitionName, workflowTaskId); |
|
|
|
checkPresenzaIstruttore(transitionName, workflowTaskId); |
|
|
@ -185,23 +198,48 @@ public class EditWorkflowTaskAction extends BaseStrutsPortletAction { |
|
|
|
} else if (transitionName.equalsIgnoreCase("Riassegna") || transitionName.equalsIgnoreCase("assegna")) { |
|
|
|
} else if (transitionName.equalsIgnoreCase("Riassegna") || transitionName.equalsIgnoreCase("assegna")) { |
|
|
|
HttpServletRequest httpServletRequest = PortalUtil.getOriginalServletRequest(PortalUtil |
|
|
|
HttpServletRequest httpServletRequest = PortalUtil.getOriginalServletRequest(PortalUtil |
|
|
|
.getHttpServletRequest(actionRequest)); |
|
|
|
.getHttpServletRequest(actionRequest)); |
|
|
|
String istr = httpServletRequest.getParameter("kaleo--istruttore--") != null ? httpServletRequest |
|
|
|
String istruttore = httpServletRequest.getParameter("kaleo--istruttore--"); |
|
|
|
.getParameter("kaleo--istruttore--").trim() : StringPool.BLANK; |
|
|
|
if (Validator.isNull(istruttore)) { |
|
|
|
if (istr.isEmpty()) { |
|
|
|
|
|
|
|
_log.error("controllo validazione completamento task = " + transitionName + " -" |
|
|
|
_log.error("controllo validazione completamento task = " + transitionName + " -" |
|
|
|
+ workflowTaskId + " non riuscito - istruttore non presente nel workflow"); |
|
|
|
+ workflowTaskId + " non riuscito - istruttore non presente nel workflow"); |
|
|
|
throw new PortalException("controllo validazione completamento task riassegna non riuscito"); |
|
|
|
throw new PortalException("controllo validazione completamento task riassegna non riuscito"); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if (istruttore.startsWith("--UO--")) { |
|
|
|
|
|
|
|
aggiorna = false; |
|
|
|
|
|
|
|
KaleoTaskInstanceToken taskInstanceToken = KaleoTaskInstanceTokenLocalServiceUtil |
|
|
|
|
|
|
|
.getKaleoTaskInstanceToken(workflowTaskId); |
|
|
|
|
|
|
|
if (taskInstanceToken.getClassName().equals(ControlloPratica.class.getName())) { |
|
|
|
|
|
|
|
ControlloPratica controllo = ControlloPraticaLocalServiceUtil |
|
|
|
|
|
|
|
.getControlloPratica(taskInstanceToken.getClassPK()); |
|
|
|
|
|
|
|
IntPratica pratica = IntPraticaLocalServiceUtil |
|
|
|
|
|
|
|
.getIntPratica(controllo.getIntPraticaId()); |
|
|
|
|
|
|
|
long companyId = controllo.getCompanyId(); |
|
|
|
|
|
|
|
long roleId = RoleLocalServiceUtil.getRole(companyId, "portos_assegnatore").getRoleId(); |
|
|
|
|
|
|
|
int uo = Integer.parseInt(istruttore.substring(6)); |
|
|
|
|
|
|
|
WorkflowInstanceLink link = WorkflowInstanceLinkLocalServiceUtil.getWorkflowInstanceLink( |
|
|
|
|
|
|
|
companyId, controllo.getGroupId(), ControlloPratica.class.getName(), |
|
|
|
|
|
|
|
controllo.getPrimaryKey()); |
|
|
|
|
|
|
|
WorkflowInstance instance = WorkflowInstanceManagerUtil.getWorkflowInstance(companyId, |
|
|
|
|
|
|
|
link.getWorkflowInstanceId()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pratica.setUnitaOperativa(uo); |
|
|
|
|
|
|
|
IntPraticaLocalServiceUtil.updateIntPratica(pratica); |
|
|
|
|
|
|
|
WorkflowTaskManagerUtil |
|
|
|
|
|
|
|
.assignWorkflowTaskToRole(companyId, taskInstanceToken.getUserId(), |
|
|
|
|
|
|
|
workflowTaskId, roleId, "Trasferito all'UO " + uo |
|
|
|
|
|
|
|
+ " per assegnazione all'istruttore", null, |
|
|
|
|
|
|
|
instance.getWorkflowContext()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (aggiorna) { |
|
|
|
Map<String, Serializable> workflowContext = new HashMap<String, Serializable>(); |
|
|
|
Map<String, Serializable> workflowContext = new HashMap<String, Serializable>(); |
|
|
|
|
|
|
|
|
|
|
|
workflowContext.put(WorkflowConstants.CONTEXT_TRANSITION_NAME, transitionName); |
|
|
|
workflowContext.put(WorkflowConstants.CONTEXT_TRANSITION_NAME, transitionName); |
|
|
|
|
|
|
|
|
|
|
|
WorkflowUtil.updateWorkflowContextWithTaskFormParameters(actionRequest, workflowContext); |
|
|
|
WorkflowUtil.updateWorkflowContextWithTaskFormParameters(actionRequest, workflowContext); |
|
|
|
|
|
|
|
WorkflowTaskManagerUtil.completeWorkflowTask(themeDisplay.getCompanyId(), |
|
|
|
WorkflowTaskManagerUtil.completeWorkflowTask(themeDisplay.getCompanyId(), themeDisplay.getUserId(), |
|
|
|
themeDisplay.getUserId(), workflowTaskId, transitionName, comment, workflowContext); |
|
|
|
workflowTaskId, transitionName, comment, workflowContext); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
protected void relaseTask(ActionRequest actionRequest) throws Exception { |
|
|
|
protected void relaseTask(ActionRequest actionRequest) throws Exception { |
|
|
|