Project

General

Profile

« Previous | Next » 

Revision 905236e8

Added by Katja Luther over 4 years ago

ref #8385: adapt strucutre of db prefs to local prefs

View differences:

eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/preference/PreferencesUtil.java
43 43
import eu.etaxonomy.cdm.api.facade.DerivedUnitFacadeConfigurator;
44 44
import eu.etaxonomy.cdm.api.service.ITermService;
45 45
import eu.etaxonomy.cdm.api.service.ITermTreeService;
46
import eu.etaxonomy.cdm.api.service.IVocabularyService;
46 47
import eu.etaxonomy.cdm.api.service.config.FindTaxaAndNamesConfiguratorImpl;
47 48
import eu.etaxonomy.cdm.api.service.config.IFindTaxaAndNamesConfigurator;
48 49
import eu.etaxonomy.cdm.common.CdmUtils;
......
51 52
import eu.etaxonomy.cdm.model.common.ICdmBase;
52 53
import eu.etaxonomy.cdm.model.common.Language;
53 54
import eu.etaxonomy.cdm.model.common.MarkerType;
55
import eu.etaxonomy.cdm.model.description.Feature;
54 56
import eu.etaxonomy.cdm.model.metadata.CdmPreference;
55 57
import eu.etaxonomy.cdm.model.metadata.CdmPreference.PrefKey;
56 58
import eu.etaxonomy.cdm.model.metadata.IPreferencePredicate;
......
62 64
import eu.etaxonomy.cdm.model.term.ISimpleTerm;
63 65
import eu.etaxonomy.cdm.model.term.TermBase;
64 66
import eu.etaxonomy.cdm.model.term.TermTree;
67
import eu.etaxonomy.cdm.model.term.VocabularyEnum;
65 68
import eu.etaxonomy.cdm.strategy.match.DefaultMatchStrategy;
66 69
import eu.etaxonomy.cdm.strategy.match.FieldMatcher;
67 70
import eu.etaxonomy.cdm.strategy.match.IMatchStrategy;
......
72 75
import eu.etaxonomy.taxeditor.model.NomenclaturalCodeHelper;
73 76
import eu.etaxonomy.taxeditor.remoting.source.CdmRemoteSource;
74 77
import eu.etaxonomy.taxeditor.store.CdmStore;
78
import eu.etaxonomy.taxeditor.store.TermStore;
75 79
import eu.etaxonomy.taxeditor.store.internal.TaxeditorStorePlugin;
76 80
import eu.etaxonomy.taxeditor.ui.dialog.DefaultLanguageDialog;
77 81

  
......
92 96
    public static final String P2_REPOSITORIES_DELIM = ",";
93 97
    public static final String P2_REPOSITORY_FIELDS_DELIM = ";";
94 98
    public static final String SUBJECT_DELIM = "/";
99

  
100
    private static TermTree preferredNameFeatureTree;
101

  
95 102
    private final static Logger logger = Logger.getLogger(PreferencesUtil.class);
96 103

  
97 104
    public static IPreferenceStore getPreferenceStore() {
......
1735 1742
        return getPreferenceStore().contains(prefKey(prefKey));
1736 1743
    }
1737 1744

  
1745
    /**
1746
     *
1747
     */
1748
    public static TermTree getPreferredFeatureTreeForNameDescription() {
1749
        if(preferredNameFeatureTree != null){
1750
            return preferredNameFeatureTree;
1751
        }
1752
        createPreferredFeatureTreeForNameDescription();
1753
        return preferredNameFeatureTree;
1754

  
1755
    }
1756

  
1757
    public static void createPreferredFeatureTreeForNameDescription() {
1758

  
1759
        CdmPreferenceCache cache = CdmPreferenceCache.instance();
1760
        CdmPreference pref = cache.get(PreferencePredicate.NameFeatures.getKey());
1761
        List<Feature> terms;
1762
        boolean override = PreferencesUtil.getBooleanValue(PreferencesUtil.createOverridePreferenceString(PreferencePredicate.NameFeatures.getKey()));
1763
        if (pref != null ){
1764
            List<UUID> uuids = PreferencesUtil.createUUIDListFromStringPref(pref.getValue());
1765
            terms = CdmStore.getTermManager().getTerms(uuids, Feature.class);
1766
        }else if (override){
1767
            terms = CdmStore.getTermManager().getPreferredTerms(CdmStore.getService(IVocabularyService.class).load(VocabularyEnum.NameFeature.getUuid()));
1768
        }else{
1769
            terms = new ArrayList();
1770
            terms.addAll(TermStore.getTerms(CdmStore.getService(IVocabularyService.class).load(VocabularyEnum.NameFeature.getUuid()), null));
1771
        }
1772
        terms.remove(Feature.PROTOLOGUE());
1773
        preferredNameFeatureTree = TermTree.NewInstance(terms);
1774

  
1775

  
1776
    }
1777

  
1738 1778

  
1739 1779

  
1740 1780
}

Also available in: Unified diff