Project

General

Profile

« Previous | Next » 

Revision a523b3b1

Added by Andreas Müller almost 7 years ago

Add getter/setter/termloader for (inverse)symbol, fix update script
#5734

View differences:

cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/common/DefinedTermBase.java
179 179

  
180 180
//***************************** CONSTRUCTOR *******************************************/
181 181

  
182

  
183

  
184
	//for javassit only
182
    //for javassit only
185 183
    @Deprecated
186 184
    protected DefinedTermBase(){};
187 185

  
......
328 326
          this.vocabulary = newVocabulary;
329 327
    }
330 328

  
329

  
330
    public String getSymbol() {
331
        return symbol;
332
    }
333
    public void setSymbol(String symbol) {
334
        this.symbol = symbol;
335
    }
336

  
331 337
//******************************* METHODS ******************************************************/
332 338

  
333 339

  
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/common/RelationshipTermBase.java
168 168
	 * @param languages
169 169
	 * @return
170 170
	 */
171
	public Representation getPreferredInverseRepresentation(List<Language> languages) {
171
    public Representation getPreferredInverseRepresentation(List<Language> languages) {
172 172
		Representation repr = null;
173 173
		if(languages != null){
174 174
			for(Language language : languages) {
......
224 224
		return this.getInverseRepresentation(lang).getDescription();
225 225
	}
226 226

  
227
    public String getInverseSymbol() {
228
        return inverseSymbol;
229
    }
230
    public void setInverseSymbol(String inverseSymbol) {
231
        this.inverseSymbol = inverseSymbol;
232
    }
233

  
234
//**************** CSV *************************/
235

  
227 236
	@Override
228 237
	public T readCsvLine(Class<T> termClass, List<String> csvLine, Map<UUID,DefinedTermBase> terms, boolean abbrevAsId) {
229 238
		T newInstance = super.readCsvLine(termClass, csvLine, terms, abbrevAsId);
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/description/PresenceAbsenceTerm.java
329 329
        newInstance.setAbsenceTerm(isAbsence);
330 330

  
331 331
        newInstance.getRepresentation(Language.DEFAULT()).setAbbreviatedLabel(abbreviatedLabel);
332
        newInstance.setSymbol(abbreviatedLabel);
332 333
        return newInstance;
333 334
    }
334 335

  
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/taxon/TaxonRelationshipType.java
10 10
package eu.etaxonomy.cdm.model.taxon;
11 11

  
12 12
import java.util.HashMap;
13
import java.util.List;
13 14
import java.util.Map;
14 15
import java.util.UUID;
15 16

  
......
22 23
import org.apache.log4j.Logger;
23 24
import org.hibernate.envers.Audited;
24 25

  
26
import eu.etaxonomy.cdm.model.common.DefinedTermBase;
25 27
import eu.etaxonomy.cdm.model.common.RelationshipTermBase;
26 28
import eu.etaxonomy.cdm.model.common.TermType;
27 29
import eu.etaxonomy.cdm.model.common.TermVocabulary;
......
426 428
		return getTermByUuid(uuidAllRelationships);
427 429
	}
428 430

  
429
//	@Override
430
//	public TaxonRelationshipType readCsvLine(Class<TaxonRelationshipType> termClass, List<String> csvLine, Map<UUID,DefinedTermBase> terms) {
431
//		return super.readCsvLine(termClass, csvLine, terms);
432
//	}
431
    @Override
432
    public TaxonRelationshipType readCsvLine(Class<TaxonRelationshipType> termClass, List<String> csvLine, Map<UUID,DefinedTermBase> terms, boolean abbrevAsId) {
433
        TaxonRelationshipType newInstance = super.readCsvLine(termClass, csvLine, terms, abbrevAsId);
434

  
435
        String inverseLabelAbbrev = csvLine.get(7).trim();
436
        newInstance.setSymbol(newInstance.getIdInVocabulary());
437
        newInstance.setInverseSymbol(inverseLabelAbbrev);
438
        return newInstance;
439
    }
433 440
}
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/database/update/v36_40/SchemaUpdater_36_40.java
98 98
        stepList.add(step);
99 99

  
100 100
        stepName = "Update symbols for terms";
101
        query = "UPDATE @@DefinedTermBase@@ SET symbol = idInVocabulary WHERE idInVocabulary <> ''";
101
        query = "UPDATE @@DefinedTermBase@@ SET symbol = idInVocabulary WHERE idInVocabulary <> '' AND termType IN ('PAT','TRT')";
102 102
        step = SimpleSchemaUpdaterStep.NewNonAuditedInstance(stepName, query, -99);
103 103
        stepList.add(step);
104 104

  
......
111 111
        stepList.add(step);
112 112

  
113 113
        stepName = "Update symbols for terms";
114
        query = "UPDATE DefinedTermBase dtb SET inverseSymbol = ( " +
115
            " SELECT  r.abbreviatedlabel " +
116
            " FROM RelationshipTermBase_inverseRepresentation MN " +
117
                " INNER JOIN Representation r ON r.id = MN.inverserepresentations_id " +
118
            " WHERE dtb.id = MN.DefinedTermBase_id AND r.abbreviatedlabel <> '' ) ";
114
        query = "UPDATE DefinedTermBase dtb "
115
            + "SET inverseSymbol = ( " +
116
                " SELECT  r.abbreviatedlabel " +
117
                " FROM RelationshipTermBase_inverseRepresentation MN " +
118
                    " INNER JOIN Representation r ON r.id = MN.inverserepresentations_id " +
119
                " WHERE dtb.id = MN.DefinedTermBase_id AND r.abbreviatedlabel <> '' ) "
120
            + " WHERE termType IN ('PAT','TRT') ";
119 121
        step = SimpleSchemaUpdaterStep.NewNonAuditedInstance(stepName, query, -99);
120 122
        stepList.add(step);
121 123

  

Also available in: Unified diff