Revize efca2344
Přidáno uživatelem Ondřej Drtina před téměř 4 roky(ů)
merge_db/src/Starter.java | ||
---|---|---|
4 | 4 |
import java.util.Scanner; |
5 | 5 |
|
6 | 6 |
public class Starter { |
7 |
public static ArrayList<String> deletedRedundantItIds; //contains ids of duplicated items which were deleted (duplicated items existed mefore merge...) |
|
8 |
|
|
7 | 9 |
public static void main(String[] args){ |
8 |
//establish connection to DBs |
|
10 |
deletedRedundantItIds = new ArrayList<>(); |
|
11 |
|
|
12 |
//establish connection to DBs with unmodified content (dalimil1, dalimil2) |
|
9 | 13 |
Connection dalimil1Con = establishDalimilX("dalimil1"); |
10 | 14 |
Connection dalimil2Con = establishDalimilX("dalimil2"); |
11 |
//retrieve content of "dd_wordform"s |
|
15 |
//retrieve content of "dd_wordform"s of dalimil1
|
|
12 | 16 |
ResultSet dalimil1Wordform = retrieveWordformDalimilX(dalimil1Con, "dalimil1"); |
13 | 17 |
//start process of finding whats missing in dalimil2 (AND is present in dalimil1) |
14 |
checkMissingWordformDalimil2(dalimil1Con, dalimil2Con, dalimil1Wordform); |
|
18 |
checkMissingWordformDalimil2(dalimil1Con, dalimil2Con, dalimil1Wordform); //UNCOMMENT THIS TO MERGE |
|
19 |
|
|
20 |
//UNCOMMENT THIS TO PERFORM COMPLETE CHECK - START |
|
21 |
/*System.out.println("MERGED DB CHECK mergedDBCheck - START"); |
|
22 |
mergedDBCheck(dalimil2Con); |
|
23 |
System.out.println("MERGED DB CHECK mergedDBCheck - END"); |
|
24 |
System.out.println("REVIEW DELETED ITEMS MERGE reviewDeletedItemsMerge - START"); |
|
25 |
reviewDeletedItemsMerge(dalimil2Con); |
|
26 |
System.out.println("REVIEW DELETED ITEMS MERGE reviewDeletedItemsMerge - END");*/ |
|
27 |
//UNCOMMENT THIS TO PERFORM COMPLETE CHECK - END |
|
28 |
|
|
15 | 29 |
//close connection to DBs |
16 | 30 |
closeDalimilX(dalimil1Con, "dalimil1"); |
17 | 31 |
closeDalimilX(dalimil2Con, "dalimil2"); |
... | ... | |
101 | 115 |
} |
102 | 116 |
|
103 | 117 |
if(finished.equals("f") && finishedSec.equals("t")){ |
104 |
System.out.println("OK, found finished equivalent to unfinished item.. From first drop item: " + dal1Print); |
|
118 |
//System.out.println("OK, found finished equivalent to unfinished item.. From first drop item: " + dal1Print);
|
|
105 | 119 |
//if unfinished item from first db has finished equivalent in second db, then drop item from first db and keep entry in second |
106 | 120 |
if(!doNotDeleteID[0].contains(Integer.valueOf(id))){ //drop from first only if supervisor doesnt want to keep |
107 | 121 |
deleteConflict(dalimil1Con, "dalimil1", id, dal1Print); //drop from first db |
108 | 122 |
}else{ |
109 |
System.out.println("Conflicting ID: " + id + " kept.."); |
|
123 |
//System.out.println("Conflicting ID: " + id + " kept..");
|
|
110 | 124 |
} |
111 | 125 |
}else{ |
112 | 126 |
dalimil1Var.add(dal1Print); |
... | ... | |
115 | 129 |
if(!doNotDeleteID[0].contains(Integer.valueOf(id))){ //drop from first only if supervisor doesnt want to keep |
116 | 130 |
deleteConflict(dalimil1Con, "dalimil1", id, dal1Print); //delete conflicting item from first db |
117 | 131 |
}else{ |
118 |
System.out.println("Conflicting ID: " + id + " kept.."); |
|
132 |
//System.out.println("Conflicting ID: " + id + " kept..");
|
|
119 | 133 |
} |
120 | 134 |
if(!doNotDeleteID[1].contains(Integer.valueOf(idSec))){ //drop from second only if supervisor doesnt want to keep |
121 | 135 |
deleteConflict(dalimil2Con, "dalimil2", idSec, dal2Print); //delete conflicting item from second db |
122 | 136 |
}else{ |
123 |
System.out.println("Conflicting ID: " + idSec + " kept.."); |
|
137 |
//System.out.println("Conflicting ID: " + idSec + " kept..");
|
|
124 | 138 |
} |
125 | 139 |
} |
126 | 140 |
} |
... | ... | |
136 | 150 |
} |
137 | 151 |
} |
138 | 152 |
|
153 |
/** |
|
154 |
* Checks whether all finished entries present in dalimil1original and dalimil2original (original, not modified DBs) are present in dalimil2 (merged DB) |
|
155 |
* @param dalimil2Con connection to dalimil2 DB (merged DB with all finished rows from dalimil1original and dalimil2original - except the ones, which supervisor wanted to delete) |
|
156 |
*/ |
|
157 |
private static void mergedDBCheck(Connection dalimil2Con){ |
|
158 |
Connection dalimil1origCon = establishDalimilX("dalimil1original"); //connection to db which contains unmodified dalimil1 |
|
159 |
Connection dalimil2origCon = establishDalimilX("dalimil2original"); //connection to db which contains unmodified dalimil2 |
|
160 |
|
|
161 |
ResultSet dalimil1origWordform = retrieveWordformDalimilX(dalimil1origCon, "dalimil1original"); //content of dalimil1 original dd_wordform |
|
162 |
ResultSet dalimil2origWordform = retrieveWordformDalimilX(dalimil2origCon, "dalimil2original"); //content of dalimil2 original dd_wordform |
|
163 |
|
|
164 |
//go through dalimil1original + dalimil2original and check presence of each finished item in dalimil2 (merged DB) |
|
165 |
try{ |
|
166 |
while(dalimil1origWordform.next()){ |
|
167 |
//get all fields dalimil1original/dd_wordform - START |
|
168 |
String id = dalimil1origWordform.getString("id"); |
|
169 |
String context = dalimil1origWordform.getString("context"); |
|
170 |
String date = dalimil1origWordform.getString("date"); |
|
171 |
String description = dalimil1origWordform.getString("description"); |
|
172 |
String description2 = dalimil1origWordform.getString("description2"); |
|
173 |
String description3 = dalimil1origWordform.getString("description3"); |
|
174 |
String ending = dalimil1origWordform.getString("ending"); |
|
175 |
String finished = dalimil1origWordform.getString("finished"); |
|
176 |
String namedentity = dalimil1origWordform.getString("namedentity"); |
|
177 |
String position1 = dalimil1origWordform.getString("position1"); |
|
178 |
String position2 = dalimil1origWordform.getString("position2"); |
|
179 |
String positiondetail = dalimil1origWordform.getString("positiondetail"); |
|
180 |
String prefix = dalimil1origWordform.getString("prefix"); |
|
181 |
String suffix = dalimil1origWordform.getString("suffix"); |
|
182 |
String word = dalimil1origWordform.getString("word"); |
|
183 |
String lemma_id = dalimil1origWordform.getString("lemma_id"); |
|
184 |
String tag_id = dalimil1origWordform.getString("tag_id"); |
|
185 |
//get all fields dalimil1original/dd_wordform - END |
|
186 |
|
|
187 |
//look where points lemma_id and tag_id |
|
188 |
String[] lemma_id_dd_lemma = retrieveLemmaContForId(dalimil1origCon, "dalimil1original", lemma_id); |
|
189 |
String tag_id_dd_tag = retrieveTagContForId(dalimil1origCon, "dalimil1original", tag_id); |
|
190 |
ArrayList<String> manuscript_cont = retrieveManuscriptNumsForId(dalimil1origCon, "dalimil1original", id); |
|
191 |
|
|
192 |
if(finished.equals("t")){ //entry is considered as finished, continue with check of presence in merged DB |
|
193 |
boolean isPresentMerge = checkPresenceEntryMergedDB(id, "dalimil1", dalimil2Con, context, date, description, description2, description3, |
|
194 |
ending, finished, namedentity, position1, position2, positiondetail, prefix, |
|
195 |
suffix, word, tag_id_dd_tag, lemma_id_dd_lemma[0], lemma_id_dd_lemma[1], manuscript_cont); |
|
196 |
if(!isPresentMerge){ //finished entry is not present in merged DB, that should not ever occur :(!!! |
|
197 |
System.out.println("ERR, finished item from FIRST DB is not present in merged DB!!!" + id); |
|
198 |
}else{ |
|
199 |
//System.out.println("Ok, item " + word + " (FIRST DB) found in merged DB " + id); |
|
200 |
} |
|
201 |
} |
|
202 |
} |
|
203 |
|
|
204 |
while(dalimil2origWordform.next()){ |
|
205 |
//get all fields dalimil2original/dd_wordform - START |
|
206 |
String id = dalimil2origWordform.getString("id"); |
|
207 |
String context = dalimil2origWordform.getString("context"); |
|
208 |
String date = dalimil2origWordform.getString("date"); |
|
209 |
String description = dalimil2origWordform.getString("description"); |
|
210 |
String description2 = dalimil2origWordform.getString("description2"); |
|
211 |
String description3 = dalimil2origWordform.getString("description3"); |
|
212 |
String ending = dalimil2origWordform.getString("ending"); |
|
213 |
String finished = dalimil2origWordform.getString("finished"); |
|
214 |
String namedentity = dalimil2origWordform.getString("namedentity"); |
|
215 |
String position1 = dalimil2origWordform.getString("position1"); |
|
216 |
String position2 = dalimil2origWordform.getString("position2"); |
|
217 |
String positiondetail = dalimil2origWordform.getString("positiondetail"); |
|
218 |
String prefix = dalimil2origWordform.getString("prefix"); |
|
219 |
String suffix = dalimil2origWordform.getString("suffix"); |
|
220 |
String word = dalimil2origWordform.getString("word"); |
|
221 |
if(word.equals("viz'u")){ //DB contains just one word, which throws exception -> edit the word |
|
222 |
word = "viz''u"; |
|
223 |
} |
|
224 |
|
|
225 |
String lemma_id = dalimil2origWordform.getString("lemma_id"); |
|
226 |
String tag_id = dalimil2origWordform.getString("tag_id"); |
|
227 |
//get all fields dalimil2original/dd_wordform - END |
|
228 |
|
|
229 |
//look where points lemma_id and tag_id |
|
230 |
String[] lemma_id_dd_lemma = retrieveLemmaContForId(dalimil2origCon, "dalimil2original", lemma_id); |
|
231 |
String tag_id_dd_tag = retrieveTagContForId(dalimil2origCon, "dalimil2original", tag_id); |
|
232 |
ArrayList<String> manuscript_cont = retrieveManuscriptNumsForId(dalimil2origCon, "dalimil2original", id); |
|
233 |
|
|
234 |
if(finished.equals("t")){ //entry is considered as finished, continue with check of presence in merged DB |
|
235 |
boolean isPresentMerge = checkPresenceEntryMergedDB(id, "dalimil2",dalimil2Con, context, date, description, description2, description3, |
|
236 |
ending, finished, namedentity, position1, position2, positiondetail, prefix, |
|
237 |
suffix, word, tag_id_dd_tag, lemma_id_dd_lemma[0], lemma_id_dd_lemma[1], manuscript_cont); |
|
238 |
if(!isPresentMerge){ //finished entry is not present in merged DB, that should not ever occur :(!!! |
|
239 |
System.out.println("ERR, finished item from SECOND DB is not present in merged DB!!!" + id); |
|
240 |
}else{ |
|
241 |
//System.out.println("Ok, item " + word + " (FIRST DB) found in merged DB " + id); |
|
242 |
} |
|
243 |
} |
|
244 |
} |
|
245 |
}catch (SQLException throwables) { |
|
246 |
System.out.println("err, working with dbs"); |
|
247 |
throwables.printStackTrace(); |
|
248 |
} |
|
249 |
|
|
250 |
closeDalimilX(dalimil1origCon, "dalimil1original"); |
|
251 |
closeDalimilX(dalimil2origCon, "dalimil2original"); |
|
252 |
} |
|
253 |
|
|
254 |
/** |
|
255 |
* Checks whether entry specified by given parameters is present in merged DB (dalimil2). |
|
256 |
* @param id id the entry in given DB |
|
257 |
* @param nameDB name of the checked DB (dalimil1 or dalimil2 expected) |
|
258 |
* @param dalimil2mergedCon connection to merged database (dalimil2) |
|
259 |
* @param context original DB - table dd_wordform - context |
|
260 |
* @param date original DB - table dd_wordform - date |
|
261 |
* @param description original DB - table dd_wordform - description |
|
262 |
* @param description2 original DB - table dd_wordform - description2 |
|
263 |
* @param description3 original DB - table dd_wordform - description3 |
|
264 |
* @param ending original DB - table dd_wordform - ending |
|
265 |
* @param finished original DB - table dd_wordform - finished |
|
266 |
* @param namedentity original DB - table dd_wordform - namedentity |
|
267 |
* @param position1 original DB - table dd_wordform - position1 |
|
268 |
* @param position2 original DB - table dd_wordform - position2 |
|
269 |
* @param positiondetail original DB - table dd_wordform - positiondetail |
|
270 |
* @param prefix original DB - table dd_wordform - prefix |
|
271 |
* @param suffix original DB - table dd_wordform - suffix |
|
272 |
* @param word original DB - table dd_wordform - word |
|
273 |
* @param tag original DB - table dd_tag - tag |
|
274 |
* @param lemma original DB - table dd_lemma - lemma |
|
275 |
* @param pos original DB - table dd_lemma - pos |
|
276 |
* @param manuscriptNums original DB - table dd_manuscript - numbers of all manuscript assigned to doc |
|
277 |
* @return true if specified entry is present in second DB, else false |
|
278 |
*/ |
|
279 |
private static boolean checkPresenceEntryMergedDB(String id, String nameDB, Connection dalimil2mergedCon, String context, String date, String description, String description2, String description3, |
|
280 |
String ending, String finished, String namedentity, String position1, String position2, String positiondetail, String prefix, |
|
281 |
String suffix, String word, String tag, String lemma, String pos, ArrayList<String> manuscriptNums){ |
|
282 |
ResultSet retrievedResMerge = null; //result retrieved from merged DB (dalimil2) |
|
283 |
Statement statementMerge = null; //statement to be executed on merged DB (dalimil2) |
|
284 |
|
|
285 |
//tags in first DB are shorter than the ones in second DB (sec is 12char length) -> make it match |
|
286 |
while(tag.length() < 12){ |
|
287 |
tag += "-"; |
|
288 |
} |
|
289 |
|
|
290 |
try{ |
|
291 |
//retrieve all rows from dd_lemma which match desired lemma + pos (then one of the retrieved ids has to be assigned to the wordform) - START |
|
292 |
Statement statementLemma = dalimil2mergedCon.createStatement(); |
|
293 |
ArrayList<String> possibleLemmaIdsList = new ArrayList<>(); |
|
294 |
|
|
295 |
ResultSet statementLemmaRes = statementLemma.executeQuery("SELECT * FROM public.dd_lemma WHERE lemma='" + lemma + "' AND pos='" + pos + "';"); |
|
296 |
|
|
297 |
while(statementLemmaRes.next()){ |
|
298 |
possibleLemmaIdsList.add(statementLemmaRes.getString("id")); |
|
299 |
} |
|
300 |
//retrieve all rows from dd_lemma which match desired lemma + pos (then one of the retrieved ids has to be assigned to the wordform) - END |
|
301 |
|
|
302 |
//retrieve all rows from dd_tag which match desired tag (then one of the retrieved ids has to be assigned to the wordform) - START |
|
303 |
Statement statementTag = dalimil2mergedCon.createStatement(); |
|
304 |
ArrayList<String> possibleTagIdsList = new ArrayList<>(); |
|
305 |
|
|
306 |
ResultSet statementTagRes = statementTag.executeQuery("SELECT * FROM public.dd_tag WHERE tag='" + tag + "';"); |
|
307 |
while(statementTagRes.next()){ |
|
308 |
possibleTagIdsList.add(statementTagRes.getString("id")); |
|
309 |
} |
|
310 |
//retrieve all rows from dd_tag which match desired tag (then one of the retrieved ids has to be assigned to the wordform) - END |
|
311 |
|
|
312 |
boolean dd_wordformPresent = false; |
|
313 |
|
|
314 |
//retrieve all items from dd_wordform which match all attributes except for tag_id and lemma_id (then one one of retrieved ids must have assigned required manuscripts) - START |
|
315 |
statementMerge = dalimil2mergedCon.createStatement(); |
|
316 |
ArrayList<String> wordformIds = new ArrayList<>(); |
|
317 |
|
|
318 |
retrievedResMerge = statementMerge.executeQuery("SELECT * FROM public.dd_wordform WHERE context='" + context + "' AND date='" + date + "' AND description='" + description + "' AND description2='" + description2 + "' AND description3='" + description3 + "' AND ending='" + ending + "' AND finished='" + finished + "' AND namedentity='" + namedentity + "' AND position1='" + position1 + "' AND position2='" + position2 + "' AND positiondetail='" + positiondetail + "' AND prefix='" + prefix + "' AND suffix='" + suffix + "' AND word='" + word + "';"); |
|
319 |
while(retrievedResMerge.next()){ |
|
320 |
if(possibleTagIdsList.contains(retrievedResMerge.getString("tag_id")) && possibleLemmaIdsList.contains(retrievedResMerge.getString("lemma_id"))){ //found item with suitable tag id and lemma id |
|
321 |
wordformIds.add(retrievedResMerge.getString("id")); |
|
322 |
} |
|
323 |
} |
|
324 |
//retrieve all items from dd_wordform which match all attributes except for tag_id and lemma_id (then one one of retrieved ids must have assigned required manuscripts) - END |
|
325 |
|
|
326 |
int matchCountWordform = 0; //number of matches found in merged DB, table dd_wordform |
|
327 |
ArrayList<String> matchingWordformLemmaTagManucriptIds = new ArrayList<>(); //wordform ids of items WHICH HAVE SAME: wordform, lemma, tag, assigned manuscript = totally equiv entry |
|
328 |
|
|
329 |
//got suitable dd_lemma + dd_tag -> from that deducted possible dd_wordform ids. now check if any of possible dd_wordform ids have assigned required manuscripts |
|
330 |
for(String suitableId : wordformIds){ //go through possible wordform ids and check if they have required entries in dd_manuscript |
|
331 |
Statement statementManuscript = dalimil2mergedCon.createStatement(); |
|
332 |
ArrayList<String> assignedManuscriptNumsList = new ArrayList<>(); //manuscript numbers assigned to traversed id |
|
333 |
ResultSet statementManuscriptRes = statementManuscript.executeQuery("SELECT * FROM public.dd_manuscript WHERE wordform_id=" + suitableId + ";"); |
|
334 |
|
|
335 |
while(statementManuscriptRes.next()){ //add all manuscripts assigned to specified id to list |
|
336 |
String manuscript = statementManuscriptRes.getString("manuscript"); |
|
337 |
assignedManuscriptNumsList.add(manuscript); |
|
338 |
} |
|
339 |
|
|
340 |
int traversedManuscriptCount = 0; //number of already checked assigned manuscripts |
|
341 |
for(String manuscriptNum : assignedManuscriptNumsList){ |
|
342 |
if(manuscriptNums.contains(manuscriptNum)){ |
|
343 |
traversedManuscriptCount++; |
|
344 |
} |
|
345 |
} |
|
346 |
|
|
347 |
if(traversedManuscriptCount == assignedManuscriptNumsList.size()){ //number of checked items equals to total number of assigned manuscripts, items MATCH (same wordform, lemma, tag and assigned manuscripts...) |
|
348 |
matchingWordformLemmaTagManucriptIds.add(suitableId); |
|
349 |
matchCountWordform++; |
|
350 |
} |
|
351 |
} |
|
352 |
|
|
353 |
if(matchCountWordform == 1){ //found exactly one matching entry in merged DB (dalimil2), ok (if > 1 is not nice -> db contains redundant information, but doesnt matter that much...) |
|
354 |
dd_wordformPresent = true; |
|
355 |
}else if(matchCountWordform == 0){ |
|
356 |
System.out.println("Not FOUND: db" + nameDB + ", id: " + id + "context='" + context + "' AND date='" + date + "' AND description='" + description + "' AND description2='" + description2 + "' AND description3='" + description3 + "' AND ending='" + ending + "' AND finished='" + finished + "' AND namedentity='" + namedentity + "' AND position1='" + position1 + "' AND position2='" + position2 + "' AND positiondetail='" + positiondetail + "' AND prefix='" + prefix + "' AND suffix='" + suffix + "' AND word='" + word + "';"); |
|
357 |
}else if(matchCountWordform > 0){ |
|
358 |
System.out.println("Found more than once! - START"); |
|
359 |
|
|
360 |
for(int i = 0; i < wordformIds.size(); i++){ |
|
361 |
String wfid = wordformIds.get(i); |
|
362 |
System.out.println("In merged db " + nameDB + " id is: " + wfid + ", id from original: " + id); |
|
363 |
|
|
364 |
if(i != 0){ //do not delete the first one, must keep one equiv |
|
365 |
deleteConflict(dalimil2mergedCon, "dalimil2merged", wfid, "DELETE AFTER MERGE"); //drop from first db |
|
366 |
deletedRedundantItIds.add(wfid); |
|
367 |
} |
|
368 |
} |
|
369 |
System.out.println("Found more than once! - END"); |
|
370 |
dd_wordformPresent = true; |
|
371 |
} |
|
372 |
|
|
373 |
if(dd_wordformPresent){ //found entry with matching content - dd_wordform + dd_lemma + dd_tag + dd_manuscript (except for ids, thats obvious) |
|
374 |
return true; |
|
375 |
}else{ |
|
376 |
return false; |
|
377 |
} |
|
378 |
} catch (SQLException throwables) { |
|
379 |
System.out.println("ERR, checking data in merged DB. id in original: " + id); |
|
380 |
throwables.printStackTrace(); |
|
381 |
return false; |
|
382 |
} |
|
383 |
} |
|
384 |
|
|
385 |
/** |
|
386 |
* Checks whether all deleted items really had equivavelents. |
|
387 |
* @param dalimil2mergedCon connection to DB which does not contains redundant items (final DB to be used) |
|
388 |
*/ |
|
389 |
private static void reviewDeletedItemsMerge(Connection dalimil2mergedCon){ |
|
390 |
Connection dalimil2mergedWOdeletedredundantCon = establishDalimilX("dalimil2mergedWOdeletedredundant"); //connection to DB which still contains redundant items |
|
391 |
|
|
392 |
for(String removedId : deletedRedundantItIds){ //go through removed items in dalimil2mergedWOdeletedredundant and check if equiv is really present in dalimil2 |
|
393 |
ResultSet wordformDeletedMerge = retrieveWordformIdDalimilX(dalimil2mergedWOdeletedredundantCon, "dalimil2mergedWOdeletedredundant", removedId); //retrieve content of dd_wordform for deleted id |
|
394 |
|
|
395 |
int matchCount = 0; //number of items found in dalimil2mergedWOdeletedredundant with the specified id (SHOULD NOT EVER BE > 1!) |
|
396 |
|
|
397 |
try{ |
|
398 |
while(wordformDeletedMerge.next()){ //go through items found with specified id |
|
399 |
matchCount++; |
|
400 |
|
|
401 |
//get all fields dalimil2mergedWOdeletedredundant/dd_wordform - START |
|
402 |
String id = wordformDeletedMerge.getString("id"); |
|
403 |
String context = wordformDeletedMerge.getString("context"); |
|
404 |
String date = wordformDeletedMerge.getString("date"); |
|
405 |
String description = wordformDeletedMerge.getString("description"); |
|
406 |
String description2 = wordformDeletedMerge.getString("description2"); |
|
407 |
String description3 = wordformDeletedMerge.getString("description3"); |
|
408 |
String ending = wordformDeletedMerge.getString("ending"); |
|
409 |
String finished = wordformDeletedMerge.getString("finished"); |
|
410 |
String namedentity = wordformDeletedMerge.getString("namedentity"); |
|
411 |
String position1 = wordformDeletedMerge.getString("position1"); |
|
412 |
String position2 = wordformDeletedMerge.getString("position2"); |
|
413 |
String positiondetail = wordformDeletedMerge.getString("positiondetail"); |
|
414 |
String prefix = wordformDeletedMerge.getString("prefix"); |
|
415 |
String suffix = wordformDeletedMerge.getString("suffix"); |
|
416 |
String word = wordformDeletedMerge.getString("word"); |
|
417 |
String lemma_id = wordformDeletedMerge.getString("lemma_id"); |
|
418 |
String tag_id = wordformDeletedMerge.getString("tag_id"); |
|
419 |
//get all fields dalimil2mergedWOdeletedredundant/dd_wordform - END |
|
420 |
|
|
421 |
String[] lemma_id_dd_lemma = retrieveLemmaContForId(dalimil2mergedWOdeletedredundantCon, "dalimil2mergedWOdeletedredundant", lemma_id); //retrieve lemma from dd_lemma for deleted id |
|
422 |
String tag_id_dd_tag = retrieveTagContForId(dalimil2mergedWOdeletedredundantCon, "dalimil2mergedWOdeletedredundant", tag_id); //retrieve tag from dd_tag for deleted id |
|
423 |
ArrayList<String> manuscript_cont = retrieveManuscriptNumsForId(dalimil2mergedWOdeletedredundantCon, "dalimil2mergedWOdeletedredundant", id); //retrieve manuscripts from dd_manuscript for deleted id |
|
424 |
|
|
425 |
boolean isEquivPresent = checkPresenceEntryMergedDB(id, "dalimil2", dalimil2mergedCon, context, date, description, description2, description3, |
|
426 |
ending, finished, namedentity, position1, position2, positiondetail, prefix, |
|
427 |
suffix, word, tag_id_dd_tag, lemma_id_dd_lemma[0], lemma_id_dd_lemma[1], manuscript_cont); |
|
428 |
|
|
429 |
if(!isEquivPresent){ //if equivalent is not present in DB with removed duplicates, something is wrong... |
|
430 |
System.out.println("ERR, duplicated item with id " + id + " has no equivalents in final DB!!!"); |
|
431 |
}else{ |
|
432 |
System.out.println("Ok, found equivalent to removed id: " + removedId); |
|
433 |
} |
|
434 |
} |
|
435 |
}catch (SQLException throwables) { |
|
436 |
System.out.println("err, working with dbs"); |
|
437 |
throwables.printStackTrace(); |
|
438 |
} |
|
439 |
|
|
440 |
if(matchCount != 1){ |
|
441 |
System.out.println("err, match count for deleted id is not 1!"); |
|
442 |
} |
|
443 |
} |
|
444 |
|
|
445 |
closeDalimilX(dalimil2mergedWOdeletedredundantCon, "dalimil2mergedWOdeletedredundant"); |
|
446 |
} |
|
447 |
|
|
139 | 448 |
/** |
140 | 449 |
* Parses content of the file which contains only valid entries and returns ArrayLists which contains ids of entries which should stay in DB. Each entry begins with "Dal1:" or "Dal2:" and ends with ", OK" |
141 | 450 |
* @param pathToFile path to the file which contains valid entries (checked by contracting authority) |
... | ... | |
176 | 485 |
} |
177 | 486 |
} |
178 | 487 |
|
179 |
System.out.println("size is: " + toStayInDB[0].size() + " and " + toStayInDB[1].size()); |
|
488 |
//System.out.println("size is: " + toStayInDB[0].size() + " and " + toStayInDB[1].size());
|
|
180 | 489 |
|
181 | 490 |
return toStayInDB; |
182 | 491 |
} |
... | ... | |
194 | 503 |
int affectedManuscript = statement.executeUpdate("DELETE FROM public.dd_manuscript WHERE wordform_id=" + id); //delete entry which is associated with the word from dd_manuscript |
195 | 504 |
int affectedWordform = statement.executeUpdate("DELETE FROM public.dd_wordform WHERE id=" + id); //delete entry from dd_wordform |
196 | 505 |
//System.out.println("Removing affected wordform num: " + affectedWordform + ", affected manuscript num: " + affectedManuscript + " info line: " + whichDB + " " + textRepres); |
506 |
System.out.println("Z " + whichDB + " odstraneno: " + textRepres); |
|
197 | 507 |
} catch (SQLException throwables) { |
198 | 508 |
System.out.println("ERR, " + whichDB + " - deleting conflicts from database."); |
199 | 509 |
throwables.printStackTrace(); |
... | ... | |
543 | 853 |
private static Connection establishDalimilX(String whichDB){ |
544 | 854 |
String jdbcDal1 = "jdbc:postgresql://localhost:5432/" + whichDB; |
545 | 855 |
String username = "postgres"; |
546 |
String password = "PASS_TO_DB"; //obviously - replace this with your admin password
|
|
856 |
String password = "YOUR_ADMIN_PASS"; //obviously - replace this with your admin password
|
|
547 | 857 |
|
548 | 858 |
Connection connection = null; |
549 | 859 |
|
Také k dispozici: Unified diff
#8645 - zadavatelky požadovaly seznam smazaných rows -> dodal jsem. Skript nyní pracuje ve dvou modech - 1) merge, 2) otestování přítomnosti všech finished záznamů (finální podoba DB: dal_MERGED_AFTER_FINISHED_CHECK.sql)