Search in sources :

Example 1 with Proposal

use of ca.nrc.cadc.caom2.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 ca.nrc.cadc.caom2.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 ca.nrc.cadc.caom2.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 ca.nrc.cadc.caom2.Proposal in project googleads-java-lib by googleads.

the class CreateProposals method runExample.

/**
 * Runs the example.
 *
 * @param adManagerServices the services factory.
 * @param session the session.
 * @param primarySalespersonId the ID of the primary salesperson.
 * @param primaryTraffickerId the ID of the primary trafficker.
 * @param programmaticBuyerId the ID of the programmatic buyer. This can be obtained through the
 *     Programmatic_Buyer PQL table.
 * @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 primarySalespersonId, long primaryTraffickerId, long programmaticBuyerId) throws RemoteException {
    ProposalServiceInterface proposalService = adManagerServices.get(session, ProposalServiceInterface.class);
    Proposal proposal = new Proposal();
    // Setting required Marketplace information.
    ProposalMarketplaceInfo proposalMarketplaceInfo = new ProposalMarketplaceInfo();
    proposalMarketplaceInfo.setBuyerAccountId(programmaticBuyerId);
    // Set common required fields for a proposal.
    proposal.setName("Proposal #" + new Random().nextInt(Integer.MAX_VALUE));
    proposal.setPrimaryTraffickerId(primaryTraffickerId);
    proposal.setMarketplaceInfo(proposalMarketplaceInfo);
    SalespersonSplit primarySalesperson = new SalespersonSplit();
    primarySalesperson.setUserId(primarySalespersonId);
    proposal.setPrimarySalesperson(primarySalesperson);
    // Create the proposal on the server.
    Proposal[] proposals = proposalService.createProposals(new Proposal[] { proposal });
    for (Proposal createdProposal : proposals) {
        System.out.printf("A proposal with ID %d and name '%s' " + "was created.%n", createdProposal.getId(), createdProposal.getName());
    }
}
Also used : ProposalServiceInterface(com.google.api.ads.admanager.axis.v202205.ProposalServiceInterface) Random(java.util.Random) ProposalMarketplaceInfo(com.google.api.ads.admanager.axis.v202205.ProposalMarketplaceInfo) SalespersonSplit(com.google.api.ads.admanager.axis.v202205.SalespersonSplit) Proposal(com.google.api.ads.admanager.axis.v202205.Proposal)

Example 5 with Proposal

use of ca.nrc.cadc.caom2.Proposal in project googleads-java-lib by googleads.

the class GetAllProposals method runExample.

/**
 * Runs the example.
 *
 * @param adManagerServices the services factory.
 * @param session the session.
 * @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) throws RemoteException {
    // Get the ProposalService.
    ProposalServiceInterface proposalService = adManagerServices.get(session, ProposalServiceInterface.class);
    // Create a statement to select all proposals.
    StatementBuilder statementBuilder = new StatementBuilder().orderBy("id ASC").limit(StatementBuilder.SUGGESTED_PAGE_LIMIT);
    // Default for total result set size.
    int totalResultSetSize = 0;
    do {
        // Get proposals by statement.
        ProposalPage page = proposalService.getProposalsByStatement(statementBuilder.toStatement());
        if (page.getResults() != null) {
            totalResultSetSize = page.getTotalResultSetSize();
            int i = page.getStartIndex();
            for (Proposal proposal : page.getResults()) {
                System.out.printf("%d) Proposal with ID %d and name '%s' was found.%n", i++, proposal.getId(), proposal.getName());
            }
        }
        statementBuilder.increaseOffsetBy(StatementBuilder.SUGGESTED_PAGE_LIMIT);
    } while (statementBuilder.getOffset() < totalResultSetSize);
    System.out.printf("Number of results found: %d%n", totalResultSetSize);
}
Also used : ProposalPage(com.google.api.ads.admanager.axis.v202205.ProposalPage) ProposalServiceInterface(com.google.api.ads.admanager.axis.v202205.ProposalServiceInterface) StatementBuilder(com.google.api.ads.admanager.axis.utils.v202205.StatementBuilder) Proposal(com.google.api.ads.admanager.axis.v202205.Proposal)

Aggregations

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 ProposalServiceInterface (com.google.api.ads.admanager.axis.v202205.ProposalServiceInterface)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 StatementBuilder (com.google.api.ads.admanager.axis.utils.v202205.StatementBuilder)4 ProposalPage (com.google.api.ads.admanager.axis.v202108.ProposalPage)4 ProposalPage (com.google.api.ads.admanager.axis.v202111.ProposalPage)4 ProposalPage (com.google.api.ads.admanager.axis.v202202.ProposalPage)4 ProposalPage (com.google.api.ads.admanager.axis.v202205.ProposalPage)4