예제 #1
0
 /**
  * Checks if a given persistence configuration entry is relevant for an item
  *
  * @param config the persistence configuration entry
  * @param item to check if the configuration applies to
  * @return true, if the configuration applies to the item
  */
 protected boolean appliesToItem(PersistenceConfiguration config, Item item) {
   for (EObject itemCfg : config.getItems()) {
     if (itemCfg instanceof AllConfig) {
       return true;
     }
     if (itemCfg instanceof ItemConfig) {
       ItemConfig singleItemConfig = (ItemConfig) itemCfg;
       if (item.getName().equals(singleItemConfig.getItem())) {
         return true;
       }
     }
     if (itemCfg instanceof GroupConfig) {
       GroupConfig groupItemCfg = (GroupConfig) itemCfg;
       String groupName = groupItemCfg.getGroup();
       try {
         Item gItem = itemRegistry.getItem(groupName);
         if (gItem instanceof GroupItem) {
           GroupItem groupItem = (GroupItem) gItem;
           if (groupItem.getAllMembers().contains(item)) {
             return true;
           }
         }
       } catch (Exception e) {
       }
     }
   }
   return false;
 }
예제 #2
0
  /**
   * Retrieves all items for which the persistence configuration applies to.
   *
   * @param config the persistence configuration entry
   * @return all items that this configuration applies to
   */
  protected Iterable<Item> getAllItems(PersistenceConfiguration config) {
    // first check, if we should return them all
    for (EObject itemCfg : config.getItems()) {
      if (itemCfg instanceof AllConfig) {
        return itemRegistry.getItems();
      }
    }

    // otherwise, go through the detailed definitions
    Set<Item> items = new HashSet<Item>();
    for (EObject itemCfg : config.getItems()) {
      if (itemCfg instanceof ItemConfig) {
        ItemConfig singleItemConfig = (ItemConfig) itemCfg;
        try {
          Item item = itemRegistry.getItem(singleItemConfig.getItem());
          items.add(item);
        } catch (ItemNotFoundException e) {
          logger.debug("Item '{}' does not exist.", singleItemConfig.getItem());
        }
      }
      if (itemCfg instanceof GroupConfig) {
        GroupConfig groupItemCfg = (GroupConfig) itemCfg;
        String groupName = groupItemCfg.getGroup();
        try {
          Item gItem = itemRegistry.getItem(groupName);
          if (gItem instanceof GroupItem) {
            GroupItem groupItem = (GroupItem) gItem;
            items.addAll(groupItem.getAllMembers());
          }
        } catch (ItemNotFoundException e) {
          logger.debug("Item group '{}' does not exist.", groupName);
        }
      }
    }
    return items;
  }