Ejemplo n.º 1
0
  static void addAndUpdateAdGroupCriterion(long adGroupId) throws RemoteException, Exception {
    // Add a biddable criterion as the root.

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

    outputStatusMessage("Applying a biddable criterion as the root...\n");

    ApplyProductPartitionActionsResponse applyPartitionActionsResponse =
        applyPartitionActions(_partitionActions);
    printCriterionIds(
        applyPartitionActionsResponse.getAdGroupCriterionIds(),
        applyPartitionActionsResponse.getPartialErrors());

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

    outputStatusMessage(
        "Printing the ad group's product partition; contains only the tree root node\n");
    printProductPartitions(adGroupCriterions);

    // Update the bid of the root node that we just added.

    BiddableAdGroupCriterion updatedRoot = new BiddableAdGroupCriterion();
    updatedRoot.setId(applyPartitionActionsResponse.getAdGroupCriterionIds().getLongs().get(0));
    updatedRoot.setAdGroupId(adGroupId);
    updatedRoot.setCriterionBid(getFixedBid(0.40));

    _partitionActions.getAdGroupCriterionActions().clear();

    addPartitionAction(updatedRoot, ItemAction.UPDATE);

    outputStatusMessage("Updating the bid for the tree root node...\n");

    applyPartitionActionsResponse = applyPartitionActions(_partitionActions);

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

    outputStatusMessage("Updated the bid for the tree root node\n");
    printProductPartitions(adGroupCriterions);
  }
Ejemplo n.º 2
0
  static void addPartitionAction(final AdGroupCriterion CRITERION, final ItemAction ITEM_ACTION) {
    AdGroupCriterionAction partitionAction =
        new AdGroupCriterionAction() {
          {
            action = ITEM_ACTION;
            adGroupCriterion = CRITERION;
          }
        };

    // _partitionActions is a global variable.

    _partitionActions.getAdGroupCriterionActions().add(partitionAction);
  }
Ejemplo n.º 3
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);
  }
Ejemplo n.º 4
0
  static ApplyProductPartitionActionsResponse addBranchAndLeafCriterion(long adGroupId)
      throws RemoteException, Exception {
    _partitionActions.getAdGroupCriterionActions().clear();

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

    AdGroupCriterion existingRoot = getRootNode(adGroupCriterions);

    if (existingRoot != null) {
      addPartitionAction(existingRoot, ItemAction.DELETE);
    }

    AdGroupCriterion root =
        addPartition(
            adGroupId,
            null,
            new ProductCondition() {
              {
                setOperand("All");
                setAttribute(null);
              }
            },
            ProductPartitionType.SUBDIVISION,
            null,
            false);

    AdGroupCriterion animalsSubdivision =
        addPartition(
            adGroupId,
            root,
            new ProductCondition() {
              {
                setOperand("CategoryL1");
                setAttribute("Animals & Pet Supplies");
              }
            },
            ProductPartitionType.SUBDIVISION,
            null,
            false);

    AdGroupCriterion petSuppliesSubdivision =
        addPartition(
            adGroupId,
            animalsSubdivision,
            new ProductCondition() {
              {
                setOperand("CategoryL2");
                setAttribute("Pet Supplies");
              }
            },
            ProductPartitionType.SUBDIVISION,
            null,
            false);

    AdGroupCriterion brandA =
        addPartition(
            adGroupId,
            petSuppliesSubdivision,
            new ProductCondition() {
              {
                setOperand("Brand");
                setAttribute("Brand A");
              }
            },
            ProductPartitionType.UNIT,
            getFixedBid(0.35),
            false);

    AdGroupCriterion brandB =
        addPartition(
            adGroupId,
            petSuppliesSubdivision,
            new ProductCondition() {
              {
                setOperand("Brand");
                setAttribute("Brand B");
              }
            },
            ProductPartitionType.UNIT,
            null,
            true);

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

    AdGroupCriterion otherPetSupplies =
        addPartition(
            adGroupId,
            animalsSubdivision,
            new ProductCondition() {
              {
                setOperand("CategoryL2");
                setAttribute(null);
              }
            },
            ProductPartitionType.UNIT,
            getFixedBid(0.35),
            false);

    AdGroupCriterion electronics =
        addPartition(
            adGroupId,
            root,
            new ProductCondition() {
              {
                setOperand("CategoryL1");
                setAttribute("Electronics");
              }
            },
            ProductPartitionType.UNIT,
            getFixedBid(0.35),
            false);

    AdGroupCriterion otherCategoryL1 =
        addPartition(
            adGroupId,
            root,
            new ProductCondition() {
              {
                setOperand("CategoryL1");
                setAttribute(null);
              }
            },
            ProductPartitionType.UNIT,
            getFixedBid(0.35),
            false);

    outputStatusMessage("Applying product partitions to the ad group...\n");
    ApplyProductPartitionActionsResponse applyPartitionActionsResponse =
        applyPartitionActions(_partitionActions);

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

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

    return applyPartitionActionsResponse;
  }