Search in sources :

Example 1 with JobServiceClient

use of com.google.cloud.talent.v4.JobServiceClient 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 JobServiceClient

use of com.google.cloud.talent.v4.JobServiceClient 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 3 with JobServiceClient

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

the class JobSearchGetJob method getJob.

// Get Job.
public static void getJob(String projectId, String tenantId, String jobId) throws IOException {
    // 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);
        GetJobRequest request = GetJobRequest.newBuilder().setName(name.toString()).build();
        Job response = jobServiceClient.getJob(request);
        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.format("Address: %s%n", address);
        }
        for (String email : response.getApplicationInfo().getEmailsList()) {
            System.out.format("Email: %s%n", email);
        }
        for (String websiteUri : response.getApplicationInfo().getUrisList()) {
            System.out.format("Website: %s%n", websiteUri);
        }
    }
}
Also used : GetJobRequest(com.google.cloud.talent.v4beta1.GetJobRequest) JobName(com.google.cloud.talent.v4beta1.JobName) JobServiceClient(com.google.cloud.talent.v4beta1.JobServiceClient) Job(com.google.cloud.talent.v4beta1.Job)

Example 4 with JobServiceClient

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

the class JobSearchBatchCreateJobs method sampleBatchCreateJobs.

/**
 * Batch Create Jobs
 *
 * @param projectId Your Google Cloud Project ID
 * @param tenantId Identifier of the Tenant
 */
public static void sampleBatchCreateJobs(String projectId, String tenantId, String companyNameOne, String requisitionIdOne, String titleOne, String descriptionOne, String jobApplicationUrlOne, String addressOne, String languageCodeOne, String companyNameTwo, String requisitionIdTwo, String titleTwo, String descriptionTwo, String jobApplicationUrlTwo, String addressTwo, String languageCodeTwo) {
    try (JobServiceClient jobServiceClient = JobServiceClient.create()) {
        String formattedParent = TenantName.format(projectId, tenantId);
        List<String> uris = Arrays.asList(jobApplicationUrlOne);
        Job.ApplicationInfo applicationInfo = Job.ApplicationInfo.newBuilder().addAllUris(uris).build();
        List<String> addresses = Arrays.asList(addressOne);
        Job jobsElement = Job.newBuilder().setCompany(companyNameOne).setRequisitionId(requisitionIdOne).setTitle(titleOne).setDescription(descriptionOne).setApplicationInfo(applicationInfo).addAllAddresses(addresses).setLanguageCode(languageCodeOne).build();
        List<String> uris2 = Arrays.asList(jobApplicationUrlTwo);
        Job.ApplicationInfo applicationInfo2 = Job.ApplicationInfo.newBuilder().addAllUris(uris2).build();
        List<String> addresses2 = Arrays.asList(addressTwo);
        Job jobsElement2 = Job.newBuilder().setCompany(companyNameTwo).setRequisitionId(requisitionIdTwo).setTitle(titleTwo).setDescription(descriptionTwo).setApplicationInfo(applicationInfo2).addAllAddresses(addresses2).setLanguageCode(languageCodeTwo).build();
        List<Job> jobs = Arrays.asList(jobsElement, jobsElement2);
        BatchCreateJobsRequest request = BatchCreateJobsRequest.newBuilder().setParent(formattedParent).addAllJobs(jobs).build();
        OperationFuture<JobOperationResult, BatchOperationMetadata> future = jobServiceClient.batchCreateJobsAsync(request);
        System.out.println("Waiting for operation to complete...");
        JobOperationResult response = future.get();
        System.out.printf("Batch response: %s\n", response);
    } catch (Exception exception) {
        System.err.println("Failed to create the client due to: " + exception);
    }
}
Also used : JobOperationResult(com.google.cloud.talent.v4beta1.JobOperationResult) JobServiceClient(com.google.cloud.talent.v4beta1.JobServiceClient) BatchCreateJobsRequest(com.google.cloud.talent.v4beta1.BatchCreateJobsRequest) BatchOperationMetadata(com.google.cloud.talent.v4beta1.BatchOperationMetadata) Job(com.google.cloud.talent.v4beta1.Job)

Example 5 with JobServiceClient

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

the class JobSearchBatchUpdateJobs method sampleBatchUpdateJobs.

