Revision 99491025
Added by Andreas Müller almost 16 years ago
cdmlib-model/src/main/java/eu/etaxonomy/cdm/aspectj/PropertyChangeAspect.aj | ||
---|---|---|
41 | 41 |
// Also get methods for booleans start with "is" or "has" |
42 | 42 |
Object oldValue = property.get(cb); |
43 | 43 |
proceed( cb ); |
44 |
cb.firePropertyChange( propertyName, oldValue, property.get(cb)); |
|
44 |
Object newValue = property.get(cb); |
|
45 |
// logger.error ("Prop: " + propertyName); |
|
46 |
// logger.warn("OLD:" + oldValue); |
|
47 |
// logger.warn("New:" + newValue); |
|
48 |
if (! isPersistentSet(newValue) && ! isPersistentSet(oldValue) ){ |
|
49 |
cb.firePropertyChange( propertyName, oldValue, newValue); |
|
50 |
} |
|
45 | 51 |
} catch (NoSuchMethodException e) { |
46 | 52 |
e.printStackTrace(); |
47 | 53 |
proceed( cb ); |
... | ... | |
57 | 63 |
} |
58 | 64 |
} |
59 | 65 |
} |
66 |
|
|
67 |
private boolean isPersistentSet(Object value){ |
|
68 |
if (value == null){ |
|
69 |
//logger.debug("(null) is not PS"); |
|
70 |
return false; |
|
71 |
}else if (value.getClass().getName().equals("PersistentSet")){ |
|
72 |
//logger.warn(value.getClass() + " is PS !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); |
|
73 |
return true; |
|
74 |
}else{ |
|
75 |
//logger.warn(value.getClass().getSimpleName() + " is is not PS"); |
|
76 |
return false; |
|
77 |
} |
|
78 |
} |
|
60 | 79 |
|
61 | 80 |
|
62 | 81 |
/** |
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/common/OrderedTermBase.java | ||
---|---|---|
101 | 101 |
if (OrderedTermVocabulary.class.isAssignableFrom(newVocabulary.getClass())){ |
102 | 102 |
OrderedTermVocabulary voc = (OrderedTermVocabulary)newVocabulary; |
103 | 103 |
|
104 |
if (this.orderIndex > 1){
|
|
104 |
if (this.orderIndex > 0){
|
|
105 | 105 |
//don't change orderIndex |
106 | 106 |
}else if (voc.getLowestTerm() == null){ |
107 | 107 |
this.orderIndex = 1; |
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/common/OrderedTermVocabulary.java | ||
---|---|---|
113 | 113 |
@Transient |
114 | 114 |
public T getLowestTerm() { |
115 | 115 |
try { |
116 |
return ((SortedSet<T>)terms).first(); |
|
116 |
SortedSet<T> sortedSet = new TreeSet(); |
|
117 |
sortedSet.addAll(terms); |
|
118 |
return sortedSet.first(); |
|
119 |
//return ((SortedSet<T>)terms).first(); |
|
117 | 120 |
} catch (NoSuchElementException e) { |
118 | 121 |
return null; |
119 | 122 |
} |
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/common/TermVocabulary.java | ||
---|---|---|
59 | 59 |
private String termSourceUri; |
60 | 60 |
protected Class termClass; |
61 | 61 |
|
62 |
protected Set<T> terms = getNewTermSet(); |
|
62 |
//TODO Changed |
|
63 |
public Set<T> terms = getNewTermSet(); |
|
63 | 64 |
|
64 | 65 |
//to be overriden by subclasses, e.g. OrderedTermVocabulary |
65 | 66 |
@Transient |
... | ... | |
79 | 80 |
@Type(type="DefinedTermBase") |
80 | 81 |
@Cascade({CascadeType.SAVE_UPDATE}) |
81 | 82 |
public Set<T> getTerms() { |
82 |
Set<T> result = getNewTermSet(); |
|
83 |
result.addAll(terms); |
|
84 |
return result; |
|
83 |
//Set<T> result = getNewTermSet(); |
|
84 |
//result.addAll(terms); |
|
85 |
//return result; |
|
86 |
return terms; |
|
85 | 87 |
} |
86 | 88 |
protected void setTerms(Set<T> terms) { |
87 | 89 |
this.terms = terms; |
cdmlib-model/src/test/java/eu/etaxonomy/cdm/aspectj/PropertyChangeTest.java | ||
---|---|---|
9 | 9 |
import org.apache.log4j.Logger; |
10 | 10 |
import org.junit.Before; |
11 | 11 |
import org.junit.BeforeClass; |
12 |
import org.junit.Ignore; |
|
12 | 13 |
import org.junit.Test; |
13 | 14 |
|
14 | 15 |
import eu.etaxonomy.cdm.model.name.BotanicalName; |
cdmlib-model/src/test/java/eu/etaxonomy/cdm/model/common/CdmBaseTest.java | ||
---|---|---|
17 | 17 |
import org.junit.AfterClass; |
18 | 18 |
import org.junit.Before; |
19 | 19 |
import org.junit.BeforeClass; |
20 |
import org.junit.Ignore; |
|
20 | 21 |
import org.junit.Test; |
21 | 22 |
|
22 | 23 |
import eu.etaxonomy.cdm.model.agent.Person; |
cdmlib-model/src/test/java/eu/etaxonomy/cdm/model/common/OrderedTermVocabularyTest.java | ||
---|---|---|
82 | 82 |
@Test |
83 | 83 |
public final void testGetTerms() { |
84 | 84 |
assertEquals(3, oVoc1.getTerms().size()); |
85 |
assertNotSame(oVoc1.terms, oVoc1.getTerms()); |
|
85 |
//assertNotSame(oVoc1.terms, oVoc1.getTerms());
|
|
86 | 86 |
assertTrue( oVoc1.terms.getClass().isAssignableFrom(oVoc1.getTerms().getClass())); |
87 | 87 |
} |
88 | 88 |
|
cdmlib-model/src/test/java/eu/etaxonomy/cdm/model/common/TermVocabularyTest.java | ||
---|---|---|
88 | 88 |
} |
89 | 89 |
|
90 | 90 |
@Test |
91 |
|
|
91 | 92 |
public final void testGetTerms() { |
92 | 93 |
assertEquals(3, voc1.getTerms().size()); |
93 |
assertNotSame(voc1.terms, voc1.getTerms()); |
|
94 |
//assertNotSame(voc1.terms, voc1.getTerms());
|
|
94 | 95 |
assertTrue( voc1.terms.getClass().isAssignableFrom(voc1.getTerms().getClass())); |
95 | 96 |
} |
96 | 97 |
|
Also available in: Unified diff