From: greatim Date: Sat, 20 Sep 2014 07:56:47 +0000 (+0900) Subject: DB: remove old database X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F58%2F27858%2F1;p=sdk%2Ftools%2Fdynamic-analyzer.git DB: remove old database remove old database Change-Id: Iab76f3a61ceef5fdd8d1663834b512f7cf9f3dcd Signed-off-by: greatim --- diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/common/Global.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/common/Global.java index 3b56708..d14c1b9 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/common/Global.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/common/Global.java @@ -65,6 +65,14 @@ public class Global { } } + public static ImageInfo getLeastImageInfoByTime(long time) { + if (currentProject != null) { + return currentProject.getLeastImageInfoByTime(time); + } else { + return null; + } + } + public static ImageInfo getGreatestImageInfoByTime(long time) { if (currentProject != null) { return currentProject.getGreatestImageInfoByTime(time); diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/handlers/ClearHandler.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/handlers/ClearHandler.java index 8e186b5..ac7808f 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/handlers/ClearHandler.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/handlers/ClearHandler.java @@ -31,7 +31,6 @@ import org.eclipse.core.commands.ExecutionEvent; import org.eclipse.core.commands.ExecutionException; import org.eclipse.swt.widgets.Display; import org.tizen.dynamicanalyzer.common.AnalyzerManager; -import org.tizen.dynamicanalyzer.sql.SqlManager; import org.tizen.dynamicanalyzer.ui.page.BaseView; import org.tizen.dynamicanalyzer.ui.page.UpdateViewTimer; import org.tizen.dynamicanalyzer.ui.toolbar.StopLogProcessor; @@ -49,7 +48,6 @@ public class ClearHandler extends AbstractHandler { // CallStackManager.clear(); AnalyzerManager.getWarningChecker().clear(); StopLogProcessor.clear(); - SqlManager.getInstance().clear(); Display.getDefault().syncExec(new Runnable() { @Override diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/handlers/OpenTraceHandler.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/handlers/OpenTraceHandler.java index 20c5d4e..8643b1a 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/handlers/OpenTraceHandler.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/handlers/OpenTraceHandler.java @@ -39,14 +39,11 @@ import org.tizen.dynamicanalyzer.common.AnalyzerConstants; import org.tizen.dynamicanalyzer.common.AnalyzerManager; import org.tizen.dynamicanalyzer.common.Global; import org.tizen.dynamicanalyzer.communicator.DACommunicator; -import org.tizen.dynamicanalyzer.constant.CommonConstants; import org.tizen.dynamicanalyzer.database.SqlConnectionManager; import org.tizen.dynamicanalyzer.nl.AnalyzerLabels; import org.tizen.dynamicanalyzer.project.BinaryInfo; -import org.tizen.dynamicanalyzer.project.ImageInfo; import org.tizen.dynamicanalyzer.project.Project; import org.tizen.dynamicanalyzer.resources.ImageResources; -import org.tizen.dynamicanalyzer.sql.SqlManager; import org.tizen.dynamicanalyzer.swap.callstack.BaseCallstackManager; import org.tizen.dynamicanalyzer.swap.logparser.DataManagerRegistry; import org.tizen.dynamicanalyzer.ui.info.callstack.CallStackInserter; @@ -101,8 +98,7 @@ public class OpenTraceHandler extends AbstractHandler { Display.getDefault().syncExec(new Runnable() { @Override public void run() { - DACustomCombo deviceCombo = ToolbarArea.getInstance() - .getDeviceCombo(); + DACustomCombo deviceCombo = ToolbarArea.getInstance().getDeviceCombo(); DACustomCombo appCombo = ToolbarArea.getInstance().getAppCombo(); deviceCombo.setText(Global.getProject().getDevice()); appCombo.setText(Global.getProject().getAppName()); @@ -113,9 +109,7 @@ public class OpenTraceHandler extends AbstractHandler { } int percent = OpenTraceProgressManager.getInstance().getPercent(); - if (loadCallStackApis() && loadProfilingData() && loadProfilingChildData() && - // loadCallStackData() && - loadImageSet()) { + if (loadCallStackApis() && loadProfilingData() && loadProfilingChildData()) { OpenTraceProgressManager.getInstance().setProgressPercent( AnalyzerLabels.OPEN_TRACE_PROGRESS_LOADING, percent += 60); } else { @@ -132,8 +126,7 @@ public class OpenTraceHandler extends AbstractHandler { ToolbarArea.getInstance().checkStartButtonAndAppListEnablement(); ToolbarArea.getInstance().setRepalyButtonEnable(true); ToolbarArea.getInstance().setSourceViewEnable(true); - ToolbarArea.getInstance().setSourceViewTooltip( - AnalyzerLabels.MESSAGE_PROCESS_VIEW_SOURCE); + ToolbarArea.getInstance().setSourceViewTooltip(AnalyzerLabels.MESSAGE_PROCESS_VIEW_SOURCE); OpenTraceProgressManager.getInstance().setProgressPercent( AnalyzerLabels.OPEN_TRACE_PROGRESS_LOADING, percent += 3); @@ -156,15 +149,13 @@ public class OpenTraceHandler extends AbstractHandler { private boolean loadCallStackApis() { boolean isSuccess = true; - List> callStackUnits = - CallStackInserter.getInstance().getCallStackUnitTable() - .getCallStackUnitsFromDB(); + List> callStackUnits = CallStackInserter.getInstance().getCallStackUnitTable() + .getCallStackUnitsFromDB(); if (null == callStackUnits) { Logger.debug("failed - loadCallStackApis"); isSuccess = false; } else { - BaseCallstackManager callstackManager = AnalyzerManager - .getCallstackManager(); + BaseCallstackManager callstackManager = AnalyzerManager.getCallstackManager(); int size = callStackUnits.size(); for (int i = 0; i < size; i++) { List callStackUnit = callStackUnits.get(i); @@ -175,37 +166,12 @@ public class OpenTraceHandler extends AbstractHandler { .get(CallStackUnitDBTable.COLUMN.BINARYID.index); long addr = (Long) callStackUnit.get(CallStackUnitDBTable.COLUMN.PCADDR.index); CallStackUnit csa = new CallStackUnit(addr, pid, functionId, binaryId); - callstackManager.getCallStackApiAddrByPidMap(pid) - .put(addr, csa); + callstackManager.getCallStackApiAddrByPidMap(pid).put(addr, csa); } } return isSuccess; } - private boolean loadImageSet() { -// List> input = SqlManager.getInstance().getloadImageSet(3); -// if (null == input) { -// return false; -// } -// -// int size = input.size(); -// -// for (int i = 0; i < size; i++) { -// List imgLog = input.get(i); -// String seq = imgLog.get(0); -// String time = imgLog.get(1); -// ImageInfo imgInfo = new ImageInfo(); -// imgInfo.setSeq(seq); -// imgInfo.setTime(time); -// -// String[] path = imgLog.get(2).split(CommonConstants.SLASH); -// imgInfo.setFileName(new String(path[path.length - 1])); -// -// AnalyzerManager.getImageSet().put(seq, imgInfo); -// } - return true; - } - private boolean loadProfilingData() { boolean isSuccess = true; List> profilingDatas = FunctionUsageProfiler.getInstance() @@ -239,7 +205,7 @@ public class OpenTraceHandler extends AbstractHandler { switch (type) { case ProfilingData.TYPE_APPLICATION: case ProfilingData.TYPE_DEPENDENTLIBRARY: - case ProfilingData.TYPE_LIBRARY: + case ProfilingData.TYPE_LIBRARY: binaryId = (Integer) profilingData .get(ProfilingDataDBTable.COLUMN.BINARYID.index); bInfo = Global.getProject().getDeviceStatusInfo().getBinaryInfo(binaryId); @@ -249,25 +215,25 @@ public class OpenTraceHandler extends AbstractHandler { break; case ProfilingData.TYPE_FUNCTION: int functionId = (Integer) profilingData - .get(ProfilingDataDBTable.COLUMN.FUNCTIONID.index); + .get(ProfilingDataDBTable.COLUMN.FUNCTIONID.index); name = Global.getFunctionName(functionId); fupData = new ProfilingData(seq, name, exCount, inCount, callCount, - inElapsedTime, exElapsedTime, profiler); + inElapsedTime, exElapsedTime, profiler); break; default: // never goes here System.out.println("invalid profiling data type"); break; } - + if (null == fupData) { isSuccess = false; } else { if (type == ProfilingData.TYPE_APPLICATION) { - profiler.setAppBin(fupData); + profiler.setAppBin(fupData); } else if (type == ProfilingData.TYPE_DEPENDENTLIBRARY) { - profiler.setDependentLib(fupData); + profiler.setDependentLib(fupData); } - + profiler.getProfilingDataMap().put(seq, fupData); UIDataManager.getInstance().getfunctionProfilingDataChecker() .addProfilingData(fupData); @@ -290,10 +256,9 @@ public class OpenTraceHandler extends AbstractHandler { } else { for (int i = 0; i < profilingChilds.size(); i++) { List data = profilingChilds.get(i); - int parentSeq = (Integer) data.get(ProfilingChildDataDBTable.COLUMN.SEQ.index); + int parentSeq = (Integer) data.get(ProfilingChildDataDBTable.COLUMN.SEQ.index); int pid = (Integer) data.get(ProfilingChildDataDBTable.COLUMN.PID.index); - int childSeq = (Integer) data - .get(ProfilingChildDataDBTable.COLUMN.CHILDSEQ.index); + int childSeq = (Integer) data.get(ProfilingChildDataDBTable.COLUMN.CHILDSEQ.index); ProfileDataMaker profiler = FunctionUsageProfiler.getInstance() .getProfileDataMakerByPid(pid); diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/project/Project.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/project/Project.java index 41dc9c6..0680d37 100755 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/project/Project.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/project/Project.java @@ -364,11 +364,21 @@ public class Project { return null; } } - + public Set> getImageInfoSet() { return Collections.unmodifiableSet(imageInfos.entrySet()); } + public void buildImageInfoFrom(List imageList) { + imageInfos.clear(); + + int imgsize = imageList.size(); + for (int i = 0; i < imgsize; i++) { + long time = imageList.get(i).getTime(); + imageInfos.put(Long.valueOf(time), imageList.get(i)); + } + } + // this initForTrace() function called only when trace is started. public void initForTrace() { if (null == Global.getCurrentApplication()) { diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/sql/DBTableInfo.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/sql/DBTableInfo.java deleted file mode 100644 index 99a4fb2..0000000 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/sql/DBTableInfo.java +++ /dev/null @@ -1,174 +0,0 @@ -/* - * Dynamic Analyzer - * - * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: - * Jaewon Lim - * Jooyoul Lee - * Juyoung Kim - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * Contributors: - * - S-Core Co., Ltd - * - */ - -package org.tizen.dynamicanalyzer.sql; - -import org.tizen.dynamicanalyzer.constant.CommonConstants; - -public class DBTableInfo { - protected String tableName; - protected String[] columnNames; - protected String[] columnOptions; - protected String[] columnTypes; - - public DBTableInfo(String tableName, String[] columnNames, - String[] columnOptions, String[] columnTypes) { - this.tableName = tableName; - this.columnNames = columnNames; - this.columnOptions = columnOptions; - this.columnTypes = columnTypes; - } - - protected String getColumnString(int index) { - if (columnNames.length <= index) { - return null; - } else { - return columnNames[index] + CommonConstants.SPACE - + columnTypes[index] + CommonConstants.SPACE - + columnOptions[index]; - } - } - - public String getTableName() { - return tableName; - } - - public String createQuery() { - if (isValid()) { - StringBuffer strBuffer = new StringBuffer(); - strBuffer.append("create table "); //$NON-NLS-1$ - strBuffer.append(tableName); - strBuffer.append(" ( "); //$NON-NLS-1$ - - for (int i = 0; i < columnNames.length; i++) { - strBuffer.append(getColumnString(i)); - if (i == columnNames.length - 1) { - strBuffer.append(CommonConstants.CLOSE_BRACKET); - } else { - strBuffer.append(CommonConstants.COMMA); - } - } - strBuffer.append(CommonConstants.SEMICOLON); - - return strBuffer.toString(); - } else { - return null; - } - } - - public String selectAllQuery() { - if (isValid()) { - StringBuffer strBuffer = new StringBuffer(); - strBuffer.append("select "); //$NON-NLS-1$ - for (int i = 0; i < columnNames.length; i++) { - strBuffer.append(columnNames[i]); - if (i != columnNames.length - 1) { - strBuffer.append(CommonConstants.COMMA); - } - } - strBuffer.append(" from ");//$NON-NLS-1$ - strBuffer.append(tableName); - strBuffer.append(CommonConstants.SEMICOLON); - - return strBuffer.toString(); - } else { - return null; - } - } - - public String insertQuery() { - if (isValid()) { - StringBuffer strBuffer = new StringBuffer(); - strBuffer.append("insert into "); //$NON-NLS-1$ - strBuffer.append(tableName); - strBuffer.append(" values ( "); //$NON-NLS-1$ - - for (int i = 0; i < columnNames.length; i++) { - strBuffer.append("?"); //$NON-NLS-1$ - if (i == columnNames.length - 1) { - strBuffer.append(");"); //$NON-NLS-1$ - break; - } else { - strBuffer.append(","); //$NON-NLS-1$ - } - } - - return strBuffer.toString(); - } else { - return null; - } - } - - protected boolean isValid() { - if (null == tableName || tableName.isEmpty()) { - return false; - } - - if (null == columnNames || columnNames.length == 0) { - return false; - } - - if (null == columnOptions || columnOptions.length == 0) { - return false; - } - - if (null == columnTypes || columnTypes.length == 0) { - return false; - } - - if (columnNames.length != columnOptions.length - || columnNames.length != columnTypes.length) { - return false; - } - - return true; - } - - public String[] getColumnNames() { - return columnNames; - } - - public String[] getColumnOptions() { - return columnOptions; - } - - public String[] getColumnTypes() { - return columnTypes; - } - - public void setColumnNames(String[] columnNames) { - this.columnNames = columnNames; - } - - public void setColumnOptions(String[] columnOptions) { - this.columnOptions = columnOptions; - } - - public void setColumnTypes(String[] columnTypes) { - this.columnTypes = columnTypes; - } -} diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/sql/DBTableManager.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/sql/DBTableManager.java deleted file mode 100755 index 2284655..0000000 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/sql/DBTableManager.java +++ /dev/null @@ -1,189 +0,0 @@ -/* - * Dynamic Analyzer - * - * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: - * Jaewon Lim - * Jooyoul Lee - * Juyoung Kim - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * Contributors: - * - S-Core Co., Ltd - * - */ - -package org.tizen.dynamicanalyzer.sql; - -import java.util.ArrayList; -import java.util.List; - -import org.tizen.dynamicanalyzer.constant.CommonConstants; - -public class DBTableManager { - - public static DBTableManager instance = null; - -// private static final String TABLE_NAME_FAILED_DATA = "FailedData";//$NON-NLS-1$ -// private static final String TABLE_NAME_LEAK_DATA = "LeakData";//$NON-NLS-1$ - private static List tableInfos; - -// public static final int TABLE_INDEX_FAILED_DATA = 0; -// public static final int TABLE_INDEX_LEAK_DATA = 1; - - public static final String EMPTY = CommonConstants.EMPTY; - public static final String TEXT = "VARCHAR(256)";//$NON-NLS-1$ - public static final String BIG_TEXT = "VARCHAR(1024)";//$NON-NLS-1$ - public static final String BIGBIG_TEXT = "VARCHAR(16384)";//$NON-NLS-1$ - // public static final String TEXT = "LONGVARCHAR";//$NON-NLS-1$ - // public static final String BIG_TEXT = "LONGVARCHAR";//$NON-NLS-1$ - public static final String INTEGER = "INTEGER";//$NON-NLS-1$ - public static final String LONG = "bigint";//$NON-NLS-1$ - public static final String NOT_NULL = "not null";//$NON-NLS-1$ - - public static final String COMMON_COLUMN_RID = "Rid";//$NON-NLS-1$ - public static final String COMMON_COLUMN_ID = "Id";//$NON-NLS-1$ - public static final String COMMON_COLUMN_SEQ_NUMBER = "SeqNumber";//$NON-NLS-1$ - public static final String COMMON_COLUMN_API_NAME = "APINmae";//$NON-NLS-1$ - public static final String COMMON_COLUMN_TIME = "Time";//$NON-NLS-1$ - public static final String COMMON_COLUMN_PID = "Pid";//$NON-NLS-1$ - public static final String COMMON_COLUMN_TID = "Tid";//$NON-NLS-1$ - public static final String COMMON_COLUMN_INPUT_PARAM = "InputParm";//$NON-NLS-1$ - public static final String COMMON_COLUMN_RETURN = "Return";//$NON-NLS-1$ - public static final String COMMON_COLUMN_PCADDR = "PCAddr";//$NON-NLS-1$ - public static final String COMMON_COLUMN_ERROR = "Error";//$NON-NLS-1$ - public static final String COMMON_COLUMN_INTERNAL_CALL = "InternalCall";//$NON-NLS-1$ - public static final String COMMON_COLUMN_CALLER_PCADDR = "CallerPCAddr";//$NON-NLS-1$ - public static final String COMMON_COLUMN_RESERVED1 = "Reserved1";//$NON-NLS-1$ - public static final String COMMON_COLUMN_RESERVED2 = "Reserved2";//$NON-NLS-1$ - public static final String COMMON_COLUMN_RESERVED3 = "Reserved3";//$NON-NLS-1$ - public static final String COMMON_COLUMN_RESERVED4 = "Reserved4";//$NON-NLS-1$ - public static final String COMMON_COLUMN_RESERVED5 = "Reserved5";//$NON-NLS-1$ - public static final String COMMON_COLUMN_RESERVED6 = "Reserved6";//$NON-NLS-1$ - public static final String COMMON_COLUMN_RESERVED7 = "Reserved7";//$NON-NLS-1$ - - public static final String CUSTOM_COLUMN_ADDR = "addr";//$NON-NLS-1$ - public static final String CUSTOM_COLUMN_SEQ = "SeqNumber";//$NON-NLS-1$ - public static final String CUSTOM_COLUMN_PID = "Pid";//$NON-NLS-1$ - public static final String CUSTOM_COLUMN_API = "api";//$NON-NLS-1$ - public static final String CUSTOM_COLUMN_CALLSTACK = "callstack";//$NON-NLS-1$ - public static final String CUSTOM_COLUMN_NAME = "name";//$NON-NLS-1$ - public static final String CUSTOM_COLUMN_EXCOUNT = "exCount";//$NON-NLS-1$ - public static final String CUSTOM_COLUMN_INCOUNT = "inCount";//$NON-NLS-1$ - public static final String CUSTOM_COLUMN_CALL_COUNT = "callCount";//$NON-NLS-1$ - public static final String CUSTOM_COLUMN_PARENT = "parent";//$NON-NLS-1$ - public static final String CUSTOM_COLUMN_KEY = "key";//$NON-NLS-1$ - public static final String CUSTOM_COLUMN_INCL_EXETIME = "inclExeTime";//$NON-NLS-1$ - public static final String CUSTOM_COLUMN_EXCL_EXETIME = "exclExeTime";//$NON-NLS-1$ - public static final String CUSTOM_COLUMN_CHILD_LIST = "childList";//$NON-NLS-1$ - public static final String CUSTOM_COLUMN_START_TIME = "StartTime"; - public static final String CUSTOM_COLUMN_END_TIME = "EndTime"; - public static final String CUSTOM_COLUMN_FUNCNAME = "FunctionName"; - - public static final String TARGET_INFO_SYS_MEM_SIZE = "SystemMemorySize";//$NON-NLS-1$ - public static final String TARGET_INFO_STORAGE_SIZE = "StorageSize"; - public static final String TARGET_INFO_BLUETOOTH = "BlueTooth"; - public static final String TARGET_INFO_GPS = "GPS"; - public static final String TARGET_INFO_WIFI = "WiFi"; - public static final String TARGET_INFO_CAMERA = "Camera"; - public static final String TARGET_INFO_NETWORK = "Network"; - public static final String TARGET_INFO_MAX_BRIGHT = "Brightness"; - public static final String TARGET_INFO_CPU_CORE_COUNT = "CoreCount"; - public static final String TARGET_INFO_DEVICE_COUNT = "DeviceCount"; - public static final String TARGET_INFO_DEVICES = "Devices"; - - public static final String PROCESS_INFO = "ProcessInfo";//$NON-NLS-1$ - - public static final String LIBRARY_OBJECT_LOW_ADDR = "LowAddr"; - public static final String LIBRARY_OBJECT_HIGH_ADDR = "HighAddr"; - public static final String LIBRARY_OBJECT_PATH = "LibraryPath"; - - public static final String APINAME_NAME = "name"; - - public static final String[] commonColumns = { COMMON_COLUMN_RID, - COMMON_COLUMN_ID, COMMON_COLUMN_SEQ_NUMBER, COMMON_COLUMN_API_NAME, - COMMON_COLUMN_TIME, COMMON_COLUMN_PID, COMMON_COLUMN_TID, - COMMON_COLUMN_INPUT_PARAM, COMMON_COLUMN_RETURN, - COMMON_COLUMN_PCADDR, COMMON_COLUMN_ERROR, - COMMON_COLUMN_INTERNAL_CALL, COMMON_COLUMN_CALLER_PCADDR, - COMMON_COLUMN_RESERVED1, COMMON_COLUMN_RESERVED2, - COMMON_COLUMN_RESERVED3, COMMON_COLUMN_RESERVED4, - COMMON_COLUMN_RESERVED5, COMMON_COLUMN_RESERVED6, - COMMON_COLUMN_RESERVED7 }; - public static final String[] commonOptions = { EMPTY, EMPTY, EMPTY, EMPTY, - EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, - EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY }; - public static final String[] commonTypes = { TEXT, TEXT, TEXT, TEXT, TEXT, - TEXT, TEXT, TEXT, TEXT, TEXT, TEXT, TEXT, TEXT, TEXT, TEXT, TEXT, - TEXT, TEXT, TEXT, TEXT }; - - public synchronized static DBTableManager getInstance() { - if (null == instance) { - synchronized (DBTableManager.class) { - if (null == instance) { - instance = new DBTableManager(); - instance.init(); - } - } - } - return instance; - } - - public List getTableInfos() { - if (null == tableInfos) { - tableInfos = new ArrayList(); - } - return tableInfos; - } - - private void init() { - // init tableInfo; - getTableInfos(); - - // "failed data" table info block -// { -// String[] names = { "Rid", "MsgId", "SeqNumber", "Time", "ApiName", -// "Parameter", "Return", "ErrorCode", "CallerPc", "Pid", -// "LibName" }; -// String[] options = { EMPTY, EMPTY, NOT_NULL, EMPTY, EMPTY, EMPTY, -// EMPTY, EMPTY, EMPTY, EMPTY, EMPTY }; -// String[] types = { TEXT, TEXT, TEXT, TEXT, TEXT, TEXT, TEXT, TEXT, -// TEXT, TEXT, TEXT }; -// DBTableInfo failedDataTableInfo = new DBTableInfo( -// TABLE_NAME_FAILED_DATA, names, options, types); -// tableInfos.add(failedDataTableInfo); -// } - - // "leak data" table info block -// { -// String[] names = { "Rid", "LeakSeq", "MsgId", "SeqNumber", "Time", -// "ApiName", "Pid", "Address", "CallerPc", "Parameter", -// "Return", "LibName", "Key", "ParentKey" }; -// // commonColumns; -// String[] options = { EMPTY, EMPTY, EMPTY, NOT_NULL, EMPTY, EMPTY, -// EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY, EMPTY }; -// String[] types = { TEXT, TEXT, TEXT, TEXT, TEXT, TEXT, TEXT, TEXT, -// TEXT, TEXT, TEXT, TEXT, TEXT, TEXT }; -// DBTableInfo leakDataTableInfo = new DBTableInfo( -// TABLE_NAME_LEAK_DATA, names, options, types); -// tableInfos.add(leakDataTableInfo); -// } - } - - public DBTableInfo getTableInfo(int tableInfoIndex) { - return getTableInfos().get(tableInfoIndex); - } - -} diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/sql/SqlManager.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/sql/SqlManager.java deleted file mode 100755 index 5cb0c08..0000000 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/sql/SqlManager.java +++ /dev/null @@ -1,219 +0,0 @@ -/* - * Dynamic Analyzer - * - * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: - * Jaewon Lim - * hyunJong park< phjwithyou.park@samsung.com> - * Juyoung Kim - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * Contributors: - * - S-Core Co., Ltd - * - */ -package org.tizen.dynamicanalyzer.sql; - -import java.io.File; -import java.sql.Connection; -import java.sql.DriverManager; -import java.sql.ResultSet; -import java.sql.ResultSetMetaData; -import java.sql.SQLException; -import java.sql.SQLWarning; -import java.sql.Statement; -import java.util.ArrayList; -import java.util.List; - -import org.tizen.dynamicanalyzer.common.AnalyzerConstants; -import org.tizen.dynamicanalyzer.common.AnalyzerManager; -import org.tizen.dynamicanalyzer.common.Global; -import org.tizen.dynamicanalyzer.constant.CommonConstants; -import org.tizen.dynamicanalyzer.project.Project; -import org.tizen.dynamicanalyzer.util.CommonUtil; -import org.tizen.dynamicanalyzer.util.Logger; - -public class SqlManager { - // private static final int PERMIT = 1; - // private Semaphore semaphore = new Semaphore(PERMIT); - - private static SqlManager instance = null; - - private Connection connection = null; - - private boolean isQueryPrint = false; - - private Connection getConnection() { - Project project = Global.getProject(); - if (null != project && !AnalyzerManager.isExit()) { - return getConnection(project.getSavePath()); - } - return null; - } - - public Connection getConnection(String path) { - try { - if (null != connection) { - return connection; - } - Class.forName("org.hsqldb.jdbcDriver"); - String dbUrl = "jdbc:hsqldb:" - + path - + File.separator - + AnalyzerConstants.DATABASE_NAME - + ";shutdown=false;hsqldb.default_table_type=cached;hsqldb.large_data=true;hdqldb.log_data=false"; //$NON-NLS-1$ - connection = DriverManager.getConnection(dbUrl, "SA", ""); - SQLWarning warning = connection.getWarnings(); - while (warning != null) { - Logger.debug("Message: " + warning.getMessage()); - Logger.debug("SQL state: " + warning.getSQLState()); - Logger.debug("Vendor code: " + warning.getErrorCode()); - warning = warning.getNextWarning(); - } - } catch (ClassNotFoundException e) { - e.printStackTrace(); - } catch (SQLException e) { - e.printStackTrace(); - } - return connection; - } - - public void semaphoreAcquire() { - // if (connection != null) { - // try { - // semaphore.acquire(); - // } catch (InterruptedException e) { - // e.printStackTrace(); - // } - // } - } - - public void semaphoreRelease() { - // if (connection == null) { - // return; - // } else { - // semaphore.release(); - // } - } - - public synchronized static SqlManager getInstance() { - if (null == instance) { - instance = new SqlManager(); - } - return instance; - } - - public void clear() { - // semaphore = new Semaphore(PERMIT); - instance = null; - } - - public List> selectQuery(String dbFilePath, String[] columnName, String tableName, - String option) { - List> dbInfo = null; - String query = null; - Statement stat = null; - ResultSet rs = null; - Connection conn = null; - try { - if (null == dbFilePath) { - conn = getConnection(); - } else { - conn = getConnection(dbFilePath); - } - if (null == conn) { - return null; - } - if (null == tableName || tableName.length() < 1) { - Logger.debug("tableName is null"); - return null; - } - - StringBuilder columns = new StringBuilder(); - if (null == columnName || columnName.length < 1) { - Logger.debug("tableName is null"); - return null; - } else { - for (int i = 0; i < columnName.length; i++) { - if ((0 < i) && (i < columnName.length)) { - columns.append(", ");//$NON-NLS-1$ - } - columns.append(columnName[i]); - } - } - String queryOption = CommonConstants.EMPTY; - if (null != option) { - queryOption = option; - } - query = String.format("select %s from %s %s;",//$NON-NLS-1$ - columns.toString(), tableName, queryOption); - - semaphoreAcquire(); - stat = conn.createStatement(); - if (isQueryPrint) { - Logger.debug("query : " + query); - } - rs = stat.executeQuery(query); - if (null != rs) { - dbInfo = new ArrayList>(); - ResultSetMetaData rsMetaData = rs.getMetaData(); - int nRsMetaDataCount = rsMetaData.getColumnCount(); - while (rs.next()) { - List rowData = new ArrayList(); - for (int i = 1; i < nRsMetaDataCount + 1; i++) { - if (rsMetaData.getColumnTypeName(i).contains("INTEGER")) { - rowData.add(Integer.toString(rs.getInt(i))); - } else if (rsMetaData.getColumnTypeName(i).contains("BIGINT")) { - rowData.add(Long.toString(rs.getLong(i))); - } else if (rsMetaData.getColumnTypeName(i).contains("VARCHAR")) {//$NON-NLS-1$ - rowData.add(rs.getString(rsMetaData.getColumnName(i))); - } else { - Logger.debug("Error undefine Type : " + rsMetaData.getColumnTypeName(i)); - } - - } - dbInfo.add(rowData); - } - } - } catch (SQLException e) { - Logger.debug("SQLException - selecte : " + query); - e.printStackTrace(); - } finally { - CommonUtil.tryClose(stat, rs); - semaphoreRelease(); - if (null != dbFilePath) { - } - } - return dbInfo; - } - - public long getLastScreenshotTime(long time) { - String queryOption = "where time >=" + time;//$NON-NLS-1$ - List> dbInfo = selectQuery(null, - new String[] { "min(time)" }, "screenshot", queryOption); //$NON-NLS-1$ //$NON-NLS-2$ - if (dbInfo == null || dbInfo.isEmpty() || null == dbInfo.get(0).get(0)) { - return -1; - } - return Long.parseLong(dbInfo.get(0).get(0)); - } - - public List> getloadImageSet(int size) { - List> dbInfo = selectQuery(null, new String[] { - "SeqNumber", "Time", "ImageFilePath" }, "screenshot", null); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - return dbInfo; - } - - -} diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/info/screenshot/ScreenshotDataManager.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/info/screenshot/ScreenshotDataManager.java index 7acb8ce..532a807 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/info/screenshot/ScreenshotDataManager.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/info/screenshot/ScreenshotDataManager.java @@ -1,13 +1,18 @@ package org.tizen.dynamicanalyzer.ui.info.screenshot; import java.io.File; +import java.sql.ResultSet; +import java.sql.SQLException; import java.util.ArrayList; import java.util.List; +import java.util.Map; import org.tizen.dynamicanalyzer.common.Global; import org.tizen.dynamicanalyzer.communicator.DACommunicator; import org.tizen.dynamicanalyzer.constant.CommonConstants; +import org.tizen.dynamicanalyzer.database.DBColumn; import org.tizen.dynamicanalyzer.database.DBTable; +import org.tizen.dynamicanalyzer.database.SqlConnectionManager; import org.tizen.dynamicanalyzer.project.ImageInfo; import org.tizen.dynamicanalyzer.swap.channel.data.DataChannelConstants; import org.tizen.dynamicanalyzer.swap.logparser.LogPackage; @@ -19,6 +24,8 @@ import org.tizen.dynamicanalyzer.swap.model.data.SystemData; import org.tizen.dynamicanalyzer.utils.AnalyzerUtil; public class ScreenshotDataManager extends PageDataManager { + private static final String SCREENSHOT_QUERY = "select %s from %s order by %s"; + private static ScreenshotDataManager instance = null; private ScreenShotDBTable screenShotDBTable = null; @@ -110,8 +117,9 @@ public class ScreenshotDataManager extends PageDataManager { } /* - * TODO interface of SystemData is changed(by jungwook). removed getResidentMemory(). - * residentMemory is possible one more per multi process. + * TODO interface of SystemData is changed(by jungwook). removed + * getResidentMemory(). residentMemory is possible one more per + * multi process. */ // lastProcessMemory = input.getResidentMemory(); lastStartTime = input.getTime(); @@ -126,4 +134,42 @@ public class ScreenshotDataManager extends PageDataManager { makeSystemData(systemDataLogs); makeScreenShotData(screenShotLogs); } + + @Override + public void openData(Map dataMap) { + List imageList = new ArrayList(); + + StringBuilder columnstr = new StringBuilder(); + List columnList = screenShotDBTable.getColumns(); + int columnsize = columnList.size(); + for (int i = 0; i < columnsize; i++) { + columnstr.append(columnList.get(i).getName()); + if (i != columnsize - 1) { + columnstr.append(", "); + } + } + + String querystr = String.format(SCREENSHOT_QUERY, columnstr.toString(), + screenShotDBTable.getTableName(), ScreenShotDBTable.COLUMN.TIME); + + ResultSet rs = SqlConnectionManager.executeQueryRS(querystr); + if(rs != null) { + + try { + while(rs.next()) { + ImageInfo img = new ImageInfo(); + img.setTime(rs.getLong(1)); + img.setFileName(rs.getString(2)); + img.setOrientation(rs.getInt(3)); + imageList.add(img); + } + } catch (SQLException e) { + e.printStackTrace(); + } + + SqlConnectionManager.releaseResultSet(rs); + } + + Global.getProject().buildImageInfoFrom(imageList); + } } diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/userinterface/control/UIControlListTable.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/userinterface/control/UIControlListTable.java index 0eb63a9..b82a91a 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/userinterface/control/UIControlListTable.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/userinterface/control/UIControlListTable.java @@ -43,8 +43,9 @@ import org.eclipse.swt.widgets.Event; import org.eclipse.swt.widgets.Listener; import org.tizen.dynamicanalyzer.common.AnalyzerManager; import org.tizen.dynamicanalyzer.common.DASelectionData; +import org.tizen.dynamicanalyzer.common.Global; import org.tizen.dynamicanalyzer.model.TreeInput; -import org.tizen.dynamicanalyzer.sql.SqlManager; +import org.tizen.dynamicanalyzer.project.ImageInfo; import org.tizen.dynamicanalyzer.swap.model.data.ControlData; import org.tizen.dynamicanalyzer.swap.model.data.LogData; import org.tizen.dynamicanalyzer.ui.summary.profiling.ProfilingData; @@ -86,16 +87,15 @@ public class UIControlListTable extends DATreeComposite { if (items.length <= 0) { return; } - DATableDataFormat dataFormat = (DATableDataFormat) items[0] - .getData(); + DATableDataFormat dataFormat = (DATableDataFormat) items[0].getData(); ControlData data = (ControlData) dataFormat.getLogData(); - String className = UIDataManager.getInstance() - .getControlDataChecker().getClassName(data); + String className = UIDataManager.getInstance().getControlDataChecker() + .getClassName(data); UIDataManager.getInstance().setTableSeleteClassName(className); long time = getSnapsotForScene(className, data.getTime()); - DASelectionData selData = new DASelectionData( - UIPage.controlListViewID, time, 0, items, table); + DASelectionData selData = new DASelectionData(UIPage.controlListViewID, time, 0, + items, table); AnalyzerManager.getCurrentPage().updateView(selData); setSelfUpdate(true); @@ -139,19 +139,20 @@ public class UIControlListTable extends DATreeComposite { } private long getSnapsotForScene(String className, long strTime) { - Long time = UIDataManager.getInstance().getFindScreenshotViewHashMap() - .get(className); + Long time = UIDataManager.getInstance().getFindScreenshotViewHashMap().get(className); if (null == time) { return strTime; } if (time == -1) { time = strTime; } - long result = SqlManager.getInstance().getLastScreenshotTime(time); - if (result == -1) { - result = strTime; + + ImageInfo lastimg = Global.getLeastImageInfoByTime(strTime); + if (lastimg == null) { + return strTime; + } else { + return lastimg.getTime(); } - return result; } @Override @@ -194,8 +195,7 @@ public class UIControlListTable extends DATreeComposite { public List difference(ArrayList base, ArrayList target) { @SuppressWarnings("unchecked") - ArrayList result = (ArrayList) base - .clone(); + ArrayList result = (ArrayList) base.clone(); result.removeAll(target); return result; } @@ -221,33 +221,28 @@ public class UIControlListTable extends DATreeComposite { output.setParent(Long.toString(input.getParentPointer())); output.setChild(Long.toString(input.getChildPointer())); - String strSelectedClassname = UIDataManager.getInstance() - .getTableSeleteClassName(); + String strSelectedClassname = UIDataManager.getInstance().getTableSeleteClassName(); boolean isUpdate = true; - if ((isSelfUpdate() == true) - && (input.getControlType().trim().equals("Frame") == false)//$NON-NLS-1$ + if ((isSelfUpdate() == true) && (input.getControlType().trim().equals("Frame") == false)//$NON-NLS-1$ && (input.getControlType().trim().equals("Form") == false)//$NON-NLS-1$ && (input.getControlType().trim().equals("Panel") == false)) {//$NON-NLS-1$ isUpdate = false; } - if (strSelectedClassname.equals(input.getCalssKeyName()) - && (isUpdate == true)) { + if (strSelectedClassname.equals(input.getCalssKeyName()) && (isUpdate == true)) { output.setSecondSelection(true); } return output; } // !! recursive!! - public boolean makeChildTree(TreeInput nodeParent, TreeInput currentNode, - int nNodeDepth) { + public boolean makeChildTree(TreeInput nodeParent, TreeInput currentNode, int nNodeDepth) { if (nodeParent.getChild().trim().equals(currentNode.getParent().trim())) { nodeParent.getChildren().add(currentNode); return true; } else { for (int i = 0; i < nodeParent.getChildren().size(); i++) { - if (makeChildTree(nodeParent.getChildren().get(i), currentNode, - nNodeDepth++) == true) { + if (makeChildTree(nodeParent.getChildren().get(i), currentNode, nNodeDepth++) == true) { break; } } @@ -257,8 +252,8 @@ public class UIControlListTable extends DATreeComposite { @Override public List makeTreeInput() { - List controlList = UIDataManager.getInstance() - .getControlDataChecker().getDataList(); + List controlList = UIDataManager.getInstance().getControlDataChecker() + .getDataList(); List output = new ArrayList(); int size = controlList.size(); int nNodeDepth = 0; @@ -296,8 +291,7 @@ public class UIControlListTable extends DATreeComposite { return false; } for (int i = 0; i < index; i++) { - if (controlList.get(i).getChildPointer() == (controlList.get(index) - .getParentPointer())) { + if (controlList.get(i).getChildPointer() == (controlList.get(index).getParentPointer())) { isRootNode = false; break; diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/userinterface/scene/UISceneListTable.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/userinterface/scene/UISceneListTable.java index 7b70b3c..5603944 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/userinterface/scene/UISceneListTable.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/userinterface/scene/UISceneListTable.java @@ -37,8 +37,9 @@ import org.eclipse.swt.widgets.Composite; import org.tizen.dynamicanalyzer.common.AnalyzerConstants; import org.tizen.dynamicanalyzer.common.AnalyzerManager; import org.tizen.dynamicanalyzer.common.DASelectionData; +import org.tizen.dynamicanalyzer.common.Global; import org.tizen.dynamicanalyzer.model.TableInput; -import org.tizen.dynamicanalyzer.sql.SqlManager; +import org.tizen.dynamicanalyzer.project.ImageInfo; import org.tizen.dynamicanalyzer.swap.model.data.SceneData; import org.tizen.dynamicanalyzer.ui.range.RangeDataManager; import org.tizen.dynamicanalyzer.ui.toolbar.ToolbarArea; @@ -86,14 +87,12 @@ public class UISceneListTable extends DATableComposite { } private long getScreensotForScene(long strTime) { - Long result = SqlManager.getInstance().getLastScreenshotTime(strTime); - if (null == result) { + ImageInfo lastimg = Global.getLeastImageInfoByTime(strTime); + if(lastimg == null) { return strTime; + } else { + return lastimg.getTime(); } - if (result == -1) { - result = strTime; - } - return result; } protected List makeTableInput() {