From 339de174e64a72a8904156fde35c470110396438 Mon Sep 17 00:00:00 2001 From: Mike Ganbold Date: Tue, 26 May 2020 20:51:33 -0700 Subject: [PATCH 1/7] fix: talent solution v4 samples tests --- jobs/v4/cts_v4_secrets.txt | 3 +++ .../main/java/com/example/jobs/CommuteSearchJobs.java | 3 +++ .../com/example/jobs/CustomRankingSearchJobs.java | 3 +++ .../java/com/example/jobs/HistogramSearchJobs.java | 3 +++ .../example/jobs/JobSearchAutoCompleteJobTitle.java | 3 +++ .../com/example/jobs/JobSearchCreateClientEvent.java | 3 +++ .../java/com/example/jobs/JobSearchCreateCompany.java | 3 +++ .../java/com/example/jobs/JobSearchCreateJob.java | 11 +++++++++++ .../jobs/JobSearchCreateJobCustomAttributes.java | 3 +++ .../java/com/example/jobs/JobSearchCreateTenant.java | 3 +++ .../java/com/example/jobs/JobSearchDeleteCompany.java | 3 +++ .../java/com/example/jobs/JobSearchDeleteJob.java | 3 +++ .../java/com/example/jobs/JobSearchDeleteTenant.java | 3 +++ .../java/com/example/jobs/JobSearchGetCompany.java | 3 +++ .../main/java/com/example/jobs/JobSearchGetJob.java | 3 +++ .../java/com/example/jobs/JobSearchGetTenant.java | 3 +++ .../java/com/example/jobs/JobSearchListCompanies.java | 3 +++ .../main/java/com/example/jobs/JobSearchListJobs.java | 3 +++ .../java/com/example/jobs/JobSearchListTenants.java | 3 +++ 19 files changed, 65 insertions(+) create mode 100644 jobs/v4/cts_v4_secrets.txt diff --git a/jobs/v4/cts_v4_secrets.txt b/jobs/v4/cts_v4_secrets.txt new file mode 100644 index 00000000000..ca173304157 --- /dev/null +++ b/jobs/v4/cts_v4_secrets.txt @@ -0,0 +1,3 @@ +export CTS_TENANT_ID=50c14f00-dc38-4812-989b-d9b59c7fdf07 +export CTS_COMPANY_ID=bdad284d-9aca-4cb9-af09-ce65afcc5d6a +export CTS_JOB_ID=81763118243291846 \ No newline at end of file diff --git a/jobs/v4/src/main/java/com/example/jobs/CommuteSearchJobs.java b/jobs/v4/src/main/java/com/example/jobs/CommuteSearchJobs.java index 2dad6176bcb..658bde231aa 100644 --- a/jobs/v4/src/main/java/com/example/jobs/CommuteSearchJobs.java +++ b/jobs/v4/src/main/java/com/example/jobs/CommuteSearchJobs.java @@ -42,6 +42,9 @@ public static void searchJobs() throws IOException { // Search Jobs with histogram queries. public static void searchJobs(String projectId, String tenantId) throws IOException { + // Initialize client that will be used to send requests. This client only needs to be created + // once, and can be reused for multiple requests. After completing all of your requests, call + // the "close" method on the client to safely clean up any remaining background resources. try (JobServiceClient jobServiceClient = JobServiceClient.create()) { TenantName parent = TenantName.of(projectId, tenantId); String domain = "www.example.com"; diff --git a/jobs/v4/src/main/java/com/example/jobs/CustomRankingSearchJobs.java b/jobs/v4/src/main/java/com/example/jobs/CustomRankingSearchJobs.java index dac2f276832..7a466c843e1 100644 --- a/jobs/v4/src/main/java/com/example/jobs/CustomRankingSearchJobs.java +++ b/jobs/v4/src/main/java/com/example/jobs/CustomRankingSearchJobs.java @@ -37,6 +37,9 @@ public static void searchCustomRankingJobs() throws IOException { // Search Jobs using custom rankings. public static void searchCustomRankingJobs(String projectId, String tenantId) throws IOException { + // Initialize client that will be used to send requests. This client only needs to be created + // once, and can be reused for multiple requests. After completing all of your requests, call + // the "close" method on the client to safely clean up any remaining background resources. try (JobServiceClient jobServiceClient = JobServiceClient.create()) { TenantName parent = TenantName.of(projectId, tenantId); String domain = "www.example.com"; diff --git a/jobs/v4/src/main/java/com/example/jobs/HistogramSearchJobs.java b/jobs/v4/src/main/java/com/example/jobs/HistogramSearchJobs.java index 0ec97a2b957..63fb6739b7a 100644 --- a/jobs/v4/src/main/java/com/example/jobs/HistogramSearchJobs.java +++ b/jobs/v4/src/main/java/com/example/jobs/HistogramSearchJobs.java @@ -40,6 +40,9 @@ public static void searchJobs() throws IOException { // Search Jobs with histogram queries. public static void searchJobs(String projectId, String tenantId, String query) throws IOException { + // Initialize client that will be used to send requests. This client only needs to be created + // once, and can be reused for multiple requests. After completing all of your requests, call + // the "close" method on the client to safely clean up any remaining background resources. try (JobServiceClient jobServiceClient = JobServiceClient.create()) { TenantName parent = TenantName.of(projectId, tenantId); diff --git a/jobs/v4/src/main/java/com/example/jobs/JobSearchAutoCompleteJobTitle.java b/jobs/v4/src/main/java/com/example/jobs/JobSearchAutoCompleteJobTitle.java index 675f32a0002..0ae8edd7f2c 100644 --- a/jobs/v4/src/main/java/com/example/jobs/JobSearchAutoCompleteJobTitle.java +++ b/jobs/v4/src/main/java/com/example/jobs/JobSearchAutoCompleteJobTitle.java @@ -37,6 +37,9 @@ public static void completeQuery() throws IOException { // Complete job title given partial text (autocomplete). public static void completeQuery(String projectId, String tenantId, String query) throws IOException { + // Initialize client that will be used to send requests. This client only needs to be created + // once, and can be reused for multiple requests. After completing all of your requests, call + // the "close" method on the client to safely clean up any remaining background resources. try (CompletionClient completionClient = CompletionClient.create()) { TenantName parent = TenantName.of(projectId, tenantId); CompleteQueryRequest request = diff --git a/jobs/v4/src/main/java/com/example/jobs/JobSearchCreateClientEvent.java b/jobs/v4/src/main/java/com/example/jobs/JobSearchCreateClientEvent.java index 5df585cf7e5..d7c835cf147 100644 --- a/jobs/v4/src/main/java/com/example/jobs/JobSearchCreateClientEvent.java +++ b/jobs/v4/src/main/java/com/example/jobs/JobSearchCreateClientEvent.java @@ -42,6 +42,9 @@ public static void createClientEvent() throws IOException { // Creates a client event. public static void createClientEvent( String projectId, String tenantId, String requestId, String eventId) throws IOException { + // Initialize client that will be used to send requests. This client only needs to be created + // once, and can be reused for multiple requests. After completing all of your requests, call + // the "close" method on the client to safely clean up any remaining background resources. try (EventServiceClient eventServiceClient = EventServiceClient.create()) { TenantName parent = TenantName.of(projectId, tenantId); diff --git a/jobs/v4/src/main/java/com/example/jobs/JobSearchCreateCompany.java b/jobs/v4/src/main/java/com/example/jobs/JobSearchCreateCompany.java index f823259e3b9..2838e0cf450 100644 --- a/jobs/v4/src/main/java/com/example/jobs/JobSearchCreateCompany.java +++ b/jobs/v4/src/main/java/com/example/jobs/JobSearchCreateCompany.java @@ -38,6 +38,9 @@ public static void createCompany() throws IOException { // Create a company. public static void createCompany( String projectId, String tenantId, String displayName, String externalId) throws IOException { + // Initialize client that will be used to send requests. This client only needs to be created + // once, and can be reused for multiple requests. After completing all of your requests, call + // the "close" method on the client to safely clean up any remaining background resources. try (CompanyServiceClient companyServiceClient = CompanyServiceClient.create()) { TenantName parent = TenantName.of(projectId, tenantId); Company company = diff --git a/jobs/v4/src/main/java/com/example/jobs/JobSearchCreateJob.java b/jobs/v4/src/main/java/com/example/jobs/JobSearchCreateJob.java index e7652c5b8ce..e7a55aa4c85 100644 --- a/jobs/v4/src/main/java/com/example/jobs/JobSearchCreateJob.java +++ b/jobs/v4/src/main/java/com/example/jobs/JobSearchCreateJob.java @@ -22,6 +22,8 @@ import com.google.cloud.talent.v4beta1.Job; import com.google.cloud.talent.v4beta1.JobServiceClient; import com.google.cloud.talent.v4beta1.TenantName; +import com.google.protobuf.Timestamp; + import java.io.IOException; import java.util.Arrays; import java.util.List; @@ -46,6 +48,9 @@ public static void createJob( String requisitionId, String jobApplicationUrl) throws IOException { + // Initialize client that will be used to send requests. This client only needs to be created + // once, and can be reused for multiple requests. After completing all of your requests, call + // the "close" method on the client to safely clean up any remaining background resources. try (JobServiceClient jobServiceClient = JobServiceClient.create()) { TenantName parent = TenantName.of(projectId, tenantId); Job.ApplicationInfo applicationInfo = @@ -54,6 +59,11 @@ public static void createJob( List addresses = Arrays.asList("1600 Amphitheatre Parkway, Mountain View, CA 94043", "111 8th Avenue, New York, NY 10011"); + // if exp date is not set, by default it will expire in 30 days. + long twoMonthsFromNow = System.currentTimeMillis() + + 5270400; // 2 months in milliseconds + Timestamp expirationDate = Timestamp.newBuilder().setSeconds(twoMonthsFromNow).build(); + Job job = Job.newBuilder() .setCompany(companyId) @@ -63,6 +73,7 @@ public static void createJob( .setApplicationInfo(applicationInfo) .addAllAddresses(addresses) .setLanguageCode("en-US") + .setPostingExpireTime(expirationDate) .build(); CreateJobRequest request = diff --git a/jobs/v4/src/main/java/com/example/jobs/JobSearchCreateJobCustomAttributes.java b/jobs/v4/src/main/java/com/example/jobs/JobSearchCreateJobCustomAttributes.java index 5eeabce8f4e..8c8e1b9dcf5 100644 --- a/jobs/v4/src/main/java/com/example/jobs/JobSearchCreateJobCustomAttributes.java +++ b/jobs/v4/src/main/java/com/example/jobs/JobSearchCreateJobCustomAttributes.java @@ -43,6 +43,9 @@ public static void createJob( String companyId, String requisitionId) throws IOException { + // Initialize client that will be used to send requests. This client only needs to be created + // once, and can be reused for multiple requests. After completing all of your requests, call + // the "close" method on the client to safely clean up any remaining background resources. try (JobServiceClient jobServiceClient = JobServiceClient.create()) { TenantName parent = TenantName.of(projectId, tenantId); diff --git a/jobs/v4/src/main/java/com/example/jobs/JobSearchCreateTenant.java b/jobs/v4/src/main/java/com/example/jobs/JobSearchCreateTenant.java index d5389406825..76ad1658795 100644 --- a/jobs/v4/src/main/java/com/example/jobs/JobSearchCreateTenant.java +++ b/jobs/v4/src/main/java/com/example/jobs/JobSearchCreateTenant.java @@ -35,6 +35,9 @@ public static void createTenant() throws IOException { // Create Tenant for scoping resources, e.g. companies and jobs. public static void createTenant(String projectId, String externalId) throws IOException { + // Initialize client that will be used to send requests. This client only needs to be created + // once, and can be reused for multiple requests. After completing all of your requests, call + // the "close" method on the client to safely clean up any remaining background resources. try (TenantServiceClient tenantServiceClient = TenantServiceClient.create()) { ProjectName parent = ProjectName.of(projectId); Tenant tenant = Tenant.newBuilder().setExternalId(externalId).build(); diff --git a/jobs/v4/src/main/java/com/example/jobs/JobSearchDeleteCompany.java b/jobs/v4/src/main/java/com/example/jobs/JobSearchDeleteCompany.java index 18599edc8b6..44d8b33aff6 100644 --- a/jobs/v4/src/main/java/com/example/jobs/JobSearchDeleteCompany.java +++ b/jobs/v4/src/main/java/com/example/jobs/JobSearchDeleteCompany.java @@ -36,6 +36,9 @@ public static void deleteCompany() throws IOException { // Delete Company. public static void deleteCompany(String projectId, String tenantId, String companyId) throws IOException { + // Initialize client that will be used to send requests. This client only needs to be created + // once, and can be reused for multiple requests. After completing all of your requests, call + // the "close" method on the client to safely clean up any remaining background resources. try (CompanyServiceClient companyServiceClient = CompanyServiceClient.create()) { CompanyName name = CompanyName.ofProjectTenantCompanyName(projectId, tenantId, companyId); diff --git a/jobs/v4/src/main/java/com/example/jobs/JobSearchDeleteJob.java b/jobs/v4/src/main/java/com/example/jobs/JobSearchDeleteJob.java index 9fc5fd7b32b..82ff8b0a096 100644 --- a/jobs/v4/src/main/java/com/example/jobs/JobSearchDeleteJob.java +++ b/jobs/v4/src/main/java/com/example/jobs/JobSearchDeleteJob.java @@ -35,6 +35,9 @@ public static void deleteJob() throws IOException { // Delete Job. public static void deleteJob(String projectId, String tenantId, String jobId) throws IOException { + // Initialize client that will be used to send requests. This client only needs to be created + // once, and can be reused for multiple requests. After completing all of your requests, call + // the "close" method on the client to safely clean up any remaining background resources. try (JobServiceClient jobServiceClient = JobServiceClient.create()) { JobName name = JobName.ofProjectTenantJobName(projectId, tenantId, jobId); diff --git a/jobs/v4/src/main/java/com/example/jobs/JobSearchDeleteTenant.java b/jobs/v4/src/main/java/com/example/jobs/JobSearchDeleteTenant.java index f984c48d8e6..5d112da04d8 100644 --- a/jobs/v4/src/main/java/com/example/jobs/JobSearchDeleteTenant.java +++ b/jobs/v4/src/main/java/com/example/jobs/JobSearchDeleteTenant.java @@ -34,6 +34,9 @@ public static void deleteTenant() throws IOException { // Delete Tenant. public static void deleteTenant(String projectId, String tenantId) throws IOException { + // Initialize client that will be used to send requests. This client only needs to be created + // once, and can be reused for multiple requests. After completing all of your requests, call + // the "close" method on the client to safely clean up any remaining background resources. try (TenantServiceClient tenantServiceClient = TenantServiceClient.create()) { TenantName name = TenantName.of(projectId, tenantId); diff --git a/jobs/v4/src/main/java/com/example/jobs/JobSearchGetCompany.java b/jobs/v4/src/main/java/com/example/jobs/JobSearchGetCompany.java index 6aff009185b..02f7cac95c4 100644 --- a/jobs/v4/src/main/java/com/example/jobs/JobSearchGetCompany.java +++ b/jobs/v4/src/main/java/com/example/jobs/JobSearchGetCompany.java @@ -37,6 +37,9 @@ public static void getCompany() throws IOException { // Get Company. public static void getCompany(String projectId, String tenantId, String companyId) throws IOException { + // Initialize client that will be used to send requests. This client only needs to be created + // once, and can be reused for multiple requests. After completing all of your requests, call + // the "close" method on the client to safely clean up any remaining background resources. try (CompanyServiceClient companyServiceClient = CompanyServiceClient.create()) { CompanyName name = CompanyName.ofProjectTenantCompanyName(projectId, tenantId, companyId); diff --git a/jobs/v4/src/main/java/com/example/jobs/JobSearchGetJob.java b/jobs/v4/src/main/java/com/example/jobs/JobSearchGetJob.java index 8d6545a5d94..fb13608b376 100644 --- a/jobs/v4/src/main/java/com/example/jobs/JobSearchGetJob.java +++ b/jobs/v4/src/main/java/com/example/jobs/JobSearchGetJob.java @@ -36,6 +36,9 @@ public static void getJob() throws IOException { // Get Job. public static void getJob(String projectId, String tenantId, String jobId) throws IOException { + // Initialize client that will be used to send requests. This client only needs to be created + // once, and can be reused for multiple requests. After completing all of your requests, call + // the "close" method on the client to safely clean up any remaining background resources. try (JobServiceClient jobServiceClient = JobServiceClient.create()) { JobName name = JobName.ofProjectTenantJobName(projectId, tenantId, jobId); diff --git a/jobs/v4/src/main/java/com/example/jobs/JobSearchGetTenant.java b/jobs/v4/src/main/java/com/example/jobs/JobSearchGetTenant.java index c59f90e27a8..35d5622c595 100644 --- a/jobs/v4/src/main/java/com/example/jobs/JobSearchGetTenant.java +++ b/jobs/v4/src/main/java/com/example/jobs/JobSearchGetTenant.java @@ -35,6 +35,9 @@ public static void getTenant() throws IOException { // Get Tenant by name. public static void getTenant(String projectId, String tenantId) throws IOException { + // Initialize client that will be used to send requests. This client only needs to be created + // once, and can be reused for multiple requests. After completing all of your requests, call + // the "close" method on the client to safely clean up any remaining background resources. try (TenantServiceClient tenantServiceClient = TenantServiceClient.create()) { TenantName name = TenantName.of(projectId, tenantId); diff --git a/jobs/v4/src/main/java/com/example/jobs/JobSearchListCompanies.java b/jobs/v4/src/main/java/com/example/jobs/JobSearchListCompanies.java index 4e9878f7d9e..dc87750e705 100644 --- a/jobs/v4/src/main/java/com/example/jobs/JobSearchListCompanies.java +++ b/jobs/v4/src/main/java/com/example/jobs/JobSearchListCompanies.java @@ -35,6 +35,9 @@ public static void listCompanies() throws IOException { // List Companies. public static void listCompanies(String projectId, String tenantId) throws IOException { + // Initialize client that will be used to send requests. This client only needs to be created + // once, and can be reused for multiple requests. After completing all of your requests, call + // the "close" method on the client to safely clean up any remaining background resources. try (CompanyServiceClient companyServiceClient = CompanyServiceClient.create()) { TenantName parent = TenantName.of(projectId, tenantId); diff --git a/jobs/v4/src/main/java/com/example/jobs/JobSearchListJobs.java b/jobs/v4/src/main/java/com/example/jobs/JobSearchListJobs.java index df1342c843c..66537385bcd 100644 --- a/jobs/v4/src/main/java/com/example/jobs/JobSearchListJobs.java +++ b/jobs/v4/src/main/java/com/example/jobs/JobSearchListJobs.java @@ -36,6 +36,9 @@ public static void listJobs() throws IOException { // Search Jobs with histogram queries. public static void listJobs(String projectId, String tenantId, String filter) throws IOException { + // Initialize client that will be used to send requests. This client only needs to be created + // once, and can be reused for multiple requests. After completing all of your requests, call + // the "close" method on the client to safely clean up any remaining background resources. try (JobServiceClient jobServiceClient = JobServiceClient.create()) { TenantName parent = TenantName.of(projectId, tenantId); ListJobsRequest request = diff --git a/jobs/v4/src/main/java/com/example/jobs/JobSearchListTenants.java b/jobs/v4/src/main/java/com/example/jobs/JobSearchListTenants.java index 565e75e4714..2c60e5abb1b 100644 --- a/jobs/v4/src/main/java/com/example/jobs/JobSearchListTenants.java +++ b/jobs/v4/src/main/java/com/example/jobs/JobSearchListTenants.java @@ -34,6 +34,9 @@ public static void listTenants() throws IOException { // List Tenants. public static void listTenants(String projectId) throws IOException { + // Initialize client that will be used to send requests. This client only needs to be created + // once, and can be reused for multiple requests. After completing all of your requests, call + // the "close" method on the client to safely clean up any remaining background resources. try (TenantServiceClient tenantServiceClient = TenantServiceClient.create()) { ProjectName parent = ProjectName.of(projectId); From 3ba44a869c906bb67c9f24b738d47d6e7bb8d972 Mon Sep 17 00:00:00 2001 From: Mike Ganbold Date: Tue, 26 May 2020 20:57:57 -0700 Subject: [PATCH 2/7] deleted unnecessary text file --- jobs/v4/cts_v4_secrets.txt | 3 --- 1 file changed, 3 deletions(-) delete mode 100644 jobs/v4/cts_v4_secrets.txt diff --git a/jobs/v4/cts_v4_secrets.txt b/jobs/v4/cts_v4_secrets.txt deleted file mode 100644 index ca173304157..00000000000 --- a/jobs/v4/cts_v4_secrets.txt +++ /dev/null @@ -1,3 +0,0 @@ -export CTS_TENANT_ID=50c14f00-dc38-4812-989b-d9b59c7fdf07 -export CTS_COMPANY_ID=bdad284d-9aca-4cb9-af09-ce65afcc5d6a -export CTS_JOB_ID=81763118243291846 \ No newline at end of file From dd96e3ac4a01170e25fd108b1a03354e56170528 Mon Sep 17 00:00:00 2001 From: Mike Ganbold Date: Wed, 27 May 2020 10:29:05 -0700 Subject: [PATCH 3/7] updated exp date --- .../main/java/com/example/jobs/JobSearchCreateJob.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/jobs/v4/src/main/java/com/example/jobs/JobSearchCreateJob.java b/jobs/v4/src/main/java/com/example/jobs/JobSearchCreateJob.java index e7a55aa4c85..dda511c01d2 100644 --- a/jobs/v4/src/main/java/com/example/jobs/JobSearchCreateJob.java +++ b/jobs/v4/src/main/java/com/example/jobs/JobSearchCreateJob.java @@ -23,6 +23,7 @@ import com.google.cloud.talent.v4beta1.JobServiceClient; import com.google.cloud.talent.v4beta1.TenantName; import com.google.protobuf.Timestamp; +import com.google.protobuf.util.Timestamps; import java.io.IOException; import java.util.Arrays; @@ -60,9 +61,11 @@ public static void createJob( "111 8th Avenue, New York, NY 10011"); // if exp date is not set, by default it will expire in 30 days. - long twoMonthsFromNow = System.currentTimeMillis() + - 5270400; // 2 months in milliseconds - Timestamp expirationDate = Timestamp.newBuilder().setSeconds(twoMonthsFromNow).build(); + Timestamp expirationDate = Timestamps.add( + Timestamps.fromMillis(System.currentTimeMillis()), + com.google.protobuf.Duration.newBuilder() + .setSeconds(60L * 60L * 24L * 30L) // 30 days ago + .build()); Job job = Job.newBuilder() From 6335d376e90cde6673552561e551b1adf439b1d2 Mon Sep 17 00:00:00 2001 From: Mike Ganbold Date: Wed, 27 May 2020 10:46:40 -0700 Subject: [PATCH 4/7] fixed the lint --- .../java/com/example/jobs/JobSearchCreateJob.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/jobs/v4/src/main/java/com/example/jobs/JobSearchCreateJob.java b/jobs/v4/src/main/java/com/example/jobs/JobSearchCreateJob.java index dda511c01d2..a26514b7049 100644 --- a/jobs/v4/src/main/java/com/example/jobs/JobSearchCreateJob.java +++ b/jobs/v4/src/main/java/com/example/jobs/JobSearchCreateJob.java @@ -57,15 +57,18 @@ public static void createJob( Job.ApplicationInfo applicationInfo = Job.ApplicationInfo.newBuilder().addUris(jobApplicationUrl).build(); - List addresses = Arrays.asList("1600 Amphitheatre Parkway, Mountain View, CA 94043", + List addresses = + Arrays.asList( + "1600 Amphitheatre Parkway, Mountain View, CA 94043", "111 8th Avenue, New York, NY 10011"); // if exp date is not set, by default it will expire in 30 days. - Timestamp expirationDate = Timestamps.add( + Timestamp expirationDate = + Timestamps.add( Timestamps.fromMillis(System.currentTimeMillis()), com.google.protobuf.Duration.newBuilder() - .setSeconds(60L * 60L * 24L * 30L) // 30 days ago - .build()); + .setSeconds(60L * 60L * 24L * 30L) // 30 days ago + .build()); Job job = Job.newBuilder() From 633879703926e5ce8c991604c0b445109272398a Mon Sep 17 00:00:00 2001 From: Mike Ganbold Date: Wed, 27 May 2020 11:27:12 -0700 Subject: [PATCH 5/7] updated code according to new checkstyle --- jobs/v4/pom.xml | 2 +- .../java/com/example/jobs/CommuteSearchJobs.java | 8 ++++---- .../example/jobs/CustomRankingSearchJobs.java | 8 ++++---- .../com/example/jobs/HistogramSearchJobs.java | 8 ++++---- .../jobs/JobSearchAutoCompleteJobTitle.java | 4 ++-- .../com/example/jobs/JobSearchCreateCompany.java | 6 +++--- .../com/example/jobs/JobSearchCreateJob.java | 3 +-- .../com/example/jobs/JobSearchCreateTenant.java | 4 ++-- .../com/example/jobs/JobSearchGetCompany.java | 4 ++-- .../java/com/example/jobs/JobSearchGetJob.java | 16 ++++++++-------- .../com/example/jobs/JobSearchGetTenant.java | 4 ++-- .../com/example/jobs/JobSearchListCompanies.java | 6 +++--- .../java/com/example/jobs/JobSearchListJobs.java | 8 ++++---- .../com/example/jobs/JobSearchListTenants.java | 4 ++-- 14 files changed, 42 insertions(+), 43 deletions(-) diff --git a/jobs/v4/pom.xml b/jobs/v4/pom.xml index d193d2ce329..da9ceaebda9 100644 --- a/jobs/v4/pom.xml +++ b/jobs/v4/pom.xml @@ -24,7 +24,7 @@ - 3.5 + 3.5.4 diff --git a/jobs/v4/src/main/java/com/example/jobs/CommuteSearchJobs.java b/jobs/v4/src/main/java/com/example/jobs/CommuteSearchJobs.java index 658bde231aa..e8e8e04b094 100644 --- a/jobs/v4/src/main/java/com/example/jobs/CommuteSearchJobs.java +++ b/jobs/v4/src/main/java/com/example/jobs/CommuteSearchJobs.java @@ -83,11 +83,11 @@ public static void searchJobs(String projectId, String tenantId) throws IOExcept for (SearchJobsResponse.MatchingJob responseItem : jobServiceClient.searchJobs(request).iterateAll()) { - System.out.printf("Job summary: %s\n", responseItem.getJobSummary()); - System.out.printf("Job title snippet: %s\n", responseItem.getJobTitleSnippet()); + System.out.format("Job summary: %s%n", responseItem.getJobSummary()); + System.out.format("Job title snippet: %s%n", responseItem.getJobTitleSnippet()); Job job = responseItem.getJob(); - System.out.printf("Job name: %s\n", job.getName()); - System.out.printf("Job title: %s\n", job.getTitle()); + System.out.format("Job name: %s%n", job.getName()); + System.out.format("Job title: %s%n", job.getTitle()); } } } diff --git a/jobs/v4/src/main/java/com/example/jobs/CustomRankingSearchJobs.java b/jobs/v4/src/main/java/com/example/jobs/CustomRankingSearchJobs.java index 7a466c843e1..94899b282f4 100644 --- a/jobs/v4/src/main/java/com/example/jobs/CustomRankingSearchJobs.java +++ b/jobs/v4/src/main/java/com/example/jobs/CustomRankingSearchJobs.java @@ -69,11 +69,11 @@ public static void searchCustomRankingJobs(String projectId, String tenantId) th .build(); for (SearchJobsResponse.MatchingJob responseItem : jobServiceClient.searchJobs(request).iterateAll()) { - System.out.printf("Job summary: %s\n", responseItem.getJobSummary()); - System.out.printf("Job title snippet: %s\n", responseItem.getJobTitleSnippet()); + System.out.format("Job summary: %s%n", responseItem.getJobSummary()); + System.out.format("Job title snippet: %s%n", responseItem.getJobTitleSnippet()); Job job = responseItem.getJob(); - System.out.printf("Job name: %s\n", job.getName()); - System.out.printf("Job title: %s\n", job.getTitle()); + System.out.format("Job name: %s%n", job.getName()); + System.out.format("Job title: %s%n", job.getTitle()); } } } diff --git a/jobs/v4/src/main/java/com/example/jobs/HistogramSearchJobs.java b/jobs/v4/src/main/java/com/example/jobs/HistogramSearchJobs.java index 63fb6739b7a..57c34123392 100644 --- a/jobs/v4/src/main/java/com/example/jobs/HistogramSearchJobs.java +++ b/jobs/v4/src/main/java/com/example/jobs/HistogramSearchJobs.java @@ -66,11 +66,11 @@ public static void searchJobs(String projectId, String tenantId, String query) for (SearchJobsResponse.MatchingJob responseItem : jobServiceClient.searchJobs(request).iterateAll()) { - System.out.printf("Job summary: %s\n", responseItem.getJobSummary()); - System.out.printf("Job title snippet: %s\n", responseItem.getJobTitleSnippet()); + System.out.format("Job summary: %s%n", responseItem.getJobSummary()); + System.out.format("Job title snippet: %s%n", responseItem.getJobTitleSnippet()); Job job = responseItem.getJob(); - System.out.printf("Job name: %s\n", job.getName()); - System.out.printf("Job title: %s\n", job.getTitle()); + System.out.format("Job name: %s%n", job.getName()); + System.out.format("Job title: %s%n", job.getTitle()); } } } diff --git a/jobs/v4/src/main/java/com/example/jobs/JobSearchAutoCompleteJobTitle.java b/jobs/v4/src/main/java/com/example/jobs/JobSearchAutoCompleteJobTitle.java index 0ae8edd7f2c..842d77a05d1 100644 --- a/jobs/v4/src/main/java/com/example/jobs/JobSearchAutoCompleteJobTitle.java +++ b/jobs/v4/src/main/java/com/example/jobs/JobSearchAutoCompleteJobTitle.java @@ -51,9 +51,9 @@ public static void completeQuery(String projectId, String tenantId, String query .build(); CompleteQueryResponse response = completionClient.completeQuery(request); for (CompleteQueryResponse.CompletionResult result : response.getCompletionResultsList()) { - System.out.printf("Suggested title: %s\n", result.getSuggestion()); + System.out.format("Suggested title: %s%n", result.getSuggestion()); // Suggestion type is JOB_TITLE or COMPANY_TITLE - System.out.printf("Suggestion type: %s\n", result.getType()); + System.out.format("Suggestion type: %s%n", result.getType()); } } } diff --git a/jobs/v4/src/main/java/com/example/jobs/JobSearchCreateCompany.java b/jobs/v4/src/main/java/com/example/jobs/JobSearchCreateCompany.java index 2838e0cf450..baa890a51d9 100644 --- a/jobs/v4/src/main/java/com/example/jobs/JobSearchCreateCompany.java +++ b/jobs/v4/src/main/java/com/example/jobs/JobSearchCreateCompany.java @@ -54,9 +54,9 @@ public static void createCompany( Company response = companyServiceClient.createCompany(request); System.out.println("Created Company"); - System.out.printf("Name: %s\n", response.getName()); - System.out.printf("Display Name: %s\n", response.getDisplayName()); - System.out.printf("External ID: %s\n", response.getExternalId()); + System.out.format("Name: %s%n", response.getName()); + System.out.format("Display Name: %s%n", response.getDisplayName()); + System.out.format("External ID: %s%n", response.getExternalId()); } } } diff --git a/jobs/v4/src/main/java/com/example/jobs/JobSearchCreateJob.java b/jobs/v4/src/main/java/com/example/jobs/JobSearchCreateJob.java index a26514b7049..d070600bca5 100644 --- a/jobs/v4/src/main/java/com/example/jobs/JobSearchCreateJob.java +++ b/jobs/v4/src/main/java/com/example/jobs/JobSearchCreateJob.java @@ -24,7 +24,6 @@ import com.google.cloud.talent.v4beta1.TenantName; import com.google.protobuf.Timestamp; import com.google.protobuf.util.Timestamps; - import java.io.IOException; import java.util.Arrays; import java.util.List; @@ -86,7 +85,7 @@ public static void createJob( CreateJobRequest.newBuilder().setParent(parent.toString()).setJob(job).build(); Job response = jobServiceClient.createJob(request); - System.out.printf("Created job: %s\n", response.getName()); + System.out.format("Created job: %s%n", response.getName()); } } } diff --git a/jobs/v4/src/main/java/com/example/jobs/JobSearchCreateTenant.java b/jobs/v4/src/main/java/com/example/jobs/JobSearchCreateTenant.java index 76ad1658795..5d9b1a5f46c 100644 --- a/jobs/v4/src/main/java/com/example/jobs/JobSearchCreateTenant.java +++ b/jobs/v4/src/main/java/com/example/jobs/JobSearchCreateTenant.java @@ -47,8 +47,8 @@ public static void createTenant(String projectId, String externalId) throws IOEx Tenant response = tenantServiceClient.createTenant(request); System.out.println("Created Tenant"); - System.out.printf("Name: %s\n", response.getName()); - System.out.printf("External ID: %s\n", response.getExternalId()); + System.out.format("Name: %s%n", response.getName()); + System.out.format("External ID: %s%n", response.getExternalId()); } } } diff --git a/jobs/v4/src/main/java/com/example/jobs/JobSearchGetCompany.java b/jobs/v4/src/main/java/com/example/jobs/JobSearchGetCompany.java index 02f7cac95c4..639b15979cc 100644 --- a/jobs/v4/src/main/java/com/example/jobs/JobSearchGetCompany.java +++ b/jobs/v4/src/main/java/com/example/jobs/JobSearchGetCompany.java @@ -46,8 +46,8 @@ public static void getCompany(String projectId, String tenantId, String companyI GetCompanyRequest request = GetCompanyRequest.newBuilder().setName(name.toString()).build(); Company response = companyServiceClient.getCompany(request); - System.out.printf("Company name: %s\n", response.getName()); - System.out.printf("Display name: %s\n", response.getDisplayName()); + System.out.format("Company name: %s%n", response.getName()); + System.out.format("Display name: %s%n", response.getDisplayName()); } } } diff --git a/jobs/v4/src/main/java/com/example/jobs/JobSearchGetJob.java b/jobs/v4/src/main/java/com/example/jobs/JobSearchGetJob.java index fb13608b376..84a88801792 100644 --- a/jobs/v4/src/main/java/com/example/jobs/JobSearchGetJob.java +++ b/jobs/v4/src/main/java/com/example/jobs/JobSearchGetJob.java @@ -45,19 +45,19 @@ public static void getJob(String projectId, String tenantId, String jobId) throw GetJobRequest request = GetJobRequest.newBuilder().setName(name.toString()).build(); Job response = jobServiceClient.getJob(request); - System.out.printf("Job name: %s\n", response.getName()); - System.out.printf("Requisition ID: %s\n", response.getRequisitionId()); - System.out.printf("Title: %s\n", response.getTitle()); - System.out.printf("Description: %s\n", response.getDescription()); - System.out.printf("Posting language: %s\n", response.getLanguageCode()); + System.out.format("Job name: %s%n", response.getName()); + System.out.format("Requisition ID: %s%n", response.getRequisitionId()); + System.out.format("Title: %s%n", response.getTitle()); + System.out.format("Description: %s%n", response.getDescription()); + System.out.format("Posting language: %s%n", response.getLanguageCode()); for (String address : response.getAddressesList()) { - System.out.printf("Address: %s\n", address); + System.out.format("Address: %s%n", address); } for (String email : response.getApplicationInfo().getEmailsList()) { - System.out.printf("Email: %s\n", email); + System.out.format("Email: %s%n", email); } for (String websiteUri : response.getApplicationInfo().getUrisList()) { - System.out.printf("Website: %s\n", websiteUri); + System.out.format("Website: %s%n", websiteUri); } } } diff --git a/jobs/v4/src/main/java/com/example/jobs/JobSearchGetTenant.java b/jobs/v4/src/main/java/com/example/jobs/JobSearchGetTenant.java index 35d5622c595..527ba34d295 100644 --- a/jobs/v4/src/main/java/com/example/jobs/JobSearchGetTenant.java +++ b/jobs/v4/src/main/java/com/example/jobs/JobSearchGetTenant.java @@ -44,8 +44,8 @@ public static void getTenant(String projectId, String tenantId) throws IOExcepti GetTenantRequest request = GetTenantRequest.newBuilder().setName(name.toString()).build(); Tenant response = tenantServiceClient.getTenant(request); - System.out.printf("Name: %s\n", response.getName()); - System.out.printf("External ID: %s\n", response.getExternalId()); + System.out.format("Name: %s%n", response.getName()); + System.out.format("External ID: %s%n", response.getExternalId()); } } } diff --git a/jobs/v4/src/main/java/com/example/jobs/JobSearchListCompanies.java b/jobs/v4/src/main/java/com/example/jobs/JobSearchListCompanies.java index dc87750e705..cef24dc2087 100644 --- a/jobs/v4/src/main/java/com/example/jobs/JobSearchListCompanies.java +++ b/jobs/v4/src/main/java/com/example/jobs/JobSearchListCompanies.java @@ -45,9 +45,9 @@ public static void listCompanies(String projectId, String tenantId) throws IOExc ListCompaniesRequest.newBuilder().setParent(parent.toString()).build(); for (Company responseItem : companyServiceClient.listCompanies(request).iterateAll()) { - System.out.printf("Company Name: %s\n", responseItem.getName()); - System.out.printf("Display Name: %s\n", responseItem.getDisplayName()); - System.out.printf("External ID: %s\n", responseItem.getExternalId()); + System.out.format("Company Name: %s%n", responseItem.getName()); + System.out.format("Display Name: %s%n", responseItem.getDisplayName()); + System.out.format("External ID: %s%n", responseItem.getExternalId()); } } } diff --git a/jobs/v4/src/main/java/com/example/jobs/JobSearchListJobs.java b/jobs/v4/src/main/java/com/example/jobs/JobSearchListJobs.java index 66537385bcd..81f844226ea 100644 --- a/jobs/v4/src/main/java/com/example/jobs/JobSearchListJobs.java +++ b/jobs/v4/src/main/java/com/example/jobs/JobSearchListJobs.java @@ -44,10 +44,10 @@ public static void listJobs(String projectId, String tenantId, String filter) th ListJobsRequest request = ListJobsRequest.newBuilder().setParent(parent.toString()).setFilter(filter).build(); for (Job responseItem : jobServiceClient.listJobs(request).iterateAll()) { - System.out.printf("Job name: %s\n", responseItem.getName()); - System.out.printf("Job requisition ID: %s\n", responseItem.getRequisitionId()); - System.out.printf("Job title: %s\n", responseItem.getTitle()); - System.out.printf("Job description: %s\n", responseItem.getDescription()); + System.out.format("Job name: %s%n", responseItem.getName()); + System.out.format("Job requisition ID: %s%n", responseItem.getRequisitionId()); + System.out.format("Job title: %s%n", responseItem.getTitle()); + System.out.format("Job description: %s%n", responseItem.getDescription()); } } } diff --git a/jobs/v4/src/main/java/com/example/jobs/JobSearchListTenants.java b/jobs/v4/src/main/java/com/example/jobs/JobSearchListTenants.java index 2c60e5abb1b..4b0be36b2cf 100644 --- a/jobs/v4/src/main/java/com/example/jobs/JobSearchListTenants.java +++ b/jobs/v4/src/main/java/com/example/jobs/JobSearchListTenants.java @@ -44,8 +44,8 @@ public static void listTenants(String projectId) throws IOException { ListTenantsRequest.newBuilder().setParent(parent.toString()).build(); for (Tenant responseItem : tenantServiceClient.listTenants(request).iterateAll()) { - System.out.printf("Tenant Name: %s\n", responseItem.getName()); - System.out.printf("External ID: %s\n", responseItem.getExternalId()); + System.out.format("Tenant Name: %s%n", responseItem.getName()); + System.out.format("External ID: %s%n", responseItem.getExternalId()); } } } From e2f55137ba0edcbb5677300ba1a7869d384b0d01 Mon Sep 17 00:00:00 2001 From: Mike Ganbold Date: Wed, 27 May 2020 16:54:23 -0700 Subject: [PATCH 6/7] removed setExpireDate mthd --- .../com/example/jobs/JobSearchCreateJob.java | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/jobs/v4/src/main/java/com/example/jobs/JobSearchCreateJob.java b/jobs/v4/src/main/java/com/example/jobs/JobSearchCreateJob.java index d070600bca5..59fc165e225 100644 --- a/jobs/v4/src/main/java/com/example/jobs/JobSearchCreateJob.java +++ b/jobs/v4/src/main/java/com/example/jobs/JobSearchCreateJob.java @@ -22,11 +22,14 @@ import com.google.cloud.talent.v4beta1.Job; import com.google.cloud.talent.v4beta1.JobServiceClient; import com.google.cloud.talent.v4beta1.TenantName; -import com.google.protobuf.Timestamp; -import com.google.protobuf.util.Timestamps; import java.io.IOException; +import java.sql.Timestamp; +import java.time.LocalDate; +import java.time.LocalDateTime; import java.util.Arrays; +import java.util.Calendar; import java.util.List; +import java.util.Locale; public class JobSearchCreateJob { @@ -61,14 +64,7 @@ public static void createJob( "1600 Amphitheatre Parkway, Mountain View, CA 94043", "111 8th Avenue, New York, NY 10011"); - // if exp date is not set, by default it will expire in 30 days. - Timestamp expirationDate = - Timestamps.add( - Timestamps.fromMillis(System.currentTimeMillis()), - com.google.protobuf.Duration.newBuilder() - .setSeconds(60L * 60L * 24L * 30L) // 30 days ago - .build()); - + // By default, job posting will expire in 30 days. Job job = Job.newBuilder() .setCompany(companyId) @@ -78,7 +74,6 @@ public static void createJob( .setApplicationInfo(applicationInfo) .addAllAddresses(addresses) .setLanguageCode("en-US") - .setPostingExpireTime(expirationDate) .build(); CreateJobRequest request = From 898f9ded6d0d903d788de012a4e0308b86e20568 Mon Sep 17 00:00:00 2001 From: Mike Ganbold Date: Wed, 27 May 2020 16:57:53 -0700 Subject: [PATCH 7/7] added helpful link to job exp --- jobs/v4/src/main/java/com/example/jobs/JobSearchCreateJob.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/jobs/v4/src/main/java/com/example/jobs/JobSearchCreateJob.java b/jobs/v4/src/main/java/com/example/jobs/JobSearchCreateJob.java index 59fc165e225..ecbc0e9433e 100644 --- a/jobs/v4/src/main/java/com/example/jobs/JobSearchCreateJob.java +++ b/jobs/v4/src/main/java/com/example/jobs/JobSearchCreateJob.java @@ -64,7 +64,8 @@ public static void createJob( "1600 Amphitheatre Parkway, Mountain View, CA 94043", "111 8th Avenue, New York, NY 10011"); - // By default, job posting will expire in 30 days. + // By default, job will expire in 30 days. + // https://cloud.google.com/talent-solution/job-search/docs/jobs Job job = Job.newBuilder() .setCompany(companyId)