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
/*
 * 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.trastrack.domain.Code;
import com.bestray.transtracking.dao.AlertDao;
import com.bestray.transtracking.dao.CodeDao;
import com.bestray.transtracking.dao.VehicleMaintenanceDao;
import com.bestray.transtracking.dao.impl.AlertDaoImpl;
import com.bestray.transtracking.dao.impl.CodeDaoImpl;
import com.bestray.transtracking.dao.impl.VehicleMaintenanceDaoImpl;
import com.bestray.transtracking.service.AlertService;
import com.bestray.transtracking.service.CodeService;
import com.bestray.trastrack.domain.VehicleMaintenance;
import com.bestray.transtracking.service.impl.CodeServiceImpl;
import java.util.List;
import java.util.Vector;
import com.bestray.transtracking.exceptions.TransTrackException;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author sumitHome
 */
public class AlertServiceImpl implements AlertService{

    private static final String MAINTENANCE_STATUS ="MAINTENANCE_STATUS";
     private static final String MAINTENANCE_STATUS_PENDING ="PENDING";
      private static final String MAINTENANCE_STATUS_DONE ="DONE";
    
    
    private VehicleMaintenanceDao vmDao;
    private AlertDao alertdao;
    private CodeService codeService;
   
    
    
    
    public AlertServiceImpl() {
        
        vmDao = new VehicleMaintenanceDaoImpl( DataSourceObject.getDataSourceObject());
        alertdao = new AlertDaoImpl( DataSourceObject.getDataSourceObject());
        
        
    }
    
    

    public Vector<Vector<String>> getAlertList() throws TransTrackException{
         
        Vector<Vector<String>> alerts = new Vector<Vector<String>>();
        try{
        //vmDao = new VehicleMaintenanceDaoImpl( DataSourceObject.getDataSourceObject());
         
        List<VehicleMaintenance> alertList = vmDao.findAllAlerts();
        for(VehicleMaintenance vm:alertList){
              Vector<String> alertLst = new Vector<String>();
              alertLst.add(String.valueOf(vm.getId()));  
              alertLst.add(vm.getVehicle().getVehicle_number());
              alertLst.add(vm.getTask().getMaintenance_Name());
              
               alerts.add(alertLst);
          }
        }catch(Exception e){
            throw new TransTrackException("Error in fetching Alert List");
        }
        return alerts;
    }

    public Vector<Vector<String>> getAlertPending() throws TransTrackException {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    public boolean updateMaintenanceStatus(VehicleMaintenance vehicleMaintenance) {
        codeService = new CodeServiceImpl();
        Code statusCodeDone = (Code) codeService.getCodeByNameAndValue(MAINTENANCE_STATUS, MAINTENANCE_STATUS_DONE);
        if(statusCodeDone != null){
            try {
                vehicleMaintenance.setMaintenance_status(statusCodeDone.getId());
                alertdao.updateAlert(vehicleMaintenance);
            } catch (Exception ex) {
                Logger.getLogger(AlertServiceImpl.class.getName()).log(Level.SEVERE, null, ex);
                throw new TransTrackException("Error in updating VehicleMaintenance record");
            }
        }
         
        return true;
    }

    @Override
    public void updateVehicleMaster(Long vehicle_id) throws TransTrackException {
        try {
        alertdao.updateVehicleMaster(vehicle_id);
        } catch (Exception ex) {
                Logger.getLogger(AlertServiceImpl.class.getName()).log(Level.SEVERE, null, ex);
                throw new TransTrackException("Error in updating VehicleMaintenance record");
            }
    }
    
}

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

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