|
|
|
@ -5,6 +5,7 @@ import it.tref.liferay.portos.bo.model.IntPratica;
|
|
|
|
|
import it.tref.liferay.portos.bo.service.ControlloPraticaLocalServiceUtil; |
|
|
|
|
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.UnitaOperativeUtil; |
|
|
|
|
import it.tref.liferay.portos.bo.util.AzioniPraticheUtil; |
|
|
|
|
import it.tref.liferay.portos.kaleo.model.FormLog; |
|
|
|
|
import it.tref.liferay.portos.kaleo.service.ClpSerializer; |
|
|
|
@ -70,7 +71,6 @@ import com.liferay.portal.model.LayoutTypePortlet;
|
|
|
|
|
import com.liferay.portal.model.Organization; |
|
|
|
|
import com.liferay.portal.model.Portlet; |
|
|
|
|
import com.liferay.portal.model.User; |
|
|
|
|
import com.liferay.portal.model.WorkflowInstanceLink; |
|
|
|
|
import com.liferay.portal.security.auth.PrincipalException; |
|
|
|
|
import com.liferay.portal.service.GroupLocalServiceUtil; |
|
|
|
|
import com.liferay.portal.service.OrganizationLocalServiceUtil; |
|
|
|
@ -80,12 +80,13 @@ import com.liferay.portal.service.ServiceContext;
|
|
|
|
|
import com.liferay.portal.service.ServiceContextFactory; |
|
|
|
|
import com.liferay.portal.service.UserGroupRoleLocalServiceUtil; |
|
|
|
|
import com.liferay.portal.service.UserLocalServiceUtil; |
|
|
|
|
import com.liferay.portal.service.WorkflowInstanceLinkLocalServiceUtil; |
|
|
|
|
import com.liferay.portal.theme.ThemeDisplay; |
|
|
|
|
import com.liferay.portal.util.PortalUtil; |
|
|
|
|
import com.liferay.portal.workflow.kaleo.model.KaleoInstance; |
|
|
|
|
import com.liferay.portal.workflow.kaleo.model.KaleoInstanceToken; |
|
|
|
|
import com.liferay.portal.workflow.kaleo.model.KaleoTaskInstanceToken; |
|
|
|
|
import com.liferay.portal.workflow.kaleo.service.KaleoInstanceLocalServiceUtil; |
|
|
|
|
import com.liferay.portal.workflow.kaleo.service.KaleoInstanceTokenLocalServiceUtil; |
|
|
|
|
import com.liferay.portal.workflow.kaleo.service.KaleoTaskInstanceTokenLocalServiceUtil; |
|
|
|
|
|
|
|
|
|
public class EditWorkflowTaskAction extends BaseStrutsPortletAction { |
|
|
|
@ -143,6 +144,8 @@ public class EditWorkflowTaskAction extends BaseStrutsPortletAction {
|
|
|
|
|
throw e; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} else if (cmd.equals("removeUO")) { |
|
|
|
|
removeUO(actionRequest); |
|
|
|
|
} else { |
|
|
|
|
originalStrutsPortletAction.processAction(originalStrutsPortletAction, portletConfig, |
|
|
|
|
actionRequest, actionResponse); |
|
|
|
@ -206,30 +209,18 @@ public class EditWorkflowTaskAction extends BaseStrutsPortletAction {
|
|
|
|
|
} |
|
|
|
|
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()); |
|
|
|
|
} |
|
|
|
|
ControlloPratica controllo = WorkflowUtil.getControlloPratica(workflowTaskId); |
|
|
|
|
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)); |
|
|
|
|
|
|
|
|
|
WorkflowTaskManagerUtil.assignWorkflowTaskToRole(companyId, themeDisplay.getUserId(), |
|
|
|
|
workflowTaskId, roleId, "Trasferito all'UO " + uo |
|
|
|
|
+ " per assegnazione all'istruttore.\n" + comment, null, |
|
|
|
|
WorkflowUtil.getWorkflowContext(controllo)); |
|
|
|
|
pratica.setUnitaOperativa(uo); |
|
|
|
|
IntPraticaLocalServiceUtil.updateIntPratica(pratica); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -242,6 +233,27 @@ public class EditWorkflowTaskAction extends BaseStrutsPortletAction {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
protected void removeUO(ActionRequest actionRequest) throws PortalException, SystemException { |
|
|
|
|
ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); |
|
|
|
|
|
|
|
|
|
long workflowTaskId = ParamUtil.getLong(actionRequest, "workflowTaskId"); |
|
|
|
|
String comment = ParamUtil.getString(actionRequest, "comment"); |
|
|
|
|
ControlloPratica controllo = WorkflowUtil.getControlloPratica(workflowTaskId); |
|
|
|
|
IntPratica pratica = IntPraticaLocalServiceUtil.getIntPratica(controllo.getIntPraticaId()); |
|
|
|
|
long companyId = themeDisplay.getCompanyId(); |
|
|
|
|
long userId = themeDisplay.getUserId(); |
|
|
|
|
Map<String, Serializable> workflowContext = WorkflowUtil.getWorkflowContext(controllo); |
|
|
|
|
long roleId = RoleLocalServiceUtil.getRole(companyId, "portos_assegnatore").getRoleId(); |
|
|
|
|
|
|
|
|
|
WorkflowTaskManagerUtil.assignWorkflowTaskToUser(companyId, userId, workflowTaskId, userId, |
|
|
|
|
StringPool.BLANK, null, workflowContext); |
|
|
|
|
WorkflowTaskManagerUtil.assignWorkflowTaskToRole(companyId, userId, workflowTaskId, roleId, |
|
|
|
|
"Rimosso dalla unità operativa " + pratica.getUnitaOperativa() + ".\n" + comment, null, |
|
|
|
|
workflowContext); |
|
|
|
|
pratica.setUnitaOperativa(0); |
|
|
|
|
IntPraticaLocalServiceUtil.updateIntPratica(pratica); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
protected void relaseTask(ActionRequest actionRequest) throws Exception { |
|
|
|
|
|
|
|
|
|
ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); |
|
|
|
@ -422,9 +434,7 @@ public class EditWorkflowTaskAction extends BaseStrutsPortletAction {
|
|
|
|
|
ThemeDisplay themeDisplay = (ThemeDisplay) renderRequest.getAttribute(WebKeys.THEME_DISPLAY); |
|
|
|
|
|
|
|
|
|
long workflowTaskId = ParamUtil.getLong(renderRequest, "workflowTaskId"); |
|
|
|
|
|
|
|
|
|
WorkflowTask workflowTask = null; |
|
|
|
|
|
|
|
|
|
if (workflowTaskId > 0) { |
|
|
|
|
workflowTask = WorkflowTaskManagerUtil.getWorkflowTask(themeDisplay.getCompanyId(), |
|
|
|
|
workflowTaskId); |
|
|
|
@ -438,31 +448,34 @@ public class EditWorkflowTaskAction extends BaseStrutsPortletAction {
|
|
|
|
|
renderRequest.setAttribute("assegna-value", valoreTransizioneAssegna); |
|
|
|
|
|
|
|
|
|
// Gestione permessi action button
|
|
|
|
|
ControlloPratica controlloPratica = getControlloPratica(workflowTask.getWorkflowInstanceId()); |
|
|
|
|
ControlloPratica controllo = getControlloPratica(workflowTask.getWorkflowInstanceId()); |
|
|
|
|
|
|
|
|
|
// ADT BUG BO ID=33
|
|
|
|
|
renderRequest.setAttribute( |
|
|
|
|
"historyWorkflowEsitiLogs", |
|
|
|
|
getHistoryWorkfloLogs(themeDisplay, workflowTask.getWorkflowInstanceId(), renderRequest, |
|
|
|
|
controlloPratica)); |
|
|
|
|
|
|
|
|
|
long groupIdTerritorio = controlloPratica.getGroupId(); |
|
|
|
|
Group group = GroupLocalServiceUtil.getGroup(groupIdTerritorio); |
|
|
|
|
controllo)); |
|
|
|
|
|
|
|
|
|
Group group = GroupLocalServiceUtil.getGroup(controllo.getGroupId()); |
|
|
|
|
User user = themeDisplay.getUser(); |
|
|
|
|
Organization org = OrganizationLocalServiceUtil.getOrganization(group.getClassPK()); |
|
|
|
|
|
|
|
|
|
int unitaOperativa = WorkflowUtil.getIntPratica(workflowTaskId).getUnitaOperativa(); |
|
|
|
|
List<Integer> unitaOperativeUtente = UnitaOperativeUtil.getUnitaOperative(user); |
|
|
|
|
boolean canPortosAssegnatore = UserGroupRoleLocalServiceUtil.hasUserGroupRole(user.getUserId(), |
|
|
|
|
org.getGroupId(), "portos_assegnatore"); |
|
|
|
|
boolean canPortosApprovatore = UserGroupRoleLocalServiceUtil.hasUserGroupRole(user.getUserId(), |
|
|
|
|
org.getGroupId(), "portos_approvatore"); |
|
|
|
|
org.getGroupId(), "portos_assegnatore") |
|
|
|
|
&& (unitaOperativeUtente.contains(unitaOperativa) || unitaOperativeUtente.contains(0)); |
|
|
|
|
|
|
|
|
|
KaleoInstance instance = KaleoInstanceLocalServiceUtil.getKaleoInstance(workflowTask |
|
|
|
|
.getWorkflowInstanceId()); |
|
|
|
|
KaleoInstanceToken rootToken = KaleoInstanceTokenLocalServiceUtil.getKaleoInstanceToken(instance |
|
|
|
|
.getRootKaleoInstanceTokenId()); |
|
|
|
|
|
|
|
|
|
boolean canPortosIstruttore = UserGroupRoleLocalServiceUtil.hasUserGroupRole(user.getUserId(), |
|
|
|
|
org.getGroupId(), "portos_istruttore"); |
|
|
|
|
boolean canRemoveUO = canPortosAssegnatore && (0 != unitaOperativa) |
|
|
|
|
&& rootToken.getCurrentKaleoNodeName().equalsIgnoreCase("Assegnazione"); |
|
|
|
|
|
|
|
|
|
renderRequest.setAttribute("canPortosAssegnatore", canPortosAssegnatore); |
|
|
|
|
renderRequest.setAttribute("canPortosApprovatore", canPortosApprovatore); |
|
|
|
|
renderRequest.setAttribute("canPortosIstruttore", canPortosIstruttore); |
|
|
|
|
renderRequest.setAttribute("canRemoveUO", canRemoveUO); |
|
|
|
|
|
|
|
|
|
return originalStrutsPortletAction.render(originalStrutsPortletAction, portletConfig, renderRequest, |
|
|
|
|
renderResponse); |
|
|
|
|