/*
  * NOTE FOR DEVELOPERS:
  *
  * Never modify or reference this class directly. All methods that expect a kaleo task assignment model instance should use the {@link KaleoTaskAssignment} interface instead.
  */
 public void persist() throws SystemException {
   if (this.isNew()) {
     KaleoTaskAssignmentLocalServiceUtil.addKaleoTaskAssignment(this);
   } else {
     KaleoTaskAssignmentLocalServiceUtil.updateKaleoTaskAssignment(this);
   }
 }
  protected void initActionableDynamicQuery(ActionableDynamicQuery actionableDynamicQuery) {
    actionableDynamicQuery.setBaseLocalService(
        com.liferay.portal.workflow.kaleo.service.KaleoTaskAssignmentLocalServiceUtil.getService());
    actionableDynamicQuery.setClassLoader(getClassLoader());
    actionableDynamicQuery.setModelClass(KaleoTaskAssignment.class);

    actionableDynamicQuery.setPrimaryKeyPropertyName("kaleoTaskAssignmentId");
  }
  @Override
  public ActionableDynamicQuery getActionableDynamicQuery() {
    ActionableDynamicQuery actionableDynamicQuery = new DefaultActionableDynamicQuery();

    actionableDynamicQuery.setBaseLocalService(
        com.liferay.portal.workflow.kaleo.service.KaleoTaskAssignmentLocalServiceUtil.getService());
    actionableDynamicQuery.setClassLoader(getClassLoader());
    actionableDynamicQuery.setModelClass(KaleoTaskAssignment.class);

    actionableDynamicQuery.setPrimaryKeyPropertyName("kaleoTaskAssignmentId");

    return actionableDynamicQuery;
  }
  protected List<KaleoTaskAssignment> getCalculatedKaleoTaskAssignments(
      KaleoTaskInstanceToken kaleoTaskInstanceToken) throws PortalException {

    List<KaleoTaskAssignment> calculatedKaleoTaskAssignments = new ArrayList<>();

    KaleoInstanceToken kaleoInstanceToken = kaleoTaskInstanceToken.getKaleoInstanceToken();

    Map<String, Serializable> workflowContext =
        WorkflowContextUtil.convert(kaleoTaskInstanceToken.getWorkflowContext());

    ServiceContext workflowContextServiceContext =
        (ServiceContext) workflowContext.get(WorkflowConstants.CONTEXT_SERVICE_CONTEXT);

    ExecutionContext executionContext =
        new ExecutionContext(kaleoInstanceToken, workflowContext, workflowContextServiceContext);

    List<KaleoTaskAssignment> configuredKaleoTaskAssignments =
        KaleoTaskAssignmentLocalServiceUtil.getKaleoTaskAssignments(
            kaleoTaskInstanceToken.getKaleoTaskId());

    for (KaleoTaskAssignment configuredKaleoTaskAssignment : configuredKaleoTaskAssignments) {

      String[] assigneeScriptRequiredContexts =
          StringUtil.split(configuredKaleoTaskAssignment.getAssigneeScriptRequiredContexts());

      ClassLoader[] classLoaders = ClassLoaderUtil.getClassLoaders(assigneeScriptRequiredContexts);

      Collection<KaleoTaskAssignment> kaleoTaskAssignments =
          _taskAssignmentSelector.calculateTaskAssignments(
              configuredKaleoTaskAssignment, executionContext, classLoaders);

      calculatedKaleoTaskAssignments.addAll(kaleoTaskAssignments);
    }

    return calculatedKaleoTaskAssignments;
  }
 public void save() throws SystemException {
   KaleoTaskAssignmentLocalServiceUtil.updateKaleoTaskAssignment(this);
 }