Search in sources :

Example 1 with TenantName

use of com.google.cloud.talent.v4.TenantName in project java-docs-samples by GoogleCloudPlatform.

the class CustomRankingSearchJobs method searchCustomRankingJobs.

// Search Jobs using custom rankings.
public static void searchCustomRankingJobs(String projectId, String tenantId) throws IOException {
    // 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";
        String sessionId = "Hashed session identifier";
        String userId = "Hashed user identifier";
        RequestMetadata requestMetadata = RequestMetadata.newBuilder().setDomain(domain).setSessionId(sessionId).setUserId(userId).build();
        SearchJobsRequest.CustomRankingInfo.ImportanceLevel importanceLevel = SearchJobsRequest.CustomRankingInfo.ImportanceLevel.EXTREME;
        String rankingExpression = "(someFieldLong + 25) * 0.25";
        SearchJobsRequest.CustomRankingInfo customRankingInfo = SearchJobsRequest.CustomRankingInfo.newBuilder().setImportanceLevel(importanceLevel).setRankingExpression(rankingExpression).build();
        String orderBy = "custom_ranking desc";
        SearchJobsRequest request = SearchJobsRequest.newBuilder().setParent(parent.toString()).setRequestMetadata(requestMetadata).setCustomRankingInfo(customRankingInfo).setOrderBy(orderBy).build();
        for (SearchJobsResponse.MatchingJob responseItem : jobServiceClient.searchJobs(request).iterateAll()) {
            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.format("Job name: %s%n", job.getName());
            System.out.format("Job title: %s%n", job.getTitle());
        }
    }
}
Also used : SearchJobsRequest(com.google.cloud.talent.v4beta1.SearchJobsRequest) SearchJobsResponse(com.google.cloud.talent.v4beta1.SearchJobsResponse) TenantName(com.google.cloud.talent.v4beta1.TenantName) JobServiceClient(com.google.cloud.talent.v4beta1.JobServiceClient) Job(com.google.cloud.talent.v4beta1.Job) RequestMetadata(com.google.cloud.talent.v4beta1.RequestMetadata)

Example 2 with TenantName

use of com.google.cloud.talent.v4.TenantName in project java-docs-samples by GoogleCloudPlatform.

the class JobSearchAutoCompleteJobTitle method completeQuery.

// Complete job title given partial text (autocomplete).
public static void completeQuery(String projectId, String tenantId, String query) throws IOException {
    // 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 = CompleteQueryRequest.newBuilder().setParent(parent.toString()).setQuery(query).setPageSize(// limit for number of results
        5).addLanguageCodes(// language code
        "en-US").build();
        CompleteQueryResponse response = completionClient.completeQuery(request);
        for (CompleteQueryResponse.CompletionResult result : response.getCompletionResultsList()) {
            System.out.format("Suggested title: %s%n", result.getSuggestion());
            // Suggestion type is JOB_TITLE or COMPANY_TITLE
            System.out.format("Suggestion type: %s%n", result.getType());
        }
    }
}
Also used : CompleteQueryResponse(com.google.cloud.talent.v4beta1.CompleteQueryResponse) TenantName(com.google.cloud.talent.v4beta1.TenantName) CompletionClient(com.google.cloud.talent.v4beta1.CompletionClient) CompleteQueryRequest(com.google.cloud.talent.v4beta1.CompleteQueryRequest)

Example 3 with TenantName

use of com.google.cloud.talent.v4.TenantName in project java-docs-samples by GoogleCloudPlatform.

the class JobSearchCreateJobCustomAttributes method createJob.

// Create Job with Custom Attributes.
public static void createJob(String projectId, String tenantId, String companyId, String requisitionId) throws IOException {
    // 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);
        // Custom attribute can be string or numeric value, and can be filtered in search queries.
        // https://cloud.google.com/talent-solution/job-search/docs/custom-attributes
        CustomAttribute customAttribute = CustomAttribute.newBuilder().addStringValues("Internship").addStringValues("Apprenticeship").setFilterable(true).build();
        Job job = Job.newBuilder().setCompany(companyId).setTitle("Software Developer I").setDescription("This is a description of this <i>wonderful</i> job!").putCustomAttributes("FOR_STUDENTS", customAttribute).setRequisitionId(requisitionId).setLanguageCode("en-US").build();
        CreateJobRequest request = CreateJobRequest.newBuilder().setParent(parent.toString()).setJob(job).build();
        Job response = jobServiceClient.createJob(request);
        System.out.printf("Created job: %s\n", response.getName());
    }
}
Also used : TenantName(com.google.cloud.talent.v4beta1.TenantName) CustomAttribute(com.google.cloud.talent.v4beta1.CustomAttribute) JobServiceClient(com.google.cloud.talent.v4beta1.JobServiceClient) Job(com.google.cloud.talent.v4beta1.Job) CreateJobRequest(com.google.cloud.talent.v4beta1.CreateJobRequest)

