Project

General

Profile

Revision 0d3ee32e

ID0d3ee32e2fd2c0cc7000bbaf94ef56895bdce906
Parent c2c05353
Child aaea23f9

Added by Andreas Müller about 4 years ago

cleanup

View differences:

cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/common/mapping/DbImportExtensionMapper.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
*/
......
35 35
 * as it does not map to a single attribute
36 36
 * @author a.mueller
37 37
 * @created 12.05.2009
38
 * @version 1.0
39 38
 */
40
public class DbImportExtensionMapper extends DbSingleAttributeImportMapperBase<DbImportStateBase<?,?>, IdentifiableEntity> implements IDbImportMapper<DbImportStateBase<?,?>,IdentifiableEntity>{
39
public class DbImportExtensionMapper extends DbSingleAttributeImportMapperBase<DbImportStateBase<?,?>, IdentifiableEntity>
40
        implements IDbImportMapper<DbImportStateBase<?,?>,IdentifiableEntity>{
41 41
	private static final Logger logger = Logger.getLogger(DbImportExtensionMapper.class);
42
	
42

  
43 43
//************************** FACTORY METHODS ***************************************************************/
44
	
44

  
45 45
	/**
46 46
	 * @param dbAttributeString
47 47
	 * @param uuid
......
54 54
	public static DbImportExtensionMapper NewInstance(String dbAttributeString, UUID uuid, String label, String text, String labelAbbrev){
55 55
		return new DbImportExtensionMapper(dbAttributeString, uuid, label, text, labelAbbrev);
56 56
	}
57
	
57

  
58 58
	public static DbImportExtensionMapper NewInstance(String dbAttributeString, ExtensionType extensionType){
59 59
		return new DbImportExtensionMapper(dbAttributeString, extensionType);
60 60
	}
61
	
61

  
62 62
//***************** VARIABLES **********************************************************/
63
	
63

  
64 64
	private ExtensionType extensionType;
65 65
	private String label;
66 66
	private String text;
......
82 82
		this.text = text;
83 83
		this.labelAbbrev = labelAbbrev;
84 84
	}
85
	
85

  
86 86
	/**
87 87
	 * @param dbAttributeString
88 88
	 * @param extensionType
......
91 91
		super(dbAttributeString, dbAttributeString);
92 92
		this.extensionType = extensionType;
93 93
	}
94
	
94

  
95 95
//****************************** METHODS ***************************************************/
96
	
97
	/* (non-Javadoc)
98
	 * @see eu.etaxonomy.cdm.io.common.mapping.DbSingleAttributeImportMapperBase#initialize(eu.etaxonomy.cdm.io.common.DbImportStateBase, java.lang.Class)
99
	 */
96

  
100 97
	@Override
101 98
	public void initialize(DbImportStateBase<?,?> state, Class<? extends CdmBase> destinationClass) {
102 99
		importMapperHelper.initialize(state, destinationClass);
103 100
		CdmImportBase<?, ?> currentImport = state.getCurrentIO();
104 101
		if (currentImport == null){
105
			throw new IllegalStateException("Current import is not available. Please make sure the the state knows about the current import (state.setCurrentImport())) !"); 
102
			throw new IllegalStateException("Current import is not available. Please make sure the the state knows about the current import (state.setCurrentImport())) !");
106 103
		}
107
		
104

  
108 105
		try {
109 106
			if (  checkDbColumnExists()){
110 107
				if (this.extensionType == null){
......
117 114
			//do nothing  - checkDbColumnExists is not possible
118 115
		}
119 116
	}
120
	
117

  
121 118

  
122 119
	/**
123 120
	 * @param valueMap
......
129 126
		String dbValue = dbValueObject == null? null: dbValueObject.toString();
130 127
		return invoke(dbValue, cdmBase);
131 128
	}
132
	
129

  
133 130
	/**
134 131
	 * @param dbValue
135 132
	 * @param cdmBase
......
146 143
		}else{
147 144
			throw new IllegalArgumentException("extended object must be of type identifiable entity.");
148 145
		}
149
		
146

  
150 147
	}
151
	
152
	/* (non-Javadoc)
153
	 * @see eu.etaxonomy.cdm.io.common.mapping.DbSingleAttributeImportMapperBase#invoke(java.sql.ResultSet, eu.etaxonomy.cdm.model.common.CdmBase)
154
	 */
155
	public IdentifiableEntity invoke(ResultSet rs, IdentifiableEntity identifiableEntity) throws SQLException {
148

  
149
	@Override
150
    public IdentifiableEntity invoke(ResultSet rs, IdentifiableEntity identifiableEntity) throws SQLException {
156 151
		String dbValue = rs.getString(getSourceAttribute());
157 152
		return invoke(dbValue, identifiableEntity);
158 153
	}
159
	
154

  
160 155
	/**
161 156
	 * @param dbValue
162 157
	 * @param identifiableEntity
......
174 169
		}
175 170
		return identifiableEntity;
176 171
	}
177
	
178
	
172

  
173

  
179 174
	/**
180 175
	 * @param service
181 176
	 * @param uuid
......
210 205

  
211 206

  
212 207
	//not used
213
	/* (non-Javadoc)
214
	 * @see eu.etaxonomy.cdm.io.common.CdmSingleAttributeMapperBase#getTypeClass()
215
	 */
216
	public Class<String> getTypeClass(){
208
	@Override
209
    public Class<String> getTypeClass(){
217 210
		return String.class;
218 211
	}
219 212

  
220
	
221

  
222 213
}
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/agent/TeamOrPersonBase.java
87 87
        this.nomenclaturalTitle = StringUtils.isBlank(nomenclaturalTitle) ? null : nomenclaturalTitle;
88 88
    }
89 89

  
90
    /* (non-Javadoc)
91
     * @see eu.etaxonomy.cdm.model.common.IdentifiableEntity#getTitleCache()
92
     */
90

  
93 91
    @Override
94 92
    @Transient /*
95 93
                TODO  is the transient annotation still needed, can't we remove this ??
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/description/TextFormat.java
97 97
//********* METHODS **************************************/
98 98

  
99 99

  
100
	/* (non-Javadoc)
101
	 * @see eu.etaxonomy.cdm.model.common.DefinedTermBase#resetTerms()
102
	 */
103 100
	@Override
104 101
	public void resetTerms(){
105 102
		termMap = null;
......
107 104

  
108 105
	@Override
109 106
	protected void setDefaultTerms(TermVocabulary<TextFormat> termVocabulary){
110
		termMap = new HashMap<UUID, TextFormat>();
107
		termMap = new HashMap<>();
111 108
		for (TextFormat term : termVocabulary.getTerms()){
112 109
			termMap.put(term.getUuid(), term);
113 110
		}
cdmlib-model/src/main/java/eu/etaxonomy/cdm/strategy/cache/media/MediaDefaultCacheStrategy.java
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
*/
9 9

  
10 10
package eu.etaxonomy.cdm.strategy.cache.media;
11 11

  
......
35 35
	public static MediaDefaultCacheStrategy NewInstance() {
36 36
		return new MediaDefaultCacheStrategy();
37 37
	}
38
	
38

  
39 39
	@Override
40 40
	protected UUID getUuid() {
41
		return uuid; 
41
		return uuid;
42 42
	}
43
	
44
	
45
	public String getTitleCache(Media media) {
46
		media = (Media) HibernateProxyHelper.deproxy(media, Media.class);
43

  
44

  
45
	@Override
46
    public String getTitleCache(Media media) {
47
		media = HibernateProxyHelper.deproxy(media, Media.class);
47 48
		return getTitleCacheByLanguage(media, Language.DEFAULT());
48 49
	}
49
	
50

  
50 51
	public String getTitleCacheByLanguage(Media media, Language lang) {
51 52
		String result;
52 53
		List<Language> languages = Arrays.asList(new Language[]{lang});
53 54
		LanguageString languageString = MultilanguageTextHelper.getPreferredLanguageString(media.getAllTitles(), languages);
54 55
		result = (languageString != null ? languageString.getText() : "");
55
		
56

  
56 57
		//get first image uri
57 58
		if (StringUtils.isBlank(result)){
58 59
			for (MediaRepresentation mediaRepresentation : media.getRepresentations()){
......
79 80
	}
80 81

  
81 82

  
82
	
83

  
83 84
}

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)