Salvatore La Manna
3 anni fa
23 ha cambiato i file con 152 aggiunte e 104 eliminazioni
@ -0,0 +1,68 @@ |
|||||||
|
package it.mwg.sismica.bo.util; |
||||||
|
|
||||||
|
import it.mwg.sismica.bo.shared.util.Generics; |
||||||
|
import it.tref.liferay.portos.bo.model.ControlloPratica; |
||||||
|
|
||||||
|
import java.util.Arrays; |
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
import com.liferay.portal.kernel.dao.orm.QueryUtil; |
||||||
|
import com.liferay.portal.kernel.exception.PortalException; |
||||||
|
import com.liferay.portal.kernel.exception.SystemException; |
||||||
|
import com.liferay.portal.kernel.log.Log; |
||||||
|
import com.liferay.portal.kernel.log.LogFactoryUtil; |
||||||
|
import com.liferay.portal.kernel.util.StringPool; |
||||||
|
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.WorkflowLogManagerUtil; |
||||||
|
import com.liferay.portal.kernel.workflow.WorkflowTask; |
||||||
|
import com.liferay.portal.kernel.workflow.WorkflowTaskManagerUtil; |
||||||
|
import com.liferay.portal.kernel.workflow.comparator.WorkflowComparatorFactoryUtil; |
||||||
|
import com.liferay.portal.model.User; |
||||||
|
import com.liferay.portal.model.WorkflowInstanceLink; |
||||||
|
import com.liferay.portal.service.UserLocalServiceUtil; |
||||||
|
import com.liferay.portal.service.WorkflowInstanceLinkLocalServiceUtil; |
||||||
|
|
||||||
|
public class WorkflowUtil { |
||||||
|
|
||||||
|
private static final Log _log = LogFactoryUtil.getLog(WorkflowUtil.class); |
||||||
|
|
||||||
|
public static String provenienza(ControlloPratica cp) { |
||||||
|
|
||||||
|
String provenienza = StringPool.DASH; |
||||||
|
long companyId = cp.getCompanyId(); |
||||||
|
try { |
||||||
|
WorkflowInstanceLink link = WorkflowInstanceLinkLocalServiceUtil.getWorkflowInstanceLink(companyId, |
||||||
|
cp.getGroupId(), ControlloPratica.class.getName(), cp.getPrimaryKey()); |
||||||
|
WorkflowInstance instance = WorkflowInstanceManagerUtil.getWorkflowInstance(companyId, |
||||||
|
link.getWorkflowInstanceId()); |
||||||
|
List<WorkflowLog> logs = WorkflowLogManagerUtil.getWorkflowLogsByWorkflowInstance(companyId, |
||||||
|
instance.getWorkflowInstanceId(), Arrays.asList(WorkflowLog.TASK_ASSIGN), QueryUtil.ALL_POS, |
||||||
|
QueryUtil.ALL_POS, WorkflowComparatorFactoryUtil.getLogCreateDateComparator(true)); |
||||||
|
String taskName = null; |
||||||
|
long userId = 0; |
||||||
|
for (WorkflowLog log : logs) { |
||||||
|
if (log.getAuditUserId() != 0 && log.getRoleId() == 0 && log.getWorkflowTaskId() != 0) { |
||||||
|
WorkflowTask task = WorkflowTaskManagerUtil.getWorkflowTask(companyId, log.getWorkflowTaskId()); |
||||||
|
if (task.isCompleted()) { |
||||||
|
taskName = task.getName(); |
||||||
|
} |
||||||
|
if (log.getUserId() != log.getAuditUserId() || task.isCompleted()) { |
||||||
|
userId = log.getAuditUserId(); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
if (userId != 0) { |
||||||
|
User audit = UserLocalServiceUtil.fetchUser(userId); |
||||||
|
provenienza = Generics.capitalizeFull(audit.getFullName()); |
||||||
|
if (null != taskName) { |
||||||
|
provenienza += " (" + taskName + ')'; |
||||||
|
} |
||||||
|
} |
||||||
|
} catch (PortalException | SystemException e) { |
||||||
|
_log.error(e, e); |
||||||
|
} |
||||||
|
return provenienza; |
||||||
|
} |
||||||
|
} |
Caricamento…
Reference in new issue