ludc
2025-01-16 986aa62ed00bee39363bab41b4eeb8259d446efd
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
package com.vci.server.workflow.server.service;
 
import java.util.List;
 
import org.hibernate.HibernateException;
 
import com.vci.corba.common.VCIError;
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.PlwfinstancetemplateDaoImpl;
import com.vci.server.workflow.dao.PlwfpersonsetDaoImpl;
import com.vci.server.workflow.objects.Plwfinstancetemplate;
import com.vci.server.workflow.objects.Plwfpersonset;
 
public class PlwfinstancetemplateService extends BaseService{
    private static PlwfinstancetemplateService instance = null;
    
    private PlwfinstancetemplateService(){
        
    }
    
    public static PlwfinstancetemplateService getInstance(){
        if(instance == null){
            instance = new PlwfinstancetemplateService();
        }
        return instance;
    }
    
    //add
    public boolean savePlwfinstancetemplate(Plwfinstancetemplate obj) throws VCIError {
 
        try {
            PlwfinstancetemplateDaoImpl daoImpl = new PlwfinstancetemplateDaoImpl();
            daoImpl.saveOrUpdate(obj);
            return true;
        } catch(Exception e){
            e.printStackTrace();
            throw new VCIError("411116", new String[] {});
        }
    }
    //query
    public Plwfinstancetemplate getPlwfinstancetemplateById(String plOId) throws Throwable {
        try {
            PlwfinstancetemplateDaoImpl daoImpl = new PlwfinstancetemplateDaoImpl();
            return daoImpl.getById(plOId);
        } catch(Throwable e){
            throw e;
        }
        
    }
    
    //query by plclass and plisdefault
    @SuppressWarnings("unchecked")
    public List<Plwfinstancetemplate> getPlwfinstancetemplateByClassAndDefault(String plclass, String plisdefault) throws VCIError {
        try {
            PlwfinstancetemplateDaoImpl daoImpl = new PlwfinstancetemplateDaoImpl();
            String hql = "from Plwfinstancetemplate where plclass= ?";
            Object[] obj = new Object[]{plclass};
            if (!"".equals(plisdefault)) {
                hql = "from Plwfinstancetemplate where plclass= ? and plisdefault= ?";
                obj = new Object[]{plclass, plisdefault};
            }
            return daoImpl.createQueryList(hql, obj);
        } catch(Exception e){
            e.printStackTrace();
            throw new VCIError("411117", new String[] {});
        }
        
    }
    
    public List<Plwfinstancetemplate> getPlwfinstancetemplate() throws VCIError {
        try {
            PlwfinstancetemplateDaoImpl daoImpl = new PlwfinstancetemplateDaoImpl();
            return daoImpl.loadAll();
        } catch(Exception e){
            e.printStackTrace();
            throw new VCIError("411117", new String[] {});
        }
    }
    
    @SuppressWarnings("unchecked")
    public List<Plwfpersonset> getPlwfpersonset(final String name) {
        return (List<Plwfpersonset>)new HibernateTemplate().run(new HibernateCallback(){
            public Object execute() throws HibernateException {
                PlwfpersonsetDaoImpl daoImpl = new PlwfpersonsetDaoImpl();
                String hql = "from Plwfpersonset where pltempid= ?";
                return daoImpl.createQueryList(hql, new Object[]{name});
            }
        });
    }
 
    //del
    public boolean deletePlwfinstancetemplate(Plwfinstancetemplate obj) throws VCIError{
        try {
            PlwfinstancetemplateDaoImpl daoImpl = new PlwfinstancetemplateDaoImpl();
//            String hql ="from Plwfpersonset where pltempid='"+obj.getPloid()+"' ";
            List<Plwfpersonset> list = getPlwfpersonset(obj.getPloid());
            PlwfpersonsetDaoImpl pdaoImpl = new PlwfpersonsetDaoImpl();
            for (Plwfpersonset plwfpersonset : list) {
                String sql = "delete from Plwfpersonset t where t.ploid = '" + plwfpersonset.getPloid() + "'";
                pdaoImpl.createSQLQuery(sql);
            }
            daoImpl.delete(obj);
            return true;
        } catch(Exception e){
            e.printStackTrace();
            throw new VCIError("411118", new String[] {});
        }
        
    }
    
    //del by id
//    public boolean deletePlwfinstancetemplateById(String id) throws Throwable{
//        try {
//            PlwfinstancetemplateDaoImpl daoImpl = new PlwfinstancetemplateDaoImpl();
//            Plwfinstancetemplate obj = daoImpl.getById(id);
//            if (obj != null) {
//                daoImpl.delete(obj);
//            }
//            return true;
//        } catch(Throwable e){
//            throw e;
//        }
//        
//    }
}