Project

General

Profile

Actions

feature request #9427

closed

Code cleaning in CdmPreferenceCache

Added by Katja Luther almost 2 years ago. Updated over 1 year ago.

Status:
Closed
Priority:
New
Assignee:
Category:
taxeditor
Target version:
Start date:
Due date:
% Done:

100%

Estimated time:
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

Related to EDIT - bug #9422: Improve performance during Preferences startupClosedKatja Luther

Actions
Actions #1

Updated by Katja Luther almost 2 years ago

  • Related to bug #9422: Improve performance during Preferences startup added
Actions #2

Updated by Katja Luther almost 2 years ago

  • Description updated (diff)
Actions #3

Updated by Andreas Müller almost 2 years ago

  • Tags set to fast
Actions #4

Updated by Katja Luther almost 2 years ago

  • Status changed from New to Resolved
  • % Done changed from 0 to 50
Actions #5

Updated by Katja Luther almost 2 years ago

  • Assignee changed from Katja Luther to Andreas Müller
  • Severity changed from normal to blocker

Please have a look.

Actions #6

Updated by Andreas Müller almost 2 years 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.

Actions #7

Updated by Katja Luther almost 2 years ago

  • Status changed from Resolved to Closed

looks fine

Actions #8

Updated by Katja Luther almost 2 years ago

  • % Done changed from 80 to 100
Actions #9

Updated by Andreas Müller over 1 year ago

  • Tags deleted (fast)
Actions

Also available in: Atom PDF