提交 10b39f2e 编写于 作者: F frederikheremans

ACT-238 extracting common methods to Query interface

上级 f21d7910
......@@ -13,10 +13,8 @@
package org.activiti.engine.history;
import java.util.List;
import org.activiti.engine.ActivitiException;
import org.activiti.engine.impl.HistoricActivityInstanceQueryImpl;
import org.activiti.engine.impl.Query;
/**
......@@ -24,7 +22,7 @@ import org.activiti.engine.impl.HistoricActivityInstanceQueryImpl;
*
* @author Tom Baeyens
*/
public interface HistoricActivityInstanceQuery {
public interface HistoricActivityInstanceQuery extends Query<HistoricActivityInstanceQuery, HistoricActivityInstance>{
/** Only select historic activity instances with the given process instance.
* {@link ProcessInstance) ids and {@link HistoricProcessInstance} ids match. */
......@@ -73,30 +71,4 @@ public interface HistoricActivityInstanceQuery {
/** Order by processInstanceId (needs to be followed by {@link #asc()} or {@link #desc()}). */
HistoricActivityInstanceQuery orderByProcessInstanceId();
/** Order by the given property (needs to be followed by {@link #asc()} or {@link #desc()}). */
HistoricActivityInstanceQuery orderBy(HistoricActivityInstanceQueryProperty property);
/** Order the results ascending on the given property as
* defined in this class (needs to come after a call to one of the orderByXxxx methods). */
HistoricActivityInstanceQuery asc();
/** Order the results descending on the given property as
* defined in this class (needs to come after a call to one of the orderByXxxx methods). */
HistoricActivityInstanceQuery desc();
/** Executes the query and get a list of {@link HistoricProcessInstance}s as the result. */
List<HistoricActivityInstance> list();
/** Executes the query and get a page of {@link HistoricProcessInstance}s as the result. */
List<HistoricActivityInstance> listPage(int firstResult, int maxResults);
/** Executes the query and get the single expected result.
* @throws ActivitiException when the query results in more
* than one historic activity instance.
*/
HistoricActivityInstance singleResult();
/** Executes the query and get number of results. */
long count();
}
......@@ -16,13 +16,15 @@ package org.activiti.engine.history;
import java.util.HashMap;
import java.util.Map;
import org.activiti.engine.impl.QueryProperty;
/**
* Contains the possible properties which can be used in a {@link HistoricActivityInstanceQuery}.
*
* @author Tom Baeyens
*/
public class HistoricActivityInstanceQueryProperty {
public class HistoricActivityInstanceQueryProperty implements QueryProperty {
private static final Map<String, HistoricActivityInstanceQueryProperty> properties = new HashMap<String, HistoricActivityInstanceQueryProperty>();
......
......@@ -13,9 +13,7 @@
package org.activiti.engine.history;
import java.util.List;
import org.activiti.engine.ActivitiException;
import org.activiti.engine.impl.Query;
......@@ -24,7 +22,7 @@ import org.activiti.engine.ActivitiException;
* @author Tom Baeyens
* @author Joram Barrez
*/
public interface HistoricProcessInstanceQuery {
public interface HistoricProcessInstanceQuery extends Query<HistoricProcessInstanceQuery, HistoricProcessInstance>{
/** Only select historic process instances with the given process instance.
* {@link ProcessInstance) ids and {@link HistoricProcessInstance} ids match. */
......@@ -59,30 +57,4 @@ public interface HistoricProcessInstanceQuery {
/** Order by the duration of the process instance (needs to be followed by {@link #asc()} or {@link #desc()}). */
HistoricProcessInstanceQuery orderByDuration();
/** Order by the given property */
HistoricProcessInstanceQuery orderBy(HistoricProcessInstanceQueryProperty property);
/** Order the results descending on the given property as
* defined in this class (needs to come after a call to one of the orderByXxxx methods). */
HistoricProcessInstanceQuery desc();
/** Order the results descending on the given property as
* defined in this class (needs to come after a call to one of the orderByXxxx methods). */
HistoricProcessInstanceQuery asc();
/** Executes the query and get a list of {@link HistoricProcessInstance}s as the result. */
List<HistoricProcessInstance> list();
/** Executes the query and get a page of {@link HistoricProcessInstance}s as the result. */
List<HistoricProcessInstance> listPage(int firstResult, int maxResults);
/** Executes the query and get the single expected result.
* @throws ActivitiException when the query results in more
* than one historic process instance.
*/
HistoricProcessInstance singleResult();
/** Executes the query and get number of results. */
long count();
}
......@@ -16,11 +16,13 @@ package org.activiti.engine.history;
import java.util.HashMap;
import java.util.Map;
import org.activiti.engine.impl.QueryProperty;
/**
* @author Joram Barrez
*/
public class HistoricProcessInstanceQueryProperty {
public class HistoricProcessInstanceQueryProperty implements QueryProperty {
private static final Map<String, HistoricProcessInstanceQueryProperty> properties = new HashMap<String, HistoricProcessInstanceQueryProperty>();
......
......@@ -13,9 +13,7 @@
package org.activiti.engine.identity;
import java.util.List;
import org.activiti.engine.ActivitiException;
import org.activiti.engine.impl.Query;
/**
......@@ -23,7 +21,7 @@ import org.activiti.engine.ActivitiException;
*
* @author Joram Barrez
*/
public interface GroupQuery {
public interface GroupQuery extends Query<GroupQuery, Group> {
/** Only select {@link Group}s with the given id. */
GroupQuery id(String id);
......@@ -52,33 +50,4 @@ public interface GroupQuery {
/** Order by group type (needs to be followed by {@link #asc()} or {@link #desc()}). */
GroupQuery orderByType();
/** Order by the given property (needs to be followed by {@link #asc()} or {@link #desc()}). */
GroupQuery orderBy(GroupQueryProperty property);
/** Order the results ascending on the given property as
* defined in this class (needs to come after a call to one of the orderByXxxx methods). */
GroupQuery asc();
/** Order the results descending on the given property as
* defined in this class (needs to come after a call to one of the orderByXxxx methods). */
GroupQuery desc();
//results ////////////////////////////////////////////////////////
/** Executes the query and counts number of {@link Group}s in the result. */
long count();
/**
* Executes the query and returns the {@link Group}.
* @throws ActivitiException when the query results in more
* than one {@link Group}.
*/
Group singleResult();
/** Executes the query and get a list of {@link Group}s as the result. */
List<Group> list();
/** Executes the query and get a list of {@link Group}s as the result. */
List<Group> listPage(int firstResult, int maxResults);
}
......@@ -16,6 +16,8 @@ package org.activiti.engine.identity;
import java.util.HashMap;
import java.util.Map;
import org.activiti.engine.impl.QueryProperty;
/**
......@@ -23,7 +25,7 @@ import java.util.Map;
*
* @author Joram Barrez
*/
public class GroupQueryProperty {
public class GroupQueryProperty implements QueryProperty {
private static final Map<String, GroupQueryProperty> properties = new HashMap<String, GroupQueryProperty>();
......
......@@ -13,9 +13,7 @@
package org.activiti.engine.identity;
import java.util.List;
import org.activiti.engine.ActivitiException;
import org.activiti.engine.impl.Query;
/**
......@@ -23,7 +21,7 @@ import org.activiti.engine.ActivitiException;
*
* @author Joram Barrez
*/
public interface UserQuery {
public interface UserQuery extends Query<UserQuery, User> {
/** Only select {@link User}s with the given id/ */
UserQuery id(String id);
......@@ -68,34 +66,4 @@ public interface UserQuery {
/** Order by user email (needs to be followed by {@link #asc()} or {@link #desc()}). */
UserQuery orderByEmail();
/** Order by the given property (needs to be followed by {@link #asc()} or {@link #desc()}). */
UserQuery orderBy(UserQueryProperty property);
/** Order the results ascending on the given property as
* defined in this class (needs to come after a call to one of the orderByXxxx methods). */
UserQuery asc();
/** Order the results descending on the given property as
* defined in this class (needs to come after a call to one of the orderByXxxx methods). */
UserQuery desc();
//results ////////////////////////////////////////////////////////
/** Executes the query and counts number of {@link User}s in the result. */
long count();
/**
* Executes the query and returns the {@link User}.
* @throws ActivitiException when the query results in more
* than one {@link User}.
*/
User singleResult();
/** Executes the query and get a list of {@link User}s as the result. */
List<User> list();
/** Executes the query and get a list of {@link User}s as the result. */
List<User> listPage(int firstResult, int maxResults);
}
......@@ -16,6 +16,8 @@ package org.activiti.engine.identity;
import java.util.HashMap;
import java.util.Map;
import org.activiti.engine.impl.QueryProperty;
/**
......@@ -23,7 +25,7 @@ import java.util.Map;
*
* @author Joram Barrez
*/
public class UserQueryProperty {
public class UserQueryProperty implements QueryProperty {
private static final Map<String, UserQueryProperty> properties = new HashMap<String, UserQueryProperty>();
......
......@@ -25,7 +25,7 @@ import org.activiti.engine.impl.interceptor.CommandExecutor;
*
* @author Joram Barrez
*/
public abstract class AbstractQuery<T> implements Command<Object>{
public abstract class AbstractQuery<T extends Query<?,?>, U> implements Command<Object>, Query<T,U>{
public static final String SORTORDER_ASC = "asc";
public static final String SORTORDER_DESC = "desc";
......@@ -49,23 +49,23 @@ public abstract class AbstractQuery<T> implements Command<Object>{
}
@SuppressWarnings("unchecked")
public T singleResult() {
public U singleResult() {
this.resultType = ResultType.SINGLE_RESULT;
return (T) commandExecutor.execute(this);
return (U) commandExecutor.execute(this);
}
@SuppressWarnings("unchecked")
public List<T> list() {
public List<U> list() {
this.resultType = ResultType.LIST;
return (List) commandExecutor.execute(this);
return (List<U>) commandExecutor.execute(this);
}
@SuppressWarnings("unchecked")
public List<T> listPage(int firstResult, int maxResults) {
public List<U> listPage(int firstResult, int maxResults) {
this.firstResult = firstResult;
this.maxResults = maxResults;
this.resultType = ResultType.LIST_PAGE;
return (List) commandExecutor.execute(this);
return (List<U>) commandExecutor.execute(this);
}
public long count() {
......@@ -91,10 +91,10 @@ public abstract class AbstractQuery<T> implements Command<Object>{
* Executes the actual query to retrieve the list of results.
* @param page used if the results must be paged. If null, no paging will be applied.
*/
public abstract List<T> executeList(CommandContext commandContext, Page page);
public abstract List<U> executeList(CommandContext commandContext, Page page);
public T executeSingleResult(CommandContext commandContext) {
List<T> results = executeList(commandContext, null);
public U executeSingleResult(CommandContext commandContext) {
List<U> results = executeList(commandContext, null);
if (results.size() == 1) {
return results.get(0);
} else if (results.size() > 1) {
......
......@@ -27,7 +27,7 @@ import org.activiti.engine.repository.DeploymentQueryProperty;
* @author Tom Baeyens
* @author Joram Barrez
*/
public class DeploymentQueryImpl extends AbstractQuery<Deployment> implements DeploymentQuery {
public class DeploymentQueryImpl extends AbstractQuery<DeploymentQuery, Deployment> implements DeploymentQuery {
protected String deploymentId;
protected String name;
......@@ -79,8 +79,11 @@ public class DeploymentQueryImpl extends AbstractQuery<Deployment> implements De
return orderBy(DeploymentQueryProperty.NAME);
}
public DeploymentQueryImpl orderBy(DeploymentQueryProperty property) {
this.orderProperty = property;
public DeploymentQueryImpl orderBy(QueryProperty property) {
if(!(property instanceof DeploymentQueryProperty)) {
throw new ActivitiException("Only DeploymentQueryProperty can be used with orderBy");
}
this.orderProperty = (DeploymentQueryProperty) property;
return this;
}
......
......@@ -26,7 +26,8 @@ import org.activiti.engine.runtime.ExecutionQueryProperty;
* @author Joram Barrez
* @author Frederik Heremans
*/
public class ExecutionQueryImpl extends ExecutionVariableQueryImpl<ExecutionQueryImpl, Execution> implements ExecutionQuery {
public class ExecutionQueryImpl extends ExecutionVariableQueryImpl<ExecutionQuery, Execution>
implements ExecutionQuery {
protected String processDefinitionId;
protected String processDefinitionKey;
......@@ -108,8 +109,11 @@ public class ExecutionQueryImpl extends ExecutionVariableQueryImpl<ExecutionQuer
return this;
}
public ExecutionQueryImpl orderBy(ExecutionQueryProperty property) {
this.orderProperty = property;
public ExecutionQueryImpl orderBy(QueryProperty property) {
if(!(property instanceof ExecutionQueryProperty)) {
throw new ActivitiException("Only ExecutionQueryProperty can be used with orderBy");
}
this.orderProperty = (ExecutionQueryProperty) property;
return this;
}
......
......@@ -28,7 +28,7 @@ import org.activiti.engine.impl.variable.VariableTypes;
*
* @author Frederik Heremans
*/
public abstract class ExecutionVariableQueryImpl<T, U> extends AbstractQuery<U> {
public abstract class ExecutionVariableQueryImpl<T extends Query<?,?>, U> extends AbstractQuery<T, U> {
protected List<QueryVariableValue> variables = new ArrayList<QueryVariableValue>();
......@@ -62,7 +62,7 @@ public abstract class ExecutionVariableQueryImpl<T, U> extends AbstractQuery<U>
public T variableValueGreaterThan(String name, Object value) {
addVariable(name, value, QueryOperator.GREATER_THAN);
return (T) this;
}
}
@SuppressWarnings("unchecked")
public T variableValueGreaterThanOrEqual(String name, Object value) {
......
......@@ -26,7 +26,7 @@ import org.activiti.engine.impl.interceptor.CommandExecutor;
/**
* @author Joram Barrez
*/
public class GroupQueryImpl extends AbstractQuery<Group> implements GroupQuery {
public class GroupQueryImpl extends AbstractQuery<GroupQuery, Group> implements GroupQuery {
protected String id;
protected String name;
......@@ -97,8 +97,11 @@ public class GroupQueryImpl extends AbstractQuery<Group> implements GroupQuery {
return orderBy(GroupQueryProperty.TYPE);
}
public GroupQuery orderBy(GroupQueryProperty property) {
this.orderProperty = property;
public GroupQuery orderBy(QueryProperty property) {
if(!(property instanceof GroupQueryProperty)) {
throw new ActivitiException("Only GroupQueryProperty can be used with orderBy");
}
this.orderProperty = (GroupQueryProperty) property;
return this;
}
......
......@@ -26,7 +26,8 @@ import org.activiti.engine.impl.interceptor.CommandExecutor;
/**
* @author Tom Baeyens
*/
public class HistoricActivityInstanceQueryImpl extends AbstractQuery<HistoricActivityInstance> implements HistoricActivityInstanceQuery {
public class HistoricActivityInstanceQueryImpl extends AbstractQuery<HistoricActivityInstanceQuery, HistoricActivityInstance>
implements HistoricActivityInstanceQuery {
protected String processInstanceId;
protected String executionId;
......@@ -128,8 +129,11 @@ public class HistoricActivityInstanceQueryImpl extends AbstractQuery<HistoricAct
return this;
}
public HistoricActivityInstanceQueryImpl orderBy(HistoricActivityInstanceQueryProperty property) {
this.orderProperty = property;
public HistoricActivityInstanceQueryImpl orderBy(QueryProperty property) {
if(!(property instanceof HistoricActivityInstanceQueryProperty)) {
throw new ActivitiException("Only HistoricActivityInstanceQueryProperty can be used with orderBy");
}
this.orderProperty = (HistoricActivityInstanceQueryProperty) property;
return this;
}
......
......@@ -26,7 +26,8 @@ import org.activiti.engine.impl.interceptor.CommandExecutor;
/**
* @author Tom Baeyens
*/
public class HistoricProcessInstanceQueryImpl extends AbstractQuery<HistoricProcessInstance> implements HistoricProcessInstanceQuery {
public class HistoricProcessInstanceQueryImpl extends AbstractQuery<HistoricProcessInstanceQuery, HistoricProcessInstance>
implements HistoricProcessInstanceQuery {
protected String processInstanceId;
protected String processDefinitionId;
......@@ -107,8 +108,11 @@ public class HistoricProcessInstanceQueryImpl extends AbstractQuery<HistoricProc
return this;
}
public HistoricProcessInstanceQuery orderBy(HistoricProcessInstanceQueryProperty property) {
this.orderProperty = property;
public HistoricProcessInstanceQuery orderBy(QueryProperty property) {
if(!(property instanceof HistoricProcessInstanceQueryProperty)) {
throw new ActivitiException("Only HistoricProcessInstanceQueryProperty can be used with orderBy");
}
this.orderProperty = (HistoricProcessInstanceQueryProperty) property;
return this;
}
......
......@@ -20,16 +20,16 @@ import org.activiti.engine.ActivitiException;
import org.activiti.engine.impl.interceptor.CommandContext;
import org.activiti.engine.impl.interceptor.CommandExecutor;
import org.activiti.engine.impl.util.ClockUtil;
import org.activiti.engine.management.JobQueryProperty;
import org.activiti.engine.runtime.Job;
import org.activiti.engine.runtime.JobQuery;
import org.activiti.engine.runtime.JobQueryProperty;
/**
* @author Joram Barrez
* @author Tom Baeyens
*/
public class JobQueryImpl extends AbstractQuery<Job> implements JobQuery {
public class JobQueryImpl extends AbstractQuery<JobQuery, Job> implements JobQuery {
protected String id;
protected String processInstanceId;
......@@ -155,8 +155,11 @@ public class JobQueryImpl extends AbstractQuery<Job> implements JobQuery {
return orderBy(JobQueryProperty.RETRIES);
}
public JobQuery orderBy(JobQueryProperty property) {
this.orderProperty = property;
public JobQuery orderBy(QueryProperty property) {
if(!(property instanceof JobQueryProperty)) {
throw new ActivitiException("Only JobQueryProperty can be used with orderBy");
}
this.orderProperty = (JobQueryProperty) property;
return this;
}
......
......@@ -27,7 +27,8 @@ import org.activiti.engine.repository.ProcessDefinitionQueryProperty;
* @author Tom Baeyens
* @author Joram Barrez
*/
public class ProcessDefinitionQueryImpl extends AbstractQuery<ProcessDefinition> implements ProcessDefinitionQuery {
public class ProcessDefinitionQueryImpl extends AbstractQuery<ProcessDefinitionQuery, ProcessDefinition>
implements ProcessDefinitionQuery {
protected String id;
protected String name;
......@@ -124,8 +125,11 @@ public class ProcessDefinitionQueryImpl extends AbstractQuery<ProcessDefinition>
return orderBy(ProcessDefinitionQueryProperty.VERSION);
}
public ProcessDefinitionQuery orderBy(ProcessDefinitionQueryProperty property) {
this.orderProperty = property;
public ProcessDefinitionQuery orderBy(QueryProperty property) {
if(!(property instanceof ProcessDefinitionQueryProperty)) {
throw new ActivitiException("Only ProcessDefinitionQueryProperty can be used with orderBy");
}
this.orderProperty = (ProcessDefinitionQueryProperty) property;
return this;
}
......
......@@ -117,8 +117,11 @@ public class ProcessInstanceQueryImpl extends ExecutionVariableQueryImpl<Process
return this;
}
public ProcessInstanceQuery orderBy(ProcessInstanceQueryProperty property) {
this.orderProperty = property;
public ProcessInstanceQuery orderBy(QueryProperty property) {
if(!(property instanceof ProcessInstanceQueryProperty)) {
throw new ActivitiException("Only ProcessInstanceQueryProperty can be used with orderBy");
}
this.orderProperty = (ProcessInstanceQueryProperty) property;
return this;
}
......
/* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.activiti.engine.impl;
import java.util.List;
/**
* Describes basic methods for querying.
*
* @author Frederik Heremans
*/
public interface Query<T extends Query< ? , ? >, U extends Object> {
/**
* Order by the given property (needs to be followed by {@link #asc()} or
* {@link #desc()}).
*/
T orderBy(QueryProperty property);
/**
* Order the results ascending on the given property as defined in this
* class (needs to come after a call to one of the orderByXxxx methods).
*/
T asc();
/**
* Order the results descending on the given property as defined in this
* class (needs to come after a call to one of the orderByXxxx methods).
*/
T desc();
/** Executes the query and returns the number of results */
long count();
/**
* Executes the query and returns the resulting entity.
* @throws ActivitiException when the query results in more than one
* entities.. Ê
*/
U singleResult();
/** Executes the query and get a list of entities as the result. */
List<U> list();
/** Executes the query and get a list of entities as the result. */
List<U> listPage(int firstResult, int maxResults);
}
/* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.activiti.engine.impl;
/**
* Describes a property that can be used in a Query.
*
* @author Frederik Heremans
*/
public interface QueryProperty {
String getName();
}
......@@ -28,7 +28,7 @@ import org.activiti.engine.task.TaskQueryProperty;
* @author Joram Barrez
* @author Tom Baeyens
*/
public class TaskQueryImpl extends AbstractQuery<Task> implements TaskQuery {
public class TaskQueryImpl extends AbstractQuery<TaskQuery, Task> implements TaskQuery {
protected String taskId;
protected String name;
......@@ -192,8 +192,11 @@ public class TaskQueryImpl extends AbstractQuery<Task> implements TaskQuery {
return orderBy(TaskQueryProperty.ASSIGNEE);
}
public TaskQueryImpl orderBy(TaskQueryProperty property) {
this.orderProperty = property;
public TaskQueryImpl orderBy(QueryProperty property) {
if(!(property instanceof QueryProperty)) {
throw new ActivitiException("Only QueryProperty can be used with orderBy");
}
this.orderProperty = (TaskQueryProperty) property;
return this;
}
......
......@@ -26,7 +26,7 @@ import org.activiti.engine.impl.interceptor.CommandExecutor;
/**
* @author Joram Barrez
*/
public class UserQueryImpl extends AbstractQuery<User> implements UserQuery {
public class UserQueryImpl extends AbstractQuery<UserQuery, User> implements UserQuery {
protected String id;
protected String firstName;
......@@ -119,8 +119,11 @@ public class UserQueryImpl extends AbstractQuery<User> implements UserQuery {
return orderBy(UserQueryProperty.LAST_NAME);
}
public UserQuery orderBy(UserQueryProperty property) {
this.orderProperty = property;
public UserQuery orderBy(QueryProperty property) {
if(!(property instanceof UserQueryProperty)) {
throw new ActivitiException("Only UserQueryProperty can be used with orderBy");
}
this.orderProperty = (UserQueryProperty) property;
return this;
}
......
......@@ -13,10 +13,8 @@
package org.activiti.engine.repository;
import java.util.List;
import org.activiti.engine.ActivitiException;
import org.activiti.engine.RepositoryService;
import org.activiti.engine.impl.Query;
/**
* Allows programmatic querying of {@link Deployment}s.
......@@ -32,7 +30,7 @@ import org.activiti.engine.RepositoryService;
* @author Tom Baeyens
* @author Joram Barrez
*/
public interface DeploymentQuery {
public interface DeploymentQuery extends Query<DeploymentQuery, Deployment>{
/** Only select deployments with the given deployment id. */
DeploymentQuery deploymentId(String deploymentId);
......@@ -53,33 +51,4 @@ public interface DeploymentQuery {
/** Order by deployment time (needs to be followed by {@link #asc()} or {@link #desc()}). */
DeploymentQuery orderByDeploymenTime();
/** Order by the given property (needs to be followed by {@link #asc()} or {@link #desc()}). */
DeploymentQuery orderBy(DeploymentQueryProperty property);
/** Order the results ascending on the given property as
* defined in this class (needs to come after a call to one of the orderByXxxx methods). */
DeploymentQuery asc();
/** Order the results descending on the given property as
* defined in this class (needs to come after a call to one of the orderByXxxx methods). */
DeploymentQuery desc();
//results ////////////////////////////////////////////////////////
/** Executes the query and counts number of {@link Deployment}s in the result. */
long count();
/**
* Executes the query and returns the {@link Deployment}.
* @throws ActivitiException when the query results in more
* than one deployment.
*/
Deployment singleResult();
/** Executes the query and get a list of {@link Deployment}s as the result. */
List<Deployment> list();
/** Executes the query and get a list of {@link Deployment}s as the result. */
List<Deployment> listPage(int firstResult, int maxResults);
}
......@@ -29,6 +29,8 @@ package org.activiti.engine.repository;
import java.util.HashMap;
import java.util.Map;
import org.activiti.engine.impl.QueryProperty;
/**
......@@ -36,7 +38,7 @@ import java.util.Map;
*
* @author Joram Barrez
*/
public class DeploymentQueryProperty {
public class DeploymentQueryProperty implements QueryProperty {
private static final Map<String, DeploymentQueryProperty> properties = new HashMap<String, DeploymentQueryProperty>();
......
......@@ -16,6 +16,7 @@ package org.activiti.engine.repository;
import java.util.List;
import org.activiti.engine.ActivitiException;
import org.activiti.engine.impl.Query;
/**
* Allows programmatic querying of {@link ProcessDefinition}s.
......@@ -23,7 +24,7 @@ import org.activiti.engine.ActivitiException;
* @author Tom Baeyens
* @author Joram Barrez
*/
public interface ProcessDefinitionQuery {
public interface ProcessDefinitionQuery extends Query<ProcessDefinitionQuery, ProcessDefinition> {
/** Only select process definiton with the given id. */
ProcessDefinitionQuery id(String processDefinitionId);
......@@ -86,40 +87,4 @@ public interface ProcessDefinitionQuery {
/** Order by process definition version (needs to be followed by {@link #asc()} or {@link #desc()}). */
ProcessDefinitionQuery orderByVersion();
/** Order by the given property (needs to be followed by {@link #asc()} or {@link #desc()}). */
ProcessDefinitionQuery orderBy(ProcessDefinitionQueryProperty property);
/** Order the results ascending on the given property as
* defined in this class (needs to come after a call to one of the orderByXxxx methods). */
ProcessDefinitionQuery asc();
/** Order the results descending on the given property as
* defined in this class (needs to come after a call to one of the orderByXxxx methods). */
ProcessDefinitionQuery desc();
// results ////////////////////////////////////////////////////////////
/**
* Executes the query and counts number of {@link ProcessDefinition}s in the result.
*/
long count();
/**
* Executes the query and returns the {@link ProcessDefinition}.
*
* @throws ActivitiException
* when the query results in more than one process definition.
*/
ProcessDefinition singleResult();
/**
* Executes the query and get a list of {@link ProcessDefinition}s as the result.
*/
List<ProcessDefinition> list();
/**
* Executes the query and get a list of {@link ProcessDefinition}s as the result.
*/
List<ProcessDefinition> listPage(int firstResult, int maxResults);
}
......@@ -16,13 +16,15 @@ package org.activiti.engine.repository;
import java.util.HashMap;
import java.util.Map;
import org.activiti.engine.impl.QueryProperty;
/**
* Contains the possible properties that can be used in a {@link ProcessDefinitionQuery}.
*
* @author Joram Barrez
*/
public class ProcessDefinitionQueryProperty {
public class ProcessDefinitionQueryProperty implements QueryProperty {
private static final Map<String, ProcessDefinitionQueryProperty> properties = new HashMap<String, ProcessDefinitionQueryProperty>();
......
......@@ -13,9 +13,8 @@
package org.activiti.engine.runtime;
import java.io.Serializable;
import java.util.List;
import org.activiti.engine.ActivitiException;
import org.activiti.engine.impl.Query;
import org.activiti.engine.impl.cfg.ProcessEngineConfiguration;
......@@ -25,7 +24,7 @@ import org.activiti.engine.impl.cfg.ProcessEngineConfiguration;
* @author Joram Barrez
* @author Frederik Heremans
*/
public interface ExecutionQuery {
public interface ExecutionQuery extends Query<ExecutionQuery, Execution>{
/** Only select executions which have the given process definition key. **/
ExecutionQuery processDefinitionKey(String processDefinitionKey);
......@@ -119,35 +118,4 @@ public interface ExecutionQuery {
/** Order by process definition id (needs to be followed by {@link #asc()} or {@link #desc()}). */
ExecutionQuery orderByProcessDefinitionId();
/** Order by the given property (needs to be followed by {@link #asc()} or {@link #desc()}). */
ExecutionQuery orderBy(ExecutionQueryProperty property);
/** Order the results ascending on the given property as
* defined in this class (needs to come after a call to one of the orderByXxxx methods). */
ExecutionQuery asc();
/** Order the results descending on the given property as
* defined in this class (needs to come after a call to one of the orderByXxxx methods). */
ExecutionQuery desc();
//results //////////////////////////////////////////////////////////////
/** Executes the query and get a list of {@link Execution}s as the result. */
List<Execution> list();
/** Executes the query and get a list of {@link Execution}s as the result. */
List<Execution> listPage(int firstResult, int maxResults);
/**
* Executes the query and returns the {@link Execution}.
* @throws ActivitiException when the query results in more
* than one execution.
*/
Execution singleResult();
/** Executes the query and gets the number of result */
long count();
}
......@@ -16,12 +16,14 @@ package org.activiti.engine.runtime;
import java.util.HashMap;
import java.util.Map;
import org.activiti.engine.impl.QueryProperty;
/**
* Contains the possible properties that can be used in a {@link ExecutionQueryt}.
*
* @author Joram Barrez
*/
public class ExecutionQueryProperty {
public class ExecutionQueryProperty implements QueryProperty {
private static final Map<String, ExecutionQueryProperty> properties = new HashMap<String, ExecutionQueryProperty>();
......
......@@ -14,10 +14,8 @@
package org.activiti.engine.runtime;
import java.util.Date;
import java.util.List;
import org.activiti.engine.ActivitiException;
import org.activiti.engine.management.JobQueryProperty;
import org.activiti.engine.impl.Query;
/**
......@@ -25,7 +23,7 @@ import org.activiti.engine.management.JobQueryProperty;
*
* @author Joram Barrez
*/
public interface JobQuery {
public interface JobQuery extends Query<JobQuery, Job> {
/** Only select jobs with the given id */
JobQuery id(String jobId);
......@@ -79,34 +77,4 @@ public interface JobQuery {
/** Order by retries (needs to be followed by {@link #asc()} or {@link #desc()}). */
JobQuery orderByRetries();
/** Order by the given property (needs to be followed by {@link #asc()} or {@link #desc()}). */
JobQuery orderBy(JobQueryProperty property);
/** Order the results ascending on the given property as
* defined in this class (needs to come after a call to one of the orderByXxxx methods). */
JobQuery asc();
/** Order the results descending on the given property as
* defined in this class (needs to come after a call to one of the orderByXxxx methods). */
JobQuery desc();
//results //////////////////////////////////////////
/** Executes the query and returns the number of results */
long count();
/**
* Executes the query and returns the {@link Job}.
* @throws ActivitiException when the query results in more
* than one job.
*/
Job singleResult();
/** Executes the query and get a list of {@link Job}s as the result. */
List<Job> list();
/** Executes the query and get a list of {@link Job}s as the result. */
List<Job> listPage(int firstResult, int maxResults);
}
......@@ -11,19 +11,19 @@
* limitations under the License.
*/
package org.activiti.engine.management;
package org.activiti.engine.runtime;
import java.util.HashMap;
import java.util.Map;
import org.activiti.engine.runtime.JobQuery;
import org.activiti.engine.impl.QueryProperty;
/**
* Contains the possible properties that can be used in a {@link JobQuery}.
*
* @author Joram Barrez
*/
public class JobQueryProperty {
public class JobQueryProperty implements QueryProperty {
private static final Map<String, JobQueryProperty> properties = new HashMap<String, JobQueryProperty>();
......
......@@ -13,9 +13,8 @@
package org.activiti.engine.runtime;
import java.io.Serializable;
import java.util.List;
import org.activiti.engine.ActivitiException;
import org.activiti.engine.impl.Query;
import org.activiti.engine.impl.cfg.ProcessEngineConfiguration;
/**
......@@ -24,7 +23,7 @@ import org.activiti.engine.impl.cfg.ProcessEngineConfiguration;
* @author Joram Barrez
* @author Frederik Heremans
*/
public interface ProcessInstanceQuery {
public interface ProcessInstanceQuery extends Query<ProcessInstanceQuery, ProcessInstance> {
/** Select the process instance with the given id */
ProcessInstanceQuery processInstanceId(String processInstanceId);
......@@ -138,40 +137,4 @@ public interface ProcessInstanceQuery {
/** Order by process definition id (needs to be followed by {@link #asc()} or {@link #desc()}). */
ProcessInstanceQuery orderByProcessDefinitionId();
/** Order by the given property (needs to be followed by {@link #asc()} or {@link #desc()}). */
ProcessInstanceQuery orderBy(ProcessInstanceQueryProperty property);
/** Order the results ascending on the given property as
* defined in this class (needs to come after a call to one of the orderByXxxx methods). */
ProcessInstanceQuery asc();
/** Order the results descending on the given property as
* defined in this class (needs to come after a call to one of the orderByXxxx methods). */
ProcessInstanceQuery desc();
//results /////////////////////////////////////////////////////////////////
/**
* Executes the query and get a list of {@link ProcessInstance}s as the
* result.
*/
List<ProcessInstance> list();
/**
* Executes the query and get a list of {@link ProcessInstance}s as the
* result.
*/
List<ProcessInstance> listPage(int firstResult, int maxResults);
/**
* Executes the query and returns the {@link ProcessInstance}.
*
* @throws ActivitiException
* when the query results in more than one process instance.
*/
ProcessInstance singleResult();
/** Executes the query and returns the number of results */
long count();
}
......@@ -16,13 +16,15 @@ package org.activiti.engine.runtime;
import java.util.HashMap;
import java.util.Map;
import org.activiti.engine.impl.QueryProperty;
/**
* Contains the possible properties that can be used in a {@link ProcessInstanceQuery}.
*
* @author Joram Barrez
*/
public class ProcessInstanceQueryProperty {
public class ProcessInstanceQueryProperty implements QueryProperty {
private static final Map<String, ProcessInstanceQueryProperty> properties = new HashMap<String, ProcessInstanceQueryProperty>();
......
......@@ -12,16 +12,14 @@
*/
package org.activiti.engine.task;
import java.util.List;
import org.activiti.engine.ActivitiException;
import org.activiti.engine.impl.Query;
/**
* Allows programmatic querying of {@link Task}s;
*
* @author Joram Barrez
*/
public interface TaskQuery {
public interface TaskQuery extends Query<TaskQuery, Task>{
/**
* Only select tasks with the given task id (in practice, there will be
......@@ -86,35 +84,5 @@ public interface TaskQuery {
/** Order by execution id (needs to be followed by {@link #asc()} or {@link #desc()}). */
TaskQuery orderByExecutionId();
/** Order by the given property (needs to be followed by {@link #asc()} or {@link #desc()}). */
TaskQuery orderBy(TaskQueryProperty property);
/** Order the results ascending on the given property as
* defined in this class (needs to come after a call to one of the orderByXxxx methods). */
TaskQuery asc();
/** Order the results descending on the given property as
* defined in this class (needs to come after a call to one of the orderByXxxx methods). */
TaskQuery desc();
// results ////////////////////////////////////////////////////////////
/** Execute the query and return the number of results. */
long count();
/**
* Executes the query and returns the {@link Task}.
*
* @throws ActivitiException
* when the query results in more than one process definition.
*/
Task singleResult();
/** Executes the query and get a list of {@link Task}s as the result. */
List<Task> list();
/** Executes the query and get a list of {@link Task}s as the result. */
List<Task> listPage(int firstResult, int maxResults);
}
......@@ -29,6 +29,8 @@ package org.activiti.engine.task;
import java.util.HashMap;
import java.util.Map;
import org.activiti.engine.impl.QueryProperty;
/**
......@@ -36,7 +38,7 @@ import java.util.Map;
*
* @author Joram Barrez
*/
public class TaskQueryProperty {
public class TaskQueryProperty implements QueryProperty {
private static final Map<String, TaskQueryProperty> properties = new HashMap<String, TaskQueryProperty>();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册