Search in sources :

Example 1 with Proposal

use of com.google.api.ads.admanager.axis.v202205.Proposal in project caom2db by opencadc.

the class ReadAccessGeneratorTest method getSampleObservation.

Observation getSampleObservation(final String id, final int numPlanes, Date now, long dateOffset) {
    Observation obs = new SimpleObservation("obsID_" + id, "collectionID_" + id);
    obs.proposal = new Proposal("proposalID_" + id);
    Date rd = null;
    if (now != null) {
        rd = new Date(now.getTime() + dateOffset);
    }
    obs.metaRelease = rd;
    for (int i = 0; i < numPlanes; i++) {
        Plane p = new Plane("productID_" + id + i);
        if (now != null) {
            p.metaRelease = rd;
            p.dataRelease = rd;
        }
        obs.getPlanes().add(p);
        Artifact a = new Artifact(URI.create("cadc:FOO/bar"), ProductType.SCIENCE, ReleaseType.DATA);
        p.getArtifacts().add(a);
    }
    return obs;
}
Also used : Plane(ca.nrc.cadc.caom2.Plane) SimpleObservation(ca.nrc.cadc.caom2.SimpleObservation) Observation(ca.nrc.cadc.caom2.Observation) SimpleObservation(ca.nrc.cadc.caom2.SimpleObservation) Proposal(ca.nrc.cadc.caom2.Proposal) Date(java.util.Date) Artifact(ca.nrc.cadc.caom2.Artifact)

Example 2 with Proposal

use of com.google.api.ads.admanager.axis.v202205.Proposal in project caom2db by opencadc.

the class CaomRepoTupleTests method testPastDates.

@Test
public void testPastDates() throws Exception {
    final Calendar pastCal = Calendar.getInstance();
    // November 25th, 1977.
    pastCal.set(1977, Calendar.NOVEMBER, 25, 1, 51, 0);
    pastCal.set(Calendar.MILLISECOND, 0);
    final String observationID = generateID("testPastDates");
    final String path = TEST_COLLECTION + "/" + observationID;
    final String productID = generateID(TEST_PRODUCT_ID_PREFIX);
    final String uri = SCHEME + path;
    final Observation observation = new SimpleObservation(TEST_COLLECTION, observationID);
    observation.proposal = new Proposal("proposal777_pastdates");
    observation.metaRelease = pastCal.getTime();
    final Plane plane = new Plane(productID);
    // Test 1
    // Past data release and current meta release.
    plane.dataRelease = pastCal.getTime();
    plane.metaRelease = pastCal.getTime();
    observation.getPlanes().add(plane);
    // ensurePutAndDelete(observation, uri);
    sendObservation("PUT", observation, subject1, 200, "OK", null);
}
Also used : Plane(ca.nrc.cadc.caom2.Plane) SimpleObservation(ca.nrc.cadc.caom2.SimpleObservation) Calendar(java.util.Calendar) SimpleObservation(ca.nrc.cadc.caom2.SimpleObservation) Observation(ca.nrc.cadc.caom2.Observation) Proposal(ca.nrc.cadc.caom2.Proposal) Test(org.junit.Test)

Example 3 with Proposal

use of com.google.api.ads.admanager.axis.v202205.Proposal in project googleads-java-lib by googleads.

the class RequestBuyerAcceptance method runExample.

/**
 * Runs the example.
 *
 * @param adManagerServices the services factory.
 * @param session the session.
 * @param proposalId the proposal ID to send.
 * @throws ApiException if the API request failed with one or more service errors.
 * @throws RemoteException if the API request failed due to other errors.
 */
