田源
2024-03-07 4b4083fd73dc27ece42f4835483565eef0e4f608
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
package com.vci.server.workflow.server.instance;
 
import java.util.List;
 
import org.hibernate.HibernateException;
 
import com.vci.common.objects.UserEntity;
import com.vci.server.base.persistence.dao.BaseService;
import com.vci.server.base.persistence.dao.HibernateCallback;
import com.vci.server.base.persistence.dao.HibernateTemplate;
import com.vci.server.workflow.dao.FlowInstanceDaoImpl;
import com.vci.server.workflow.dao.ProcessCategoryDaoImpl;
import com.vci.server.workflow.objects.FlowInstance;
import com.vci.server.workflow.objects.ProcessCategory;
 
public class FlowInstanceService extends BaseService {
 
    public FlowInstanceService(UserEntity userEntity) {
        super(userEntity);
    }
 
    public FlowInstanceService() {
    }
 
    @SuppressWarnings("unchecked")
    public List<FlowInstance> getFlowInstances(final String applicant) {
        return (List<FlowInstance>)new HibernateTemplate().run(new HibernateCallback(){
            public Object execute() throws HibernateException {
                FlowInstanceDaoImpl impl = new FlowInstanceDaoImpl();
                String hql = "from FlowInstance t where t.applicant = ?";
                return impl.createQueryList(hql, new Object[]{applicant});
            }
        });
    }
 
    //
    @SuppressWarnings("unchecked")
    public List<FlowInstance> getFlowInstancesname(final String name) {
        return (List<FlowInstance>)new HibernateTemplate().run(new HibernateCallback(){
            public Object execute() throws HibernateException {
                FlowInstanceDaoImpl impl = new FlowInstanceDaoImpl();
                String hql = "from FlowInstance t where t.processName = ?";
                return impl.createQueryList(hql, new Object[]{name});
            }
        });
    }
    public boolean saveFlowInstance(final FlowInstance object) {
        return (Boolean)new HibernateTemplate().run(new HibernateCallback(){
            public Object execute() throws HibernateException {
                FlowInstanceDaoImpl impl = new FlowInstanceDaoImpl();
                object.setUserEntity(userEntity);
                impl.saveOrUpdate(object);
                return true;
            }
        });
    }
    
    public boolean updateFlowInstance(final FlowInstance object){
        return (Boolean)new HibernateTemplate().run(new HibernateCallback(){
            public Object execute() throws HibernateException {
                FlowInstanceDaoImpl impl = new FlowInstanceDaoImpl();
                object.setUserEntity(userEntity);
                FlowInstance objGet = impl.getById(object.getId());
                if(objGet == null){
                    impl.saveOrUpdate(object);
                }else{
                    objGet.setUserEntity(userEntity);
                    objGet.setId(object.getId());
                    objGet.setExecutionid(object.getExecutionid());
                    objGet.setApplicant(object.getApplicant());
                    objGet.setCreator(object.getCreator());
                    objGet.setTemplatePuid(object.getTemplatePuid());
                    objGet.setTemplateName(object.getTemplateName());
                    objGet.setClsfOid(object.getClsfOid());
                    objGet.setTableName(object.getTableName());
                    objGet.setDesc(object.getDesc());
                    objGet.setProcessType(object.getProcessType());
                    impl.saveOrUpdate(objGet);
                }
                return true;
            }
        });
    }
 
}