Project

General

Profile

« Previous | Next » 

Revision 892efc69

Added by Andreas Kohlbecker almost 14 years ago

merging /branches/cdmlib/SPRINT-Chichorieae1/ to trunk

View differences:

cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/berlinModel/in/BerlinModelNameFactsImport.java
125 125
							Media media = getMedia(nameFact, config.getMediaUrl(), config.getMediaPath());
126 126
							if (media.getRepresentations().size() > 0){
127 127
								TaxonNameDescription description = TaxonNameDescription.NewInstance();
128
								TextData protolog = TextData.NewInstance(Feature.PROTOLOG());
128
								TextData protolog = TextData.NewInstance(Feature.PROTOLOGUE());
129 129
								protolog.addMedia(media);
130
								protolog.addSource(String.valueOf(nameFactId), NAMESPACE, citation, 
131
										nameFactRefDetail, null, null);
130
								protolog.addSource(String.valueOf(nameFactId), NAMESPACE, null, null, null, null);
132 131
								description.addElement(protolog);
133 132
								taxonNameBase.addDescription(description);
134
								description.addDescriptionSource(citation);
133
								if (citation != null){
134
									description.addDescriptionSource(citation);
135
									protolog.addSource(null, null, citation, nameFactRefDetail, null, null);
136
								}
135 137
							}//end NAME_FACT_PROTOLOGUE
136 138
						}catch(NullPointerException e){
137 139
							logger.warn("MediaUrl and/or MediaPath not set. Could not get protologue.");
......
200 202
			while (rs.next()){
201 203
				handleForeignKey(rs, nameIdSet, "PTnameFk");
202 204
				handleForeignKey(rs, referenceIdSet, "nameFactRefFk");
203
			}
204
			
205
	}
206
	
205 207
			//name map
206 208
			nameSpace = BerlinModelTaxonNameImport.NAMESPACE;
207 209
			cdmClass = TaxonNameBase.class;
......
231 233
	}
232 234

  
233 235
	
234
	//FIXME gibt es da keine allgemeine Methode in common?
235 236
	//FIXME gibt es da keine allgemeine Methode in common?
236 237
	public Media getMedia(String nameFact, URL mediaUrl, File mediaPath){
237 238
		if (mediaUrl == null){
......
263 264
		if (file.exists()){
264 265
			representationTif.addRepresentationPart(makeImage(urlStringTif, size, file));
265 266
		}
266
		media.addRepresentation(representationTif);
267
		if(representationTif.getParts().size() > 0){
268
			media.addRepresentation(representationTif);
269
		}
267 270
		// end tif
268 271
		// jpg
269 272
		boolean fileExists = true;
......
279 282
				fileExists = false;
280 283
			}
281 284
		}
282
		media.addRepresentation(representationJpg);
285
		if(representationJpg.getParts().size() > 0){
286
			media.addRepresentation(representationJpg);
287
		}
283 288
		// end jpg
284 289
		//png
285 290
		String urlStringPng = mediaUrlString + "png/" + nameFact + "." + suffixPng;
......
302 307
				}
303 308
			}
304 309
		} 
305
		media.addRepresentation(representationPng);
310
		if(representationPng.getParts().size() > 0){
311
			media.addRepresentation(representationPng);
312
		}
306 313
		//end png
307 314
        //pdf 
308 315
        String urlStringPdf = mediaUrlString + "pdf/" + nameFact + "." + suffixPdf; 
......
325 332
                        } 
326 333
                } 
327 334
        }  
328
        media.addRepresentation(representationPdf); 
335
        if(representationPdf.getParts().size() > 0){
336
        	media.addRepresentation(representationPdf);
337
        }
329 338
        //end pdf 
330 339
		
331 340
		if(logger.isDebugEnabled()){
......
342 351
	
343 352
	private ImageFile makeImage(String imageUri, Integer size, File file){
344 353
		ImageMetaData imageMetaData = ImageMetaData.newInstance();
345
	
346
		imageMetaData.readMetaData(file.toURI(), 0);
347
		
354
		try {
355
			imageMetaData.readMetaData(file.toURI(), 0);
356
		} catch (IOException e) {
357
			logger.error("IOError reading image metadata." , e);
358
		}
348 359
		ImageFile image = ImageFile.NewInstance(imageUri, size, imageMetaData);
349 360
		return image;
350 361
	}

Also available in: Unified diff