Revision c6df7de0
Added by Andreas Müller almost 7 years ago
app-import/src/main/java/eu/etaxonomy/cdm/io/greece/FloraHellenicaImageImport.java | ||
---|---|---|
19 | 19 |
import org.apache.sanselan.Sanselan; |
20 | 20 |
import org.apache.sanselan.common.IImageMetadata; |
21 | 21 |
import org.apache.sanselan.common.ImageMetadata.Item; |
22 |
import org.joda.time.DateTime; |
|
23 |
import org.joda.time.DateTimeZone; |
|
24 |
import org.joda.time.format.DateTimeFormat; |
|
25 |
import org.joda.time.format.DateTimeFormatter; |
|
22 | 26 |
import org.springframework.stereotype.Component; |
23 | 27 |
import org.springframework.transaction.TransactionStatus; |
24 | 28 |
|
25 | 29 |
import eu.etaxonomy.cdm.api.service.config.MatchingTaxonConfigurator; |
26 | 30 |
import eu.etaxonomy.cdm.io.common.CdmImportBase; |
31 |
import eu.etaxonomy.cdm.io.common.utils.ImportDeduplicationHelper; |
|
27 | 32 |
import eu.etaxonomy.cdm.io.mexico.SimpleExcelTaxonImportState; |
28 | 33 |
import eu.etaxonomy.cdm.model.agent.Person; |
29 | 34 |
import eu.etaxonomy.cdm.model.common.Language; |
... | ... | |
50 | 55 |
private static final String BASE_URL = "https://media.e-taxonomy.eu/flora-greece/"; |
51 | 56 |
private static final String IMAGE_FOLDER = "////BGBM-PESIHPC/Greece/thumbs/"; |
52 | 57 |
|
58 |
@SuppressWarnings("unchecked") |
|
59 |
private ImportDeduplicationHelper<SimpleExcelTaxonImportState<?>> deduplicationHelper = (ImportDeduplicationHelper<SimpleExcelTaxonImportState<?>>)ImportDeduplicationHelper.NewInstance(this); |
|
60 |
|
|
53 | 61 |
/** |
54 | 62 |
* {@inheritDoc} |
55 | 63 |
*/ |
... | ... | |
118 | 126 |
Item item = (Item) object; |
119 | 127 |
// System.out.println(item.getKeyword() + ": " + item.getText()); |
120 | 128 |
String keyword = item.getKeyword().toLowerCase(); |
121 |
String value = item.getText();
|
|
129 |
String value = removeQuots(item.getText());
|
|
122 | 130 |
if("image description".equals(keyword)){ |
123 | 131 |
media.putDescription(Language.DEFAULT(), value); |
124 |
}else if ("artist".equals(item.getKeyword().toLowerCase())){
|
|
132 |
}else if ("artist".equals(keyword)){
|
|
125 | 133 |
if (isNotBlank(artistStr) && ! value.contains(artistStr)){ |
126 | 134 |
logger.warn("Artist and artistStr are different: " + artistStr + "; " + value); |
127 | 135 |
} |
128 | 136 |
artistStr = value; |
137 |
}else if ("date time original".equalsIgnoreCase(item.getKeyword())){ |
|
138 |
DateTimeFormatter f = DateTimeFormat.forPattern("yyyy:MM:dd HH:mm:ss"); |
|
139 |
DateTime created = f.withZone(DateTimeZone.forID("Europe/Athens")).parseDateTime(value); |
|
140 |
media.setMediaCreated(created); |
|
129 | 141 |
} |
130 | 142 |
} |
131 | 143 |
} catch (ImageReadException | IOException e1) { |
... | ... | |
133 | 145 |
} |
134 | 146 |
if (isNotBlank(artistStr)){ |
135 | 147 |
Person person = Person.NewInstance(); |
136 |
person.setLastname(artistStr); |
|
148 |
String[] split = artistStr.split("\\+"); |
|
149 |
if (split.length == 1){ |
|
150 |
person.setLastname(artistStr); |
|
151 |
}else if (split.length == 2){ |
|
152 |
person.setFirstname(split[0]); |
|
153 |
person.setLastname(split[1]); |
|
154 |
}else{ |
|
155 |
person.setTitleCache("artistStr", true); |
|
156 |
} |
|
157 |
person = (Person)deduplicationHelper.getExistingAuthor(state, person); |
|
158 |
|
|
137 | 159 |
media.setArtist(person); |
138 | 160 |
} |
139 | 161 |
|
... | ... | |
162 | 184 |
} |
163 | 185 |
} |
164 | 186 |
|
187 |
private String removeQuots(String text) { |
|
188 |
if (text.startsWith("'") && text.endsWith("'")){ |
|
189 |
return text.substring(1, text.length() -1); |
|
190 |
}else{ |
|
191 |
return text; |
|
192 |
} |
|
193 |
} |
|
194 |
|
|
165 | 195 |
private Reference secReference; |
166 | 196 |
private Reference getSecReference(SimpleExcelTaxonImportState<CONFIG> state) { |
167 | 197 |
if (secReference != null){ |
Also available in: Unified diff
ref #6286 fix Status in Greece and fix media metadata, add feature supportsXXX