Project

General

Profile

« Previous | Next » 

Revision 0ca09004

Added by Patrick Plitzner almost 5 years ago

cleanup

View differences:

eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/preference/PreferencesUtil.java
82 82
 */
83 83
public class PreferencesUtil implements IPreferenceKeys {
84 84

  
85
	/**
86
	 *
87
	 */
88 85
	public static final String PREFERRED_TERMS_CHANGE = "preferred_terms";
89 86

  
90 87
	public static final String P2_REPOSITORIES_DELIM = ",";
......
92 89

  
93 90
	private final static Logger logger = Logger.getLogger(PreferencesUtil.class);
94 91

  
95

  
96

  
97

  
98

  
99
	/**
100
	 * <p>
101
	 * getPreferenceStore
102
	 * </p>
103
	 *
104
	 * @return a {@link org.eclipse.jface.preference.IPreferenceStore} object.
105
	 */
106 92
	public static IPreferenceStore getPreferenceStore() {
107 93
		return TaxeditorStorePlugin.getDefault().getPreferenceStore();
108 94
	}
......
115 101
        return name + "_OVERRIDE_";
116 102
    }
117 103

  
118
	/**
119
     * <p>
120
     * setStringValue
121
     * </p>
122
     *
123
     *
124
     **/
125 104
    public static void setStringValue(String name, String value) {
126 105
        if (value != null){
127 106
            getPreferenceStore().setValue(prefKey(name), value);
......
130 109
        }
131 110
    }
132 111

  
133
    /**
134
     * <p>
135
     * setIntValue
136
     * </p>
137
     *
138
     *
139
     **/
140 112
    public static void setIntValue(String name, int value) {
141 113
        getPreferenceStore().setValue(prefKey(name), value);
142 114
    }
143 115

  
144
    /**
145
     * <p>
146
     * setBooleanValue
147
     * </p>
148
     *
149
     *
150
     **/
151 116
    public static void setBooleanValue(String name, boolean value) {
152 117
        getPreferenceStore().setValue(prefKey(name), value);
153 118
    }
154 119

  
155
    /**
156
     * <p>
157
     * setBooleanValue
158
     * </p>
159
     *
160
     *
161
     **/
162 120
    public static void setDoubleValue(String name, double value) {
163 121
        getPreferenceStore().setValue(prefKey(name), value);
164 122
    }
165 123

  
166
    /**
167
     * <p>
168
     * setFloatValue
169
     * </p>
170
     *
171
     *
172
     **/
173 124
    public static void setFloatValue(String name, float value) {
174 125
        getPreferenceStore().setValue(prefKey(name), value);
175 126
    }
176 127

  
177
    /**
178
     * <p>
179
     * setFloatValue
180
     * </p>
181
     *
182
     *
183
     **/
184 128
    public static void setLongValue(String name, long value) {
185 129
        getPreferenceStore().setValue(prefKey(name), value);
186 130
    }
187 131

  
188
    /**
189
     * <p>
190
     * getStringValue
191
     * </p>
192
     *
193
     *
194
     **/
195 132
    public static String getStringValue(String name, boolean local) {
196 133

  
197 134
        CdmPreference pref = getDBPreferenceValue(name);
......
240 177
        return pref;
241 178
    }
242 179

  
243
    /**
244
     * <p>
245
     * setIntValue
246
     * </p>
247
     *
248
     *
249
     **/
250 180
    public static int getIntValue(String name, boolean local) {
251 181
        CdmPreference pref= getDBPreferenceValue(name);
252 182
        String prefValue = null;
......
282 212
        return getBooleanValue(name, false);
283 213
    }
284 214

  
285
    /**
286
     * <p>
287
     * getBooleanValue
288
     * </p>
289
     *
290
     *
291
     **/
