View Javadoc

1   package salto.tool.jdo.data;
2   
3   import java.util.ArrayList;
4   
5   import salto.tool.jdo.util.DoNameCreator;
6   import salto.tool.jdo.util.IDoNameCreator;
7   import salto.tool.sql.data.TableFK;
8   import salto.tool.sql.data.TableInfo;
9   
10  /***
11   * Objet de donn�e correspondant � un attribut java d'une classe de type
12   * Dataobject Date de cr�ation : (18/10/01 06:37:36)
13   * 
14   * @author : E. Loiez
15   */
16  public class JdoInfo extends TableInfo implements Cloneable {
17  	protected String javaPckName = null;
18  
19  	protected String javaClassName = null;
20  
21  	protected JdoColInfo[] jdoColInfos = null;
22  
23  	// composant cr�ant les noms / ce composant doit �tre param�trable
24  	protected static IDoNameCreator nameCreator = new DoNameCreator();
25  
26  	/***
27  	 * Commentaire relatif au constructeur JdoInfo.
28  	 */
29  	public JdoInfo() {
30  		super();
31  	}
32  
33  	/***
34  	 * Commentaire relatif au constructeur JdoInfo.
35  	 */
36  	public JdoInfo(TableInfo tableInfo) {
37  		super(tableInfo);
38  		if (colInfos != null) {
39  			jdoColInfos = new JdoColInfo[colInfos.length];
40  			for (int i = 0; i < jdoColInfos.length; i++) {
41  				jdoColInfos[i] = new JdoColInfo(colInfos[i]);
42  			}
43  		}
44  	}
45  
46  	/***
47  	 * @return Returns the javaClassName.
48  	 */
49  	public String getJavaClassName() {
50  		if (javaClassName == null)
51  			javaClassName = nameCreator.createDoName(tableName);
52  		return javaClassName;
53  	}
54  
55  	/***
56  	 * colinfos that are not pk and not fk
57  	 * 
58  	 * @return
59  	 */
60  	public JdoColInfo[] getBasicColInfos() {
61  		ArrayList list = new ArrayList();
62  
63  		for (int i = 0; i < jdoColInfos.length; i++) {
64  			boolean basic = true;
65  
66  			for (int j = 0; j < this.pk.length && basic; j++) {
67  				if (pk[j].getCol().equals(jdoColInfos[i].getColName())) {
68  					basic = false;
69  				}
70  
71  			}
72  
73  			for (int j = 0; j < this.getImportedFk().length && basic; j++) {
74  				TableFK[] fks = this.getImportedFk()[j];
75  
76  				for (int k = 0; k < fks.length; k++) {
77  					if (fks[k].getFkColumnName().equals(jdoColInfos[i].getColName())) {
78  						basic = false;
79  					}
80  				}
81  
82  			}
83  
84  			if (basic) {
85  				list.add(jdoColInfos[i]);
86  			}
87  		}
88  
89  		return (JdoColInfo[]) list.toArray(new JdoColInfo[list.size()]);
90  	}
91  
92  	/***
93  	 * colinfos that are not fk
94  	 * 
95  	 * @return
96  	 */
97  	public JdoColInfo[] getNonFKColInfos() {
98  		ArrayList list = new ArrayList();
99  
100 		for (int i = 0; i < jdoColInfos.length; i++) {
101 			boolean basic = true;
102 
103 			for (int j = 0; j < this.getImportedFk().length && basic; j++) {
104 				TableFK[] fks = this.getImportedFk()[j];
105 
106 				for (int k = 0; k < fks.length; k++) {
107 					if (fks[k].getFkColumnName().equals(jdoColInfos[i].getColName())) {
108 						basic = false;
109 					}
110 				}
111 
112 			}
113 
114 			if (basic) {
115 				list.add(jdoColInfos[i]);
116 			}
117 		}
118 
119 		return (JdoColInfo[]) list.toArray(new JdoColInfo[list.size()]);
120 	}
121 
122 	/***
123 	 * @return Returns the jdoColInfos.
124 	 */
125 	public JdoColInfo[] getJdoColInfos() {
126 		return jdoColInfos;
127 	}
128 
129 	/***
130 	 * @param jdoColInfos
131 	 *            The jdoColInfos to set.
132 	 */
133 	public void setJdoColInfos(JdoColInfo[] jdoColInfos) {
134 		this.jdoColInfos = jdoColInfos;
135 	}
136 
137 	/***
138 	 * @param javaClassName
139 	 *            The javaClassName to set.
140 	 */
141 	public void setJavaClassName(String javaClassName) {
142 		this.javaClassName = javaClassName;
143 	}
144 
145 	/***
146 	 * @return Returns the javaPckName.
147 	 */
148 	public String getJavaPckName() {
149 		return javaPckName;
150 	}
151 
152 	/***
153 	 * @param javaPckName
154 	 *            The javaPckName to set.
155 	 */
156 	public void setJavaPckName(String javaPckName) {
157 		this.javaPckName = javaPckName;
158 	}
159 
160 	/*
161 	 * (non-Javadoc)
162 	 * 
163 	 * @see java.lang.Object#clone()
164 	 */
165 	protected Object clone() throws CloneNotSupportedException {
166 		// TODO Auto-generated method stub
167 		return super.clone();
168 	}
169 
170 }