Project

General

Profile

Download (2.34 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
* Copyright (C) 2019 EDIT
3
* European Distributed Institute of Taxonomy
4
* http://www.e-taxonomy.eu
5
*
6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7
* See LICENSE.TXT at the top of this package for the full license terms.
8
*/
9
package eu.etaxonomy.taxeditor.databaseAdmin.preferencePage;
10

    
11
import java.util.ArrayList;
12
import java.util.List;
13
import java.util.UUID;
14

    
15
import org.apache.commons.lang3.StringUtils;
16

    
17
import eu.etaxonomy.cdm.model.metadata.CdmPreference;
18
import eu.etaxonomy.cdm.persistence.dto.TermDto;
19
import eu.etaxonomy.taxeditor.preference.LocalOrDefaultEnum;
20
import eu.etaxonomy.taxeditor.preference.NomenclaturalStatusTypePreferences;
21
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
22

    
23
/**
24
 * @author k.luther
25
 * @since 05.06.2019
26
 *
27
 */
28
public class NomenclaturalStatusTypeAdminPreference extends NomenclaturalStatusTypePreferences {
29

    
30

    
31
    public NomenclaturalStatusTypeAdminPreference(){
32
        super();
33
        isAdminPreference = true;
34
     }
35

    
36

    
37

    
38
    @Override
39
    public boolean performOk() {
40
        if (!isApply()){
41
            return true;
42
        }
43

    
44
        Object[] checkedElements = treeComposite.getViewer().getCheckedElements();
45

    
46
        List<UUID> listUIIDChecked = new ArrayList<>();
47
        //List<DefinedTermBase> preferredTerms = new ArrayList<>();
48
        for (Object o : checkedElements) {
49
            if(o instanceof TermDto){
50
                TermDto termDto = (TermDto) o;
51
                listUIIDChecked.add(termDto.getUuid());
52
                //preferredTerms.add(CdmStore.getService(ITermService.class).load(termDto.getUuid()));
53
            }
54
        }
55
        String saveCheckedElements = StringUtils.join(listUIIDChecked, ";"); //$NON-NLS-1$
56
        if (pref == null){
57
            saveCheckedElements = null;
58
        }
59
        CdmPreference savePref = CdmPreference.NewTaxEditorInstance(predicate, saveCheckedElements);
60
        String text = this.useLocalOrAdmin.getText();
61
        if (text.equals(LocalOrDefaultEnum.Database.getLabel()) ){
62
            savePref.setAllowOverride(false);
63
        }else if (text.equals(LocalOrDefaultEnum.AllowOverride.getLabel())){
64
            savePref.setAllowOverride(true);
65
        }
66

    
67
        PreferencesUtil.setPreferenceToDB(savePref);
68
        PreferencesUtil.updateDBPreferences();
69
        PreferencesUtil.firePreferencesChanged(this.getClass());
70
        return true;
71

    
72
    }
73
}
(21-21/29)