Subversion Repository Public Repository

Aurocare_27_07_2018

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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.bestray.healthcareemr.ServiceImpl;

import com.bestray.healthcarecommonutil.exception.DataAccessException;
import com.bestray.healthcarecommonutil.exception.HealthCareException;
import com.bestray.healthcarecommonutil.exception.ProcessingException;
import com.bestray.healthcarecommonutil.vo.TAccDeptRole;
import com.bestray.healthcarecommonutil.vo.TAccount;
import com.bestray.healthcarecommonutil.vo.TAccountDepartment;
import com.bestray.healthcarecommonutil.vo.TAccountRole;
import com.bestray.healthcarecommonutil.vo.TDepartmentMaster;
import com.bestray.healthcarecommonutil.vo.TRole;
import com.bestray.healthcareemr.Dao.UserAccountDeptDao;
import com.bestray.healthcareemr.Dao.UserAccountRoleDao;
import com.bestray.healthcareemr.Dao.UserAccountDao;
import com.bestray.healthcareemr.Service.UserAccountDeptRoleService;
import com.bestray.healthcareemr.Service.UserAccountRoleService;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.DefaultListModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.orm.hibernate3.HibernateOptimisticLockingFailureException;
import org.springframework.stereotype.Service;

/**
 *
 * @author user3
 */
@Service
public class UserAccountRoleServiceImpl implements UserAccountRoleService{
    
    @Autowired
    private UserAccountRoleDao userAccountRoleDao;
    @Autowired
    private UserAccountDeptDao userAccountDeptDao;
    @Autowired
    private UserAccountDao userAccountDao;
    @Autowired
    private UserAccountDeptRoleService userAccountDeptRoleService;
    
    private TAccount acc;

    
    /*public UserAccountRoleServiceImpl(UserAccountRoleDao userAccountRoleDao,UserAccountDeptDao userAccountDeptDao,
            UserAccountDao userAccountDao) {
        this.userAccountRoleDao = userAccountRoleDao;
        this.userAccountDeptDao = userAccountDeptDao;
        this.userAccountDao = userAccountDao;
    }*/
    
    @Override
    public List<TAccountRole> getRoleByAccount(TAccount account) throws ProcessingException {
        try{
            return userAccountRoleDao.getRoleByAccount(account);
        }catch(DataAccessException e){
            throw new ProcessingException();
        }
    }
    
    @Override
    public void deleteRoleAssignedAcc(List<TAccountRole> accountRole) throws ProcessingException,IllegalArgumentException {
        try{
            userAccountRoleDao.deleteRoleAssignedAcc(accountRole);
        }catch(IllegalArgumentException e){
            throw e;
        }catch(DataAccessException e){
            throw new ProcessingException();
        }
    }
    
    /*@Override
    public void saveAccountWithRole(TAccount account, List<TRole> rolelist, List<TDepartmentMaster> deptList)throws ProcessingException {
        try{
            final java.util.Date date= new java.util.Date();               
            TAccountRole accountRole = new TAccountRole();
            TAccountDepartment accountDept = new TAccountDepartment();
            account.setCreatedDate(new Timestamp(date.getTime()));
            
            
            if(account.getId()!=null){
                System.out.println("Entering Delete"+account.getId());
                List<TAccountRole> accrole = userAccountRoleDao.getRoleByAccount(account);
                List<TAccountDepartment> accDept = userAccountDeptDao.getDepartmentByAccount(account);
                userAccountRoleDao.deleteRoleAssignedAcc(accrole);
                userAccountDeptDao.deleteDepartmentAssignedAcc(accDept);
            }
            acc = new TAccount();
            acc = userAccountDao.saveAccount(account);
            
            for(TRole role:rolelist){
                accountRole = new TAccountRole();
                accountRole.setAccountId(acc);
                accountRole.setRoleId(role);
                accountRole.setCreatedDate(new Timestamp(date.getTime()));
                userAccountRoleDao.saveAccountAndRole(accountRole);
            }
            
            for(TDepartmentMaster dept:deptList){
               accountDept = new TAccountDepartment();
               accountDept.setAccountId(acc); 
               accountDept.setDeptId(dept);
               accountDept.setCreatedDate(new Timestamp(date.getTime()));
               userAccountDeptDao.saveAccountAndDept(accountDept);
            }
        }catch(DataAccessException e){
            Logger.getLogger(UserSetupServiceImpl.class.getName()).log(Level.SEVERE, null, e);
            throw new ProcessingException();
        }catch(Exception e){
            Logger.getLogger(UserSetupServiceImpl.class.getName()).log(Level.SEVERE, null, e);
            throw new HealthCareException("Error in Saving...");
        }
    }*/

    @Override
    public void saveAccountWithDept(TAccount account, DefaultListModel deptdestmodel) throws IllegalArgumentException,HibernateOptimisticLockingFailureException,ProcessingException {
        try{
            final java.util.Date date= new java.util.Date();               
            TAccountDepartment accountDept = new TAccountDepartment();
            account.setCreatedDate(new Timestamp(date.getTime()));
            List<TAccDeptRole> accdeptrole = new ArrayList<TAccDeptRole>();
            if(account.getId()!=null){
                List<TAccountDepartment> accDept = userAccountDeptDao.getDepartmentByAccount(account);
                for(TAccountDepartment acdept:accDept){
                    accdeptrole.addAll(userAccountDeptRoleService.getAssociatedRole(acdept));
                }
                userAccountDeptRoleService.deleteRoleAssignedToDept(accdeptrole);
                userAccountDeptDao.deleteDepartmentAssignedAcc(accDept);
            }
            acc = new TAccount();
            acc = userAccountDao.saveAccount(account);
            int count=0;
            List<TDepartmentMaster> deptdestlist = new ArrayList<TDepartmentMaster>();
            for(int i=0;i<deptdestmodel.getSize();i++){
                TDepartmentMaster d = (TDepartmentMaster)deptdestmodel.get(i);
                deptdestlist.add(d);
            }
            for(TDepartmentMaster dept:deptdestlist){
               accountDept = new TAccountDepartment();
               accountDept.setAccountId(acc); 
               accountDept.setDeptId(dept);
               if(count==0){
                   accountDept.setDefaultDept("Y");
                   count++;
               }else{
                   accountDept.setDefaultDept("N");
               }
               accountDept.setCreatedDate(new Timestamp(date.getTime()));
               userAccountDeptDao.saveAccountAndDept(accountDept);
            }
        }catch(HibernateOptimisticLockingFailureException e){
            Logger.getLogger(UserSetupServiceImpl.class.getName()).log(Level.SEVERE, null, e);
            throw e;
        }catch(IllegalArgumentException e){
            Logger.getLogger(UserSetupServiceImpl.class.getName()).log(Level.SEVERE, null, e);
            throw e;
        }catch(DataAccessException e){
            Logger.getLogger(UserSetupServiceImpl.class.getName()).log(Level.SEVERE, null, e);
            throw new ProcessingException();
        }catch(Exception e){
            Logger.getLogger(UserSetupServiceImpl.class.getName()).log(Level.SEVERE, null, e);
            throw new HealthCareException("Error in Saving...");
        }
    }
    
}

Commits for Aurocare_27_07_2018/AuroCareEMR/src/main/java/com/bestray/healthcareemr/ServiceImpl/UserAccountRoleServiceImpl.java

Diff revisions: vs.
Revision Author Commited Message
1 girijabapi picture girijabapi Fri 27 Jul, 2018 07:21:55 +0000