| 1 | |
|
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | |
|
| 6 | |
|
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | |
|
| 14 | |
|
| 15 | |
|
| 16 | |
|
| 17 | |
|
| 18 | |
package rs.mgifos.mosquito.model; |
| 19 | |
|
| 20 | |
import java.util.Iterator; |
| 21 | |
import java.util.LinkedHashMap; |
| 22 | |
import java.util.Map; |
| 23 | |
import java.util.Set; |
| 24 | |
|
| 25 | |
|
| 26 | |
|
| 27 | |
|
| 28 | |
|
| 29 | |
public class MetaColumn { |
| 30 | |
protected String code; |
| 31 | |
|
| 32 | |
protected String comment; |
| 33 | |
|
| 34 | 18 | protected MetaColumn fkColParent = null; |
| 35 | |
|
| 36 | |
protected String jClassName; |
| 37 | |
|
| 38 | |
protected int length; |
| 39 | |
|
| 40 | 18 | protected boolean mandatory = false; |
| 41 | |
|
| 42 | |
protected String name; |
| 43 | |
|
| 44 | 18 | protected MetaKey parentKey = null; |
| 45 | |
|
| 46 | |
protected String parentTable; |
| 47 | |
|
| 48 | |
protected int precision; |
| 49 | |
|
| 50 | |
protected String defaultVal; |
| 51 | |
|
| 52 | 18 | protected LinkedHashMap<String, String> lhmListOfVals = new LinkedHashMap<String, String>(); |
| 53 | |
|
| 54 | |
|
| 55 | |
|
| 56 | |
|
| 57 | |
|
| 58 | |
|
| 59 | |
|
| 60 | |
|
| 61 | |
|
| 62 | |
|
| 63 | |
|
| 64 | |
|
| 65 | |
|
| 66 | |
|
| 67 | |
|
| 68 | |
|
| 69 | |
|
| 70 | |
|
| 71 | |
|
| 72 | |
public MetaColumn(String aCode, String aName, String aParentTable, |
| 73 | |
boolean aMandatory, MetaColumn aFKParent, String aJClassName, |
| 74 | |
int aLength, int aPrecision, String aComment) { |
| 75 | 18 | super(); |
| 76 | 18 | code = aCode; |
| 77 | 18 | name = aName; |
| 78 | 18 | parentTable = aParentTable; |
| 79 | 18 | mandatory = aMandatory; |
| 80 | 18 | fkColParent = aFKParent; |
| 81 | 18 | jClassName = aJClassName; |
| 82 | 18 | length = aLength; |
| 83 | 18 | precision = aPrecision; |
| 84 | 18 | comment = aComment; |
| 85 | 18 | } |
| 86 | |
|
| 87 | |
|
| 88 | |
|
| 89 | |
|
| 90 | |
|
| 91 | |
|
| 92 | |
public String getCode() { |
| 93 | 45 | return code; |
| 94 | |
} |
| 95 | |
|
| 96 | |
|
| 97 | |
|
| 98 | |
|
| 99 | |
public String getComment() { |
| 100 | 18 | return comment; |
| 101 | |
} |
| 102 | |
|
| 103 | |
|
| 104 | |
|
| 105 | |
|
| 106 | |
|
| 107 | |
|
| 108 | |
public MetaColumn getFkColParent() { |
| 109 | 0 | return fkColParent; |
| 110 | |
} |
| 111 | |
|
| 112 | |
|
| 113 | |
|
| 114 | |
|
| 115 | |
public String getJClassName() { |
| 116 | 18 | return jClassName; |
| 117 | |
} |
| 118 | |
|
| 119 | |
|
| 120 | |
|
| 121 | |
|
| 122 | |
public int getLength() { |
| 123 | 18 | return length; |
| 124 | |
} |
| 125 | |
|
| 126 | |
|
| 127 | |
|
| 128 | |
|
| 129 | |
|
| 130 | |
|
| 131 | |
public String getName() { |
| 132 | 18 | return name; |
| 133 | |
} |
| 134 | |
|
| 135 | |
|
| 136 | |
|
| 137 | |
|
| 138 | |
public MetaKey getParentKey() { |
| 139 | 0 | return parentKey; |
| 140 | |
} |
| 141 | |
|
| 142 | |
|
| 143 | |
|
| 144 | |
|
| 145 | |
|
| 146 | |
|
| 147 | |
public String getParentTable() { |
| 148 | 0 | return parentTable; |
| 149 | |
} |
| 150 | |
|
| 151 | |
|
| 152 | |
|
| 153 | |
|
| 154 | |
public int getPrecision() { |
| 155 | 18 | return precision; |
| 156 | |
} |
| 157 | |
|
| 158 | |
|
| 159 | |
|
| 160 | |
|
| 161 | |
|
| 162 | |
|
| 163 | |
public String getTableDotColumnCode() { |
| 164 | 18 | return parentTable + "." + code; |
| 165 | |
} |
| 166 | |
|
| 167 | |
|
| 168 | |
|
| 169 | |
|
| 170 | |
|
| 171 | |
|
| 172 | |
public boolean isMandatory() { |
| 173 | 0 | return mandatory; |
| 174 | |
} |
| 175 | |
|
| 176 | |
|
| 177 | |
|
| 178 | |
|
| 179 | |
|
| 180 | |
|
| 181 | |
|
| 182 | |
public boolean isPartOfFK() { |
| 183 | 0 | return fkColParent != null; |
| 184 | |
} |
| 185 | |
|
| 186 | |
|
| 187 | |
|
| 188 | |
|
| 189 | |
|
| 190 | |
|
| 191 | |
public boolean isPartOfPK() { |
| 192 | 0 | return parentKey != null; |
| 193 | |
} |
| 194 | |
|
| 195 | |
|
| 196 | |
|
| 197 | |
|
| 198 | |
private String recursiveFkHTMLTable() { |
| 199 | 0 | String retVal = "<TABLE border=\"1\">" + "<CAPTION><B>" + parentTable |
| 200 | |
+ "." + code + "</B></CAPTION>"; |
| 201 | 0 | retVal += "<TBODY>"; |
| 202 | 0 | retVal += "<TR><TD align=\"right\">" + "<B>name</B>" + "</TD>" |
| 203 | |
+ "<TD align=\"left\">" + name + "</TD></TR>"; |
| 204 | 0 | retVal += "<TR><TD align=\"right\">" + "<B>code</B>" + "</TD>" |
| 205 | |
+ "<TD align=\"left\">" + code + "</TD></TR>"; |
| 206 | 0 | retVal += "<TR><TD align=\"right\">" + "<B>fkColParent</B>" + "</TD>"; |
| 207 | 0 | if (fkColParent != null) { |
| 208 | 0 | retVal += "<TD>" + fkColParent.recursiveFkHTMLTable() + "</TD>"; |
| 209 | |
} |
| 210 | 0 | retVal += "</TBODY></TABLE>"; |
| 211 | 0 | return retVal; |
| 212 | |
} |
| 213 | |
|
| 214 | |
|
| 215 | |
|
| 216 | |
|
| 217 | |
|
| 218 | |
|
| 219 | |
|
| 220 | |
public void setCode(String aCode) { |
| 221 | 0 | code = aCode; |
| 222 | 0 | } |
| 223 | |
|
| 224 | |
|
| 225 | |
|
| 226 | |
|
| 227 | |
|
| 228 | |
public void setComment(String aComment) { |
| 229 | 0 | comment = aComment; |
| 230 | 0 | } |
| 231 | |
|
| 232 | |
|
| 233 | |
|
| 234 | |
|
| 235 | |
|
| 236 | |
|
| 237 | |
|
| 238 | |
public void setFkColParent(MetaColumn aFkColParent) { |
| 239 | 4 | fkColParent = aFkColParent; |
| 240 | 4 | } |
| 241 | |
|
| 242 | |
|
| 243 | |
|
| 244 | |
|
| 245 | |
|
| 246 | |
public void setJClassName(String aClassName) { |
| 247 | 0 | jClassName = aClassName; |
| 248 | 0 | } |
| 249 | |
|
| 250 | |
|
| 251 | |
|
| 252 | |
|
| 253 | |
|
| 254 | |
public void setLength(int aLength) { |
| 255 | 0 | length = aLength; |
| 256 | 0 | } |
| 257 | |
|
| 258 | |
|
| 259 | |
|
| 260 | |
|
| 261 | |
|
| 262 | |
|
| 263 | |
|
| 264 | |
public void setMandatory(boolean aMandatory) { |
| 265 | 0 | mandatory = aMandatory; |
| 266 | 0 | } |
| 267 | |
|
| 268 | |
|
| 269 | |
|
| 270 | |
|
| 271 | |
|
| 272 | |
|
| 273 | |
|
| 274 | |
public void setName(String aName) { |
| 275 | 0 | name = aName; |
| 276 | 0 | } |
| 277 | |
|
| 278 | |
|
| 279 | |
|
| 280 | |
|
| 281 | |
|
| 282 | |
public void setParentKey(MetaKey aParentKey) { |
| 283 | 5 | parentKey = aParentKey; |
| 284 | 5 | } |
| 285 | |
|
| 286 | |
|
| 287 | |
|
| 288 | |
|
| 289 | |
|
| 290 | |
|
| 291 | |
|
| 292 | |
public void setParentTable(String aParentTable) { |
| 293 | 18 | parentTable = aParentTable; |
| 294 | 18 | } |
| 295 | |
|
| 296 | |
|
| 297 | |
|
| 298 | |
|
| 299 | |
|
| 300 | |
public void setPrecision(int aPrecision) { |
| 301 | 0 | precision = aPrecision; |
| 302 | 0 | } |
| 303 | |
|
| 304 | |
|
| 305 | |
|
| 306 | |
|
| 307 | |
|
| 308 | |
|
| 309 | |
public String toString() { |
| 310 | 0 | return name; |
| 311 | |
} |
| 312 | |
|
| 313 | |
|
| 314 | |
|
| 315 | |
|
| 316 | |
|
| 317 | |
|
| 318 | |
public String toStringVerbose() { |
| 319 | 0 | String retVal = "<HTML><TABLE border=\"1\" >" |
| 320 | |
+ "<CAPTION><STRONG>" + parentTable + "." + code |
| 321 | |
+ "</STRONG></CAPTION>"; |
| 322 | 0 | retVal += "<TBODY>"; |
| 323 | 0 | retVal += "<TR><TD align=\"right\">" + "<B>name</B>" + "</TD>" |
| 324 | |
+ "<TD align=\"left\">" + name + "</TD></TR>"; |
| 325 | 0 | retVal += "<TR><TD align=\"right\">" + "<B>code</B>" + "</TD>" |
| 326 | |
+ "<TD align=\"left\">" + code + "</TD></TR>"; |
| 327 | 0 | retVal += "<TR><TD align=\"right\">" + "<B>parentTable</B>" + "</TD>" |
| 328 | |
+ "<TD align=\"left\">" + parentTable + "</TD></TR>"; |
| 329 | 0 | retVal += "<TR><TD align=\"right\">" + "<B>partOfPK</B>" + "</TD>" |
| 330 | |
+ "<TD align=\"left\">" + isPartOfPK() + "</TD></TR>"; |
| 331 | 0 | retVal += "<TR><TD align=\"right\">" + "<B>mandatory</B>" + "</TD>" |
| 332 | |
+ "<TD align=\"left\">" + mandatory + "</TD></TR>"; |
| 333 | 0 | retVal += "<TR><TD align=\"right\">" + "<B>jClassName</B>" + "</TD>" |
| 334 | |
+ "<TD align=\"left\">" + jClassName + "</TD></TR>"; |
| 335 | 0 | retVal += "<TR><TD align=\"right\">" + "<B>length</B>" + "</TD>" |
| 336 | |
+ "<TD align=\"left\">" + length + "</TD></TR>"; |
| 337 | 0 | retVal += "<TR><TD align=\"right\">" + "<B>precision</B>" + "</TD>" |
| 338 | |
+ "<TD align=\"left\">" + precision + "</TD></TR>"; |
| 339 | |
|
| 340 | 0 | retVal += "<TR><TD align=\"right\">" + "<B>defaultVal</B>" + "</TD>" |
| 341 | |
+ "<TD align=\"left\">" + defaultVal + "</TD></TR>"; |
| 342 | |
|
| 343 | 0 | retVal += "<TR><TD align=\"right\">" + "<B>value-label map</B>" |
| 344 | |
+ "</TD>"; |
| 345 | 0 | Set<Map.Entry<String, String>> entries = lhmListOfVals.entrySet(); |
| 346 | 0 | if (!lhmListOfVals.isEmpty()) { |
| 347 | 0 | retVal += "<TD><TABLE border=\"1\"><TBODY>"; |
| 348 | 0 | for (Iterator<Map.Entry<String, String>> iter = entries.iterator(); iter |
| 349 | 0 | .hasNext();) { |
| 350 | 0 | Map.Entry<String, String> entry = iter.next(); |
| 351 | 0 | retVal += "<TR><TD align=\"right\">" + "<B>value,label</B>" |
| 352 | |
+ "</TD>" + "<TD align=\"left\">" + entry.getKey() |
| 353 | |
+ "," + entry.getValue() + "</TD></TR>"; |
| 354 | 0 | } |
| 355 | 0 | retVal += "</TBODY></TABLE></TD>"; |
| 356 | |
} |
| 357 | 0 | retVal += "</TR>"; |
| 358 | 0 | retVal += "<TR><TD align=\"right\">" + "<B>comment</B>" + "</TD>" |
| 359 | |
+ "<TD align=\"left\">" |
| 360 | |
+ MetaUtils.insertHTMLBreaks(comment, 50) + "</TD></TR>"; |
| 361 | 0 | retVal += "<TR><TD align=\"right\">" + "<B>fkColParent</B>" + "</TD>"; |
| 362 | 0 | if (fkColParent != null) { |
| 363 | 0 | retVal += "<TD rowspan=\"2\">" + fkColParent.recursiveFkHTMLTable() |
| 364 | |
+ "</TD>"; |
| 365 | |
} |
| 366 | 0 | retVal += "</TBODY></TABLE></HTML>"; |
| 367 | 0 | return retVal; |
| 368 | |
} |
| 369 | |
|
| 370 | |
|
| 371 | |
|
| 372 | |
|
| 373 | |
public String getDefaultVal() { |
| 374 | 18 | return defaultVal; |
| 375 | |
} |
| 376 | |
|
| 377 | |
|
| 378 | |
|
| 379 | |
|
| 380 | |
|
| 381 | |
public void setDefaultVal(String aDefaultVal) { |
| 382 | 18 | defaultVal = aDefaultVal; |
| 383 | 18 | } |
| 384 | |
|
| 385 | |
|
| 386 | |
|
| 387 | |
|
| 388 | |
|
| 389 | |
|
| 390 | |
public Set entrySet_Value_Label() { |
| 391 | 0 | return lhmListOfVals.entrySet(); |
| 392 | |
} |
| 393 | |
|
| 394 | |
|
| 395 | |
|
| 396 | |
|
| 397 | |
|
| 398 | |
public boolean hasListOfVals() { |
| 399 | 0 | return !lhmListOfVals.isEmpty(); |
| 400 | |
} |
| 401 | |
|
| 402 | |
|
| 403 | |
|
| 404 | |
|
| 405 | |
public Object put(String aValue, String aLabel) { |
| 406 | 0 | return lhmListOfVals.put(aValue, aLabel); |
| 407 | |
} |
| 408 | |
} |