Project

General

Profile

« Previous | Next » 

Revision 9c1f21ba

Added by Patricia Kelbert over 10 years ago

try to debug sources duplicates in ABCD import

View differences:

src/main/java/eu/etaxonomy/cdm/io/common/ImportConfiguratorBase.java
141 141
	@Override
142 142
    public boolean isValid(){
143 143
		boolean result = true;
144
		if (source == null){
144
		if (getSource() == null){
145 145
			logger.warn("Connection to source could not be established");
146 146
			result = false;
147 147
		}
src/main/java/eu/etaxonomy/cdm/io/specimen/SpecimenUserInteraction.java
158 158
     * @return
159 159
     */
160 160
    @SuppressWarnings("rawtypes")
161
    public List<OriginalSourceBase<?>> askForSourceSource(Map<String, OriginalSourceBase<?>> refMap, String currentElement, String blabla,
161
    public List<OriginalSourceBase<?>> askForSource(Map<String, OriginalSourceBase<?>> refMap, String currentElement, String blabla,
162 162
            IReferenceService iReferenceService, List<String> docSources) {
163

  
164
        System.out.println(refMap);
163 165
        List<String>  possibilities = new ArrayList<String> (refMap.keySet());
164 166

  
165 167
        Set<String> all = new HashSet<String>();
......
182 184

  
183 185
        Object[] options = {"Add and close", "Add and continue - I want to add more sources","Close without adding anything"};
184 186

  
187
        System.out.println(docSources);
185 188
        int n=1;
186 189
        while (n==1){
187 190
            group = new ButtonGroup();
......
322 325
        scrollPane.setPreferredSize( new Dimension( 700, 50 ) );
323 326

  
324 327
        Map<String,TaxonDescription> descrMap = new HashMap<String, TaxonDescription>();
328

  
329
        int descCnt=1;
325 330
        for (TaxonDescription description : descriptions){
331
            System.out.println("descr. titlecache "+description.getTitleCache());
326 332
            Set<IdentifiableSource> sources =  description.getTaxon().getSources();
327 333
            sources.addAll(description.getSources());
328 334
            List<String> src=new ArrayList<String>();
329
            src.add("(");
330 335
            for (IdentifiableSource s:sources) {
331 336
                src.add(s.getCitation().getTitleCache());
332 337
            }
333
            src.add(")");
334
            descrMap.put(description.getTitleCache()+StringUtils.join(src,";"),description);
335
            //            for (IdentifiableSource source:sources){
336
            //                if(ref.equals(source.getCitation())) {
337
            //                    taxonDescription = description;
338
            //                }
339
            //            }
338
            List<String> srcb = new ArrayList<String>(new HashSet<String>(src));
339
            if (srcb.size()>0) {
340
                if(descrMap.containsKey(descCnt+": "+description.getTitleCache()+"("+StringUtils.join(srcb,";")+")")) {
341
                    descCnt+=1;
342
                }
343
                descrMap.put(descCnt+": "+description.getTitleCache()+"("+StringUtils.join(srcb,";")+")",description);
344
            }
345
            else {
346
                if(descrMap.containsKey(description.getTitleCache())) {
347
                    descCnt+=1;
348
                }
349
                descrMap.put(descCnt+": "+description.getTitleCache(),description);
350
                //            for (IdentifiableSource source:sources){
351
                //                if(ref.equals(source.getCitation())) {
352
                //                    taxonDescription = description;
353
                //                }
354
                //            }
355
            }
340 356
        }
341 357
        List<String>  possibilities = new ArrayList<String> (descrMap.keySet());
342 358
        if (possibilities.size()==0) {
src/main/java/eu/etaxonomy/cdm/io/specimen/abcd206/in/Abcd206Import.java
397 397
                System.out.println("reference has problem?" +reference.hasProblem());
398 398

  
399 399

  
400
                IdentifiableSource sour = IdentifiableSource.NewInstance(OriginalSourceType.Import,null,null, reference,citationDetail);
400
                IdentifiableSource sour = getIdentifiableSource(reference,citationDetail);
401

  
401 402
                try{
402
                    dataHolder.docSources.add(sour.getCitation().getTitleCache()+ "---"+sour.getCitationMicroReference());
403
                    if(sour.getCitationMicroReference() !=null && !sour.getCitationMicroReference().isEmpty()) {
404
                        dataHolder.docSources.add(sour.getCitation().getTitleCache()+ "---"+sour.getCitationMicroReference());
405
                    } else {
406
                        dataHolder.docSources.add(sour.getCitation().getTitleCache());
407
                    }
403 408
                }catch(Exception e){
404 409
                    logger.warn("oups");
405 410
                }
......
411 416
                getReferenceService().saveOrUpdate(reference);
412 417
            }
413 418

  
419

  
414 420
            List<OriginalSourceBase> issTmp = getCommonService().list(IdentifiableSource.class, null, null, null, null);
415 421
            List<OriginalSourceBase> issTmp2 = getCommonService().list(DescriptionElementSource.class, null, null, null, null);
416 422

  
......
424 430

  
425 431

  
426 432
            for( OriginalSourceBase<?> osb:osbSet) {
427
                if(osb.getCitationMicroReference() !=null) {
433
                if(osb.getCitationMicroReference() !=null  && !osb.getCitationMicroReference().isEmpty()) {
428 434
                    try{
429 435
                        sourceMap.put(osb.getCitation().getTitleCache()+ "---"+osb.getCitationMicroReference(),osb);
430 436
                    }catch(NullPointerException e){logger.warn("null pointer problem (no ref?) with "+osb);}
......
435 441
                }
436 442
            }
437 443

  
438

  
439 444
            if( state.getConfig().isInteractWithUser()){
440 445
                List<OriginalSourceBase<?>>sources=null;
441 446
                if(!derivedUnitSourcesSet){
442
                    sources= sui.askForSourceSource(sourceMap, "the unit itself","",getReferenceService(), dataHolder.docSources);
447
                    sources= sui.askForSource(sourceMap, "the unit itself","",getReferenceService(), dataHolder.docSources);
443 448
                    derivedUnitSources=sources;
444 449
                    derivedUnitSourcesSet=true;
445 450
                }
......
448 453
                }
449 454
                for (OriginalSourceBase<?> sour:sources){
450 455
                    if(sour.isInstanceOf(IdentifiableSource.class)){
451
                        derivedUnitFacade.addSource((IdentifiableSource)sour.clone());
456
                        if(sourceNotLinkedToElement(derivedUnitFacade,sour)) {
457
                            derivedUnitFacade.addSource((IdentifiableSource)sour.clone());
458
                        }
452 459
                    }else{
453
                        derivedUnitFacade.addSource(OriginalSourceType.Import,sour.getCitation(),sour.getCitationMicroReference(), ioName);
460
                        if(sourceNotLinkedToElement(derivedUnitFacade,sour)) {
461
                            derivedUnitFacade.addSource(OriginalSourceType.Import,sour.getCitation(),sour.getCitationMicroReference(), ioName);
462
                        }
454 463
                    }
455 464
                }
456 465
            }else{
457 466
                for (OriginalSourceBase<?> sr : sourceMap.values()){
458 467
                    if(sr.isInstanceOf(IdentifiableSource.class)){
459
                        derivedUnitFacade.addSource((IdentifiableSource)sr.clone());
468
                        if(sourceNotLinkedToElement(derivedUnitFacade,sr)) {
469
                            derivedUnitFacade.addSource((IdentifiableSource)sr.clone());
470
                        }
460 471
                    }else{
461
                        derivedUnitFacade.addSource(OriginalSourceType.Import,sr.getCitation(),sr.getCitationMicroReference(), ioName);
472
                        if(sourceNotLinkedToElement(derivedUnitFacade,sr)) {
473
                            derivedUnitFacade.addSource(OriginalSourceType.Import,sr.getCitation(),sr.getCitationMicroReference(), ioName);
474
                        }
462 475
                    }
463 476
                }
464 477
            }
......
484 497
        return;
485 498
    }
486 499

  
500
    /**
501
     * @param derivedUnitFacade
502
     * @param sour
503
     * @return
504
     */
505
    private boolean sourceNotLinkedToElement(DerivedUnitFacade derivedUnitFacade, OriginalSourceBase<?> source) {
506
        Set<IdentifiableSource> linkedSources = derivedUnitFacade.getSources();
507
        for (IdentifiableSource is:linkedSources){
508
            if (is.getCitation().getTitleCache().equalsIgnoreCase(source.getCitation().getTitleCache())
509
                    && is.getCitationMicroReference().equalsIgnoreCase(source.getCitationMicroReference())){
510
                return false;
511
            }
512
        }
513
        return true;
514
    }
515

  
516
    /**
517
     * @param reference
518
     * @param citationDetail
519
     * @return
520
     */
521
    private IdentifiableSource getIdentifiableSource(Reference<?> reference, String citationDetail) {
522

  
523
        List<OriginalSourceBase> issTmp = getCommonService().list(IdentifiableSource.class, null, null, null, null);
524

  
525

  
526
        try {
527
            for (OriginalSourceBase<?> osb:issTmp){
528
                if (osb.getCitation().getTitleCache().equalsIgnoreCase(reference.getTitleCache())
529
                        && osb.getCitationMicroReference().equalsIgnoreCase(citationDetail)) {
530
                    System.out.println("REFERENCE FOUND RETURN EXISTING SOURCE");
531
                    return (IdentifiableSource) osb.clone();
532
                }
533
            }
534
        } catch (CloneNotSupportedException e) {
535
            // TODO Auto-generated catch block
536
            e.printStackTrace();
537
        }
538

  
539
        IdentifiableSource sour = IdentifiableSource.NewInstance(OriginalSourceType.Import,null,null, reference,citationDetail);
540
        return sour;
541
    }
542

  
543
    /**
544
     * @param reference
545
     * @param citationDetail
546
     * @return
547
     */
548
    private DescriptionElementSource getDescriptionSource(Reference<?> reference, String citationDetail) {
549

  
550
        List<OriginalSourceBase> issTmp2 = getCommonService().list(DescriptionElementSource.class, null, null, null, null);
551

  
552
        try {
553
            for (OriginalSourceBase<?> osb:issTmp2){
554
                if (osb.getCitation().equals(reference) && osb.getCitationMicroReference().equalsIgnoreCase(citationDetail)) {
555
                    return (DescriptionElementSource) osb.clone();
556
                }
557
            }
558
        } catch (CloneNotSupportedException e) {
559
            // TODO Auto-generated catch block
560
            e.printStackTrace();
561
        }
562

  
563
        DescriptionElementSource sour = DescriptionElementSource.NewInstance(OriginalSourceType.Import,null,null, reference,citationDetail);
564
        return sour;
565
    }
566

  
567

  
487 568
    /**
488 569
     * Very fast and dirty implementation to allow handling of transient objects as described in
489 570
     * https://dev.e-taxonomy.eu/trac/ticket/3726
......
743 824
        determinationEvent.setPreferredFlag(preferredFlag);
744 825

  
745 826
        determinationEvent.setIdentifiedUnit(derivedUnitBase);
746

  
747 827
        derivedUnitBase.addDetermination(determinationEvent);
748 828

  
749 829
        try {
......
844 924
        }
845 925
        if (taxonDescription == null){
846 926
            taxonDescription = TaxonDescription.NewInstance(taxon, false);
847
            taxonDescription.addSource(OriginalSourceType.Import, null, null, ref, null);
927
            if(sourceNotLinkedToElement(taxonDescription,ref,null)) {
928
                taxonDescription.addSource(OriginalSourceType.Import, null, null, ref, null);
929
            }
848 930
            taxon.addDescription(taxonDescription);
849 931
        }
850 932

  
......
865 947

  
866 948

  
867 949
        for( OriginalSourceBase<?> osb:osbSet) {
868
            if(osb.getCitationMicroReference() !=null) {
950
            if(osb.getCitationMicroReference() !=null && !osb.getCitationMicroReference().isEmpty()) {
869 951
                try{
870 952
                    sourceMap.put(osb.getCitation().getTitleCache()+ "---"+osb.getCitationMicroReference(),osb);
871 953
                }catch(NullPointerException e){logger.warn("null pointer problem (no ref?) with "+osb);}
......
879 961
        if (state.getConfig().isInteractWithUser()){
880 962
            List<OriginalSourceBase<?>> res = null;
881 963
            if(!descriptionSourcesSet){
882
                res = sui.askForSourceSource(sourceMap, "the description group ("+taxon+")",
964
                res = sui.askForSource(sourceMap, "the description group ("+taxon+")",
883 965
                        "The current reference is "+ref.getTitleCache(),getReferenceService(), dataHolder.docSources);
884 966
                descriptionRefs=res;
885 967
                descriptionSourcesSet=true;
......
891 973
                for (OriginalSourceBase<?> sour:res){
892 974
                    if(sour.isInstanceOf(IdentifiableSource.class)){
893 975
                        try {
894
                            taxonDescription.addSource((IdentifiableSource)sour.clone());
976
                            if(sourceNotLinkedToElement(taxonDescription,sour)) {
977
                                taxonDescription.addSource((IdentifiableSource)sour.clone());
978
                            }
895 979
                        } catch (CloneNotSupportedException e) {
896 980
                            logger.warn("no cloning?");
897 981
                        }
898 982
                    }else{
899
                        taxonDescription.addSource(OriginalSourceType.Import,null, null, sour.getCitation(),sour.getCitationMicroReference());
983
                        if(sourceNotLinkedToElement(taxonDescription,sour)) {
984
                            taxonDescription.addSource(OriginalSourceType.Import,null, null, sour.getCitation(),sour.getCitationMicroReference());
985
                        }
900 986
                    }
901 987
                }
902 988
            }
903 989
        }
904 990
        else {
991
            if(sourceNotLinkedToElement(taxonDescription,ref,null)) {
905 992
            taxonDescription.addSource(OriginalSourceType.Import,null, null, ref, null);
906 993
        }
994
        }
907 995

  
908 996
        IndividualsAssociation indAssociation = IndividualsAssociation.NewInstance();
909 997
        Feature feature = makeFeature(derivedUnitBase);
......
927 1015

  
928 1016

  
929 1017
            for( OriginalSourceBase<?> osb:osbSet) {
930
                if(osb.getCitationMicroReference() !=null) {
1018
                if(osb.getCitationMicroReference() !=null && !osb.getCitationMicroReference().isEmpty()) {
931 1019
                    try{
932 1020
                        sourceMap.put(osb.getCitation().getTitleCache()+ "---"+osb.getCitationMicroReference(),osb);
933 1021
                    }catch(NullPointerException e){logger.warn("null pointer problem (no ref?) with "+osb);}
......
940 1028

  
941 1029
            List<OriginalSourceBase<?>> sources =null;
942 1030
            if(!associationSourcesSet) {
943
                sources = sui.askForSourceSource(sourceMap,  "descriptive element (association) ",taxon.toString(),
1031
                sources = sui.askForSource(sourceMap,  "descriptive element (association) ",taxon.toString(),
944 1032
                        getReferenceService(),dataHolder.docSources);
945 1033
                associationRefs=sources;
946 1034
                associationSourcesSet=true;
......
953 1041
                    if(source !=null) {
954 1042
                        if(source.isInstanceOf(DescriptionElementSource.class)){
955 1043
                            try {
956
                                indAssociation.addSource((DescriptionElementSource)source.clone());
1044
                                if(sourceNotLinkedToElement(indAssociation,source)) {
1045
                                    indAssociation.addSource((DescriptionElementSource)source.clone());
1046
                                }
957 1047
                            } catch (CloneNotSupportedException e) {
958 1048
                                logger.warn("clone forbidden?");
959 1049
                            }
960 1050
                        }else{
961
                            indAssociation.addSource(OriginalSourceType.Import,null, null, source.getCitation(),source.getCitationMicroReference());
1051
                            if(sourceNotLinkedToElement(indAssociation,source)) {
1052
                                indAssociation.addSource(OriginalSourceType.Import,null, null, source.getCitation(),source.getCitationMicroReference());
1053
                            }
1054
                            try {
1055
                                if(sourceNotLinkedToElement(derivedUnitBase, source)) {
1056
                                    derivedUnitBase.addSource((IdentifiableSource) source.clone());
1057
                                }
1058
                            } catch (CloneNotSupportedException e) {
1059
                                // TODO Auto-generated catch block
1060
                                e.printStackTrace();
1061
                            }
962 1062
                        }
963 1063

  
964 1064
                    }
965 1065
                }
966 1066
            }
967 1067
        }else {
968
            indAssociation.addSource(OriginalSourceType.Import,null, null, ref, null);
969
            //=======
1068
            if(sourceNotLinkedToElement(indAssociation,ref,null)) {
1069
                indAssociation.addSource(OriginalSourceType.Import,null, null, ref, null);
1070
            }
1071
                if(sourceNotLinkedToElement(derivedUnitBase, ref,null)) {
1072
                    derivedUnitBase.addSource(OriginalSourceType.Import,null, null, ref, null);
1073
                }
970 1074
            for (Reference<?> citation : determinationEvent.getReferences()) {
971
                indAssociation.addSource(DescriptionElementSource.NewInstance(OriginalSourceType.Import, null, null, citation, null));
972
                //>>>>>>> .fusion-droit.r19057
1075
                if(sourceNotLinkedToElement(indAssociation,citation,null))
1076
                 {
1077
                    indAssociation.addSource(DescriptionElementSource.NewInstance(OriginalSourceType.Import, null, null, citation, null));
1078
                }
1079
                    if(sourceNotLinkedToElement(derivedUnitBase, ref,null)) {
1080
                        derivedUnitBase.addSource(OriginalSourceType.Import,null, null, ref, null);
1081
                    }
973 1082
            }
974 1083
        }
975 1084

  
......
982 1091

  
983 1092

  
984 1093

  
1094
    /**
1095
     * @param derivedUnitBase2
1096
     * @param ref2
1097
     * @param object
1098
     * @return
1099
     */
1100
    private boolean sourceNotLinkedToElement(DerivedUnit derivedUnitBase2, Reference<?> b, String d) {
1101
        Set<IdentifiableSource> linkedSources = derivedUnitBase2.getSources();
1102
        for (IdentifiableSource is:linkedSources){
1103
            Reference a = is.getCitation();
1104
            String c = is.getCitationMicroReference();
1105

  
1106
            boolean refMatch=false;
1107
            boolean microMatch=false;
1108

  
1109
            try{
1110
                if (a==null && b==null) {
1111
                    refMatch=true;
1112
                }
1113
                if (a!=null && b!=null) {
1114
                    if (a.getTitleCache().equalsIgnoreCase(b.getTitleCache())) {
1115
                        refMatch=true;
1116
                    }
1117
                }
1118
            }catch(Exception e){}
1119

  
1120

  
1121
            try{
1122
                if (c==null && d==null) {
1123
                    microMatch=true;
1124
                }
1125
                if(c!=null && d!=null) {
1126
                    if(c.equalsIgnoreCase(d)) {
1127
                        microMatch=true;
1128
                    }
1129
                }
1130
            }
1131
            catch(Exception e){}
1132

  
1133
            if (microMatch && refMatch) {
1134
                return false;
1135
            }
1136

  
1137

  
1138
        }
1139
        return true;
1140
    }
1141

  
1142
    /**
1143
     * @param derivedUnitBase2
1144
     * @param source
1145
     * @return
1146
     */
1147
    private boolean sourceNotLinkedToElement(DerivedUnit derivedUnitBase2, OriginalSourceBase<?> source) {
1148
        Set<IdentifiableSource> linkedSources = derivedUnitBase2.getSources();
1149
        for (IdentifiableSource is:linkedSources){
1150
            Reference a = is.getCitation();
1151
            Reference b = source.getCitation();
1152
            String c = is.getCitationMicroReference();
1153
            String d = source.getCitationMicroReference();
1154

  
1155
            boolean refMatch=false;
1156
            boolean microMatch=false;
1157

  
1158
            try{
1159
                if (a==null && b==null) {
1160
                    refMatch=true;
1161
                }
1162
                if (a!=null && b!=null) {
1163
                    if (a.getTitleCache().equalsIgnoreCase(b.getTitleCache())) {
1164
                        refMatch=true;
1165
                    }
1166
                }
1167
            }catch(Exception e){}
1168

  
1169

  
1170
            try{
1171
                if (c==null && d==null) {
1172
                    microMatch=true;
1173
                }
1174
                if(c!=null && d!=null) {
1175
                    if(c.equalsIgnoreCase(d)) {
1176
                        microMatch=true;
1177
                    }
1178
                }
1179
            }
1180
            catch(Exception e){}
1181

  
1182
            if (microMatch && refMatch) {
1183
                return false;
1184
            }
1185

  
1186

  
1187
        }
1188
        return true;
1189
    }
1190

  
1191
    /**
1192
     * @param indAssociation
1193
     * @param ref2
1194
     * @param object
1195
     * @return
1196
     */
1197
    private boolean sourceNotLinkedToElement(IndividualsAssociation indAssociation, Reference<?> a, String d) {
1198
        Set<DescriptionElementSource> linkedSources = indAssociation.getSources();
1199
        for (DescriptionElementSource is:linkedSources){
1200
            Reference b = is.getCitation();
1201
            String c = is.getCitationMicroReference();
1202

  
1203
            boolean refMatch=false;
1204
            boolean microMatch=false;
1205

  
1206
            try{
1207
                if (a==null && b==null) {
1208
                    refMatch=true;
1209
                }
1210
                if (a!=null && b!=null) {
1211
                    if (a.getTitleCache().equalsIgnoreCase(b.getTitleCache())) {
1212
                        refMatch=true;
1213
                    }
1214
                }
1215
            }catch(Exception e){}
1216

  
1217

  
1218
            try{
1219
                if (c==null && d==null) {
1220
                    microMatch=true;
1221
                }
1222
                if(c!=null && d!=null) {
1223
                    if(c.equalsIgnoreCase(d)) {
1224
                        microMatch=true;
1225
                    }
1226
                }
1227
            }
1228
            catch(Exception e){}
1229

  
1230
            if (microMatch && refMatch) {
1231
                return false;
1232
            }
1233
        }
1234
        return true;
1235
    }
1236

  
1237
    /**
1238
     * @param taxonDescription
1239
     * @param ref2
1240
     * @param object
1241
     * @return
1242
     */
1243
    private boolean sourceNotLinkedToElement(TaxonDescription taxonDescription, Reference<?> a, String d) {
1244
        Set<IdentifiableSource> linkedSources = taxonDescription.getSources();
1245
        for (IdentifiableSource is:linkedSources){
1246
            Reference b = is.getCitation();
1247
            String c = is.getCitationMicroReference();
1248

  
1249
            boolean refMatch=false;
1250
            boolean microMatch=false;
1251

  
1252
            try{
1253
                if (a==null && b==null) {
1254
                    refMatch=true;
1255
                }
1256
                if (a!=null && b!=null) {
1257
                    if (a.getTitleCache().equalsIgnoreCase(b.getTitleCache())) {
1258
                        refMatch=true;
1259
                    }
1260
                }
1261
            }catch(Exception e){}
1262

  
1263

  
1264
            try{
1265
                if (c==null && d==null) {
1266
                    microMatch=true;
1267
                }
1268
                if(c!=null && d!=null) {
1269
                    if(c.equalsIgnoreCase(d)) {
1270
                        microMatch=true;
1271
                    }
1272
                }
1273
            }
1274
            catch(Exception e){}
1275

  
1276
            if (microMatch && refMatch) {
1277
                return false;
1278
            }
1279
        }
1280
        return true;
1281
    }
1282

  
1283
    /**
1284
     * @param indAssociation
1285
     * @param source
1286
     * @return
1287
     */
1288
    private boolean sourceNotLinkedToElement(IndividualsAssociation indAssociation, OriginalSourceBase<?> source) {
1289
        Set<DescriptionElementSource> linkedSources = indAssociation.getSources();
1290
        for (DescriptionElementSource is:linkedSources){
1291
            Reference a = is.getCitation();
1292
            Reference b = source.getCitation();
1293
            String c = is.getCitationMicroReference();
1294
            String d = source.getCitationMicroReference();
1295

  
1296
            boolean refMatch=false;
1297
            boolean microMatch=false;
1298

  
1299
            try{
1300
                if (a==null && b==null) {
1301
                    refMatch=true;
1302
                }
1303
                if (a!=null && b!=null) {
1304
                    if (a.getTitleCache().equalsIgnoreCase(b.getTitleCache())) {
1305
                        refMatch=true;
1306
                    }
1307
                }
1308
            }catch(Exception e){}
1309

  
1310

  
1311
            try{
1312
                if (c==null && d==null) {
1313
                    microMatch=true;
1314
                }
1315
                if(c!=null && d!=null) {
1316
                    if(c.equalsIgnoreCase(d)) {
1317
                        microMatch=true;
1318
                    }
1319
                }
1320
            }
1321
            catch(Exception e){}
1322

  
1323
            if (microMatch && refMatch) {
1324
                return false;
1325
            }
1326
        }
1327
        return true;
1328
    }
1329

  
1330
    /**
1331
     * @param taxonDescription
1332
     * @param sour
1333
     * @return
1334
     */
1335
    private boolean sourceNotLinkedToElement(TaxonDescription taxonDescription, OriginalSourceBase<?> sour) {
1336
        Set<IdentifiableSource> linkedSources = taxonDescription.getSources();
1337
        for (IdentifiableSource is:linkedSources){
1338
            Reference a = is.getCitation();
1339
            Reference b = sour.getCitation();
1340
            String c = is.getCitationMicroReference();
1341
            String d = sour.getCitationMicroReference();
1342

  
1343
            boolean refMatch=false;
1344
            boolean microMatch=false;
1345

  
1346
            try{
1347
                if (a==null && b==null) {
1348
                    refMatch=true;
1349
                }
1350
                if (a!=null && b!=null) {
1351
                    if (a.getTitleCache().equalsIgnoreCase(b.getTitleCache())) {
1352
                        refMatch=true;
1353
                    }
1354
                }
1355
            }catch(Exception e){}
1356

  
1357

  
1358
            try{
1359
                if (c==null && d==null) {
1360
                    microMatch=true;
1361
                }
1362
                if(c!=null && d!=null) {
1363
                    if(c.equalsIgnoreCase(d)) {
1364
                        microMatch=true;
1365
                    }
1366
                }
1367
            }
1368
            catch(Exception e){}
1369

  
1370
            if (microMatch && refMatch) {
1371
                return false;
1372
            }
1373

  
1374

  
1375
        }
1376
        return true;
1377
    }
1378

  
985 1379
    /**
986 1380
     * look for the Feature object (FieldObs, Specimen,...)
987 1381
     * @param unit : a specimen or obersvation base

Also available in: Unified diff