refactor JobsApi

This commit is contained in:
Brian Long 2023-11-13 17:34:59 -05:00
parent b146e1d55a
commit 17515d4be3
7 changed files with 251 additions and 153 deletions

View File

@ -14,10 +14,13 @@
*/
package com.inteligr8.activiti;
import com.inteligr8.activiti.api.DeadletterJobsApi;
import com.inteligr8.activiti.api.ExecutionApi;
import com.inteligr8.activiti.api.JobsApi;
import com.inteligr8.activiti.api.ManagementApi;
import com.inteligr8.activiti.api.ProcessInstanceApi;
import com.inteligr8.activiti.api.RuntimeApi;
import com.inteligr8.activiti.api.TimerJobsApi;
/**
* This interface consolidates the JAX-RS APIs available in the open-source
@ -36,6 +39,18 @@ public interface ActivitiPublicRestApi {
default RuntimeApi getRuntimeApi() {
return this.getApi(RuntimeApi.class);
}
default JobsApi getJobsApi() {
return this.getApi(JobsApi.class);
}
default DeadletterJobsApi getDeadletterJobsApi() {
return this.getApi(DeadletterJobsApi.class);
}
default TimerJobsApi getTimerJobsApi() {
return this.getApi(TimerJobsApi.class);
}
default ProcessInstanceApi getProcessInstanceApi() {
return this.getApi(ProcessInstanceApi.class);

View File

@ -0,0 +1,163 @@
/*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.inteligr8.activiti.api;
import java.io.File;
import java.time.LocalDate;
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
import com.inteligr8.activiti.model.Action;
import com.inteligr8.activiti.model.Action.ActionValue;
import com.inteligr8.activiti.model.Job;
import com.inteligr8.activiti.model.ResultList;
public interface BaseJobsApi {
@GET
@Path("{jobId}")
@Produces({ MediaType.APPLICATION_JSON })
public Job getJob(
@PathParam("jobId") String jobId);
@DELETE
@Path("{jobId}")
public void deleteJob(
@PathParam("jobId") String jobId);
@POST
@Path("{jobId}")
@Consumes({ MediaType.APPLICATION_JSON })
public void executeJob(
@PathParam("jobId") String jobId,
Action execute);
default void executeJob(
String jobId,
ActionValue action) {
this.executeJob(jobId, new Action(action));
}
default void executeJob(
String jobId) {
this.executeJob(jobId, new Action(ActionValue.Execute));
}
@GET
@Path("{jobId}/execution-stacktrace")
@Produces({ MediaType.APPLICATION_OCTET_STREAM })
public File getJobStacktrace(
@PathParam("jobId") String jobId);
@GET
@Produces({ MediaType.APPLICATION_JSON })
public ResultList<Job> queryJobs(
@QueryParam("processInstanceId") String processInstanceId,
@QueryParam("executionId") String executionId,
@QueryParam("processDefinitionId") String processDefinitionId,
@QueryParam("withRetriesLeft") Boolean withRetriesLeft,
@QueryParam("executable") Boolean executable,
@QueryParam("dueBefore") LocalDate dueBefore,
@QueryParam("dueAfter") LocalDate dueAfter,
@QueryParam("withoutTenantId") Boolean withoutTenatId,
@QueryParam("sort") String sort);
@GET
@Produces({ MediaType.APPLICATION_JSON })
public ResultList<Job> queryJobs(
@QueryParam("processInstanceId") String processInstanceId,
@QueryParam("executionId") String executionId,
@QueryParam("processDefinitionId") String processDefinitionId,
@QueryParam("withRetriesLeft") Boolean withRetriesLeft,
@QueryParam("executable") Boolean executable,
@QueryParam("dueBefore") LocalDate dueBefore,
@QueryParam("dueAfter") LocalDate dueAfter,
@QueryParam("tenantId") String tenantId,
@QueryParam("tenantIdLike") String tenantIdLike,
@QueryParam("sort") String sort);
@GET
@Produces({ MediaType.APPLICATION_JSON })
public ResultList<Job> queryJobs(
@QueryParam("processInstanceId") String processInstanceId,
@QueryParam("executionId") String executionId,
@QueryParam("processDefinitionId") String processDefinitionId,
@QueryParam("withRetriesLeft") Boolean withRetriesLeft,
@QueryParam("executable") Boolean executable,
@QueryParam("withException") Boolean withException,
@QueryParam("dueBefore") LocalDate dueBefore,
@QueryParam("dueAfter") LocalDate dueAfter,
@QueryParam("exceptionMessage") String exceptionMessage,
@QueryParam("withoutTenantId") Boolean withoutTenatId,
@QueryParam("sort") String sort);
@GET
@Produces({ MediaType.APPLICATION_JSON })
public ResultList<Job> queryJobs(
@QueryParam("processInstanceId") String processInstanceId,
@QueryParam("executionId") String executionId,
@QueryParam("processDefinitionId") String processDefinitionId,
@QueryParam("withRetriesLeft") Boolean withRetriesLeft,
@QueryParam("executable") Boolean executable,
@QueryParam("withException") Boolean withException,
@QueryParam("dueBefore") LocalDate dueBefore,
@QueryParam("dueAfter") LocalDate dueAfter,
@QueryParam("exceptionMessage") String exceptionMessage,
@QueryParam("tenantId") String tenantId,
@QueryParam("tenantIdLike") String tenantIdLike,
@QueryParam("sort") String sort);
@GET
@Produces({ MediaType.APPLICATION_JSON })
public ResultList<Job> queryJobs(
@QueryParam("id") String jobId,
@QueryParam("processInstanceId") String processInstanceId,
@QueryParam("executionId") String executionId,
@QueryParam("processDefinitionId") String processDefinitionId,
@QueryParam("withRetriesLeft") Boolean withRetriesLeft,
@QueryParam("executable") Boolean executable,
@QueryParam("withException") Boolean withException,
@QueryParam("dueBefore") LocalDate dueBefore,
@QueryParam("dueAfter") LocalDate dueAfter,
@QueryParam("exceptionMessage") String exceptionMessage,
@QueryParam("withoutTenantId") Boolean withoutTenatId,
@QueryParam("sort") String sort);
@GET
@Produces({ MediaType.APPLICATION_JSON })
public ResultList<Job> queryJobs(
@QueryParam("id") String jobId,
@QueryParam("processInstanceId") String processInstanceId,
@QueryParam("executionId") String executionId,
@QueryParam("processDefinitionId") String processDefinitionId,
@QueryParam("withRetriesLeft") Boolean withRetriesLeft,
@QueryParam("executable") Boolean executable,
@QueryParam("withException") Boolean withException,
@QueryParam("dueBefore") LocalDate dueBefore,
@QueryParam("dueAfter") LocalDate dueAfter,
@QueryParam("exceptionMessage") String exceptionMessage,
@QueryParam("tenantId") String tenantId,
@QueryParam("tenantIdLike") String tenantIdLike,
@QueryParam("sort") String sort);
}

View File

@ -0,0 +1,21 @@
/*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.inteligr8.activiti.api;
import javax.ws.rs.Path;
@Path("/api/management/deadletter-jobs")
public interface DeadletterJobsApi extends BaseJobsApi {
}

View File

@ -0,0 +1,21 @@
/*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.inteligr8.activiti.api;
import javax.ws.rs.Path;
@Path("/api/management/jobs")
public interface JobsApi extends BaseJobsApi {
}

View File

@ -14,25 +14,13 @@
*/
package com.inteligr8.activiti.api;
import java.io.File;
import java.time.LocalDate;
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
import com.inteligr8.activiti.model.Action;
import com.inteligr8.activiti.model.Action.ActionValue;
import com.inteligr8.activiti.model.Engine;
import com.inteligr8.activiti.model.EngineProperties;
import com.inteligr8.activiti.model.Job;
import com.inteligr8.activiti.model.ResultList;
@Path("/api/management")
public interface ManagementApi {
@ -46,146 +34,5 @@ public interface ManagementApi {
@Path("properties")
@Produces({ MediaType.APPLICATION_JSON })
public EngineProperties getEngineProperties();
@Path("jobs")
public interface JobsApiImpl extends JobsApi {}
@Path("timer-jobs")
public interface TimerJobsApiImpl extends JobsApi {}
@Path("deadletter-jobs")
public interface DeadletterJobsApiImpl extends JobsApi {}
public interface JobsApi {
@GET
@Path("{jobId}")
@Produces({ MediaType.APPLICATION_JSON })
public Job getJob(
@PathParam("jobId") String jobId);
@DELETE
@Path("{jobId}")
public void deleteJob(
@PathParam("jobId") String jobId);
@POST
@Path("{jobId}")
@Consumes({ MediaType.APPLICATION_JSON })
public void executeJob(
@PathParam("jobId") String jobId,
Action execute);
default void executeJob(
String jobId,
ActionValue action) {
this.executeJob(jobId, new Action(action));
}
default void executeJob(
String jobId) {
this.executeJob(jobId, new Action(ActionValue.Execute));
}
@GET
@Path("{jobId}/execution-stacktrace")
@Produces({ MediaType.APPLICATION_OCTET_STREAM })
public File getJobStacktrace(
@PathParam("jobId") String jobId);
@GET
@Produces({ MediaType.APPLICATION_JSON })
public ResultList<Job> queryJobs(
@QueryParam("processInstanceId") String processInstanceId,
@QueryParam("executionId") String executionId,
@QueryParam("processDefinitionId") String processDefinitionId,
@QueryParam("withRetriesLeft") Boolean withRetriesLeft,
@QueryParam("executable") Boolean executable,
@QueryParam("dueBefore") LocalDate dueBefore,
@QueryParam("dueAfter") LocalDate dueAfter,
@QueryParam("withoutTenantId") Boolean withoutTenatId,
@QueryParam("sort") String sort);
@GET
@Produces({ MediaType.APPLICATION_JSON })
public ResultList<Job> queryJobs(
@QueryParam("processInstanceId") String processInstanceId,
@QueryParam("executionId") String executionId,
@QueryParam("processDefinitionId") String processDefinitionId,
@QueryParam("withRetriesLeft") Boolean withRetriesLeft,
@QueryParam("executable") Boolean executable,
@QueryParam("dueBefore") LocalDate dueBefore,
@QueryParam("dueAfter") LocalDate dueAfter,
@QueryParam("tenantId") String tenantId,
@QueryParam("tenantIdLike") String tenantIdLike,
@QueryParam("sort") String sort);
@GET
@Produces({ MediaType.APPLICATION_JSON })
public ResultList<Job> queryJobs(
@QueryParam("processInstanceId") String processInstanceId,
@QueryParam("executionId") String executionId,
@QueryParam("processDefinitionId") String processDefinitionId,
@QueryParam("withRetriesLeft") Boolean withRetriesLeft,
@QueryParam("executable") Boolean executable,
@QueryParam("withException") Boolean withException,
@QueryParam("dueBefore") LocalDate dueBefore,
@QueryParam("dueAfter") LocalDate dueAfter,
@QueryParam("exceptionMessage") String exceptionMessage,
@QueryParam("withoutTenantId") Boolean withoutTenatId,
@QueryParam("sort") String sort);
@GET
@Produces({ MediaType.APPLICATION_JSON })
public ResultList<Job> queryJobs(
@QueryParam("processInstanceId") String processInstanceId,
@QueryParam("executionId") String executionId,
@QueryParam("processDefinitionId") String processDefinitionId,
@QueryParam("withRetriesLeft") Boolean withRetriesLeft,
@QueryParam("executable") Boolean executable,
@QueryParam("withException") Boolean withException,
@QueryParam("dueBefore") LocalDate dueBefore,
@QueryParam("dueAfter") LocalDate dueAfter,
@QueryParam("exceptionMessage") String exceptionMessage,
@QueryParam("tenantId") String tenantId,
@QueryParam("tenantIdLike") String tenantIdLike,
@QueryParam("sort") String sort);
@GET
@Produces({ MediaType.APPLICATION_JSON })
public ResultList<Job> queryJobs(
@QueryParam("id") String jobId,
@QueryParam("processInstanceId") String processInstanceId,
@QueryParam("executionId") String executionId,
@QueryParam("processDefinitionId") String processDefinitionId,
@QueryParam("withRetriesLeft") Boolean withRetriesLeft,
@QueryParam("executable") Boolean executable,
@QueryParam("withException") Boolean withException,
@QueryParam("dueBefore") LocalDate dueBefore,
@QueryParam("dueAfter") LocalDate dueAfter,
@QueryParam("exceptionMessage") String exceptionMessage,
@QueryParam("withoutTenantId") Boolean withoutTenatId,
@QueryParam("sort") String sort);
@GET
@Produces({ MediaType.APPLICATION_JSON })
public ResultList<Job> queryJobs(
@QueryParam("id") String jobId,
@QueryParam("processInstanceId") String processInstanceId,
@QueryParam("executionId") String executionId,
@QueryParam("processDefinitionId") String processDefinitionId,
@QueryParam("withRetriesLeft") Boolean withRetriesLeft,
@QueryParam("executable") Boolean executable,
@QueryParam("withException") Boolean withException,
@QueryParam("dueBefore") LocalDate dueBefore,
@QueryParam("dueAfter") LocalDate dueAfter,
@QueryParam("exceptionMessage") String exceptionMessage,
@QueryParam("tenantId") String tenantId,
@QueryParam("tenantIdLike") String tenantIdLike,
@QueryParam("sort") String sort);
}
}

View File

@ -0,0 +1,21 @@
/*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.inteligr8.activiti.api;
import javax.ws.rs.Path;
@Path("/api/management/timer-jobs")
public interface TimerJobsApi extends BaseJobsApi {
}

View File

@ -4,5 +4,15 @@ import com.fasterxml.jackson.annotation.JsonInclude;
@JsonInclude(JsonInclude.Include.NON_NULL)
public class Variable extends com.inteligr8.activiti.model.Variable {
/**
* No args constructor for use in serialization
*/
public Variable() {
}
public Variable(String name, String scope, String type, Object value) {
super(name, scope, type, value);
}
}