public static void runExample(DfpServices dfpServices, DfpSession session, long packageId) throws Exception { // Get the PackageService. PackageServiceInterface packageService = dfpServices.get(session, PackageServiceInterface.class); // Create a statement to select a single package. StatementBuilder statementBuilder = new StatementBuilder() .where("id = :id") .orderBy("id ASC") .limit(1) .withBindVariableValue("id", packageId); // Get the package. PackagePage page = packageService.getPackagesByStatement(statementBuilder.toStatement()); Package pkg = Iterables.getOnlyElement(Arrays.asList(page.getResults())); // Update the comments of the package. pkg.setComments("This package is ready to be made into proposal line items."); // Update the package on the server. Package[] packages = packageService.updatePackages(new Package[] {pkg}); for (Package updatedPackage : packages) { System.out.printf( "Package with ID %d and name '%s' was updated.%n", updatedPackage.getId(), updatedPackage.getName()); } }
public static void runExample( DfpServices dfpServices, DfpSession session, long reconciliationReportId) throws Exception { // Get the ReconciliationOrderReportService. ReconciliationOrderReportServiceInterface reconciliationOrderReportService = dfpServices.get(session, ReconciliationOrderReportServiceInterface.class); // Create a statement to select reconciliation order reports. StatementBuilder statementBuilder = new StatementBuilder() .where("reconciliationReportId = :reconciliationReportId") .orderBy("id ASC") .limit(StatementBuilder.SUGGESTED_PAGE_LIMIT) .withBindVariableValue("reconciliationReportId", reconciliationReportId); // Default for total result set size. int totalResultSetSize = 0; do { // Get reconciliation order reports by statement. ReconciliationOrderReportPage page = reconciliationOrderReportService.getReconciliationOrderReportsByStatement( statementBuilder.toStatement()); if (page.getResults() != null) { totalResultSetSize = page.getTotalResultSetSize(); int i = page.getStartIndex(); for (ReconciliationOrderReport reconciliationOrderReport : page.getResults()) { System.out.printf( "%d) Reconciliation order report with ID %d and status '%s' was found.%n", i++, reconciliationOrderReport.getId(), reconciliationOrderReport.getStatus()); } } statementBuilder.increaseOffsetBy(StatementBuilder.SUGGESTED_PAGE_LIMIT); } while (statementBuilder.getOffset() < totalResultSetSize); System.out.printf("Number of results found: %d%n", totalResultSetSize); }