public static void runExample(AdManagerServices adManagerServices, AdManagerSession session, long proposalId) throws RemoteException {
    // Get the ProposalService.
    ProposalServiceInterface proposalService = adManagerServices.get(session, ProposalServiceInterface.class);
    // Create a statement to only select a single proposal by ID.
    StatementBuilder statementBuilder = new StatementBuilder().where("WHERE id = :id").orderBy("id ASC").limit(StatementBuilder.SUGGESTED_PAGE_LIMIT).withBindVariableValue("id", proposalId);
    // Retrieve a small amount of proposals at a time, paging through until all
    // proposals have been retrieved.
    int totalResultSetSize = 0;
    do {
        ProposalPage page = proposalService.getProposalsByStatement(statementBuilder.toStatement());
        if (page.getResults() != null) {
            // Print out some information for each proposal.
            totalResultSetSize = page.getTotalResultSetSize();
            int i = page.getStartIndex();
            for (Proposal proposal : page.getResults()) {
                System.out.printf("%d) Proposal with ID %d and name '%s' will be sent to Marketplace for buyer " + "acceptance.%n", i++, proposal.getId(), proposal.getName());
            }
        }
        statementBuilder.increaseOffsetBy(StatementBuilder.SUGGESTED_PAGE_LIMIT);
    } while (statementBuilder.getOffset() < totalResultSetSize);
    System.out.printf("Number of proposals to be sent to Marketplace for buyer acceptance: %d%n", totalResultSetSize);
    if (totalResultSetSize > 0) {
        // Remove limit and offset from statement.
        statementBuilder.removeLimitAndOffset();
        // Create action.
        com.google.api.ads.admanager.axis.v202108.RequestBuyerAcceptance action = new com.google.api.ads.admanager.axis.v202108.RequestBuyerAcceptance();
        // Perform action.
        UpdateResult result = proposalService.performProposalAction(action, statementBuilder.toStatement());
        if (result != null && result.getNumChanges() > 0) {
            System.out.printf("Number of proposals that were sent to Marketplace for buyer acceptance: %d%n", result.getNumChanges());
        } else {
            System.out.println("No proposals were sent to Marketplace for buyer acceptance.");
        }
    }
}
Also used : ProposalServiceInterface(com.google.api.ads.admanager.axis.v202108.ProposalServiceInterface) ProposalPage(com.google.api.ads.admanager.axis.v202108.ProposalPage) StatementBuilder(com.google.api.ads.admanager.axis.utils.v202108.StatementBuilder) Proposal(com.google.api.ads.admanager.axis.v202108.Proposal) UpdateResult(com.google.api.ads.admanager.axis.v202108.UpdateResult)

Example 4 with Proposal

use of com.google.api.ads.admanager.axis.v202205.Proposal in project googleads-java-lib by googleads.

the class CreateProposalLineItems method runExample.

/**
 * Runs the example.
 *
 * @param adManagerServices the services factory.
 * @param session the session.
 * @param proposalId the ID of the proposal that the proposal line items will belong to.
 * @throws ApiException if the API request failed with one or more service errors.
 * @throws RemoteException if the API request failed due to other errors.
 */
