-
Notifications
You must be signed in to change notification settings - Fork 122
/
Copy pathEdgeConvertCreateDDL.java
73 lines (60 loc) · 2.32 KB
/
EdgeConvertCreateDDL.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import java.io.*;
import java.util.*;
public abstract class EdgeConvertCreateDDL {
static String[] products = {"MySQL"};
protected EdgeTable[] tables; //master copy of EdgeTable objects
protected EdgeField[] fields; //master copy of EdgeField objects
protected int[] numBoundTables;
protected int maxBound;
protected StringBuffer sb;
protected int selected;
public EdgeConvertCreateDDL(EdgeTable[] tables, EdgeField[] fields) {
this.tables = tables;
this.fields = fields;
initialize();
} //EdgeConvertCreateDDL(EdgeTable[], EdgeField[])
public EdgeConvertCreateDDL() { //default constructor with empty arg list for to allow output dir to be set before there are table and field objects
} //EdgeConvertCreateDDL()
public void initialize() {
numBoundTables = new int[tables.length];
maxBound = 0;
sb = new StringBuffer();
for (int i = 0; i < tables.length; i++) { //step through list of tables
int numBound = 0; //initialize counter for number of bound tables
int[] relatedFields = tables[i].getRelatedFieldsArray();
for (int j = 0; j < relatedFields.length; j++) { //step through related fields list
if (relatedFields[j] != 0) {
numBound++; //count the number of non-zero related fields
}
}
numBoundTables[i] = numBound;
if (numBound > maxBound) {
maxBound = numBound;
}
}
}
protected EdgeTable getTable(int numFigure) {
for (int tIndex = 0; tIndex < tables.length; tIndex++) {
if (numFigure == tables[tIndex].getNumFigure()) {
return tables[tIndex];
}
}
return null;
}
protected EdgeField getField(int numFigure) {
for (int fIndex = 0; fIndex < fields.length; fIndex++) {
if (numFigure == fields[fIndex].getNumFigure()) {
return fields[fIndex];
}
}
return null;
}
public abstract String getDatabaseName();
public abstract String getProductName();
public abstract String getSQLString();
public abstract void createDDL();
}//EdgeConvertCreateDDL