@Override
  public Collection<KaleoTaskAssignment> calculateTaskAssignments(
      KaleoTaskAssignment kaleoTaskAssignment, ExecutionContext executionContext)
      throws PortalException {

    KaleoInstanceToken kaleoInstanceToken = executionContext.getKaleoInstanceToken();

    Group group = null;

    long groupId = kaleoInstanceToken.getGroupId();

    if (groupId != WorkflowConstants.DEFAULT_GROUP_ID) {
      group = _groupLocalService.getGroup(groupId);

      if (group.isLayout()) {
        group = _groupLocalService.getGroup(group.getParentGroupId());
      }
    }

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

    if (isValidAssignment(kaleoTaskAssignment, group)) {
      calculatedKaleoTaskAssignments.add(kaleoTaskAssignment);
    }

    return calculatedKaleoTaskAssignments;
  }
Пример #2
0
  public static Tuple getElements(String xml, String className, int inactiveGroupsCount) {

    List<Element> resultRows = new ArrayList<>();
    int totalRows = 0;

    try {
      xml = XMLUtil.stripInvalidChars(xml);

      Document document = SAXReaderUtil.read(xml);

      Element rootElement = document.getRootElement();

      List<Element> elements = rootElement.elements("entry");

      totalRows =
          GetterUtil.getInteger(
              rootElement.elementText(
                  OpenSearchUtil.getQName("totalResults", OpenSearchUtil.OS_NAMESPACE)));

      for (Element element : elements) {
        try {
          long entryScopeGroupId =
              GetterUtil.getLong(
                  element.elementText(
                      OpenSearchUtil.getQName("scopeGroupId", OpenSearchUtil.LIFERAY_NAMESPACE)));

          if ((entryScopeGroupId != 0) && (inactiveGroupsCount > 0)) {
            Group entryGroup = GroupServiceUtil.getGroup(entryScopeGroupId);

            if (entryGroup.isLayout()) {
              entryGroup = GroupLocalServiceUtil.getGroup(entryGroup.getParentGroupId());
            }

            if (!entryGroup.isActive()) {
              totalRows--;

              continue;
            }
          }

          resultRows.add(element);
        } catch (Exception e) {
          _log.error("Unable to retrieve individual search result for " + className, e);

          totalRows--;
        }
      }
    } catch (Exception e) {
      _log.error("Unable to display content for " + className, e);
    }

    return new Tuple(resultRows, totalRows);
  }