Search in sources :

Example 1 with Job

use of com.google.cloud.dataproc.v1.Job 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 2 with Job

use of com.google.cloud.dataproc.v1.Job 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)

Example 3 with Job

use of com.google.cloud.dataproc.v1.Job in project java-talent by googleapis.

the class JobSearchCommuteSearch method sampleSearchJobs.

/**
 * Search Jobs using commute distance
 */
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();
        CommuteMethod commuteMethod = CommuteMethod.TRANSIT;
        long seconds = 1800L;
        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.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) 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) TenantOrProjectName(com.google.cloud.talent.v4beta1.TenantOrProjectName) LatLng(com.google.type.LatLng) Job(com.google.cloud.talent.v4beta1.Job) CommuteMethod(com.google.cloud.talent.v4beta1.CommuteMethod)

Example 4 with Job

use of com.google.cloud.dataproc.v1.Job in project java-talent by googleapis.

the class ITSystemTest method updateJobTest.

@Test
public void updateJobTest() {
    String department = "Information technology";
    Job updateJob = job.toBuilder().setDepartment(department).build();
    UpdateJobRequest request = UpdateJobRequest.newBuilder().setJob(updateJob).build();
    Job actual = jobServiceClient.updateJob(request);
    assertEquals(job.getName(), actual.getName());
    assertEquals(job.getCompany(), actual.getCompany());
    assertEquals(job.getRequisitionId(), actual.getRequisitionId());
    assertEquals(job.getTitle(), actual.getTitle());
    assertEquals(job.getDescription(), actual.getDescription());
    assertEquals(job.getApplicationInfo(), actual.getApplicationInfo());
    assertEquals(job.getAddressesCount(), actual.getAddressesCount());
    assertEquals(job.getLanguageCode(), actual.getLanguageCode());
    assertEquals(department, actual.getDepartment());
}
Also used : UpdateJobRequest(com.google.cloud.talent.v4beta1.UpdateJobRequest) Job(com.google.cloud.talent.v4beta1.Job) Test(org.junit.Test)

Example 5 with Job

use of com.google.cloud.dataproc.v1.Job in project java-talent by googleapis.

the class ITSystemTest method beforeTest.

@BeforeClass
public static void beforeTest() throws IOException {
    /* create tenant */
    tenantServiceClient = TenantServiceClient.create();
    Tenant createTenant = Tenant.newBuilder().setName(TENANT_NAME).setExternalId(EXTERNAL_ID).build();
    CreateTenantRequest request = CreateTenantRequest.newBuilder().setParent(PROJECT_NAME.toString()).setTenant(createTenant).build();
    tenant = tenantServiceClient.createTenant(request);
    tenantId = getId(tenant.getName());
    tenantName = TenantName.of(PROJECT_ID, tenantId);
    /* create company */
    companyServiceClient = CompanyServiceClient.create();
    Company createCompany = Company.newBuilder().setDisplayName(DISPLAY_NAME).setExternalId(EXTERNAL_ID).build();
    CreateCompanyRequest companyRequest = CreateCompanyRequest.newBuilder().setParent(tenantName.toString()).setCompany(createCompany).build();
    company = companyServiceClient.createCompany(companyRequest);
    companyId = getId(company.getName());
    companyName = CompanyName.ofProjectTenantCompanyName(PROJECT_ID, tenantId, companyId);
    /* create job */
    jobServiceClient = JobServiceClient.create();
    Job.ApplicationInfo applicationInfo = Job.ApplicationInfo.newBuilder().addAllUris(Arrays.asList(JOB_APPLICATION_URL)).build();
    Job createJob = Job.newBuilder().setCompany(companyId).setRequisitionId(REQUISITION_ID).setTitle(TITLE).setDescription(DESCRIPTION).setApplicationInfo(applicationInfo).addAllAddresses(Arrays.asList(ADDRESS_ONE, ADDRESS_TWO)).setLanguageCode(LANGUAGE_CODE).build();
    CreateJobRequest jobRequest = CreateJobRequest.newBuilder().setParent(tenantName.toString()).setJob(createJob).build();
    job = jobServiceClient.createJob(jobRequest);
    jobId = getId(job.getName());
    jobName = JobName.ofProjectTenantJobName(PROJECT_ID, tenantId, jobId);
    /*create event */
    eventServiceClient = EventServiceClient.create();
    // create completion
    completionClient = CompletionClient.create();
}
Also used : CreateTenantRequest(com.google.cloud.talent.v4beta1.CreateTenantRequest) Company(com.google.cloud.talent.v4beta1.Company) Tenant(com.google.cloud.talent.v4beta1.Tenant) CreateCompanyRequest(com.google.cloud.talent.v4beta1.CreateCompanyRequest) Job(com.google.cloud.talent.v4beta1.Job) CreateJobRequest(com.google.cloud.talent.v4beta1.CreateJobRequest) BeforeClass(org.junit.BeforeClass)

Aggregations

Job (org.pentaho.platform.api.scheduler2.Job)94 Test (org.junit.Test)91 Job (io.fabric8.kubernetes.api.model.batch.v1.Job)38 Serializable (java.io.Serializable)25 ArrayList (java.util.ArrayList)24 HashMap (java.util.HashMap)22 SimpleJobTrigger (org.pentaho.platform.api.scheduler2.SimpleJobTrigger)21 Job (com.google.cloud.talent.v4beta1.Job)20 JobScheduleRequest (org.pentaho.platform.web.http.api.resources.JobScheduleRequest)19 ComplexJobTrigger (org.pentaho.platform.api.scheduler2.ComplexJobTrigger)18 SchedulerException (org.pentaho.platform.api.scheduler2.SchedulerException)17 JobServiceClient (com.google.cloud.talent.v4beta1.JobServiceClient)16 Date (java.util.Date)14 IJobFilter (org.pentaho.platform.api.scheduler2.IJobFilter)14 Job (com.google.cloud.video.transcoder.v1.Job)13 TranscoderServiceClient (com.google.cloud.video.transcoder.v1.TranscoderServiceClient)13 JobBuilder (io.fabric8.kubernetes.api.model.batch.v1.JobBuilder)13 IJobTrigger (org.pentaho.platform.api.scheduler2.IJobTrigger)12 Map (java.util.Map)11 Test (org.junit.jupiter.api.Test)10