Project

General

Profile

feature request #9427

Code cleaning in CdmPreferenceCache

Added by Katja Luther 6 months ago. Updated about 2 months ago.

Status:
Closed
Priority:
New
Assignee:
Category:
taxeditor
Target version:
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

Related to Edit - bug #9422: Improve performance during Preferences startup Closed 01/25/2021

Associated revisions

Revision a5c094d3 (diff)
Added by Katja Luther 6 months ago

fix #9427: code cleaning

Revision 543d3926 (diff)
Added by Andreas Müller 6 months ago

ref #9427 further remove redundant code by parameterized method call

History

#1 Updated by Katja Luther 6 months ago

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

#2 Updated by Katja Luther 6 months ago

  • Description updated (diff)

#3 Updated by Andreas Müller 6 months ago

  • Tags set to fast

#4 Updated by Katja Luther 6 months ago

  • Status changed from New to Resolved
  • % Done changed from 0 to 50

#5 Updated by Katja Luther 6 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 6 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.

#7 Updated by Katja Luther 5 months ago

  • Status changed from Resolved to Closed

looks fine

#8 Updated by Katja Luther 5 months ago

  • % Done changed from 80 to 100

#9 Updated by Andreas Müller about 2 months ago

  • Tags deleted (fast)

Also available in: Atom PDF

Add picture from clipboard (Maximum size: 40 MB)