View Javadoc

1   /**
2    * Copyright 2005-2013 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.kuali.student.core.krms.builder;
17  
18  import org.kuali.rice.krms.builder.ComponentBuilder;
19  import org.kuali.student.core.krms.dto.KSPropositionEditor;
20  import org.kuali.student.r2.core.constants.KSKRMSServiceConstants;
21  
22  import java.util.HashMap;
23  import java.util.List;
24  import java.util.Map;
25  
26  /**
27   * @author Kuali Student Team
28   */
29  public class DurationComponentBuilder implements ComponentBuilder<KSPropositionEditor> {
30  
31      @Override
32      public List<String> getComponentIds() {
33          return null;  //To change body of implemented methods use File | Settings | File Templates.
34      }
35  
36      @Override
37      public void resolveTermParameters(KSPropositionEditor propositionEditor, Map<String, String> termParameters) {
38          String durationType = termParameters.get(KSKRMSServiceConstants.TERM_PARAMETER_TYPE_DURATION_TYPE_KEY);
39          String duration = termParameters.get(KSKRMSServiceConstants.TERM_PARAMETER_TYPE_DURATION_KEY);
40          if (durationType != null) {
41          propositionEditor.setDurationType(durationType);
42          }
43          if (duration != null) {
44              propositionEditor.setDuration(Integer.parseInt(duration));
45          }
46  
47      }
48  
49      @Override
50      public Map<String, String> buildTermParameters(KSPropositionEditor propositionEditor) {
51          Map<String, String> termParameters = new HashMap<String, String>();
52              termParameters.put(KSKRMSServiceConstants.TERM_PARAMETER_TYPE_DURATION_TYPE_KEY, propositionEditor.getDurationType());
53              termParameters.put(KSKRMSServiceConstants.TERM_PARAMETER_TYPE_DURATION_KEY, propositionEditor.getDuration().toString());
54  
55          return termParameters;
56      }
57  
58      @Override
59      public void onSubmit(KSPropositionEditor propositionEditor) {
60          //To change body of implemented methods use File | Settings | File Templates.
61      }
62  
63      @Override
64      public void validate(KSPropositionEditor propositionEditor) {
65          //To change body of implemented methods use File | Settings | File Templates.
66      }
67  
68  }