Revision 92fdeae1
Added by Andreas Müller about 3 years ago
app-import/src/main/java/eu/etaxonomy/cdm/app/cyprus/CyprusImagesActivator.java | ||
---|---|---|
39 | 39 |
import eu.etaxonomy.cdm.api.service.config.MatchingTaxonConfigurator; |
40 | 40 |
import eu.etaxonomy.cdm.app.common.CdmDestinations; |
41 | 41 |
import eu.etaxonomy.cdm.common.UTF8; |
42 |
import eu.etaxonomy.cdm.common.media.ImageInfo; |
|
42 |
import eu.etaxonomy.cdm.common.media.CdmImageInfo;
|
|
43 | 43 |
import eu.etaxonomy.cdm.database.DbSchemaValidation; |
44 | 44 |
import eu.etaxonomy.cdm.database.ICdmDataSource; |
45 | 45 |
import eu.etaxonomy.cdm.io.api.application.CdmIoApplicationController; |
... | ... | |
462 | 462 |
media.addRepresentation(representation); |
463 | 463 |
|
464 | 464 |
if (uriStrThumb != null){ |
465 |
ImageInfo imageInfoThumb = null; |
|
465 |
CdmImageInfo imageInfoThumb = null;
|
|
466 | 466 |
uriStrThumb = uriStrThumb.replace(" ", "%20"); //replace whitespace |
467 | 467 |
URI uriThumb = new URI(uriStrThumb); |
468 | 468 |
try { |
469 | 469 |
if (readMediaData){ |
470 | 470 |
logger.info("Read media data from: " + uriThumb); |
471 |
imageInfoThumb = ImageInfo.NewInstance(uriThumb, 0); |
|
471 |
imageInfoThumb = CdmImageInfo.NewInstance(uriThumb, 0);
|
|
472 | 472 |
} |
473 | 473 |
} catch (Exception e) { |
474 | 474 |
String message = "An error occurred when trying to read image meta data for " + uriThumb.toString() + ": " + e.getMessage(); |
... | ... | |
497 | 497 |
private MediaRepresentation makeMediaRepresentation(String uriString, boolean readMediaData) { |
498 | 498 |
|
499 | 499 |
uriString = uriString.replace(" ", "%20"); //replace whitespace |
500 |
ImageInfo imageInfo = null; |
|
500 |
CdmImageInfo imageInfo = null;
|
|
501 | 501 |
URI uri; |
502 | 502 |
try { |
503 | 503 |
uri = new URI(uriString); |
... | ... | |
508 | 508 |
try { |
509 | 509 |
if (readMediaData){ |
510 | 510 |
logger.info("Read media data from: " + uri); |
511 |
imageInfo = ImageInfo.NewInstance(uri, 0); |
|
511 |
imageInfo = CdmImageInfo.NewInstance(uri, 0);
|
|
512 | 512 |
} |
513 | 513 |
} catch (Exception e) { |
514 | 514 |
try { |
515 | 515 |
//try again |
516 |
imageInfo = ImageInfo.NewInstance(uri, 0); |
|
516 |
imageInfo = CdmImageInfo.NewInstance(uri, 0);
|
|
517 | 517 |
} catch (Exception e1) { |
518 | 518 |
String message = "An error occurred when trying to read image meta data for " + uri.toString() + ": " + e1.getMessage(); |
519 | 519 |
e1.printStackTrace(); |
app-import/src/main/java/eu/etaxonomy/cdm/app/greece/GreeceImagesUpdaterActivator.java | ||
---|---|---|
19 | 19 |
|
20 | 20 |
import eu.etaxonomy.cdm.api.application.CdmApplicationController; |
21 | 21 |
import eu.etaxonomy.cdm.app.common.CdmDestinations; |
22 |
import eu.etaxonomy.cdm.common.media.ImageInfo; |
|
22 |
import eu.etaxonomy.cdm.common.media.CdmImageInfo;
|
|
23 | 23 |
import eu.etaxonomy.cdm.database.DbSchemaValidation; |
24 | 24 |
import eu.etaxonomy.cdm.database.ICdmDataSource; |
25 | 25 |
import eu.etaxonomy.cdm.io.api.application.CdmIoApplicationController; |
... | ... | |
59 | 59 |
if (image.getSize()!= null){ |
60 | 60 |
continue; |
61 | 61 |
} |
62 |
ImageInfo imageInfo; |
|
62 |
CdmImageInfo imageInfo;
|
|
63 | 63 |
try { |
64 |
imageInfo = ImageInfo.NewInstance(uri, 0); |
|
64 |
imageInfo = CdmImageInfo.NewInstance(uri, 0);
|
|
65 | 65 |
image.setWidth(imageInfo.getWidth()); |
66 | 66 |
image.setHeight(imageInfo.getHeight()); |
67 | 67 |
image.setSize((int)imageInfo.getLength()); |
app-import/src/main/java/eu/etaxonomy/cdm/app/greece/GreeceLargeImagesAdderActivator.java | ||
---|---|---|
19 | 19 |
|
20 | 20 |
import eu.etaxonomy.cdm.api.application.CdmApplicationController; |
21 | 21 |
import eu.etaxonomy.cdm.app.common.CdmDestinations; |
22 |
import eu.etaxonomy.cdm.common.media.ImageInfo; |
|
22 |
import eu.etaxonomy.cdm.common.media.CdmImageInfo;
|
|
23 | 23 |
import eu.etaxonomy.cdm.database.DbSchemaValidation; |
24 | 24 |
import eu.etaxonomy.cdm.database.ICdmDataSource; |
25 | 25 |
import eu.etaxonomy.cdm.io.api.application.CdmIoApplicationController; |
... | ... | |
160 | 160 |
return result; |
161 | 161 |
} |
162 | 162 |
|
163 |
/** |
|
164 |
* @param part |
|
165 |
*/ |
|
166 | 163 |
private void handlePart(ImageFile part) { |
167 |
ImageInfo imageInfo = null; |
|
164 |
CdmImageInfo imageInfo = null;
|
|
168 | 165 |
URI uri = part.getUri(); |
169 | 166 |
try { |
170 |
imageInfo = ImageInfo.NewInstance(uri, 0); |
|
167 |
imageInfo = CdmImageInfo.NewInstance(uri, 0);
|
|
171 | 168 |
} catch (Exception e) { |
172 | 169 |
String message = "An error occurred when trying to read image meta data for %s."; |
173 | 170 |
message = String.format(message, uri.toString()); |
... | ... | |
189 | 186 |
*/ |
190 | 187 |
private void handleUri(Media media, String uriStr) { |
191 | 188 |
URI uri = URI.create(uriStr); |
192 |
ImageInfo imageInfo = null; |
|
189 |
CdmImageInfo imageInfo = null;
|
|
193 | 190 |
try { |
194 |
imageInfo = ImageInfo.NewInstance(uri, 0); |
|
191 |
imageInfo = CdmImageInfo.NewInstance(uri, 0);
|
|
195 | 192 |
} catch (Exception e) { |
196 | 193 |
String message = "An error occurred when trying to read image meta data for %s."; |
197 | 194 |
message = String.format(message, uri.toString()); |
app-import/src/main/java/eu/etaxonomy/cdm/io/ProtologueImport.java | ||
---|---|---|
12 | 12 |
import java.io.File; |
13 | 13 |
import java.net.MalformedURLException; |
14 | 14 |
import java.net.URI; |
15 |
import java.net.URISyntaxException; |
|
15 | 16 |
import java.util.HashSet; |
16 | 17 |
import java.util.Set; |
17 | 18 |
|
... | ... | |
21 | 22 |
|
22 | 23 |
import eu.etaxonomy.cdm.api.service.ICommonService; |
23 | 24 |
import eu.etaxonomy.cdm.app.wp6.palmae.config.PalmaeProtologueImportConfigurator; |
24 |
import eu.etaxonomy.cdm.common.CdmUtils; |
|
25 | 25 |
import eu.etaxonomy.cdm.io.common.CdmImportBase; |
26 | 26 |
import eu.etaxonomy.cdm.io.common.DefaultImportState; |
27 | 27 |
import eu.etaxonomy.cdm.model.description.Feature; |
... | ... | |
32 | 32 |
import eu.etaxonomy.cdm.model.media.MediaRepresentationPart; |
33 | 33 |
import eu.etaxonomy.cdm.model.name.TaxonName; |
34 | 34 |
|
35 |
|
|
36 | 35 |
/** |
37 | 36 |
* @author a.mueller |
38 | 37 |
* @since 29.07.2008 |
... | ... | |
125 | 124 |
}catch(NullPointerException e){ |
126 | 125 |
logger.warn("MediaUrl and/or MediaPath not set. Could not get protologue."); |
127 | 126 |
return null; |
128 |
} |
|
127 |
} catch (URISyntaxException e) { |
|
128 |
logger.warn("URISyntaxException when reading URI. Could not get protologue."); |
|
129 |
return null; |
|
130 |
} |
|
129 | 131 |
return null; |
130 |
|
|
131 | 132 |
} |
132 | 133 |
|
133 | 134 |
private TaxonNameDescription getNameDescription(TaxonName taxonName) { |
... | ... | |
142 | 143 |
return result; |
143 | 144 |
} |
144 | 145 |
|
145 |
private Media getMedia(DefaultImportState<PalmaeProtologueImportConfigurator> state, File file){ |
|
146 |
private Media getMedia(DefaultImportState<PalmaeProtologueImportConfigurator> state, File file) throws URISyntaxException{
|
|
146 | 147 |
try { |
147 | 148 |
//File file = (File)state.getConfig().getSource(); |
148 | 149 |
String url = file.toURI().toURL().toString(); |
149 | 150 |
String mimeTypePdf = "application/pdf"; |
150 | 151 |
String suffixPdf = "pdf"; |
151 | 152 |
String urlStringPdf = state.getConfig().getUrlString() + file.getName(); |
152 |
URI uri = CdmUtils.string2Uri(urlStringPdf);
|
|
153 |
URI uri = new URI(urlStringPdf);
|
|
153 | 154 |
Integer size = null; |
154 | 155 |
|
155 | 156 |
if (file.exists()){ |
app-import/src/main/java/eu/etaxonomy/cdm/io/berlinModel/in/BerlinModelFactsImport.java | ||
---|---|---|
32 | 32 |
import au.com.bytecode.opencsv.CSVReader; |
33 | 33 |
import eu.etaxonomy.cdm.common.CdmUtils; |
34 | 34 |
import eu.etaxonomy.cdm.common.UTF8; |
35 |
import eu.etaxonomy.cdm.common.media.ImageInfo; |
|
35 |
import eu.etaxonomy.cdm.common.media.CdmImageInfo;
|
|
36 | 36 |
import eu.etaxonomy.cdm.database.update.DatabaseTypeNotSupportedException; |
37 | 37 |
import eu.etaxonomy.cdm.io.berlinModel.BerlinModelTransformer; |
38 | 38 |
import eu.etaxonomy.cdm.io.berlinModel.in.validation.BerlinModelFactsImportValidator; |
... | ... | |
1006 | 1006 |
* @param size |
1007 | 1007 |
*/ |
1008 | 1008 |
private void makeMediaRepresentation(Media media, URI uri) { |
1009 |
ImageInfo imageInfo = null; |
|
1009 |
CdmImageInfo imageInfo = null;
|
|
1010 | 1010 |
Integer size = null; |
1011 | 1011 |
try { |
1012 |
imageInfo = ImageInfo.NewInstance(uri, 30); |
|
1012 |
imageInfo = CdmImageInfo.NewInstance(uri, 30);
|
|
1013 | 1013 |
} catch (IOException | HttpException e) { |
1014 | 1014 |
logger.error("Error when reading image meta: " + e + ", "+ uri.toString()); |
1015 | 1015 |
} |
app-import/src/main/java/eu/etaxonomy/cdm/io/berlinModel/in/BerlinModelNameFactsImport.java | ||
---|---|---|
32 | 32 |
import org.springframework.stereotype.Component; |
33 | 33 |
|
34 | 34 |
import eu.etaxonomy.cdm.common.CdmUtils; |
35 |
import eu.etaxonomy.cdm.common.media.ImageInfo; |
|
35 |
import eu.etaxonomy.cdm.common.media.CdmImageInfo;
|
|
36 | 36 |
import eu.etaxonomy.cdm.io.berlinModel.in.validation.BerlinModelNameFactsImportValidator; |
37 | 37 |
import eu.etaxonomy.cdm.io.common.IOValidator; |
38 | 38 |
import eu.etaxonomy.cdm.io.common.ResultSetPartitioner; |
... | ... | |
49 | 49 |
import eu.etaxonomy.cdm.model.reference.OriginalSourceType; |
50 | 50 |
import eu.etaxonomy.cdm.model.reference.Reference; |
51 | 51 |
|
52 |
|
|
53 | 52 |
/** |
54 | 53 |
* @author a.mueller |
55 | 54 |
* @since 20.03.2008 |
... | ... | |
252 | 251 |
return result; |
253 | 252 |
} |
254 | 253 |
|
255 |
|
|
256 | 254 |
//FIXME gibt es da keine allgemeine Methode in common? |
257 | 255 |
public Media getMedia(String nameFact, URL mediaUrl, File mediaPath){ |
258 | 256 |
if (mediaUrl == null){ |
... | ... | |
375 | 373 |
return media; |
376 | 374 |
} |
377 | 375 |
|
378 |
|
|
379 | 376 |
private ImageFile makeImage(String imageUri, Integer size, File file){ |
380 |
ImageInfo imageMetaData = null; |
|
377 |
CdmImageInfo imageMetaData = null;
|
|
381 | 378 |
URI uri; |
382 | 379 |
try { |
383 | 380 |
uri = new URI(imageUri); |
384 | 381 |
try { |
385 |
imageMetaData = ImageInfo.NewInstance(uri, 0); |
|
382 |
imageMetaData = CdmImageInfo.NewInstance(uri, 0);
|
|
386 | 383 |
} catch (IOException e) { |
387 | 384 |
logger.error("IOError reading image metadata." , e); |
388 | 385 |
} catch (HttpException e) { |
... | ... | |
397 | 394 |
|
398 | 395 |
} |
399 | 396 |
|
400 |
|
|
401 |
/* (non-Javadoc) |
|
402 |
* @see eu.etaxonomy.cdm.io.common.CdmIoBase#doCheck(eu.etaxonomy.cdm.io.common.IoStateBase) |
|
403 |
*/ |
|
404 | 397 |
@Override |
405 | 398 |
protected boolean doCheck(BerlinModelImportState state){ |
406 | 399 |
IOValidator<BerlinModelImportState> validator = new BerlinModelNameFactsImportValidator(); |
407 | 400 |
return validator.validate(state); |
408 | 401 |
} |
409 | 402 |
|
410 |
|
|
411 |
/* (non-Javadoc) |
|
412 |
* @see eu.etaxonomy.cdm.io.common.CdmIoBase#isIgnore(eu.etaxonomy.cdm.io.common.IImportConfigurator) |
|
413 |
*/ |
|
414 | 403 |
@Override |
415 | 404 |
protected boolean isIgnore(BerlinModelImportState state){ |
416 | 405 |
return ! state.getConfig().isDoNameFacts(); |
417 | 406 |
} |
418 | 407 |
|
419 |
|
|
420 |
|
|
421 | 408 |
//for testing only |
422 | 409 |
public static void main(String[] args) { |
423 | 410 |
|
app-import/src/main/java/eu/etaxonomy/cdm/io/greece/ImageImportTest.java | ||
---|---|---|
24 | 24 |
import org.joda.time.format.DateTimeFormat; |
25 | 25 |
import org.joda.time.format.DateTimeFormatter; |
26 | 26 |
|
27 |
import eu.etaxonomy.cdm.common.media.ImageInfo; |
|
27 |
import eu.etaxonomy.cdm.common.media.CdmImageInfo;
|
|
28 | 28 |
import eu.etaxonomy.cdm.io.common.utils.ImportDeduplicationHelper; |
29 | 29 |
import eu.etaxonomy.cdm.model.agent.AgentBase; |
30 | 30 |
import eu.etaxonomy.cdm.model.common.TimePeriod; |
... | ... | |
37 | 37 |
/** |
38 | 38 |
* @author a.mueller |
39 | 39 |
* @since 13.05.2017 |
40 |
* |
|
41 | 40 |
*/ |
42 | 41 |
public class ImageImportTest { |
43 | 42 |
|
... | ... | |
64 | 63 |
String taxonNameStr = taxonNameAndArtist[0]; |
65 | 64 |
String artistStr = taxonNameAndArtist[1]; |
66 | 65 |
|
67 |
|
|
68 | 66 |
if(false){ |
69 | 67 |
continue; |
70 | 68 |
} |
... | ... | |
98 | 96 |
e1.printStackTrace(); |
99 | 97 |
} |
100 | 98 |
|
101 |
|
|
102 |
|
|
103 |
|
|
104 |
ImageInfo imageMetaData; |
|
99 |
CdmImageInfo imageMetaData; |
|
105 | 100 |
try { |
106 |
imageMetaData = ImageInfo.NewInstance(uri, 0); |
|
101 |
imageMetaData = CdmImageInfo.NewInstance(uri, 0);
|
|
107 | 102 |
|
108 | 103 |
String mimeType = imageMetaData.getMimeType(); |
109 | 104 |
String suffix = null; |
... | ... | |
121 | 116 |
e.printStackTrace(); |
122 | 117 |
} |
123 | 118 |
} |
124 |
|
|
125 | 119 |
} |
126 | 120 |
} |
127 |
|
|
128 |
/** |
|
129 |
* @param text |
|
130 |
* @return |
|
131 |
*/ |
|
132 | 121 |
private String removeQuots(String text) { |
133 | 122 |
if (text.startsWith("'") && text.endsWith("'")){ |
134 | 123 |
return text.substring(1, text.length() -1); |
... | ... | |
137 | 126 |
} |
138 | 127 |
} |
139 | 128 |
|
140 |
/** |
|
141 |
* @param taxonNameStr |
|
142 |
* @return |
|
143 |
*/ |
|
144 | 129 |
private Taxon getAcceptedTaxon(String taxonNameStr) { |
145 | 130 |
return Taxon.NewInstance(null, null); |
146 | 131 |
} |
147 | 132 |
|
148 |
/** |
|
149 |
* @param fileStr |
|
150 |
* @return |
|
151 |
*/ |
|
152 | 133 |
private String[] getTaxonName(String fileStr) { |
153 | 134 |
String[] result = new String[2]; |
154 | 135 |
fileStr = fileStr.split("\\.")[0]; |
app-import/src/main/java/eu/etaxonomy/cdm/io/wp6/CichorieaeImageImport.java | ||
---|---|---|
13 | 13 |
import java.io.IOException; |
14 | 14 |
import java.net.MalformedURLException; |
15 | 15 |
import java.net.URI; |
16 |
import java.net.URISyntaxException; |
|
16 | 17 |
import java.util.List; |
17 | 18 |
import java.util.UUID; |
18 | 19 |
|
... | ... | |
22 | 23 |
|
23 | 24 |
import eu.etaxonomy.cdm.app.images.AbstractImageImporter; |
24 | 25 |
import eu.etaxonomy.cdm.app.images.ImageImportState; |
25 |
import eu.etaxonomy.cdm.common.CdmUtils; |
|
26 |
import eu.etaxonomy.cdm.common.media.ImageInfo; |
|
26 |
import eu.etaxonomy.cdm.common.media.CdmImageInfo; |
|
27 | 27 |
import eu.etaxonomy.cdm.model.agent.AgentBase; |
28 | 28 |
import eu.etaxonomy.cdm.model.common.Language; |
29 | 29 |
import eu.etaxonomy.cdm.model.common.LanguageString; |
... | ... | |
40 | 40 |
/** |
41 | 41 |
* @author n.hoffmann |
42 | 42 |
* @since 18.11.2008 |
43 |
* @version 1.0 |
|
44 | 43 |
*/ |
45 | 44 |
@Component |
46 | 45 |
public class CichorieaeImageImport extends AbstractImageImporter { |
47 |
private static final Logger logger = Logger.getLogger(CichorieaeImageImport.class); |
|
48 | 46 |
|
47 |
private static final long serialVersionUID = -5123899111873586729L; |
|
48 |
private static final Logger logger = Logger.getLogger(CichorieaeImageImport.class); |
|
49 | 49 |
|
50 | 50 |
/** |
51 | 51 |
* Imports images from a directory. |
... | ... | |
78 | 78 |
}else{ |
79 | 79 |
logger.warn("Source is not a directory!" + source.toString()); |
80 | 80 |
} |
81 |
|
|
82 | 81 |
return; |
83 |
|
|
84 | 82 |
} |
85 | 83 |
|
86 | 84 |
private String getTaxonName(String fileName){ |
... | ... | |
124 | 122 |
return taxonName; |
125 | 123 |
} |
126 | 124 |
|
127 |
|
|
128 |
/** |
|
129 |
* @param tree |
|
130 |
* @param sourceRef |
|
131 |
* @param name |
|
132 |
* @param taxonName |
|
133 |
* @param taxa |
|
134 |
* @param taxon |
|
135 |
*/ |
|
136 |
private void handleTaxa(Classification tree, Reference sourceRef, String fileName, String taxonName, List<TaxonBase> taxa) { |
|
125 |
private void handleTaxa(Classification tree, Reference sourceRef, |
|
126 |
String fileName, String taxonName, List<TaxonBase> taxa) { |
|
137 | 127 |
|
138 | 128 |
Taxon taxon = getTaxon(tree, taxonName, taxa); |
139 | 129 |
TaxonDescription imageGallery = taxon.getOrCreateImageGallery(sourceRef == null ? null :sourceRef.getTitleCache()); |
... | ... | |
148 | 138 |
logger.error("IOException when handling image url"); |
149 | 139 |
} catch (HttpException e) { |
150 | 140 |
logger.error("HttpException when handling image url"); |
151 |
} |
|
141 |
} catch (URISyntaxException e) { |
|
142 |
logger.error("URISyntaxException when handling image url"); |
|
143 |
} |
|
152 | 144 |
} |
153 | 145 |
|
154 |
|
|
155 |
/** |
|
156 |
* @param fileName |
|
157 |
* @param taxonName |
|
158 |
* @return |
|
159 |
* @throws MalformedURLException |
|
160 |
* @throws IOException |
|
161 |
* @throws HttpException |
|
162 |
*/ |
|
163 |
private Media getMedia(String fileName, String taxonName) throws MalformedURLException, IOException, HttpException { |
|
146 |
private Media getMedia(String fileName, String taxonName) throws MalformedURLException, IOException, HttpException, URISyntaxException { |
|
164 | 147 |
String urlPrefix = "http://media.bgbm.org/erez/erez?src=EditWP6/photos/"; |
165 | 148 |
String urlString = urlPrefix + fileName; |
166 | 149 |
logger.info(urlString); |
167 |
URI uri = CdmUtils.string2Uri(urlString);
|
|
168 |
ImageInfo imageMetaData =ImageInfo.NewInstance(uri, 0);
|
|
150 |
URI uri = new URI(urlString);
|
|
151 |
CdmImageInfo imageMetaData = CdmImageInfo.NewInstance(uri, 0);
|
|
169 | 152 |
|
170 | 153 |
String mimeType = imageMetaData.getMimeType(); |
171 | 154 |
String suffix = null; |
... | ... | |
182 | 165 |
return media; |
183 | 166 |
} |
184 | 167 |
|
185 |
/** |
|
186 |
* @param tree |
|
187 |
* @param taxonName |
|
188 |
* @param taxa |
|
189 |
* @return |
|
190 |
*/ |
|
191 |
private Taxon getTaxon(Classification tree, String taxonName, |
|
168 |
private Taxon getTaxon(Classification tree, |
|
169 |
String taxonName, |
|
192 | 170 |
List<TaxonBase> taxa) { |
171 |
|
|
193 | 172 |
Taxon taxon = null; |
194 | 173 |
if(taxa.size() > 1) { |
195 | 174 |
if (logger.isDebugEnabled()) { |
196 | 175 |
logger.debug("multiple taxa with this name found: " + taxonName); |
197 | 176 |
} |
198 |
for (TaxonBase taxonBase : taxa) { |
|
177 |
for (TaxonBase<?> taxonBase : taxa) {
|
|
199 | 178 |
Taxon tax = (Taxon)taxonBase; |
200 | 179 |
if (tree.isTaxonInTree(tax)) { |
201 | 180 |
taxon = tax; |
Also available in: Unified diff
rename ImageInfo to CdmImageInfo and replace CdmUtils.str2uri