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;
}
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;
}
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);
}
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);
}
Aggregations