Example #1
0
  public static UnitNamePart find(final String namePart) {
    final String normalizedNamePart = StringNormalizer.normalize(namePart);

    final UnitNamePart indexedUnitNamePart = unitNamePartIndexMap.get(normalizedNamePart);
    if (indexedUnitNamePart != null) {
      return indexedUnitNamePart;
    }

    for (final UnitNamePart unitNamePart : Bennu.getInstance().getUnitNamePartSet()) {
      final String otherUnitNamePart = unitNamePart.getNamePart();
      if (!unitNamePartIndexMap.containsKey(otherUnitNamePart)) {
        unitNamePartIndexMap.put(otherUnitNamePart, unitNamePart);
      }
      if (normalizedNamePart.equals(otherUnitNamePart)) {
        return unitNamePart;
      }
    }
    return null;
  }
  @Override
  public Collection<ExecutionDegree> getSearchResults(
      Map<String, String> argsMap, String value, int maxCount) {
    final String executionYearOid = argsMap.get("executionYearOid");
    final ExecutionYear executionYear = FenixFramework.getDomainObject(executionYearOid);

    final String searchValue = StringNormalizer.normalize(value);

    final List<ExecutionDegree> result = new ArrayList<ExecutionDegree>();
    for (final ExecutionDegree executionDegree : executionYear.getExecutionDegreesSet()) {
      final DegreeCurricularPlan degreeCurricularPlan = executionDegree.getDegreeCurricularPlan();
      final Degree degree = degreeCurricularPlan.getDegree();
      if (match(searchValue, degreeCurricularPlan.getName())
          || match(searchValue, degree.getNameI18N(executionYear).getContent())
          || match(searchValue, degree.getSigla())) {
        result.add(executionDegree);
        if (result.size() >= maxCount) {
          break;
        }
      }
    }
    return result;
  }
 private boolean match(final String stringToMatch, final String content) {
   final String normalizedContent = StringNormalizer.normalize(content);
   return normalizedContent.indexOf(stringToMatch) >= 0;
 }
Example #4
0
 public static String normalize(final String string) {
   return StringNormalizer.normalize(string.trim());
 }