Esempio n. 1
0
  static AdGroupCriterion getRootNode(ArrayOfAdGroupCriterion adGroupCriterions) {
    AdGroupCriterion rootNode = null;

    for (AdGroupCriterion adGroupCriterion : adGroupCriterions.getAdGroupCriterions()) {
      if (((ProductPartition) adGroupCriterion.getCriterion()).getParentCriterionId() == null) {
        rootNode = adGroupCriterion;
        break;
      }
    }

    return rootNode;
  }
Esempio n. 2
0
  static void printProductPartitions(ArrayOfAdGroupCriterion adGroupCriterions) {
    Map<Long, ArrayList<AdGroupCriterion>> childBranches =
        new HashMap<Long, ArrayList<AdGroupCriterion>>();
    AdGroupCriterion treeRoot = null;

    for (AdGroupCriterion adGroupCriterion : adGroupCriterions.getAdGroupCriterions()) {
      ProductPartition partition = (ProductPartition) adGroupCriterion.getCriterion();
      childBranches.put(adGroupCriterion.getId(), new ArrayList<AdGroupCriterion>());

      if (partition.getParentCriterionId() != null) {
        childBranches.get(partition.getParentCriterionId()).add(adGroupCriterion);
      } else {
        treeRoot = adGroupCriterion;
      }
    }

    printProductPartitionTree(treeRoot, childBranches, 0);
  }