Project

General

Profile

« Previous | Next » 

Revision cc1302bd

Added by Katja Luther almost 5 years ago

ref #8045: check whether all db preferences are deleted from DB if value is default value

View differences:

eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/preference/PreferencesUtil.java
247 247
     *
248 248
     *
249 249
     **/
250
    public static int getIntValue(String name) {
250
    public static int getIntValue(String name, boolean local) {
251 251
        CdmPreference pref= getDBPreferenceValue(name);
252 252
        String prefValue = null;
253 253
        if (pref != null){
......
259 259
        }catch(NumberFormatException e){
260 260
            logger.debug("Preference value of " + name + " is not a number");
261 261
        }
262
        if (result == null){
262

  
263
        String overrideKey =  createPreferenceString(createOverridePreferenceString(name));
264
        boolean override = true;
265
        if (getPreferenceStore().contains(overrideKey)){
266
            override = getPreferenceStore().getBoolean(overrideKey);
267
        }
268
        if (local || pref == null || (pref != null && pref.isAllowOverride() && override)){
263 269
            String dbSpecific = prefKey(name);
264 270
            if (getPreferenceStore().contains(dbSpecific)){
265 271
                result = getPreferenceStore().getInt(dbSpecific);
......
270 276
        }
271 277
        return result;
272 278

  
273

  
274 279
    }
275 280

  
276 281
    public static boolean getBooleanValue(String name) {
......
287 292
    public static boolean getBooleanValue(String name, boolean local) {
288 293
        if (CdmStore.isActive()){
289 294
            CdmPreference pref = getDBPreferenceValue(name);
290
            String prefValue = null;
291
            if (pref == null || local){
295

  
296
            String overrideKey =  createPreferenceString(createOverridePreferenceString(name));
297
            boolean override = true;
298
            if (getPreferenceStore().contains(overrideKey)){
299
                override = getPreferenceStore().getBoolean(overrideKey);
300
            }
301
            if (local || pref == null || (pref != null && pref.isAllowOverride() && override)){
292 302
                String dbSpecific = prefKey(name);
293
                if (getPreferenceStore().contains(dbSpecific)){
294
                    return getPreferenceStore().getBoolean(dbSpecific);
295
                }else{
296
                    return getPreferenceStore().
297
                            getBoolean(name);
298
                }
299
            }else{
303
                return getPreferenceStore().getBoolean(dbSpecific);
304
             }else{
300 305
                return Boolean.valueOf(pref.getValue());
301 306
            }
302 307

  
......
345 350
     *
346 351
     *
347 352
     **/
348
    public static float getFloatValue(String name) {
353
    public static float getFloatValue(String name, boolean local) {
349 354
        CdmPreference pref = getDBPreferenceValue(name);
350 355
        String prefValue = null;
351 356
        if (pref != null){
......
357 362
        }catch(NumberFormatException e){
358 363
            logger.debug("Preference value of " + name + " is not a number");
359 364
        }
360
        if (result == null){
365
        String overrideKey =  createPreferenceString(createOverridePreferenceString(name));
366
        boolean override = true;
367
        if (getPreferenceStore().contains(overrideKey)){
368
            override = getPreferenceStore().getBoolean(overrideKey);
369
        }
370
        if (local || pref == null || (pref != null && pref.isAllowOverride() && override)){
361 371
            String dbSpecific = prefKey(name);
362 372
            if (getPreferenceStore().contains(dbSpecific)){
363 373
                result = getPreferenceStore().getFloat(dbSpecific);
......
945 955
		getPreferenceStore().setDefault(createPreferenceString(PreferencePredicate.ShowIdInSource.getKey()), Boolean.valueOf(PreferencePredicate.ShowIdInSource.getDefaultValue().toString()));
946 956
		getPreferenceStore().setDefault(createPreferenceString(PreferencePredicate.DisableMultiClassification.getKey()), Boolean.valueOf(PreferencePredicate.DisableMultiClassification.getDefaultValue().toString()));
947 957
		getPreferenceStore().setDefault(createPreferenceString(PreferencePredicate.ShowImportExportMenu.getKey()), Boolean.valueOf(PreferencePredicate.ShowImportExportMenu.getDefaultValue().toString()));
958
		getPreferenceStore().setDefault(createPreferenceString(PreferencePredicate.ShowSpecimen.getKey()), Boolean.valueOf(PreferencePredicate.ShowSpecimen.getDefaultValue().toString()));
948 959

  
949 960
	}
950 961

  
......
1492 1503
        }else{
1493 1504
            value = getStringValue(PreferencePredicate.NameDetailsView.getKey(), local);
1494 1505
        }
1495
        String [] sections = value.split(";");
1496
        Map<String, Boolean> sectionMap = new HashMap<String, Boolean>();
1497
        String[] sectionValues;
1498
        for (String sectionValue: sections){
1499
            sectionValues = sectionValue.split(":");
1500
            sectionMap.put(sectionValues[0], Boolean.valueOf(sectionValues[1]));
1501
        }
1502

  
1503
        config.setSimpleDetailsViewActivated(getValue(sectionMap, "simpleViewActivated"));
1504

  
1505
        config.setTaxonSectionActivated(getValue(sectionMap, "taxon"));
1506

  
1507
        config.setSecDetailsActivated(getValue(sectionMap, "taxon.SecDetails"));
1508
        config.setSecEnabled(getValue(sectionMap, "taxon.SecEnabled"));
1509

  
1510
        config.setLSIDActivated(getValue(sectionMap, "lsid"));
1511

  
1512
        config.setNomenclaturalCodeActived(getValue(sectionMap, "nc"));
1513

  
1514
        config.setAppendedPhraseActivated(getValue(sectionMap, "ap"));
1515

  
1516
        config.setRankActivated(getValue(sectionMap, "rank"));
1517

  
1518
        config.setAtomisedEpithetsActivated(getValue(sectionMap, "atomisedEpithets"));
1519

  
1520
        config.setAuthorshipSectionActivated(getValue(sectionMap,"author"));
1521

  
1522
        config.setNomenclaturalReferenceSectionActivated(sectionMap.get("nomRef"));
1523

  
1524
        config.setNomenclaturalStatusSectionActivated(getValue(sectionMap, "nomStat"));
1525

  
1526
        config.setProtologueActivated(getValue(sectionMap,"protologue"));
1527

  
1528
        config.setTypeDesignationSectionActivated(getValue(sectionMap,"typeDes"));
1529

  
1530
        config.setNameRelationsSectionActivated(getValue(sectionMap,"nameRelation"));
1531

  
1506
        if (value!= null){
1507
            String [] sections = value.split(";");
1508
            Map<String, Boolean> sectionMap = new HashMap<String, Boolean>();
1509
            String[] sectionValues;
1510
            for (String sectionValue: sections){
1511
                sectionValues = sectionValue.split(":");
1512
                sectionMap.put(sectionValues[0], Boolean.valueOf(sectionValues[1]));
1513
            }
1514
            config.setSimpleDetailsViewActivated(getValue(sectionMap, "simpleViewActivated"));
1515
            config.setTaxonSectionActivated(getValue(sectionMap, "taxon"));
1516
            config.setSecDetailsActivated(getValue(sectionMap, "taxon.SecDetails"));
1517
            config.setSecEnabled(getValue(sectionMap, "taxon.SecEnabled"));
1518
            config.setLSIDActivated(getValue(sectionMap, "lsid"));
1519
            config.setNomenclaturalCodeActived(getValue(sectionMap, "nc"));
1520
            config.setAppendedPhraseActivated(getValue(sectionMap, "ap"));
1521
            config.setRankActivated(getValue(sectionMap, "rank"));
1522
            config.setAtomisedEpithetsActivated(getValue(sectionMap, "atomisedEpithets"));
1523
            config.setAuthorshipSectionActivated(getValue(sectionMap,"author"));
1524
            config.setNomenclaturalReferenceSectionActivated(sectionMap.get("nomRef"));
1525
            config.setNomenclaturalStatusSectionActivated(getValue(sectionMap, "nomStat"));
1526
            config.setProtologueActivated(getValue(sectionMap,"protologue"));
1527
            config.setTypeDesignationSectionActivated(getValue(sectionMap,"typeDes"));
1528
            config.setNameRelationsSectionActivated(getValue(sectionMap,"nameRelation"));
1532 1529
            config.setHybridActivated(getValue(sectionMap,"hybrid"));
1533

  
1530
        }
1534 1531
        return config;
1535 1532
    }
1536 1533

  

Also available in: Unified diff