001/**
002 * Copyright 2005-2013 The Kuali Foundation
003 *
004 * Licensed under the Educational Community License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.opensource.org/licenses/ecl2.php
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016package org.kuali.rice.krms.dto;
017
018import org.kuali.rice.krad.web.form.UifFormBase;
019import org.kuali.rice.krms.api.repository.agenda.AgendaDefinition;
020import org.kuali.rice.krms.api.repository.agenda.AgendaDefinitionContract;
021
022import java.io.Serializable;
023import java.util.ArrayList;
024import java.util.List;
025import java.util.Map;
026
027/**
028 * @author Kuali Student Team
029 */
030public class AgendaEditor extends UifFormBase implements AgendaDefinitionContract, Serializable {
031
032    private String id;
033    private String name;
034    private String typeId;
035    private String contextId;
036    private boolean active = true;
037    private String firstItemId;
038    private Map<String, String> attributes;
039    private Long versionNumber;
040    private String courseName;
041
042    private AgendaTypeInfo agendaTypeInfo;
043    private Map<String, RuleEditor> ruleEditors;
044    private List<RuleEditor> deletedRules;
045
046    private AgendaEditor parent;
047
048    public AgendaEditor() {
049        super();
050    }
051
052    public AgendaEditor(AgendaDefinition definition) {
053        this.id = definition.getId();
054        this.name = definition.getName();
055        this.typeId = definition.getTypeId();
056        this.contextId = definition.getContextId();
057        this.active = definition.isActive();
058        this.firstItemId = definition.getFirstItemId();
059        this.attributes = definition.getAttributes();
060        this.versionNumber = definition.getVersionNumber();
061    }
062
063    public String getId() {
064        return id;
065    }
066
067    public void setId(String id) {
068        this.id = id;
069    }
070
071    public String getName() {
072        return name;
073    }
074
075    public void setName(String name) {
076        this.name = name;
077    }
078
079    public String getTypeId() {
080        return typeId;
081    }
082
083    public void setTypeId(String typeId) {
084        this.typeId = typeId;
085    }
086
087    public String getContextId() {
088        return contextId;
089    }
090
091    public void setContextId(String contextId) {
092        this.contextId = contextId;
093    }
094
095    public boolean isActive() {
096        return active;
097    }
098
099    public void setActive(boolean active) {
100        this.active = active;
101    }
102
103    public String getFirstItemId() {
104        return firstItemId;
105    }
106
107    public void setFirstItemId(String firstItemId) {
108        this.firstItemId = firstItemId;
109    }
110
111    public Map<String, String> getAttributes() {
112        return attributes;
113    }
114
115    public void setAttributes(Map<String, String> attributes) {
116        this.attributes = attributes;
117    }
118
119    public Long getVersionNumber() {
120        return versionNumber;
121    }
122
123    public void setVersionNumber(Long versionNumber) {
124        this.versionNumber = versionNumber;
125    }
126
127    public Map<String, RuleEditor> getRuleEditors() {
128        return ruleEditors;
129    }
130
131    public void setRuleEditors(Map<String, RuleEditor> ruleEditors) {
132        this.ruleEditors = ruleEditors;
133    }
134
135    public List<RuleEditor> getDeletedRules() {
136        if(this.deletedRules == null) {
137            return deletedRules = new ArrayList<RuleEditor>();
138        }
139        return deletedRules;
140    }
141
142    public void setDeletedRules(List<RuleEditor> deletedRules) {
143        this.deletedRules = deletedRules;
144    }
145
146    public String getCourseName() {
147        return courseName;
148    }
149
150    public void setCourseName(String courseName) {
151        this.courseName = courseName;
152    }
153
154    public AgendaTypeInfo getAgendaTypeInfo() {
155        return agendaTypeInfo;
156    }
157
158    public void setAgendaTypeInfo(AgendaTypeInfo agendaTypeInfo) {
159        this.agendaTypeInfo = agendaTypeInfo;
160    }
161
162    public AgendaEditor getParent() {
163        return parent;
164    }
165
166    public void setParent(AgendaEditor parent) {
167        this.parent = parent;
168    }
169
170    public boolean isDummyAgenda(){
171        if(this.getId()==null){
172            for(RuleEditor rule : this.getRuleEditors().values()){
173                if(rule.isDummy()==false){
174                    return false;
175                }
176            }
177            return true;
178        }
179        return false;
180    }
181
182}