Esempio n. 1
0
  public static NxsDataset instanciate(final URI destination, final boolean withWriteAccess)
      throws NoResultException {
    NxsDataset dataset = null;
    String filePath = destination.getPath();
    if (filePath != null) {
      try {
        dataset = new NxsDataset(new File(filePath), withWriteAccess);
        String fragment = destination.getFragment();

        if (fragment != null && !fragment.isEmpty()) {
          IGroup group = dataset.getRootGroup();
          try {
            String path = URLDecoder.decode(fragment, "UTF-8");
            for (IContainer container : group.findAllContainerByPath(path)) {
              if (container.getModelType().equals(ModelType.Group)) {
                dataset.mRootPhysical = (IGroup) container;
                break;
              }
            }
          } catch (UnsupportedEncodingException e) {
            Factory.getLogger().log(Level.WARNING, e.getMessage());
          }
        }
      } catch (Exception e) {
        throw new NoResultException(e);
      }
    }
    return dataset;
  }
Esempio n. 2
0
 @Override
 public IGroup getGroup(String shortName) {
   if (shortName != null) {
     for (IGroup group : groupList) {
       if (shortName.equals(group.getName())) {
         return group;
       }
     }
   }
   return null;
 }
Esempio n. 3
0
 @Override
 public String toString() {
   StringBuffer buffer = new StringBuffer();
   IGroup parent = getParentGroup();
   buffer.append(
       "Group "
           + getShortName()
           + " (parent = "
           + ((parent == null) ? "Nobody" : parent.getName())
           + ")");
   return buffer.toString();
 }
Esempio n. 4
0
 @Override
 public IDataset getDataset() {
   if (dataset == null) {
     IGroup root = getRootGroup();
     if (root == null) {
       return null;
     } else {
       return root.getDataset();
     }
   } else {
     return dataset;
   }
 }
Esempio n. 5
0
  @Override
  public IGroup getGroupWithAttribute(final String attributeName, final String value) {
    List<IGroup> groups = getGroupList();
    IAttribute attr;
    for (IGroup group : groups) {
      attr = group.getAttribute(attributeName);
      if (attr.getStringValue().equals(value)) {
        return group;
      }
    }

    return null;
  }
Esempio n. 6
0
 @Override
 public IGroup getGroupWithAttribute(String attributeName, String value) {
   if (name != null) {
     for (IGroup group : groupList) {
       IAttribute attribute = group.getAttribute(name);
       if (attribute != null) {
         if (StringUtils.isSameString(value, attribute.getStringValue())) {
           return group;
         }
       }
     }
   }
   return null;
 }
Esempio n. 7
0
 @Override
 public void addSubgroup(IGroup group) {
   if ((group instanceof EdfGroup) && (!groupList.contains(group))) {
     groupList.add((EdfGroup) group);
     objectList.add((EdfGroup) group);
     group.setParent(this);
   }
 }
Esempio n. 8
0
  @Override
  public void setDimensions(String dimString) {
    IGroup parent = getParentGroup();

    List<String> dimNames = java.util.Arrays.asList(dimString.split(" "));
    List<IDataItem> items = parent.getDataItemList();

    for (IDataItem item : items) {
      IAttribute attr = item.getAttribute("axis");
      if (attr != null) {
        try {
          IDimension dim =
              new BasicDimension(item.getName(), item.getData(), false, item.isUnlimited(), false);
          if ("*".equals(dimString)) {
            setDimension(dim, attr.getNumericValue().intValue());
          } else if (dimNames.contains(attr.getName())) {
            setDimension(dim, attr.getNumericValue().intValue());
          }
        } catch (IOException e) {
          e.printStackTrace();
        }
      }
    }
  }
Esempio n. 9
0
 @Override
 public IGroup createGroup(IGroup parent, String shortName) {
   ArchivingGroup group = null;
   if ((shortName != null) && !shortName.isEmpty()) {
     if (parent != null) {
       if (parent instanceof ArchivingGroup) {
         group =
             new ArchivingGroup(
                 NAME, (ArchivingDataset) parent.getDataset(), (ArchivingGroup) parent, shortName);
       }
     } else {
       group = new ArchivingGroup(NAME, null, null, shortName);
     }
   }
   return group;
 }
Esempio n. 10
0
 @Override
 public boolean removeGroup(final IGroup group) {
   return removeGroup(group.getShortName());
 }
Esempio n. 11
0
 @Override
 public void addSubgroup(final IGroup group) {
   group.setParent(this);
   groupMap.put(group.getShortName(), group);
 }