Project

General

Profile

Revision ca8969f2

IDca8969f2b82d9ca3366a4d73bf4ec252f9f87e9e
Parent c47fd6c0
Child 4d18f3c4

Added by Andreas Müller 8 months ago

ref #7901 implement IPreferencePredicate in CdmPreference and service layer

View differences:

cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/metadata/CdmPreference.java
56 56
    private static final long serialVersionUID = 4307599154287181582L;
57 57

  
58 58
    public static final CdmPreference NewInstance(PreferenceSubject subject,
59
            PreferencePredicate predicate, String value){
59
            IPreferencePredicate predicate, String value){
60 60
        return new CdmPreference(subject, predicate, value);
61 61
    }
62 62

  
63 63

  
64
    public static final CdmPreference NewInstance(PreferenceSubject subject, PreferencePredicate predicate, List<UUID> value){
64
    public static final CdmPreference NewInstance(PreferenceSubject subject, IPreferencePredicate predicate, List<UUID> value){
65 65
        return new CdmPreference(subject, predicate, uuidListStr(value));
66 66
    }
67
    public static final CdmPreference NewInstance(PreferenceSubject subject, PreferencePredicate predicate, UUID ... value){
67
    public static final CdmPreference NewInstance(PreferenceSubject subject, IPreferencePredicate predicate, UUID ... value){
68 68
        return new CdmPreference(subject, predicate, uuidListStr(Arrays.asList(value)));
69 69
    }
70 70

  
71
    public static final CdmPreference NewInstance(PreferenceSubject subject, PreferencePredicate predicate, UUID value){
71
    public static final CdmPreference NewInstance(PreferenceSubject subject, IPreferencePredicate predicate, UUID value){
72 72
        return new CdmPreference(subject, predicate, value.toString());
73 73
    }
74 74

  
......
77 77
     * @param value
78 78
     * @return
79 79
     */
80
    public static CdmPreference NewDatabaseInstance(PreferencePredicate predicate, String value) {
80
    public static CdmPreference NewDatabaseInstance(IPreferencePredicate predicate, String value) {
81 81
        return new CdmPreference(PreferenceSubject.NewDatabaseInstance(), predicate, value);
82 82
    }
83 83

  
......
86 86
     * @param value
87 87
     * @return
88 88
     */
89
    public static CdmPreference NewVaadinInstance(PreferencePredicate predicate, String value) {
89
    public static CdmPreference NewVaadinInstance(IPreferencePredicate predicate, String value) {
90 90
        return new CdmPreference(PreferenceSubject.NewVaadinInstance(), predicate, value);
91 91
    }
92 92

  
......
95 95
     * @param value
96 96
     * @return
97 97
     */
98
    public static CdmPreference NewTaxEditorInstance(PreferencePredicate predicate, String value) {
98
    public static CdmPreference NewTaxEditorInstance(IPreferencePredicate predicate, String value) {
99 99
        return new CdmPreference(PreferenceSubject.NewTaxEditorInstance(), predicate, value);
100 100
    }
101 101

  
102
    public static PrefKey NewKey(PreferenceSubject subject, PreferencePredicate predicate){
102
    public static PrefKey NewKey(PreferenceSubject subject, IPreferencePredicate predicate){
103 103
      return new PrefKey(subject, predicate);
104 104
    }
105 105

  
......
139 139
        //for hibernate use only
140 140
        private PrefKey(){}
141 141

  
142
        private PrefKey(PreferenceSubject subject, PreferencePredicate predicate){
142
        private PrefKey(PreferenceSubject subject, IPreferencePredicate predicate){
143 143
            this(subject.toString(), predicate.getKey());
144 144
        }
145 145
//      private PrefKey(PreferenceSubjectEnum subject, PreferencePredicate predicate){
......
159 159
            if (predicate.length() > 255) {
160 160
                throw new IllegalArgumentException("Predicate must not be longer then 255 for preference");
161 161
            }
162
            if (!(subject.matches(PreferenceSubject.ROOT + "(([A-Za-z]+\\[.*\\]|"+PreferenceSubject.VAADIN+")"+PreferenceSubject.SEP+")?") || subject.matches(PreferenceSubject.ROOT + "(([A-Za-z]+\\[.*\\]|"+PreferenceSubject.TAX_EDITOR+")"+PreferenceSubject.SEP+")?"))){
162
            if (!(subject.matches(PreferenceSubject.ROOT + "(([A-Za-z]+\\[.*\\]|"+PreferenceSubject.VAADIN+")"+PreferenceSubject.SEP+")?")
163
                    || subject.matches(PreferenceSubject.ROOT + "(([A-Za-z]+\\[.*\\]|"+PreferenceSubject.TAX_EDITOR+")"+PreferenceSubject.SEP+")?"))){
163 164
                throw new IllegalArgumentException("Subject does not follow the required syntax");
164 165
            }
165 166

  
......
209 210
	private CdmPreference(){}
210 211

  
211 212

  
212
	private CdmPreference(PreferenceSubject subject, PreferencePredicate predicate, String value){
213
	private CdmPreference(PreferenceSubject subject, IPreferencePredicate predicate, String value){
213 214
		this.key = new PrefKey(subject, predicate);
214 215
		//TODO are null values allowed?		assert predicate != null : "value must not be null for preference";
215 216
		if (value != null && value.length() > 1023) {throw new IllegalArgumentException(
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/IPreferenceService.java
13 13
import eu.etaxonomy.cdm.model.common.CdmBase;
14 14
import eu.etaxonomy.cdm.model.metadata.CdmPreference;
15 15
import eu.etaxonomy.cdm.model.metadata.CdmPreference.PrefKey;
16
import eu.etaxonomy.cdm.model.metadata.PreferencePredicate;
16
import eu.etaxonomy.cdm.model.metadata.IPreferencePredicate;
17 17
import eu.etaxonomy.cdm.model.metadata.PreferenceSubject;
18 18
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
19 19

  
......
85 85
      * @param predicate
86 86
      * @return
87 87
      */
88
     public CdmPreference findDatabase(PreferencePredicate predicate);
88
     public CdmPreference findDatabase(IPreferencePredicate predicate);
89 89

  
90 90
     /**
91 91
      * Retrieve the vaadin wide preference for the given predicate.
92 92
      * @param predicate
93 93
      * @return
94 94
      */
95
     public CdmPreference findVaadin(PreferencePredicate predicate);
95
     public CdmPreference findVaadin(IPreferencePredicate predicate);
96 96

  
97 97

  
98 98
     /**
......
100 100
      * @param predicate
101 101
      * @return
102 102
      */
103
     public CdmPreference findTaxEditor(PreferencePredicate predicate);
103
     public CdmPreference findTaxEditor(IPreferencePredicate predicate);
104 104

  
105 105
     /**
106 106
      * Returns the best matching preference that matches the given
......
112 112
      */
113 113
     public Object find(TaxonNode taxonNode, String predicate);
114 114

  
115
     public CdmPreference find(TaxonNode taxonNode, PreferencePredicate predicate);
115
     public CdmPreference find(TaxonNode taxonNode, IPreferencePredicate predicate);
116 116

  
117 117
     /**
118 118
      * Returns the best matching preference that matches the given
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/PreferenceServiceImpl.java
20 20
import eu.etaxonomy.cdm.model.common.CdmBase;
21 21
import eu.etaxonomy.cdm.model.metadata.CdmPreference;
22 22
import eu.etaxonomy.cdm.model.metadata.CdmPreference.PrefKey;
23
import eu.etaxonomy.cdm.model.metadata.PreferencePredicate;
23
import eu.etaxonomy.cdm.model.metadata.IPreferencePredicate;
24 24
import eu.etaxonomy.cdm.model.metadata.PreferenceSubject;
25 25
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
26 26
import eu.etaxonomy.cdm.persistence.dao.common.IPreferenceDao;
......
52 52
     * {@inheritDoc}
53 53
     */
54 54
    @Override
55
    public CdmPreference findDatabase(PreferencePredicate predicate){
55
    public CdmPreference findDatabase(IPreferencePredicate predicate){
56 56
        PrefKey key = CdmPreference.NewKey(PreferenceSubject.NewDatabaseInstance(), predicate);
57 57
        return find(key);
58 58
    }
......
61 61
     * {@inheritDoc}
62 62
     */
63 63
    @Override
64
    public CdmPreference findVaadin(PreferencePredicate predicate){
64
    public CdmPreference findVaadin(IPreferencePredicate predicate){
65 65
        PrefKey key = CdmPreference.NewKey(PreferenceSubject.NewVaadinInstance(), predicate);
66 66
        return find(key);
67 67
    }
68 68

  
69 69
    @Override
70
    public CdmPreference findTaxEditor(PreferencePredicate predicate){
70
    public CdmPreference findTaxEditor(IPreferencePredicate predicate){
71 71
        PrefKey key = CdmPreference.NewKey(PreferenceSubject.NewTaxEditorInstance(), predicate);
72 72
        return find(key);
73 73
    }
......
95 95
    }
96 96

  
97 97
    @Override
98
    public CdmPreference find(TaxonNode taxonNode, PreferencePredicate predicate){
98
    public CdmPreference find(TaxonNode taxonNode, IPreferencePredicate predicate){
99 99
        return dao.find(taxonNode, predicate.getKey());
100 100
    }
101 101

  

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)