Revision c3a6a3bf
Added by Andreas Müller over 7 years ago
app-import/src/main/java/eu/etaxonomy/cdm/io/berlinModel/in/BerlinModelFactsImport.java | ||
---|---|---|
63 | 63 |
import eu.etaxonomy.cdm.model.description.TextData; |
64 | 64 |
import eu.etaxonomy.cdm.model.location.Country; |
65 | 65 |
import eu.etaxonomy.cdm.model.location.NamedArea; |
66 |
import eu.etaxonomy.cdm.model.location.NamedAreaLevel; |
|
67 |
import eu.etaxonomy.cdm.model.location.NamedAreaType; |
|
66 | 68 |
import eu.etaxonomy.cdm.model.media.ImageFile; |
67 | 69 |
import eu.etaxonomy.cdm.model.media.Media; |
68 | 70 |
import eu.etaxonomy.cdm.model.media.MediaRepresentation; |
... | ... | |
484 | 486 |
*/ |
485 | 487 |
private void mergeSalvadorDistribution(TaxonDescription taxonDescription, |
486 | 488 |
@NotNull Distribution newDistribution) { |
489 |
|
|
487 | 490 |
Distribution existingDistribution = null; |
488 | 491 |
for (DescriptionElementBase deb : taxonDescription.getElements()){ |
489 | 492 |
if (deb.isInstanceOf(Distribution.class)){ |
... | ... | |
523 | 526 |
if (area == null){ |
524 | 527 |
logger.info("Added Salvador area: " + areaString); |
525 | 528 |
TermVocabulary<NamedArea> voc = getVocabulary(TermType.NamedArea, BerlinModelTransformer.uuidSalvadorAreas, |
526 |
"Salvador areas", "Salvador areas", null, null, true, NamedArea.NewInstance()); |
|
529 |
"Salvador departments", "Salvador departments", null, null, true, NamedArea.NewInstance()); |
|
530 |
if (voc.getRepresentation(Language.SPANISH_CASTILIAN()) == null){ |
|
531 |
voc.addRepresentation(Representation.NewInstance("Salvador departamentos", "Salvador departamentos", "dep.", Language.SPANISH_CASTILIAN())); |
|
532 |
getVocabularyService().saveOrUpdate(voc); |
|
533 |
} |
|
527 | 534 |
NamedArea newArea = NamedArea.NewInstance(areaString, areaString, null); |
528 | 535 |
newArea.getRepresentations().iterator().next().setLanguage(Language.SPANISH_CASTILIAN()); |
536 |
newArea.setLevel(NamedAreaLevel.DEPARTMENT()); |
|
537 |
newArea.setType(NamedAreaType.ADMINISTRATION_AREA()); |
|
529 | 538 |
voc.addTerm(newArea); |
530 | 539 |
getTermService().saveOrUpdate(newArea); |
531 | 540 |
salvadorAreaMap.put(areaString, newArea); |
541 |
area = newArea; |
|
532 | 542 |
} |
533 | 543 |
PresenceAbsenceTerm state = getSalvadorDistributionState(taxon); |
534 | 544 |
result = Distribution.NewInstance(area, state); |
... | ... | |
713 | 723 |
int page = intFact + 249; |
714 | 724 |
if (intFact >= 263){ |
715 | 725 |
vol = "2016"; |
716 |
page = intFact + (intFact < 403 ? 95 : 96);
|
|
726 |
page = intFact - (intFact < 403 ? 95 : 94);
|
|
717 | 727 |
}else if (intFact >= 142){ |
718 | 728 |
vol = "2012"; |
719 | 729 |
page = intFact + (intFact < 255 ? 3 : 4); |
720 | 730 |
} |
721 |
String title = getSalvadorImageTitle(intFact);
|
|
722 |
media.putTitle(Language.SPANISH_CASTILIAN(), title);
|
|
731 |
String description = getSalvadorImageTitle(intFact);
|
|
732 |
media.putDescription(Language.SPANISH_CASTILIAN(), description);
|
|
723 | 733 |
|
724 | 734 |
Reference ref = getSalvadorReference(vol); |
725 | 735 |
String originalName = getSalvadorImageNameInfo(intFact); |
726 |
IdentifiableSource source = media.addSource(OriginalSourceType.PrimaryMediaSource, fact, "Fig.", ref, String.valueOf(page));
|
|
736 |
IdentifiableSource source = media.addSource(OriginalSourceType.PrimaryMediaSource, fact, "Fig.", ref, "p. " + page);
|
|
727 | 737 |
source.setOriginalNameString(originalName); |
728 | 738 |
media.setArtist(getSalvadorArtist()); |
729 | 739 |
media.addRights(getSalvadorCopyright(vol)); |
... | ... | |
777 | 787 |
} |
778 | 788 |
} |
779 | 789 |
|
780 |
/** |
|
781 |
* |
|
782 |
*/ |
|
783 | 790 |
private void initSalvadorImagesFile() { |
784 | 791 |
if (salvadorImages == null){ |
785 | 792 |
salvadorImages = new HashMap<>(); |
... | ... | |
787 | 794 |
CSVReader reader = new CSVReader(CdmUtils.getUtf8ResourceReader("salvador" + CdmUtils.getFolderSeperator() + "SalvadorImages.csv"),';'); |
788 | 795 |
List<String[]> lines = reader.readAll(); |
789 | 796 |
for (String[] line : lines){ |
790 |
if(! "ID".equals(line[0])){ |
|
791 |
salvadorImages.put(Integer.valueOf(line[0]), line); |
|
797 |
String first = line[0]; |
|
798 |
if(! "ID".equals(first)){ |
|
799 |
try { |
|
800 |
salvadorImages.put(Integer.valueOf(first), line); |
|
801 |
} catch (NumberFormatException e) { |
|
802 |
logger.warn("Number not recognized: " + first); |
|
803 |
} |
|
792 | 804 |
} |
793 | 805 |
} |
794 | 806 |
reader.close(); |
... | ... | |
799 | 811 |
} |
800 | 812 |
|
801 | 813 |
|
814 |
private Rights rights1; |
|
815 |
private Rights rights2; |
|
816 |
private Rights rights3; |
|
817 |
|
|
802 | 818 |
private Rights getSalvadorCopyright(String vol) { |
803 |
String text;
|
|
819 |
initRights();
|
|
804 | 820 |
if ("2009".equals(vol)){ |
805 |
text = "(c) Jardín Botánico y Museo Botánico Berlin-Dahlem & Asociación Jardín Botánico La Laguna. Berlin, Antiguo Cuscatlán 2009.";
|
|
821 |
return rights1;
|
|
806 | 822 |
}else if ("2012".equals(vol)){ |
807 |
text = "(c) Jardín Botánico y Museo Botánico Berlin-Dahlem & Asociación Jardín Botánico La Laguna. Berlin, Antiguo Cuscatlán 2012.";
|
|
823 |
return rights1;
|
|
808 | 824 |
}else if ("2016".equals(vol)){ |
809 |
text = "(c) Jardín Botánico y Museo Botánico Berlin-Dahlem & Asociación Jardín Botánico La Laguna. Berlin, Antiguo Cuscatlán 2016.";
|
|
825 |
return rights3;
|
|
810 | 826 |
}else{ |
811 | 827 |
throw new RuntimeException("Volume not recognized: " + vol); |
812 | 828 |
} |
813 |
Rights result = Rights.NewInstance(text, Language.SPANISH_CASTILIAN(), RightsType.COPYRIGHT()); |
|
814 |
return result; |
|
815 | 829 |
} |
816 | 830 |
|
831 |
private void initRights(){ |
|
832 |
if (rights1 == null){ |
|
833 |
String text = "(c) Jardín Botánico y Museo Botánico Berlin-Dahlem & Asociación Jardín Botánico La Laguna. Berlin, Antiguo Cuscatlán 2009."; |
|
834 |
rights1 = Rights.NewInstance(text, Language.SPANISH_CASTILIAN(), RightsType.COPYRIGHT()); |
|
835 |
text = "(c) Jardín Botánico y Museo Botánico Berlin-Dahlem & Asociación Jardín Botánico La Laguna. Berlin, Antiguo Cuscatlán 2012."; |
|
836 |
rights2 = Rights.NewInstance(text, Language.SPANISH_CASTILIAN(), RightsType.COPYRIGHT()); |
|
837 |
text = "(c) Jardín Botánico y Museo Botánico Berlin-Dahlem & Asociación Jardín Botánico La Laguna. Berlin, Antiguo Cuscatlán 2016."; |
|
838 |
rights3 = Rights.NewInstance(text, Language.SPANISH_CASTILIAN(), RightsType.COPYRIGHT()); |
|
839 |
getCommonService().save(rights1); |
|
840 |
getCommonService().save(rights2); |
|
841 |
getCommonService().save(rights3); |
|
842 |
} |
|
843 |
} |
|
817 | 844 |
|
818 | 845 |
private Integer salvadorArtistId; |
819 | 846 |
private AgentBase<?> getSalvadorArtist() { |
... | ... | |
916 | 943 |
ImageInfo imageInfo = null; |
917 | 944 |
Integer size = null; |
918 | 945 |
try { |
919 |
imageInfo = ImageInfo.NewInstance(uri, 0); |
|
946 |
imageInfo = ImageInfo.NewInstance(uri, 30);
|
|
920 | 947 |
} catch (IOException | HttpException e) { |
921 | 948 |
logger.error("Error when reading image meta: " + e + ", "+ uri.toString()); |
922 | 949 |
} |
Also available in: Unified diff
ref #6252 and ref #3934 Improve image import, fix distribution import and add area level / type