Revision 6e8ebcb6
Added by Andreas Müller over 2 years ago
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/occurrence/SpecimenOrObservationBase.java | ||
---|---|---|
277 | 277 |
this.identityCache = identityCache; |
278 | 278 |
} |
279 | 279 |
|
280 |
/** |
|
281 |
* Sets the identity (short) cache. For how to use see {@link #setTitleCache(String, boolean)} |
|
282 |
*/ |
|
280 | 283 |
public void setIdentityCache(String identityCache, boolean isProtected) { |
281 |
this.protectedIdentityCache = isProtected; |
|
282 | 284 |
setIdentityCache(identityCache); |
285 |
this.protectedIdentityCache = isProtected; |
|
283 | 286 |
} |
284 | 287 |
|
285 | 288 |
/** |
cdmlib-model/src/main/java/eu/etaxonomy/cdm/strategy/cache/occurrence/DerivedUnitDefaultCacheStrategy.java | ||
---|---|---|
137 | 137 |
}; |
138 | 138 |
} |
139 | 139 |
|
140 |
|
|
141 |
//NOTE still need to discuss, if the identity cache for derived units |
|
142 |
//should also include the identity cache for field units (see also #5951). |
|
143 |
//This may make sense for searching, but is less comfortable in |
|
144 |
//tree representations. |
|
145 |
//For search it might be not so urgent if showing both the identity cache |
|
146 |
//followed by the titleCache whcih includes field unit information. |
|
147 |
@Override |
|
148 |
protected String doGetIdentityCache(DerivedUnit derivedUnit) { |
|
149 |
String specimenLabel = getSpecimenLabel(derivedUnit); |
|
150 |
if (isBlank(specimenLabel)){ |
|
151 |
return getTitleCache(derivedUnit); |
|
152 |
}else{ |
|
153 |
//NOTE: in future we may add further information if not both data are given |
|
154 |
// collection code/label AND unit number |
|
155 |
return specimenLabel; |
|
156 |
} |
|
157 |
} |
|
158 |
|
|
140 | 159 |
/** |
141 | 160 |
* Produces the collection code and number which is the combination of the collection code and |
142 | 161 |
* accession number or barcode. |
cdmlib-model/src/main/java/eu/etaxonomy/cdm/strategy/cache/occurrence/DnaSampleDefaultCacheStrategy.java | ||
---|---|---|
86 | 86 |
|
87 | 87 |
return result; |
88 | 88 |
} |
89 |
|
|
90 |
//NOTE: this is a first implementation, it may be adapted in future |
|
91 |
@Override |
|
92 |
protected String doGetIdentityCache(DnaSample dnaSample) { |
|
93 |
String result = getCollectionAndAccession(dnaSample); |
|
94 |
//sample designation |
|
95 |
if (isBlank(result)){ |
|
96 |
result = dnaSample.getIdentifierString(DefinedTerm.uuidSampleDesignation); |
|
97 |
} |
|
98 |
//any other identifier |
|
99 |
if (isBlank(result)){ |
|
100 |
if (!dnaSample.getIdentifiers().isEmpty()){ |
|
101 |
result = dnaSample.getIdentifiers().get(0).getIdentifier(); |
|
102 |
} |
|
103 |
} |
|
104 |
if (isBlank(result)){ |
|
105 |
return doGetTitleCache(dnaSample); |
|
106 |
}else{ |
|
107 |
return result; |
|
108 |
} |
|
109 |
} |
|
89 | 110 |
} |
cdmlib-model/src/main/java/eu/etaxonomy/cdm/strategy/cache/occurrence/FieldUnitDefaultCacheStrategy.java | ||
---|---|---|
95 | 95 |
return result; |
96 | 96 |
} |
97 | 97 |
|
98 |
@Override |
|
99 |
protected String doGetIdentityCache(FieldUnit fieldUnit) { |
|
100 |
if (fieldUnit == null){ |
|
101 |
return null; |
|
102 |
} |
|
103 |
String collectorAndFieldNumber = getCollectorAndFieldNumber(fieldUnit); |
|
104 |
if (isBlank(collectorAndFieldNumber)){ |
|
105 |
return this.doGetTitleCache(fieldUnit); |
|
106 |
}else{ |
|
107 |
//NOTE: in future we may decide to return further information if |
|
108 |
//not both information is available collector AND fieldNumber. |
|
109 |
return collectorAndFieldNumber; |
|
110 |
} |
|
111 |
} |
|
112 |
|
|
98 | 113 |
private String getFieldData(FieldUnit fieldUnit) { |
99 | 114 |
|
100 | 115 |
if (fieldUnit.isProtectedTitleCache()){ |
cdmlib-model/src/main/java/eu/etaxonomy/cdm/strategy/cache/occurrence/MediaSpecimenDefaultCacheStrategy.java | ||
---|---|---|
61 | 61 |
|
62 | 62 |
return result; |
63 | 63 |
} |
64 |
|
|
65 |
//NOTE: this is a first implementation, it may be adapted in future |
|
66 |
@Override |
|
67 |
protected String doGetIdentityCache(MediaSpecimen mediaSpecimen) { |
|
68 |
String collectionAndAccession = getCollectionAndAccession(mediaSpecimen); |
|
69 |
if (isBlank(collectionAndAccession)){ |
|
70 |
return getTitleCache(mediaSpecimen); |
|
71 |
}else{ |
|
72 |
return collectionAndAccession; |
|
73 |
} |
|
74 |
} |
|
64 | 75 |
} |
cdmlib-model/src/main/java/eu/etaxonomy/cdm/strategy/cache/occurrence/OccurrenceCacheStrategyBase.java | ||
---|---|---|
43 | 43 |
return getTitleCache(specimen, false); |
44 | 44 |
} |
45 | 45 |
|
46 |
/** |
|
47 |
* Returns the title cache for the given specimen. |
|
48 |
* |
|
49 |
* @param emptyIfBlank if <code>true</code> a blank result will be returned as empty string. Otherwise |
|
50 |
* the toString() result is returned. |
|
51 |
* @return the title cache |
|
52 |
*/ |
|
46 | 53 |
public String getTitleCache(T specimen, boolean emptyIfBlank) { |
47 | 54 |
if (specimen == null){ |
48 | 55 |
return null; |
... | ... | |
58 | 65 |
return result; |
59 | 66 |
} |
60 | 67 |
|
68 |
public String getIdentityCache(T specimen){ |
|
69 |
boolean emptyIfBlank = true; //for future |
|
70 |
if (specimen == null){ |
|
71 |
return null; |
|
72 |
} |
|
73 |
String result = doGetIdentityCache(specimen); |
|
74 |
if (isBlank(result)){ |
|
75 |
return getTitleCache(specimen, emptyIfBlank); |
|
76 |
} |
|
77 |
return result; |
|
78 |
} |
|
79 |
|
|
61 | 80 |
protected abstract String doGetTitleCache(T occurrence); |
62 | 81 |
|
82 |
protected abstract String doGetIdentityCache(T occurrence); |
|
83 |
|
|
63 | 84 |
protected String getCollectionAndAccession(T occurrence){ |
64 | 85 |
if (occurrence.isInstanceOf(FieldUnit.class)){ |
65 | 86 |
return null; //does not exist for field units |
Also available in: Unified diff
ref #5952, ref #5951 add identityCache formatting to SpecimenOrObservationBase cache strategies