Revision 8422c0cd
Added by Andreas Müller almost 8 years ago
app-import/src/main/java/eu/etaxonomy/cdm/io/algaterra/AlgaTerraImageImportBase.java | ||
---|---|---|
1 | 1 |
/** |
2 | 2 |
* Copyright (C) 2007 EDIT |
3 |
* European Distributed Institute of Taxonomy
|
|
3 |
* European Distributed Institute of Taxonomy |
|
4 | 4 |
* http://www.e-taxonomy.eu |
5 |
*
|
|
5 |
* |
|
6 | 6 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
7 | 7 |
* See LICENSE.TXT at the top of this package for the full license terms. |
8 | 8 |
*/ |
... | ... | |
44 | 44 |
private static final String ALGAE_URL_ORIGINAL = "http://media.bgbm.org/erez/erez?cmd=get&src=Algaterra%2FAlgae%2F"; |
45 | 45 |
private static final String SITE_URL_ORIGINAL = "http://media.bgbm.org/erez/erez?cmd=get&src=Algaterra%2FSites%2F"; |
46 | 46 |
private static final String VOUCHER_URL_ORIGINAL = "http://media.bgbm.org/erez/erez?cmd=get&src=Algaterra%2FVoucher%2F"; |
47 |
|
|
48 |
|
|
47 |
|
|
48 |
|
|
49 | 49 |
protected enum PathType { |
50 | 50 |
Image (ALGAE_URL_BASE, ALGAE_URL_ORIGINAL), |
51 | 51 |
Site (SITE_URL_BASE, SITE_URL_ORIGINAL), |
52 | 52 |
Voucher (VOUCHER_URL_BASE, VOUCHER_URL_ORIGINAL) |
53 | 53 |
; |
54 |
|
|
54 |
|
|
55 | 55 |
String urlThumbnail; |
56 | 56 |
String urlOriginal; |
57 | 57 |
private PathType(String urlThumbnail, String urlOriginal){ |
... | ... | |
64 | 64 |
super(tableName, pluralString); |
65 | 65 |
} |
66 | 66 |
|
67 |
|
|
67 |
|
|
68 | 68 |
/** |
69 |
* Creates a media object and
|
|
69 |
* Creates a media object and |
|
70 | 70 |
* @param rs |
71 | 71 |
* @param derivedUnit |
72 | 72 |
* @param state |
... | ... | |
75 | 75 |
* @throws SQLException |
76 | 76 |
*/ |
77 | 77 |
protected Media handleSingleImage(ResultSet rs, IdentifiableEntity<?> identifiableEntity, AlgaTerraImportState state, ResultSetPartitioner partitioner, PathType pathType) throws SQLException { |
78 |
|
|
78 |
|
|
79 | 79 |
try { |
80 | 80 |
String figurePhrase = rs.getString("FigurePhrase"); |
81 | 81 |
// String filePath = rs.getString("filePath"); |
82 | 82 |
String fileName = rs.getString("fileName"); |
83 | 83 |
//TODO publishFlag |
84 | 84 |
Boolean publishFlag = rs.getBoolean("RestrictedFlag"); |
85 |
|
|
86 |
|
|
85 |
|
|
86 |
|
|
87 | 87 |
if (isBlank(fileName)){ |
88 | 88 |
throw new RuntimeException("FileName is missing"); |
89 | 89 |
} |
90 | 90 |
// if (isBlank(filePath)){ |
91 | 91 |
// filePath = state.getAlgaTerraConfigurator().getImageBaseUrl(); |
92 | 92 |
// } |
93 |
|
|
94 |
|
|
93 |
|
|
94 |
|
|
95 | 95 |
//handle thumbnail |
96 | 96 |
String filePath = pathType.urlThumbnail; |
97 | 97 |
String fullPath = filePath + fileName; |
... | ... | |
99 | 99 |
if (media == null){ |
100 | 100 |
logger.warn("Thumbnail image not found: " + filePath); |
101 | 101 |
} |
102 |
|
|
102 |
|
|
103 | 103 |
//handle original |
104 | 104 |
if (state.getAlgaTerraConfigurator().isImportOriginalSizeMedia()){ |
105 | 105 |
filePath = pathType.urlOriginal; |
... | ... | |
115 | 115 |
logger.warn("Original image not found: " + filePath); |
116 | 116 |
} |
117 | 117 |
} |
118 |
|
|
118 |
|
|
119 | 119 |
if (media == null){ |
120 | 120 |
throw new RuntimeException ("Media not found for " +fullPath); |
121 | 121 |
} |
122 |
|
|
123 |
|
|
124 |
|
|
122 |
|
|
123 |
|
|
124 |
|
|
125 | 125 |
if (isNotBlank(figurePhrase)){ |
126 | 126 |
media.putTitle(Language.DEFAULT(), figurePhrase); |
127 | 127 |
} |
128 |
|
|
128 |
|
|
129 | 129 |
//TODO ref |
130 |
Reference<?> ref = null;
|
|
130 |
Reference ref = null; |
|
131 | 131 |
if (identifiableEntity != null){ |
132 | 132 |
DescriptionBase<?> desc = getDescription(identifiableEntity, ref, IMAGE_GALLERY, CREATE); |
133 | 133 |
TextData textData = null; |
... | ... | |
144 | 144 |
}else{ |
145 | 145 |
logger.warn("Identifiable Entity is null. Can't add media "); |
146 | 146 |
} |
147 |
|
|
147 |
|
|
148 | 148 |
//notes |
149 |
|
|
149 |
|
|
150 | 150 |
//TODO restrictedFlag |
151 |
|
|
152 |
//TODO id, created for
|
|
151 |
|
|
152 |
//TODO id, created for |
|
153 | 153 |
// this.doIdCreatedUpdatedNotes(state, descriptionElement, rs, id, namespace); |
154 |
|
|
154 |
|
|
155 | 155 |
return media; |
156 | 156 |
} catch (Exception e) { |
157 | 157 |
throw new RuntimeException(e); |
158 | 158 |
} |
159 |
|
|
159 |
|
|
160 | 160 |
} |
161 | 161 |
|
162 | 162 |
|
163 | 163 |
|
164 | 164 |
|
165 |
private DescriptionBase<?> getDescription(IdentifiableEntity identifiableEntity, Reference<?> ref,
|
|
165 |
private DescriptionBase<?> getDescription(IdentifiableEntity identifiableEntity, Reference ref, |
|
166 | 166 |
boolean imageGallery, boolean create) { |
167 | 167 |
if (identifiableEntity.isInstanceOf(SpecimenOrObservationBase.class)){ |
168 | 168 |
return getSpecimenDescription(CdmBase.deproxy(identifiableEntity, SpecimenOrObservationBase.class), ref, imageGallery, create); |
... | ... | |
172 | 172 |
logger.warn("Unsupported IdentifiableEntity type: " + identifiableEntity.getClass()); |
173 | 173 |
return null; |
174 | 174 |
} |
175 |
}
|
|
175 |
} |
|
176 | 176 |
} |
Also available in: Unified diff
Remove generics from Reference in cdmlib-app #5830