Example #1
0
  /**
   * @param type
   * @return a map whose keys are the values corresponding to nodes of type 'type' and the values
   *     are the number of them
   */
  private Map<String, Integer> extractNodes(NodeType type) {
    Map<String, Integer> resultNodes = new HashMap<String, Integer>();

    List<ISANode> node = graph.getNodes(type);

    for (ISANode nodeOfInterest : node) {
      // extract the values!
      for (int rowIndex = 1; rowIndex < assayTable.length; rowIndex++) {
        if (nodeOfInterest.getIndex() < assayTable[rowIndex].length) {

          String[] row =
              Arrays.copyOf(assayTable[rowIndex], assayTable[rowIndex].length, String[].class);
          String value = row[nodeOfInterest.getIndex()];
          if (value != null && !value.equals("")) {
            if (!resultNodes.containsKey(value)) {
              resultNodes.put(value, 1);
            } else {
              int newCount = resultNodes.get(value) + 1;
              resultNodes.put(value, newCount);
            }
          }
        }
      }
    }

    return resultNodes;
  }
Example #2
0
  /** @return Map with structure: < attribute name , < attribute value , row count >> */
  public Map<String, Map<String, Integer>> extractMaterialAttributes() {
    Map<String, Map<String, Integer>> resultNodes = new HashMap<String, Map<String, Integer>>();

    List<ISANode> node = graph.getNodes(NodeType.MATERIAL_NODE);

    for (ISANode nodeOfInterest : node) {
      // extract the values!
      MaterialNode materialNode = (MaterialNode) nodeOfInterest;

      for (ISANode property : materialNode.getMaterialAttributes()) {

        for (int rowIndex = 1; rowIndex < assayTable.length; rowIndex++) {

          if (property.getIndex() < assayTable[rowIndex].length) {
            String[] row =
                Arrays.copyOf(assayTable[rowIndex], assayTable[rowIndex].length, String[].class);

            String value = row[property.getIndex()];
            if (value != null && !value.equals("")) {

              if (!resultNodes.containsKey(property.getName())) {
                resultNodes.put(property.getName(), new HashMap<String, Integer>());
              }

              if (!resultNodes.get(property.getName()).containsKey(value)) {
                resultNodes.get(property.getName()).put(value, 1);
              } else {
                int newCount = resultNodes.get(property.getName()).get(value) + 1;
                resultNodes.get(property.getName()).put(value, newCount);
              }
            }
          }
        }
      }
    }
    return resultNodes;
  }