Coverage Report - org.kuali.student.enrollment.class1.hold.model.HoldIssueEntity
 
Classes in this File Line Coverage Branch Coverage Complexity
HoldIssueEntity
0%
0/55
0%
0/8
1.222
 
 1  
 /*
 2  
  * Copyright 2007 The Kuali Foundation
 3  
  *
 4  
  * Licensed under the Educational Community License, Version 1.0 (the "License");
 5  
  * you may not use this file except in compliance with the License.
 6  
  * You may obtain a copy of the License at
 7  
  *
 8  
  * http://www.opensource.org/licenses/ecl1.php
 9  
  *
 10  
  * Unless required by applicable law or agreed to in writing, software
 11  
  * distributed under the License is distributed on an "AS IS" BASIS,
 12  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 13  
  * See the License for the specific language governing permissions and
 14  
  * limitations under the License.
 15  
  */
 16  
 package org.kuali.student.enrollment.class1.hold.model;
 17  
 
 18  
 import org.kuali.student.common.entity.KSEntityConstants;
 19  
 import org.kuali.student.r2.common.dto.AttributeInfo;
 20  
 import org.kuali.student.r2.common.dto.RichTextInfo;
 21  
 import org.kuali.student.r2.common.entity.AttributeOwner;
 22  
 import org.kuali.student.r2.common.entity.MetaEntity;
 23  
 import org.kuali.student.r2.common.infc.Attribute;
 24  
 import org.kuali.student.r2.core.hold.dto.IssueInfo;
 25  
 import org.kuali.student.r2.core.hold.infc.Issue;
 26  
 
 27  
 import javax.persistence.*;
 28  
 import java.util.ArrayList;
 29  
 import java.util.List;
 30  
 
 31  
 /**
 32  
  * This is a description of what this class does - andy don't forget to fill this in.
 33  
  *
 34  
  * @author Kuali Rice Team (kuali-rice@googlegroups.com)
 35  
  */
 36  
 @Entity
 37  
 @Table(name = "KSEN_HOLD_ISSUE")
 38  
 public class HoldIssueEntity extends MetaEntity implements AttributeOwner<HoldIssueAttributeEntity> {
 39  
 
 40  
     @Column(name = "NAME")
 41  
     private String name;
 42  
 
 43  
     @Column(name = "ORG_ID")
 44  
     private String organizationId;
 45  
 
 46  
     @Column(name = "HOLD_ISSUE_TYPE", nullable = false)
 47  
     private String holdIssueType;
 48  
 
 49  
     @Column(name = "DESCR_PLAIN", length = KSEntityConstants.EXTRA_LONG_TEXT_LENGTH, nullable = false)
 50  
     private String descrPlain;
 51  
 
 52  
     @Column(name = "DESCR_FORMATTED", length = KSEntityConstants.EXTRA_LONG_TEXT_LENGTH)
 53  
     private String descrFormatted;
 54  
 
 55  
     @OneToMany(cascade = CascadeType.ALL, mappedBy = "owner")
 56  
     private List<HoldIssueAttributeEntity> attributes;
 57  
 
 58  
     @Column(name = "HOLD_ISSUE_STATE", nullable = false)
 59  
     private String holdIssueState;
 60  
 
 61  0
     public HoldIssueEntity() {
 62  0
     }
 63  
 
 64  
     public HoldIssueEntity(Issue issue) {
 65  0
         super(issue);
 66  0
         this.setId(issue.getId());
 67  0
         this.setHoldIssueType(issue.getTypeKey());
 68  0
         this.fromDto(issue);
 69  0
     }
 70  
 
 71  
     public void fromDto(Issue issue) {
 72  0
         setName(issue.getName());
 73  0
         setOrganizationId(issue.getOrganizationId());
 74  0
         setHoldIssueState(issue.getStateKey());
 75  0
         setHoldIssueType(issue.getTypeKey());
 76  0
         if (issue.getDescr() != null) {
 77  0
             setDescrFormatted(issue.getDescr().getFormatted());
 78  0
             setDescrPlain(issue.getDescr().getPlain());
 79  
         }
 80  0
         this.setAttributes(new ArrayList<HoldIssueAttributeEntity>());
 81  0
         for (Attribute att : issue.getAttributes()) {
 82  0
             HoldIssueAttributeEntity attEntity = new HoldIssueAttributeEntity(att);
 83  0
             this.getAttributes().add(attEntity);
 84  0
         }
 85  0
     }
 86  
 
 87  
     @Override
 88  
     public void setAttributes(List<HoldIssueAttributeEntity> attributes) {
 89  0
         this.attributes = attributes;
 90  0
     }
 91  
 
 92  
     @Override
 93  
     public List<HoldIssueAttributeEntity> getAttributes() {
 94  0
         return attributes;
 95  
     }
 96  
 
 97  
     public String getName() {
 98  0
         return name;
 99  
     }
 100  
 
 101  
     public void setName(String name) {
 102  0
         this.name = name;
 103  0
     }
 104  
 
 105  
     public String getOrganizationId() {
 106  0
         return organizationId;
 107  
     }
 108  
 
 109  
     public void setOrganizationId(String organizationId) {
 110  0
         this.organizationId = organizationId;
 111  0
     }
 112  
 
 113  
     public String getHoldIssueType() {
 114  0
         return holdIssueType;
 115  
     }
 116  
 
 117  
     public void setHoldIssueType(String issueType) {
 118  0
         this.holdIssueType = issueType;
 119  0
     }
 120  
 
 121  
     public String getHoldIssueState() {
 122  0
         return holdIssueState;
 123  
     }
 124  
 
 125  
     public void setHoldIssueState(String issueState) {
 126  0
         this.holdIssueState = issueState;
 127  0
     }
 128  
 
 129  
     public String getDescrPlain() {
 130  0
         return descrPlain;
 131  
     }
 132  
 
 133  
     public void setDescrPlain(String plain) {
 134  0
         this.descrPlain = plain;
 135  0
     }
 136  
 
 137  
     public String getDescrFormatted() {
 138  0
         return descrFormatted;
 139  
     }
 140  
 
 141  
     public void setDescrFormatted(String formatted) {
 142  0
         this.descrFormatted = formatted;
 143  0
     }
 144  
 
 145  
     public IssueInfo toDto() {
 146  0
         IssueInfo info = new IssueInfo();
 147  0
         info.setId(getId());
 148  0
         info.setName(getName());
 149  0
         info.setTypeKey(getHoldIssueType());
 150  0
         info.setStateKey(getHoldIssueState());
 151  0
         info.setOrganizationId(getOrganizationId());
 152  0
         if (descrPlain != null) {
 153  0
             info.setDescr(new RichTextInfo(descrPlain, descrFormatted));
 154  
         }
 155  0
         info.setMeta(super.toDTO());
 156  0
         for (HoldIssueAttributeEntity att : getAttributes()) {
 157  0
             AttributeInfo attInfo = att.toDto();
 158  0
             info.getAttributes().add(attInfo);
 159  0
         }
 160  0
         return info;
 161  
     }
 162  
 }