1 package org.kuali.ole.deliver.bo;
2
3
4 import org.apache.commons.collections.CollectionUtils;
5 import org.kuali.rice.core.api.mo.AbstractDataTransferObject;
6 import org.kuali.rice.core.api.mo.ModelBuilder;
7
8 import javax.xml.bind.annotation.*;
9 import java.io.Serializable;
10 import java.util.ArrayList;
11 import java.util.List;
12
13
14 @XmlRootElement(name = OlePatronLoanDocuments.Constants.ROOT_ELEMENT_NAME)
15 @XmlAccessorType(XmlAccessType.NONE)
16 @XmlType(name = "PatronLoan", propOrder = {
17 OlePatronLoanDocuments.Elements.OLE_PATRON_LOAN_ITM
18 })
19 public class OlePatronLoanDocuments extends AbstractDataTransferObject implements OlePatronLoanDocumentsContract {
20
21 private static final long serialVersionUID = 1L;
22
23 @XmlElement(name = Elements.OLE_PATRON_LOAN_ITM, required = false)
24 private final List<OlePatronLoanDocument> olePatronLoanItem;
25
26
27 public OlePatronLoanDocuments() {
28 this.olePatronLoanItem = null;
29 }
30
31 public OlePatronLoanDocuments(Builder builder) {
32
33 this.olePatronLoanItem = new ArrayList<OlePatronLoanDocument>();
34 if (!CollectionUtils.isEmpty(builder.getOlePatronLoanDocuments())) {
35 for (OlePatronLoanDocument.Builder olePatronLoanDocument : builder.getOlePatronLoanDocuments()) {
36 this.olePatronLoanItem.add(olePatronLoanDocument.build());
37 }
38 }
39 }
40
41
42
43
44
45
46
47 public static OlePatronLoanDocument to(OleRenewalLoanDocument bo) {
48 if (bo == null) {
49 return null;
50 }
51 return OlePatronLoanDocument.Builder.create(bo).build();
52 }
53
54
55 @Override
56 public String getId() {
57 return null;
58 }
59
60 @Override
61 public Long getVersionNumber() {
62 return null;
63 }
64
65
66 @Override
67 public List<? extends OlePatronLoanDocumentContract> getOlePatronLoanDocuments() {
68 return olePatronLoanItem;
69 }
70
71 public static class Builder
72 implements Serializable, ModelBuilder, OlePatronLoanDocumentsContract {
73 private List<OlePatronLoanDocument.Builder> olePatronLoanDocuments;
74 private Long versionNumber;
75 private String objectId;
76
77 public void setVersionNumber(Long versionNumber) {
78 this.versionNumber = versionNumber;
79 }
80
81 public String getObjectId() {
82 return objectId;
83 }
84
85 public void setObjectId(String objectId) {
86 this.objectId = objectId;
87 }
88
89 private Builder() {
90 }
91
92 public static Builder create() {
93 return new Builder();
94 }
95
96 public static Builder create(OlePatronLoanDocumentsContract contract) {
97
98 if (contract == null) {
99 throw new IllegalArgumentException("contract was null");
100 }
101 Builder builder = create();
102
103 builder.olePatronLoanDocuments = new ArrayList<OlePatronLoanDocument.Builder>();
104 if (!CollectionUtils.isEmpty(contract.getOlePatronLoanDocuments())) {
105 for (OlePatronLoanDocumentContract olePatronLoanDocumentContract : contract.getOlePatronLoanDocuments()) {
106 builder.olePatronLoanDocuments.add(OlePatronLoanDocument.Builder.create(olePatronLoanDocumentContract));
107 }
108 }
109
110 builder.setVersionNumber(contract.getVersionNumber());
111
112
113
114 return builder;
115 }
116
117
118 public OlePatronLoanDocuments build() {
119 return new OlePatronLoanDocuments(this);
120 }
121
122 @Override
123 public String getId() {
124 return null;
125 }
126
127 @Override
128 public Long getVersionNumber() {
129 return null;
130 }
131
132 @Override
133 public List<OlePatronLoanDocument.Builder> getOlePatronLoanDocuments() {
134 return olePatronLoanDocuments;
135 }
136
137 public void setOlePatronLoanDocuments(List<OlePatronLoanDocumentContract> OlePatronLoanDocumentContract) {
138 this.olePatronLoanDocuments = olePatronLoanDocuments;
139 }
140
141
142 }
143
144
145 static class Constants {
146
147 final static String ROOT_ELEMENT_NAME = "olePatronLoanItems";
148 }
149
150 static class Elements {
151
152 final static String OLE_PATRON_LOAN_ITM = "olePatronLoanItem";
153
154 }
155
156 }