Package org.jbpm.env.session.hibernate

Source Code of org.jbpm.env.session.hibernate.HibernatePvmDbSession

/*
* JBoss, Home of Professional Open Source
* Copyright 2005, JBoss Inc., and individual contributors as indicated
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* This 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 2.1 of
* the License, or (at your option) any later version.
*
* This software 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jbpm.env.session.hibernate;

import java.util.List;

import org.hibernate.Query;
import org.hibernate.Session;
import org.jbpm.env.session.Job;
import org.jbpm.env.session.PvmDbSession;
import org.jbpm.env.session.Timer;
import org.jbpm.pvm.Execution;
import org.jbpm.pvm.ProcessDefinition;

/**
* @author Tom Baeyens
*/
public class HibernatePvmDbSession extends HibernateDbSession implements PvmDbSession {

  public HibernatePvmDbSession() {
  }

  public HibernatePvmDbSession(Session session) {
    super(session);
  }

  public List<String> findProcessDefinitionNames() {
    return session.getNamedQuery("findProcessDefinitionNames").list();
  }

  public List<ProcessDefinition> findProcessDefinitions(String name) {
    Query query = session.getNamedQuery("findProcessDefinitionsByName");
    query.setString("name", name);
    return query.list();
  }

  public ProcessDefinition findProcessDefinition(String name, int version) {
    Query query = session.getNamedQuery("findProcessDefinitionByNameAndVersion");
    query.setString("name", name);
    query.setInteger("version", version);
    ProcessDefinition processDefinition = (ProcessDefinition) query.uniqueResult();
    return processDefinition;
  }

  public ProcessDefinition findProcessDefinition(String name) {
    Query query = session.getNamedQuery("findProcessDefinitionsByName");
    query.setString("name", name);
    query.setMaxResults(1);
    ProcessDefinition processDefinition = (ProcessDefinition) query.uniqueResult();
    return processDefinition;
  }

  public Timer findNextTimer() {
    Query query = session.getNamedQuery("findNextTimer");
    query.setMaxResults(1);
    Timer timer = (Timer) query.uniqueResult();
    return timer;
  }

  public List<Timer> findAllTimers() {
    Query query = session.getNamedQuery("findAllTimers");
    return query.list();
  }

  public Execution findExecution(String processDefinitionName, String key) {
    Query query = session.getNamedQuery("findExecutionByProcessDefinitionNameAndKey");
    query.setString("name", processDefinitionName);
    query.setString("key", key);
    query.setMaxResults(1);
    return (Execution) query.uniqueResult();
  }

  public List<Job> getJobs() {
    return session.getNamedQuery("findJobs").list();
  }
}
TOP

Related Classes of org.jbpm.env.session.hibernate.HibernatePvmDbSession

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.