ReadFactory.java 3.2 KB
Newer Older
R
roo00 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
package com.x.processplatform.service.processing.factory;

import java.util.List;

import javax.persistence.EntityManager;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;

import com.x.processplatform.core.entity.content.Read;
import com.x.processplatform.core.entity.content.Read_;
import com.x.processplatform.service.processing.AbstractFactory;
import com.x.processplatform.service.processing.Business;

public class ReadFactory extends AbstractFactory {

	public ReadFactory(Business business) throws Exception {
		super(business);
	}

	public List<String> listWithWork(String id) throws Exception {
		EntityManager em = this.entityManagerContainer().get(Read.class);
		CriteriaBuilder cb = em.getCriteriaBuilder();
		CriteriaQuery<String> cq = cb.createQuery(String.class);
		Root<Read> root = cq.from(Read.class);
		Predicate p = cb.equal(root.get(Read_.work), id);
		cq.select(root.get(Read_.id)).where(p);
		return em.createQuery(cq).getResultList();
	}

Z
zhourui 已提交
32 33 34 35 36 37 38 39 40
//	public List<String> listWithJob(String job) throws Exception {
//		EntityManager em = this.entityManagerContainer().get(Read.class);
//		CriteriaBuilder cb = em.getCriteriaBuilder();
//		CriteriaQuery<String> cq = cb.createQuery(String.class);
//		Root<Read> root = cq.from(Read.class);
//		Predicate p = cb.equal(root.get(Read_.job), job);
//		cq.select(root.get(Read_.id)).where(p);
//		return em.createQuery(cq).getResultList();
//	}
R
roo00 已提交
41

Z
zhourui 已提交
42 43 44 45 46 47 48 49 50 51 52
//	public List<String> listWithPersonWithWork(String person, String work) throws Exception {
//		EntityManager em = this.entityManagerContainer().get(Read.class);
//		CriteriaBuilder cb = em.getCriteriaBuilder();
//		CriteriaQuery<String> cq = cb.createQuery(String.class);
//		Root<Read> root = cq.from(Read.class);
//		Predicate p = cb.equal(root.get(Read_.person), person);
//		p = cb.and(p, cb.equal(root.get(Read_.completed), false));
//		p = cb.and(p, cb.equal(root.get(Read_.work), work));
//		cq.select(root.get(Read_.id)).where(p);
//		return em.createQuery(cq).getResultList();
//	}
R
roo00 已提交
53

Z
zhourui 已提交
54 55 56 57 58 59 60 61 62 63 64
//	public List<String> listWithPersonWithWorkCompleted(String person, String workCompleted) throws Exception {
//		EntityManager em = this.entityManagerContainer().get(Read.class);
//		CriteriaBuilder cb = em.getCriteriaBuilder();
//		CriteriaQuery<String> cq = cb.createQuery(String.class);
//		Root<Read> root = cq.from(Read.class);
//		Predicate p = cb.equal(root.get(Read_.person), person);
//		p = cb.and(p, cb.equal(root.get(Read_.completed), true));
//		p = cb.and(p, cb.equal(root.get(Read_.workCompleted), workCompleted));
//		cq.select(root.get(Read_.id)).where(p);
//		return em.createQuery(cq).getResultList();
//	}
R
roo00 已提交
65

Z
zhourui 已提交
66 67 68 69 70 71 72 73 74
//	public List<String> listWithActivityToken(String activityToken) throws Exception {
//		EntityManager em = this.entityManagerContainer().get(Read.class);
//		CriteriaBuilder cb = em.getCriteriaBuilder();
//		CriteriaQuery<String> cq = cb.createQuery(String.class);
//		Root<Read> root = cq.from(Read.class);
//		Predicate p = cb.equal(root.get(Read_.activityToken), activityToken);
//		cq.select(root.get(Read_.id)).where(p);
//		return em.createQuery(cq).getResultList();
//	}
R
roo00 已提交
75
}