Revize c670fa2f
Přidáno uživatelem Jan Havlíček před téměř 5 roky(ů)
.gitignore | ||
---|---|---|
6 | 6 |
project/json.txt |
7 | 7 |
project/app.config |
8 | 8 |
project/Deserializer/.classpath |
9 |
project/jdeserialize_out.txt |
|
10 |
project/jdeserialize_err.txt |
project/Deserializer/src/CLI.java | ||
---|---|---|
170 | 170 |
} |
171 | 171 |
|
172 | 172 |
@Override |
173 |
public void completed(String html, String json, String loaded) {
|
|
173 |
public void completed(String json, String loaded) { |
|
174 | 174 |
if (json != null) { |
175 | 175 |
System.out.println("Deserialization completed."); |
176 | 176 |
saveJson(json); |
project/Deserializer/src/Converter.java | ||
---|---|---|
90 | 90 |
continue; |
91 | 91 |
} |
92 | 92 |
|
93 |
StringBuilder html = new StringBuilder(); |
|
94 | 93 |
StringBuilder json = new StringBuilder(); |
95 | 94 |
|
96 | 95 |
boolean error = false; |
... | ... | |
99 | 98 |
System.setOut(FileWorker.createRedirectStream(false)); |
100 | 99 |
System.setErr(FileWorker.createRedirectStream(true)); |
101 | 100 |
System.out.println("--- jdeserialize begins ---".toUpperCase()); |
102 |
convert(array, html, json);
|
|
101 |
convert(array, json); |
|
103 | 102 |
} catch (Exception e) { |
104 | 103 |
e.printStackTrace(); |
105 | 104 |
error = true; |
... | ... | |
110 | 109 |
System.setErr(new PrintStream(new FileOutputStream(FileDescriptor.err))); |
111 | 110 |
System.setOut(new PrintStream(new FileOutputStream(FileDescriptor.out))); |
112 | 111 |
} |
113 |
|
|
114 |
//test file output |
|
115 |
try { |
|
116 |
BufferedWriter writer = new BufferedWriter(new FileWriter("html.txt")); |
|
117 |
writer.write(html.toString().replace("<br/>", "\n")); // TODO pridan replace pro odsazovani - lepsi orientace v souboru. |
|
118 |
writer.close(); |
|
119 |
|
|
120 |
BufferedWriter writer2 = new BufferedWriter(new FileWriter("json.txt")); |
|
121 |
writer2.write(json.toString()); |
|
122 |
writer2.close(); |
|
123 |
} catch (IOException e) { |
|
124 |
// TODO Auto-generated catch block |
|
125 |
e.printStackTrace(); |
|
126 |
} |
|
127 |
//test file output |
|
128 | 112 |
|
129 |
ui.completed(error ? null : html.toString(), error ? null : json.toString(), array == null ? null : new String(array));
|
|
113 |
ui.completed(error ? null : json.toString(), array == null ? null : new String(array)); |
|
130 | 114 |
} |
131 | 115 |
} |
132 | 116 |
|
... | ... | |
141 | 125 |
return array; |
142 | 126 |
} |
143 | 127 |
|
144 |
private void convert(byte[] buffer, StringBuilder html, StringBuilder json) throws Exception {
|
|
128 |
private void convert(byte[] buffer, StringBuilder json) throws Exception { |
|
145 | 129 |
jdeserialize deserializer = new jdeserialize(buffer); |
146 | 130 |
|
147 | 131 |
// gets the "contents" into an array - returnes the deserialization of all |
... | ... | |
151 | 135 |
for (content cnt : cntnts) { |
152 | 136 |
if (cnt != null) { |
153 | 137 |
json.append(cnt.toJson("", null, false)).append("\n"); |
154 |
html.append(cnt.toJson("", null, false)); |
|
155 | 138 |
} |
156 | 139 |
} |
157 | 140 |
} |
project/Deserializer/src/Editor.java | ||
---|---|---|
75 | 75 |
return json; |
76 | 76 |
} |
77 | 77 |
|
78 |
public void setContent(String html, String json) {
|
|
78 |
public void setContent(String json) { |
|
79 | 79 |
this.json = json; |
80 | 80 |
editor.call("setValue", ""); |
81 | 81 |
editor.call("insert", json); |
project/Deserializer/src/IConversionResults.java | ||
---|---|---|
2 | 2 |
public interface IConversionResults { |
3 | 3 |
|
4 | 4 |
public void loadingInputFileError(); |
5 |
public void completed(String html, String json, String loaded);
|
|
5 |
public void completed(String json, String loaded); |
|
6 | 6 |
|
7 | 7 |
} |
project/Deserializer/src/Window.java | ||
---|---|---|
406 | 406 |
} |
407 | 407 |
|
408 | 408 |
@Override |
409 |
public void completed(String html, String json, String loaded) {
|
|
409 |
public void completed(String json, String loaded) { |
|
410 | 410 |
Platform.runLater(() -> { |
411 |
String _html = html; String _json = json;
|
|
411 |
String _json = json; |
|
412 | 412 |
|
413 |
boolean showData = html != null && json != null;
|
|
413 |
boolean showData = json != null; |
|
414 | 414 |
|
415 | 415 |
if (!showData && loaded != null && |
416 | 416 |
Report.confirm("Výsledek deserializace", null, "Při deserializaci došlo k chybě. " |
417 | 417 |
+ "Je ale možné, že nejde o serializovaná data. Chcete zobrazit, co bylo načteno?")) { |
418 |
_html = loaded.trim(); |
|
419 |
_json = _html;
|
|
418 |
|
|
419 |
_json = loaded.trim();
|
|
420 | 420 |
showData = true; |
421 | 421 |
} |
422 | 422 |
|
423 | 423 |
if (showData) { |
424 |
editor.setContent(_html, _json);
|
|
424 |
editor.setContent(_json); |
|
425 | 425 |
setOutputLayoutDisabled(false); |
426 | 426 |
} |
427 | 427 |
}); |
project/Deserializer/src/io/Database.java | ||
---|---|---|
23 | 23 |
|
24 | 24 |
public DB_Messenger(String driver, String url, String user, String password, String table, String condition, String column) { |
25 | 25 |
this.driver = driver; |
26 |
this.url = url; |
|
26 |
//The timezone statement added due to MySQL DB. Is it OK with MsSQL and Oracle? |
|
27 |
this.url = url + "?useTimezone=true&serverTimezone=UTC"; |
|
27 | 28 |
this.user = user; |
28 | 29 |
this.password = password; |
29 |
this.sql = "SELECT " + column + " FROM " + table + " WHERE " + condition + ";"; |
|
30 |
|
|
31 |
this.sql = "SELECT " + column + " FROM " + table; |
|
32 |
if(condition.length() > 0) |
|
33 |
{ |
|
34 |
this.sql += " WHERE " + condition; |
|
35 |
} |
|
36 |
this.sql += ";"; |
|
37 |
|
|
30 | 38 |
this.column = column; |
31 | 39 |
} |
32 | 40 |
|
... | ... | |
49 | 57 |
//DriverManager.registerDriver(new com.microsoft.sqlserver.jdbc.SQLServerDriver()); |
50 | 58 |
|
51 | 59 |
System.out.println("--- Connecting to the database ---".toUpperCase()); |
60 |
|
|
52 | 61 |
conn = DriverManager.getConnection(crate.url, crate.user, crate.password); |
53 | 62 |
|
54 | 63 |
System.out.println("--- Executing the query ---".toUpperCase()); |
Také k dispozici: Unified diff
re #7963 DB communication repaired, tested.
html structures removed