Search in sources :

Example 21 with JobServiceClient

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

the class JobSearchCustomRankingSearch method sampleSearchJobs.

/**
 * Search Jobs using custom rankings
 *
 * @param projectId Your Google Cloud Project ID
 * @param tenantId Identifier of the Tenantd
 */
public static void sampleSearchJobs(String projectId, String tenantId) {
    try (JobServiceClient jobServiceClient = JobServiceClient.create()) {
        TenantOrProjectName 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.printf("Job summary: %s\n", responseItem.getJobSummary());
            System.out.printf("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());
        }
    } catch (Exception exception) {
        System.err.println("Failed to create the client due to: " + exception);
    }
}
Also used : SearchJobsRequest(com.google.cloud.talent.v4beta1.SearchJobsRequest) JobServiceClient(com.google.cloud.talent.v4beta1.JobServiceClient) TenantOrProjectName(com.google.cloud.talent.v4beta1.TenantOrProjectName) Job(com.google.cloud.talent.v4beta1.Job) RequestMetadata(com.google.cloud.talent.v4beta1.RequestMetadata)

Example 22 with JobServiceClient

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

the class JobSearchHistogramSearch method sampleSearchJobs.

/**
 * Search Jobs with histogram queries
 *
 * @param query Histogram query More info on histogram facets, constants, and built-in functions:
 *     https://godoc.org/google.golang.org/genproto/googleapis/cloud/talent/v4beta1#SearchJobsRequest
 */
public static void sampleSearchJobs(String projectId, String tenantId, String query) {
    try (JobServiceClient jobServiceClient = JobServiceClient.create()) {
        TenantOrProjectName 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();
        HistogramQuery histogramQueriesElement = HistogramQuery.newBuilder().setHistogramQuery(query).build();
        List<HistogramQuery> histogramQueries = Arrays.asList(histogramQueriesElement);
        SearchJobsRequest request = SearchJobsRequest.newBuilder().setParent(parent.toString()).setRequestMetadata(requestMetadata).addAllHistogramQueries(histogramQueries).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());
            Job job = responseItem.getJob();
            System.out.printf("Job name: %s\n", job.getName());
            System.out.printf("Job title: %s\n", job.getTitle());
        }
    } catch (Exception exception) {
        System.err.println("Failed to create the client due to: " + exception);
    }
}
Also used : SearchJobsRequest(com.google.cloud.talent.v4beta1.SearchJobsRequest) HistogramQuery(com.google.cloud.talent.v4beta1.HistogramQuery) JobServiceClient(com.google.cloud.talent.v4beta1.JobServiceClient) TenantOrProjectName(com.google.cloud.talent.v4beta1.TenantOrProjectName) Job(com.google.cloud.talent.v4beta1.Job) RequestMetadata(com.google.cloud.talent.v4beta1.RequestMetadata)

Example 23 with JobServiceClient

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

the class JobSearchBatchDeleteJob method sampleBatchDeleteJobs.

/**
 * Batch delete jobs using a filter
 *
 * @param projectId Your Google Cloud Project ID
 * @param tenantId Identifier of the Tenantd
 * @param filter The filter string specifies the jobs to be deleted. For example: companyName =
 *     "projects/api-test-project/companies/123" AND equisitionId = "req-1"
 */
public static void sampleBatchDeleteJobs(String projectId, String tenantId, String filter) {
    try (JobServiceClient jobServiceClient = JobServiceClient.create()) {
        TenantOrProjectName parent = TenantName.of(projectId, tenantId);
        BatchDeleteJobsRequest request = BatchDeleteJobsRequest.newBuilder().setParent(parent.toString()).setFilter(filter).build();
        jobServiceClient.batchDeleteJobs(request);
        System.out.println("Batch deleted jobs from filter");
    } catch (Exception exception) {
        System.err.println("Failed to create the client due to: " + exception);
    }
}
Also used : BatchDeleteJobsRequest(com.google.cloud.talent.v4beta1.BatchDeleteJobsRequest) JobServiceClient(com.google.cloud.talent.v4beta1.JobServiceClient) TenantOrProjectName(com.google.cloud.talent.v4beta1.TenantOrProjectName)

Example 24 with JobServiceClient

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

the class JobSearchCreateJob method sampleCreateJob.

/**
 * Create Job
 *
 * @param projectId Your Google Cloud Project ID
 * @param tenantId Identifier of the Tenant
 */
public static void sampleCreateJob(String projectId, String tenantId, String companyName, String requisitionId, String title, String description, String jobApplicationUrl, String addressOne, String addressTwo, String languageCode) {
    try (JobServiceClient jobServiceClient = JobServiceClient.create()) {
        TenantOrProjectName parent = TenantName.of(projectId, tenantId);
        List<String> uris = Arrays.asList(jobApplicationUrl);
        Job.ApplicationInfo applicationInfo = Job.ApplicationInfo.newBuilder().addAllUris(uris).build();
        List<String> addresses = Arrays.asList(addressOne, addressTwo);
        Job job = Job.newBuilder().setCompany(companyName).setRequisitionId(requisitionId).setTitle(title).setDescription(description).setApplicationInfo(applicationInfo).addAllAddresses(addresses).setLanguageCode(languageCode).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());
    } catch (Exception exception) {
        System.err.println("Failed to create the client due to: " + exception);
    }
}
Also used : JobServiceClient(com.google.cloud.talent.v4beta1.JobServiceClient) TenantOrProjectName(com.google.cloud.talent.v4beta1.TenantOrProjectName) Job(com.google.cloud.talent.v4beta1.Job) CreateJobRequest(com.google.cloud.talent.v4beta1.CreateJobRequest)

Example 25 with JobServiceClient

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

the class JobSearchCreateJob method createJob.

// Create a job.
public static void createJob(String projectId, String tenantId, String companyId, String requisitionId, String jobApplicationUrl) 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);
        Job.ApplicationInfo applicationInfo = Job.ApplicationInfo.newBuilder().addUris(jobApplicationUrl).build();
        List<String> addresses = Arrays.asList("1600 Amphitheatre Parkway, Mountain View, CA 94043", "111 8th Avenue, New York, NY 10011");
        // By default, job will expire in 30 days.
        // https://cloud.google.com/talent-solution/job-search/docs/jobs
        Job job = Job.newBuilder().setCompany(companyId).setRequisitionId(requisitionId).setTitle("Software Developer").setDescription("Develop, maintain the software solutions.").setApplicationInfo(applicationInfo).addAllAddresses(addresses).setLanguageCode("en-US").build();
        CreateJobRequest request = CreateJobRequest.newBuilder().setParent(parent.toString()).setJob(job).build();
        Job response = jobServiceClient.createJob(request);
        System.out.format("Created job: %s%n", response.getName());
    }
}
Also used : TenantName(com.google.cloud.talent.v4.TenantName) JobServiceClient(com.google.cloud.talent.v4.JobServiceClient) Job(com.google.cloud.talent.v4.Job) CreateJobRequest(com.google.cloud.talent.v4.CreateJobRequest)

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