Example 4 with TenantName

use of com.google.cloud.talent.v4.TenantName in project java-docs-samples by GoogleCloudPlatform.

the class JobSearchListCompanies method listCompanies.

// List Companies.
public static void listCompanies(String projectId, String tenantId) throws IOException {
    // 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);
        ListCompaniesRequest request = ListCompaniesRequest.newBuilder().setParent(parent.toString()).build();
        for (Company responseItem : companyServiceClient.listCompanies(request).iterateAll()) {
            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());
        }
    }
}
Also used : ListCompaniesRequest(com.google.cloud.talent.v4beta1.ListCompaniesRequest) CompanyServiceClient(com.google.cloud.talent.v4beta1.CompanyServiceClient) Company(com.google.cloud.talent.v4beta1.Company) TenantName(com.google.cloud.talent.v4beta1.TenantName)

Example 5 with TenantName

use of com.google.cloud.talent.v4.TenantName in project java-talent by googleapis.

the class JobServiceClientTest method listJobsTest.

@Test
public void listJobsTest() throws Exception {
    Job responsesElement = Job.newBuilder().build();
    ListJobsResponse expectedResponse = ListJobsResponse.newBuilder().setNextPageToken("").addAllJobs(Arrays.asList(responsesElement)).build();
    mockJobService.addResponse(expectedResponse);
    TenantName parent = TenantName.of("[PROJECT]", "[TENANT]");
    String filter = "filter-1274492040";
    ListJobsPagedResponse pagedListResponse = client.listJobs(parent, filter);
    List<Job> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getJobsList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockJobService.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListJobsRequest actualRequest = ((ListJobsRequest) actualRequests.get(0));
    Assert.assertEquals(parent.toString(), actualRequest.getParent());
    Assert.assertEquals(filter, actualRequest.getFilter());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : ListJobsPagedResponse(com.google.cloud.talent.v4.JobServiceClient.ListJobsPagedResponse) AbstractMessage(com.google.protobuf.AbstractMessage) Test(org.junit.Test)

Aggregations

TenantName (com.google.cloud.talent.v4beta1.TenantName)14 TenantName (com.google.cloud.talent.v4.TenantName)12 Job (com.google.cloud.talent.v4.Job)6 JobServiceClient (com.google.cloud.talent.v4.JobServiceClient)6 Job (com.google.cloud.talent.v4beta1.Job)6 JobServiceClient (com.google.cloud.talent.v4beta1.JobServiceClient)6 TenantServiceClient (com.google.cloud.talent.v4beta1.TenantServiceClient)4 RequestMetadata (com.google.cloud.talent.v4.RequestMetadata)3 SearchJobsRequest (com.google.cloud.talent.v4.SearchJobsRequest)3 SearchJobsResponse (com.google.cloud.talent.v4.SearchJobsResponse)3 RequestMetadata (com.google.cloud.talent.v4beta1.RequestMetadata)3 SearchJobsRequest (com.google.cloud.talent.v4beta1.SearchJobsRequest)3 SearchJobsResponse (com.google.cloud.talent.v4beta1.SearchJobsResponse)3 Company (com.google.cloud.talent.v4.Company)2 CompanyServiceClient (com.google.cloud.talent.v4.CompanyServiceClient)2 CreateJobRequest (com.google.cloud.talent.v4.CreateJobRequest)2 TenantServiceClient (com.google.cloud.talent.v4.TenantServiceClient)2 Company (com.google.cloud.talent.v4beta1.Company)2 CompanyServiceClient (com.google.cloud.talent.v4beta1.CompanyServiceClient)2 CreateJobRequest (com.google.cloud.talent.v4beta1.CreateJobRequest)2