@Override
  @RequiresXsrfCheck
  protected String doExecute() throws Exception {
    // Find all possibly affected issues.
    final List<GenericValue> associatedProjects = getConfigScheme().getAssociatedProjects();
    if ((associatedProjects != null) && !associatedProjects.isEmpty()) {
      final List<Long> projectIds = GenericValueUtils.transformToLongIdsList(associatedProjects);
      final Collection<Option> obseleteOptions =
          CollectionUtils.subtract(getOriginalOptions(), getNewOptions());
      if ((obseleteOptions != null) && !obseleteOptions.isEmpty()) {
        final List<String> obseleteOptionIds = new ArrayList<String>(obseleteOptions.size());
        for (final Option option : obseleteOptions) {
          obseleteOptionIds.add(option.getId());
        }

        final Query query = getQuery(projectIds, obseleteOptionIds);
        final SearchResults searchResults =
            searchProvider.search(query, getLoggedInUser(), PagerFilter.getUnlimitedFilter());
        final List affectedIssues = searchResults.getIssues();
        if ((affectedIssues != null) && !affectedIssues.isEmpty()) {
          // Prepare for Update
          configScheme =
              new FieldConfigScheme.Builder(getConfigScheme())
                  .setName(getName())
                  .setDescription(getDescription())
                  .toFieldConfigScheme();
          final List<String> optionIds = new ArrayList<String>(Arrays.asList(getSelectedOptions()));

          return migrateIssues(this, affectedIssues, optionIds);
        }
      }
    }

    return super.doExecute();
  }
  @SuppressWarnings("unchecked")
  Collection<AbstractClass> getAllClassesFromReferedModels(FormCollection fc) {
    Set<AbstractClass> existing = new HashSet<AbstractClass>();
    Set<AbstractClass> all = new HashSet<AbstractClass>();

    EList<FormContainer> forms = fc.getForms();
    for (FormContainer formContainer : forms) {
      if (formContainer instanceof ClassReference) {
        ClassReference cr = (ClassReference) formContainer;
        AbstractClass real_class = cr.getReal_class();
        if (real_class instanceof Clazz) {
          existing.add(real_class);
        }
      }
    }
    List<Model> lm = new ArrayList<Model>();

    for (AbstractClass abstractClass : existing) {
      EObject rootContainer2 = CommonServices.getRootContainer(abstractClass);
      if (rootContainer2 instanceof Model) {
        Model rootContainer = (Model) rootContainer2;
        lm.add(rootContainer);
      }
    }

    for (Model package1 : lm) {
      EList<Clazz> allClasses = package1.getAllClasses();
      all.addAll(allClasses);
    }

    return CollectionUtils.subtract(all, existing);
  }
 protected boolean validGroupMemberPrincipalIDs(List<GroupDocumentMember> groupMembers) {
   boolean valid = true;
   List<String> principalIds = new ArrayList<String>();
   for (GroupDocumentMember groupMember : groupMembers) {
     if (StringUtils.equals(
         groupMember.getMemberTypeCode(),
         KimConstants.KimGroupMemberTypes.PRINCIPAL_MEMBER_TYPE.getCode())) {
       principalIds.add(groupMember.getMemberId());
     }
   }
   if (!principalIds.isEmpty()) {
     // retrieve valid principals/principal-ids from identity service
     List<Principal> validPrincipals = getIdentityService().getPrincipals(principalIds);
     List<String> validPrincipalIds = new ArrayList<String>(validPrincipals.size());
     for (Principal principal : validPrincipals) {
       validPrincipalIds.add(principal.getPrincipalId());
     }
     // check that there are no invalid principals in the principal list, return false
     List<String> invalidPrincipalIds =
         new ArrayList<String>(CollectionUtils.subtract(principalIds, validPrincipalIds));
     // if list is not empty add error messages and return false
     if (CollectionUtils.isNotEmpty(invalidPrincipalIds)) {
       GlobalVariables.getMessageMap()
           .putError(
               "document.member.memberId",
               RiceKeyConstants.ERROR_MEMBERID_MEMBERTYPE_MISMATCH,
               invalidPrincipalIds.toArray(new String[invalidPrincipalIds.size()]));
       valid = false;
     }
   }
   return valid;
 }
