(no commit message)
[cdmlib.git] / cdmlib-io / src / main / java / eu / etaxonomy / cdm / io / berlinModel / BerlinModelImport.java
1 package eu.etaxonomy.cdm.io.berlinModel;
2
3 import static eu.etaxonomy.cdm.io.berlinModel.BerlinModelTransformer.*;
4 import java.sql.ResultSet;
5 import java.sql.SQLException;
6 import java.util.HashMap;
7 import java.util.List;
8 import java.util.Map;
9 import java.util.UUID;
10
11 import org.apache.log4j.Logger;
12
13 import eu.etaxonomy.cdm.api.application.CdmApplicationController;
14 import eu.etaxonomy.cdm.api.service.IAgentService;
15 import eu.etaxonomy.cdm.api.service.INameService;
16 import eu.etaxonomy.cdm.api.service.IReferenceService;
17 import eu.etaxonomy.cdm.api.service.IService;
18 import eu.etaxonomy.cdm.api.service.ITaxonService;
19 import eu.etaxonomy.cdm.io.source.Source;
20 import eu.etaxonomy.cdm.model.name.BotanicalName;
21 import eu.etaxonomy.cdm.model.name.Rank;
22 import eu.etaxonomy.cdm.model.name.TaxonNameBase;
23 import eu.etaxonomy.cdm.model.reference.Article;
24 import eu.etaxonomy.cdm.model.reference.Book;
25 import eu.etaxonomy.cdm.model.reference.BookSection;
26 import eu.etaxonomy.cdm.model.reference.Database;
27 import eu.etaxonomy.cdm.model.reference.Generic;
28 import eu.etaxonomy.cdm.model.reference.Journal;
29 import eu.etaxonomy.cdm.model.reference.ReferenceBase;
30 import eu.etaxonomy.cdm.model.reference.StrictReferenceBase;
31 import eu.etaxonomy.cdm.model.taxon.Synonym;
32 import eu.etaxonomy.cdm.model.taxon.SynonymRelationshipType;
33 import eu.etaxonomy.cdm.model.taxon.Taxon;
34 import eu.etaxonomy.cdm.model.taxon.TaxonBase;
35 import eu.etaxonomy.cdm.strategy.exceptions.UnknownRankException;
36
37 public class BerlinModelImport {
38 private static final Logger logger = Logger.getLogger(BerlinModelImport.class);
39
40 private boolean deleteAll = false;
41
42 //BerlinModelDB
43 private Source source;
44
45 //CdmApplication
46 private CdmApplicationController cdmApp;
47
48 //Constants
49 //final boolean OBLIGATORY = true;
50 //final boolean FACULTATIVE = false;
51 final int modCount = 100;
52
53
54 //Hashmaps for Joins
55 private Map<Integer, UUID> referenceMap = new HashMap<Integer, UUID>();
56 private Map<Integer, UUID> taxonNameMap = new HashMap<Integer, UUID>();
57 private Map<Integer, UUID> taxonMap = new HashMap<Integer, UUID>();
58
59
60 /**
61 * Executes the whole
62 */
63 public boolean doImport(Source source, CdmApplicationController cdmApp){
64 if (source == null || cdmApp == null){
65 throw new NullPointerException("Source and CdmApplicationController must not be null");
66 }
67 this.source = source;
68 this.cdmApp = cdmApp;
69
70 //make and save Authors
71 makeAuthors();
72
73 //make and save References
74 if (! makeReferences()){
75 return false;
76 }
77
78 //make and save Names
79 makeTaxonNames();
80
81 //make and save Taxa
82 makeTaxa();
83
84 //make and save Facts
85 makeRelTaxa();
86
87 //make and save Facts
88 makeFacts();
89
90 if (false){
91 //make and save publications
92 /* makePublications(root);
93 saveToXml(root.getChild("Publications", nsTcs), outputPath, outputFileName + "Publications", format);
94
95 saveToXml(root.getChild("TaxonNames", nsTcs), outputPath, outputFileName + "_TaxonNames", format);
96
97 //make and save Concepts
98 makeConcepts(root);
99 saveToXml(root.getChild("TaxonConcepts", nsTcs), outputPath, outputFileName + "_TaxonConcepts", format);
100 */ }
101 return true;
102 }
103
104
105
106 /**
107 * @return
108 */
109 private boolean makeAuthors(){
110 String dbAttrName;
111 String cdmAttrName;
112
113 logger.info("start makeAuthors ...");
114 logger.warn("Authors not yet implemented !!");
115
116 IAgentService agentService = cdmApp.getAgentService();
117 boolean delete = deleteAll;
118
119 // if (delete){
120 // List<Agent> listAllAgents = agentService.getAllAgents(0, 1000);
121 // while(listAllAgents.size() > 0 ){
122 // for (Agent name : listAllAgents ){
123 // //FIXME
124 // //nameService.remove(name);
125 // }
126 // listAllAgents = agentService.getAllAgents(0, 1000);
127 // }
128 // }
129 // try {
130 //get data from database
131 String strQuery =
132 " SELECT * " +
133 " FROM AuthorTeam " ;
134 ResultSet rs = source.getResultSet(strQuery) ;
135
136
137
138
139
140 logger.info("end makeAuthors ...");
141 return true;
142 // } catch (SQLException e) {
143 // logger.error("SQLException:" + e);
144 // return false;
145 // }
146 }
147
148
149 /**
150 * @return
151 */
152 private boolean makeReferences(){
153 String dbAttrName;
154 String cdmAttrName;
155 boolean success = true;
156
157 logger.info("start makeReferences ...");
158 IReferenceService referenceService = cdmApp.getReferenceService();
159 boolean delete = deleteAll;
160
161 // if (delete){
162 // List<TaxonNameBase> listAllReferences = referenceService.getAllReferences(0, 1000);
163 // while(listAllReferences.size() > 0 ){
164 // for (TaxonNameBase name : listAllReferences ){
165 // //FIXME
166 // //nameService.remove(name);
167 // }
168 // listAllReferences = referenceService.getAllReferences(0, 1000);
169 // }
170 // }
171 try {
172
173
174 //get data from database
175 String strQuery =
176 " SELECT Reference.* , InReference.RefId as InRefId, InReference.RefCategoryFk as InRefCategoryFk, " +
177 " InInReference.RefId as InInRefId, InInReference.RefCategoryFk as InInRefCategoryFk " +
178 " FROM Reference AS InInReference " +
179 " RIGHT OUTER JOIN Reference AS InReference ON InInReference.RefId = InReference.InRefFk " +
180 " RIGHT OUTER JOIN Reference ON InReference.RefId = dbo.Reference.InRefFk ";
181
182
183 ResultSet rs = source.getResultSet(strQuery) ;
184
185 int i = 0;
186 //for each reference
187 while (rs.next()){
188
189 if ((i++ % modCount) == 0){ logger.info("References handled: " + (i-1));}
190
191 //create TaxonName element
192 int refId = rs.getInt("refId");
193 int categoryFk = rs.getInt("refCategoryFk");
194 int inRefFk = rs.getInt("inRefFk");
195 int inRefCategoryFk = rs.getInt("InRefCategoryFk");
196
197 StrictReferenceBase ref;
198 try {
199 logger.debug("RefCategoryFk: " + categoryFk);
200
201 if (categoryFk == REF_JOURNAL){
202 ref = new Journal();
203 }else if(categoryFk == REF_BOOK){
204 ref = new Book();
205 }else if(categoryFk == REF_ARTICLE){
206 ref = new Article();
207 }else if(categoryFk == REF_DATABASE){
208 ref = new Database();
209 }else if(categoryFk == REF_PART_OF_OTHER_TITLE){
210 if (inRefCategoryFk == REF_BOOK){
211 //TODO
212 ref = new BookSection();
213 }else{
214 logger.warn("Reference type of part-of-reference not recognized");
215 ref = new Generic();
216 }
217 }else if(categoryFk == REF_UNKNOWN){
218 ref = new Generic();
219 }else{
220 ref = new Generic();
221 }
222
223
224 dbAttrName = "refCache";
225 cdmAttrName = "titleCache";
226 //TODO wohin kommt der refCache
227 //INomenclaturalReference hat nur getNomenclaturalCitation , müsste es nicht so was wie setAbbrevTitle geben?
228 success &= ImportHelper.addStringValue(rs, ref, dbAttrName, cdmAttrName);
229
230 dbAttrName = "nomRefCache";
231 cdmAttrName = "titleCache";
232 success &= ImportHelper.addStringValue(rs, ref, dbAttrName, cdmAttrName);
233
234 // dbAttrName = "BinomHybFlag";
235 // cdmAttrName = "isBinomHybrid";
236 // ImportHelper.addBooleanValue(rs, ref, dbAttrName, cdmAttrName);
237
238 //TODO
239 // all attributes
240
241
242 UUID refUuid = referenceService.saveReference(ref);
243 //Session sess = new Session().
244 referenceMap.put(refId, refUuid);
245
246 } catch (Exception e) {
247 logger.warn("Reference with id " + refId + " threw Exception and could not be saved");
248 e.printStackTrace();
249 success = false;
250 return success;
251 }
252
253 }
254
255
256 logger.info("end makeReferences ...");
257 return success;
258 } catch (SQLException e) {
259 logger.error("SQLException:" + e);
260 return false;
261 }
262 }
263
264
265
266 /**
267 * @return
268 */
269 private boolean makeTaxonNames(){
270 String dbAttrName;
271 String cdmAttrName;
272 boolean success = true ;
273
274 logger.info("start makeTaxonNames ...");
275 INameService nameService = cdmApp.getNameService();
276 boolean delete = deleteAll;
277
278 if (delete){
279 List<TaxonNameBase> listAllNames = nameService.getAllNames(0, 1000);
280 while(listAllNames.size() > 0 ){
281 for (TaxonNameBase name : listAllNames ){
282 //FIXME
283 //nameService.remove(name);
284 }
285 listAllNames = nameService.getAllNames(0, 1000);
286 }
287 }
288
289 try {
290
291
292 //get data from database
293 String strQuery =
294 "SELECT TOP 102 Name.* , RefDetail.RefDetailId, RefDetail.RefFk, " +
295 " RefDetail.FullRefCache, RefDetail.FullNomRefCache, RefDetail.PreliminaryFlag AS RefDetailPrelim, RefDetail.Details, " +
296 " RefDetail.SecondarySources, RefDetail.IdInSource " +
297 " FROM Name LEFT OUTER JOIN RefDetail ON Name.NomRefDetailFk = RefDetail.RefDetailId AND Name.NomRefDetailFk = RefDetail.RefDetailId AND " +
298 " Name.NomRefFk = RefDetail.RefFk AND Name.NomRefFk = RefDetail.RefFk";
299 ResultSet rs = source.getResultSet(strQuery) ;
300
301 int i = 0;
302 //for each reference
303 while (rs.next()){
304
305 if ((i++ % modCount) == 0){ logger.info("Names handled: " + (i-1));}
306
307 //create TaxonName element
308 int nameId = rs.getInt("nameId");
309 int rankId = rs.getInt("rankFk");
310
311 try {
312 logger.info(rankId);
313 Rank rank = BerlinModelTransformer.rankId2Rank(rankId);
314 //FIXME
315 //BotanicalName name = BotanicalName.NewInstance(BerlinModelTransformer.rankId2Rank(rankId));
316 BotanicalName botanicalName = new BotanicalName(rank);
317
318 if (rankId < 40){
319 dbAttrName = "supraGenericName";
320 }else{
321 dbAttrName = "genus";
322 }
323 cdmAttrName = "genusOrUninomial";
324 success &= ImportHelper.addStringValue(rs, botanicalName, dbAttrName, cdmAttrName);
325
326 dbAttrName = "genusSubdivisionEpi";
327 cdmAttrName = "infraGenericEpithet";
328 success &= ImportHelper.addStringValue(rs, botanicalName, dbAttrName, cdmAttrName);
329
330 dbAttrName = "speciesEpi";
331 cdmAttrName = "specificEpithet";
332 success &= ImportHelper.addStringValue(rs, botanicalName, dbAttrName, cdmAttrName);
333
334
335 dbAttrName = "infraSpeciesEpi";
336 cdmAttrName = "infraSpecificEpithet";
337 success &= ImportHelper.addStringValue(rs, botanicalName, dbAttrName, cdmAttrName);
338
339 dbAttrName = "unnamedNamePhrase";
340 cdmAttrName = "appendedPhrase";
341 success &= ImportHelper.addStringValue(rs, botanicalName, dbAttrName, cdmAttrName);
342
343 dbAttrName = "preliminaryFlag";
344 cdmAttrName = "XX" + "protectedTitleCache";
345 success &= ImportHelper.addBooleanValue(rs, botanicalName, dbAttrName, cdmAttrName);
346
347 dbAttrName = "HybridFormulaFlag";
348 cdmAttrName = "isHybridFormula";
349 success &= ImportHelper.addBooleanValue(rs, botanicalName, dbAttrName, cdmAttrName);
350
351 dbAttrName = "MonomHybFlag";
352 cdmAttrName = "isMonomHybrid";
353 success &= ImportHelper.addBooleanValue(rs, botanicalName, dbAttrName, cdmAttrName);
354
355 dbAttrName = "BinomHybFlag";
356 cdmAttrName = "isBinomHybrid";
357 success &= ImportHelper.addBooleanValue(rs, botanicalName, dbAttrName, cdmAttrName);
358
359 dbAttrName = "TrinomHybFlag";
360 cdmAttrName = "isTrinomHybrid";
361 success &= ImportHelper.addBooleanValue(rs, botanicalName, dbAttrName, cdmAttrName);
362
363 //botanicalName.s
364
365 // dbAttrName = "notes";
366 // cdmAttrName = "isTrinomHybrid";
367 // ImportHelper.addStringValue(rs, botanicalName, dbAttrName, cdmAttrName);
368
369 //TODO
370 //Created
371 //Note
372 //makeAuthorTeams
373 //CultivarGroupName
374 //CultivarName
375 //Source_Acc
376 //OrthoProjection
377
378 //Details
379
380 dbAttrName = "details";
381 cdmAttrName = "nomenclaturalMicroReference";
382 success &= ImportHelper.addStringValue(rs, botanicalName, dbAttrName, cdmAttrName);
383
384 //TODO
385 //preliminaryFlag
386
387
388 UUID nameUuid = nameService.saveTaxonName(botanicalName);
389 taxonNameMap.put(nameId, nameUuid);
390
391 } catch (UnknownRankException e) {
392 logger.warn("Name with id " + nameId + " has unknown rankId " + rankId + " and could not be saved.");
393 success = false;
394 }
395
396 }
397
398 // //id
399 // strDbAttr = "NameId";
400 // //save id for later
401 // int intID = rs.getInt(strDbAttr);
402 //
403 // String nameId = rs.getString(strDbAttr);
404 //
405 // //add TaxonName to nameMap
406 // nameMap.put(nameId, elTaxonName);
407 //
408 //
409 // strValue = nameId;
410 // strAttrName = "id";
411 // parent = elTaxonName;
412 // xml.addStringAttribute(strValue, parent, strAttrName, NS_NULL);
413 //
414 // //Code
415 // strAttrName = "nomenclaturalCode";
416 // strValue = "Botanical";
417 // parent = elTaxonName;
418 // xml.addStringAttribute(strValue, parent, strAttrName, NS_NULL);
419 //
420 // //Simple
421 // strDbAttr = "FullNameCache";
422 // strElName = "Simple";
423 // parent = elTaxonName;
424 // xml.addElement(rs,strDbAttr, parent, strElName, nsTcs, OBLIGATORY);
425 //
426 // if (fullVersion){
427 // //Rank
428 // strDbAttr = "RankAbbrev";
429 // strElName = "Rank";
430 // parent = elTaxonName;
431 // xml.addElement(rs,strDbAttr, parent, strElName, nsTcs, OBLIGATORY);
432 //
433 // //CanonicalName
434 // parent = elTaxonName;
435 // makeCanonicalName(rs, parent);
436 //
437 //
438 // //CanonicalAuthorship
439 // parent = elTaxonName;
440 // makeCanonicalAuthorship(rs, parent);
441 //
442 // } //fi fullVersion
443 //
444 // //PublishedIn
445 // strDbAttr = "NomRefFk";
446 // strAttrName = "ref";
447 // strElName = "PublishedIn";
448 // parent = elTaxonName;
449 // Attribute attrPublRef = xml.addAttributeInElement(rs, strDbAttr, parent, strAttrName, strElName, nsTcs, FACULTATIVE);
450 //
451 // if (attrPublRef != null){
452 // //does Publication exist?
453 // String ref = attrPublRef.getValue();
454 // if (! publicationMap.containsKey(ref)){
455 // logger.error("PublishedIn ref " + ref + " for " + nameId + " does not exist.");
456 // }
457 // }
458 //
459 //
460 // if (fullVersion){
461 // //Year
462 // String year = rs.getString("RefYear");
463 // if (year == null) {
464 // year = rs.getString("HigherRefYear");
465 // }
466 // strValue = year;
467 // strElName = "Year";
468 // parent = elTaxonName;
469 // xml.addStringElement(strValue, parent, strElName, nsTcs, FACULTATIVE);
470 //
471 // //MicroReference
472 // strDbAttr = "Details";
473 // strElName = "MicroReference";
474 // parent = elTaxonName;
475 // xml.addElement(rs,strDbAttr, parent, strElName, nsTcs, FACULTATIVE);
476 //
477 // }//fi fullversion
478 // }//while
479 //
480 // //insert related Names (Basionyms, ReplacedSyns, etc.
481 // makeSpellingCorrections(nameMap);
482 // makeBasionyms(nameMap);
483 // makeLaterHomonyms(nameMap);
484 // makeReplacedNames(nameMap);
485 //
486 // //insert Status infos
487 // makeNameSpecificData(nameMap);
488 //cdmApp.flush();
489 logger.info("end makeTaxonNames ...");
490 return success;
491 } catch (SQLException e) {
492 logger.error("SQLException:" + e);
493 return false;
494 }
495 }
496
497
498
499 /**
500 * @return
501 */
502 private boolean makeTaxa(){
503 String dbAttrName;
504 String cdmAttrName;
505
506 logger.info("start makeTaxa ...");
507
508 ITaxonService taxonService = cdmApp.getTaxonService();
509 INameService nameService = cdmApp.getNameService();
510 IReferenceService referenceService = cdmApp.getReferenceService();
511 boolean delete = deleteAll;
512
513 // if (delete){
514 // List<TaxonBase> listAllTaxa = taxonService.getAllTaxa(0, 1000);
515 // while(listAllTaxa.size() > 0 ){
516 // for (TaxonBase taxon : listAllTaxa ){
517 // //FIXME
518 // //nameService.remove(name);
519 // }
520 // listAllTaxa = taxonService.getAllTaxa(0, 1000);
521 // }
522 // }
523 try {
524 //get data from database
525 String strQuery =
526 " SELECT * " +
527 " FROM PTaxon " ;
528 ResultSet rs = source.getResultSet(strQuery) ;
529
530
531 int i = 0;
532 //for each reference
533 while (rs.next()){
534
535 if ((i++ % modCount) == 0){ logger.info("Names handled: " + (i-1));}
536
537 //create TaxonName element
538 int taxonId = rs.getInt("taxonId");
539 int statusFk = rs.getInt("statusFk");
540
541 int nameFk = rs.getInt("nameFk");
542 int refFk = rs.getInt("refFk");
543
544 TaxonNameBase taxonName;
545 UUID nameUuid = taxonNameMap.get(nameFk);
546 if (nameUuid == null){
547 taxonName = null;
548 }else{
549 taxonName = nameService.getTaxonNameByUuid(nameUuid);
550 }
551
552
553 ReferenceBase reference;
554 UUID refUuid = referenceMap.get(refFk);
555 if (refUuid == null){
556 reference = null;
557 }else{
558 reference = referenceService.getReferenceByUuid(refUuid);
559 }
560
561 TaxonBase taxonBase;
562 Synonym synonym;
563 Taxon taxon;
564 try {
565 logger.info(statusFk);
566 if (statusFk == 1){
567 taxon = Taxon.NewInstance(taxonName, reference);
568 taxonBase = taxon;
569 }else if (statusFk == 2){
570 synonym = Synonym.NewInstance(taxonName, reference);
571 taxonBase = synonym;
572 }else{
573 synonym = Synonym.NewInstance(taxonName, reference);
574 taxonBase = synonym;
575 }
576
577 dbAttrName = "xxx";
578 cdmAttrName = "yyy";
579 ImportHelper.addStringValue(rs, taxonBase, dbAttrName, cdmAttrName);
580
581 dbAttrName = "genusSubdivisionEpi";
582 cdmAttrName = "infraGenericEpithet";
583 ImportHelper.addStringValue(rs, taxonBase, dbAttrName, cdmAttrName);
584
585 dbAttrName = "isDoubtful";
586 cdmAttrName = "isDoubtful";
587 ImportHelper.addBooleanValue(rs, taxonBase, dbAttrName, cdmAttrName);
588
589
590 //TODO
591 //Created
592 //Note
593 //ALL
594
595 UUID taxonUuid = taxonService.saveTaxon(taxonBase);
596 taxonMap.put(taxonId, taxonUuid);
597
598 } catch (Exception e) {
599 logger.warn("An exception occurred when creating taxon with id " + taxonId + ". Taxon could not be saved.");
600 }
601
602 }
603
604 logger.info("end makeTaxa ...");
605 return true;
606 } catch (SQLException e) {
607 logger.error("SQLException:" + e);
608 return false;
609 }
610 }
611
612
613 /**
614 * @return
615 */
616 private boolean makeRelTaxa(){
617 String dbAttrName;
618 String cdmAttrName;
619
620 logger.info("start makeTaxonRelationships ...");
621 logger.warn("RelTaxa not yet implemented !!");
622
623 ITaxonService taxonService = cdmApp.getTaxonService();
624 boolean delete = deleteAll;
625
626 // if (delete){
627 // List<Agent> listAllAgents = agentService.getAllAgents(0, 1000);
628 // while(listAllAgents.size() > 0 ){
629 // for (Agent name : listAllAgents ){
630 // //FIXME
631 // //nameService.remove(name);
632 // }
633 // listAllAgents = agentService.getAllAgents(0, 1000);
634 // }
635 // }
636 try {
637 //get data from database
638 String strQuery =
639 " SELECT * " +
640 " FROM RelPTaxon Join Taxon1 Join Taxon2" ;
641 ResultSet rs = source.getResultSet(strQuery) ;
642 int i = 0;
643 //for each reference
644 while (rs.next()){
645
646 if ((i++ % modCount) == 0){ logger.info("RelPTaxa handled: " + (i-1));}
647
648
649 int taxon1Id = rs.getInt("taxon1Id");
650 int taxon2Id = rs.getInt("taxon2Id");
651 int factId = rs.getInt("factId");
652 int relTypeFk = rs.getInt("relTypeFk");
653
654 TaxonBase taxon1 = getTaxonById(taxon1Id, taxonService);
655 TaxonBase taxon2 = getTaxonById(taxon2Id, taxonService);
656
657 //TODO
658 ReferenceBase citation = null;
659 String microcitation = null;
660
661
662 if (relTypeFk == IS_INCLUDED_IN){
663 ((Taxon)taxon2).addTaxonomicChild((Taxon)taxon1, citation, microcitation);
664 }else if (relTypeFk == IS_SYNONYM_OF){
665 ((Taxon)taxon2).addSynonym((Synonym)taxon1, SynonymRelationshipType.SYNONYM_OF());
666 }else if (relTypeFk == IS_HOMOTYPIC_SYNONYM_OF){
667 ((Taxon)taxon2).addSynonym((Synonym)taxon1, SynonymRelationshipType.HOMOTYPIC_SYNONYM_OF());
668 }else if (relTypeFk == IS_HETEROTYPIC_SYNONYM_OF){
669 ((Taxon)taxon2).addSynonym((Synonym)taxon1, SynonymRelationshipType.HETEROTYPIC_SYNONYM_OF());
670 }else if (relTypeFk == IS_MISAPPLIED_NAME_OF){
671 ((Taxon)taxon2).addMisappliedName((Taxon)taxon1, citation, microcitation);
672 }else {
673 //TODO
674 logger.warn("TaxonRelationShipType " + relTypeFk + " not yet implemented");
675 }
676
677
678 //....
679
680
681
682 }
683 logger.info("end makeFacts ...");
684 return true;
685 } catch (SQLException e) {
686 logger.error("SQLException:" + e);
687 return false;
688 }
689 }
690
691
692 private TaxonBase getTaxonById(int id, IService<TaxonBase> service){
693 TaxonBase result;
694 UUID uuid = taxonMap.get(id);
695 if (uuid == null){
696 result = null;
697 }else{
698 result = ((ITaxonService)service).getTaxonByUuid(uuid); //.getCdmObjectByUuid(uuid);// taxonService.getTaxonByUuid(taxonUuid);
699 }
700 return result;
701
702 }
703
704 /**
705 * @return
706 */
707 private boolean makeFacts(){
708 String dbAttrName;
709 String cdmAttrName;
710
711 logger.info("start makeFacts ...");
712 logger.warn("Facts not yet implemented !!");
713
714 //IAgentService agentService = cdmApp.getAgentService();
715 boolean delete = deleteAll;
716
717 // if (delete){
718 // List<Agent> listAllAgents = agentService.getAllAgents(0, 1000);
719 // while(listAllAgents.size() > 0 ){
720 // for (Agent name : listAllAgents ){
721 // //FIXME
722 // //nameService.remove(name);
723 // }
724 // listAllAgents = agentService.getAllAgents(0, 1000);
725 // }
726 // }
727 try {
728 //get data from database
729 String strQuery =
730 " SELECT * " +
731 " FROM Facts " ;
732 ResultSet rs = source.getResultSet(strQuery) ;
733 int i = 0;
734 //for each reference
735 while (rs.next()){
736
737 if ((i++ % modCount) == 0){ logger.info("Facts handled: " + (i-1));}
738
739 //create TaxonName element
740 int factId = rs.getInt("factId");
741
742 //....
743
744
745
746 }
747 logger.info("end makeFacts ...");
748 return true;
749 } catch (SQLException e) {
750 logger.error("SQLException:" + e);
751 return false;
752 }
753 }
754
755
756
757
758
759
760 }