1
2
3
4
5
6
7
8
9
10
11
12
13
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.XmlAttribute;
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 ForeignKey implements NamedElement {
31
32 String name;
33 ForeignKeyConstraintType onDelete;
34 ForeignKeyConstraintType onUpdate;
35 List<String> localColumnNames;
36 List<String> foreignColumnNames;
37 String localTableName;
38 String foreignTableName;
39
40
41
42
43 public ForeignKey(ForeignKey fk) {
44 super();
45
46 this.name = fk.getName();
47 this.onDelete = fk.getOnDelete();
48 this.onUpdate = fk.getOnUpdate();
49 this.localColumnNames = new ArrayList<String>(CollectionUtils.toEmptyList(fk.getLocalColumnNames()));
50 this.foreignColumnNames = new ArrayList<String>(CollectionUtils.toEmptyList(fk.getForeignColumnNames()));
51 this.localTableName = fk.getLocalTableName();
52 this.foreignTableName = fk.getForeignTableName();
53 }
54
55 public ForeignKey() {
56 this(null, null, null);
57 }
58
59 public ForeignKey(String name, String localTableName, String foreignTableName) {
60 this.name = name;
61 this.localTableName = localTableName;
62 this.foreignTableName = foreignTableName;
63
64 localColumnNames = new ArrayList<String>();
65 foreignColumnNames = new ArrayList<String>();
66 }
67
68 @XmlAttribute
69 public String getForeignTableName() {
70 return foreignTableName;
71 }
72
73 public void setForeignTableName(String foreignTableName) {
74 this.foreignTableName = foreignTableName;
75 }
76
77 @XmlAttribute
78 public String getLocalTableName() {
79 return localTableName;
80 }
81
82 public void setLocalTableName(String localTableName) {
83 this.localTableName = localTableName;
84 }
85
86 @Override
87 @XmlAttribute
88 public String getName() {
89 return name;
90 }
91
92 public void setName(String name) {
93 this.name = name;
94 }
95
96 public List<String> getForeignColumnNames() {
97 return foreignColumnNames;
98 }
99
100 public void setForeignColumnNames(List<String> foreignColumnNames) {
101 this.foreignColumnNames = foreignColumnNames;
102 }
103
104 public List<String> getLocalColumnNames() {
105 return localColumnNames;
106 }
107
108 public void setLocalColumnNames(List<String> localColumnNames) {
109 this.localColumnNames = localColumnNames;
110 }
111
112 @XmlAttribute
113 public ForeignKeyConstraintType getOnDelete() {
114 return onDelete;
115 }
116
117 @XmlAttribute
118 public ForeignKeyConstraintType getOnUpdate() {
119 return onUpdate;
120 }
121
122 public void setOnDelete(ForeignKeyConstraintType onDelete) {
123 this.onDelete = onDelete;
124 }
125
126 public void setOnUpdate(ForeignKeyConstraintType onUpdate) {
127 this.onUpdate = onUpdate;
128 }
129 }