@Override
  public List<String> findGuestNamesByCompany(final String company) {
    List<Guest> all = repository.findAll();
    List<Guest> filtered =
        ListUtils.select(
            all,
            new Predicate<Guest>() {
              public boolean evaluate(Guest g) {
                return company.equals(g.getCompany());
              }
            });

    Collections.sort(
        filtered,
        new Comparator<Guest>() {
          @Override
          public int compare(Guest o1, Guest o2) {
            return Integer.compare(o1.getGrade(), o2.getGrade());
          }
        });

    Collection<String> names =
        CollectionUtils.collect(
            filtered,
            new Transformer<Guest, String>() {
              public String transform(Guest g) {
                return g.getName();
              }
            });

    return new ArrayList<>(names);
  }
  /** @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) */
  protected void doGet(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
    System.out.println(request.getRequestURI());

    Collection<File> traceFiles =
        Arrays.asList(
            traceDirectory.listFiles(
                (FilenameFilter) new WildcardFileFilter("*.json", IOCase.INSENSITIVE)));

    if (request.getRequestURI().endsWith("unusedTraces")) {
      traceFiles = extractUnusedTraceFiles(traceFiles);
    }

    Collection<SelectOptionDTO> traceFileDTOs =
        CollectionUtils.collect(
            traceFiles,
            new Transformer<File, SelectOptionDTO>() {
              @Override
              public SelectOptionDTO transform(File f) {
                SelectOptionDTO dto = new SelectOptionDTO();
                dto.value = MessageFormat.format(TRACE_URL_FORMAT, f.getName());
                dto.text = f.getName().replace(".json", "");
                return dto;
              }
            });

    String json = new GsonBuilder().setPrettyPrinting().create().toJson(traceFileDTOs);

    response.setCharacterEncoding("UTF-8");
    response.getWriter().append(json);
  }
  /**
   * Get available configuration properties.
   *
   * @param instance connector instance.
   * @return configuration properties.
   */
  @Override
  protected final List<ConnConfProperty> getConnProperties(final ConnInstanceTO instance) {

    final List<ConnConfProperty> res =
        CollectionUtils.collect(
            ConnectorModal.getBundle(instance, bundles).getProperties(),
            new Transformer<ConnConfPropSchema, ConnConfProperty>() {

              @Override
              public ConnConfProperty transform(final ConnConfPropSchema key) {
                final ConnConfProperty property = new ConnConfProperty();
                property.setSchema(key);

                if (instance.getKey() != null
                    && instance.getConfMap().containsKey(key.getName())
                    && instance.getConfMap().get(key.getName()).getValues() != null) {

                  property.getValues().addAll(instance.getConfMap().get(key.getName()).getValues());
                  property.setOverridable(instance.getConfMap().get(key.getName()).isOverridable());
                }

                if (property.getValues().isEmpty() && !key.getDefaultValues().isEmpty()) {
                  property.getValues().addAll(key.getDefaultValues());
                }
                return property;
              }
            },
            new ArrayList<ConnConfProperty>());

    return res;
  }
Esempio n. 4
0
  @Transactional(propagation = Propagation.REQUIRES_NEW, readOnly = true)
  @Override
  public Collection<String> findAllResourceNames(final User user) {
    return CollectionUtils.collect(
        findAllResources(user),
        new Transformer<ExternalResource, String>() {

          @Override
          public String transform(final ExternalResource input) {
            return input.getKey();
          }
        });
  }
Esempio n. 5
0
  @Transactional(propagation = Propagation.REQUIRES_NEW, readOnly = true)
  @Override
  public Collection<Long> findAllGroupKeys(final User user) {
    return CollectionUtils.collect(
        findAllGroups(user),
        new Transformer<Group, Long>() {

          @Override
          public Long transform(final Group input) {
            return input.getKey();
          }
        });
  }
Esempio n. 6
0
  @PreAuthorize("isAuthenticated()")
  public List<SecurityQuestionTO> list() {
    return CollectionUtils.collect(
        securityQuestionDAO.findAll(),
        new Transformer<SecurityQuestion, SecurityQuestionTO>() {

          @Override
          public SecurityQuestionTO transform(final SecurityQuestion input) {
            return binder.getSecurityQuestionTO(input);
          }
        },
        new ArrayList<SecurityQuestionTO>());
  }
Esempio n. 7
0
 public static String[] buildLookupAttributeIds(
     BinaryAttributeDetector binaryAttrDetector, @Nullable Set<Attribute> attrs) {
   // noinspection ConstantConditions
   return (!CollectionUtils.isEmpty(attrs)
       ? ToolCollectionUtils.toArray(
           CollectionUtils.select(
               IteratorUtils.asIterable(
                   ToolIteratorUtils.chainedArrayIterator(
                       CollectionUtils.collect(
                           attrs, new LdapAttributeIdTransformer(binaryAttrDetector)))),
               PredicateUtils.uniquePredicate()),
           String.class)
       : ArrayUtils.EMPTY_STRING_ARRAY);
 }
Esempio n. 8
0
 private List<FieldDescriptor> createFieldList(TypeElement serviceElement) {
   return ListUtils.unmodifiableList(
       CollectionUtils.collect(
           serviceElement.getEnclosedElements(),
           new Transformer<Element, FieldDescriptor>() {
             @Override
             public FieldDescriptor transform(Element enclosed) {
               FieldDescriptor fieldDescriptor =
                   enclosed.accept(AnnotationFieldVisitor.INSTANCE, utils);
               return fieldDescriptor;
             }
           },
           new ArrayList<FieldDescriptor>()));
 }
Esempio n. 9
0
  @Transactional(propagation = Propagation.REQUIRES_NEW, readOnly = true)
  @Override
  public Collection<Group> findAllGroups(final User user) {
    return CollectionUtils.union(
        CollectionUtils.collect(
            user.getMemberships(),
            new Transformer<UMembership, Group>() {

              @Override
              public Group transform(final UMembership input) {
                return input.getRightEnd();
              }
            },
            new ArrayList<Group>()),
        findDynGroupMemberships(user));
  }