292 215
    public static boolean getBooleanValue(String name, boolean local) {
293 216
        if (CdmStore.isActive()){
294 217
            CdmPreference pref = getDBPreferenceValue(name);
......
311 234

  
312 235
    }
313 236

  
314
    /**
315
     * <p>
316
     * setBooleanValue
317
     * </p>
318
     *
319
     *
320
     **/
321 237
    public static double getDoubleValue(String name) {
322 238
        CdmPreference pref = getDBPreferenceValue(name);
323 239
        String prefValue = null;
......
343 259

  
344 260
    }
345 261

  
346
    /**
347
     * <p>
348
     * getFloatValue
349
     * </p>
350
     *
351
     *
352
     **/
353 262
    public static float getFloatValue(String name, boolean local) {
354 263
        CdmPreference pref = getDBPreferenceValue(name);
355 264
        String prefValue = null;
......
380 289

  
381 290
    }
382 291

  
383
    /**
384
     * <p>
385
     * getLongValue
386
     * </p>
387
     *
388
     *
389
     **/
390 292
    public static long getLongValue(String name) {
391 293
        CdmPreference pref = getDBPreferenceValue(name);
392 294
        String prefValue = null;
......
411 313
        return result;
412 314
    }
413 315

  
414

  
415
	/**
416
	 * <p>
417
	 * setPreferredNomenclaturalCode
418
	 * </p>
419
	 *
420
	 * @param preferredCode
421
	 *            a {@link eu.etaxonomy.cdm.model.name.NomenclaturalCode}
422
	 *            object.
423
	 */
424 316
	public static CdmPreference setPreferredNomenclaturalCode(
425 317
			String preferenceValue, boolean local) {
426 318
	    if (local){
......
463 355

  
464 356
	}
465 357

  
466
	/**
467
     * <p>
468
     * setPreferredNomenclaturalCode
469
     * </p>
470
     *
471
     * @param preferredCode
472
     *            a {@link eu.etaxonomy.cdm.model.name.NomenclaturalCode}
473
     *            object.
474
     */
475 358
    public static void setPreferredNomenclaturalCode(
476 359
        CdmPreference preference) {
477 360

  
......
491 374

  
492 375
    }
493 376

  
494

  
495

  
496

  
497
	/**
498
	 * <p>
499
	 * getPreferredNomenclaturalCode
500
	 * </p>
501
	 *
502
	 * @return a {@link eu.etaxonomy.cdm.model.name.NomenclaturalCode} object.
503
	 */
504 377
	public static NomenclaturalCode getPreferredNomenclaturalCode() {
505 378

  
506 379
		CdmPreference pref = getPreferenceFromDB(PreferencePredicate.NomenclaturalCode);
......
522 395

  
523 396
	}
524 397

  
525
	/**
526
     * <p>
527
     * getPreferredNomenclaturalCode
528
     * </p>
529
     *
530
     * @return a {@link eu.etaxonomy.cdm.model.name.NomenclaturalCode} object.
531
     */
532 398
    public static NomenclaturalCode getPreferredNomenclaturalCode(String preferenceKeyNomenclaturalCode) {
533 399

  
534 400
        for (NomenclaturalCode code : NomenclaturalCodeHelper.getAllCodes()) {
......
612 478

  
613 479
    }
614 480

  
615

  
616

  
617 481
    public static void setPreferenceToDB(CdmPreference preference){
618 482
        ICdmRepository controller;
619 483
        try{
......
628 492

  
629 493
    }
630 494

  
631

  
632

  
633 495
	public static String getPreferredDefaultLangugae(){
634 496
	    String preferredLanguage = getStringValue(DEFAULT_LANGUAGE_EDITOR);
635 497
	    if(StringUtils.isNotEmpty(preferredLanguage) && StringUtils.isNotBlank(preferredLanguage)){
......
719 581
		return DefaultMatchStrategy.NewInstance(clazz);
720 582
	}
721 583

  
722
	/**
723
	 * <p>
724
	 * getDateFormatPattern
725
	 * </p>
726
	 *
727
	 * @return a {@link java.lang.String} object.
728
	 */
729 584
	public static String getDateFormatPattern() {
730 585
		// TODO make this configurable in properties
731 586
		String pattern = "Y-M-d H:m";
732 587
		return pattern;
733 588
	}
734 589

  
735
	/**
736
	 * <p>
737
	 * addTermToPreferredTerms
738
	 * </p>
739
	 *
740
	 * @param term
741
	 *            a T object.
742
	 * @param <T>
743
	 *            a T object.
744
	 */
745 590
	public static <T extends TermBase> void addTermToPreferredTerms(T term) {
746 591

  
747 592
		// VocabularyEnum vocabulary =
......
881 726
				configurator.isDoTaxaByCommonNames());
882 727
	}
883 728

  
884
	/**
885
	 * <p>
886
	 * firePreferencesChanged
887
	 * </p>
888
	 *
889
	 * @param clazz
890
	 *            a {@link java.lang.Class} object.
891
	 */
892 729
	public static void firePreferencesChanged(Class clazz) {
893 730
		getPreferenceStore().firePropertyChangeEvent(PREFERRED_TERMS_CHANGE,
894 731
				null, clazz);
......
959 796

  
960 797
	}
961 798

  
962
	/**
963
	 * <p>
964
	 * checkNomenclaturalCode
965
	 * </p>
966
	 */
967 799
	public static void checkNomenclaturalCode() {
968 800
		// First time Editor is opened, no nomenclatural code has been set
969 801
		if (PreferencesUtil.getPreferredNomenclaturalCode() == null) {
......
1009 841
	    }
1010 842
	}
1011 843

  
1012
	/**
1013
	 * <p>
1014
	 * getMapServiceAccessPoint
1015
	 * </p>
1016
	 *
1017
	 * @return a {@link java.lang.String} object.
1018
	 */
1019 844
	public static String getMapServiceAccessPoint() {
1020 845
		return getStringValue(EDIT_MAP_SERVICE_ACCES_POINT);
1021 846
	}
1022 847

  
1023
	/**
1024
	 * <p>
1025
	 * shouldConnectAtStartUp
1026
	 * </p>
1027
	 *
1028
	 * @return a boolean.
1029
	 */
1030 848
	public static boolean shouldConnectAtStartUp() {
1031 849
		//FIXME :  force SHOULD_CONNECT_AT_STARTUP to false (ticket 3828) until resolution
1032 850
		//return getBooleanValue(SHOULD_CONNECT_AT_STARTUP);
1033 851
		return false;
1034 852
	}
1035 853

  
1036
	/**
1037
	 * <p>
1038
	 * getDefaultFeatureTreeForTextualDescription
1039
	 * </p>
1040
	 *
1041
	 * @return a {@link eu.etaxonomy.cdm.model.term.FeatureTree} object.
1042
	 */
1043 854
	public static FeatureTree getDefaultFeatureTreeForTextualDescription() {
1044 855
		String uuidString = getStringValue(
1045 856
				FEATURE_TREE_DEFAULT_TEXT);
......
1054 865
		return tree;
1055 866
	}
1056 867

  
1057
	/**
1058
	 * <p>
1059
	 * getDefaultFeatureTreeForStructuredDescription
1060
	 * </p>
1061
	 *
1062
	 * @return a {@link eu.etaxonomy.cdm.model.term.FeatureTree} object.
1063
	 */
1064 868
	public static FeatureTree getDefaultFeatureTreeForStructuredDescription() {
1065 869
		String uuidString = getStringValue(
1066 870
				FEATURE_TREE_DEFAULT_STRUCTURE);
......
1068 872
				IFeatureTreeService.class).load(UUID.fromString(uuidString));
1069 873
	}
1070 874

  
1071
	/**
1072
	 * <p>
1073
	 * setSortRanksHierarchichally
1074
	 * </p>
1075
	 *
1076
	 * @param selection
1077
	 *            a boolean.
1078
	 */
1079 875
	public static void setSortRanksHierarchichally(boolean selection) {
1080 876
		setBooleanValue(SORT_RANKS_HIERARCHICHALLY, selection);
1081 877
	}
1082 878

  
1083
	/**
1084
	 * <p>
1085
	 * getSortRanksHierarchichally
1086
	 * </p>
1087
	 *
1088
	 * @return a boolean.
1089
	 */
1090 879
	public static boolean getSortRanksHierarchichally() {
1091 880
		return getBooleanValue(SORT_RANKS_HIERARCHICHALLY);
1092 881
	}
......
1124 913

  
1125 914
	}
1126 915

  
1127
	/**
1128
	 * @return
1129
	 */
1130 916
	public static Map<MarkerType, Boolean> getEditMarkerTypePreferences() {
1131 917
		List<MarkerType> markerTypes = CdmStore.getTermManager()
1132 918
				.getPreferredTerms(MarkerType.class);
......
1143 929
		return result;
1144 930
	}
1145 931

  
1146
	/**
1147
	 * @param markerTypeEditingMap
1148
	 */
1149 932
	public static void setEditMarkerTypePreferences(
1150 933
			Map<MarkerType, Boolean> markerTypeEditingMap) {
1151 934
		for (MarkerType markerType : markerTypeEditingMap.keySet()) {
......
1162 945
		return markerType.getClass().getName() + EDIT_MARKER_TYPE_PREFIX;
1163 946
	}
1164 947

  
1165
	/**
1166
	 * <p>
1167
	 * setEditMarkerTypePreference
1168
	 * </p>
1169
	 *
1170
	 * @param input
1171
	 *            a {@link org.eclipse.ui.IEditorInput} object.
1172
	 * @param markerType
1173
	 *            a {@link eu.etaxonomy.cdm.model.common.MarkerType} object.
1174
	 * @param edit
1175
	 *            a boolean.
1176
	 */
1177 948
	public static void setEditMarkerTypePreference(MarkerType markerType,
1178 949
			boolean edit) {
1179 950
		setBooleanValue(
1180 951
				getMarkerTypeEditingPreferenceKey(markerType), edit);
1181 952
	}
1182 953

  
1183
	/**
1184
	 * @return
1185
	 */
1186 954
	public static DerivedUnitFacadeConfigurator getDerivedUnitConfigurator() {
1187 955
		DerivedUnitFacadeConfigurator configurator = DerivedUnitFacadeConfigurator
1188 956
				.NewInstance();
......
1322 1090
        }
1323 1091
    }
1324 1092

  
1325

  
1326

  
1327

  
1328
    /**
1329
     * @param orderActivated
1330
     */
1331 1093
    public static void setSortNodes(NavigatorOrderEnum nodesOrder) {
1332 1094
        setStringValue(PreferencePredicate.TaxonNodeOrder.getKey(), nodesOrder.key);
1333 1095

  
1334 1096
    }
1335 1097

  
1336
    /**
1337
     * @param orderActivated
1338
     */
1339 1098
    public static NavigatorOrderEnum getSortNodes() {
1340 1099
        return NavigatorOrderEnum.valueOf(getStringValue(PreferencePredicate.TaxonNodeOrder.getKey()));
1341 1100

  
1342 1101
    }
1343 1102

  
1344
    /**
1345
     * @param orderActivated
1346
     */
1347 1103
    public static boolean isNodesSortedNaturally() {
1348 1104
        NavigatorOrderEnum value = NavigatorOrderEnum.valueOf(getStringValue(PreferencePredicate.TaxonNodeOrder.getKey()));
1349 1105
        return value.equals(NavigatorOrderEnum.NaturalOrder);
1350 1106

  
1351 1107
    }
1352 1108

  
1353
    /**
1354
     * @param orderActivated
1355
     */
1356 1109
    public static boolean isNodesSortedByName() {
1357 1110
        NavigatorOrderEnum value = NavigatorOrderEnum.valueOf(getStringValue(PreferencePredicate.TaxonNodeOrder.getKey()));
1358 1111
        return value.equals(NavigatorOrderEnum.AlphabeticalOrder);
1359 1112

  
1360 1113
    }
1361 1114

  
1362
    /**
1363
     * @param orderActivated
1364
     */
1365 1115
    public static boolean isNodesSortedByNameAndRank() {
1366 1116
        NavigatorOrderEnum value = NavigatorOrderEnum.valueOf(getStringValue(PreferencePredicate.TaxonNodeOrder.getKey()));
1367 1117
        return value.equals(NavigatorOrderEnum.RankAndNameOrder);
1368 1118

  
1369 1119
    }
1370
	/**
1371
	 * <p>
1372
	 * setStoreNavigatorState
1373
	 * </p>
1374
	 *
1375
	 * @param selection
1376
	 *            a boolean.
1377
	 */
1378
	public static boolean isStoreNavigatorState() {
1120

  
1121
    public static boolean isStoreNavigatorState() {
1379 1122
		return getBooleanValue(RESTORE_NAVIGATOR_STATE);
1380 1123

  
1381 1124
	}
1382 1125

  
1383
	/**
1384
	 * <p>
1385
	 * setStoreNavigatorState
1386
	 * </p>
1387
	 *
1388
	 * @param selection
1389
	 *            a boolean.
1390
	 */
1391 1126
	public static void setStoreNavigatorState(boolean selection) {
1392 1127
		setBooleanValue(RESTORE_NAVIGATOR_STATE, selection);
1393 1128

  
1394 1129
	}
1395 1130

  
1396
    /**
1397
     * @return
1398
     */
1399 1131
    public static boolean isShowUpWidgetIsDisposedMessages() {
1400 1132
       return getBooleanValue(IS_SHOW_UP_WIDGET_IS_DISPOSED);
1401 1133
    }
......
1403 1135
        setBooleanValue(IS_SHOW_UP_WIDGET_IS_DISPOSED, selection);
1404 1136
    }
1405 1137

  
1406
    /**
1407
     * @return
1408
     */
1409 1138
    public static boolean isShowIdInVocabularyInChecklistEditor() {
1410 1139
        String area_display = getStringValue(PreferencePredicate.DisplayOfAreasInDistributionEditor.getKey());
1411 1140
        if (area_display.equals(TermDisplayEnum.IdInVocabulary.getKey())) {
......
1442 1171
        return getBooleanValue(PreferencePredicate.OwnDescriptionForDistributionEditor.getKey());
1443 1172
    }
1444 1173

  
1445
    /**
1446
     * @return
1447
     */
1448 1174
    public static String displayAreaInChecklistEditor() {
1449 1175
        String result = getStringValue(PreferencePredicate.DisplayOfAreasInDistributionEditor.getKey());
1450 1176
        if (StringUtils.isBlank(result)){
......
1453 1179
       return result;
1454 1180
    }
1455 1181

  
1456
    /**
1457
     * @return
1458
     */
1459 1182
    public static String displayStatusInChecklistEditor() {
1460 1183
        String result = getStringValue(PreferencePredicate.DisplayOfStatus.getKey());
1461 1184
        if (StringUtils.isBlank(result)){
......
1468 1191

  
1469 1192
    }
1470 1193

  
1471
    /**
1472
     * @return
1473
     */
1474 1194
    public static boolean isShowRankInChecklistEditor() {
1475 1195
        return getBooleanValue(PreferencePredicate.ShowRankInDistributionEditor.getKey());
1476 1196
    }
......
1478 1198
       setBooleanValue(PreferencePredicate.ShowRankInDistributionEditor.getKey(), selection);
1479 1199
    }
1480 1200

  
1481
    /**
1482
     * @param object
1483
     * @param b
1484
     * @return
1485
     */
1486 1201
    public static NameDetailsConfigurator getPreferredNameDetailsConfiguration( boolean local) {
1487 1202
        NameDetailsConfigurator config = new NameDetailsConfigurator(true);
1488 1203
        CdmPreferenceCache cache = CdmPreferenceCache.instance();
......
1580 1295
        return config;
1581 1296
    }
1582 1297

  
1583

  
1584
    /**
1585
     * @param object
1586
     * @param b
1587
     * @return
1588
     */
1589 1298
    public static void setPreferredNameDetailsConfiguration(NameDetailsConfigurator config, boolean local) {
1590 1299
        CdmPreference preference = null;
1591 1300

  
......
1610 1319

  
1611 1320
	}
1612 1321

  
1613

  
1614

  
1615
    /**
1616
     * <p>
1617
     * setAbcdConfigurator
1618
     * </p>
1619
     *
1620
     * @param preferredConfiguration
1621
     *            a {@link eu.etaxonomy.cdm.io.specimen.abcd206.in.Abcd206ImportConfigurator}
1622
     *            object.
1623
     */
1624 1322
    public static Abcd206ImportConfigurator getDBAbcdImportConfigurationPreference() {
1625 1323

  
1626 1324
        Abcd206ImportConfigurator config = Abcd206ImportConfigurator.NewInstance(null,null);
......
1714 1412

  
1715 1413
    }
1716 1414

  
1717

  
1718 1415
    public static void updateAbcdImportConfigurationPreference() {
1719 1416
        CdmPreferenceCache cache = CdmPreferenceCache.instance();
1720 1417

  
......
1751 1448
        }
1752 1449
    }
1753 1450

  
1451
    public static boolean isSortTaxaByRankAndName() {
1754 1452

  
1453
        return getBooleanValue(IPreferenceKeys.SORT_TAXA_BY_RANK_AND_NAME);
1454
    }
1755 1455

  
1456
    public static String getSortNamedAreasInDistributionEditor() {
1756 1457

  
1458
        return getStringValue(PreferencePredicate.AreasSortedInDistributionEditor.getKey());
1459
    }
1757 1460

  
1461
    public static void setSortNamedAreasInDistributionEditor(String isSortByVocabularyOrder) {
1462
        setStringValue(PreferencePredicate.AreasSortedInDistributionEditor.getKey(), isSortByVocabularyOrder);
1758 1463

  
1464
    }
1759 1465

  
1760
/**
1761
 * @return
1762
 */
1763
public static boolean isSortTaxaByRankAndName() {
1764

  
1765
    return getBooleanValue(IPreferenceKeys.SORT_TAXA_BY_RANK_AND_NAME);
1766
}
1767

  
1768
/**
1769
 * @return
1770
 */
1771
public static String getSortNamedAreasInDistributionEditor() {
1772

  
1773
    return getStringValue(PreferencePredicate.AreasSortedInDistributionEditor.getKey());
1774
}
1775

  
1776
public static void setSortNamedAreasInDistributionEditor(String isSortByVocabularyOrder) {
1777
    setStringValue(PreferencePredicate.AreasSortedInDistributionEditor.getKey(), isSortByVocabularyOrder);
1778

  
1779
}
1780

  
1781
/**
1782
 * <p>
1783
 * setPreferredNamedAreasForDistributionEditor
1784
 * </p>
1785
 *
1786
 * @param saveCheckedElements
1787
 * @param saveGrayedElements
1788
 */
1789
public static void setLastSelectedReference(
1790
        List<String> lastSelectedReferences) {
1466
    public static void setLastSelectedReference(
1467
            List<String> lastSelectedReferences) {
1791 1468

  
1792 1469
        setStringValue(PreferencesUtil.LAST_SELECTED_REFERENCES, lastSelectedReferences.toString());
1793 1470
    }
1794 1471

  
1795
/**
1796
 * <p>
1797
 * setPreferredNamedAreasForDistributionEditor
1798
 * </p>
1799
 *
1800
 * @param saveCheckedElements
1801
 * @param saveGrayedElements
1802
 */
1803
public static List<String> getLastSelectedReferences() {
1472
    public static List<String> getLastSelectedReferences() {
1804 1473

  
1805 1474
        //IPreferenceStore preferenceStore = PreferencesUtil.getPreferenceStore();
1806 1475
        String lastSelected = getStringValue(PreferencesUtil.LAST_SELECTED_REFERENCES);
......
1811 1480
        return result;
1812 1481
    }
1813 1482

  
1483
    public static void setPreferredNamedAreasForDistributionEditor(
1484
            String saveCheckedElements, String saveGrayedElements, boolean local) {
1485
        if (local){
1486
            setStringValue(PreferencePredicate.AvailableDistributionAreaTerms.getKey(), saveCheckedElements);
1814 1487

  
1815
/**
1816
 * <p>
1817
 * setPreferredNamedAreasForDistributionEditor
1818
 * </p>
1819
 *
1820
 * @param saveCheckedElements
1821
 * @param saveGrayedElements
1822
 */
1823
public static void setPreferredNamedAreasForDistributionEditor(
1824
        String saveCheckedElements, String saveGrayedElements, boolean local) {
1825
    if (local){
1826
        setStringValue(PreferencePredicate.AvailableDistributionAreaTerms.getKey(), saveCheckedElements);
1488
        }
1489
        else{
1490
            CdmPreference preference = null;
1827 1491

  
1828
    }
1829
    else{
1830
        CdmPreference preference = null;
1492
            if (saveCheckedElements == null){
1493
                preference = getPreferenceFromDB(PreferencePredicate.AvailableDistributionAreaTerms);
1831 1494

  
1832
        if (saveCheckedElements == null){
1833
            preference = getPreferenceFromDB(PreferencePredicate.AvailableDistributionAreaTerms);
1495
                if (preference == null){
1496
                    return ;
1497
                } else{
1498
                    setStringValue(PreferencePredicate.AvailableDistributionAreaTerms.getKey(),
1499
                            saveCheckedElements);
1500
                    preference = CdmPreference.NewInstance(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.AvailableDistributionAreaTerms, saveCheckedElements);
1501
                    setPreferenceToDB(preference);
1834 1502

  
1835
            if (preference == null){
1836
                return ;
1503
                }
1837 1504
            } else{
1838
                setStringValue(PreferencePredicate.AvailableDistributionAreaTerms.getKey(),
1839
                        saveCheckedElements);
1840 1505
                preference = CdmPreference.NewInstance(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.AvailableDistributionAreaTerms, saveCheckedElements);
1841 1506
                setPreferenceToDB(preference);
1507
                setStringValue(PreferencePredicate.AvailableDistributionAreaTerms.getKey(),
1508
                        saveCheckedElements);
1842 1509

  
1843 1510
            }
1844
        } else{
1845
           preference = CdmPreference.NewInstance(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.AvailableDistributionAreaTerms, saveCheckedElements);
1846
           setPreferenceToDB(preference);
1847
           setStringValue(PreferencePredicate.AvailableDistributionAreaTerms.getKey(),
1848
                    saveCheckedElements);
1849

  
1850 1511
        }
1851
    }
1852

  
1853
}
1854 1512

  
1855
/**
1856
 * @param saveCheckedElements
1857
 * @param saveCheckedElements2
1858
 * @param b
1859
 */
1860
public static void setPreferredVocabulariesForDistributionEditor(String saveCheckedElements,
1861
        boolean local, boolean isOverride) {
1862
    if (local){
1863
      setStringValue(PreferencePredicate.AvailableDistributionAreaVocabularies.getKey(), saveCheckedElements);
1864
      setBooleanValue(prefOverrideKey(PreferencePredicate.AvailableDistributionAreaVocabularies.getKey()), isOverride);
1865 1513
    }
1866
    else{
1867
        ICdmRepository controller;
1868
        CdmPreference preference = null;
1869

  
1870
        if (saveCheckedElements == null){
1871
            preference = getPreferenceFromDB(PreferencePredicate.AvailableDistributionAreaVocabularies);
1872 1514

  
1873
            if (preference == null){
1874
                return ;
1515
    public static void setPreferredVocabulariesForDistributionEditor(String saveCheckedElements,
1516
            boolean local, boolean isOverride) {
1517
        if (local){
1518
            setStringValue(PreferencePredicate.AvailableDistributionAreaVocabularies.getKey(), saveCheckedElements);
1519
            setBooleanValue(prefOverrideKey(PreferencePredicate.AvailableDistributionAreaVocabularies.getKey()), isOverride);
1520
        }
1521
        else{
1522
            ICdmRepository controller;
1523
            CdmPreference preference = null;
1524

  
1525
            if (saveCheckedElements == null){
1526
                preference = getPreferenceFromDB(PreferencePredicate.AvailableDistributionAreaVocabularies);
1527

  
1528
                if (preference == null){
1529
                    return ;
1530
                } else{
1531
                    setStringValue(PreferencePredicate.AvailableDistributionAreaVocabularies.getKey(),
1532
                            saveCheckedElements);
1533
                    preference = CdmPreference.NewInstance(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.AvailableDistributionAreaVocabularies, saveCheckedElements);
1534
                    preference.setAllowOverride(isOverride);
1535
                    setPreferenceToDB(preference);
1536
                }
1875 1537
            } else{
1876
                setStringValue(PreferencePredicate.AvailableDistributionAreaVocabularies.getKey(),
1877
                        saveCheckedElements);
1878 1538
                preference = CdmPreference.NewInstance(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.AvailableDistributionAreaVocabularies, saveCheckedElements);
1879 1539
                preference.setAllowOverride(isOverride);
1880 1540
                setPreferenceToDB(preference);
1881
            }
1882
        } else{
1883
            preference = CdmPreference.NewInstance(PreferenceSubject.NewTaxEditorInstance(), PreferencePredicate.AvailableDistributionAreaVocabularies, saveCheckedElements);
1884
            preference.setAllowOverride(isOverride);
1885
            setPreferenceToDB(preference);
1886
            setStringValue(PreferencePredicate.AvailableDistributionAreaVocabularies.getKey(),
1887
                    saveCheckedElements);
1541
                setStringValue(PreferencePredicate.AvailableDistributionAreaVocabularies.getKey(),
1542
                        saveCheckedElements);
1888 1543

  
1544
            }
1889 1545
        }
1890 1546
    }
1891
}
1892 1547

  
1548
    public static String getPreferredVocabulariesForDistributionEditor(boolean local) {
1549
        if (local){
1893 1550

  
1894
/**
1895
 * @param saveCheckedElements
1896
 * @param saveCheckedElements2
1897
 * @param b
1898
 */
1899
public static String getPreferredVocabulariesForDistributionEditor(boolean local) {
1900
    if (local){
1901

  
1902
        String pref = getStringValue(PreferencePredicate.AvailableDistributionAreaVocabularies.getKey(), local);
1903
        return pref;
1904
    }
1905
    else{
1906
        CdmPreference preference = null;
1907
        preference = getPreferenceFromDB(PreferencePredicate.AvailableDistributionAreaVocabularies);
1908
        if (preference == null){
1909
            return null;
1910
        } else{
1911
            return preference.getValue();
1551
            String pref = getStringValue(PreferencePredicate.AvailableDistributionAreaVocabularies.getKey(), local);
1552
            return pref;
1912 1553
        }
1554
        else{
1555
            CdmPreference preference = null;
1556
            preference = getPreferenceFromDB(PreferencePredicate.AvailableDistributionAreaVocabularies);
1557
            if (preference == null){
1558
                return null;
1559
            } else{
1560
                return preference.getValue();
1561
            }
1913 1562

  
1563
        }
1914 1564
    }
1915
}
1916 1565

  
1917
public static List<UUID> createUUIDListFromStringPref(String prefKey) {
1918
    String prefValue = PreferencesUtil.getStringValue(prefKey);
1919
    String[] stringArray = prefValue.split(";");
1920
    List<UUID> uuidList = new ArrayList();
1921
    for (String uuid: stringArray){
1922
        if (!StringUtils.isBlank(uuid)){
1923
            uuidList.add(UUID.fromString(uuid));
1566
    public static List<UUID> createUUIDListFromStringPref(String prefKey) {
1567
        String prefValue = PreferencesUtil.getStringValue(prefKey);
1568
        String[] stringArray = prefValue.split(";");
1569
        List<UUID> uuidList = new ArrayList();
1570
        for (String uuid: stringArray){
1571
            if (!StringUtils.isBlank(uuid)){
1572
                uuidList.add(UUID.fromString(uuid));
1573
            }
1924 1574
        }
1575
        return uuidList;
1925 1576
    }
1926
    return uuidList;
1927
}
1928

  
1929
public static boolean getFilterCommonNameReferences(){
1930
    return getBooleanValue(PreferencesUtil.FILTER_COMMON_NAME_REFERENCES);
1931
}
1932

  
1933
/**
1934
 *
1935
 */
1936
public static void updateDBPreferences() {
1937
    CdmPreference preference = null;
1938
    CdmPreferenceCache cache = CdmPreferenceCache.instance();
1939
    cache.getAllTaxEditorDBPreferences();
1940

  
1941
    //ABCD Configurator
1942

  
1943
    updateAbcdImportConfigurationPreference();
1944

  
1945
    //Name Details
1946
    NameDetailsConfigurator config = getPreferredNameDetailsConfiguration(false);
1947
//    if (config != null ){
1948
//        if (!getBooleanValue(OVERRIDE_NAME_DETAILS) ||  !getBooleanValue(ALLOW_OVERRIDE_NAME_DETAILS)){
1949
//            setPreferredNameDetailsConfiguration(config, false);
1950
//        }
1951
//    }
1952

  
1953

  
1954 1577

  
1578
    public static boolean getFilterCommonNameReferences(){
1579
        return getBooleanValue(PreferencesUtil.FILTER_COMMON_NAME_REFERENCES);
1580
    }
1955 1581

  
1582
    public static void updateDBPreferences() {
1583
        CdmPreference preference = null;
1584
        CdmPreferenceCache cache = CdmPreferenceCache.instance();
1585
        cache.getAllTaxEditorDBPreferences();
1956 1586

  
1587
        //ABCD Configurator
1957 1588

  
1589
        updateAbcdImportConfigurationPreference();
1958 1590

  
1591
        //Name Details
1592
        NameDetailsConfigurator config = getPreferredNameDetailsConfiguration(false);
1593
        //    if (config != null ){
1594
        //        if (!getBooleanValue(OVERRIDE_NAME_DETAILS) ||  !getBooleanValue(ALLOW_OVERRIDE_NAME_DETAILS)){
1595
        //            setPreferredNameDetailsConfiguration(config, false);
1596
        //        }
1597
        //    }
1959 1598

  
1960
}
1599
    }
1961 1600

  
1962
/**
1963
 * @param string
1964
 * @param saveCheckedElements
1965
 */
1966
public static void setPreferencesToDB(List<CdmPreference> preferences) {
1601
    public static void setPreferencesToDB(List<CdmPreference> preferences) {
1967 1602

  
1968
    ICdmRepository controller;
1969
    try{
1970
        if(CdmStore.isActive()){
1971
            controller = CdmStore.getCurrentApplicationConfiguration();
1972
            for (CdmPreference preference: preferences){
1603
        ICdmRepository controller;
1604
        try{
1605
            if(CdmStore.isActive()){
1606
                controller = CdmStore.getCurrentApplicationConfiguration();
1607
                for (CdmPreference preference: preferences){
1973 1608

  
1974
                controller.getPreferenceService().set(preference);
1609
                    controller.getPreferenceService().set(preference);
1975 1610

  
1976
                CdmPreferenceCache.instance().put(preference);
1611
                    CdmPreferenceCache.instance().put(preference);
1612
                }
1977 1613
            }
1614
        }catch(Exception e){
1615
            e.printStackTrace();
1978 1616
        }
1979
    }catch(Exception e){
1980
        e.printStackTrace();
1981 1617
    }
1982
}
1983

  
1984

  
1985

  
1986

  
1987

  
1988

  
1989

  
1990 1618

  
1991 1619
}

Also available in: Unified diff