| 1 | |
package org.kuali.student.r2.core.process.model; |
| 2 | |
|
| 3 | |
import org.kuali.student.r2.common.dto.AttributeInfo; |
| 4 | |
import org.kuali.student.r2.common.entity.AttributeOwner; |
| 5 | |
import org.kuali.student.r2.common.entity.MetaEntity; |
| 6 | |
import org.kuali.student.r2.common.infc.Attribute; |
| 7 | |
import org.kuali.student.r2.core.class1.state.model.StateEntity; |
| 8 | |
import org.kuali.student.r2.core.process.dto.CheckInfo; |
| 9 | |
import org.kuali.student.r2.core.process.infc.Check; |
| 10 | |
|
| 11 | |
import javax.persistence.CascadeType; |
| 12 | |
import javax.persistence.Column; |
| 13 | |
import javax.persistence.Entity; |
| 14 | |
import javax.persistence.JoinColumn; |
| 15 | |
import javax.persistence.ManyToOne; |
| 16 | |
import javax.persistence.OneToMany; |
| 17 | |
import javax.persistence.Table; |
| 18 | |
import java.util.ArrayList; |
| 19 | |
import java.util.List; |
| 20 | |
|
| 21 | |
@Entity |
| 22 | |
@Table(name = "KSEN_CHECK") |
| 23 | |
public class CheckEntity extends MetaEntity implements AttributeOwner<CheckAttributeEntity>{ |
| 24 | |
|
| 25 | |
|
| 26 | |
@Column(name = "NAME") |
| 27 | |
private String name; |
| 28 | |
|
| 29 | |
|
| 30 | |
@ManyToOne(cascade = CascadeType.ALL) |
| 31 | |
@JoinColumn(name = "RT_DESCR_ID") |
| 32 | |
private CheckRichTextEntity descr; |
| 33 | |
|
| 34 | |
|
| 35 | |
@ManyToOne(optional=false) |
| 36 | |
@JoinColumn(name = "STATE_ID") |
| 37 | |
private StateEntity checkState; |
| 38 | |
|
| 39 | |
|
| 40 | |
@ManyToOne(optional=false) |
| 41 | |
@JoinColumn(name = "TYPE_ID") |
| 42 | |
private CheckTypeEntity checkType; |
| 43 | |
|
| 44 | |
@Column(name = "ISSUE_ID") |
| 45 | |
private String issueId; |
| 46 | |
|
| 47 | |
@Column(name = "MILESTONE_TYPE_ID") |
| 48 | |
private String milestoneTypeId; |
| 49 | |
|
| 50 | |
@ManyToOne(optional=true) |
| 51 | |
@JoinColumn(name = "PROCESS_ID") |
| 52 | |
private ProcessEntity process; |
| 53 | |
|
| 54 | |
@Column(name = "AGENDA_ID") |
| 55 | |
private String agendaId; |
| 56 | |
|
| 57 | |
@OneToMany(cascade = CascadeType.ALL, mappedBy = "owner") |
| 58 | |
private List<CheckAttributeEntity> attributes; |
| 59 | |
|
| 60 | |
@Override |
| 61 | |
public void setAttributes(List<CheckAttributeEntity> attributes) { |
| 62 | 0 | this.attributes = attributes; |
| 63 | 0 | } |
| 64 | |
|
| 65 | 0 | public CheckEntity() {} |
| 66 | |
public CheckEntity(Check check){ |
| 67 | 0 | super(check); |
| 68 | 0 | this.setId(check.getKey()); |
| 69 | 0 | this.setName(check.getName()); |
| 70 | 0 | if(check.getDescr() != null) { |
| 71 | 0 | this.setDescr(new CheckRichTextEntity(check.getDescr())); |
| 72 | |
} |
| 73 | |
|
| 74 | 0 | this.setAttributes(new ArrayList<CheckAttributeEntity>()); |
| 75 | 0 | if (null != check.getAttributes()) { |
| 76 | 0 | for (Attribute att : check.getAttributes()) { |
| 77 | 0 | CheckAttributeEntity attEntity = new CheckAttributeEntity(att); |
| 78 | 0 | this.getAttributes().add(attEntity); |
| 79 | 0 | } |
| 80 | |
} |
| 81 | |
|
| 82 | 0 | this.setIssueId(check.getIssueKey()); |
| 83 | 0 | this.setMilestoneTypeId(check.getMilestoneTypeKey()); |
| 84 | 0 | this.setAgendaId(check.getAgendaId()); |
| 85 | 0 | } |
| 86 | |
|
| 87 | |
|
| 88 | |
|
| 89 | |
|
| 90 | |
public CheckInfo toDto(){ |
| 91 | 0 | CheckInfo obj = new CheckInfo(); |
| 92 | 0 | obj.setMeta(super.toDTO()); |
| 93 | 0 | obj.setKey(getId()); |
| 94 | 0 | obj.setName(name); |
| 95 | 0 | if (checkType != null) { |
| 96 | 0 | obj.setTypeKey(checkType.getId()); |
| 97 | |
} |
| 98 | 0 | if (checkState != null) { |
| 99 | 0 | obj.setStateKey(checkState.getId()); |
| 100 | |
} |
| 101 | 0 | if (descr != null) { |
| 102 | 0 | obj.setDescr(descr.toDto()); |
| 103 | |
} |
| 104 | |
|
| 105 | 0 | if (null != process) { |
| 106 | 0 | obj.setProcessKey(process.getId()); |
| 107 | |
} |
| 108 | |
|
| 109 | 0 | obj.setIssueKey(issueId); |
| 110 | 0 | obj.setMilestoneTypeKey(milestoneTypeId); |
| 111 | 0 | obj.setAgendaId(agendaId); |
| 112 | |
|
| 113 | 0 | List<AttributeInfo> atts = new ArrayList<AttributeInfo>(); |
| 114 | 0 | for (CheckAttributeEntity att : getAttributes()) { |
| 115 | 0 | AttributeInfo attInfo = att.toDto(); |
| 116 | 0 | atts.add(attInfo); |
| 117 | 0 | } |
| 118 | 0 | obj.setAttributes(atts); |
| 119 | |
|
| 120 | 0 | return obj; |
| 121 | |
} |
| 122 | |
|
| 123 | |
|
| 124 | 0 | public String getName() { return name; } |
| 125 | 0 | public void setName(String name) { this.name = name; } |
| 126 | |
|
| 127 | |
|
| 128 | 0 | public CheckRichTextEntity getDescr() { return descr; } |
| 129 | 0 | public void setDescr(CheckRichTextEntity descr) { this.descr = descr; } |
| 130 | |
|
| 131 | |
|
| 132 | |
public StateEntity getCheckStateID() { |
| 133 | 0 | return checkState; |
| 134 | |
} |
| 135 | |
public void setCheckStateID(StateEntity checkState) { |
| 136 | 0 | this.checkState = checkState; |
| 137 | 0 | } |
| 138 | |
|
| 139 | |
|
| 140 | |
public CheckTypeEntity getCheckTypeID() { |
| 141 | 0 | return checkType; |
| 142 | |
} |
| 143 | |
public void setCheckTypeID(CheckTypeEntity checkType) { |
| 144 | 0 | this.checkType = checkType; |
| 145 | 0 | } |
| 146 | |
|
| 147 | |
public StateEntity getCheckState() { |
| 148 | 0 | return checkState; |
| 149 | |
} |
| 150 | |
|
| 151 | |
public void setCheckState(StateEntity checkState) { |
| 152 | 0 | this.checkState = checkState; |
| 153 | 0 | } |
| 154 | |
|
| 155 | |
public CheckTypeEntity getCheckType() { |
| 156 | 0 | return checkType; |
| 157 | |
} |
| 158 | |
|
| 159 | |
public void setCheckType(CheckTypeEntity checkType) { |
| 160 | 0 | this.checkType = checkType; |
| 161 | 0 | } |
| 162 | |
|
| 163 | |
public String getIssueId() { |
| 164 | 0 | return issueId; |
| 165 | |
} |
| 166 | |
|
| 167 | |
public void setIssueId(String issueId) { |
| 168 | 0 | this.issueId = issueId; |
| 169 | 0 | } |
| 170 | |
|
| 171 | |
public String getMilestoneTypeId() { |
| 172 | 0 | return milestoneTypeId; |
| 173 | |
} |
| 174 | |
|
| 175 | |
public void setMilestoneTypeId(String milestoneTypeId) { |
| 176 | 0 | this.milestoneTypeId = milestoneTypeId; |
| 177 | 0 | } |
| 178 | |
|
| 179 | |
public ProcessEntity getProcess() { |
| 180 | 0 | return process; |
| 181 | |
} |
| 182 | |
|
| 183 | |
public void setProcess(ProcessEntity process) { |
| 184 | 0 | this.process = process; |
| 185 | 0 | } |
| 186 | |
|
| 187 | |
public String getAgendaId() { |
| 188 | 0 | return agendaId; |
| 189 | |
} |
| 190 | |
|
| 191 | |
public void setAgendaId(String agendaId) { |
| 192 | 0 | this.agendaId = agendaId; |
| 193 | 0 | } |
| 194 | |
|
| 195 | |
@Override |
| 196 | |
public List<CheckAttributeEntity> getAttributes() { |
| 197 | 0 | return attributes; |
| 198 | |
} |
| 199 | |
} |