1   
2   
3   
4   
5   
6   
7   
8   
9   
10  
11  
12  
13  
14  
15  
16  package org.kuali.rice.krad.data.metadata.impl;
17  
18  import java.util.Collections;
19  import java.util.List;
20  
21  import org.kuali.rice.krad.data.metadata.DataObjectCollection;
22  import org.kuali.rice.krad.data.metadata.DataObjectCollectionSortAttribute;
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  public class DataObjectCollectionImpl extends MetadataChildBase implements DataObjectCollection {
34  	private static final long serialVersionUID = -785119931770775640L;
35  
36  	protected DataObjectCollection embeddedCollection;
37  
38      protected String elementLabel;
39  	protected Long minItems;
40  	protected Long maxItems;
41  	protected List<DataObjectCollectionSortAttribute> defaultOrdering;
42  	protected Boolean indirectCollection;
43  
44      
45  
46  
47  
48  
49  
50  
51      @Override
52  	public String getElementLabel() {
53  		if (elementLabel == null) {
54  			elementLabel = getLabelFromPropertyName(relatedType.getSimpleName());
55  		}
56          return elementLabel;
57      }
58  
59      
60  
61  
62  
63  
64      public void setElementLabel(String elementLabel) {
65          this.elementLabel = elementLabel;
66      }
67  
68  	@Override
69  	public Long getMinItems() {
70  		if (minItems != null) {
71  			return minItems;
72  		}
73  		if (embeddedCollection != null) {
74  			return embeddedCollection.getMinItems();
75  		}
76  		return null;
77      }
78  
79      
80  
81  
82  
83  
84  	public void setMinItemsInCollection(Long minOccurs) {
85  		this.minItems = minOccurs;
86      }
87  
88      
89  
90  
91  	@Override
92  	public Long getMaxItems() {
93  		if (maxItems != null) {
94  			return maxItems;
95  		}
96  		if (embeddedCollection != null) {
97  			return embeddedCollection.getMaxItems();
98  		}
99  		return null;
100     }
101 
102     
103 
104 
105 
106 
107 	public void setMaxItemsInCollection(Long maxOccurs) {
108 		this.maxItems = maxOccurs;
109     }
110 
111     
112 
113 
114 	@Override
115 	public List<DataObjectCollectionSortAttribute> getDefaultOrdering() {
116 		if (defaultOrdering != null) {
117 			return defaultOrdering;
118 		}
119 		if (embeddedCollection != null) {
120 			return embeddedCollection.getDefaultOrdering();
121 		}
122 		return Collections.emptyList();
123 	}
124 
125     
126 
127 
128 
129 
130 	public void setDefaultCollectionOrderingAttributeNames(
131 			List<DataObjectCollectionSortAttribute> defaultCollectionOrdering) {
132 		this.defaultOrdering = defaultCollectionOrdering;
133 	}
134 
135     
136 
137 
138 	@Override
139 	public boolean isIndirectCollection() {
140 		if (indirectCollection != null) {
141 			return indirectCollection;
142 		}
143 		if (embeddedCollection != null) {
144 			return embeddedCollection.isIndirectCollection();
145 		}
146 		return false;
147 	}
148 
149     
150 
151 
152 
153 
154 	public void setIndirectCollection(boolean indirectCollection) {
155 		this.indirectCollection = indirectCollection;
156 	}
157 
158     
159 
160 
161 
162 
163 	public DataObjectCollection getEmbeddedCollection() {
164 		return embeddedCollection;
165 	}
166 
167 	public void setEmbeddedCollection(DataObjectCollection embeddedCollection) {
168 		this.embeddedCollection = embeddedCollection;
169 		setEmbeddedMetadataChild(embeddedCollection);
170 	}
171 
172 }