Пример #1
0
  @Override
  public List<IDataItem> getDataItemList() {
    listChildren();

    ArrayList<IDataItem> list = new ArrayList<IDataItem>();
    for (IContainer container : mChildren) {
      if (container.getModelType() == ModelType.DataItem) {
        list.add((IDataItem) container);
      }
    }

    return list;
  }
Пример #2
0
  @Override
  public List<IGroup> getGroupList() {
    listChildren();

    ArrayList<IGroup> list = new ArrayList<IGroup>();
    for (IContainer container : mChildren) {
      if (container.getModelType() == ModelType.Group) {
        list.add((IGroup) container);
      }
    }

    return list;
  }
Пример #3
0
  @Override
  public IContainer getContainer(String shortName) {
    List<IContainer> list = listChildren();
    IContainer result = null;

    for (IContainer container : list) {
      if (container.getShortName().equals(shortName)) {
        result = container;
        break;
      }
    }

    return result;
  }
Пример #4
0
  @Override
  public IDataItem findDataItemWithAttribute(IKey key, String name, String attribute)
      throws NoResultException {
    List<IContainer> list = findAllContainers(key);
    IDataItem result = null;
    for (IContainer item : list) {
      if (item.getModelType() == ModelType.DataItem && item.hasAttribute(name, attribute)) {
        result = (IDataItem) item;
        break;
      }
    }

    return result;
  }
Пример #5
0
  @Override
  public List<IContainer> findAllContainerByPath(String path) throws NoResultException {
    List<IContainer> list = new ArrayList<IContainer>();
    List<IContainer> tmp = null;
    String tmpName;

    // Store in a map all different containers from all m_groups
    Map<String, ArrayList<IContainer>> items = new HashMap<String, ArrayList<IContainer>>();
    for (IGroup group : mGroups) {
      try {
        tmp = group.findAllContainerByPath(path);
        for (IContainer item : tmp) {
          tmpName = item.getShortName();
          if (items.containsKey(tmpName)) {
            items.get(tmpName).add(item);
          } else {
            ArrayList<IContainer> tmpList = new ArrayList<IContainer>();
            tmpList.add(item);
            items.put(tmpName, tmpList);
          }
        }
      } catch (NoResultException e) {
        // Nothing to do
      }
    }

    // Construct that were found
    for (Entry<String, ArrayList<IContainer>> entry : items.entrySet()) {
      tmp = entry.getValue();
      // If a Group list then construct a new Group folder
      if (tmp.get(0).getModelType() == ModelType.Group) {
        list.add(new NxsGroup(tmp.toArray(new IGroup[tmp.size()]), this, mDataset));
      }
      // If a IDataItem list then construct a new compound NxsDataItem
      else {
        ArrayList<NexusDataItem> dataItems = new ArrayList<NexusDataItem>();
        for (IContainer item : tmp) {
          if (item.getModelType() == ModelType.DataItem) {
            dataItems.add((NexusDataItem) item);
          }
        }
        NexusDataItem[] array = new NexusDataItem[dataItems.size()];
        dataItems.toArray(array);
        list.add(new NxsDataItem(array, this, mDataset));
      }
    }

    return list;
  }
