feature request #9427
Code cleaning in CdmPreferenceCache
Start date:
01/28/2021
Due date:
% Done:
100%
Severity:
blocker
Description
copied from #9422:
for CdmPreferenceCache.getAllTaxEditorDBPreferences() the code
PrefKey key = CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.AvailableDistributionStatus);
if (get(key) != null){
if (!PreferencesUtil.getOverrideForPreference(PreferencePredicate.AvailableDistributionStatus.getKey()) || !get(key).isAllowOverride()){
//get terms for the uuids... and add them to the termManager as preferred terms
ITermService termService = CdmStore.getService(ITermService.class);
List<UUID> uuidList = new ArrayList<>();
if (get(key).getValue() != null){
String[] uuidArray =findBestMatching(key).getValue().split(";");
for (String uuidString:uuidArray){
try {
uuidList.add(UUID.fromString(uuidString));
} catch (Exception e) {
logger.warn("Preference loading failed", e);
}
}
}
List<DefinedTermBase> definedTermBases = termService.load(uuidList, null);
List<TermDto> dtos = new ArrayList<>();
for (DefinedTermBase<?> term: definedTermBases){
dtos.add(TermDto.fromTerm(term));
}
CdmStore.getTermManager().setPreferredTermsByType(dtos, TermType.PresenceAbsenceTerm);
}
}
is very redundantly used 3x. This should be deduplicated. Such c&p within the same class almost always shows that code deduplication should be applied. We should try to avoid this in future.
Related issues
Associated revisions
fix #9427: code cleaning
ref #9427 further remove redundant code by parameterized method call
History
#1 Updated by Katja Luther 3 months ago
- Related to bug #9422: Improve performance during Preferences startup added
#2 Updated by Katja Luther 3 months ago
- Description updated (diff)
#3 Updated by Andreas Müller 3 months ago
- Tags set to fast
#4 Updated by Katja Luther 2 months ago
- Status changed from New to Resolved
- % Done changed from 0 to 50
Applied in changeset taxeditor|a5c094d3aeed06649e96b33d5779d86c3e92b5a3.
#5 Updated by Katja Luther 2 months ago
- Assignee changed from Katja Luther to Andreas Müller
- Severity changed from normal to blocker
Please have a look.
#6 Updated by Andreas Müller 2 months ago
- Assignee changed from Andreas Müller to Katja Luther
- % Done changed from 50 to 80
I did some further reduncancy removal. Please check the code and test once if loading still works as expected. Then we can close the ticket.
#8 Updated by Katja Luther about 2 months ago
- % Done changed from 80 to 100