Project

General

Profile

« Previous | Next » 

Revision 93c502fa

Added by Katja Luther over 2 years ago

ref #9736: add name_fk and preferred source fk to specimen type table

View differences:

cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/cdmLight/CdmLightClassificationExport.java
1403 1403
        if (specimenType.getSources() != null && !specimenType.getSources().isEmpty()){
1404 1404
            String sourceString = "";
1405 1405
            int index = 0;
1406
            for (IdentifiableSource source: specimenType.getSources()){
1406
            List<IdentifiableSource> sources = new ArrayList<>(specimenType.getSources());
1407
            Comparator<IdentifiableSource> compareByYear = new Comparator<IdentifiableSource>() {
1408
                @Override
1409
                public int compare(IdentifiableSource o1, IdentifiableSource o2) {
1410
                    if (o1 == o2){
1411
                        return 0;
1412
                    }
1413
                    if (o1.getCitation() == null && o2.getCitation() != null){
1414
                        return -1;
1415
                    }
1416
                    if (o2.getCitation() == null && o1.getCitation() != null){
1417
                        return 1;
1418
                    }
1419
                    if (o1.getCitation().equals(o2.getCitation())){
1420
                        return 0;
1421
                    }
1422
                    if (o1.getCitation().getDatePublished() == null && o2.getCitation().getDatePublished() != null){
1423
                        return -1;
1424
                    }
1425
                    if (o1.getCitation().getDatePublished() != null && o2.getCitation().getDatePublished() == null){
1426
                        return 1;
1427
                    }
1428
                    if (o1.getCitation().getDatePublished().getYear() == null && o2.getCitation().getDatePublished().getYear() != null){
1429
                        return -1;
1430
                    }
1431
                    if (o1.getCitation().getDatePublished().getYear() != null && o2.getCitation().getDatePublished().getYear() == null){
1432
                        return 1;
1433
                    }
1434
                    return o1.getCitation().getDatePublished().getYear().compareTo(o2.getCitation().getDatePublished().getYear());
1435
                }
1436
            };
1437
            Collections.sort(sources, compareByYear);
1438
            for (IdentifiableSource source: sources){
1407 1439
                if (source.getCitation()!= null){
1408 1440
                    sourceString = sourceString.concat(source.getCitation().getCitation());
1441
                    handleReference(state, source.getCitation());
1409 1442
                }
1410 1443
                index++;
1411
                if (index != specimenType.getSources().size()){
1412
                    sourceString.concat(", ");
1444
                if (index <= specimenType.getSources().size()){
1445
                    sourceString = sourceString.concat("; ");
1413 1446
                }
1414 1447
            }
1448

  
1415 1449
            csvLine[table.getIndex(CdmLightExportTable.TYPE_INFORMATION_REF_STRING)] = sourceString;
1450
            if (sources.get(0).getCitation() != null ){
1451
                csvLine[table.getIndex(CdmLightExportTable.TYPE_INFORMATION_REF_FK)] = getId(state, sources.get(0).getCitation());
1452
            }
1416 1453
        }
1417 1454
        if (specimenType.getDesignationSource() != null && specimenType.getDesignationSource().getCitation() != null && !state.getReferenceStore().contains(specimenType.getDesignationSource().getCitation().getUuid())){
1418 1455
            handleReference(state, specimenType.getDesignationSource().getCitation());
1419 1456
            csvLine[table.getIndex(CdmLightExportTable.TYPE_DESIGNATED_BY_REF_FK)] = specimenType.getDesignationSource() != null ? getId(state, specimenType.getDesignationSource().getCitation()): "";
1420 1457
        }
1421
        state.getProcessor().put(table, specimenType, csvLine);
1422 1458

  
1423
        //TYPE_ID, SPECIMEN_FK, TYPE_VERBATIM_CITATION, TYPE_STATUS, TYPE_DESIGNATED_BY_STRING, TYPE_DESIGNATED_BY_REF_FK};
1424
        //Specimen_Fk und den Typusangaben (Art des Typus [holo, lecto, etc.], Quelle, Designation-Quelle, +
1459

  
1425 1460
        Set<TaxonName> typifiedNames = specimenType.getTypifiedNames();
1426
        table = CdmLightExportTable.TYPE_SPECIMEN_NAME;
1427
        for (TaxonName name: typifiedNames){
1428
            csvLine = new String[table.getSize()];
1429
            csvLine[table.getIndex(CdmLightExportTable.NAME_FK)] = getId(state, name);
1430
            csvLine[table.getIndex(CdmLightExportTable.TYPE_FK)] = getId(state, specimenType);
1431
            state.getProcessor().put(table, specimenType.getUuid().toString() + "-" + name.getUuid().toString(), csvLine);
1461

  
1462
        if (typifiedNames.size() > 1){
1463
            state.getResult().addWarning("Please check the specimen type  "
1464
                    + cdmBaseStr(specimenType) + " there are more then one typified name.");
1432 1465
        }
1466
        if (typifiedNames.iterator().hasNext()){
1467
            TaxonName name = typifiedNames.iterator().next();
1468
            csvLine[table.getIndex(CdmLightExportTable.TYPIFIED_NAME_FK)] = getId(state, name);
1469
        }
1470
        state.getProcessor().put(table, specimenType, csvLine);
1433 1471

  
1434 1472

  
1435 1473

  
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/cdmLight/CdmLightExportTable.java
195 195
    protected static final String TYPE_VERBATIM_CITATION = "TypeVerbatimCitation";
196 196
    protected static final String TYPE_STATUS = "TypeStatus";
197 197
    protected static final String TYPE_INFORMATION_REF_STRING = "TypeInformationSource";
198
    protected static final String TYPE_INFORMATION_REF_FK = "TypeInfoSourcePreferred_Fk";
198 199
    protected static final String TYPE_DESIGNATED_BY_REF_FK = "TypeDesignatedBy_Fk";
199 200

  
200 201
    //Type_Name_Rel
......
355 356
    }
356 357

  
357 358
    final static String[] typeDesignationColumns(){
358
        return new String[]{TYPE_ID, SPECIMEN_FK, //TYPIFIED_NAME_FK, TYPE_VERBATIM_CITATION,
359
                TYPE_STATUS, TYPE_INFORMATION_REF_STRING, TYPE_DESIGNATED_BY_REF_FK};
359
        return new String[]{TYPE_ID, TYPIFIED_NAME_FK, SPECIMEN_FK, //TYPE_VERBATIM_CITATION,
360
                TYPE_STATUS, TYPE_DESIGNATED_BY_REF_FK, TYPE_INFORMATION_REF_STRING, TYPE_INFORMATION_REF_FK};
360 361

  
361 362
    }
362 363

  

Also available in: Unified diff