public static void runExample(AdManagerServices adManagerServices, AdManagerSession session, long proposalId) throws RemoteException {
    ProposalLineItemServiceInterface proposalLineItemService = adManagerServices.get(session, ProposalLineItemServiceInterface.class);
    NetworkServiceInterface networkService = adManagerServices.get(session, NetworkServiceInterface.class);
    ProposalLineItem proposalLineItem = new ProposalLineItem();
    // Set common required fields for a proposal line item.
    proposalLineItem.setName("Proposal line item #" + new Random().nextInt(Integer.MAX_VALUE));
    proposalLineItem.setProposalId(proposalId);
    proposalLineItem.setLineItemType(LineItemType.STANDARD);
    // Get the root ad unit ID used to target the whole site.
    String rootAdUnitId = networkService.getCurrentNetwork().getEffectiveRootAdUnitId();
    // Create inventory targeting.
    InventoryTargeting inventoryTargeting = new InventoryTargeting();
    // Create ad unit targeting for the root ad unit (i.e. the whole network).
    AdUnitTargeting adUnitTargeting = new AdUnitTargeting();
    adUnitTargeting.setAdUnitId(rootAdUnitId);
    adUnitTargeting.setIncludeDescendants(true);
    inventoryTargeting.setTargetedAdUnits(new AdUnitTargeting[] { adUnitTargeting });
    // Target display environment
    RequestPlatformTargeting requestPlatformTargeting = new RequestPlatformTargeting();
    requestPlatformTargeting.setTargetedRequestPlatforms(new RequestPlatform[] { RequestPlatform.BROWSER });
    // Target Display environment by excluding Mobile Apps.
    // DeviceCapabilities can be obtained though the Device_Capability PQL table:
    // https://developers.google.com/ad-manager/api/reference/latest/PublisherQueryLanguageService
    DeviceCapability mobileApps = new DeviceCapability();
    mobileApps.setId(5005L);
    DeviceCapabilityTargeting deviceCapabilityTargeting = new DeviceCapabilityTargeting();
    deviceCapabilityTargeting.setExcludedDeviceCapabilities(new DeviceCapability[] { mobileApps });
    TechnologyTargeting technologyTargeting = new TechnologyTargeting();
    technologyTargeting.setDeviceCapabilityTargeting(deviceCapabilityTargeting);
    // Create targeting.
    Targeting targeting = new Targeting();
    targeting.setInventoryTargeting(inventoryTargeting);
    targeting.setRequestPlatformTargeting(requestPlatformTargeting);
    targeting.setTechnologyTargeting(technologyTargeting);
    proposalLineItem.setTargeting(targeting);
    // Create creative placeholder size.
    Size size = new Size();
    size.setWidth(300);
    size.setHeight(250);
    size.setIsAspectRatio(false);
    // Create the creative placeholder.
    CreativePlaceholder creativePlaceholder = new CreativePlaceholder();
    creativePlaceholder.setSize(size);
    // Set the size of creatives that can be associated with this proposal line item.
    proposalLineItem.setCreativePlaceholders(new CreativePlaceholder[] { creativePlaceholder });
    // Set the length of the proposal line item to run.
    proposalLineItem.setStartDateTime(DateTimes.toDateTime(Instant.now(), "America/New_York"));
    proposalLineItem.setEndDateTime(DateTimes.toDateTime(Instant.now().plus(Duration.standardDays(30L)), "America/New_York"));
    // Set delivery specifications for the proposal line item.
    proposalLineItem.setDeliveryRateType(DeliveryRateType.EVENLY);
    // Set pricing for the proposal line item for 1000 impressions at a CPM of $2
    // for a total value of $2.
    Goal goal = new Goal();
    goal.setUnits(1000L);
    goal.setUnitType(UnitType.IMPRESSIONS);
    proposalLineItem.setGoal(goal);
    proposalLineItem.setNetRate(new Money("USD", 2000000L));
    proposalLineItem.setRateType(RateType.CPM);
    ProposalLineItem[] proposalLineItems = proposalLineItemService.createProposalLineItems(new ProposalLineItem[] { proposalLineItem });
    for (ProposalLineItem createdProposalLineItem : proposalLineItems) {
        System.out.printf("A proposal line item with ID %d and name '%s' was created.%n", createdProposalLineItem.getId(), createdProposalLineItem.getName());
    }
}
Also used : DeviceCapabilityTargeting(com.google.api.ads.admanager.axis.v202205.DeviceCapabilityTargeting) NetworkServiceInterface(com.google.api.ads.admanager.axis.v202205.NetworkServiceInterface) RequestPlatformTargeting(com.google.api.ads.admanager.axis.v202205.RequestPlatformTargeting) AdUnitTargeting(com.google.api.ads.admanager.axis.v202205.AdUnitTargeting) DeviceCapabilityTargeting(com.google.api.ads.admanager.axis.v202205.DeviceCapabilityTargeting) RequestPlatformTargeting(com.google.api.ads.admanager.axis.v202205.RequestPlatformTargeting) Targeting(com.google.api.ads.admanager.axis.v202205.Targeting) InventoryTargeting(com.google.api.ads.admanager.axis.v202205.InventoryTargeting) TechnologyTargeting(com.google.api.ads.admanager.axis.v202205.TechnologyTargeting) Size(com.google.api.ads.admanager.axis.v202205.Size) InventoryTargeting(com.google.api.ads.admanager.axis.v202205.InventoryTargeting) CreativePlaceholder(com.google.api.ads.admanager.axis.v202205.CreativePlaceholder) Money(com.google.api.ads.admanager.axis.v202205.Money) Goal(com.google.api.ads.admanager.axis.v202205.Goal) AdUnitTargeting(com.google.api.ads.admanager.axis.v202205.AdUnitTargeting) Random(java.util.Random) ProposalLineItem(com.google.api.ads.admanager.axis.v202205.ProposalLineItem) TechnologyTargeting(com.google.api.ads.admanager.axis.v202205.TechnologyTargeting) ProposalLineItemServiceInterface(com.google.api.ads.admanager.axis.v202205.ProposalLineItemServiceInterface) DeviceCapability(com.google.api.ads.admanager.axis.v202205.DeviceCapability)

