Skip to content

Commit d72fd89

Browse files
xinyunh0929dzlier-gcp
authored andcommitted
Rebrand Cloud Job Discovery to Cloud Talent Solution and add the V3 code samples (GoogleCloudPlatform#1166)
* cjd samples * cjd samples * modify README * modify README * revert gitignore * Add license header * Update the samples * Reorganize the samples and add more comments * Change the google could samples version from LATEST to 1.0.9 * Modify the tenantJobSearch * separate the sample tests * cjd samples * cjd samples * modify README * modify README * revert gitignore * Add quickstart and remove the deprecated samples * Remove unused folder * Add license header * Update the samples * Reorganize the samples and add more comments * Change the google could samples version from LATEST to 1.0.9 * Modify the tenantJobSearch * separate the sample tests * Add quickstart and remove the deprecated samples * Remove unused folder * Remove deprecated code sample and modify the comment * Remove service util * V3 quickstart change * Add v3 samples * Remove v3 local resource from pom * Modify Readme * Modify V3 code sample and related tests * Modify the package version * Unify the setup and modify some samples * Remove unnecessary files * Delete READONLY * Fix some typo errors * Format the V3 code samples
1 parent d898fc1 commit d72fd89

31 files changed

+2375
-10
lines changed

READONLY

-1
This file was deleted.

jobs/cjd_sample/README.md renamed to jobs/v2/README.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
1-
# Cloud Job Discovery client samples
1+
# Cloud Talent Solution client samples
22

33
<a href="https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/GoogleCloudPlatform/java-docs-samples&page=editor&open_in_editor=jobs/cjd_sample/README.md">
44
<img alt="Open in Cloud Shell" src ="http://gstatic.com/cloudssh/images/open-btn.png"></a>
55

6-
[Cloud Job Discovery][jobs] is part of Google for Jobs - a Google-wide commitment to help people find jobs more easily. Job Discovery provides plug and play access to Google’s search and machine learning capabilities, enabling the entire recruiting ecosystem - company career sites, job boards, applicant tracking systems, and staffing agencies to improve job site engagement and candidate conversion.
6+
[Cloud Talent Solution][jobs] is part of Google for Jobs - a Google-wide commitment to help people find jobs more easily. Talent Solution provides plug and play access to Google’s search and machine learning capabilities, enabling the entire recruiting ecosystem - company career sites, job boards, applicant tracking systems, and staffing agencies to improve job site engagement and candidate conversion.
77

8-
This sample Java application demonstrates how to access the Cloud Job Discovery API using the [Google Cloud Client Library for Java][google-cloud-java].
8+
This sample Java application demonstrates how to access the Cloud Talent Solution API using the [Google Cloud Client Library for Java][google-cloud-java].
99

10-
[jobs]: https://cloud.google.com/job-discovery/
10+
[jobs]: https://cloud.google.com/talent-solution/job-search/docs
1111
[google-cloud-java]: https://github.com/GoogleCloudPlatform/google-cloud-java
1212

1313
## Setup
1414

1515
1. Install [Maven](http://maven.apache.org/).
16-
1. [Enable](https://console.cloud.google.com/apis/api/jobs.googleapis.com/overview) Cloud Job Discovery API.
16+
1. [Enable](https://console.cloud.google.com/apis/api/jobs.googleapis.com/overview) Cloud Talent Solution API.
1717

1818
## Build
1919

jobs/v2/pom.xml

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
<groupId>com.google.samples</groupId>
7+
<artifactId>cloud-talent-solution-samples</artifactId>
8+
<version>2.0-SNAPSHOT</version>
9+
<packaging>jar</packaging>
10+
11+
<!--
12+
The parent pom defines common style checks and testing strategies for our samples.
13+
Removing or replacing it should not affect the execution of the samples in anyway.
14+
-->
15+
<parent>
16+
<groupId>com.google.cloud.samples</groupId>
17+
<artifactId>shared-configuration</artifactId>
18+
<version>1.0.10</version>
19+
</parent>
20+
21+
<properties>
22+
<maven.compiler.target>1.8</maven.compiler.target>
23+
<maven.compiler.source>1.8</maven.compiler.source>
24+
</properties>
25+
26+
<prerequisites>
27+
<maven>3.5</maven>
28+
</prerequisites>
29+
30+
<dependencies>
31+
<!-- [START dependencies] -->
32+
<dependency>
33+
<groupId>com.google.apis</groupId>
34+
<artifactId>google-api-services-jobs</artifactId>
35+
<version>v2-rev17-1.24.1</version>
36+
</dependency>
37+
<!-- [END dependencies] -->
38+
39+
<!-- Test dependencies -->
40+
<dependency>
41+
<groupId>com.google.truth</groupId>
42+
<artifactId>truth</artifactId>
43+
<version>0.40</version>
44+
<scope>test</scope>
45+
</dependency>
46+
<dependency>
47+
<groupId>junit</groupId>
48+
<artifactId>junit</artifactId>
49+
<version>RELEASE</version>
50+
</dependency>
51+
</dependencies>
52+
</project>

jobs/cjd_sample/src/main/java/com/google/samples/AutoCompleteSample.java renamed to jobs/v2/src/main/java/com/google/samples/AutoCompleteSample.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,9 @@ public static void jobTitleAutoComplete(String companyName, String query)
5656

5757
System.out.println(results);
5858
}
59-
// [END auto_complete_default]
59+
// [END auto_complete_job_title]
6060

61+
// [START auto_complete_default]
6162
/**
6263
* Auto completes job titles within given companyName.
6364
*/

jobs/v3/README.md

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Cloud Talent Solution client samples
2+
3+
<a href="https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/GoogleCloudPlatform/java-docs-samples&page=editor&open_in_editor=jobs/cjd_sample/README.md">
4+
<img alt="Open in Cloud Shell" src ="http://gstatic.com/cloudssh/images/open-btn.png"></a>
5+
6+
[Cloud Talent Solution][jobs] is part of Google for Jobs - a Google-wide commitment to help people find jobs more easily. Talent Solution provides plug and play access to Google’s search and machine learning capabilities, enabling the entire recruiting ecosystem - company career sites, job boards, applicant tracking systems, and staffing agencies to improve job site engagement and candidate conversion.
7+
8+
This sample Java application demonstrates how to access the Cloud Talent Solution API using the [Google Cloud Client Library for Java][google-cloud-java].
9+
10+
[jobs]: https://cloud.google.com/talent-solution/job-search/docs
11+
[google-cloud-java]: https://github.com/GoogleCloudPlatform/google-cloud-java
12+
13+
## Setup
14+
15+
1. Install [Maven](http://maven.apache.org/).
16+
1. [Enable](https://console.cloud.google.com/apis/api/jobs.googleapis.com/overview) Cloud Talent Solution API.
17+
18+
## Build
19+
20+
Build your project with:
21+
```
22+
mvn clean package
23+
```
24+
25+
## Local testing
26+
27+
1. [Create a service account](https://cloud.google.com/docs/authentication/getting-started#creating_the_service_account)
28+
and set the `GOOGLE_APPLICATION_CREDENTIALS` environment variable, for example:
29+
```
30+
export GOOGLE_APPLICATION_CREDENTIALS=/path/to/your/key.json
31+
```
32+
2. Run all samples with command:
33+
```
34+
mvn -Dtest=SampleTests test
35+
```
36+
Or a single sample:
37+
```
38+
mvn exec:java -Dexec.mainClass="com.google.samples.BatchOperationSample"
39+
```

jobs/cjd_sample/pom.xml renamed to jobs/v3/pom.xml

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
55
<modelVersion>4.0.0</modelVersion>
66
<groupId>com.google.samples</groupId>
7-
<artifactId>cloud-job-discovery-samples</artifactId>
8-
<version>1.0-SNAPSHOT</version>
7+
<artifactId>cloud-talent-solution-samples</artifactId>
8+
<version>3.0-SNAPSHOT</version>
99
<packaging>jar</packaging>
1010

1111
<!--
@@ -32,7 +32,7 @@
3232
<dependency>
3333
<groupId>com.google.apis</groupId>
3434
<artifactId>google-api-services-jobs</artifactId>
35-
<version>LATEST</version>
35+
<version>v3-rev5-1.24.1</version>
3636
</dependency>
3737
<!-- [END dependencies] -->
3838

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
/*
2+
* Copyright 2018 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.google.samples;
18+
19+
import com.google.api.services.jobs.v3.CloudTalentSolution;
20+
import com.google.api.services.jobs.v3.CloudTalentSolution.Projects.Complete;
21+
import com.google.api.services.jobs.v3.model.Company;
22+
import com.google.api.services.jobs.v3.model.CompleteQueryResponse;
23+
import com.google.api.services.jobs.v3.model.Job;
24+
import java.io.IOException;
25+
26+
/**
27+
* The samples in this file introduced how to do the auto complete, including:
28+
*
29+
* - Default auto complete (on both company display name and job title)
30+
*
31+
* - Auto complete on job title only
32+
*/
33+
public final class AutoCompleteSample {
34+
35+
private static final String DEFAULT_PROJECT_ID =
36+
"projects/" + System.getenv("GOOGLE_CLOUD_PROJECT");
37+
38+
private static CloudTalentSolution talentSolutionClient = JobServiceQuickstart
39+
.getTalentSolutionClient();
40+
41+
//[START auto_complete_job_title]
42+
43+
/**
44+
* Auto completes job titles within given companyName.
45+
*/
46+
public static void jobTitleAutoComplete(String companyName, String query)
47+
throws IOException {
48+
49+
Complete complete =
50+
talentSolutionClient
51+
.projects()
52+
.complete(DEFAULT_PROJECT_ID)
53+
.setQuery(query)
54+
.setLanguageCode("en-US")
55+
.setType("JOB_TITLE")
56+
.setPageSize(10);
57+
if (companyName != null) {
58+
complete.setCompanyName(companyName);
59+
}
60+
61+
CompleteQueryResponse results = complete.execute();
62+
63+
System.out.println(results);
64+
}
65+
// [END auto_complete_default]
66+
67+
/**
68+
* Auto completes job titles within given companyName.
69+
*/
70+
public static void defaultAutoComplete(String companyName, String query)
71+
throws IOException {
72+
Complete complete =
73+
talentSolutionClient
74+
.projects()
75+
.complete(DEFAULT_PROJECT_ID)
76+
.setQuery(query)
77+
.setLanguageCode("en-US")
78+
.setPageSize(10);
79+
if (companyName != null) {
80+
complete.setCompanyName(companyName);
81+
}
82+
83+
CompleteQueryResponse results = complete.execute();
84+
85+
System.out.println(results);
86+
}
87+
// [END auto_complete_default]
88+
89+
public static void main(String... args) throws Exception {
90+
Company companyToBeCreated = BasicCompanySample.generateCompany().setDisplayName("Google");
91+
String companyName = BasicCompanySample.createCompany(companyToBeCreated).getName();
92+
93+
Job jobToBeCreated = BasicJobSample.generateJobWithRequiredFields(companyName)
94+
.setTitle("Software engineer");
95+
final String jobName = BasicJobSample.createJob(jobToBeCreated).getName();
96+
97+
// Wait several seconds for post processing
98+
Thread.sleep(10000);
99+
defaultAutoComplete(companyName, "goo");
100+
defaultAutoComplete(companyName, "sof");
101+
jobTitleAutoComplete(companyName, "sof");
102+
103+
BasicJobSample.deleteJob(jobName);
104+
BasicCompanySample.deleteCompany(companyName);
105+
}
106+
}

0 commit comments

Comments
 (0)