001/**
002 * Copyright 2012 The Kuali Foundation Licensed under the
003 * Educational Community License, Version 2.0 (the "License"); you may
004 * not use this file except in compliance with the License. You may
005 * obtain a copy of the License at
006 *
007 * http://www.osedu.org/licenses/ECL-2.0
008 *
009 * Unless required by applicable law or agreed to in writing,
010 * software distributed under the License is distributed on an "AS IS"
011 * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
012 * or implied. See the License for the specific language governing
013 * permissions and limitations under the License.
014 *
015 */
016package org.kuali.student.enrollment.class2.acal.dto;
017
018import org.apache.commons.lang.StringUtils;
019import org.kuali.student.r2.core.acal.dto.KeyDateInfo;
020import org.kuali.student.r2.common.dto.RichTextInfo;
021import org.kuali.student.r2.core.class1.type.dto.TypeInfo;
022import org.kuali.student.r2.core.constants.AtpServiceConstants;
023
024/**
025 * Wrapper class for <code>KeyDateInfo</code> dto.
026 *
027 * @author Kuali Student Team
028 */
029public class KeyDateWrapper extends TimeSetWrapper{
030
031    private String keyDateType;
032    private String keyDateNameUI;
033
034    private KeyDateInfo keyDateInfo;
035    private TypeInfo typeInfo;
036
037    public KeyDateWrapper(){
038        setAllDay(true);
039        setDateRange(false);
040        keyDateInfo = new KeyDateInfo();
041        keyDateInfo.setStateKey(AtpServiceConstants.MILESTONE_DRAFT_STATE_KEY);
042        RichTextInfo desc = new RichTextInfo();
043        desc.setPlain("test");
044        keyDateInfo.setDescr(desc);
045    }
046
047    public KeyDateWrapper(KeyDateInfo keydate,boolean isCopy){
048
049        this.setKeyDateType(keydate.getTypeKey());
050
051        if (isCopy){
052            this.setKeyDateInfo(new KeyDateInfo());
053            RichTextInfo desc = new RichTextInfo();
054            desc.setPlain(keydate.getTypeKey());
055            getKeyDateInfo().setDescr(desc);
056            getKeyDateInfo().setStateKey(AtpServiceConstants.MILESTONE_DRAFT_STATE_KEY);
057        }else{
058            this.setStartDate(keydate.getStartDate());
059            this.setEndDate(keydate.getEndDate());
060            this.setAllDay(keydate.getIsAllDay());
061            this.setDateRange(keydate.getIsDateRange());
062            this.setKeyDateInfo(keydate);
063            buildDateAndTime();        // don't do this when copying
064        }
065
066    }
067
068    public String getKeyDateType() {
069        return keyDateType;
070    }
071
072    public void setKeyDateType(String keyDateType) {
073        this.keyDateType = keyDateType;
074    }
075
076    public KeyDateInfo getKeyDateInfo() {
077        return keyDateInfo;
078    }
079
080    public void setKeyDateInfo(KeyDateInfo keyDateInfo) {
081        this.keyDateInfo = keyDateInfo;
082    }
083
084    public String getKeyDateNameUI() {
085        return keyDateNameUI;
086    }
087
088    public void setKeyDateNameUI(String keyDateNameUI) {
089        this.keyDateNameUI = keyDateNameUI;
090    }
091
092    public TypeInfo getTypeInfo() {
093        return typeInfo;
094    }
095
096    public void setTypeInfo(TypeInfo typeInfo) {
097        this.typeInfo = typeInfo;
098    }
099
100    public boolean isNew() {
101        return StringUtils.isBlank(keyDateInfo.getId());
102    }
103
104    //This is for UI display purpose
105    public String getStartDateUI(){
106        return formatStartDateUI(keyDateInfo.getStartDate());
107    }
108
109    //This is for UI display purpose
110    public String getEndDateUI(){
111        return formatEndDateUI(keyDateInfo.getEndDate());
112    }
113}