| 1 | |
package org.kuali.student.enrollment.class2.acal.dto; |
| 2 | |
|
| 3 | |
import org.apache.commons.lang.StringUtils; |
| 4 | |
import org.kuali.student.enrollment.acal.constants.AcademicCalendarServiceConstants; |
| 5 | |
import org.kuali.student.enrollment.acal.dto.TermInfo; |
| 6 | |
import org.kuali.student.r2.common.dto.RichTextInfo; |
| 7 | |
import org.kuali.student.r2.common.util.constants.AtpServiceConstants; |
| 8 | |
import org.kuali.student.r2.core.type.dto.TypeInfo; |
| 9 | |
|
| 10 | |
import java.util.ArrayList; |
| 11 | |
import java.util.Date; |
| 12 | |
import java.util.List; |
| 13 | |
|
| 14 | |
public class AcademicTermWrapper { |
| 15 | |
|
| 16 | |
private static final long serialVersionUID = 4898118410378641665L; |
| 17 | |
|
| 18 | |
private TermInfo termInfo; |
| 19 | |
|
| 20 | |
private String name; |
| 21 | |
private int instructionalDays; |
| 22 | |
private String termType; |
| 23 | |
private Date startDate; |
| 24 | |
private Date endDate; |
| 25 | |
|
| 26 | |
private String termNameForUI; |
| 27 | |
private List<KeyDatesGroupWrapper> keyDatesGroupWrappers; |
| 28 | |
|
| 29 | |
private TypeInfo typeInfo; |
| 30 | |
|
| 31 | |
private List<KeyDateWrapper> keyDatesToDeleteOnSave; |
| 32 | |
|
| 33 | |
private boolean isOfficial; |
| 34 | |
private boolean isAlreadySaved; |
| 35 | |
|
| 36 | |
|
| 37 | 0 | public AcademicTermWrapper(){ |
| 38 | 0 | keyDatesGroupWrappers = new ArrayList(); |
| 39 | 0 | keyDatesToDeleteOnSave = new ArrayList<KeyDateWrapper>(); |
| 40 | 0 | termInfo = new TermInfo(); |
| 41 | 0 | termInfo.setStateKey(AtpServiceConstants.ATP_DRAFT_STATE_KEY); |
| 42 | 0 | RichTextInfo desc = new RichTextInfo(); |
| 43 | 0 | desc.setPlain("Test"); |
| 44 | 0 | termInfo.setDescr(desc); |
| 45 | |
|
| 46 | 0 | } |
| 47 | |
|
| 48 | 0 | public AcademicTermWrapper(TermInfo termInfo,boolean isCopy){ |
| 49 | 0 | this.startDate = termInfo.getStartDate(); |
| 50 | 0 | this.endDate = termInfo.getEndDate(); |
| 51 | 0 | this.termType = termInfo.getTypeKey(); |
| 52 | 0 | this.keyDatesGroupWrappers = new ArrayList(); |
| 53 | 0 | this.keyDatesToDeleteOnSave = new ArrayList<KeyDateWrapper>(); |
| 54 | |
|
| 55 | 0 | if (isCopy){ |
| 56 | 0 | setTermInfo(new TermInfo()); |
| 57 | 0 | RichTextInfo desc = new RichTextInfo(); |
| 58 | 0 | desc.setPlain(termInfo.getTypeKey()); |
| 59 | 0 | getTermInfo().setDescr(desc); |
| 60 | 0 | getTermInfo().setStateKey(AtpServiceConstants.ATP_DRAFT_STATE_KEY); |
| 61 | 0 | } else{ |
| 62 | 0 | setTermInfo(termInfo); |
| 63 | 0 | this.name = termInfo.getName(); |
| 64 | |
} |
| 65 | |
|
| 66 | 0 | } |
| 67 | |
|
| 68 | |
public String getName() { |
| 69 | 0 | return name; |
| 70 | |
} |
| 71 | |
|
| 72 | |
public void setName(String name) { |
| 73 | 0 | this.name = name; |
| 74 | 0 | } |
| 75 | |
|
| 76 | |
public String getTermType() { |
| 77 | 0 | return termType; |
| 78 | |
} |
| 79 | |
|
| 80 | |
public void setTermType(String termType) { |
| 81 | 0 | this.termType = termType; |
| 82 | 0 | } |
| 83 | |
|
| 84 | |
public Date getStartDate() { |
| 85 | 0 | return startDate; |
| 86 | |
} |
| 87 | |
|
| 88 | |
public void setStartDate(Date startDate) { |
| 89 | 0 | this.startDate = startDate; |
| 90 | 0 | } |
| 91 | |
|
| 92 | |
public Date getEndDate() { |
| 93 | 0 | return endDate; |
| 94 | |
} |
| 95 | |
|
| 96 | |
public void setEndDate(Date endDate) { |
| 97 | 0 | this.endDate = endDate; |
| 98 | 0 | } |
| 99 | |
|
| 100 | |
public TermInfo getTermInfo() { |
| 101 | 0 | return termInfo; |
| 102 | |
} |
| 103 | |
|
| 104 | |
public void setTermInfo(TermInfo termInfo) { |
| 105 | 0 | this.termInfo = termInfo; |
| 106 | 0 | } |
| 107 | |
|
| 108 | |
public int getInstructionalDays() { |
| 109 | 0 | return instructionalDays; |
| 110 | |
} |
| 111 | |
|
| 112 | |
public void setInstructionalDays(int instructionalDays) { |
| 113 | 0 | this.instructionalDays = instructionalDays; |
| 114 | 0 | } |
| 115 | |
|
| 116 | |
public String getTermNameForUI() { |
| 117 | 0 | return termNameForUI; |
| 118 | |
} |
| 119 | |
|
| 120 | |
public void setTermNameForUI(String termNameForUI) { |
| 121 | 0 | this.termNameForUI = termNameForUI; |
| 122 | 0 | } |
| 123 | |
|
| 124 | |
public List<KeyDatesGroupWrapper> getKeyDatesGroupWrappers() { |
| 125 | 0 | return keyDatesGroupWrappers; |
| 126 | |
} |
| 127 | |
|
| 128 | |
public void setKeyDatesGroupWrappers(List<KeyDatesGroupWrapper> keyDatesGroupWrappers) { |
| 129 | 0 | this.keyDatesGroupWrappers = keyDatesGroupWrappers; |
| 130 | 0 | } |
| 131 | |
|
| 132 | |
public List<KeyDateWrapper> getKeyDatesToDeleteOnSave() { |
| 133 | 0 | return keyDatesToDeleteOnSave; |
| 134 | |
} |
| 135 | |
|
| 136 | |
public void setKeyDatesToDeleteOnSave(List<KeyDateWrapper> keyDatesToDeleteOnSave) { |
| 137 | 0 | this.keyDatesToDeleteOnSave = keyDatesToDeleteOnSave; |
| 138 | 0 | } |
| 139 | |
|
| 140 | |
public void clear(){ |
| 141 | 0 | setEndDate(null); |
| 142 | 0 | setStartDate(null); |
| 143 | 0 | setTermType(null); |
| 144 | 0 | setName(null); |
| 145 | 0 | setTypeInfo(null); |
| 146 | 0 | keyDatesToDeleteOnSave.clear(); |
| 147 | 0 | } |
| 148 | |
|
| 149 | |
public TypeInfo getTypeInfo() { |
| 150 | 0 | return typeInfo; |
| 151 | |
} |
| 152 | |
|
| 153 | |
public void setTypeInfo(TypeInfo typeInfo) { |
| 154 | 0 | this.typeInfo = typeInfo; |
| 155 | 0 | } |
| 156 | |
|
| 157 | |
public boolean isOfficial() { |
| 158 | 0 | return StringUtils.equals(termInfo.getStateKey(), AcademicCalendarServiceConstants.TERM_OFFICIAL_STATE_KEY); |
| 159 | |
} |
| 160 | |
|
| 161 | |
public boolean isNew() { |
| 162 | 0 | return StringUtils.isBlank(termInfo.getId()); |
| 163 | |
} |
| 164 | |
|
| 165 | |
public boolean isKeyDateGroupExists(String keydateGroupTypeKey){ |
| 166 | 0 | for(KeyDatesGroupWrapper wrapper : keyDatesGroupWrappers){ |
| 167 | 0 | if (StringUtils.equalsIgnoreCase(wrapper.getKeyDateGroupType(),keydateGroupTypeKey)){ |
| 168 | 0 | return true; |
| 169 | |
} |
| 170 | |
} |
| 171 | 0 | return false; |
| 172 | |
} |
| 173 | |
|
| 174 | |
} |