Project

General

Profile

« Previous | Next » 

Revision 23a201e7

Added by Andreas Müller over 4 years ago

ref #1444, ref #8508, ref #8508 Finish ERMS image import and some export improvement (not yet ready)

View differences:

cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/erms/ErmsImageImport.java
76 76
		if (mapping == null){
77 77
			mapping = new DbImportMapping<>();
78 78
			//TODO do we need to add to TaxonNameBase too?
79
			//Often images are attached to synonyms
79 80
			String idAttribute = null;
80 81
			boolean isOneTextData = true;
81 82
			mapping.addMapper(DbImportImageCreationMapper.NewInstance(idAttribute, IMAGE_NAMESPACE, "tu_id", ErmsImportBase.TAXON_NAMESPACE, isOneTextData));
cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/out/PesiDescriptionExport.java
63 63
import eu.etaxonomy.cdm.model.description.TaxonNameDescription;
64 64
import eu.etaxonomy.cdm.model.description.TextData;
65 65
import eu.etaxonomy.cdm.model.location.NamedArea;
66
import eu.etaxonomy.cdm.model.media.Media;
67
import eu.etaxonomy.cdm.model.media.MediaRepresentation;
68
import eu.etaxonomy.cdm.model.media.MediaRepresentationPart;
66 69
import eu.etaxonomy.cdm.model.name.TaxonName;
67 70
import eu.etaxonomy.cdm.model.taxon.Taxon;
68 71
import eu.etaxonomy.cdm.model.taxon.TaxonBase;
......
825 828
		return result;
826 829
	}
827 830

  
831
    @SuppressWarnings("unused")  //used by mapper
832
    private static String getMediaThumb(DescriptionElementBase deb) {
833
        //FIXME does not yet support multiple images per deb
834
        String startsWith = "http://images.vliz.be/thumbs/";
835
        String result = null;
836
        List<Media> medias = deb.getMedia();
837
        for (Media media : medias){
838
            for (MediaRepresentation rep : media.getRepresentations()){
839
                for (MediaRepresentationPart part : rep.getParts()){
840
                    String strUrl = part.getUri().toString();
841
                    if (strUrl.startsWith(startsWith)){
842
                        result = part.getUri().toString();
843
                    }
844
                }
845
            }
846
        }
847
        return result;
848
    }
849

  
850
    @SuppressWarnings("unused")  //used by mapper
851
    private static String getMediaUrl(DescriptionElementBase deb) {
852
        //FIXME does not yet support multiple images per deb
853
        String startsWith = "http://www.marbef.org/data/aphia.php?p=image&pic=";
854
        String result = null;
855
        List<Media> medias = deb.getMedia();
856
        for (Media media : medias){
857
            for (MediaRepresentation rep : media.getRepresentations()){
858
                for (MediaRepresentationPart part : rep.getParts()){
859
                    String strUrl = part.getUri().toString();
860
                    if (strUrl.startsWith(startsWith)){
861
                        result = part.getUri().toString();
862
                    }
863
                }
864
            }
865
        }
866
        return result;
867
    }
868

  
869
//******************************* MAPPINGS ********************************************
828 870

  
829 871
	/**
830 872
	 * Returns the CDM to PESI specific export mappings for PESI notes.
......
973 1015
	}
974 1016

  
975 1017
	private PesiExportMapping getImageMapping() {
976
		PesiExportMapping mapping = new PesiExportMapping(dbImageTableName);
977
		mapping.addMapper(DbDescriptionElementTaxonMapper.NewInstance("taxonFk"));
978 1018

  
979
		//TODO xxx
1019
	    //FIXME does not yet support multiple images per image gallery
980 1020

  
1021
	    PesiExportMapping mapping = new PesiExportMapping(dbImageTableName);
1022
		mapping.addMapper(DbDescriptionElementTaxonMapper.NewInstance("taxonFk"));
1023
		mapping.addMapper(MethodMapper.NewInstance("img_thumb", this, "getMediaThumb"));
1024
		mapping.addMapper(MethodMapper.NewInstance("img_url", this, "getMediaUrl"));
981 1025
		return mapping;
982 1026
	}
983 1027

  

Also available in: Unified diff