Skip to content

Commit 66e6b09

Browse files
committed
added sql string escaping and minor refactoring
1 parent 5c57960 commit 66e6b09

File tree

10 files changed

+403
-429
lines changed

10 files changed

+403
-429
lines changed

pom.xml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
55
<modelVersion>4.0.0</modelVersion>
66

7-
<groupId>com.omer.csc895</groupId>
7+
<groupId>com.csgt</groupId>
88
<artifactId>CallStackGraphTool</artifactId>
99
<version>1.0-SNAPSHOT</version>
1010

@@ -34,6 +34,12 @@
3434
<artifactId>derby</artifactId>
3535
<version>10.13.1.1</version>
3636
</dependency>
37+
<!-- https://mvnrepository.com/artifact/commons-lang/commons-lang -->
38+
<dependency>
39+
<groupId>commons-lang</groupId>
40+
<artifactId>commons-lang</artifactId>
41+
<version>2.6</version>
42+
</dependency>
3743

3844
</dependencies>
3945

src/main/java/com/csgt/controller/CanvasController.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,6 @@ private void addUIComponents() {
111111
}
112112

113113
public void removeUIComponents() {
114-
System.out.println("CanvasController.removeUIComponents");
115114
removeNodeCellsFromUI();
116115
removeEdgesFromUI();
117116
removeHighlightsFromUI();

src/main/java/com/csgt/controller/EventHandlers.java

Lines changed: 370 additions & 395 deletions
Large diffs are not rendered by default.

src/main/java/com/csgt/controller/InstructionsPaneController.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,8 @@ private void initGraphics() {
133133
}
134134

135135
public void setMethodDefGraphics(boolean enabled) {
136+
System.out.println("InstructionsPaneController.setMethodDefGraphics");
137+
System.out.println("enabled = [" + enabled + "]");
136138
if (enabled) {
137139
// methodDefInfoLabel.setWrapText(true);
138140
// methodDefInfoLabel.setTextOverrun(OverrunStyle.CENTER_ELLIPSIS);
@@ -145,7 +147,7 @@ public void setMethodDefGraphics(boolean enabled) {
145147

146148
} else {
147149
methodDefInfoGlyph.setIcon(FontAwesome.Glyph.ARROW_RIGHT);
148-
methodDefInfoGlyph.setColor(ColorProp.GREY);
150+
methodDefInfoGlyph.setColor(ColorProp.RED);
149151
}
150152
}
151153

src/main/java/com/csgt/controller/MenuController.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ private void setFileRelatedGraphics() {
226226

227227
setRunAnalysisMenuItemGraphics(true);
228228
setResetMenuItemGraphics(true);
229-
// ControllerLoader.instructionsPaneController.setMethodDefGraphics(true);
229+
ControllerLoader.instructionsPaneController.setMethodDefGraphics(true);
230230
ControllerLoader.instructionsPaneController.setCallTraceGraphics(true);
231231
ControllerLoader.instructionsPaneController.setFileRunInfoGraphics(true);
232232
} else if (!methodDefFileSet && !callTraceFileSet) {
@@ -433,13 +433,13 @@ private void firstTimeSetUpHighlightsWindow() {
433433
GridPane.setConstraints(headingCol1, 0, 0);
434434
GridPane.setHalignment(headingCol1, HPos.CENTER);
435435

436-
Label headingCol2 = new Label("Highlight method only");
436+
Label headingCol2 = new Label("Highlight node only");
437437
headingCol2.setWrapText(true);
438438
headingCol2.setFont(Font.font("Verdana", FontWeight.BOLD, headingCol2.getFont().getSize() * 1.1));
439439
GridPane.setConstraints(headingCol2, 1, 0);
440440
GridPane.setHalignment(headingCol2, HPos.CENTER);
441441

442-
Label headingCol3 = new Label("Highlight subtree");
442+
Label headingCol3 = new Label("Highlight node subtree");
443443
headingCol3.setWrapText(true);
444444
headingCol3.setFont(Font.font("Verdana", FontWeight.BOLD, headingCol3.getFont().getSize() * 1.1));
445445
GridPane.setConstraints(headingCol3, 2, 0);
@@ -867,7 +867,7 @@ private void setChooseMethodDefMenuItemGraphics(boolean enabled, boolean isSet)
867867
methodDefnGlyph.setIcon(FontAwesome.Glyph.CHECK);
868868
methodDefnGlyph.setColor(ColorProp.GREEN);
869869
} else if (!enabled && !isSet) {
870-
// after choosing dataaccess and clicking run analysis
870+
// after choosing database and clicking run analysis
871871
chooseMethodDefMenuItem.setDisable(true);
872872
methodDefnGlyph.setIcon(FontAwesome.Glyph.PLUS);
873873
methodDefnGlyph.setColor(ColorProp.GREY);

src/main/java/com/csgt/controller/files/parsers/ParseCallTrace.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.csgt.controller.files.parsers;
22

33
import com.csgt.controller.tasks.ParseFileTask;
4+
import org.apache.commons.lang.StringEscapeUtils;
45

56
import java.io.BufferedReader;
67
import java.io.File;
@@ -9,6 +10,7 @@
910
import java.util.Arrays;
1011
import java.util.List;
1112
import java.util.function.Consumer;
13+
import java.util.stream.Collectors;
1214

1315
/**
1416
* Parser class for Call Trace Log file.
@@ -31,7 +33,10 @@ public void readFile(File logFile, ParseFileTask.BytesRead bytesRead, Consumer<L
3133
}
3234

3335
private List<String> parse(String line) {
34-
return Arrays.asList(line.split("\\|"));
36+
List<String> parsedList = Arrays.asList(line.split("\\|"));
37+
List<String> escapedList = parsedList.stream().map(s -> StringEscapeUtils.escapeSql(s)).collect(Collectors.toList());
38+
39+
return escapedList;
3540
}
3641

3742
public static int countNumberOfLines(File file) {

src/main/java/com/csgt/dataaccess/DAO/CallTraceDAOImpl.java

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -42,25 +42,7 @@ public static void createTable() {
4242
public static int insert(List<String> val) {
4343

4444
int autoIncrementedId = -1;
45-
// int processID = Integer.parseInt(readSoFar.get(0));
46-
// int threadID = Integer.parseInt(readSoFar.get(1));
47-
// int methodID = Integer.parseInt(readSoFar.get(2));
48-
// String eventType = readSoFar.get(3);
49-
// String parameters = readSoFar.get(4);
50-
// String time_instant = readSoFar.get(5);
51-
52-
// TimeStamp | ProcessID | ThreadID | EventType |LockObjectID
53-
// utc time format | 40948 | 9 | Wait-Enter |3986916
54-
55-
// TimeStamp | ProcessID | ThreadID | EventType | MethodID | Arguments
56-
// 2017-03-31T17:00:19.305Z | 40948 | 9 | Enter | 1 | []
57-
// TimeStamp | ProcessID | ThreadID | EventType | MethodID
58-
// 2017-03-31T17:00:19.305Z | 40948 | 9 | Enter | 1
5945
String time_instant = val.get(0);
60-
// Instant instant = Instant.parse(time_instant);
61-
// Timestamp timestamp = Timestamp.from(instant);
62-
// java.sql.Timestamp sqlTimeStamp = new Timestamp(instant.toEpochMilli());
63-
6446
Timestamp timestamp = new Timestamp(Long.valueOf(time_instant));
6547
int processID = Integer.parseInt(val.get(1));
6648
int threadID = Integer.parseInt(val.get(2));
@@ -72,22 +54,16 @@ public static int insert(List<String> val) {
7254
if (eventType.equalsIgnoreCase("ENTER")) {
7355
methodID = Integer.parseInt(val.get(4));
7456
parameters = val.get(5);
75-
// } else if (eventType.equalsIgnoreCase("EXIT")) {
76-
// methodID = Integer.parseInt(readSoFar.get(4));
7757
} else if (eventType.equalsIgnoreCase("WAIT-ENTER") || eventType.equalsIgnoreCase("WAIT-EXIT") ||
7858
eventType.equalsIgnoreCase("NOTIFY-ENTER") || eventType.equalsIgnoreCase("NOTIFY-EXIT") ||
7959
eventType.equalsIgnoreCase("NOTIFYALL-ENTER") || eventType.equalsIgnoreCase("NOTIFYALL-EXIT")) {
8060
lockObjectId = val.get(4);
8161
}
82-
// System.out.println("starting insert");
83-
// System.out.println("CallTraceDAOImpl:insert: " + isTableCreated());
8462

8563
if (!isTableCreated())
8664
createTable();
8765
String sql = null;
8866
try (Connection c = DatabaseUtil.getConnection(); Statement ps = c.createStatement()) {
89-
90-
// System.out.println("value of callTraceTableCreated: " + callTraceTableCreated);
9167
sql = "INSERT INTO " + CALL_TRACE_TABLE +
9268
"(" +
9369
"process_id, " +

src/main/java/com/csgt/dataaccess/DAO/ElementDAOImpl.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,6 @@ public static List<ElementDTO> getElementDTOs(List<String> ids) {
237237
ids.forEach(id -> stringJoiner.add(id));
238238

239239
String sql = "SELECT * FROM " + TableNames.ELEMENT_TABLE + " WHERE ID in " + stringJoiner.toString();
240-
System.out.println("ElementDAOImpl.getElementDTOsInViewport query: " + sql);
241240

242241
try (ResultSet rs = DatabaseUtil.select(sql)) {
243242
while (rs.next()) {

src/main/java/com/csgt/dataaccess/DTO/ElementDTO.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,4 +215,9 @@ public String getThredId() {
215215
public void setThredId(String thredId) {
216216
this.thredId = thredId;
217217
}
218+
219+
@Override
220+
public String toString() {
221+
return "[id=" + id + "; parentId=" + parentId +"]";
222+
}
218223
}

src/main/java/com/csgt/presentation/graph/NodeCell.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,13 +302,15 @@ private void setUpDropShadow(boolean isLite) {
302302
}
303303

304304
public void blink() {
305+
System.out.println("NodeCell.blink");
305306
double duration = 10;
306307
double min = nodeShape.getStrokeWidth();
307308
double max = 4;
308309
final boolean[] grow = {true};
310+
nodeShape.setStroke(Color.RED);
309311

310312
Platform.runLater(() -> {
311-
final int[] noOfPluses = {5*2};
313+
final int[] noOfPluses = {3 * 2};
312314

313315
Timeline timeline = new Timeline();
314316
KeyFrame pulseNode = new KeyFrame(Duration.millis(duration),
@@ -343,6 +345,11 @@ public void handle(ActionEvent event) {
343345
timeline.getKeyFrames().add(pulseNode);
344346
timeline.setCycleCount(Animation.INDEFINITE);
345347
timeline.play();
348+
349+
timeline.setOnFinished(event -> {
350+
nodeShape.setStroke(Color.GREY);
351+
nodeShape.setStrokeWidth(0.5);
352+
});
346353
});
347354

348355
}

0 commit comments

Comments
 (0)