| 1 | |
package org.kuali.student.enrollment.class1.lui.model; |
| 2 | |
|
| 3 | |
import java.util.ArrayList; |
| 4 | |
import java.util.List; |
| 5 | |
|
| 6 | |
import javax.persistence.CascadeType; |
| 7 | |
import javax.persistence.Column; |
| 8 | |
import javax.persistence.Entity; |
| 9 | |
import javax.persistence.JoinColumn; |
| 10 | |
import javax.persistence.ManyToOne; |
| 11 | |
import javax.persistence.OneToMany; |
| 12 | |
import javax.persistence.Table; |
| 13 | |
|
| 14 | |
import org.kuali.student.enrollment.lui.dto.LuiIdentifierInfo; |
| 15 | |
import org.kuali.student.enrollment.lui.infc.LuiIdentifier; |
| 16 | |
import org.kuali.student.r2.common.dto.AttributeInfo; |
| 17 | |
import org.kuali.student.r2.common.entity.MetaEntity; |
| 18 | |
import org.kuali.student.r2.common.infc.Attribute; |
| 19 | |
|
| 20 | |
@Entity |
| 21 | |
@Table(name = "KSEN_LUI_IDENT") |
| 22 | |
public class LuiIdentifierEntity extends MetaEntity { |
| 23 | |
|
| 24 | |
@Column(name = "LUI_CD") |
| 25 | |
private String code; |
| 26 | |
@Column(name = "SHRT_NAME") |
| 27 | |
private String shortName; |
| 28 | |
@Column(name = "LNG_NAME") |
| 29 | |
private String longName; |
| 30 | |
@Column(name = "DIVISION") |
| 31 | |
private String division; |
| 32 | |
@Column(name = "VARTN") |
| 33 | |
private String variation; |
| 34 | |
@Column(name = "SUFX_CD") |
| 35 | |
private String suffixCode; |
| 36 | |
@Column(name = "LUI_ID_TYPE") |
| 37 | |
private String type; |
| 38 | |
@Column(name = "LUI_ID_STATE") |
| 39 | |
private String state; |
| 40 | |
@ManyToOne |
| 41 | |
@JoinColumn(name = "LUI_ID") |
| 42 | |
private LuiEntity lui; |
| 43 | |
@OneToMany(cascade = CascadeType.ALL, mappedBy = "owner") |
| 44 | |
private List<LuiIdentifierAttributeEntity> attributes; |
| 45 | |
|
| 46 | 0 | public LuiIdentifierEntity() { |
| 47 | 0 | } |
| 48 | |
|
| 49 | |
public LuiIdentifierEntity(LuiIdentifier luiIdentifier) { |
| 50 | 0 | super(luiIdentifier); |
| 51 | 0 | this.setId(luiIdentifier.getId()); |
| 52 | 0 | this.setType(luiIdentifier.getTypeKey()); |
| 53 | 0 | fromDto(luiIdentifier); |
| 54 | 0 | } |
| 55 | |
|
| 56 | |
public void fromDto(LuiIdentifier luiIdentifier) { |
| 57 | 0 | this.setState(luiIdentifier.getStateKey()); |
| 58 | 0 | this.setCode(luiIdentifier.getCode()); |
| 59 | 0 | this.setDivision(luiIdentifier.getDivision()); |
| 60 | 0 | this.setLongName(luiIdentifier.getLongName()); |
| 61 | 0 | this.setShortName(luiIdentifier.getShortName()); |
| 62 | 0 | this.setSuffixCode(luiIdentifier.getSuffixCode()); |
| 63 | 0 | this.setVariation(luiIdentifier.getVariation()); |
| 64 | 0 | this.setAttributes(new ArrayList<LuiIdentifierAttributeEntity>()); |
| 65 | |
|
| 66 | 0 | for (Attribute att : luiIdentifier.getAttributes()) { |
| 67 | 0 | LuiIdentifierAttributeEntity attEntity = new LuiIdentifierAttributeEntity(att); |
| 68 | 0 | this.getAttributes().add(attEntity); |
| 69 | 0 | } |
| 70 | 0 | } |
| 71 | |
|
| 72 | |
public LuiIdentifierInfo toDto() { |
| 73 | 0 | LuiIdentifierInfo info = new LuiIdentifierInfo(); |
| 74 | 0 | info.setId(getId()); |
| 75 | 0 | info.setCode(code); |
| 76 | 0 | info.setDivision(division); |
| 77 | 0 | info.setLongName(longName); |
| 78 | 0 | info.setShortName(shortName); |
| 79 | 0 | info.setStateKey(state); |
| 80 | 0 | info.setSuffixCode(suffixCode); |
| 81 | 0 | info.setTypeKey(type); |
| 82 | 0 | info.setVariation(variation); |
| 83 | 0 | info.setMeta(super.toDTO()); |
| 84 | |
|
| 85 | 0 | if(attributes != null){ |
| 86 | 0 | for (LuiIdentifierAttributeEntity att : getAttributes()) { |
| 87 | 0 | AttributeInfo attInfo = att.toDto(); |
| 88 | 0 | info.getAttributes().add(attInfo); |
| 89 | 0 | } |
| 90 | |
} |
| 91 | 0 | return info; |
| 92 | |
} |
| 93 | |
|
| 94 | |
public String getCode() { |
| 95 | 0 | return code; |
| 96 | |
} |
| 97 | |
|
| 98 | |
public void setCode(String code) { |
| 99 | 0 | this.code = code; |
| 100 | 0 | } |
| 101 | |
|
| 102 | |
public String getShortName() { |
| 103 | 0 | return shortName; |
| 104 | |
} |
| 105 | |
|
| 106 | |
public void setShortName(String shortName) { |
| 107 | 0 | this.shortName = shortName; |
| 108 | 0 | } |
| 109 | |
|
| 110 | |
public String getLongName() { |
| 111 | 0 | return longName; |
| 112 | |
} |
| 113 | |
|
| 114 | |
public void setLongName(String longName) { |
| 115 | 0 | this.longName = longName; |
| 116 | 0 | } |
| 117 | |
|
| 118 | |
public String getDivision() { |
| 119 | 0 | return division; |
| 120 | |
} |
| 121 | |
|
| 122 | |
public void setDivision(String division) { |
| 123 | 0 | this.division = division; |
| 124 | 0 | } |
| 125 | |
|
| 126 | |
public String getVariation() { |
| 127 | 0 | return variation; |
| 128 | |
} |
| 129 | |
|
| 130 | |
public void setVariation(String variation) { |
| 131 | 0 | this.variation = variation; |
| 132 | 0 | } |
| 133 | |
|
| 134 | |
public String getSuffixCode() { |
| 135 | 0 | return suffixCode; |
| 136 | |
} |
| 137 | |
|
| 138 | |
public void setSuffixCode(String suffixCode) { |
| 139 | 0 | this.suffixCode = suffixCode; |
| 140 | 0 | } |
| 141 | |
|
| 142 | |
public String getType() { |
| 143 | 0 | return type; |
| 144 | |
} |
| 145 | |
|
| 146 | |
public void setType(String type) { |
| 147 | 0 | this.type = type; |
| 148 | 0 | } |
| 149 | |
|
| 150 | |
public String getState() { |
| 151 | 0 | return state; |
| 152 | |
} |
| 153 | |
|
| 154 | |
public void setState(String state) { |
| 155 | 0 | this.state = state; |
| 156 | 0 | } |
| 157 | |
|
| 158 | |
public void setAttributes(List<LuiIdentifierAttributeEntity> attributes) { |
| 159 | 0 | this.attributes = attributes; |
| 160 | |
|
| 161 | 0 | } |
| 162 | |
|
| 163 | |
public List<LuiIdentifierAttributeEntity> getAttributes() { |
| 164 | 0 | return attributes; |
| 165 | |
|
| 166 | |
|
| 167 | |
|
| 168 | |
|
| 169 | |
|
| 170 | |
|
| 171 | |
|
| 172 | |
} |
| 173 | |
|
| 174 | |
public LuiEntity getLui() { |
| 175 | 0 | return lui; |
| 176 | |
} |
| 177 | |
|
| 178 | |
public void setLui(LuiEntity lui) { |
| 179 | 0 | this.lui = lui; |
| 180 | 0 | } |
| 181 | |
} |