Example 5 with Proposal

use of com.google.api.ads.admanager.axis.v202205.Proposal in project googleads-java-lib by googleads.

the class GetProposalLineItemsForProposal method runExample.

/**
 * Runs the example.
 *
 * @param adManagerServices the services factory.
 * @param session the session.
 * @param proposalId the ID of the proposal.
 * @throws ApiException if the API request failed with one or more service errors.
 * @throws RemoteException if the API request failed due to other errors.
 */
public static void runExample(AdManagerServices adManagerServices, AdManagerSession session, long proposalId) throws RemoteException {
    ProposalLineItemServiceInterface proposalLineItemService = adManagerServices.get(session, ProposalLineItemServiceInterface.class);
    // Create a statement to select proposal line items.
    StatementBuilder statementBuilder = new StatementBuilder().where("proposalId = :proposalId").orderBy("id ASC").limit(StatementBuilder.SUGGESTED_PAGE_LIMIT).withBindVariableValue("proposalId", proposalId);
    // Retrieve a small amount of proposal line items at a time, paging through
    // until all proposal line items have been retrieved.
    int totalResultSetSize = 0;
    do {
        ProposalLineItemPage page = proposalLineItemService.getProposalLineItemsByStatement(statementBuilder.toStatement());
        if (page.getResults() != null) {
            // Print out some information for each proposal line item.
            totalResultSetSize = page.getTotalResultSetSize();
            int i = page.getStartIndex();
            for (ProposalLineItem proposalLineItem : page.getResults()) {
                System.out.printf("%d) Proposal line item with ID %d and name '%s' was found.%n", i++, proposalLineItem.getId(), proposalLineItem.getName());
            }
        }
        statementBuilder.increaseOffsetBy(StatementBuilder.SUGGESTED_PAGE_LIMIT);
    } while (statementBuilder.getOffset() < totalResultSetSize);
    System.out.printf("Number of results found: %d%n", totalResultSetSize);
}
Also used : ProposalLineItem(com.google.api.ads.admanager.axis.v202205.ProposalLineItem) StatementBuilder(com.google.api.ads.admanager.axis.utils.v202205.StatementBuilder) ProposalLineItemPage(com.google.api.ads.admanager.axis.v202205.ProposalLineItemPage) ProposalLineItemServiceInterface(com.google.api.ads.admanager.axis.v202205.ProposalLineItemServiceInterface)

Aggregations

StatementBuilder (com.google.api.ads.admanager.axis.utils.v202205.StatementBuilder)9 ProposalServiceInterface (com.google.api.ads.admanager.axis.v202205.ProposalServiceInterface)6 Observation (ca.nrc.cadc.caom2.Observation)5 Proposal (ca.nrc.cadc.caom2.Proposal)5 SimpleObservation (ca.nrc.cadc.caom2.SimpleObservation)5 Proposal (com.google.api.ads.admanager.axis.v202108.Proposal)5 ProposalServiceInterface (com.google.api.ads.admanager.axis.v202108.ProposalServiceInterface)5 Proposal (com.google.api.ads.admanager.axis.v202111.Proposal)5 ProposalServiceInterface (com.google.api.ads.admanager.axis.v202111.ProposalServiceInterface)5 Proposal (com.google.api.ads.admanager.axis.v202202.Proposal)5 ProposalServiceInterface (com.google.api.ads.admanager.axis.v202202.ProposalServiceInterface)5 Proposal (com.google.api.ads.admanager.axis.v202205.Proposal)5 ProposalLineItem (com.google.api.ads.admanager.axis.v202205.ProposalLineItem)5 ProposalLineItemServiceInterface (com.google.api.ads.admanager.axis.v202205.ProposalLineItemServiceInterface)5 Random (java.util.Random)5 Plane (ca.nrc.cadc.caom2.Plane)4 StatementBuilder (com.google.api.ads.admanager.axis.utils.v202108.StatementBuilder)4 StatementBuilder (com.google.api.ads.admanager.axis.utils.v202111.StatementBuilder)4 StatementBuilder (com.google.api.ads.admanager.axis.utils.v202202.StatementBuilder)4 ProposalPage (com.google.api.ads.admanager.axis.v202108.ProposalPage)4