Search in sources :

Example 1 with CommuteFilter

use of com.google.cloud.talent.v4beta1.CommuteFilter 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

CommuteFilter (com.google.cloud.talent.v4beta1.CommuteFilter)1 CommuteMethod (com.google.cloud.talent.v4beta1.CommuteMethod)1 Job (com.google.cloud.talent.v4beta1.Job)1 JobQuery (com.google.cloud.talent.v4beta1.JobQuery)1 JobServiceClient (com.google.cloud.talent.v4beta1.JobServiceClient)1 RequestMetadata (com.google.cloud.talent.v4beta1.RequestMetadata)1 SearchJobsRequest (com.google.cloud.talent.v4beta1.SearchJobsRequest)1 SearchJobsResponse (com.google.cloud.talent.v4beta1.SearchJobsResponse)1 TenantName (com.google.cloud.talent.v4beta1.TenantName)1 Duration (com.google.protobuf.Duration)1 LatLng (com.google.type.LatLng)1