From f16cb935c0d8df09395a706767c9210bea201e22 Mon Sep 17 00:00:00 2001 From: "Hyunjong.park" Date: Wed, 28 Jan 2015 13:13:45 +0900 Subject: [PATCH] DB : improve the sql query method for select, create Signed-off-by: Hyunjong.park Change-Id: I4e7ce823dbfc0f4c7a9e5cff3373f7bdfacb73e2 Signed-off-by: Hyunjong.park --- .../dynamic-analyzer/sql/create_1.0.xml | 31 +++ .../dynamic-analyzer/sql/create_2.0.xml | 30 +++ .../dynamic-analyzer/sql/select_1.0.xml | 29 +++ .../dynamic-analyzer/sql/select_2.0.xml | 29 +++ .../dynamicanalyzer/common/path/PathConstants.java | 1 + .../dynamicanalyzer/common/path/PathManager.java | 2 + .../dynamicanalyzer/common/AnalyzerConstants.java | 5 +- .../common/PostWindowOpenCallback.java | 2 + .../dynamicanalyzer/database/DBQueryXMLParser.java | 224 +++++++++++++++++++++ .../tizen/dynamicanalyzer/database/DBTable.java | 21 +- .../ui/network/NetworkChartBoard.java | 42 +++- .../ui/network/NetworkTableView.java | 65 +++++- .../ui/network/data/NetworkAPIDBManager.java | 186 ++--------------- .../ui/network/data/NetworkDataMaker.java | 1 - .../ui/network/data/NetworkDataManager.java | 75 ++++++- .../ui/network/data/NetworkSeriesDBManager.java | 102 +--------- .../ui/network/data/type/NetworkSeriesType.java | 18 +- .../ui/toolbar/opentrace/OpenTraceDialog.java | 3 +- .../ui/toolbar/opentrace/SaveFilesTable.java | 16 +- 19 files changed, 573 insertions(+), 309 deletions(-) create mode 100644 org.tizen.dynamicanalyzer.workbench/dynamic-analyzer/sql/create_1.0.xml create mode 100644 org.tizen.dynamicanalyzer.workbench/dynamic-analyzer/sql/create_2.0.xml create mode 100644 org.tizen.dynamicanalyzer.workbench/dynamic-analyzer/sql/select_1.0.xml create mode 100644 org.tizen.dynamicanalyzer.workbench/dynamic-analyzer/sql/select_2.0.xml create mode 100644 org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/database/DBQueryXMLParser.java diff --git a/org.tizen.dynamicanalyzer.workbench/dynamic-analyzer/sql/create_1.0.xml b/org.tizen.dynamicanalyzer.workbench/dynamic-analyzer/sql/create_1.0.xml new file mode 100644 index 0000000..df950ae --- /dev/null +++ b/org.tizen.dynamicanalyzer.workbench/dynamic-analyzer/sql/create_1.0.xml @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + diff --git a/org.tizen.dynamicanalyzer.workbench/dynamic-analyzer/sql/create_2.0.xml b/org.tizen.dynamicanalyzer.workbench/dynamic-analyzer/sql/create_2.0.xml new file mode 100644 index 0000000..fbc5e2b --- /dev/null +++ b/org.tizen.dynamicanalyzer.workbench/dynamic-analyzer/sql/create_2.0.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/org.tizen.dynamicanalyzer.workbench/dynamic-analyzer/sql/select_1.0.xml b/org.tizen.dynamicanalyzer.workbench/dynamic-analyzer/sql/select_1.0.xml new file mode 100644 index 0000000..c234102 --- /dev/null +++ b/org.tizen.dynamicanalyzer.workbench/dynamic-analyzer/sql/select_1.0.xml @@ -0,0 +1,29 @@ + + + diff --git a/org.tizen.dynamicanalyzer.workbench/dynamic-analyzer/sql/select_2.0.xml b/org.tizen.dynamicanalyzer.workbench/dynamic-analyzer/sql/select_2.0.xml new file mode 100644 index 0000000..a00c1f0 --- /dev/null +++ b/org.tizen.dynamicanalyzer.workbench/dynamic-analyzer/sql/select_2.0.xml @@ -0,0 +1,29 @@ + + + diff --git a/org.tizen.dynamicanalyzer.workbench/src/org/tizen/dynamicanalyzer/common/path/PathConstants.java b/org.tizen.dynamicanalyzer.workbench/src/org/tizen/dynamicanalyzer/common/path/PathConstants.java index 77b0199..35f7f93 100644 --- a/org.tizen.dynamicanalyzer.workbench/src/org/tizen/dynamicanalyzer/common/path/PathConstants.java +++ b/org.tizen.dynamicanalyzer.workbench/src/org/tizen/dynamicanalyzer/common/path/PathConstants.java @@ -40,6 +40,7 @@ public class PathConstants { public static final String TEMP_FOLDER_NAME = "temp"; //$NON-NLS-1$ public static final String PROJECT_INFO_FILE_NAME = "projectInfo"; //$NON-NLS-1$ public static final String CONFIG_FOLDER_NAME = "config"; //$NON-NLS-1$ + public static final String SQL_FOLDER_NAME = "sql"; //$NON-NLS-1$ public static final String CONFIG_FILE_NAME = "config"; //$NON-NLS-1$ public static final String IDE_FOLDER_NAME = "ide"; //$NON-NLS-1$ public static final String PLUGINS_FOLDER_NAME = "plugins"; //$NON-NLS-1$ diff --git a/org.tizen.dynamicanalyzer.workbench/src/org/tizen/dynamicanalyzer/common/path/PathManager.java b/org.tizen.dynamicanalyzer.workbench/src/org/tizen/dynamicanalyzer/common/path/PathManager.java index 9ddbb50..f8f3f36 100755 --- a/org.tizen.dynamicanalyzer.workbench/src/org/tizen/dynamicanalyzer/common/path/PathManager.java +++ b/org.tizen.dynamicanalyzer.workbench/src/org/tizen/dynamicanalyzer/common/path/PathManager.java @@ -68,6 +68,8 @@ public class PathManager { + PathConstants.RPM_FOLDER_NAME; public static final String DA_CONFIG_FOLDER_PATH = DA_INSTALL_PATH + File.separator + PathConstants.CONFIG_FOLDER_NAME; + public static final String DA_SQL_PATH = DA_INSTALL_PATH + File.separator + + PathConstants.SQL_FOLDER_NAME; public static final String DA_TOOL_FOLDER_PATH = DA_INSTALL_PATH + File.separator + PathConstants.TOOL_FOLDER_NAME; diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/common/AnalyzerConstants.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/common/AnalyzerConstants.java index b478036..345f2f8 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/common/AnalyzerConstants.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/common/AnalyzerConstants.java @@ -31,13 +31,14 @@ import org.tizen.dynamicanalyzer.nl.AnalyzerLabels; public class AnalyzerConstants { // if log change occurs then increase save data version!! - public static final String CURRENT_SAVE_FORMAT_VERSION = "1.0"; //$NON-NLS-1$ - public static final String[] SUPPORTED_SAVE_FORMAT_VERSION = { "1.0" }; //$NON-NLS-1$ + public static final String CURRENT_SAVE_FORMAT_VERSION = "2.0"; //$NON-NLS-1$ + public static final String[] SUPPORTED_SAVE_FORMAT_VERSION = { "1.0","2.0" }; //$NON-NLS-1$ public static final boolean CHECK_INTERNAL = true; public static final String DA_VERSION_SWAP = "3.0"; public static final String DA_VERSION_OLD = "2.2"; public static final String DA_VERSION = "DA-2014-10-07"; + /* folder names */ public static final String TEMP_FOLDER_RUN_PREFIX = ".RUN"; //$NON-NLS-1$ diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/common/PostWindowOpenCallback.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/common/PostWindowOpenCallback.java index 97341e2..1bc46d6 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/common/PostWindowOpenCallback.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/common/PostWindowOpenCallback.java @@ -28,6 +28,7 @@ package org.tizen.dynamicanalyzer.common; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell; import org.tizen.dynamicanalyzer.callback.IExecutionCallback; +import org.tizen.dynamicanalyzer.database.DBQueryXMLParser; import org.tizen.dynamicanalyzer.ui.toolbar.setting.SettingDialog; import org.tizen.dynamicanalyzer.util.Logger; import org.tizen.dynamicanalyzer.util.WorkbenchUtil; @@ -40,6 +41,7 @@ public class PostWindowOpenCallback implements IExecutionCallback { Display.getDefault().asyncExec(new Runnable() { @Override public void run() { + DBQueryXMLParser.initQueryMap(AnalyzerConstants.CURRENT_SAVE_FORMAT_VERSION); final Shell shell = WorkbenchUtil.getWorkbenchWindow().getShell(); SettingDialog dialog = new SettingDialog(shell); Logger.performance("TEST", "DA Start", "Welcome Dialog"); diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/database/DBQueryXMLParser.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/database/DBQueryXMLParser.java new file mode 100644 index 0000000..13fa878 --- /dev/null +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/database/DBQueryXMLParser.java @@ -0,0 +1,224 @@ +/* + * Dynamic Analyzer + * + * Copyright (c) 2000 - 2015 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * Hyunjong Park + * 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.database; + +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.ParserConfigurationException; + +import org.tizen.dynamicanalyzer.common.path.PathManager; +import org.tizen.dynamicanalyzer.constant.CommonConstants; +import org.tizen.dynamicanalyzer.util.Logger; +import org.w3c.dom.Document; +import org.w3c.dom.NamedNodeMap; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; +import org.xml.sax.SAXException; + +public class DBQueryXMLParser { + private static Map selectQueryMap = null; + private static Map> createColumnMap = null; + + private static Thread mapThread = null; + private static String currentDAVersion = null; + + private static final String SELECT_FILE_NAME = "select";//$NON-NLS-1$ + private static final String SELECT = "SELECT";//$NON-NLS-1$ + private static final String FROM = "FROM";//$NON-NLS-1$ + private static final String WHERE = "WHERE";//$NON-NLS-1$ + + private static final String CREATE_FILE_NAME = "create";//$NON-NLS-1$ + private static final String DATA_TYPE = "DATA_TYPE";//$NON-NLS-1$ + private static final String DEFAULT_EXPRESSION = "DEFAULT_EXPRESSION";//$NON-NLS-1$ + private static final String INDEX = "INDEX";//$NON-NLS-1$ + + public static void initQueryMap(String selectedVersion) { + if (null != currentDAVersion && currentDAVersion.equals(selectedVersion)) { + return; + } + currentDAVersion = selectedVersion; + selectQueryMap = new HashMap(); + createColumnMap = new HashMap>(); + updateMapThread(); + } + + public static String getQuery(String queryName) { + if (!selectQueryMap.containsKey(queryName.trim())) { + Logger.error("Not find query : " + queryName); + return CommonConstants.EMPTY; + } + return selectQueryMap.get(queryName.trim()); + } + + public static List getColumn(String tableName) { + if (!createColumnMap.containsKey(tableName.trim())) { + Logger.error("Not find table : " + tableName); + return new ArrayList(); + } + return createColumnMap.get(tableName.trim()); + } + + private static void updateMapThread() { + if (null != mapThread && mapThread.isAlive()) { + Logger.debug("END DB XML Thread"); + mapThread.interrupt(); + } + mapThread = new Thread(new Runnable() { + @Override + public void run() { + updateSelectQueryMap(); + updateCreateColumnMap(); + } + }); + mapThread.start(); + } + + private static void updateSelectQueryMap() { + NodeList quertList = getSQLTableList(SELECT_FILE_NAME); + if (null == quertList) { + Logger.error("Not exist select file : " + SELECT_FILE_NAME); + return; + } + for (int i = 0; i < quertList.getLength(); i++) { + setSelectQuery(quertList.item(i)); + } + return; + } + + private static void setSelectQuery(Node queryNode) { + String variableName = queryNode.getNodeName(); + StringBuffer queryValue = new StringBuffer(); + NamedNodeMap queryAttributes = queryNode.getAttributes(); + if (null == queryAttributes) { + return; + } + queryValue.append(getSelectCommandValue(queryAttributes, SELECT)); + queryValue.append(getSelectCommandValue(queryAttributes, FROM)); + queryValue.append(getSelectCommandValue(queryAttributes, WHERE)); + selectQueryMap.put(variableName.trim(), queryValue.toString()); + } + + private static void updateCreateColumnMap() { + NodeList tableList = getSQLTableList(CREATE_FILE_NAME); + if (null == tableList) { + Logger.error("Not exist create file : " + CREATE_FILE_NAME); + return; + } + for (int i = 0; i < tableList.getLength(); i++) { + setColumn(tableList.item(i)); + } + return; + } + + private static void setColumn(Node tableNadeName) { + NodeList columnNodeList = tableNadeName.getChildNodes(); + List columnList = new ArrayList(); + for (int j = 0; j < columnNodeList.getLength(); j++) { + Node queryNode = columnNodeList.item(j); + String columnName = queryNode.getNodeName(); + NamedNodeMap queryAttributes = queryNode.getAttributes(); + if (null == queryAttributes) { + continue; + } + columnList.add(makeDBColumn(columnName, queryAttributes)); + } + if (columnList.size() > 0) { + createColumnMap.put(tableNadeName.getNodeName().trim(), columnList); + } + } + + private static NodeList getSQLTableList(String command) { + String filePath = getSQLFilePath(command); + DocumentBuilder builder = null; + Document doc = null; + try { + builder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); + doc = builder.parse(filePath); + } catch (ParserConfigurationException e) { + e.printStackTrace(); + } catch (SAXException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } + if (null == doc) { + return null; + } + return doc.getDocumentElement().getChildNodes(); + } + + private static String getSQLFilePath(String type) { + return PathManager.DA_SQL_PATH + File.separator + type + CommonConstants.UNDERBAR + + currentDAVersion + ".xml";//$NON-NLS-1$ + } + + private static DBColumn makeDBColumn(String columnName, NamedNodeMap queryAttributes) { + String dataType = ""; + String defaultExpression = ""; + String index = ""; + if (checkVaildAttributes(queryAttributes, DATA_TYPE)) { + dataType = queryAttributes.getNamedItem(DATA_TYPE).getNodeValue(); + } + if (checkVaildAttributes(queryAttributes, DEFAULT_EXPRESSION)) { + defaultExpression = queryAttributes.getNamedItem(DEFAULT_EXPRESSION).getNodeValue(); + } + if (checkVaildAttributes(queryAttributes, INDEX)) { + index = queryAttributes.getNamedItem(INDEX).getNodeValue(); + } + DBColumn dbColumn = new DBColumn(columnName.trim(), defaultExpression, dataType); + if (!index.equals(CommonConstants.EMPTY)) { + dbColumn.setIndex(true); + } else { + dbColumn.setIndex(false); + } + return dbColumn; + } + + private static String getSelectCommandValue(NamedNodeMap queryAttributes, String commandName) { + if (checkVaildAttributes(queryAttributes, commandName)) { + return CommonConstants.SPACE + commandName + CommonConstants.SPACE + + queryAttributes.getNamedItem(commandName).getNodeValue(); + } + return CommonConstants.EMPTY; + } + + private static boolean checkVaildAttributes(NamedNodeMap queryAttributes, String commandName) { + String attributesValue = queryAttributes.getNamedItem(commandName).getNodeValue(); + if (!attributesValue.equals(CommonConstants.EMPTY)) { + return true; + } else { + return false; + } + } +} diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/database/DBTable.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/database/DBTable.java index 7e8ef34..116e801 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/database/DBTable.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/database/DBTable.java @@ -50,11 +50,14 @@ public abstract class DBTable implements IPreparedStatement, IResultSet { } public final List getColumns() { + if (columns.size() == 0) { + columns = DBQueryXMLParser.getColumn(getTableName()); + } return columns; } public final int getColumnSize() { - return columns.size(); + return getColumns().size(); } protected final void addColumn(DBColumn col) { @@ -82,9 +85,9 @@ public abstract class DBTable implements IPreparedStatement, IResultSet { query.append(getTableName()); query.append(CommonConstants.SPACE + CommonConstants.OPEN_BRACKET); - int size = columns.size(); + int size = getColumnSize(); for (int i = 0; i < size; i++) { - query.append(columns.get(i).getColumnString()); + query.append(getColumns().get(i).getColumnString()); if (i == size - 1) { query.append(CommonConstants.CLOSE_BRACKET); } else { @@ -102,7 +105,7 @@ public abstract class DBTable implements IPreparedStatement, IResultSet { StringBuffer query = new StringBuffer(); query.append("insert into ").append(getTableName()).append(" values( "); - int columnsize = columns.size(); + int columnsize = getColumnSize(); for (int i = 0; i < columnsize; i++) { if (i == columnsize - 1) { query.append(" ? )"); @@ -135,9 +138,9 @@ public abstract class DBTable implements IPreparedStatement, IResultSet { query.append(", ");//$NON-NLS-1$ } } else { - int columnsize = columns.size(); + int columnsize = getColumnSize(); for (int i = 0; i < columnsize; i++) { - query.append(columns.get(i).getName()); + query.append(getColumns().get(i).getName()); if (i < columnsize - 1) query.append(", ");//$NON-NLS-1$ } @@ -169,15 +172,15 @@ public abstract class DBTable implements IPreparedStatement, IResultSet { } public final void createIndexTable() { - int size = columns.size(); + int size = getColumnSize(); StringBuffer indexColumns = new StringBuffer(); for (int i = 0; i < size; i++) { - if (columns.get(i).isIndex()) { + if (getColumns().get(i).isIndex()) { if (indexColumns.length() > 0) { indexColumns.append(", "); } - indexColumns.append(columns.get(i).getName()); + indexColumns.append(getColumns().get(i).getName()); } } diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/network/NetworkChartBoard.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/network/NetworkChartBoard.java index 0e1312a..86f6bac 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/network/NetworkChartBoard.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/network/NetworkChartBoard.java @@ -26,6 +26,8 @@ package org.tizen.dynamicanalyzer.ui.network; +import java.sql.ResultSet; +import java.sql.SQLException; import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.List; @@ -33,6 +35,8 @@ import java.util.List; import org.eclipse.swt.widgets.Composite; import org.tizen.dynamicanalyzer.common.AnalyzerManager; import org.tizen.dynamicanalyzer.constant.CommonConstants; +import org.tizen.dynamicanalyzer.database.DBQueryXMLParser; +import org.tizen.dynamicanalyzer.database.SqlConnectionManager; import org.tizen.dynamicanalyzer.nl.NetworkPageLabels; import org.tizen.dynamicanalyzer.nl.ThreadPageLabels; import org.tizen.dynamicanalyzer.nl.TimelineChartLabels; @@ -75,6 +79,8 @@ public class NetworkChartBoard extends DAChartBoard { private int preSelectionPId = -1; + private String networkAPISelectChartSeriesQuery = CommonConstants.EMPTY; + public NetworkChartBoard(Composite parent, String title) { super(parent, title); initIntervalMarkers(); @@ -149,6 +155,9 @@ public class NetworkChartBoard extends DAChartBoard { parentChartIndex = -1; lastChildChartIndexOfEachParent = new LinkedHashMap(); preSelectionPId = -1; + + networkAPISelectChartSeriesQuery = DBQueryXMLParser + .getQuery("NETWORK_API_SELECT_CHART_SERIES_QUERY"); } public void initIntervalMarkers() { @@ -360,8 +369,7 @@ public class NetworkChartBoard extends DAChartBoard { } public void updateApiSeries() { - List apiList = NetworkDataManager.getInstance().getAPIDBManger() - .selectAPISeries(getVisibleStartTime(), getVisibleEndTime()); + List apiList = selectAPISeries(getVisibleStartTime(), getVisibleEndTime()); if (null == apiList) { return; } @@ -370,6 +378,36 @@ public class NetworkChartBoard extends DAChartBoard { } } + public List selectAPISeries(double visibleStartTime, double visibleEndTime) { + double selectStartTime = visibleStartTime * TimelineConstants.MEGA_DOUBLE; + double selectEndTime = visibleEndTime * TimelineConstants.MEGA_DOUBLE; + String query = String.format(networkAPISelectChartSeriesQuery, selectStartTime, + selectEndTime); + ResultSet rs = SqlConnectionManager.executeQueryRS(query); + if (rs == null) { + SqlConnectionManager.releaseResultSet(rs); + return null; + } + List returnValue = new ArrayList(); + try { + while (rs.next()) { + int selectIndex = 1; + NetworkAPIType data = new NetworkAPIType(); + data.setSeq(rs.getLong(selectIndex++)); + data.setDestinationAddress(rs.getString(selectIndex++)); + data.setFdStr(rs.getString(selectIndex++)); + data.setTime(rs.getLong(selectIndex++)); + data.setApiId(rs.getInt(selectIndex++)); + data.setErrNo(rs.getLong(selectIndex++)); + returnValue.add(data); + } + SqlConnectionManager.releaseResultSet(rs); + } catch (SQLException e) { + e.printStackTrace(); + } + return returnValue; + } + public void updateSeries() { if (null == chartItemList) { return; diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/network/NetworkTableView.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/network/NetworkTableView.java index 1a31cb3..4a73558 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/network/NetworkTableView.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/network/NetworkTableView.java @@ -27,15 +27,24 @@ package org.tizen.dynamicanalyzer.ui.network; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.List; + import org.eclipse.swt.SWT; import org.eclipse.swt.layout.FillLayout; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.tizen.dynamicanalyzer.common.AnalyzerConstants; import org.tizen.dynamicanalyzer.common.DASelectionData; +import org.tizen.dynamicanalyzer.constant.CommonConstants; +import org.tizen.dynamicanalyzer.database.DBQueryXMLParser; +import org.tizen.dynamicanalyzer.database.SqlConnectionManager; import org.tizen.dynamicanalyzer.nl.NetworkPageLabels; import org.tizen.dynamicanalyzer.resources.ColorResources; import org.tizen.dynamicanalyzer.ui.network.data.NetworkDataManager; +import org.tizen.dynamicanalyzer.ui.network.data.type.NetworkAPIType; import org.tizen.dynamicanalyzer.ui.network.data.type.NetworkSelectionType; import org.tizen.dynamicanalyzer.ui.range.RangeDataManager; import org.tizen.dynamicanalyzer.ui.toolbar.ToolbarArea; @@ -52,6 +61,9 @@ public class NetworkTableView extends DAViewComposite { private boolean isChangedSelected = true; private int preSelectionPId = 1; + private String networkAPISelectTableChildQuery = CommonConstants.EMPTY; + private String networkAPISelectTableParentQuery = CommonConstants.EMPTY; + public enum COLUMN { INDEX(0, NetworkPageLabels.NETWORK_API_LIST_VIEW_INDEX), START_TIME(1, NetworkPageLabels.NETWORK_API_LIST_VIEW_START_TIME), ELASPSED_TIME(2, @@ -115,6 +127,7 @@ public class NetworkTableView extends DAViewComposite { tableComp.setColumnSize(columnSizes); tableComp.setTableName(NetworkPageLabels.NETWORK_API_LIST_VIEW_TITLE); contents.addControlListener(new TableColumnSizePackListener(tableComp, columnSizes)); + } @Override @@ -181,11 +194,8 @@ public class NetworkTableView extends DAViewComposite { return; } NetworkDataManager.getInstance().setSelectedTableAPIList( - NetworkDataManager - .getInstance() - .getAPIDBManger() - .selectAPITable(netSelection.getAddress(), netSelection.getFd(), - netSelection.isParentChart())); + selectAPITable(netSelection.getAddress(), netSelection.getFd(), + netSelection.isParentChart())); tableComp.updateTable(); tableComp.setSelectionByTime(selectionStartTime, selectionEndTime); isChangedSelected = true; @@ -195,6 +205,46 @@ public class NetworkTableView extends DAViewComposite { } } + public List selectAPITable(String address, String fd, boolean isParentChart) { + String query = String.format(networkAPISelectTableChildQuery, address.trim(), fd.trim()); + if (isParentChart) { + query = String.format(networkAPISelectTableParentQuery, address.trim()); + } + + ResultSet rs = SqlConnectionManager.executeQueryRS(query); + if (rs == null) { + SqlConnectionManager.releaseResultSet(rs); + return null; + } + List returnValue = new ArrayList(); + try { + while (rs.next()) { + int selectIndex = 1; + NetworkAPIType data = new NetworkAPIType(); + data.setSeq(rs.getLong(selectIndex++)); + data.setDestinationAddress(rs.getString(selectIndex++)); + data.setFdStr(rs.getString(selectIndex++)); + data.setTime(rs.getLong(selectIndex++)); + data.setApiId(rs.getInt(selectIndex++)); + data.setErrNo(rs.getLong(selectIndex++)); + data.setPid(rs.getInt(selectIndex++)); + data.setTid(rs.getInt(selectIndex++)); + data.setArgs(rs.getString(selectIndex++)); + data.setReturn(rs.getString(selectIndex++)); + data.setPacketMessageSize(rs.getInt(selectIndex++)); + data.setPacketMessage(rs.getString(selectIndex++)); + data.setFdApiType(rs.getInt(selectIndex++)); + data.setCallerAddress(rs.getLong(selectIndex++)); + data.setBinaryId(rs.getInt(selectIndex++)); + returnValue.add(data); + } + SqlConnectionManager.releaseResultSet(rs); + } catch (SQLException e) { + e.printStackTrace(); + } + return returnValue; + } + @Override public Control getControl() { return tableComp; @@ -203,6 +253,11 @@ public class NetworkTableView extends DAViewComposite { @Override public void clear() { tableComp.getTable().removeAll(); + + networkAPISelectTableChildQuery = DBQueryXMLParser + .getQuery("NETWORK_API_SELECT_TABLE_CHILD_QUERY"); + networkAPISelectTableParentQuery = DBQueryXMLParser + .getQuery("NETWORK_API_SELECT_TABLE_PARENT_QUERY"); } public long getRangeStartTime() { diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/network/data/NetworkAPIDBManager.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/network/data/NetworkAPIDBManager.java index 52f6fa2..8a17957 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/network/data/NetworkAPIDBManager.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/network/data/NetworkAPIDBManager.java @@ -27,178 +27,26 @@ package org.tizen.dynamicanalyzer.ui.network.data; import java.sql.PreparedStatement; -import java.sql.ResultSet; import java.sql.SQLException; -import java.util.ArrayList; import java.util.List; -import org.tizen.dynamicanalyzer.constant.CommonConstants; -import org.tizen.dynamicanalyzer.database.DBColumn; -import org.tizen.dynamicanalyzer.database.DBConstants; import org.tizen.dynamicanalyzer.database.DBTable; -import org.tizen.dynamicanalyzer.database.SqlConnectionManager; -import org.tizen.dynamicanalyzer.ui.network.data.type.NetworkAPIType; -import org.tizen.dynamicanalyzer.ui.timeline.common.TimelineConstants; public class NetworkAPIDBManager extends DBTable { private static final String TABLENAME = "NETWORK_API"; //$NON-NLS-1$ - public static final String SEQ = DBConstants.COMMON_COLUMN_SEQ; - public static final String DESTINATION_ADDRESS = "DESTINATION_ADDRESS"; //$NON-NLS-1$ - public static final String FD_VALUE = "FD_VALUE"; //$NON-NLS-1$ - public static final String API_TIME = DBConstants.COMMON_COLUMN_TIME; - public static final String API_NAME_ID = DBConstants.COMMON_COLUMN_ID; - public static final String ERRNO = DBConstants.COMMON_COLUMN_ERROR; - public static final String PID = DBConstants.COMMON_COLUMN_PID; - public static final String TID = DBConstants.COMMON_COLUMN_TID; - public static final String ARGUMENT = DBConstants.COMMON_COLUMN_ARG; - public static final String RETURN = DBConstants.COMMON_COLUMN_RET; - public static final String BYTE_SIZE = "BYTE_SIZE"; //$NON-NLS-1$ - public static final String PAYLOAD = "PAYLOAD"; //$NON-NLS-1$ - public static final String API_TYPE = "API_TYPE"; //$NON-NLS-1$ - public static final String CALLER_PC_ADDRESS = DBConstants.COMMON_COLUMN_CALLER_PC_ADDRESS; - public static final String LIB_NAME = DBConstants.COMMON_COLUMN_CALLER_LIB_NAME; - - public static final int DB_SEQ_INDEX = 0; - public static final int DB_DESTINATION_ADDRESS_INDEX = 1; - public static final int DB_FD_VALUE_INDEX = 2; - public static final int DB_API_TIME_INDEX = 3; - public static final int DB_API_NAME_ID_INDEX = 4; - public static final int DB_ERRNO_INDEX = 5; - public static final int DB_PID_INDEX = 6; - public static final int DB_TID_INDEX = 7; - public static final int DB_ARGUMENT_INDEX = 8; - public static final int DB_RETURN_INDEX = 9; - public static final int DB_BYTE_SIZE_INDEX = 10; - public static final int DB_PAYLOAD_INDEX = 11; - public static final int DB_API_TYPE_INDEX = 12; - public static final int DB_CALLER_PC_ADDRESS_INDEX = 13; - public static final int DB_LIB_NAME_INDEX = 14; - - private static final String SELECT_API_SERIES_QUERY = "select " //$NON-NLS-1$ - + SEQ + CommonConstants.COMMA + DESTINATION_ADDRESS + CommonConstants.COMMA - + FD_VALUE - + CommonConstants.COMMA + API_TIME + CommonConstants.COMMA - + API_NAME_ID - + CommonConstants.COMMA + ERRNO + " from " //$NON-NLS-1$ - + TABLENAME + " where " + API_TIME + " BETWEEN %s and %s";//$NON-NLS-1$ - - private static final String SELECT_API_TABLE_CHILD_QUERY = "select " + SEQ//$NON-NLS-1$ - + CommonConstants.COMMA + DESTINATION_ADDRESS + CommonConstants.COMMA + FD_VALUE - + CommonConstants.COMMA + API_TIME + CommonConstants.COMMA + API_NAME_ID - + CommonConstants.COMMA + ERRNO + CommonConstants.COMMA + PID + CommonConstants.COMMA - + TID + CommonConstants.COMMA + ARGUMENT + CommonConstants.COMMA + RETURN - + CommonConstants.COMMA + BYTE_SIZE + CommonConstants.COMMA + PAYLOAD - + CommonConstants.COMMA + API_TYPE + CommonConstants.COMMA + CALLER_PC_ADDRESS - + CommonConstants.COMMA + LIB_NAME + " from "//$NON-NLS-1$ - + TABLENAME + " where " + DESTINATION_ADDRESS + " = '%s' and "//$NON-NLS-1$ - + FD_VALUE + " = '%s'";//$NON-NLS-1$ - - private static final String SELECT_API_TABLE_PARENT_QUERY = "select " + SEQ//$NON-NLS-1$ - + CommonConstants.COMMA + DESTINATION_ADDRESS + CommonConstants.COMMA + FD_VALUE - + CommonConstants.COMMA + API_TIME + CommonConstants.COMMA + API_NAME_ID - + CommonConstants.COMMA + ERRNO + CommonConstants.COMMA + PID + CommonConstants.COMMA - + TID + CommonConstants.COMMA + ARGUMENT + CommonConstants.COMMA + RETURN - + CommonConstants.COMMA + BYTE_SIZE + CommonConstants.COMMA + PAYLOAD - + CommonConstants.COMMA + API_TYPE + CommonConstants.COMMA + CALLER_PC_ADDRESS - + CommonConstants.COMMA + LIB_NAME + " from "//$NON-NLS-1$ - + TABLENAME + " where " + DESTINATION_ADDRESS + " = '%s'";//$NON-NLS-1$ //$NON-NLS-2$ - @Override public String getTableName() { return TABLENAME; } public NetworkAPIDBManager() { - addColumn(new DBColumn(SEQ, DBConstants.PRIMARY_KEY, DBConstants.LONG)); - addColumn(new DBColumn(DESTINATION_ADDRESS, DBConstants.NOT_NULL, DBConstants.BIG_TEXT)); - addColumn(new DBColumn(FD_VALUE, DBConstants.NOT_NULL, DBConstants.TEXT)); - addColumn(new DBColumn(API_TIME, DBConstants.NOT_NULL, DBConstants.LONG)); - addColumn(new DBColumn(API_NAME_ID, DBConstants.NOT_NULL, DBConstants.INTEGER)); - addColumn(new DBColumn(ERRNO, DBConstants.NOT_NULL, DBConstants.LONG)); - addColumn(new DBColumn(PID, DBConstants.NOT_NULL, DBConstants.INTEGER)); - addColumn(new DBColumn(TID, DBConstants.NOT_NULL, DBConstants.INTEGER)); - addColumn(new DBColumn(ARGUMENT, DBConstants.NOT_NULL, DBConstants.BIG_TEXT)); - addColumn(new DBColumn(RETURN, DBConstants.NOT_NULL, DBConstants.BIG_TEXT)); - addColumn(new DBColumn(BYTE_SIZE, DBConstants.NOT_NULL, DBConstants.INTEGER)); - addColumn(new DBColumn(PAYLOAD, DBConstants.NOT_NULL, DBConstants.BIG_TEXT)); - addColumn(new DBColumn(API_TYPE, DBConstants.NOT_NULL, DBConstants.INTEGER)); - addColumn(new DBColumn(CALLER_PC_ADDRESS, DBConstants.NOT_NULL, DBConstants.LONG)); - addColumn(new DBColumn(LIB_NAME, DBConstants.NOT_NULL, DBConstants.INTEGER)); - setIndexColumn(DB_API_TIME_INDEX); } public void insert(List> insetData) { insertData(insetData); } - public List selectAPISeries(double visibleStartTime, double visibleEndTime) { - double selectStartTime = visibleStartTime * TimelineConstants.MEGA_DOUBLE; - double selectEndTime = visibleEndTime * TimelineConstants.MEGA_DOUBLE; - String query = String.format(SELECT_API_SERIES_QUERY, selectStartTime, selectEndTime); - ResultSet rs = SqlConnectionManager.executeQueryRS(query); - if (rs == null) { - SqlConnectionManager.releaseResultSet(rs); - return null; - } - List returnValue = new ArrayList(); - try { - while (rs.next()) { - NetworkAPIType data = new NetworkAPIType(); - data.setSeq(rs.getLong(DB_SEQ_INDEX + 1)); - data.setDestinationAddress(rs.getString(DB_DESTINATION_ADDRESS_INDEX + 1)); - data.setFdStr(rs.getString(DB_FD_VALUE_INDEX + 1)); - data.setTime(rs.getLong(DB_API_TIME_INDEX + 1)); - data.setApiId(rs.getInt(DB_API_NAME_ID_INDEX + 1)); - data.setErrNo(rs.getLong(DB_ERRNO_INDEX + 1)); - returnValue.add(data); - } - SqlConnectionManager.releaseResultSet(rs); - } catch (SQLException e) { - e.printStackTrace(); - } - return returnValue; - } - - public List selectAPITable(String address, String fd, boolean isParentChart) { - String query = String.format(SELECT_API_TABLE_CHILD_QUERY, address.trim(), fd.trim()); - if (isParentChart) { - query = String.format(SELECT_API_TABLE_PARENT_QUERY, address.trim()); - } - - ResultSet rs = SqlConnectionManager.executeQueryRS(query); - if (rs == null) { - SqlConnectionManager.releaseResultSet(rs); - return null; - } - List returnValue = new ArrayList(); - try { - while (rs.next()) { - NetworkAPIType data = new NetworkAPIType(); - data.setSeq(rs.getLong(DB_SEQ_INDEX + 1)); - data.setDestinationAddress(rs.getString(DB_DESTINATION_ADDRESS_INDEX + 1)); - data.setFdStr(rs.getString(DB_FD_VALUE_INDEX + 1)); - data.setTime(rs.getLong(DB_API_TIME_INDEX + 1)); - data.setApiId(rs.getInt(DB_API_NAME_ID_INDEX + 1)); - data.setErrNo(rs.getLong(DB_ERRNO_INDEX + 1)); - data.setPid(rs.getInt(DB_PID_INDEX + 1)); - data.setTid(rs.getInt(DB_TID_INDEX + 1)); - data.setArgs(rs.getString(DB_ARGUMENT_INDEX + 1)); - data.setReturn(rs.getString(DB_RETURN_INDEX + 1)); - data.setPacketMessageSize(rs.getInt(DB_BYTE_SIZE_INDEX + 1)); - data.setPacketMessage(rs.getString(DB_PAYLOAD_INDEX + 1)); - data.setFdApiType(rs.getInt(DB_API_TYPE_INDEX + 1)); - data.setCallerAddress(rs.getLong(DB_CALLER_PC_ADDRESS_INDEX + 1)); - data.setBinaryId(rs.getInt(DB_LIB_NAME_INDEX + 1)); - returnValue.add(data); - } - SqlConnectionManager.releaseResultSet(rs); - } catch (SQLException e) { - e.printStackTrace(); - } - return returnValue; - } - @Override public boolean prepare(PreparedStatement prep, List rowData) { boolean isPrepared = true; @@ -207,24 +55,22 @@ public class NetworkAPIDBManager extends DBTable { isPrepared = false; } else { try { - prep.setLong(DB_SEQ_INDEX + 1, (Long) (rowData.get(DB_SEQ_INDEX))); - prep.setString(DB_DESTINATION_ADDRESS_INDEX + 1, - (String) (rowData.get(DB_DESTINATION_ADDRESS_INDEX))); - prep.setString(DB_FD_VALUE_INDEX + 1, (String) (rowData.get(DB_FD_VALUE_INDEX))); - prep.setLong(DB_API_TIME_INDEX + 1, (Long) (rowData.get(DB_API_TIME_INDEX))); - prep.setInt(DB_API_NAME_ID_INDEX + 1, (Integer) (rowData.get(DB_API_NAME_ID_INDEX))); - prep.setLong(DB_ERRNO_INDEX + 1, (Long) (rowData.get(DB_ERRNO_INDEX))); - prep.setInt(DB_PID_INDEX + 1, (Integer) (rowData.get(DB_PID_INDEX))); - prep.setInt(DB_TID_INDEX + 1, (Integer) (rowData.get(DB_TID_INDEX))); - prep.setString(DB_ARGUMENT_INDEX + 1, (String) (rowData.get(DB_ARGUMENT_INDEX))); - prep.setString(DB_RETURN_INDEX + 1, (String) (rowData.get(DB_RETURN_INDEX))); - prep.setInt(DB_BYTE_SIZE_INDEX + 1, (Integer) (rowData.get(DB_BYTE_SIZE_INDEX))); - prep.setString(DB_PAYLOAD_INDEX + 1, (String) (rowData.get(DB_PAYLOAD_INDEX))); - prep.setInt(DB_API_TYPE_INDEX + 1, (Integer) (rowData.get(DB_API_TYPE_INDEX))); - prep.setLong(DB_CALLER_PC_ADDRESS_INDEX + 1, - (Long) (rowData.get(DB_CALLER_PC_ADDRESS_INDEX))); - prep.setInt(DB_LIB_NAME_INDEX + 1, (Integer) (rowData.get(DB_LIB_NAME_INDEX))); - + int selectIndex = 0; + prep.setLong(selectIndex + 1, (Long) (rowData.get(selectIndex++))); + prep.setString(selectIndex + 1, (String) (rowData.get(selectIndex++))); + prep.setString(selectIndex + 1, (String) (rowData.get(selectIndex++))); + prep.setLong(selectIndex + 1, (Long) (rowData.get(selectIndex++))); + prep.setInt(selectIndex + 1, (Integer) (rowData.get(selectIndex++))); + prep.setLong(selectIndex + 1, (Long) (rowData.get(selectIndex++))); + prep.setInt(selectIndex + 1, (Integer) (rowData.get(selectIndex++))); + prep.setInt(selectIndex + 1, (Integer) (rowData.get(selectIndex++))); + prep.setString(selectIndex + 1, (String) (rowData.get(selectIndex++))); + prep.setString(selectIndex + 1, (String) (rowData.get(selectIndex++))); + prep.setInt(selectIndex + 1, (Integer) (rowData.get(selectIndex++))); + prep.setString(selectIndex + 1, (String) (rowData.get(selectIndex++))); + prep.setInt(selectIndex + 1, (Integer) (rowData.get(selectIndex++))); + prep.setLong(selectIndex + 1, (Long) (rowData.get(selectIndex++))); + prep.setInt(selectIndex + 1, (Integer) (rowData.get(selectIndex++))); } catch (SQLException e) { e.printStackTrace(); isPrepared = false; diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/network/data/NetworkDataMaker.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/network/data/NetworkDataMaker.java index ab73fbe..2134779 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/network/data/NetworkDataMaker.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/network/data/NetworkDataMaker.java @@ -84,7 +84,6 @@ public class NetworkDataMaker { } NetworkDataManager.getInstance().getAPIDBManger().insert(insetApiSeriesData); destinationApiSeriesList.removeAll(removeEventQueue); - } private void addFailedAPIData(NetworkData logs) { diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/network/data/NetworkDataManager.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/network/data/NetworkDataManager.java index eadb800..981e0c9 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/network/data/NetworkDataManager.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/network/data/NetworkDataManager.java @@ -27,12 +27,17 @@ package org.tizen.dynamicanalyzer.ui.network.data; +import java.sql.ResultSet; +import java.sql.SQLException; import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import org.tizen.dynamicanalyzer.common.DALimit; +import org.tizen.dynamicanalyzer.constant.CommonConstants; +import org.tizen.dynamicanalyzer.database.DBQueryXMLParser; +import org.tizen.dynamicanalyzer.database.SqlConnectionManager; import org.tizen.dynamicanalyzer.swap.channel.data.DataChannelConstants; import org.tizen.dynamicanalyzer.swap.logparser.LogPackage; import org.tizen.dynamicanalyzer.swap.logparser.Logs; @@ -40,6 +45,8 @@ import org.tizen.dynamicanalyzer.swap.logparser.PageDataManager; import org.tizen.dynamicanalyzer.swap.model.data.LogData; import org.tizen.dynamicanalyzer.ui.network.data.type.NetworkAPIType; import org.tizen.dynamicanalyzer.ui.network.data.type.NetworkSeriesType; +import org.tizen.dynamicanalyzer.ui.timeline.common.TimelineConstants; +import org.tizen.dynamicanalyzer.ui.toolbar.ToolbarArea; public class NetworkDataManager extends PageDataManager { public final static int MAX_CHART_TIME = 999999999; @@ -68,9 +75,11 @@ public class NetworkDataManager extends PageDataManager { private int chartCount = 0; private int accessSeriesSize = 0; + private String networkSeriesChartSelectQuery = CommonConstants.EMPTY; + private String networkSeriesChartSelectPidQuery = CommonConstants.EMPTY; + public NetworkDataManager() { networkDataMaker = new NetworkDataMaker(); - apiDBManager = new NetworkAPIDBManager(); seriesDBManager = new NetworkSeriesDBManager(); } @@ -91,6 +100,11 @@ public class NetworkDataManager extends PageDataManager { chartCount = 0; accessSeriesSize = 0; networkDataMaker.clear(); + + networkSeriesChartSelectQuery = DBQueryXMLParser + .getQuery("NETWORK_SERIES_CHART_SELECT_QUERY"); + networkSeriesChartSelectPidQuery = DBQueryXMLParser + .getQuery("NETWORK_SERIES_CHART_SELECT_PID_QUERY"); } public LinkedHashMap getCheckStatusSeries() { @@ -138,10 +152,49 @@ public class NetworkDataManager extends PageDataManager { return; } if (seriesList.size() == 0) { - seriesList = seriesDBManager.select(0, MAX_CHART_TIME); + seriesList = select(0, MAX_CHART_TIME); } } + public List select(double visibleStartTime, double visibleEndTime) { + String selectQuery = networkSeriesChartSelectQuery; + int selectedPid = ToolbarArea.getInstance().getSelectedPid(); + if (selectedPid != 0) { + selectQuery = String.format(networkSeriesChartSelectPidQuery, selectedPid); + } + + double selectStartTime = visibleStartTime * TimelineConstants.MEGA_DOUBLE; + double selectEndTime = visibleEndTime * TimelineConstants.MEGA_DOUBLE; + String query = String.format(selectQuery, selectStartTime, selectEndTime); + ResultSet rs = SqlConnectionManager.executeQueryRS(query); + if (rs == null) { + SqlConnectionManager.releaseResultSet(rs); + return null; + } + + List statusSeriesList = new ArrayList(); + try { + while (rs.next()) { + NetworkSeriesType data = new NetworkSeriesType(); + int selectIndex = 1; + data.setRid(rs.getInt(selectIndex++)); + data.setDestinationAddress(rs.getString(selectIndex++)); + data.setFdValue(rs.getString(selectIndex++)); + data.setStartTime(rs.getLong(selectIndex++)); + data.setEndTime(rs.getLong(selectIndex++)); + data.setAPIType(rs.getInt(selectIndex++)); + data.setApiID(rs.getInt(selectIndex++)); + data.setpId(rs.getInt(selectIndex++)); + statusSeriesList.add(data); + } + SqlConnectionManager.releaseResultSet(rs); + } catch (SQLException e) { + e.printStackTrace(); + } + return statusSeriesList; + + } + public void stopProcess() { if (null == seriesList || null == seriesDBManager) { return; @@ -219,15 +272,15 @@ public class NetworkDataManager extends PageDataManager { /*** make network data thread ***/ @Override protected void makeData(LogPackage pack) { -// try { - Logs logs = pack.getLogs(DataChannelConstants.MSG_PROBE_NETWORK); - if (null != logs && logs.getRawLogs().size() != 0) { - List inputs = logs.getLogs(); + // try { + Logs logs = pack.getLogs(DataChannelConstants.MSG_PROBE_NETWORK); + if (null != logs && logs.getRawLogs().size() != 0) { + List inputs = logs.getLogs(); - networkDataMaker.makeData(inputs); - } -// } catch (Exception e) { -// Logger.error("exception network updateView"); -// } + networkDataMaker.makeData(inputs); + } + // } catch (Exception e) { + // Logger.error("exception network updateView"); + // } } } diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/network/data/NetworkSeriesDBManager.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/network/data/NetworkSeriesDBManager.java index aea9c57..0c5f945 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/network/data/NetworkSeriesDBManager.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/network/data/NetworkSeriesDBManager.java @@ -27,50 +27,15 @@ package org.tizen.dynamicanalyzer.ui.network.data; import java.sql.PreparedStatement; -import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; import java.util.List; -import org.tizen.dynamicanalyzer.constant.CommonConstants; -import org.tizen.dynamicanalyzer.database.DBColumn; -import org.tizen.dynamicanalyzer.database.DBConstants; import org.tizen.dynamicanalyzer.database.DBTable; -import org.tizen.dynamicanalyzer.database.SqlConnectionManager; import org.tizen.dynamicanalyzer.ui.network.data.type.NetworkSeriesType; -import org.tizen.dynamicanalyzer.ui.timeline.common.TimelineConstants; -import org.tizen.dynamicanalyzer.ui.toolbar.ToolbarArea; public class NetworkSeriesDBManager extends DBTable { private static final String TABLENAME = " NETWORK_SERIES"; //$NON-NLS-1$ - public static final String RID = "RID"; - public static final String DESTINATION_ADDRESS = "DESTINATION_ADDRESS"; //$NON-NLS-1$ - public static final String FD_VALUE = "FD_VALUE"; //$NON-NLS-1$ - public static final String START_TIME = "START_TIME"; //$NON-NLS-1$ - public static final String END_TIME = "END_TIME"; //$NON-NLS-1$ - public static final String STATUS_TYPE = "STATUS_TYPE"; //$NON-NLS-1$ - public static final String API_ID = DBConstants.COMMON_COLUMN_ID; - public static final String PID = DBConstants.COMMON_COLUMN_PID; - - public final static int DB_RID_INDEX = 0; - public final static int DB_DESTINATION_ADDRESSINDEX = 1; - public final static int DB_FD_VALUE_INDEX = 2; - public final static int DB_START_TIME_INDEX = 3; - public final static int DB_END_TIME_INDEX = 4; - public final static int DB_STATUS_TYPE_INDEX = 5; - public final static int DB_API_ID_INDEX = 6; - public final static int DB_PID_INDEX = 7; - - private static final String SELECT_QUERY = "select " + RID + CommonConstants.COMMA - + DESTINATION_ADDRESS + CommonConstants.COMMA + FD_VALUE + CommonConstants.COMMA - + START_TIME + CommonConstants.COMMA + END_TIME + CommonConstants.COMMA + STATUS_TYPE - + CommonConstants.COMMA + API_ID + CommonConstants.COMMA + PID + " from " + TABLENAME; //$NON-NLS-1$ - - private static final String SELECT_PID_QUERY = "select " + RID + CommonConstants.COMMA - + DESTINATION_ADDRESS + CommonConstants.COMMA + FD_VALUE + CommonConstants.COMMA - + START_TIME + CommonConstants.COMMA + END_TIME + CommonConstants.COMMA + STATUS_TYPE - + CommonConstants.COMMA + API_ID + CommonConstants.COMMA + PID - + " from " + TABLENAME + " where pid = '%s'"; //$NON-NLS-1$ private static int rid = 0; @@ -80,14 +45,6 @@ public class NetworkSeriesDBManager extends DBTable { } public NetworkSeriesDBManager() { - addColumn(new DBColumn(RID, DBConstants.PRIMARY_KEY, DBConstants.INTEGER)); - addColumn(new DBColumn(DESTINATION_ADDRESS, DBConstants.NOT_NULL, DBConstants.TEXT)); - addColumn(new DBColumn(FD_VALUE, DBConstants.NOT_NULL, DBConstants.TEXT)); - addColumn(new DBColumn(START_TIME, DBConstants.NOT_NULL, DBConstants.LONG)); - addColumn(new DBColumn(END_TIME, DBConstants.NOT_NULL, DBConstants.LONG)); - addColumn(new DBColumn(STATUS_TYPE, DBConstants.NOT_NULL, DBConstants.INTEGER)); - addColumn(new DBColumn(API_ID, DBConstants.NOT_NULL, DBConstants.INTEGER)); - addColumn(new DBColumn(PID, DBConstants.NOT_NULL, DBConstants.INTEGER)); rid = 0; } @@ -98,44 +55,6 @@ public class NetworkSeriesDBManager extends DBTable { insertData(insertDataList); } - public List select(double visibleStartTime, double visibleEndTime) { - String selectQuery = SELECT_QUERY; - int selectedPid = ToolbarArea.getInstance().getSelectedPid(); - if (selectedPid != 0) { - selectQuery = String.format(SELECT_PID_QUERY, selectedPid); - } - - double selectStartTime = visibleStartTime * TimelineConstants.MEGA_DOUBLE; - double selectEndTime = visibleEndTime * TimelineConstants.MEGA_DOUBLE; - String query = String.format(selectQuery, selectStartTime, selectEndTime); - ResultSet rs = SqlConnectionManager.executeQueryRS(query); - if (rs == null) { - SqlConnectionManager.releaseResultSet(rs); - return null; - } - - List statusSeriesList = new ArrayList(); - try { - while (rs.next()) { - NetworkSeriesType data = new NetworkSeriesType(); - data.setRid(rs.getInt(DB_RID_INDEX + 1)); - data.setDestinationAddress(rs.getString(DB_DESTINATION_ADDRESSINDEX + 1)); - data.setFdValue(rs.getString(DB_FD_VALUE_INDEX + 1)); - data.setStartTime(rs.getLong(DB_START_TIME_INDEX + 1)); - data.setEndTime(rs.getLong(DB_END_TIME_INDEX + 1)); - data.setAPIType(rs.getInt(DB_STATUS_TYPE_INDEX + 1)); - data.setApiID(rs.getInt(DB_API_ID_INDEX + 1)); - data.setpId(rs.getInt(DB_PID_INDEX + 1)); - statusSeriesList.add(data); - } - SqlConnectionManager.releaseResultSet(rs); - } catch (SQLException e) { - e.printStackTrace(); - } - return statusSeriesList; - - } - @Override public boolean prepare(PreparedStatement prep, List rowData) { boolean isPrepared = true; @@ -144,15 +63,15 @@ public class NetworkSeriesDBManager extends DBTable { isPrepared = false; } else { try { - prep.setInt(DB_RID_INDEX + 1, (Integer) (rowData.get(DB_RID_INDEX))); - prep.setString(DB_DESTINATION_ADDRESSINDEX + 1, - (String) (rowData.get(DB_DESTINATION_ADDRESSINDEX))); - prep.setString(DB_FD_VALUE_INDEX + 1, (String) (rowData.get(DB_FD_VALUE_INDEX))); - prep.setLong(DB_START_TIME_INDEX + 1, (Long) (rowData.get(DB_START_TIME_INDEX))); - prep.setLong(DB_END_TIME_INDEX + 1, (Long) (rowData.get(DB_END_TIME_INDEX))); - prep.setInt(DB_STATUS_TYPE_INDEX + 1, (Integer) (rowData.get(DB_STATUS_TYPE_INDEX))); - prep.setInt(DB_API_ID_INDEX + 1, (Integer) (rowData.get(DB_API_ID_INDEX))); - prep.setInt(DB_PID_INDEX + 1, (Integer) (rowData.get(DB_PID_INDEX))); + int selectIndex = 0; + prep.setInt(selectIndex + 1, (Integer) (rowData.get(selectIndex++))); + prep.setString(selectIndex + 1, (String) (rowData.get(selectIndex++))); + prep.setString(selectIndex + 1, (String) (rowData.get(selectIndex++))); + prep.setLong(selectIndex + 1, (Long) (rowData.get(selectIndex++))); + prep.setLong(selectIndex + 1, (Long) (rowData.get(selectIndex++))); + prep.setInt(selectIndex + 1, (Integer) (rowData.get(selectIndex++))); + prep.setInt(selectIndex + 1, (Integer) (rowData.get(selectIndex++))); + prep.setInt(selectIndex + 1, (Integer) (rowData.get(selectIndex++))); } catch (SQLException e) { e.printStackTrace(); @@ -161,5 +80,6 @@ public class NetworkSeriesDBManager extends DBTable { } return isPrepared; } - } + + diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/network/data/type/NetworkSeriesType.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/network/data/type/NetworkSeriesType.java index 9c1f428..cf46912 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/network/data/type/NetworkSeriesType.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/network/data/type/NetworkSeriesType.java @@ -31,7 +31,6 @@ import java.util.ArrayList; import java.util.List; import org.tizen.dynamicanalyzer.constant.CommonConstants; -import org.tizen.dynamicanalyzer.ui.network.data.NetworkSeriesDBManager; public class NetworkSeriesType { public final static int STATUS_TYPE_OPEN = 0; @@ -67,14 +66,15 @@ public class NetworkSeriesType { } public NetworkSeriesType(List data) { - setRid((Integer) data.get(NetworkSeriesDBManager.DB_RID_INDEX)); - setDestinationAddress((String) data.get(NetworkSeriesDBManager.DB_DESTINATION_ADDRESSINDEX)); - setFdValue((String) data.get(NetworkSeriesDBManager.DB_FD_VALUE_INDEX)); - setStartTime((Long) data.get(NetworkSeriesDBManager.DB_START_TIME_INDEX)); - setEndTime((Long) data.get(NetworkSeriesDBManager.DB_END_TIME_INDEX)); - setAPIType((Integer) data.get(NetworkSeriesDBManager.DB_STATUS_TYPE_INDEX)); - setApiID((Integer) data.get(NetworkSeriesDBManager.DB_API_ID_INDEX)); - setpId((Integer) data.get(NetworkSeriesDBManager.DB_API_ID_INDEX)); + int index = 0; + setRid((Integer) data.get(index++)); + setDestinationAddress((String) data.get(index++)); + setFdValue((String) data.get(index++)); + setStartTime((Long) data.get(index++)); + setEndTime((Long) data.get(index++)); + setAPIType((Integer) data.get(index++)); + setApiID((Integer) data.get(index++)); + setpId((Integer) data.get(index++)); } public int getRid() { diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/toolbar/opentrace/OpenTraceDialog.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/toolbar/opentrace/OpenTraceDialog.java index d6f4747..5c08019 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/toolbar/opentrace/OpenTraceDialog.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/toolbar/opentrace/OpenTraceDialog.java @@ -58,6 +58,7 @@ import org.tizen.dynamicanalyzer.appearance.DesignConstants; import org.tizen.dynamicanalyzer.common.AnalyzerConstants; import org.tizen.dynamicanalyzer.common.path.PathManager; import org.tizen.dynamicanalyzer.constant.CommonConstants; +import org.tizen.dynamicanalyzer.database.DBQueryXMLParser; import org.tizen.dynamicanalyzer.nl.AnalyzerLabels; import org.tizen.dynamicanalyzer.nl.WidgetLabels; import org.tizen.dynamicanalyzer.project.Project; @@ -315,7 +316,6 @@ public class OpenTraceDialog extends DAMessageBox { } else { return; } - OpenTraceProgressManager.getInstance().setSavePath(openPath); OpenTraceProgressManager.getInstance().startOpenTraceThread(); shell.dispose(); @@ -576,6 +576,7 @@ public class OpenTraceDialog extends DAMessageBox { device = project.getDevice(); application = project.getAppName(); elapsedTime = project.getTotalStopTime(); + DBQueryXMLParser.initQueryMap(project.getVersion()); return isSuccess; } } diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/toolbar/opentrace/SaveFilesTable.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/toolbar/opentrace/SaveFilesTable.java index c01f13b..d29eaa9 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/toolbar/opentrace/SaveFilesTable.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/toolbar/opentrace/SaveFilesTable.java @@ -144,16 +144,16 @@ public class SaveFilesTable extends DATableComposite { } private String getCreateTime(String path) { - isVaildVersion = true; + isVaildVersion = false; Project project = Project.getProjectInfoFromFile(path); - String version = project.getVersion(); - if (null != version - && (version.isEmpty() || !version - .equals(AnalyzerConstants.CURRENT_SAVE_FORMAT_VERSION))) { - isVaildVersion = false; - } else { - isVaildVersion = true; + String[] vaildVersions = AnalyzerConstants.SUPPORTED_SAVE_FORMAT_VERSION; + if (null != version && !version.isEmpty()) { + for (int i = 0; i < vaildVersions.length; i++) { + if (vaildVersions[i].equals(version)) { + isVaildVersion = true; + } + } } return project.getCreateTime(); } -- 2.7.4