Exemple #1
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));
  }
Exemple #2
0
 @Transactional(propagation = Propagation.REQUIRES_NEW, readOnly = true)
 @Override
 public Collection<Role> findAllRoles(final User user) {
   return CollectionUtils.union(user.getRoles(), findDynRoleMemberships(user));
 }
  public arquitetura.representation.Class applyAdapter(Element target, Element adaptee) {
    arquitetura.representation.Class adapterClass = null;
    if (target != null
        && adaptee != null
        && (target instanceof arquitetura.representation.Class || target instanceof Interface)
        && (adaptee instanceof arquitetura.representation.Class || adaptee instanceof Interface)) {
      try {

        adapterClass = AdapterUtil.getAdapterClass(target, adaptee);
        if (adapterClass == null) {
          adapterClass = AdapterUtil.createAdapterClass(adaptee);
        }
        // Implements/Extends and add all methods.
        if (target instanceof arquitetura.representation.Class) {
          ElementUtil.extendClass(adapterClass, (arquitetura.representation.Class) target);
        } else {
          ElementUtil.implementInterface(adapterClass, (Interface) target);
        }

        RelationshipUtil.createNewUsageRelationship("adaptee", adapterClass, adaptee);

        Relationship relationshipToBeExcluded = null;
        if (adaptee.getClass().equals(target.getClass())) {
          for (Relationship relationship : ElementUtil.getRelationships(adaptee)) {
            if (target.equals(RelationshipUtil.getSuperElement(relationship))) {
              relationshipToBeExcluded = relationship;
              break;
            }
          }
        } else {
          for (Relationship relationship : ElementUtil.getRelationships(adaptee)) {
            if (target.equals(RelationshipUtil.getImplementedInterface(relationship))) {
              relationshipToBeExcluded = relationship;
              break;
            }
          }
        }

        if (relationshipToBeExcluded != null) {
          ArchitectureRepository.getCurrentArchitecture()
              .removeRelationship(relationshipToBeExcluded);
        }

        // Copy concerns
        for (Concern concern :
            CollectionUtils.union(target.getOwnConcerns(), adaptee.getOwnConcerns())) {
          try {
            adapterClass.addConcern(concern.getName());
          } catch (ConcernNotFoundException ex) {
            Logger.getLogger(Adapter.class.getName()).log(Level.SEVERE, null, ex);
          }
        }

        // Move variants
        Variant variant = adaptee.getVariant();
        if (variant != null) {
          adaptee.setVariant(null);
          adapterClass.setVariant(variant);
          variant.setVariantElement(adapterClass);
        }

        addStereotype(target);
        addStereotype(adaptee);
        addStereotype(adapterClass);
      } catch (Exception ex) {
        Logger.getLogger(Adapter.class.getName()).log(Level.SEVERE, null, ex);
      }
    }
    return adapterClass;
  }