Пример #6
0
  private List<IContainer> listChildrenMultiGroup() {
    if (!mIsChildUpdate) {
      List<IContainer> tmp = null;
      mChildren = new ArrayList<IContainer>();
      String tmpName;

      // Store in a map all different containers from all m_groups
      Map<String, ArrayList<IContainer>> items = new HashMap<String, ArrayList<IContainer>>();
      for (IGroup group : mGroups) {
        tmp = new ArrayList<IContainer>();
        tmp.addAll(group.getDataItemList());
        tmp.addAll(group.getGroupList());
        for (IContainer item : tmp) {
          tmpName = item.getShortName();
          if (items.containsKey(tmpName)) {
            items.get(tmpName).add(item);
          } else {
            ArrayList<IContainer> tmpList = new ArrayList<IContainer>();
            tmpList.add(item);
            items.put(tmpName, tmpList);
          }
        }
      }

      // Construct what were found
      for (Entry<String, ArrayList<IContainer>> entry : items.entrySet()) {
        tmp = entry.getValue();
        // If a Group list then construct a new Group folder
        if (tmp.get(0).getModelType() == ModelType.Group) {
          mChildren.add(new NxsGroup(tmp.toArray(new IGroup[tmp.size()]), this, mDataset));
        }
        // If a IDataItem list then construct a new compound NxsDataItem
        else {
          ArrayList<NexusDataItem> nxsDataItems = new ArrayList<NexusDataItem>();
          for (IContainer item : tmp) {
            if (item.getModelType() == ModelType.DataItem) {
              nxsDataItems.add((NexusDataItem) item);
            }
          }
          NexusDataItem[] array = new NexusDataItem[nxsDataItems.size()];
          nxsDataItems.toArray(array);
          mChildren.add(new NxsDataItem(array, this, mDataset));
        }
      }
      mIsChildUpdate = true;
    }
    return mChildren;
  }
Пример #7
0
  @Override
  public IPathParameter resolvePathParameter(IContainer item) {
    IPathParameter result = null;
    String[] groupParts = item.getName().split(Pattern.quote(mPathSeparator));
    String[] pathParts = mPath.getValue().split(Pattern.quote(mPathSeparator));
    String part, param, buff;

    // Parse the path
    for (int depth = 0; depth < groupParts.length; depth++) {
      if (depth < pathParts.length) {
        part = groupParts[depth];
        param = pathParts[depth];

        // If a parameter is defined
        if (param.matches(".*(" + mPath.PARAM_PATTERN + ")+.*")) {
          // Try to determine the parameter result
          buff = param.replaceFirst("^(.*)(" + mPath.PARAM_PATTERN + ".*)$", "$1");
          part = part.substring(buff.length());
          buff = param.replaceAll(".*" + mPath.PARAM_PATTERN, "");
          part = part.replaceFirst(Pattern.quote(buff), "");
          buff = param.replaceAll(".*" + mPath.PARAM_PATTERN + ".*", "$1");
          result =
              new PathParameter(
                  Factory.getFactory(getFactoryName()), ParameterType.SUBSTITUTION, buff, part);
          break;
        }
      }
    }
    return result;
  }
Пример #8
0
 public NxsGroup(IGroup parent, PathNexus path, NxsDataset dataset) {
   try {
     List<IContainer> list = dataset.getRootGroup().findAllContainerByPath(path.getValue());
     List<IGroup> groups = new ArrayList<IGroup>();
     for (IContainer container : list) {
       if (container.getModelType() == ModelType.Group) {
         groups.add((IGroup) container);
       }
     }
     IGroup[] array = new IGroup[groups.size()];
     mGroups = groups.toArray(array);
   } catch (NoResultException e) {
   }
   mParent = parent;
   mDataset = dataset;
   mChildren = null;
   mIsChildUpdate = false;
 }
Пример #9
0
  @Override
  public IGroup findGroup(IKey key) {
    IGroup item = null;
    List<IContainer> list = new ArrayList<IContainer>();
    try {
      list = findAllOccurrences(key);
    } catch (NoResultException e) {
    }

    for (IContainer object : list) {
      if (object.getModelType().equals(ModelType.Group)) {
        item = (IGroup) object;
        break;
      }
    }

    return item;
  }
Пример #10
0
  @Override
  public IGroup findGroupWithAttribute(IKey key, String name, String value) {
    List<IContainer> list;
    try {
      list = findAllContainers(key);
    } catch (NoResultException e) {
      list = new ArrayList<IContainer>();
    }
    IGroup result = null;
    for (IContainer item : list) {
      if (item.getModelType() == ModelType.Group && item.hasAttribute(name, value)) {
        result = (IGroup) item;
        break;
      }
    }

    return result;
  }