Clover Coverage Report - KS Contract Documentation Generator 0.0.1-SNAPSHOT
Coverage timestamp: Wed Dec 31 1969 19:00:00 EST
../../../../../../img/srcFileCovDistChart0.png 0% of files have more coverage
333   613   101   10.41
132   509   0.3   32
32     3.16  
1    
 
  XmlKradBaseDictionaryCreator       Line # 37 333 0% 101 497 0% 0.0
 
No Tests
 
1    /*
2    * Copyright 2011 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.osedu.org/licenses/ECL-2.0
9    *
10    * Unless required by applicable law or agreed to in writing, software
11    * distributed under the License is distributed on an "AS IS" BASIS,
12    * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13    * See the License for the specific language governing permissions and
14    * limitations under the License.
15    */
16    package org.kuali.student.contract.model.util;
17   
18    import java.io.File;
19    import java.io.FileNotFoundException;
20    import java.io.FileOutputStream;
21    import java.io.PrintStream;
22    import java.util.Collections;
23    import java.util.Date;
24    import java.util.Enumeration;
25    import java.util.List;
26    import java.util.Stack;
27   
28    import org.kuali.student.contract.model.MessageStructure;
29    import org.kuali.student.contract.model.ServiceContractModel;
30    import org.kuali.student.contract.model.XmlType;
31    import org.kuali.student.contract.writer.XmlWriter;
32   
33    /**
34    *
35    * @author nwright
36    */
 
