コード例 #1
0
  static AdGroupCriterion addPartition(
      long adGroupId,
      AdGroupCriterion parent,
      ProductCondition condition,
      ProductPartitionType partitionType,
      FixedBid bid,
      Boolean isNegative) {
    AdGroupCriterion adGroupCriterion = null;

    if (isNegative) {
      adGroupCriterion = new NegativeAdGroupCriterion();
    } else {
      adGroupCriterion = new BiddableAdGroupCriterion();
      ((BiddableAdGroupCriterion) adGroupCriterion).setCriterionBid(bid);
    }

    adGroupCriterion.setAdGroupId(adGroupId);

    ProductPartition criterion = new ProductPartition();
    criterion.setCondition(condition);
    criterion.setParentCriterionId((parent != null) ? parent.getId() : null);

    if (partitionType == ProductPartitionType.SUBDIVISION) {
      criterion.setPartitionType(ProductPartitionType.SUBDIVISION); // Branch
      adGroupCriterion.setId(_referenceId--);
    } else {
      criterion.setPartitionType(ProductPartitionType.UNIT); // Leaf
    }

    adGroupCriterion.setCriterion(criterion);

    addPartitionAction(adGroupCriterion, ItemAction.ADD);

    return adGroupCriterion;
  }
コード例 #2
0
  static void updateBranchAndLeafCriterion(long adGroupId, long rootId, long electronicsCriterionId)
      throws RemoteException, Exception {
    _partitionActions.getAdGroupCriterionActions().clear();

    AdGroupCriterion electronics = new BiddableAdGroupCriterion();
    electronics.setId(electronicsCriterionId);
    electronics.setAdGroupId(adGroupId);
    addPartitionAction(electronics, ItemAction.DELETE);

    BiddableAdGroupCriterion parent = new BiddableAdGroupCriterion();
    parent.setId(rootId);

    AdGroupCriterion electronicsSubdivision =
        addPartition(
            adGroupId,
            parent,
            new ProductCondition() {
              {
                setOperand("CategoryL1");
                setAttribute("Electronics");
              }
            },
            ProductPartitionType.SUBDIVISION,
            null,
            false);

    AdGroupCriterion brandC =
        addPartition(
            adGroupId,
            electronicsSubdivision,
            new ProductCondition() {
              {
                setOperand("Brand");
                setAttribute("Brand C");
              }
            },
            ProductPartitionType.UNIT,
            getFixedBid(0.35),
            false);

    AdGroupCriterion brandD =
        addPartition(
            adGroupId,
            electronicsSubdivision,
            new ProductCondition() {
              {
                setOperand("Brand");
                setAttribute("Brand D");
              }
            },
            ProductPartitionType.UNIT,
            getFixedBid(0.35),
            false);

    AdGroupCriterion otherElectronicBrands =
        addPartition(
            adGroupId,
            electronicsSubdivision,
            new ProductCondition() {
              {
                setOperand("Brand");
                setAttribute(null);
              }
            },
            ProductPartitionType.UNIT,
            getFixedBid(0.35),
            false);

    outputStatusMessage("Updating the electronics partition...\n");
    ApplyProductPartitionActionsResponse applyPartitionActionsResponse =
        applyPartitionActions(_partitionActions);

    ArrayOfAdGroupCriterion adGroupCriterions =
        getAdGroupCriterionsByIds(AccountId, adGroupId, null, CriterionType.PRODUCT_PARTITION);

    outputStatusMessage("The product partition group tree now has 12 nodes\n");
    printProductPartitions(adGroupCriterions);
  }