Ejemplo n.º 1
0
  @Override
  public List<ObjectAction> getObjectActions(
      final List<ActionType> types,
      final Contributed contributed,
      final Filter<ObjectAction> filter) {

    // update our list of actions if requesting for contributed actions
    // and they have not yet been added
    // the "contributed.isIncluded()" guard is required because we cannot do this too early;
    // there must be a session available
    if (contributed.isIncluded() && !contributeeActionsAdded) {
      synchronized (this.objectActions) {
        final List<ObjectAction> actions = Lists.newArrayList(this.objectActions);
        actions.addAll(createContributeeActions());
        sortCacheAndUpdateActions(actions);
        contributeeActionsAdded = true;
      }
    }

    final List<ObjectAction> actions = Lists.newArrayList();
    for (final ActionType type : types) {
      final Collection<ObjectAction> filterActions =
          Collections2.filter(objectActionsByType.get(type), Filters.asPredicate(filter));
      actions.addAll(filterActions);
    }
    return Lists.newArrayList(
        Iterables.filter(actions, ContributeeMember.Predicates.regularElse(contributed)));
  }
Ejemplo n.º 2
0
 @Override
 public List<ObjectAssociation> getAssociations(final Contributed contributed) {
   // the "contributed.isIncluded()" guard is required because we cannot do this too early;
   // there must be a session available
   if (contributed.isIncluded() && !contributeeAssociationsAdded) {
     synchronized (this.associations) {
       List<ObjectAssociation> associations = Lists.newArrayList(this.associations);
       associations.addAll(createContributeeAssociations());
       sortAndUpdateAssociations(associations);
       contributeeAssociationsAdded = true;
     }
   }
   final List<ObjectAssociation> associations = Lists.newArrayList(this.associations);
   return Lists.newArrayList(
       Iterables.filter(associations, ContributeeMember.Predicates.regularElse(contributed)));
 }