37    public class XmlKradBaseDictionaryCreator {
38   
39    private ServiceContractModel model;
40    private ModelFinder finder;
41    private String directory;
42    private String className;
43    private XmlType xmlType;
44    private XmlWriter gwriter;
45    private XmlWriter bwriter;
46    private List<MessageStructure> messageStructures;
47   
 
48  0 toggle public XmlKradBaseDictionaryCreator(String directory,
49    ServiceContractModel model, String className) {
50  0 this.directory = directory;
51  0 this.model = model;
52  0 this.finder = new ModelFinder(this.model);
53  0 this.className = className;
54  0 this.xmlType = this.finder.findXmlType(className);
55  0 if (xmlType == null) {
56  0 throw new IllegalArgumentException(className);
57    }
58  0 this.messageStructures = this.finder.findMessageStructures(className);
59  0 if (this.messageStructures.isEmpty()) {
60  0 throw new IllegalStateException(className);
61    }
62    }
63   
 
64  0 toggle public void write() {
65  0 this.initXmlWriters();
66  0 this.writeSpringHeaderOpen(gwriter);
67  0 this.writeWarning(gwriter);
68  0 this.writeGeneratedImports(gwriter);
69  0 this.writeGeneratedObjectStructure(gwriter);
70  0 this.writeSpringHeaderClose(gwriter);
71   
72  0 this.writeSpringHeaderOpen(bwriter);
73  0 this.writeNote (bwriter);
74  0 this.writeBaseImports(bwriter);
75  0 this.writeBaseObjectStructure(bwriter);
76  0 this.writeSpringHeaderClose(bwriter);
77    }
78   
 
79  0 toggle private void initXmlWriters() {
80  0 String generatedFileName = "/ks-" + initUpper(className) + "-dictionary-generated.xml";
81  0 String baseFileName = "/ks-" + initUpper(className) + "-dictionary.xml";
82   
83  0 File dir = new File(this.directory);
84    //System.out.indentPrintln ("Writing java class: " + fileName + " to " + dir.getAbsolutePath ());
85   
86  0 if (!dir.exists()) {
87  0 if (!dir.mkdirs()) {
88  0 throw new IllegalStateException("Could not create directory "
89    + this.directory);
90    }
91    }
92   
93  0 try {
94  0 PrintStream out = new PrintStream(new FileOutputStream(this.directory + "/" + generatedFileName, false));
95  0 this.gwriter = new XmlWriter(out, 0);
96    } catch (FileNotFoundException ex) {
97  0 throw new IllegalStateException(ex);
98    }
99  0 try {
100  0 PrintStream out = new PrintStream(new FileOutputStream(this.directory + "/" + baseFileName, false));
101  0 this.bwriter = new XmlWriter(out, 0);
102    } catch (FileNotFoundException ex) {
103  0 throw new IllegalStateException(ex);
104    }
105    }
106   
 
107  0 toggle private static String initLower(String str) {
108  0 if (str == null) {
109  0 return null;
110    }
111  0 if (str.length() == 0) {
112  0 return str;
113    }
114  0 if (str.length() == 1) {
115  0 return str.toLowerCase();
116    }
117  0 return str.substring(0, 1).toLowerCase() + str.substring(1);
118    }
119   
 
120  0 toggle private static String initUpper(String str) {
121  0 if (str == null) {
122  0 return null;
123    }
124  0 if (str.length() == 0) {
125  0 return str;
126    }
127  0 if (str.length() == 1) {
128  0 return str.toUpperCase();
129    }
130  0 return str.substring(0, 1).toUpperCase() + str.substring(1);
131    }
132   
 
133  0 toggle private void writeSpringHeaderClose(XmlWriter out) {
134  0 out.decrementIndent();
135  0 out.indentPrintln("</beans>");
136    }
137   
 
138  0 toggle private void writeSpringHeaderOpen(XmlWriter out) {
139  0 out.indentPrintln("<!--");
140  0 out.indentPrintln(" Copyright 2011 The Kuali Foundation");
141  0 out.println("");
142  0 out.indentPrintln(" Licensed under the Educational Community License, Version 2.0 (the \"License\");");
143  0 out.indentPrintln(" you may not use this file except in compliance with the License.");
144  0 out.indentPrintln(" You may obtain a copy of the License at");
145  0 out.indentPrintln("");
146  0 out.indentPrintln(" http://www.opensource.org/licenses/ecl2.php");
147  0 out.println("");
148  0 out.indentPrintln(" Unless required by applicable law or agreed to in writing, software");
149  0 out.indentPrintln(" distributed under the License is distributed on an \"AS IS\" BASIS,");
150  0 out.indentPrintln(" WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.");
151  0 out.indentPrintln(" See the License for the specific language governing permissions and");
152  0 out.indentPrintln(" limitations under the License.");
153  0 out.indentPrintln("-->");
154  0 out.indentPrintln("<beans xmlns=\"http://www.springframework.org/schema/beans\"");
155  0 out.indentPrintln("xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"");
156  0 out.indentPrintln("xsi:schemaLocation=\""
157    + "http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd" + "\">");
158  0 out.println("");
159  0 out.incrementIndent();
160    }
161   
 
162  0 toggle private void writeWarning(XmlWriter out) {
163  0 out.println("");
164  0 out.indentPrintln("<!-- ********************************************************");
165  0 out.indentPrintln(" WARNING ");
166  0 out.indentPrintln(" DO NOT UPDATE THIS FILE MANUALLY");
167  0 out.indentPrintln(" This dictionary file was automatically generated on " + new Date());
168  0 out.indentPrintln(" The DictionaryGeneratorMojo reads the service contract ");
169  0 out.indentPrintln(" and creates these ks-XXXX-dictionary-generated.xml files.");
170  0 out.indentPrintln(" ");
171  0 out.indentPrintln(" If this file is out of sync with the contract re-run the mojo.");
172  0 out.indentPrintln(" ");
173  0 out.indentPrintln(" To add in additional constraints or change these default values (perhaps");
174  0 out.indentPrintln(" because the generator is not perfect) please update the corresponding ");
175  0 out.indentPrintln(" ks-XXXX-dictionary.xml instead of this one.");
176  0 out.indentPrintln("************************************************************* -->");
177    }
178   
 
179  0 toggle private void writeNote(XmlWriter out) {
180  0 out.println("");
181  0 out.indentPrintln("<!-- ********************************************************");
182  0 out.indentPrintln(" NOTE");
183  0 out.indentPrintln(" THIS FILE WAS INTENDED TO BE MODIFIED");
184  0 out.println ("");
185  0 out.indentPrintln(" While this file was originally generated on " + new Date());
186  0 out.indentPrintln(" it was intended to be subsequently modified by hand.");
187  0 out.indentPrintln(" It imports a corresponding ks-XXXX-dictionary-generated.xml file");
188  0 out.indentPrintln(" that was also automatically generated by the DictionaryCreatorMojo.");
189  0 out.indentPrintln(" This file gives you the ability to layer in addiditional definitions");
190  0 out.indentPrintln(" that are not/cannot be generated simply by reading the service contract");
191  0 out.println ("");
192  0 out.indentPrintln(" The goal is to be able to easily re-generate the ks-XXXX-dictionary-generated.xml file");
193  0 out.indentPrintln(" without affecting the manually entered additions that are coded here.");
194  0 out.indentPrintln("************************************************************* -->");
195    }
196   
 
197  0 toggle private void writeGeneratedImports(XmlWriter out) {
198  0 out.indentPrintln("<import resource=\"classpath:ks-base-dictionary.xml\"/>");
199    // TODO: only write out the ones that are used in this structure
200    // out.indentPrintln("<import resource=\"classpath:ks-RichTextInfo-dictionary.xml\"/>");
201    // out.indentPrintln("<import resource=\"classpath:ks-MetaInfo-dictionary.xml\"/>");
202    }
203   
 
204  0 toggle private void writeBaseImports(XmlWriter out) {
205  0 out.indentPrintln("<import resource=\"classpath:ks-" + initUpper(className) + "-dictionary-generated.xml\"/>");
206    }
207   
 
208  0 toggle private String stripListOffEnd(String name) {
209  0 if (name.endsWith("List")) {
210  0 return name.substring(0, name.length() - "List".length());
211    }
212  0 return name;
213    }
214   
 
215  0 toggle private void writeSubStructures(XmlType type, Stack<String> stack) {
216  0 boolean first = true;
217  0 for (MessageStructure ms : finder.findMessageStructures(type.getName())) {
218  0 XmlType st = finder.findXmlType(this.stripListOffEnd(ms.getType()));
219  0 if (st == null) {
220  0 throw new NullPointerException(ms.getType() + " does not exist in list of types with parents " + calcParents(stack));
221    }
222  0 if (!st.getPrimitive().equalsIgnoreCase(XmlType.COMPLEX)) {
223  0 continue;
224    }
225  0 if (first) {
226  0 first = false;
227  0 gwriter.indentPrintln("<ul>");
228    }
229  0 if (!stack.contains(st.getName())) {
230  0 stack.push(st.getName());
231  0 this.writeSubStructures(st, stack);
232  0 stack.pop();
233    }
234    }
235  0 if (!first) {
236  0 gwriter.indentPrintln("</ul>");
237    }
238    }
239   
 
240  0 toggle private String calcParents(Stack<String> stack) {
241  0 StringBuilder sb = new StringBuilder();
242  0 String dot = "";
243  0 Enumeration<String> en = stack.elements();
244  0 while (en.hasMoreElements()) {
245  0 sb.append(dot);
246  0 dot = ".";
247  0 sb.append(en.nextElement());
248    }
249  0 return sb.toString();
250    }
251   
 
252  0 toggle private void writeGeneratedObjectStructure(XmlWriter out) {
253    //Step 1, create the abstract structure
254  0 out.println("");
255  0 out.indentPrintln("<!-- " + className + "-->");
256  0 out.indentPrintln("<bean id=\"" + initUpper(className) + "-generated\" abstract=\"true\" parent=\"DataObjectEntry\">");
257  0 out.incrementIndent();
258  0 writeProperty("name", initLower(className));
259  0 writeProperty("objectClass", xmlType.getJavaPackage() + "." + initUpper(className));
260  0 writeProperty("objectLabel", calcObjectLabel());
261  0 writeProperty("objectDescription", xmlType.getDesc());
262  0 String titleAttribute = calcTitleAttribute();
263  0 if (titleAttribute != null) {
264  0 writeProperty("titleAttribute", titleAttribute);
265    }
266  0 out.indentPrintln("<property name=\"primaryKeys\">");
267  0 List<String> pks = calcPrimaryKeys();
268  0 if (pks != null && !pks.isEmpty()) {
269  0 out.incrementIndent();
270  0 out.indentPrintln("<list>");
271  0 out.incrementIndent();
272  0 for (String pk : pks) {
273  0 addValue(pk);
274    }
275  0 out.decrementIndent();
276  0 out.indentPrintln("</list>");
277  0 out.decrementIndent();
278    }
279  0 out.indentPrintln("</property>");
280  0 out.indentPrintln("<property name=\"attributes\">");
281  0 out.incrementIndent();
282  0 out.indentPrintln("<list>");
283  0 out.incrementIndent();
284  0 this.writeGeneratedAttributeRefBeans(className, null, new Stack<String>(), this.messageStructures, out);
285  0 out.decrementIndent();
286  0 out.indentPrintln("</list>");
287  0 out.decrementIndent();
288  0 out.indentPrintln("</property>");
289  0 out.decrementIndent();
290  0 out.indentPrintln("</bean>");
291   
292    //Step 2, loop through attributes
293  0 this.writeGeneratedAttributeDefinitions(className, null, new Stack<String>(), this.messageStructures, out);
294   
295    }
296   
 
297  0 toggle private void addValue(String value) {
298  0 gwriter.indentPrintln("<value>" + value + "</value>");
299    }
300   
 
301  0 toggle private String calcObjectLabel() {
302  0 String label = this.className;
303  0 if (label.endsWith("Info")) {
304  0 label = label.substring(0, label.length() - "Info".length());
305    }
306  0 label = initUpper(label);
307  0 return splitCamelCase(label);
308    }
309   
310    // got this from http://stackoverflow.com/questions/2559759/how-do-i-convert-camelcase-into-human-readable-names-in-java
 
311  0 toggle private static String splitCamelCase(String s) {
312  0 return s.replaceAll(
313    String.format("%s|%s|%s",
314    "(?<=[A-Z])(?=[A-Z][a-z])",
315    "(?<=[^A-Z])(?=[A-Z])",
316    "(?<=[A-Za-z])(?=[^A-Za-z])"),
317    " ");
318    }
319   
 
320  0 toggle private void writeGeneratedAttributeRefBeans(String className, String parentFieldName,
321    Stack<String> parents, List<MessageStructure> fields, XmlWriter out) {
322  0 if (parents.contains(className)) {
323  0 return;
324    }
325  0 for (MessageStructure ms : fields) {
326  0 String fieldName = calcFieldName(className, parentFieldName, ms);
327  0 out.indentPrintln("<ref bean=\"" + fieldName + "\"/>");
328    // Add complex sub-types fields
329  0 String childTypeName = this.stripListOffEnd(ms.getType());
330  0 XmlType childType = this.finder.findXmlType(childTypeName);
331  0 if (childType == null) {
332  0 throw new IllegalStateException(childTypeName);
333    }
334  0 if (childType.getPrimitive().equalsIgnoreCase(XmlType.COMPLEX)) {
335  0 parents.push(className);
336  0 List<MessageStructure> childFields = this.finder.findMessageStructures(childTypeName);
337  0 if (childFields.isEmpty()) {
338  0 throw new IllegalStateException(childTypeName);
339    }
340  0 writeGeneratedAttributeRefBeans(childTypeName, fieldName, parents, childFields, out);
341  0 parents.pop();
342    }
343    }
344    }
345   
 
346  0 toggle private void writeGeneratedAttributeDefinitions(String className, String parentFieldName,
347    Stack<String> parents, List<MessageStructure> fields, XmlWriter out) {
348  0 if (parents.contains(className)) {
349  0 return;
350    }
351  0 for (MessageStructure ms : fields) {
352  0 String fieldName = calcFieldName(className, parentFieldName, ms);
353  0 String childTypeName = this.stripListOffEnd(ms.getType());
354  0 XmlType childType = this.finder.findXmlType(childTypeName);
355  0 if (childType == null) {
356  0 throw new IllegalStateException(childTypeName);
357    }
358  0 writeGeneratedAttributeDefinition(className, parentFieldName, ms, out);
359   
360    // Add complex sub-types fields
361  0 if (childType.getPrimitive().equalsIgnoreCase(XmlType.COMPLEX)) {
362  0 parents.push(className);
363  0 List<MessageStructure> childFields = this.finder.findMessageStructures(childTypeName);
364  0 if (childFields.isEmpty()) {
365  0 throw new IllegalStateException(childTypeName);
366    }
367  0 writeGeneratedAttributeDefinitions(childTypeName, fieldName, parents, childFields, out);
368  0 parents.pop();
369    }
370    }
371    }
372   
 
373  0 toggle private void writeGeneratedAttributeDefinition(String className, String parentFieldName, MessageStructure ms, XmlWriter out) {
374   
375    //Create the abstract field
376  0 String fieldName = this.calcFieldName(className, parentFieldName, ms);
377  0 String baseKualiType = this.calcBaseKualiType(ms);
378  0 out.println("");
379  0 out.indentPrintln("<bean id=\"" + fieldName + "-generated\" abstract=\"true\" parent=\"" + baseKualiType + "\">");
380  0 out.incrementIndent();
381  0 writeProperty("name", initLower(ms.getShortName()));
382  0 if (ms.isOverriden()) {
383  0 writeProperty("shortLabel", ms.getName());
384    }
385  0 out.decrementIndent();
386    // TODO: implement maxoccurs
387    // if (isList(pd)) {
388    // addProperty("maxOccurs", "" + DictionaryConstants.UNBOUNDED, s);
389    // }
390  0 out.indentPrintln("</bean>");
391    }
392   
 
393  0 toggle private void writeBaseObjectStructure(XmlWriter out) {
394    //Step 1, create the parent bean
395  0 out.println("");
396  0 out.indentPrintln("<!-- " + className + "-->");
397  0 out.indentPrintln("<bean id=\"" + initUpper(className) + "-parent\" abstract=\"true\" parent=\"" + initUpper(className) + "-generated\">");
398  0 out.writeComment("insert any overrides to the generated object definitions here");
399  0 out.indentPrintln("</bean>");
400   
401    //Create the actual instance of the bean
402  0 out.indentPrintln("<bean id=\"" + initUpper(className) + "\" parent=\"" + initUpper(className) + "-parent\"/>");
403  0 out.println("");
404   
405    //Step 2, loop through attributes
406  0 this.writeBaseAttributeDefinitions(className, null, new Stack<String>(), this.messageStructures, out);
407   
408    }
409   
 
410  0 toggle private void writeBaseAttributeDefinitions(String className, String parentFieldName,
411    Stack<String> parents, List<MessageStructure> fields, XmlWriter out) {
412  0 if (parents.contains(className)) {
413  0 return;
414    }
415  0 for (MessageStructure ms : fields) {
416  0 String fieldName = calcFieldName(className, parentFieldName, ms);
417  0 String childTypeName = this.stripListOffEnd(ms.getType());
418  0 XmlType childType = this.finder.findXmlType(childTypeName);
419  0 if (childType == null) {
420  0 throw new IllegalStateException(childTypeName);
421    }
422  0 writeBaseAttributeDefinition(className, parentFieldName, ms, out);
423   
424    // Add complex sub-types fields
425  0 if (childType.getPrimitive().equalsIgnoreCase(XmlType.COMPLEX)) {
426  0 parents.push(className);
427  0 List<MessageStructure> childFields = this.finder.findMessageStructures(childTypeName);
428  0 if (childFields.isEmpty()) {
429  0 throw new IllegalStateException(childTypeName);
430    }
431  0 writeBaseAttributeDefinitions(childTypeName, fieldName, parents, childFields, out);
432  0 parents.pop();
433    }
434    }
435    }
436   
 
437  0 toggle private void writeBaseAttributeDefinition(String className, String parentFieldName, MessageStructure ms, XmlWriter out) {
438   
439    //Create the abstract field
440  0 String fieldName = this.calcFieldName(className, parentFieldName, ms);
441    // String baseKualiType = this.calcBaseKualiType(ms);
442  0 out.println("");
443  0 out.indentPrintln("<bean id=\"" + fieldName + "-parent\" abstract=\"true\" parent=\"" + fieldName + "-generated\">");
444  0 out.writeComment("insert any overrides to the generated attribute definitions here");
445  0 out.indentPrintln("</bean>");
446   
447    //Create the actual bean instance
448  0 out.indentPrintln("<bean id=\"" + fieldName + "\" parent=\"" + fieldName + "-parent\"/>");
449    }
450   
 
451  0 toggle private String calcBaseKualiType(MessageStructure ms) {
452   
453  0 String name = ms.getShortName();
454  0 if (name.equals("id")) {
455  0 return "BaseKuali.id";
456    }
457  0 if (name.equals("key")) {
458  0 return "BaseKuali.key";
459    }
460  0 if (name.equals("descr")) {
461  0 return "BaseKuali.descr";
462    }
463  0 if (name.equals("name")) {
464  0 return "BaseKuali.name";
465    }
466  0 if (name.equals("typeKey")) {
467  0 return "BaseKuali.typeKey";
468    }
469  0 if (name.equals("stateKey")) {
470  0 return "BaseKuali.stateKey";
471    }
472    // to handle r1 services
473  0 if (name.equals("type")) {
474  0 return "BaseKuali.typeKey";
475    }
476  0 if (name.equals("state")) {
477  0 return "BaseKuali.stateKey";
478    }
479  0 if (name.equals("effectiveDate")) {
480  0 return "BaseKuali.effectiveDate";
481    }
482  0 if (name.equals("expirationDate")) {
483  0 return "BaseKuali.expirationDate";
484    }
485  0 if (name.endsWith("orgId")) {
486  0 return "BaseKuali.orgId";
487    }
488  0 if (name.endsWith("personId")) {
489  0 return "BaseKuali.personId";
490    }
491  0 if (name.endsWith("principalId")) {
492  0 return "BaseKuali.principalId";
493    }
494  0 if (name.endsWith("cluId")) {
495  0 return "BaseKuali.cluId";
496    }
497  0 if (name.endsWith("luiId")) {
498  0 return "BaseKuali.luiId";
499    }
500  0 if (name.endsWith("Code")) {
501  0 return "BaseKuali.code";
502    }
503   
504    // now key off the type
505  0 String type = this.stripListOffEnd(ms.getType());
506  0 if (type.equalsIgnoreCase("String")) {
507  0 return "BaseKuali.string";
508    }
509  0 if (type.equalsIgnoreCase("DateTime")) {
510  0 return "BaseKuali.dateTime";
511    }
512  0 if (type.equalsIgnoreCase("Date")) {
513  0 return "BaseKuali.date";
514    }
515  0 if (type.equalsIgnoreCase("Boolean")) {
516  0 return "BaseKuali.boolean";
517    }
518  0 if (type.equalsIgnoreCase("Integer")) {
519  0 return "BaseKuali.integer";
520    }
521    // if (type.equalsIgnoreCase("Float")) {
522    // return "BaseKuali.Currency";
523    // }
524  0 if (type.equalsIgnoreCase(XmlType.COMPLEX)) {
525  0 return "BaseKuali.complex";
526    }
527    // all else fails call it a string
528  0 return "BaseKuali.string";
529   
530    }
531   
 
532  0 toggle private String calcFieldName(String className, String parentFieldName, MessageStructure ms) {
533  0 if (parentFieldName == null) {
534  0 return initUpper(className) + "." + initLower(ms.getShortName());
535    }
536  0 return parentFieldName + "." + initLower(ms.getShortName());
537    }
538   
 
539  0 toggle private String calcTitleAttribute() {
540  0 MessageStructure ms = null;
541  0 ms = this.findMessageStructure("name");
542  0 if (ms != null) {
543  0 return initLower(ms.getShortName());
544    }
545  0 ms = this.findMessageStructure("title");
546  0 if (ms != null) {
547  0 return initLower(ms.getShortName());
548    }
549  0 ms = this.findMessageStructureEndsWith("name");
550  0 if (ms != null) {
551  0 return initLower(ms.getShortName());
552    }
553  0 ms = this.findMessageStructureEndsWith("title");
554  0 if (ms != null) {
555  0 return initLower(ms.getShortName());
556    }
557  0 ms = this.findMessageStructure("key");
558  0 if (ms != null) {
559  0 return initLower(ms.getShortName());
560    }
561    // TODO: consider checking for ID and just returning null
562  0 System.out.println("XmlKradBaseDictionaryCreator: could not find a title attribute for " + this.className);
563    // ms = this.findMessageStructure("id");
564    // if (ms != null) {
565    // return initLower(ms.getShortName());
566    // }
567  0 return null;
568    }
569   
 
570  0 toggle private MessageStructure findMessageStructureEndsWith(String shortNameEndsWith) {
571  0 shortNameEndsWith = shortNameEndsWith.toLowerCase();
572  0 for (MessageStructure ms : this.messageStructures) {
573  0 if (ms.getShortName().toLowerCase().endsWith(shortNameEndsWith)) {
574  0 return ms;
575    }
576    }
577  0 return null;
578    }
579   
 
580  0 toggle private MessageStructure findMessageStructure(String shortName) {
581  0 for (MessageStructure ms : this.messageStructures) {
582  0 if (ms.getShortName().equalsIgnoreCase(shortName)) {
583  0 return ms;
584    }
585    }
586  0 return null;
587    }
588   
 
589  0 toggle private MessageStructure getMessageStructure(String shortName) {
590  0 MessageStructure ms = this.findMessageStructure(shortName);
591  0 if (ms == null) {
592  0 throw new IllegalArgumentException(shortName);
593    }
594  0 return ms;
595    }
596   
 
597  0 toggle private List<String> calcPrimaryKeys() {
598  0 MessageStructure ms = null;
599  0 ms = this.findMessageStructure("id");
600  0 if (ms != null) {
601  0 return Collections.singletonList(initLower(ms.getShortName()));
602    }
603  0 ms = this.findMessageStructure("key");
604  0 if (ms != null) {
605  0 return Collections.singletonList(initLower(ms.getShortName()));
606    }
607  0 return Collections.EMPTY_LIST;
608    }
609   
 
610  0 toggle private void writeProperty(String propertyName, String propertyValue) {
611  0 gwriter.indentPrintln("<property name=\"" + propertyName + "\" value=\"" + propertyValue + "\"/>");
612    }
613    }