/**
 * Batch Update Jobs
 *
 * @param projectId Your Google Cloud Project ID
 * @param tenantId Identifier of the Tenant
 */
public static void sampleBatchUpdateJobs(String projectId, String tenantId, String jobNameOne, String companyNameOne, String requisitionIdOne, String titleOne, String descriptionOne, String jobApplicationUrlOne, String addressOne, String languageCodeOne, String jobNameTwo, String companyNameTwo, String requisitionIdTwo, String titleTwo, String descriptionTwo, String jobApplicationUrlTwo, String addressTwo, String languageCodeTwo) {
    try (JobServiceClient jobServiceClient = JobServiceClient.create()) {
        String formattedParent = TenantName.format(projectId, tenantId);
        List<String> uris = Arrays.asList(jobApplicationUrlOne);
        Job.ApplicationInfo applicationInfo = Job.ApplicationInfo.newBuilder().addAllUris(uris).build();
        List<String> addresses = Arrays.asList(addressOne);
        Job jobsElement = Job.newBuilder().setName(jobNameOne).setCompany(companyNameOne).setRequisitionId(requisitionIdOne).setTitle(titleOne).setDescription(descriptionOne).setApplicationInfo(applicationInfo).addAllAddresses(addresses).setLanguageCode(languageCodeOne).build();
        List<String> uris2 = Arrays.asList(jobApplicationUrlTwo);
        Job.ApplicationInfo applicationInfo2 = Job.ApplicationInfo.newBuilder().addAllUris(uris2).build();
        List<String> addresses2 = Arrays.asList(addressTwo);
        Job jobsElement2 = Job.newBuilder().setName(jobNameTwo).setCompany(companyNameTwo).setRequisitionId(requisitionIdTwo).setTitle(titleTwo).setDescription(descriptionTwo).setApplicationInfo(applicationInfo2).addAllAddresses(addresses2).setLanguageCode(languageCodeTwo).build();
        List<Job> jobs = Arrays.asList(jobsElement, jobsElement2);
        BatchUpdateJobsRequest request = BatchUpdateJobsRequest.newBuilder().setParent(formattedParent).addAllJobs(jobs).build();
        OperationFuture<JobOperationResult, BatchOperationMetadata> future = jobServiceClient.batchUpdateJobsAsync(request);
        System.out.println("Waiting for operation to complete...");
        JobOperationResult response = future.get();
        System.out.printf("Batch response: %s\n", response);
    } catch (Exception exception) {
        System.err.println("Failed to create the client due to: " + exception);
    }
}
Also used : JobOperationResult(com.google.cloud.talent.v4beta1.JobOperationResult) JobServiceClient(com.google.cloud.talent.v4beta1.JobServiceClient) BatchUpdateJobsRequest(com.google.cloud.talent.v4beta1.BatchUpdateJobsRequest) BatchOperationMetadata(com.google.cloud.talent.v4beta1.BatchOperationMetadata) Job(com.google.cloud.talent.v4beta1.Job)

Aggregations

JobServiceClient (com.google.cloud.talent.v4beta1.JobServiceClient)19 Job (com.google.cloud.talent.v4beta1.Job)16 JobServiceClient (com.google.cloud.talent.v4.JobServiceClient)8 Job (com.google.cloud.talent.v4.Job)7 TenantOrProjectName (com.google.cloud.talent.v4beta1.TenantOrProjectName)7 TenantName (com.google.cloud.talent.v4.TenantName)6 RequestMetadata (com.google.cloud.talent.v4beta1.RequestMetadata)6 SearchJobsRequest (com.google.cloud.talent.v4beta1.SearchJobsRequest)6 TenantName (com.google.cloud.talent.v4beta1.TenantName)6 CreateJobRequest (com.google.cloud.talent.v4beta1.CreateJobRequest)4 JobName (com.google.cloud.talent.v4beta1.JobName)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 SearchJobsResponse (com.google.cloud.talent.v4beta1.SearchJobsResponse)3 Duration (com.google.protobuf.Duration)3 LatLng (com.google.type.LatLng)3 CreateJobRequest (com.google.cloud.talent.v4.CreateJobRequest)2 JobName (com.google.cloud.talent.v4.JobName)2 BatchOperationMetadata (com.google.cloud.talent.v4beta1.BatchOperationMetadata)2