Project

General

Profile

Revision 4ffaaf10

ID4ffaaf10cfeafcac751c28960df3624dbc27dac4
Parent 55563baa
Child 160717a9

Added by Katja Luther about 2 years ago

avoid NPE in getLastSelectedReferences

View differences:

eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/preference/IPreferenceKeys.java
141 141
    public static final String DISTRIBUTION_AREA_OCCURENCE_STATUS = "eu.etaxonomy.taxeditor.checklist.distributionAreaStatus";
142 142

  
143 143
    public static final String DISTRIBUTION_AREA_OCCURENCE_STATUS_GRAYED = "eu.etaxonomy.taxeditor.checklist.distributionAreaStatusGrayed";
144
    public static final String DISTRIBUTION_VOCABULARIES = "eu.etaxonomy.taxeditor.checklist.distributionVocabularies";
144 145

  
145 146
    public static final String CHECKLIST_ID_IN_VOCABULARY = "eu.etaxonomy.taxeditor.checklist.checklistIdInVocabulary";
146 147
    public static final String CHECKLIST_SYMBOL = "eu.etaxonomy.taxeditor.checklist.checklistSymbol";
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/preference/PreferencesUtil.java
90 90

  
91 91
	private final static Logger logger = Logger.getLogger(PreferencesUtil.class);
92 92

  
93

  
94

  
93 95
	/**
94 96
	 * <p>
95 97
	 * getPreferenceStore
......
1391 1393
        IPreferenceStore preferenceStore = PreferencesUtil.getPreferenceStore();
1392 1394
        String lastSelected = preferenceStore.getString(PreferencesUtil.LAST_SELECTED_REFERENCES);
1393 1395
        List<String> result = new ArrayList<>();
1394
        Collections.addAll(result, lastSelected.substring(1,lastSelected.length()-1).split(", "));
1396
        if (!StringUtils.isBlank(lastSelected)){
1397
            Collections.addAll(result, lastSelected.substring(1,lastSelected.length()-1).split(", "));
1398
        }
1395 1399
        return result;
1396 1400
    }
1397 1401

  
......
1404 1408
 * @param saveCheckedElements
1405 1409
 * @param saveGrayedElements
1406 1410
 */
1407
public static CdmPreference setPreferredNamedAreasForDistributionEditor(
1411
public static void setPreferredNamedAreasForDistributionEditor(
1408 1412
        String saveCheckedElements, String saveGrayedElements, boolean local) {
1409 1413
    if (local){
1410 1414
        IPreferenceStore preferenceStore = PreferencesUtil.getPreferenceStore();
......
1413 1417

  
1414 1418
    }
1415 1419
    else{
1416
        ICdmRepository controller;
1420
//        ICdmRepository controller;
1417 1421

  
1418 1422
//        PrefKey key = CdmPreference.NewKey(PreferenceSubject.NewDatabaseInstance(), PreferencePredicate.AvailableDistributionAreaTerms);
1419 1423
        CdmPreference preference = null;
1420 1424

  
1421 1425
        if (saveCheckedElements == null){
1422 1426
            preference = getPreferenceFromDB(PreferencePredicate.AvailableDistributionAreaTerms);
1423
//            preference = controller.getPreferenceService().find(key);
1427

  
1424 1428
            if (preference == null){
1425
                return null;
1429
                return ;
1426 1430
            } else{
1427
                String[] uuids = StringUtils.splitByWholeSeparator(saveCheckedElements, ",");
1428
                List<UUID> uuidList = new ArrayList();
1429
                for (String uuidString: uuids){
1430
                    uuidList.add(UUID.fromString(uuidString.trim()));
1431
                }
1432 1431
                getPreferenceStore().setValue(DISTRIBUTION_AREA_OCCURENCE_STATUS,
1433 1432
                        saveCheckedElements);
1433
                preference = CdmPreference.NewInstance(PreferenceSubject.NewDatabaseInstance(), PreferencePredicate.AvailableDistributionAreaTerms, saveCheckedElements);
1434
                setPreferenceToDB(preference);
1434 1435

  
1435
                return preference;
1436 1436
            }
1437 1437
        } else{
1438
            controller = CdmStore.getCurrentApplicationConfiguration();
1439
            preference = CdmPreference.NewInstance(PreferenceSubject.NewDatabaseInstance(), PreferencePredicate.AvailableDistributionAreaTerms, saveCheckedElements);
1440
            controller.getPreferenceService().set(preference);
1438
           preference = CdmPreference.NewInstance(PreferenceSubject.NewDatabaseInstance(), PreferencePredicate.AvailableDistributionAreaTerms, saveCheckedElements);
1439
           setPreferenceToDB(preference);
1440
           getPreferenceStore().setValue(DISTRIBUTION_AREA_OCCURENCE_STATUS,
1441
                    saveCheckedElements);
1442

  
1443
        }
1444
    }
1445

  
1446
}
1447

  
1448
/**
1449
 * @param saveCheckedElements
1450
 * @param saveCheckedElements2
1451
 * @param b
1452
 */
1453
public static void setPreferredVocabulariesForDistributionEditor(String saveCheckedElements,
1454
        boolean local) {
1455
    if (local){
1456
        IPreferenceStore preferenceStore = PreferencesUtil.getPreferenceStore();
1457
        preferenceStore.setValue(PreferencesUtil.DISTRIBUTION_VOCABULARIES, saveCheckedElements);
1458

  
1459

  
1460
    }
1461
    else{
1462
        ICdmRepository controller;
1463
        CdmPreference preference = null;
1464

  
1465
        if (saveCheckedElements == null){
1466
            preference = getPreferenceFromDB(PreferencePredicate.AvailableDistributionAreaVocabularies);
1467

  
1468
            if (preference == null){
1469
                return ;
1470
            } else{
1471
                getPreferenceStore().setValue(DISTRIBUTION_VOCABULARIES,
1472
                        saveCheckedElements);
1473
                preference = CdmPreference.NewInstance(PreferenceSubject.NewDatabaseInstance(), PreferencePredicate.AvailableDistributionAreaVocabularies, saveCheckedElements);
1474
                setPreferenceToDB(preference);
1475

  
1476

  
1477
            }
1478
        } else{
1479
            preference = CdmPreference.NewInstance(PreferenceSubject.NewDatabaseInstance(), PreferencePredicate.AvailableDistributionAreaVocabularies, saveCheckedElements);
1480
            setPreferenceToDB(preference);
1441 1481
            getPreferenceStore().setValue(DISTRIBUTION_AREA_OCCURENCE_STATUS,
1442 1482
                    saveCheckedElements);
1443 1483

  
1444 1484
        }
1445 1485
    }
1446
    return null;
1447 1486

  
1448 1487

  
1449 1488

  

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)