Exemplo n.º 1
0
 /**
  * This is a method that will create list of all main entities. (Entities for which entity passed
  * to it is having containment association)
  *
  * @param entity entity
  * @param mainEntityList mainEntityList
  * @return mainEntityList List of main entities
  */
 public static List<EntityInterface> getAllMainEntities(
     EntityInterface entity, List<EntityInterface> mainEntities) {
   List<EntityInterface> mainEntityList = mainEntities;
   try {
     List<AssociationInterface> associationList = getIncomingContainmentAssociations(entity);
     if (associationList.isEmpty()) {
       mainEntityList.add(entity);
     } else {
       for (AssociationInterface assocoation : associationList) {
         mainEntityList = getAllMainEntities(assocoation.getEntity(), mainEntityList);
       }
     }
   } catch (DynamicExtensionsSystemException deException) {
     logger.error(deException.getMessage(), deException);
   }
   return mainEntityList;
 }
Exemplo n.º 2
0
  /**
   * This method will internally call getIncomingAssociationIds of DE which will return all incoming
   * associations for entities passed.This method will filter out all incoming containment
   * associations and return list of them.
   *
   * @param entity entity
   * @throws DynamicExtensionsSystemException DynamicExtensionsSystemException
   * @return list List of incoming containment associations.
   */
  public static List<AssociationInterface> getIncomingContainmentAssociations(
      EntityInterface entity) throws DynamicExtensionsSystemException {
    EntityManagerInterface entityManager = EntityManager.getInstance();
    ArrayList<Long> allIds = (ArrayList<Long>) entityManager.getIncomingAssociationIds(entity);
    List<AssociationInterface> list = new ArrayList<AssociationInterface>();
    for (Long id : allIds) {
      AssociationInterface associationById = EntityCache.getInstance().getAssociationById(id);

      RoleInterface targetRole = associationById.getTargetRole();
      if (targetRole
          .getAssociationsType()
          .getValue()
          .equals(AQConstants.CONTAINTMENT_ASSOCIATION)) {
        list.add(associationById);
      }
    }
    return list;
  }