Beispiel #4
0
 /**
  * Busca las ventas eliminadas en siipap
  *
  * @param dia
  * @return
  */
 @SuppressWarnings("unchecked")
 public Collection<Venta> sobrantes(final Date dia) {
   List<Venta> win = buscarVentasEnSW(dia);
   List<Venta> siipap = getSupport().buscarVentasEnSiipap(dia);
   Collection<Venta> c = CollectionUtils.subtract(win, siipap);
   logger.info("Ventas sobrantes (No existentes en siipap DBF: " + c.size());
   return c;
 }
  private Set outputUrlResults(String url, Set m_inclset, Set m_exclset) {
    Set new_incls = new TreeSet(CollectionUtils.subtract(m_inclset, m_reported));
    Set new_excls = new TreeSet(CollectionUtils.subtract(m_exclset, m_reported));
    if (!m_inclset.isEmpty()) {
      outputMessage(
          "\nIncluded Urls: ("
              + new_incls.size()
              + " new, "
              + (m_inclset.size() - new_incls.size())
              + " old)",
          URL_SUMMARY_MESSAGE);
      depth_incl[m_curDepth - 1] += new_incls.size();
    }
    for (Iterator it = new_incls.iterator(); it.hasNext(); ) {
      outputMessage(it.next().toString(), PLAIN_MESSAGE);
    }

    if (!m_exclset.isEmpty()) {
      outputMessage(
          "\nExcluded Urls: ("
              + new_excls.size()
              + " new, "
              + (m_exclset.size() - new_excls.size())
              + " old)",
          URL_SUMMARY_MESSAGE);
    }
    for (Iterator it = new_excls.iterator(); it.hasNext(); ) {
      outputMessage(it.next().toString(), PLAIN_MESSAGE);
    }
    m_reported.addAll(new_incls);
    m_reported.addAll(new_excls);

    if (m_outWriter != null) {
      try {
        m_outWriter.flush();
      } catch (IOException ex) {
      }
    }
    return new_incls;
  }
  /**
   * Subtracts collection b from a (a-b) in safe manner. Following rules apply:
   *
   * <p>- If collection a is <code>null</code> or empty, then result is empty list<br>
   * - If collection b is <code>null</code> or empty, then result is a new list with same content as
   * a <br>
   * - If both collections have at least one element, results is {@link
   * CollectionUtils#subtract(Collection, Collection)}.<br>
   *
   * @param <E> Element types in collections.
   * @param a collection to subtract from
   * @param b collection to use in subtract
   * @return subtraction result
   * @see {@link CollectionUtils#subtract(Collection, Collection)}.
   */
  @SuppressWarnings("unchecked")
  public static <E> Collection<E> subtractSafe(Collection<E> a, Collection<E> b) {
    // if a is empty then return empty
    if (CollectionUtils.isEmpty(a)) {
      return Collections.emptyList();
    }

    // if b is empty, then return complete a as new list
    if (CollectionUtils.isEmpty(b)) {
      return new ArrayList<>(a);
    }

    // otherwise perform subtract
    return CollectionUtils.subtract(a, b);
  }
  public Collection getAllProjects() throws Exception {
    Collection availableProjects = Collections.EMPTY_LIST;

    final Collection projects = projectManager.getProjects();

    if (projects != null) {
      availableProjects = new ArrayList(projects);
      availableProjects =
          CollectionUtils.subtract(availableProjects, getCustomField().getAssociatedProjects());
      final FieldConfigScheme fieldConfigScheme = getFieldConfigScheme();
      if (fieldConfigScheme != null) {
        final List currentlySlectedProjects = fieldConfigScheme.getAssociatedProjects();
        if (currentlySlectedProjects != null) {
          availableProjects.addAll(currentlySlectedProjects);
        }
      }
    }

    return availableProjects;
  }
 private Collection<String> getNotSkippedTasks() {
   List all = getExecutedTasks();
   Set skipped = getSkippedTasks();
   return CollectionUtils.subtract(all, skipped);
 }
  /**
   * Updates the representation of the text form.
   *
   * @param invocations Invocations to display.
   */
  @SuppressWarnings("unchecked")
  private void updateRepresentation(List<InvocationSequenceData> invocations) {
    sourceInvocations = invocations;
    resetDisplayed = false;

    MutableDouble duration = new MutableDouble(0d);
    List<SqlStatementData> sqlList = new ArrayList<>();
    InvocationSequenceDataHelper.collectSqlsInInvocations(invocations, sqlList, duration);
    double totalInvocationsDuration = 0d;
    for (InvocationSequenceData inv : invocations) {
      totalInvocationsDuration += inv.getDuration();
    }
    double percentage = (duration.toDouble() / totalInvocationsDuration) * 100;

    slowest80List.clear();
    int slowest80 = getSlowestSqlCount(duration.toDouble(), sqlList, 0.8d, slowest80List);
    int slowest20 = sqlList.size() - slowest80;
    slowest20List = CollectionUtils.subtract(sqlList, slowest80List);

    totalSql.setText(
        "<form><p><b>" + TOTAL_SQLS + "</b> " + sqlList.size() + "</p></form>", true, false);
    totalDuration.setText(
        "<form><p><b>"
            + TOTAL_DURATION
            + "</b> "
            + NumberFormatter.formatDouble(duration.doubleValue())
            + " ms</p></form>",
        true,
        false);

    String formatedPercentage = NumberFormatter.formatDouble(percentage, 1);
    if (CollectionUtils.isNotEmpty(sqlList)) {
      Color durationInInvocationColor =
          ColorFormatter.getPerformanceColor(
              GREEN_RGB, YELLOW_RGB, RED_RGB, percentage, 20d, 80d, resourceManager);
      percentageOfDuration.setColor("durationInInvocationColor", durationInInvocationColor);
      percentageOfDuration.setText(
          "<form><p><b>"
              + SQLS_DURATION_IN_INVOCATION
              + "</b> <span color=\"durationInInvocationColor\">"
              + formatedPercentage
              + "%</span></p></form>",
          true,
          false);
    } else {
      percentageOfDuration.setText(
          "<form><p><b>"
              + SQLS_DURATION_IN_INVOCATION
              + "</b> "
              + formatedPercentage
              + "%</p></form>",
          true,
          false);
    }

    String slowest80String = getCountAndPercentage(slowest80, sqlList.size());
    String slowest20String = getCountAndPercentage(slowest20, sqlList.size());
    if (CollectionUtils.isNotEmpty(sqlList)) {
      double slowest80Percentage = ((double) slowest80 / sqlList.size()) * 100;
      if (Double.isNaN(slowest80Percentage)) {
        slowest80Percentage = 0;
      }
      Color color8020 =
          ColorFormatter.getPerformanceColor(
              GREEN_RGB, YELLOW_RGB, RED_RGB, slowest80Percentage, 70d, 10d, resourceManager);
      slowestCount.setColor(SLOWEST8020_COLOR, color8020);
      slowestHyperlinkSettings.setForeground(color8020);

      StringBuilder text = new StringBuilder("<b>" + SLOWEST_80_20 + "</b> ");
      if (slowest80 > 0) {
        text.append("<a href=\"" + SLOWEST80_LINK + "\">" + slowest80String + "</a>");
      } else {
        text.append("<span color=\"" + SLOWEST8020_COLOR + "\">" + slowest80String + "</span>");
      }
      text.append(" / ");
      if (slowest20 > 0) {
        text.append("<a href=\"" + SLOWEST20_LINK + "\">" + slowest20String + "</a>");
      } else {
        text.append("<span color=\"" + SLOWEST8020_COLOR + "\">" + slowest20String + "</span>");
      }
      slowestContent = text.toString();
    } else {
      slowestContent = "<b>" + SLOWEST_80_20 + "</b> " + slowest80String + " / " + slowest20String;
    }
    slowestCount.setText("<form><p>" + slowestContent + "</p></form>", true, false);

    main.layout();
  }