Search in sources :

Example 26 with Proposal

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

the class GetAllProposalLineItems 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 ProposalLineItemService.
    ProposalLineItemServiceInterface proposalLineItemService = adManagerServices.get(session, ProposalLineItemServiceInterface.class);
    // Create a statement to select all proposal line items.
    StatementBuilder statementBuilder = new StatementBuilder().orderBy("id ASC").limit(StatementBuilder.SUGGESTED_PAGE_LIMIT);
    // Default for total result set size.
    int totalResultSetSize = 0;
    do {
        // Get proposal line items by statement.
        ProposalLineItemPage page = proposalLineItemService.getProposalLineItemsByStatement(statementBuilder.toStatement());
        if (page.getResults() != null) {
            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)

Example 27 with Proposal

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

the class UpdateProposalLineItems method runExample.

/**
 * Runs the example.
 *
 * @param adManagerServices the services factory.
 * @param session the session.
 * @param proposalLineItemId the ID of the proposal line item to update.
 * @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 proposalLineItemId) throws RemoteException {
    // Get the ProposalLineItemService.
    ProposalLineItemServiceInterface proposalLineItemService = adManagerServices.get(session, ProposalLineItemServiceInterface.class);
    // Create a statement to select a proposal line item.
    StatementBuilder statementBuilder = new StatementBuilder().where("WHERE id = :id").orderBy("id ASC").limit(StatementBuilder.SUGGESTED_PAGE_LIMIT).withBindVariableValue("id", proposalLineItemId);
    // Get the proposal line item.
    ProposalLineItemPage page = proposalLineItemService.getProposalLineItemsByStatement(statementBuilder.toStatement());
    ProposalLineItem proposalLineItem = Iterables.getOnlyElement(Arrays.asList(page.getResults()));
    // Update the proposal line item's note field.
    proposalLineItem.setInternalNotes("Proposal line item ready for submission.");
    // Update the proposal line item on the server.
    ProposalLineItem[] proposalLineItems = proposalLineItemService.updateProposalLineItems(new ProposalLineItem[] { proposalLineItem });
    for (ProposalLineItem updatedProposalLineItem : proposalLineItems) {
        System.out.printf("Proposal line item with ID %d and name '%s' was updated.%n", updatedProposalLineItem.getId(), updatedProposalLineItem.getName());
    }
}
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)

Example 28 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.v202205.RequestBuyerAcceptance action = new com.google.api.ads.admanager.axis.v202205.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.v202205.ProposalServiceInterface) ProposalPage(com.google.api.ads.admanager.axis.v202205.ProposalPage) StatementBuilder(com.google.api.ads.admanager.axis.utils.v202205.StatementBuilder) Proposal(com.google.api.ads.admanager.axis.v202205.Proposal) UpdateResult(com.google.api.ads.admanager.axis.v202205.UpdateResult)

Example 29 with Proposal

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

the class AbstractObservationDAOTest method getTestObservation.

private Observation getTestObservation(boolean full, int depth, boolean comp, boolean sci) throws Exception {
    Observation o;
    if (comp) {
        DerivedObservation obs = new DerivedObservation("TEST", "SimpleBar", new Algorithm("doit"));
        if (full) {
            obs.getMembers().add(new ObservationURI("TEST", "simple1"));
            obs.getMembers().add(new ObservationURI("TEST", "simple2"));
            obs.getMembers().add(new ObservationURI("TEST", "simple3"));
        }
        o = obs;
    } else
        o = new SimpleObservation("TEST", "SimpleBar");
    if (full) {
        o.metaProducer = URI.create("test:observation/roundrip-1.0");
        if (sci)
            o.intent = ObservationIntentType.SCIENCE;
        else {
            o.intent = ObservationIntentType.CALIBRATION;
            o.type = "flat";
        }
        o.sequenceNumber = new Integer(123);
        o.metaRelease = TEST_DATE;
        o.proposal = new Proposal("MyFirstProposal");
        o.proposal.getKeywords().addAll(TEST_KEYWORDS);
        o.proposal.pi = "little old me";
        o.proposal.title = "My Little Pony";
        o.proposal.project = "Project 51";
        o.target = new Target("Pony 51");
        o.target.targetID = URI.create("naif:1701");
        o.target.type = TargetType.OBJECT;
        o.target.getKeywords().addAll(TEST_KEYWORDS);
        o.target.standard = Boolean.TRUE;
        o.target.redshift = new Double(0.0);
        o.target.moving = Boolean.FALSE;
        o.targetPosition = new TargetPosition("FK5", new Point(1.0, 2.0));
        if (sci)
            o.targetPosition.equinox = 2000.0;
        o.requirements = new Requirements(Status.FAIL);
        o.telescope = new Telescope("BothEyes");
        o.telescope.getKeywords().addAll(TEST_KEYWORDS);
        o.telescope.geoLocationX = 100.0;
        o.telescope.geoLocationY = 200.0;
        o.telescope.geoLocationZ = 300.0;
        o.instrument = new Instrument("test-instrument");
        o.instrument.getKeywords().addAll(TEST_KEYWORDS);
        o.environment = new Environment();
        o.environment.seeing = 0.08;
        o.environment.photometric = Boolean.TRUE;
        o.getMetaReadGroups().add(URI.create("ivo://example.net/gms?GroupA"));
        o.getMetaReadGroups().add(URI.create("ivo://example.net/gms?GroupB"));
    }
    if (depth == 1)
        return o;
    o.getPlanes().add(getTestPlane(full, "thing1", depth, true));
    o.getPlanes().add(getTestPlane(full, "thing2", depth, false));
    Assert.assertEquals(2, o.getPlanes().size());
    return o;
}
Also used : ObservationURI(ca.nrc.cadc.caom2.ObservationURI) Telescope(ca.nrc.cadc.caom2.Telescope) Point(ca.nrc.cadc.caom2.types.Point) Algorithm(ca.nrc.cadc.caom2.Algorithm) TargetPosition(ca.nrc.cadc.caom2.TargetPosition) Requirements(ca.nrc.cadc.caom2.Requirements) DerivedObservation(ca.nrc.cadc.caom2.DerivedObservation) Target(ca.nrc.cadc.caom2.Target) SimpleObservation(ca.nrc.cadc.caom2.SimpleObservation) DerivedObservation(ca.nrc.cadc.caom2.DerivedObservation) Observation(ca.nrc.cadc.caom2.Observation) DeletedObservation(ca.nrc.cadc.caom2.DeletedObservation) SimpleObservation(ca.nrc.cadc.caom2.SimpleObservation) Instrument(ca.nrc.cadc.caom2.Instrument) Environment(ca.nrc.cadc.caom2.Environment) Proposal(ca.nrc.cadc.caom2.Proposal)

Example 30 with Proposal

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

the class CaomRepoTupleTests method testFutureDates.

@Test
public void testFutureDates() throws Exception {
    final Calendar futureCal = Calendar.getInstance();
    // Thirty years, nice round number.
    futureCal.add(Calendar.YEAR, 30);
    final String observationID = generateID("testFutureDates");
    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_futuredates");
    observation.metaRelease = futureCal.getTime();
    final Plane plane = new Plane(productID);
    // Test 1
    // Future data release and current meta release.
    plane.dataRelease = futureCal.getTime();
    plane.metaRelease = futureCal.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)

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