[jBPM Users] - Re: Query on remaining task
by freak182
Hello,
Just wanted to share how I accomplished this query. although it is not, let say hibernate way or jbpm way, but it work.
|
| @SuppressWarnings("unchecked")
| public List<Task> findNextTasksByProcessInstance(final ProcessInstance process)
| {
| try {
| return (List<Task>) jbpmTemplate.execute(new JbpmCallback() {
|
| public Object doInJbpm(JbpmContext context)
| throws JbpmException {
|
| final long processDefId = process.getProcessDefinition().getId();
|
| final GraphSession sess = context.getGraphSession();
| final ProcessDefinition def = sess.getProcessDefinition(processDefId);
| final Map<String, Task> task = def.getTaskMgmtDefinition().getTasks();
| final Set<String> taskSet = task.keySet();
|
| final Session session = context.getSession();
| final Query query = session.getNamedQuery("findNextTasksByProcessInstance");
| query.setEntity("processInstance", process);
| final List<String> taskInstance = query.list();
|
| return JbpmEngineUtils.getNextTasks(taskSet, taskInstance, task);
| }
| });
| } catch (Exception e) {
| throw new CCTIException("No task instance get", e);
| }
| }
|
then subtract the activeTask from possibletask:
| public static List<String> getNextTasks(Set<String> possibleTask,List<String> completedTask,Map<String,Task> task)
| {
| final List<String> nextTasks = new ArrayList<String>();
|
| final Set<String> tmpPossibleTask = new HashSet<String>(possibleTask);
| final List<String> tmpActiveTask = new ArrayList<String>(completedTask);
| final Map<String, Task> mapTask = new HashMap<String, Task>(task);
|
| for(String s : tmpActiveTask)
| {
| if ( tmpPossibleTask.contains(s) )
| {
| tmpPossibleTask.remove(s);
| }
| }
| Iterator<String> ite = tmpPossibleTask.iterator();
| while (ite.hasNext()) {
| final String string = ite.next();
| final Task taskLeft = mapTask.get(string);
| nextTasks.add(taskLeft.getDescription());
| }
| return nextTasks;
| }
|
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4251736#4251736
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4251736
16 years, 8 months
[JBoss Portal Users] - Re: VFSZIP problem ?
by blopes
The class I have on that jar is the same as before
...
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.WebApplicationException;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.SecurityContext;
import javax.ws.rs.core.UriInfo;
import javax.ws.rs.core.Response.ResponseBuilder;
import javax.ws.rs.core.Response.Status;
import org.codehaus.jettison.json.JSONArray;
import org.codehaus.jettison.json.JSONException;
import org.codehaus.jettison.json.JSONObject;
import org.restlet.data.Form;
import org.restlet.representation.Representation;
import org.restlet.resource.ClientResource;
@Path("/users/")
public class UsersResourceImpl {
protected @Context
UriInfo uriInfo;
protected @Context SecurityContext securityContext;
//protected @Request Request;
protected UserManager userManager;
protected DivisionManager divisionManager;
protected LabManager labManager;
public UsersResourceImpl() {
userManager = (UserManager) BeanFactory.getInstance().getBean("userManager");
divisionManager = (DivisionManager)BeanFactory.getInstance().getBean("divisionManager");
labManager = (LabManager)BeanFactory.getInstance().getBean("labManager");
}
@GET
@Path("{userName}/")
@Produces("application/xml")
public User getUser(@PathParam("userName")
String userName) {
User user = userManager.getUser(userName);
if (null == user) {
ResponseBuilder builder = Response.status(Status.NOT_FOUND);
builder.type("text/html");
builder.entity("<h3>Order Not Found</h3>");
throw new WebApplicationException(builder.build());
}
return user;
}
@GET
@Produces("application/object")
@Path("/allusers")
public List getUsers() {
return userManager.getAllUsers();
}
...
}
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4251731#4251731
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4251731
16 years, 8 months
[JBoss Portal Users] - Re: VFSZIP problem ?
by blopes
I changed jersey servlet property on web.xml to
<servlet-name>JerseyAPI</servlet-name>
<servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>com.sun.jersey.config.property.resourceConfigClass</param-name>
<param-value>com.sun.jersey.api.core.PackagesResourceConfig</param-value>
</init-param>
<init-param>
<param-name>com.sun.jersey.config.property.packages</param-name>
<param-value>lib/WSSandBox.jar</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
even with this change I have the same problem:
10:34:55,553 INFO [ContextLoader] Root WebApplicationContext: initialization completed in 2121 ms
10:34:55,581 INFO [PackagesResourceConfig] Scanning for root resource and provider classes in the packages:
lib/WSSandBox.jar
10:34:55,705 INFO [WebApplicationImpl] Initiating Jersey application, version 'Jersey: 1.1.1-ea 07/14/2009 07:16 PM'
10:34:56,391 SEVERE [WebApplicationImpl] The ResourceConfig instance does not contain any root resource classes.
10:34:56,394 ERROR [[/jboss]] StandardWrapper.Throwable
com.sun.jersey.api.container.ContainerException: The ResourceConfig instance does not contain any root resource classes.
at com.sun.jersey.server.impl.application.WebApplicationImpl.processRootResources(WebApplicationImpl.java:773)
at com.sun.jersey.server.impl.application.WebApplicationImpl.initiate(WebApplicationImpl.java:645)
at com.sun.jersey.server.impl.application.WebApplicationImpl.initiate(WebApplicationImpl.java:419)
at com.sun.jersey.spi.container.servlet.ServletContainer.initiate(ServletContainer.java:377)
at com.sun.jersey.spi.container.servlet.ServletContainer$InternalWebComponent.initiate(ServletContainer.java:242)
Any ideias ?
Thanks Bruno
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4251728#4251728
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4251728
16 years, 8 months