Search in sources :

Example 1 with ReconciliationMode

use of com.google.cloud.retail.v2.ImportProductsRequest.ReconciliationMode in project java-retail by googleapis.

the class ImportProductsBigQueryTable method getImportProductsBigQueryRequest.

public static ImportProductsRequest getImportProductsBigQueryRequest(ReconciliationMode reconciliationMode) {
    BigQuerySource bigQuerySource = BigQuerySource.newBuilder().setProjectId(PROJECT_ID).setDatasetId(DATASET_ID).setTableId(TABLE_ID).setDataSchema(DATA_SCHEMA).build();
    ProductInputConfig inputConfig = ProductInputConfig.newBuilder().setBigQuerySource(bigQuerySource).build();
    ImportProductsRequest importRequest = ImportProductsRequest.newBuilder().setParent(DEFAULT_CATALOG).setReconciliationMode(reconciliationMode).setInputConfig(inputConfig).build();
    System.out.printf("Import products from big query table request: %s%n", importRequest);
    return importRequest;
}
Also used : ImportProductsRequest(com.google.cloud.retail.v2.ImportProductsRequest) ProductInputConfig(com.google.cloud.retail.v2.ProductInputConfig) BigQuerySource(com.google.cloud.retail.v2.BigQuerySource)

Example 2 with ReconciliationMode

use of com.google.cloud.retail.v2.ImportProductsRequest.ReconciliationMode in project java-retail by googleapis.

the class ImportProductsBigQueryTable method getImportProductsBigQueryRequest.

public static ImportProductsRequest getImportProductsBigQueryRequest(ReconciliationMode reconciliationMode, String projectId, String datasetId, String tableId, String dataSchema, String branchName) {
    BigQuerySource bigQuerySource = BigQuerySource.newBuilder().setProjectId(projectId).setDatasetId(datasetId).setTableId(tableId).setDataSchema(dataSchema).build();
    ProductInputConfig inputConfig = ProductInputConfig.newBuilder().setBigQuerySource(bigQuerySource).build();
    ImportProductsRequest importRequest = ImportProductsRequest.newBuilder().setParent(branchName).setReconciliationMode(reconciliationMode).setInputConfig(inputConfig).build();
    System.out.printf("Import products from big query table request: %s%n", importRequest);
    return importRequest;
}
Also used : ImportProductsRequest(com.google.cloud.retail.v2.ImportProductsRequest) ProductInputConfig(com.google.cloud.retail.v2.ProductInputConfig) BigQuerySource(com.google.cloud.retail.v2.BigQuerySource)

Example 3 with ReconciliationMode

use of com.google.cloud.retail.v2.ImportProductsRequest.ReconciliationMode in project java-retail by googleapis.

the class ImportProductsBigQueryTableTest method setUp.

@Before
public void setUp() throws IOException, InterruptedException, ExecutionException {
    String projectId = ServiceOptions.getDefaultProjectId();
    String branchName = String.format("projects/%s/locations/global/catalogs/default_catalog/branches/0", projectId);
    String datasetId = "products";
    String tableId = "products";
    String dataSchema = "product";
    ReconciliationMode reconciliationMode = ReconciliationMode.INCREMENTAL;
    bout = new ByteArrayOutputStream();
    PrintStream out = new PrintStream(bout);
    originalPrintStream = System.out;
    System.setOut(out);
    ProductsCreateBigqueryTable.main();
    ImportProductsRequest importBigQueryRequest = getImportProductsBigQueryRequest(reconciliationMode, projectId, datasetId, tableId, dataSchema, branchName);
    waitForOperationCompletion(importBigQueryRequest);
}
Also used : ImportProductsRequest(com.google.cloud.retail.v2.ImportProductsRequest) PrintStream(java.io.PrintStream) ReconciliationMode(com.google.cloud.retail.v2.ImportProductsRequest.ReconciliationMode) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Before(org.junit.Before)

Example 4 with ReconciliationMode

use of com.google.cloud.retail.v2.ImportProductsRequest.ReconciliationMode in project java-retail by googleapis.

the class ImportProductsBigQueryTable method main.

public static void main(String[] args) throws IOException, InterruptedException {
    // TODO(developer): Replace these variables before running the sample.
    String projectId = ServiceOptions.getDefaultProjectId();
    String branchName = String.format("projects/%s/locations/global/catalogs/default_catalog/branches/0", projectId);
    String datasetId = "products";
    String tableId = "products";
    // TO CHECK ERROR HANDLING USE THE TABLE WITH INVALID PRODUCTS:
    // TABLE_ID = "products_some_invalid"
    String dataSchema = "product";
    // TRY THE FULL RECONCILIATION MODE HERE:
    ReconciliationMode reconciliationMode = ReconciliationMode.INCREMENTAL;
    ImportProductsRequest importBigQueryRequest = getImportProductsBigQueryRequest(reconciliationMode, projectId, datasetId, tableId, dataSchema, branchName);
    waitForOperationCompletion(importBigQueryRequest);
}
Also used : ImportProductsRequest(com.google.cloud.retail.v2.ImportProductsRequest) ReconciliationMode(com.google.cloud.retail.v2.ImportProductsRequest.ReconciliationMode)

Aggregations

ImportProductsRequest (com.google.cloud.retail.v2.ImportProductsRequest)4 BigQuerySource (com.google.cloud.retail.v2.BigQuerySource)2 ReconciliationMode (com.google.cloud.retail.v2.ImportProductsRequest.ReconciliationMode)2 ProductInputConfig (com.google.cloud.retail.v2.ProductInputConfig)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 PrintStream (java.io.PrintStream)1 Before (org.junit.Before)1