Subversion Repository Public Repository

Satyam

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
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.bestray.healthcareemr.Views;

import com.bestray.healthcarecommonutil.util.CurvedGradientPanel;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Properties;
import javax.swing.JFileChooser;
import javax.swing.JOptionPane;
import javax.swing.SwingWorker;

// TODO: Auto-generated Javadoc
/**
 * The Class BackupRestorePanel.
 *
 * @author dell
 */
public class BackupRestorePanel extends javax.swing.JPanel {

    /** Creates new form BackupRestorePanel. */
    Properties properties;
    
    /**
     * Instantiates a new backup restore panel.
     */
    public BackupRestorePanel() {
        initComponents();
        try{
            properties=new Properties();
            FileInputStream fis=new FileInputStream(System.getProperty("user.home")+File.separator+"emr"+"/aurocare"+"/jdbc.properties");
            properties.load(fis);
            fis.close();
        }catch(IOException ie){
            ie.printStackTrace();
        }
    
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        BackupPanel = new CurvedGradientPanel();
        jPanel1 = new javax.swing.JPanel();
        backup_label = new javax.swing.JLabel();
        jPanel2 = new javax.swing.JPanel();
        jLabel6 = new javax.swing.JLabel();
        BackupPathTb = new javax.swing.JTextField();
        BackupPath = new javax.swing.JButton();
        BackupButton = new javax.swing.JButton();
        RestorePanel = new CurvedGradientPanel();
        jPanel3 = new javax.swing.JPanel();
        jLabel9 = new javax.swing.JLabel();
        RestorePathTb = new javax.swing.JTextField();
        RestorePath = new javax.swing.JButton();
        RestoreButton = new javax.swing.JButton();
        jPanel4 = new javax.swing.JPanel();
        restore_label = new javax.swing.JLabel();

        setOpaque(false);
        setLayout(new java.awt.CardLayout());

        BackupPanel.setBackground(new java.awt.Color(255, 255, 255));

        jPanel1.setOpaque(false);

        backup_label.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Backup.gif"))); // NOI18N
        backup_label.setVisible(false);

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(backup_label)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(backup_label, javax.swing.GroupLayout.PREFERRED_SIZE, 98, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPanel2.setOpaque(false);

        jLabel6.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        jLabel6.setText("Destination :");

        BackupPathTb.setEditable(false);

        BackupPath.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        BackupPath.setText("Choose");
        BackupPath.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BackupPathActionPerformed(evt);
            }
        });

        BackupButton.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        BackupButton.setText("BackUp");
        BackupButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BackupButtonActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGap(130, 130, 130)
                        .addComponent(jLabel6)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(BackupPathTb, javax.swing.GroupLayout.PREFERRED_SIZE, 378, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(BackupPath))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGap(372, 372, 372)
                        .addComponent(BackupButton)))
                .addGap(154, 154, 154))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel6)
                    .addComponent(BackupPathTb, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(BackupPath))
                .addGap(4, 4, 4)
                .addComponent(BackupButton)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout BackupPanelLayout = new javax.swing.GroupLayout(BackupPanel);
        BackupPanel.setLayout(BackupPanelLayout);
        BackupPanelLayout.setHorizontalGroup(
            BackupPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(BackupPanelLayout.createSequentialGroup()
                .addContainerGap(15, Short.MAX_VALUE)
                .addGroup(BackupPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap(15, Short.MAX_VALUE))
        );
        BackupPanelLayout.setVerticalGroup(
            BackupPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(BackupPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(111, Short.MAX_VALUE))
        );

        add(BackupPanel, "card1");

        RestorePanel.setBackground(new java.awt.Color(255, 255, 255));

        jPanel3.setOpaque(false);

        jLabel9.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        jLabel9.setText("Source :");

        RestorePathTb.setEditable(false);
        RestorePathTb.setText("");

        RestorePath.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        RestorePath.setText("Choose");
        RestorePath.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                RestorePathActionPerformed(evt);
            }
        });

        RestoreButton.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        RestoreButton.setText("Restore");
        RestoreButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                RestoreButtonActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap(193, Short.MAX_VALUE)
                .addComponent(jLabel9)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(RestorePathTb, javax.swing.GroupLayout.PREFERRED_SIZE, 314, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(RestorePath)
                .addContainerGap(194, Short.MAX_VALUE))
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(RestoreButton)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel9)
                    .addComponent(RestorePathTb, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(RestorePath))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(RestoreButton)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPanel4.setOpaque(false);

        restore_label.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Restore.gif"))); // NOI18N
        restore_label.setVisible(false);

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel4Layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(restore_label)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(restore_label, javax.swing.GroupLayout.PREFERRED_SIZE, 95, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout RestorePanelLayout = new javax.swing.GroupLayout(RestorePanel);
        RestorePanel.setLayout(RestorePanelLayout);
        RestorePanelLayout.setHorizontalGroup(
            RestorePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(RestorePanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(RestorePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );
        RestorePanelLayout.setVerticalGroup(
            RestorePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(RestorePanelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(112, Short.MAX_VALUE))
        );

        add(RestorePanel, "card2");
    }// </editor-fold>//GEN-END:initComponents

    /**
     * Backup path action performed.
     *
     * @param evt the evt
     */
    private void BackupPathActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BackupPathActionPerformed
        BackupPathTb.setText(getPath("BACKUP"));
    }//GEN-LAST:event_BackupPathActionPerformed

    /**
     * Backup button action performed.
     *
     * @param evt the evt
     */
    private void BackupButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BackupButtonActionPerformed

        try{
            Backup b = new Backup();
            backup_label.setVisible(true);
            b.execute();

            /*int processComplete;
            String databaseName=properties.getProperty("databaseName");
            String userName=properties.getProperty("jdbc.username");
            String password=properties.getProperty("jdbc.password");
            String dest=BackupPathTb.getText();
            
            if(dest.equals("")){
                JOptionPane.showMessageDialog(null, "Choose The Location to Store");
            }else{
                date = new Date();
                String dateString = sdf.format(date);
                
                Process runtimeProcess = Runtime.getRuntime().exec(properties.getProperty("mysqlpath")+"\\bin\\mysqldump -u "+userName+" -p"+password+" "+databaseName+" -r "+dest+"\\"+dateString+"_emr_backup.sql");
                
                processComplete = runtimeProcess.waitFor();

                if(processComplete==1){
                    JOptionPane.showMessageDialog(null, "Backup Failed");
                }
                else if(processComplete==0){
                    JOptionPane.showMessageDialog(null,"\n Backup created Successfully..");
                    BackupPathTb.setText("");
                }
            }*/
            
        }catch(Exception e){
            JOptionPane.showMessageDialog(null,e);
        }

    }//GEN-LAST:event_BackupButtonActionPerformed

    /**
     * Restore path action performed.
     *
     * @param evt the evt
     */
    private void RestorePathActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_RestorePathActionPerformed
        RestorePathTb.setText(getPath("RESTORE"));
    }//GEN-LAST:event_RestorePathActionPerformed

    /**
     * Restore button action performed.
     *
     * @param evt the evt
     */
    private void RestoreButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_RestoreButtonActionPerformed

        try{
            Restore r = new Restore();
            restore_label.setVisible(true);
            r.execute();
            /*String databaseName=properties.getProperty("databaseName");
            String userName=properties.getProperty("jdbc.username");
            String password=properties.getProperty("jdbc.password");
            int processComplete;
            String source=RestorePathTb.getText();
            if(source.equals("")){
                JOptionPane.showMessageDialog(null, "Choose The Backup File");
            }else{
                String[] executeCmd = new String[]{properties.getProperty("mysqlpath")+"\\bin\\mysql", databaseName, "-u" + userName, "-p" + password, "-e", "  source "+source+"" };
                Process runtimeProcess = Runtime.getRuntime().exec(executeCmd);
                processComplete = runtimeProcess.waitFor();
                if(processComplete==1){
                    JOptionPane.showMessageDialog(null, "Restore Failed");
                }
                else if(processComplete==0){
                    JOptionPane.showMessageDialog(null, "Restore Completed");
                    RestorePathTb.setText("");
                }
            }*/

        }catch(Exception ex){
            JOptionPane.showMessageDialog(null, ex);
        }
    }//GEN-LAST:event_RestoreButtonActionPerformed
    
    /**
     * Gets the path.
     *
     * @param type the type
     * @return the path
     */
    public String getPath(String type) {
       
         String path = "";
         JFileChooser fileChooser = null;
         if (fileChooser == null) {
                fileChooser = new JFileChooser();
                if(type.equalsIgnoreCase("RESTORE")){
                    fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
                }
                else if(type.equalsIgnoreCase("BACKUP")){
                    fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
                }
                fileChooser.setAcceptAllFileFilterUsed(false);
        }
        int returnVal = fileChooser.showDialog(null, "Open");
        if (returnVal == JFileChooser.APPROVE_OPTION) {
            File file = fileChooser.getSelectedFile();
            path = file.getAbsolutePath();
        }
        
       return path;
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton BackupButton;
    private javax.swing.JPanel BackupPanel;
    private javax.swing.JButton BackupPath;
    private javax.swing.JTextField BackupPathTb;
    private javax.swing.JButton RestoreButton;
    private javax.swing.JPanel RestorePanel;
    private javax.swing.JButton RestorePath;
    private javax.swing.JTextField RestorePathTb;
    private javax.swing.JLabel backup_label;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JLabel restore_label;
    // End of variables declaration//GEN-END:variables
    /** The sdf. */
    SimpleDateFormat sdf = new SimpleDateFormat("dd-MMM-yyyy");
    
    /** The date. */
    Date date;
    
    
    /**
     * The Class Backup.
     */
    class Backup extends SwingWorker {
     
     /* (non-Javadoc)
      * @see javax.swing.SwingWorker#doInBackground()
      */
     protected Object doInBackground() throws Exception {
            Thread.sleep(3000);
            int processComplete;
            String databaseName=properties.getProperty("databaseName");
            String userName=properties.getProperty("jdbc.username");
            String password=properties.getProperty("jdbc.password");
            String dest=BackupPathTb.getText();
            
            if(dest.equals("")){
                backup_label.setVisible(false);
                JOptionPane.showMessageDialog(null, "Choose The Location to Store");
            }else{
                date = new Date();
                String dateString = sdf.format(date);
                
                Process runtimeProcess = Runtime.getRuntime().exec(properties.getProperty("mysqlpath")+"\\bin\\mysqldump -u "+userName+" -p"+password+" "+databaseName+" -r "+dest+"\\"+dateString+"_emr_backup.sql");
                
                processComplete = runtimeProcess.waitFor();

                if(processComplete==1){
                    backup_label.setVisible(false);
                    JOptionPane.showMessageDialog(null, "Backup Failed");
                }
                else if(processComplete==0){
                    backup_label.setVisible(false);
                    JOptionPane.showMessageDialog(null,"\n Backup created Successfully..");
                    BackupPathTb.setText("");
                }
            }
            return null;
        }    
    }
    
    /**
     * The Class Restore.
     */
    class Restore extends SwingWorker {
     
     /* (non-Javadoc)
      * @see javax.swing.SwingWorker#doInBackground()
      */
     protected Object doInBackground() throws Exception {
         Thread.sleep(3000);
         String databaseName=properties.getProperty("databaseName");
            String userName=properties.getProperty("jdbc.username");
            String password=properties.getProperty("jdbc.password");
            int processComplete;
            String source=RestorePathTb.getText();
            if(source.equals("")){
                restore_label.setVisible(false);
                JOptionPane.showMessageDialog(null, "Choose The Backup File");
            }else{
                String[] executeCmd = new String[]{properties.getProperty("mysqlpath")+"\\bin\\mysql", databaseName, "-u" + userName, "-p" + password, "-e", "  source "+source+"" };
                Process runtimeProcess = Runtime.getRuntime().exec(executeCmd);
                processComplete = runtimeProcess.waitFor();
                if(processComplete==1){
                    restore_label.setVisible(false);
                    JOptionPane.showMessageDialog(null, "Restore Failed");
                }
                else if(processComplete==0){
                    restore_label.setVisible(false);
                    JOptionPane.showMessageDialog(null, "Restore Completed");
                    RestorePathTb.setText("");
                }
            }
            return null;
     }    
 }
}

Commits for Satyam/AuroCareEMR/src/main/java/com/bestray/healthcareemr/Views/BackupRestorePanel.java

Diff revisions: vs.
Revision Author Commited Message
1 girijabapi picture girijabapi Fri 20 Jul, 2018 05:59:17 +0000