Project

General

Profile

« Previous | Next » 

Revision 56493

refactoring

View differences:

Constraints.java
57 57

  
58 58
    }
59 59

  
60
//    //Constraint in and
61
//    public boolean verifyCriteria(Map<String,String> param){
62
//        for(Constraint constraint: constraint){
63
//            if(!constraint.verifyCriteria(param.get(constraint.getField())))
64
//                return false;
65
//        }
66
//        return true;
67
//    }
68 60

  
69 61
    //Constraint in and
70
    public boolean verifyCriteria(Map<String,List<String>> param){
62
    public boolean verifyCriteria(final Map<String, List<String>> param) {
71 63

  
72
        for(Constraint sc: constraint){
64
        for(Constraint sc : constraint) {
73 65
            boolean verified = false;
74 66
            for(String value : param.get(sc.getField())){
75 67
                if (sc.verifyCriteria(value.trim())){
......
81 73
        }
82 74
        return true;
83 75
    }
84
  /*  public ConstraintEncapsulator getCe() {
85
        return ce;
86
    }
87 76

  
88
    public void setCe(ConstraintEncapsulator ce) {
89
        this.ce = ce;
90
    }
91

  
92
    public void setConstraint(String json){
93

  
94
        ce = new Gson().fromJson(json, ConstraintEncapsulator.class);
95

  
96
    }
97

  
98
    void setSelection(VerbResolver resolver) {
99
        for(Constraint st: ce.getConstraint()){
100

  
101
            try {
102
                st.setSelection(resolver);
103
            } catch (NoSuchMethodException e) {
104
                log.error(e.getMessage());
105
            } catch (IllegalAccessException e) {
106
                log.error(e.getMessage());
107
            } catch (InvocationTargetException e) {
108
                log.error(e.getMessage());
109
            } catch (InstantiationException e) {
110
                log.error(e.getMessage());
111
            }
112
        }
113

  
114
    }
115

  
116
//    //Constraint in and
117
//    public boolean verifyCriteria(Map<String,String> param){
118
//        for(Constraint ce: ce){
119
//            if(!ce.verifyCriteria(param.get(ce.getField())))
120
//                return false;
121
//        }
122
//        return true;
123
//    }
124

  
125
    //Constraint in and
126
    public boolean verifyCriteria(Map<String,List<String>> param) throws NullPointerException {
127
        for(Constraint constraint: ce.getConstraint()){
128
            boolean verified = false;
129
            for(String value : param.get(constraint.getField())){
130
                try {
131
                    if (constraint.verifyCriteria(value.trim())) {
132
                        verified = true;
133
                    }
134
                }catch(NullPointerException npe){
135
                    log.info(new Gson().toJson(this));
136
                    throw new NullPointerException();
137

  
138
                }
139
            }
140
            if(!verified)
141
                return verified;
142
        }
143
        return true;
144
    }*/
145 77
}

Also available in: Unified diff