Project

General

Profile

« Previous | Next » 

Revision aaf7e87c

Added by Andreas Müller over 7 years ago

ref #6252 updates for salvador image import

View differences:

app-import/src/main/java/eu/etaxonomy/cdm/io/berlinModel/in/BerlinModelFactsImport.java
701 701
	        Reference sourceRef = state.getTransactionalSourceReference();
702 702
    		URI uri;
703 703
    		URI thumbUri;
704
    		ImageInfo imageInfo = null;
705
    		ImageInfo thumbImageInfo = null;
706
    		if (!state.getConfig().isSalvador()){
704
    		if (state.getConfig().isSalvador()){
707 705
    		    String thumbs = "thumbs/";
708 706
    		    String uriStr = "http://media.e-taxonomy.eu/salvador/berendsohn-et-al-%s/%s.jpg";
709 707
    		    Integer intFact = Integer.valueOf(fact);
......
711 709
    		    int page = intFact + 249;
712 710
                if (intFact >= 263){
713 711
    		        vol = "2016";
712
    		        page = intFact + (intFact < 403 ? 95 : 96);
714 713
    		    }else if (intFact >= 142){
715 714
    		        vol = "2012";
716 715
    		        page = intFact + (intFact < 255 ? 3 : 4);
717 716
    		    }
717
                media.putTitle(Language.SPANISH_CASTILIAN(), fact);
718 718
    		    Reference ref = getSalvadorReference(vol);
719 719
    		    media.addSource(OriginalSourceType.PrimaryMediaSource, "Fig. " + fact, null, ref, String.valueOf(page));
720 720
    		    media.setArtist(getSalvadorArtist());
......
723 723
    		    String thumbUriStr = String.format(uriStr, vol, thumbs + fact);
724 724
    		    uri = new URI(uriStr);
725 725
    		    thumbUri = new URI(thumbUriStr);
726
    		    if (!state.getConfig().isSalvador()){
727
                    try {
728
                        imageInfo = ImageInfo.NewInstance(uri, 0);
729
                    } catch (IOException | HttpException e) {
730
                        logger.error("Error when reading image meta: " + e);
731
                    }
732
                    try {
733
                        thumbImageInfo = ImageInfo.NewInstance(thumbUri, 0);
734
                    } catch (IOException | HttpException e) {
735
                        logger.error("Error when reading image meta: " + e);
736
                    }
737
                }
738 726
    		}else{
739 727
    		    uri = new URI(fact.trim());
740 728
    		    thumbUri = null;
741 729
    		}
742 730

  
743
    		Integer size = null;
744

  
745
    		makeMediaRepresentation(media, uri, imageInfo, size);
731
    		makeMediaRepresentation(media, uri);
746 732
    		if (thumbUri != null){
747
                makeMediaRepresentation(media, thumbUri, thumbImageInfo, size);
733
                makeMediaRepresentation(media, thumbUri);
748 734
    		}
749 735

  
750 736
    		taxonDescription = taxon.getOrCreateImageGallery(sourceRef == null ? null :sourceRef.getTitleCache());
......
758 744
    private Rights getSalvadorCopyright(String vol) {
759 745
        String text;
760 746
        if ("2009".equals(vol)){
761
            text = "(c) Botanic Garden and Botanical Museum Berlin-Dahlem & Asociación Jardín Botánico La Laguna. Berlin, Antiguo Cuscatlán 2009.";
747
            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.";
762 748
        }else if ("2012".equals(vol)){
763
            text = "(c) Botanic Garden and Botanical Museum Berlin-Dahlem & Asociación Jardín Botánico La Laguna. Berlin, Antiguo Cuscatlán 2012.";
749
            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.";
764 750
        }else if ("2016".equals(vol)){
765 751
            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.";
766 752
        }else{
......
868 854
     * @param imageInfo
869 855
     * @param size
870 856
     */
871
    private void makeMediaRepresentation(Media media, URI uri, ImageInfo imageInfo, Integer size) {
857
    private void makeMediaRepresentation(Media media, URI uri) {
858
        ImageInfo imageInfo = null;
859
        Integer size = null;
860
        try {
861
            imageInfo = ImageInfo.NewInstance(uri, 0);
862
        } catch (IOException | HttpException e) {
863
            logger.error("Error when reading image meta: " + e + ", "+ uri.toString());
864
        }
872 865
        String mimeType = imageInfo == null ? null : imageInfo.getMimeType();
873 866
        String suffix = imageInfo == null ? null : imageInfo.getSuffix();
874 867
        MediaRepresentation mediaRepresentation = MediaRepresentation.NewInstance(mimeType, suffix);

Also available in: Unified diff