Revision f476ff86
Added by Andreas Müller over 7 years ago
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/common/mapping/DbImportImageGalleryMapper.java | ||
---|---|---|
1 | 1 |
// $Id$ |
2 | 2 |
/** |
3 | 3 |
* Copyright (C) 2007 EDIT |
4 |
* European Distributed Institute of Taxonomy
|
|
4 |
* European Distributed Institute of Taxonomy |
|
5 | 5 |
* http://www.e-taxonomy.eu |
6 |
*
|
|
6 |
* |
|
7 | 7 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
8 | 8 |
* See LICENSE.TXT at the top of this package for the full license terms. |
9 | 9 |
*/ |
... | ... | |
42 | 42 |
*/ |
43 | 43 |
public class DbImportImageGalleryMapper extends DbSingleAttributeImportMapperBase<DbImportStateBase<?,?>, Taxon> implements IDbImportMapper<DbImportStateBase<?,?>,Taxon>{ |
44 | 44 |
private static final Logger logger = Logger.getLogger(DbImportImageGalleryMapper.class); |
45 |
|
|
45 |
|
|
46 | 46 |
//************************** FACTORY METHODS ***************************************************************/ |
47 |
|
|
47 |
|
|
48 | 48 |
/** |
49 | 49 |
* @param dbAttributeString |
50 | 50 |
* @param uuid |
... | ... | |
56 | 56 |
public static DbImportImageGalleryMapper NewInstance(String dbAttributeString){ |
57 | 57 |
return new DbImportImageGalleryMapper(dbAttributeString); |
58 | 58 |
} |
59 |
|
|
59 |
|
|
60 | 60 |
//***************** VARIABLES **********************************************************/ |
61 |
|
|
61 |
|
|
62 | 62 |
|
63 | 63 |
//******************************** CONSTRUCTOR *****************************************************************/ |
64 |
|
|
64 |
|
|
65 | 65 |
/** |
66 | 66 |
* @param dbAttributeString |
67 | 67 |
* @param extensionType |
... | ... | |
69 | 69 |
private DbImportImageGalleryMapper(String dbAttributeString) { |
70 | 70 |
super(dbAttributeString, dbAttributeString); |
71 | 71 |
} |
72 |
|
|
72 |
|
|
73 | 73 |
//****************************** METHODS ***************************************************/ |
74 |
|
|
74 |
|
|
75 | 75 |
/** |
76 | 76 |
* @param service |
77 | 77 |
* @param state |
... | ... | |
89 | 89 |
//do nothing |
90 | 90 |
} |
91 | 91 |
} |
92 |
|
|
92 |
|
|
93 | 93 |
|
94 | 94 |
/* (non-Javadoc) |
95 | 95 |
* @see eu.etaxonomy.cdm.io.common.mapping.DbSingleAttributeImportMapperBase#invoke(java.sql.ResultSet, eu.etaxonomy.cdm.model.common.CdmBase) |
... | ... | |
98 | 98 |
String dbValue = rs.getString(getSourceAttribute()); |
99 | 99 |
return invoke(dbValue, taxonBase); |
100 | 100 |
} |
101 |
|
|
101 |
|
|
102 | 102 |
/** |
103 | 103 |
* @param dbValue |
104 | 104 |
* @param identifiableEntity |
... | ... | |
112 | 112 |
Taxon taxon; |
113 | 113 |
if (taxonBase.isInstanceOf(Synonym.class)){ |
114 | 114 |
Synonym synonym = taxonBase.deproxy(taxonBase, Synonym.class); |
115 |
if (synonym.getAcceptedTaxa().size() > 0){
|
|
115 |
if (synonym.getAcceptedTaxon() != null){
|
|
116 | 116 |
logger.warn("Media will be added to a synonyms accepted taxon"); |
117 |
taxon = synonym.getAcceptedTaxa().iterator().next();
|
|
117 |
taxon = synonym.getAcceptedTaxon();
|
|
118 | 118 |
}else{ |
119 | 119 |
throw new IllegalArgumentException("TaxonBase was of type synonym and does not belong to an accepted taxon"); |
120 | 120 |
} |
121 | 121 |
}else{ |
122 | 122 |
taxon = taxonBase.deproxy(taxonBase, Taxon.class); |
123 | 123 |
} |
124 |
|
|
124 |
|
|
125 | 125 |
TaxonDescription imageGallery = taxon.getImageGallery(createNew); |
126 | 126 |
Set<DescriptionElementBase> elements = imageGallery.getElements(); |
127 | 127 |
DescriptionElementBase element = null; |
... | ... | |
146 | 146 |
element.addMedia(media); |
147 | 147 |
return taxon; |
148 | 148 |
} |
149 |
|
|
149 |
|
|
150 | 150 |
//not used |
151 | 151 |
/* (non-Javadoc) |
152 | 152 |
* @see eu.etaxonomy.cdm.io.common.CdmSingleAttributeMapperBase#getTypeClass() |
153 | 153 |
*/ |
154 |
public Class<String> getTypeClass(){ |
|
154 |
@Override |
|
155 |
public Class<String> getTypeClass(){ |
|
155 | 156 |
return String.class; |
156 | 157 |
} |
157 | 158 |
|
... | ... | |
162 | 163 |
public void initialize(DbImportStateBase<?,?> state, Class<? extends CdmBase> destinationClass) { |
163 | 164 |
super.importMapperHelper.initialize(state, destinationClass); |
164 | 165 |
} |
165 |
|
|
166 |
|
|
166 | 167 |
|
167 | 168 |
} |
Also available in: Unified diff
ref #5974 Remove synonym relationship first compiling implementation in cdmlib