Subversion Repository Public Repository

TransPort_Tracking

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
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.bestray.transtracking.service.impl;

import com.bestray.transporttracking.DataSourceObject;
import com.bestray.transtracking.dao.ClientCollectionDao;
import com.bestray.transtracking.dao.ClientDao;
import com.bestray.transtracking.dao.CodeDao;
import com.bestray.transtracking.dao.EmployeeDao;
import com.bestray.transtracking.dao.impl.ClientCollectionDaoImpl;
import com.bestray.transtracking.dao.impl.ClientDaoImpl;
import com.bestray.transtracking.dao.impl.CodeDaoImpl;
import com.bestray.transtracking.dao.impl.EmployeeDaoImpl;
import com.bestray.transtracking.dto.ClientCollectionSearchDTO;
import com.bestray.transtracking.service.ClientCollectionService;
import com.bestray.trastrack.domain.ClientCollection;
import com.bestray.trastrack.domain.ClientUser;
import com.bestray.trastrack.domain.Employee;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.sql.DataSource;
import com.bestray.transtracking.exceptions.TransTrackException;
import com.bestray.trastrack.domain.CollectionCalcu;
import java.util.ArrayList;
/**
 *
 * @author user3
 */
public class ClientCollectionServiceImpl implements ClientCollectionService{
    private ClientCollectionDao collectiondao;
    private EmployeeDao employeeDao;
    private ClientDao clientdao;
    private CodeDao codedao;
    
    
    public ClientCollectionServiceImpl(){
        
    }
    
    public List<ClientCollection> getSearchResult(ClientCollectionSearchDTO search) {
        List<ClientCollection> results = new ArrayList<ClientCollection>();
        try{
        DataSource ds =  DataSourceObject.getDataSourceObject();
        //vehicleService = new VehicleServiceImpl();
         collectiondao = new ClientCollectionDaoImpl(ds);
         employeeDao = new EmployeeDaoImpl(ds);
             results = collectiondao.getSearchResults(search);
            for(ClientCollection object :results){
                object.setEmployee(employeeDao.findEmplRegistraion(object.getRecived_person_id()));
                //object.setClient(clientdao.findClientRegistraion(object.getClient_id()));
                //object.setVehicle(vehicleService.getVehicleRegistrationDetails(object.getVehicleId()));
            }
             }catch(Exception e){
           throw new TransTrackException("Error in Fetching Job Entry");
       }
         return results; 
    }
    
    public boolean collectClient(ClientCollection collect) throws TransTrackException{
      boolean flag = false;
        try{
          
        clientdao = new ClientDaoImpl( DataSourceObject.getDataSourceObject());
        codedao = new CodeDaoImpl( DataSourceObject.getDataSourceObject());
        employeeDao = new EmployeeDaoImpl( DataSourceObject.getDataSourceObject()); 
        collectiondao = new ClientCollectionDaoImpl( DataSourceObject.getDataSourceObject());
        if(collect.getId()!=null && collect.getId()>0){
          collectiondao.updateCollection(collect);
       }
        else{
            if(collect.getId()==null){
                collectiondao.saveCollection(collect);
                flag = true;
            }
        }
         }catch(Exception e){
           throw new TransTrackException("Error in Fetching Job Entry");
       }
        return flag;
    }
    
    public List<ClientUser> getClientNameList() {
        List<ClientUser> list = new ArrayList<ClientUser>(); 
       try{
        collectiondao = new ClientCollectionDaoImpl( DataSourceObject.getDataSourceObject());
        list =  collectiondao.findAllClients();
       }catch(Exception e){
           throw new TransTrackException("Error in Fetching Client Name");
       }
        return list;
    }

    public ClientCollection getClientCollectionDetails(Long collectionId) throws TransTrackException{
        ClientCollection collection ;
       try{
        collectiondao = new ClientCollectionDaoImpl( DataSourceObject.getDataSourceObject());
        clientdao = new ClientDaoImpl( DataSourceObject.getDataSourceObject());
        codedao = new CodeDaoImpl( DataSourceObject.getDataSourceObject());
       collection = collectiondao.findCollectionDetails(collectionId);
 }catch(Exception e){
           throw new TransTrackException("Error in Fetching Client Collection");
       }
        return collection;
    }

    public void deleteTransaction(Long clientId) throws TransTrackException{
      try{
        ClientCollection collection = collectiondao.findCollectionDetails(clientId);
        if(collection.getClient_id()!=null){
            
                collectiondao.delete(clientId);
                 }
            }catch(Exception ex){
                 Logger.getLogger(ClientCollectionServiceImpl.class.getName()).log(Level.SEVERE, null, ex);
                 
                 throw new TransTrackException("Error in Delete Transaction");
            }
       
    }

    public List<Employee> getEmployeeNameList() {
        List<Employee> list = new ArrayList<Employee>();
        collectiondao = new ClientCollectionDaoImpl( DataSourceObject.getDataSourceObject());
        try {
            list = collectiondao.findAllEmployees();
        } catch (Exception ex) {
            Logger.getLogger(ClientCollectionServiceImpl.class.getName()).log(Level.SEVERE, null, ex);
            throw new TransTrackException("Error in Fetching Employee Name List");
        }
       return list;
    }

    public CollectionCalcu getPayment(Long clientId) throws TransTrackException {
        try {
            collectiondao = new ClientCollectionDaoImpl(DataSourceObject.getDataSourceObject());
            return collectiondao.getTotalPayment(clientId);
        } catch (Exception ex) {
            Logger.getLogger(ClientCollectionServiceImpl.class.getName()).log(Level.SEVERE, null, ex);
            throw new TransTrackException("Error in fetching total balance");
        }
    }
    
}

Commits for TransPort_Tracking/TransPortTracking/src/main/java/com/bestray/transtracking/service/impl/ClientCollectionServiceImpl.java

Diff revisions: vs.
Revision Author Commited Message
1 girijabapi picture girijabapi Sat 28 Jul, 2018 05:29:14 +0000