View Javadoc

1   /**
2    * Copyright 2011 The Kuali Foundation Licensed under the
3    * Educational Community License, Version 2.0 (the "License"); you may
4    * not use this file except in compliance with the License. You may
5    * obtain a copy of the License at
6    *
7    * http://www.osedu.org/licenses/ECL-2.0
8    *
9    * Unless required by applicable law or agreed to in writing,
10   * software distributed under the License is distributed on an "AS IS"
11   * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
12   * or implied. See the License for the specific language governing
13   * permissions and limitations under the License.
14   */
15  
16  package org.kuali.common.impex.model;
17  
18  import java.util.ArrayList;
19  import java.util.List;
20  
21  import javax.xml.bind.annotation.XmlAccessType;
22  import javax.xml.bind.annotation.XmlAccessorType;
23  import javax.xml.bind.annotation.XmlElement;
24  import javax.xml.bind.annotation.XmlRootElement;
25  
26  import org.kuali.common.util.CollectionUtils;
27  
28  @XmlRootElement
29  @XmlAccessorType(XmlAccessType.PROPERTY)
30  public class Schema {
31  
32  	String name;
33  	List<Table> tables = new ArrayList<Table>();
34  	List<Sequence> sequences = new ArrayList<Sequence>();
35  	List<View> views = new ArrayList<View>();
36  	List<ForeignKey> foreignKeys = new ArrayList<ForeignKey>();
37  
38  	/**
39  	 * This is a copy constructor. It must create a perfect, deep, copy of this object
40  	 */
41  	public Schema(Schema schema) {
42  		super();
43  		this.name = schema.getName();
44  
45  		for (Table table : CollectionUtils.toEmptyList(schema.getTables())) {
46  			this.tables.add(new Table(table));
47  		}
48  
49  		for (Sequence sequence : CollectionUtils.toEmptyList(schema.getSequences())) {
50  			this.sequences.add(new Sequence(sequence));
51  		}
52  
53  		for (View view : CollectionUtils.toEmptyList(schema.getViews())) {
54  			this.views.add(new View(view));
55  		}
56  
57  		for (ForeignKey fk : CollectionUtils.toEmptyList(schema.getForeignKeys())) {
58  			this.foreignKeys.add(new ForeignKey(fk));
59  		}
60  	}
61  
62  	public Schema() {
63  		super();
64  	}
65  
66  	@XmlElement
67  	public String getName() {
68  		return name;
69  	}
70  
71  	@XmlElement(name = "table")
72  	public List<Table> getTables() {
73  		return tables;
74  	}
75  
76  	@XmlElement(name = "foreignKey")
77  	public List<ForeignKey> getForeignKeys() {
78  		return foreignKeys;
79  	}
80  
81  	@XmlElement(name = "sequence")
82  	public List<Sequence> getSequences() {
83  		return sequences;
84  	}
85  
86  	@XmlElement(name = "view")
87  	public List<View> getViews() {
88  		return views;
89  	}
90  
91  	public void setName(String name) {
92  		this.name = name;
93  	}
94  
95  	public void setForeignKeys(List<ForeignKey> foreignKeys) {
96  		this.foreignKeys = foreignKeys;
97  	}
98  
99  	public void setSequences(List<Sequence> sequences) {
100 		this.sequences = sequences;
101 	}
102 
103 	public void setTables(List<Table> tables) {
104 		this.tables = tables;
105 	}
106 
107 	public void setViews(List<View> views) {
108 		this.views = views;
109 	}
110 }