Search in sources :

Example 11 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 12 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 13 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 14 with TenantName

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

the class JobSearchListJobs method listJobs.

// Search Jobs with histogram queries.
public static void listJobs(String projectId, String tenantId, String filter) 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);
        ListJobsRequest request = ListJobsRequest.newBuilder().setParent(parent.toString()).setFilter(filter).build();
        for (Job responseItem : jobServiceClient.listJobs(request).iterateAll()) {
            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());
        }
    }
}
Also used : ListJobsRequest(com.google.cloud.talent.v4beta1.ListJobsRequest) TenantName(com.google.cloud.talent.v4beta1.TenantName) JobServiceClient(com.google.cloud.talent.v4beta1.JobServiceClient) Job(com.google.cloud.talent.v4beta1.Job)

Example 15 with TenantName

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

the class CommuteSearchJobs method searchJobs.

// Search Jobs with histogram queries.
public static void searchJobs(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();
        CommuteMethod commuteMethod = CommuteMethod.DRIVING;
        long seconds = 3600L;
        Duration travelDuration = Duration.newBuilder().setSeconds(seconds).build();
        double latitude = 37.422408;
        double longitude = -122.084068;
        LatLng startCoordinates = LatLng.newBuilder().setLatitude(latitude).setLongitude(longitude).build();
        CommuteFilter commuteFilter = CommuteFilter.newBuilder().setCommuteMethod(commuteMethod).setTravelDuration(travelDuration).setStartCoordinates(startCoordinates).build();
        JobQuery jobQuery = JobQuery.newBuilder().setCommuteFilter(commuteFilter).build();
        SearchJobsRequest request = SearchJobsRequest.newBuilder().setParent(parent.toString()).setRequestMetadata(requestMetadata).setJobQuery(jobQuery).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) Duration(com.google.protobuf.Duration) RequestMetadata(com.google.cloud.talent.v4beta1.RequestMetadata) CommuteFilter(com.google.cloud.talent.v4beta1.CommuteFilter) JobQuery(com.google.cloud.talent.v4beta1.JobQuery) LatLng(com.google.type.LatLng) Job(com.google.cloud.talent.v4beta1.Job) CommuteMethod(com.google.cloud.talent.v4beta1.CommuteMethod)

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