[Title] db bug fix that close at stop tracing 30/20030/1
authorgreatim <jaewon81.lim@samsung.com>
Fri, 25 Apr 2014 06:30:07 +0000 (15:30 +0900)
committergreatim <jaewon81.lim@samsung.com>
Fri, 25 Apr 2014 06:30:07 +0000 (15:30 +0900)
[Desc.]
[Issue]

Change-Id: I2b5d984b3f3cf55a8d053e2d9c0bf983f295f2d4

org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/project/Project.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/logparser/MessageParser.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/toolbar/SaveAsDialog.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/toolbar/StopLogProcessor.java

index 7f7e95f..9b5fbdb 100755 (executable)
@@ -314,6 +314,9 @@ public class Project {
 
                AnalyzerManager.setProject(this);
 
+               // close previous database connection
+               SqlConnectionManager.closeConnection();
+               
                // establish database connection
                boolean conn_res = SqlConnectionManager
                                .establishConnection(getSavePath() + File.separator
index c75faae..1ff71d0 100755 (executable)
@@ -76,7 +76,7 @@ import org.tizen.dynamicanalyzer.widgets.da.base.DADialog;
 public class MessageParser {
        private static final DALogger DA_LOG = DALogger.getInstance();
        
-       static final boolean PRINT_DATA_LOG_TOFILE = true;
+       static final boolean PRINT_DATA_LOG_TOFILE = false;
 
        static final int MSG_ID_INDEX = 0;
        static final int MSG_LENGTH_INDEX = 1;
@@ -235,12 +235,12 @@ public class MessageParser {
 
                if (0 == startSec && 0 == startNano) {
                        // original code (before webapp support)
-//                     startTime.setSec(sec);
-//                     startTime.setNano(nano);
+                       startTime.setSec(sec);
+                       startTime.setNano(nano);
                        
                        // for webapp support
-                       startTime.setSec(ByteUtils.toInt(data, 8));
-                       startTime.setNano(ByteUtils.toInt(data, 12));
+//                     startTime.setSec(ByteUtils.toInt(data, 8));
+//                     startTime.setNano(ByteUtils.toInt(data, 12));
                        AnalyzerManager.getProject().setProfileStartTime(startTime);
                }
 
index 7a32fa7..a59b441 100755 (executable)
@@ -66,7 +66,7 @@ import org.tizen.dynamicanalyzer.widgets.da.base.DAText;
 
 public class SaveAsDialog extends DAMessageBox {
        private static final DALogger DA_LOG = DALogger.getInstance();
-       
+
        private int MAX_SAVE_FILE_NAME_LENGTH = 35;
 
        private DAText textBox = null;
@@ -106,7 +106,7 @@ public class SaveAsDialog extends DAMessageBox {
                textBox.setBackground(ColorResources.VIEW_BG_COLOR);
                textBox.getControl().addKeyListener(keyListener);
 
-               info = new Label(shell,  SWT.TRANSPARENT);
+               info = new Label(shell, SWT.TRANSPARENT);
                data = new FormData();
                data.top = new FormAttachment(textBox.getControl(), 5);
                data.left = new FormAttachment(0, 9);
@@ -116,7 +116,7 @@ public class SaveAsDialog extends DAMessageBox {
                info.setBackground(ColorResources.DIALOG_BG_UPPER);
                info.setForeground(ColorResources.RED);
                info.setFont(FontResources.COMBO);
-               
+
                Composite buttonComp = new Composite(shell, SWT.NONE);
                buttonComp.setLayout(new FormLayout());
                buttonComp.setBackground(ColorResources.DIALOG_BG_LOWER);
@@ -251,12 +251,11 @@ public class SaveAsDialog extends DAMessageBox {
        private boolean executeSaveTrace() {
                Project project = AnalyzerManager.getProject();
                String sourcePath = project.getSavePath();
-               String targetPath = PathManager.DA_SAVE_PATH
-                               + File.separator + saveFileName;
+               String targetPath = PathManager.DA_SAVE_PATH + File.separator
+                               + saveFileName;
 
                SqlManager.getInstance().closeConnection();
                SqlConnectionManager.closeConnection();
-               project.setSavePath(targetPath);
 
                File sourceFolder = new File(sourcePath);
                if (!sourceFolder.isDirectory()) {
@@ -274,17 +273,21 @@ public class SaveAsDialog extends DAMessageBox {
                        }
                }
                AnalyzerUtil.copyDirectory(sourceFolder, targetFolder);
+               project.setSavePath(targetPath);
 
                boolean success = AnalyzerUtil.deleteFile(new File(sourcePath));
                if (success) {
                        // add snapshot model update
                        DA_LOG.debug("save complete!!"); //$NON-NLS-1$
-
                } else {
                        DA_LOG.debug("save fail..."); //$NON-NLS-1$
-                       return false;
                }
-               return true;
+               
+               // establish db connection with new path
+               SqlConnectionManager.establishConnection(project.getSavePath()
+                               + File.separator + AnalyzerConstants.DATABASE_NAME);
+
+               return success;
        }
 
        private boolean checkValidFileName(String str) {
@@ -298,14 +301,10 @@ public class SaveAsDialog extends DAMessageBox {
                                || str.contains(CommonConstants.CMD_SPLIT)) {
                        info.setText("name contains invalid character");
                        return false;
-               }
-               else if(str.isEmpty())
-               {
+               } else if (str.isEmpty()) {
                        info.setText("file name is not empty");
                        return false;
-               } 
-               else if (str.length() > MAX_SAVE_FILE_NAME_LENGTH)
-               {
+               } else if (str.length() > MAX_SAVE_FILE_NAME_LENGTH) {
                        info.setText("file name is too long");
                        return false;
                }
index bb36933..1f1016c 100644 (file)
@@ -126,7 +126,6 @@ public class StopLogProcessor implements Runnable {
                        SqlManager.getInstance().saveProfilingChildData();
                        SqlManager.getInstance().saveApiNames();
                        SqlManager.getInstance().closeConnection();
-                       SqlConnectionManager.closeConnection();
                        DA_LOG.debug("insert to db complete..."); //$NON-NLS-1$
                        percent += 10;
                        StopProcessManager.getInstance().setValue(percent);