-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathForPath.jsp
169 lines (127 loc) · 4.13 KB
/
ForPath.jsp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
<!DOCTYPE HTML>
<%@include file="connectionString.jsp"%>
<%@page import="java.sql.DriverManager"%>
<%@page import="java.sql.Statement"%>
<%@page import="java.sql.ResultSet"%>
<%@page import="java.sql.Connection"%>
<%@ page import="java.io.*"%>
<%@ page import="java.util.*"%>
<html>
<head>
<title>Graph</title>
<script type="text/javascript">
</script>
<style>
body {
margin: 0;
padding: 0;
overflow: hidden;
}
p {
text-align: center;
overflow: overlay;
position: relative;
}
body {
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
background-image: url('bodyBG.jpg');
background-repeat: no-repeat;
}
</style>
<script type="text/javascript">
window.onload = function() {
window.opener.NodeList = null;
window.opener.EdgeList = null;
};
</script>
</head>
<body>
<script>
<%System.out.println("entered");
String var = request.getParameter("param");
System.out.println(var);
connectionString cs = new connectionString();
String url = cs.url;
String username = cs.username;
String password = cs.password;
try {
Class.forName("org.postgresql.Driver");
} catch (ClassNotFoundException e) {
System.out.println("Where is your PostgreSQL JDBC Driver? " + "Include in your library path!");
e.printStackTrace();
return;
}
System.out.println("PostgreSQL JDBC Driver Registered!");
java.sql.Connection connection = null;
try {
connection = DriverManager.getConnection(url, username, password);
} catch (Exception e) {
System.out.println("Connection Failed! Check output console");
e.printStackTrace();
return;
}
if (connection != null) {
System.out.println("Entered fro query");
ResultSet rs = null;
Statement s = connection.createStatement();
String q3 = "SELECT * FROM scenario_node WHERE building_name='lib' and node_id='" + var + "' AND node_type='source'";
rs = s.executeQuery(q3);
ArrayList<String> aa = new ArrayList<String>();
ArrayList<String> ab = new ArrayList<String>();
while (rs.next()) {
System.out.println("Yes it is a source");
ResultSet rsw = null;
Statement sw = connection.createStatement();
String q3w = "SELECT * FROM evacrun_path WHERE building_name='lib' and algorithm='CCRP_extended' and scenario_name='scene1' and source='"
+ var + "'";
rsw = sw.executeQuery(q3w);
while (rsw.next()) {
//System.out.println("path edgelisht kosam vacha");
String p = rsw.getString("path");
String q = rsw.getString("edgelist");
System.out.println(p);
System.out.println(q);
String po[] = p.split("---");
for (int i = 0; i < po.length; i++) {
if (!aa.contains(po[i])) {
aa.add(po[i]);
}
}
q = q.substring(1, q.length()-1);
System.out.println(q);
String pi[] = q.split(",");
for (int i = 0; i < pi.length; i++) {
if (!ab.contains(pi[i])) {
ab.add(pi[i]);
}
}
}
}
System.out.println(aa + " --- " + ab);
String as=new String("");
String ad=new String("");
for(int i=0;i<aa.size();i++) as += aa.get(i)+",";
for(int i=0;i<ab.size();i++) ad += ab.get(i)+",";
as=as.substring(0, as.length()-1);
ad=ad.substring(0, ad.length()-1);
System.out.println(as+" "+ad);
%>
window.opener.NodeList = "<%=as%>";
window.opener.EdgeList = "<%=ad%>";
var pass = window.opener.NodeList+"__"+window.opener.EdgeList+"__"+"4";
var popupStoD = window.open("StoD.jsp?param1="+pass,
"_self",
"visible=none,directories=no,titlebar=no,toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=1100,height=700,left=100,top=0");
<%
} else {
System.out.println("Failed to make connection!");
}
%>
</script>
</body>
</html>