1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.common.impex.schema.impl;
17
18 import java.util.Collections;
19
20 import org.kuali.common.impex.model.Column;
21 import org.kuali.common.impex.model.DataType;
22 import org.kuali.common.impex.model.DataTypeSize;
23 import org.kuali.common.impex.model.ForeignKey;
24 import org.kuali.common.impex.model.ForeignKeyConstraintType;
25 import org.kuali.common.impex.model.Table;
26 import org.kuali.common.impex.model.UniqueConstraint;
27 import org.kuali.common.impex.model.View;
28
29 public class MockDataUtil {
30
31 public static Table buildSimpleTable() {
32
33 Table result = new Table("FOO_T");
34
35
36 Column idCol = new Column("ID", DataType.STRING);
37 idCol.setSize(new DataTypeSize(36));
38 idCol.setPrimaryKey(true);
39
40 result.getColumns().add(idCol);
41
42
43 Column timeCol = new Column("CREATETIME", DataType.TIMESTAMP);
44 timeCol.setNullable(false);
45
46 result.getColumns().add(timeCol);
47
48
49 Column countCol = new Column("FOO_COUNT", DataType.FLOAT);
50 countCol.setSize(new DataTypeSize(10));
51
52 result.getColumns().add(countCol);
53
54
55 Column nameCol = new Column("NAME", DataType.STRING);
56 nameCol.setSize(new DataTypeSize(255));
57
58 result.getColumns().add(nameCol);
59
60
61 UniqueConstraint nameIndex = new UniqueConstraint(Collections.singletonList(nameCol.getName()), "FOO_U1_NAME");
62
63 result.getUniqueConstraints().add(nameIndex);
64
65 return result;
66 }
67
68 public static View buildSimpleView() {
69
70 String viewSql = "SELECT ID, NAME FROM FOO_T\n" + "WHERE NAME LIKE 'TEST%'";
71
72 return new View("TEST_V1", viewSql);
73 }
74
75 public static ForeignKey buildSimpleForeignKey() {
76 ForeignKey fk = new ForeignKey("FOO_FK_1", "FOO_T", "BAR_T");
77
78 fk.setOnDelete(ForeignKeyConstraintType.CASCADE);
79 fk.setLocalColumnNames(Collections.singletonList("BAR_ID"));
80 fk.setForeignColumnNames(Collections.singletonList("ID"));
81
82 return fk;
83 }
84 }