View Javadoc

1   package org.apache.torque.mojo;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *   http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  
22  import java.io.File;
23  
24  import org.apache.commons.configuration.PropertiesConfiguration;
25  import org.apache.maven.plugin.MojoExecutionException;
26  import org.apache.tools.ant.BuildException;
27  import org.apache.torque.task.TorqueDataModelTask;
28  
29  /**
30   * Generates the sources for the persistence classes from the schema.xml files.
31   *
32   * @author Raphael Pieroni (rafale_at_codehaus.org)
33   * @author <a href="fischer@seitenbau.de">Thomas Fischer</a>
34   *
35   * @goal om
36   * @phase generate-sources
37   */
38  public class OMMojo
39          extends DataModelTaskMojo
40  {
41      // The following dummies trick the Mojo Description Extractor
42      // into setting the correct default values for
43      // outputDir, reportFile, contextPropertiesPath, schemaExcludes
44      /**
45       * The directory in which the sources for the non-base persistence classes
46       * will be generated.
47       *
48       * @parameter property="outputDir"
49       *            expression="${project.build.sourceDirectory}/../generated-java"
50       */
51      private String dummy;
52  
53      /**
54       * The location where the report file for the non-base persistence classes 
55       * will be generated.
56       *
57       * @parameter property="reportFile"
58       *            expression="../../../target/torque/report.${project.artifact.artifactId}.om.generation"
59       */
60      private String dummy2;
61  
62      /**
63       * The location where the context property file for velocity will be
64       * generated.
65       *
66       * @parameter property="contextPropertiesPath"
67       *            expression="${project.build.directory}/torque/context.om.properties"
68       */
69      private String dummy3;
70  
71      /**
72       * The schema files which should be excluded in generation
73       * (in ant-style notation).
74       *
75       * @parameter property="schemaExcludes" expression="id-table-schema.xml"
76       */
77      private String dummy4;
78  
79      /**
80       * The directory where the sources for the base persistence classes
81       * will be generated. 
82       *
83       * @parameter expression="${project.build.directory}/generated-sources/torque"
84       */
85      private String baseOutputDir;
86  
87      /**
88       * The location where the report file for the base persistence classes
89       * will be generated.
90       *
91       * @parameter expression="../../torque/report.${project.artifact.artifactId}.om.base.generation"
92       */
93      private String baseReportFile;
94  
95      /**
96       * The context property for the target package.
97       */
98      public static final String TARGET_PACKAGE_CONTEXT_PROPERTY
99              = "targetPackage";
100 
101     /**
102      * The context property for the prefix of the class name for
103      * the generated base classes,
104      */
105     public static final String BASE_PREFIX_CONTEXT_PROPERTY
106             = "basePrefix";
107 
108     /**
109      * The context property which determines the name suffix of
110      * generated bean classes.
111      */
112     public static final String BEAN_SUFFIX_CONTEXT_PROPERTY
113             = "beanSuffix";
114 
115     /**
116      * The context property which determines the fully qualifed
117      * class name that the base beans will extend.
118      */
119     public static final String BEAN_EXTENDS_CLASS_PROPERTY
120             = "beanExtendsClass";
121 
122     /**
123      * The context property for the subpackage of the generated
124      * database Map classes.
125      */
126     public static final String SUBPACKAGE_MAP_CONTEXT_PROPERTY
127             = "subpackageMap";
128 
129     /**
130      * The context property for the subpackage of the generated
131      * base Object, Peer, and Manager classes.
132      */
133     public static final String SUBPACKAGE_BASE_CONTEXT_PROPERTY
134             = "subpackageBase";
135 
136     /**
137      * The context property for the subpackage of the generated
138      * base bean classes.
139      */
140     public static final String SUBPACKAGE_BASE_BEAN_CONTEXT_PROPERTY
141             = "subpackageBaseBean";
142 
143     /**
144      * The context property for the subpackage of the generated
145      * bean classes.
146      */
147     public static final String SUBPACKAGE_BEAN_CONTEXT_PROPERTY
148             = "subpackageBean";
149 
150     /**
151      * The context property for the subpackage of the generated
152      * manager classes.
153      */
154     public static final String SUBPACKAGE_MANAGER_CONTEXT_PROPERTY
155             = "subpackageManager";
156 
157     /**
158      * The context property for the subpackage of the generated
159      * data object classes.
160      */
161     public static final String SUBPACKAGE_OBJECT_CONTEXT_PROPERTY
162             = "subpackageObject";
163 
164     /**
165      * The context property for the subpackage of the generated
166      * peer classes.
167      */
168     public static final String SUBPACKAGE_PEER_CONTEXT_PROPERTY
169             = "subpackagePeer";
170 
171     /**
172      * The context property where the generation of the getByName-
173      * Methods can be turned on and off.
174      */
175     public static final String ADD_GET_BY_NAME_METHOD_CONTEXT_PROPERTY
176             = "addGetByNameMethod";
177 
178     /**
179      * The context property where it is configured whether the
180      * data objects implement a Retrievable interface.
181      */
182     public static final String ADD_INTAKE_RETRIEVABLE_CONTEXT_PROPERTY
183             = "addIntakeRetrievable";
184 
185     /**
186      * The context property where it is configured whether the
187      * data objects implement a Retrievable interface.
188      */
189     public static final String RETRIEVABLE_INTERFACE_CONTEXT_PROPERTY
190             = "retrievableInterface";
191 
192     /**
193      * The context property where the generation of the save
194      * methods can be turned on and off.
195      */
196     public static final String ADD_SAVE_METHOD_CONTEXT_PROPERTY
197             = "addSaveMethod";
198 
199     /**
200      * The context property where the exception thown by save methods
201      * can be configured.
202      */
203     public static final String SAVE_EXCEPTION_CONTEXT_PROPERTY
204             = "saveException";
205 
206     /**
207      * The context property where it is configured whether methods
208      * are generated to easily retrieve foreign key relationships.
209      */
210     public static final String COMPLEX_OBJECT_MODEL_CONTEXT_PROPERTY
211             = "complexObjectModel";
212 
213     /**
214      * The context property which determines whether empty cached
215      * foreign key relations should be filled automatically.
216      */
217     public static final String SILENT_DB_FETCH_CONTEXT_PROPERTY
218             = "silentDbFetch";
219 
220     /**
221      * The context property which determines whether manager classes
222      * are generated.
223      */
224     public static final String USE_MANAGERS_CONTEXT_PROPERTY
225             = "useManagers";
226 
227     /**
228      * The context property which determines whether foreign key relationships
229      * are cached.
230      */
231     public static final String OBJECT_IS_CACHING_CONTEXT_PROPERTY
232             = "objectIsCaching";
233 
234     /**
235      * The context property which determines whether isXXX methods are
236      * generated for boolean properties instead of getXXX methods.
237      */
238     public static final String CORRECT_GETTERS_CONTEXT_PROPERTY
239             = "correctGetters";
240 
241     /**
242      * The context property which determines whether java5 generics
243      * and easy iteration are used in generated code.
244      */
245     public static final String ENABLE_JAVA_5_FEATURES_CONTEXT_PROPERTY
246             = "enableJava5Features";
247 
248     /**
249      * The context property which determines whether time stamps are put
250      * into generated files.
251      */
252     public static final String ADD_TIME_STAMP_CONTEXT_PROPERTY
253             = "addTimeStamp";
254 
255     /**
256      * The context property which determines whether bean classes
257      * should be generated.
258      */
259     public static final String GENERATE_BEANS_CONTEXT_PROPERTY
260             = "generateBeans";
261 
262     /**
263      * The prefix for the base classes.
264      *
265      * @parameter expression="Base"
266      */
267     private String basePrefix;
268 
269     /**
270      * The suffix for the class name of the bean classes.
271      *
272      * @parameter expression="Bean"
273      */
274     private String beanSuffix;
275 
276     /**
277      * A fully qualified class name that the generated base bean class will
278      * extend.
279      *
280      * @parameter expression=""
281      */
282     private String beanExtendsClass;
283 
284     /**
285      * The subpackage (relative to <code>targetPackage</code>
286      * where Torque will put the generated Java classes for the database map.
287      *
288      * @parameter expression="map"
289      */
290 
291     private String subpackageMap;
292 
293     /**
294      * The subpackage (relative to <code>targetPackage</code>)
295      * where Torque will put the generated Peer Java classes.
296      * If not set, the Peer classes will be generated in
297      * <code>targetPackage</code>.
298      *
299      * @parameter
300      */
301     private String subpackagePeer;
302 
303     /**
304      * The subpackage (relative to <code>targetPackage</code>)
305      * where Torque will put the generated data object Java classes.
306      * If not set, the object classes will be generated in
307      * <code>targetPackage</code>.
308      *
309      * @parameter
310      */
311     private String subpackageObject;
312 
313     /**
314      * The subpackage (relative to <code>targetPackage</code>)
315      * where Torque will put the generated Java Manager classes,
316      * if they are generated at all.
317      * If not set, the Manager classes will be generated in
318      * <code>targetPackage</code>.
319      *
320      * @parameter
321      */
322     private String subpackageManager;
323 
324     /**
325      * The subpackage (relative to <code>targetPackage</code>)
326      * where Torque will put the generated JavaBean classes,
327      * if they are generated at all.
328      *
329      * @parameter expression="bean"
330      */
331     private String subpackageBean;
332 
333     /**
334      * The subpackage (relative to <code>targetPackage</code>)
335      * where Torque will put the generated BaseObject, BasePeer,
336      * (and BaseManager, if they are generated at all) Java classes.
337      * If not set, the Base classes will be generated in
338      * <code>targetPackage</code>.
339      *
340      * @parameter
341      */
342     private String subpackageBase;
343 
344     /**
345      * The subpackage (relative to <code>targetPackage</code>)
346      * where Torque will put the generated BaseBean Java classes,
347      * if they are generated at all.
348      *
349      * @parameter expression="bean"
350      */
351     private String subpackageBaseBean;
352 
353     /**
354      * If true, Torque adds methods to get database fields by name/position.
355      *
356      * @parameter expression="true"
357      */
358     private boolean addGetByNameMethod;
359 
360     /**
361      * If true, the data objects will implement a Retrievable interface.
362      *
363      * @parameter expression="false"
364      */
365     private boolean addRetrievableInterface;
366 
367     /**
368      * The fully qualified class name of the retrievable interface
369      * to be implemented by the data objects.
370      *
371      * @parameter expression="org.apache.turbine.om.Retrievable"
372      */
373     private String retrievableInterface;
374 
375     /**
376      * Determines whether save()-Methods should be added to the data objects.
377      *
378      * @parameter expression="true"
379      */
380     private boolean addSaveMethod;
381 
382     /**
383      * Defines which Exception should be thrown by the Object.save() method.
384      *
385      * @parameter expression="Exception"
386      */
387     private String saveException;
388 
389     /**
390      * Determines whether a time stamp and a serialVersionUID will be
391      * added to generated objects.
392      *
393      * @parameter expression="true"
394      */
395     private boolean addTimeStamp;
396 
397     /**
398      * If true, Torque generates data objects with collection support
399      * and methods to easily retrieve foreign key relationships.
400      *
401      * @parameter expression="true"
402      */
403     private boolean complexObjectModel;
404 
405     /**
406      * If true, Torque will generate Manager classes that use JCS for caching.
407      *
408      * @parameter expression="false"
409      */
410     private boolean useManagers;
411 
412     /**
413      * If true, Torque generates data objects that cache their foreign key
414      * relationships.
415      *
416      * @parameter expression="true"
417      */
418     private boolean objectIsCaching;
419 
420     /**
421      * If true and objectIsCaching is true, Torque silently fetches
422      * foreign key relation collections if the collection is not yet
423      * initialized.
424      *
425      * @parameter expression="true"
426      */
427     private boolean silentDbFetch;
428 
429     /**
430      * If true, Torque generates isXXX getter methods for boolean columns.
431      *
432      * @parameter expression="false"
433      */
434     private boolean correctGetters;
435 
436     /**
437      * If true, Torque generates a bean object for each data object,
438      * plus methods to convert data objects to beans and vice versa.
439      *
440      * @parameter expression="false"
441      */
442     private boolean generateBeans;
443 
444     /**
445      * Whether Java5 generics and iteration shorthand should be used
446      * in generated code.
447      *
448      * @parameter expression="false"
449      */
450     private boolean enableJava5Features;
451 
452     /**
453      * The control template which should be used by the Texen task. 
454      */
455     private String controlTemplate;
456 
457     /**
458      * Creates a new TorqueOMMojo object.
459      */
460     public OMMojo()
461     {
462     }
463 
464     /**
465      * Generates the OM classes for a Torque project and adds them to
466      * the compile sources of the project.
467      *
468      * @throws MojoExecutionException If an error occurs during generation.
469      *
470      * @see TexenTaskMojo#execute()
471      * @see org.apache.maven.plugin.Mojo#execute()
472      */
473     public void execute() throws MojoExecutionException
474     {
475         // generate non-base classes
476         controlTemplate = "om/Control.vm";
477         super.execute();
478         String outputDir = super.getOutputDir();
479         String reportFile = super.getReportFile();
480         try
481         {
482             File outputDirectory = new File(outputDir);
483             getLog().info ("torque non-base java sources generated into: "
484                     + outputDirectory.getAbsolutePath());
485 
486             if (getProject() != null)
487             {
488                 getProject().addCompileSourceRoot(
489                         outputDirectory.getPath());
490             }
491         }
492         catch (BuildException e)
493         {
494             getLog().error(e.getMessage());
495             throw new MojoExecutionException(e.getMessage(), e);
496         }
497 
498         // generate base classes
499         // reset texen task (for an unknown reason, the old texen task will
500         // append the already generated output to the already generated files
501         super.setGeneratorTask(new TorqueDataModelTask());
502         controlTemplate = "om/ControlBase.vm";
503         super.setOutputDir(baseOutputDir);
504         super.setReportFile(baseReportFile);
505         super.execute();
506         super.setOutputDir(outputDir);
507         super.setReportFile(reportFile);
508         
509         try
510         {
511             File baseOutputDirectory = new File(baseOutputDir);
512             getLog().info ("torque base java sources generated into: "
513                     + baseOutputDirectory.getAbsolutePath());
514 
515             if (getProject() != null)
516             {
517                 getProject().addCompileSourceRoot(
518                         baseOutputDirectory.getPath());
519             }
520         }
521         catch (BuildException e)
522         {
523             getLog().error(e.getMessage());
524             throw new MojoExecutionException(e.getMessage(), e);
525         }
526     }
527 
528     /**
529      * Returns the path to the control template.
530      *
531      * @return the path to the current control template.
532      */
533     protected String getControlTemplate()
534     {
535         return controlTemplate;
536     }
537 
538     /**
539      * Returns the context properties for the Texen task.
540      *
541      * @return The PropertiesConfiguration containing all context properties,
542      *         not null.
543      */
544     protected PropertiesConfiguration getMojoContextProperties()
545     {
546         PropertiesConfiguration configuration = new PropertiesConfiguration();
547         configuration.addProperty(
548                 TARGET_DATABASE_CONTEXT_PROPERTY,
549                 super.getTargetDatabase());
550 
551         configuration.addProperty(
552                 TARGET_PACKAGE_CONTEXT_PROPERTY,
553                 getTargetPackage());
554 
555         configuration.addProperty(
556                 BASE_PREFIX_CONTEXT_PROPERTY,
557                 basePrefix);
558 
559         configuration.addProperty(
560                 SUBPACKAGE_MAP_CONTEXT_PROPERTY,
561                 subpackageMap);
562 
563         configuration.addProperty(
564                 SUBPACKAGE_BASE_CONTEXT_PROPERTY,
565                 subpackageBase);
566 
567         configuration.addProperty(
568                 SUBPACKAGE_BASE_BEAN_CONTEXT_PROPERTY,
569                 subpackageBaseBean);
570 
571         configuration.addProperty(
572                 SUBPACKAGE_BEAN_CONTEXT_PROPERTY,
573                 subpackageBean);
574 
575         configuration.addProperty(
576                 SUBPACKAGE_MANAGER_CONTEXT_PROPERTY,
577                 subpackageManager);
578 
579         configuration.addProperty(
580                 SUBPACKAGE_OBJECT_CONTEXT_PROPERTY,
581                 subpackageObject);
582 
583         configuration.addProperty(
584                 SUBPACKAGE_PEER_CONTEXT_PROPERTY,
585                 subpackagePeer);
586 
587         configuration.addProperty(
588                 ADD_GET_BY_NAME_METHOD_CONTEXT_PROPERTY,
589                 Boolean.toString(addGetByNameMethod));
590 
591         configuration.addProperty(
592                 ADD_INTAKE_RETRIEVABLE_CONTEXT_PROPERTY,
593                 Boolean.toString(addRetrievableInterface));
594 
595         configuration.addProperty(
596                 RETRIEVABLE_INTERFACE_CONTEXT_PROPERTY,
597                 retrievableInterface);
598 
599         configuration.addProperty(
600                 ADD_SAVE_METHOD_CONTEXT_PROPERTY,
601                 Boolean.toString(addSaveMethod));
602 
603         configuration.addProperty(
604                 ADD_TIME_STAMP_CONTEXT_PROPERTY,
605                 Boolean.toString(addTimeStamp));
606 
607         configuration.addProperty(
608                 BEAN_SUFFIX_CONTEXT_PROPERTY,
609                 beanSuffix);
610 
611         configuration.addProperty(
612                 BEAN_EXTENDS_CLASS_PROPERTY,
613                 beanExtendsClass);
614 
615         configuration.addProperty(
616                 GENERATE_BEANS_CONTEXT_PROPERTY,
617                 Boolean.toString(generateBeans));
618 
619         configuration.addProperty(
620                 COMPLEX_OBJECT_MODEL_CONTEXT_PROPERTY,
621                 Boolean.toString(complexObjectModel));
622 
623         configuration.addProperty(
624                 CORRECT_GETTERS_CONTEXT_PROPERTY,
625                 Boolean.toString(correctGetters));
626 
627         configuration.addProperty(
628                 ENABLE_JAVA_5_FEATURES_CONTEXT_PROPERTY,
629                 Boolean.toString(enableJava5Features));
630 
631         configuration.addProperty(
632                 OBJECT_IS_CACHING_CONTEXT_PROPERTY,
633                 Boolean.toString(objectIsCaching));
634 
635         configuration.addProperty(
636                 SAVE_EXCEPTION_CONTEXT_PROPERTY,
637                 saveException);
638 
639         configuration.addProperty(
640                 SILENT_DB_FETCH_CONTEXT_PROPERTY,
641                 Boolean.toString(silentDbFetch));
642 
643         configuration.addProperty(
644                 USE_MANAGERS_CONTEXT_PROPERTY,
645                 Boolean.toString(useManagers));
646 
647         return configuration;
648     }
649 
650     /**
651      * Returns the prefix for the base classes.
652      *
653      * @return the prefix for the base classes.
654      */
655     public String getBasePrefix()
656     {
657         return basePrefix;
658     }
659 
660     /**
661      * Sets the prefix for the names of the base classes.
662      *
663      * @param basePrefix the prefix for the base classes.
664      */
665     public void setBasePrefix(String basePrefix)
666     {
667         this.basePrefix = basePrefix;
668     }
669 
670     /**
671      * Returns the suffix for the names of the bean classes.
672      *
673      * @return the suffix for the bean classes.
674      */
675     public String getBeanSuffix()
676     {
677         return beanSuffix;
678     }
679 
680     /**
681      * Sets the optional fully qualified class name that the
682      * generated base bean classes will extend.
683      *
684      * @param beanExtendsClass the fully qualified class or 
685      *          null/"" if none is used.
686      */
687     public void setBeanExtendsClass(String beanExtendsClass)
688     {
689         this.beanExtendsClass = beanExtendsClass;
690     }
691 
692     /**
693      * Returns the fully qualified class that the generated base bean
694      * classes will extend.
695      *
696      * @return the fully qualified class or null/"" if none is used.
697      */
698     public String getBeanExtendsClass()
699     {
700         return beanExtendsClass;
701     }
702 
703     /**
704      * Sets the suffix for the names of the bean classes.
705      *
706      * @param beanSuffix the suffix for the bean classes.
707      */
708     public void setBeanSuffix(String beanSuffix)
709     {
710         this.beanSuffix = beanSuffix;
711     }
712 
713     /**
714      * Gets the subpackage for the database map classes.
715      *
716      * @return the subpackage for the database map classes.
717      */
718     public String getSubpackageMap()
719     {
720         return subpackageMap;
721     }
722 
723     /**
724      * Sets the subpackage for the database map classes.
725      *
726      * @param subpackageMap the subpackage for the database map classes.
727      */
728     public void setSubpackageMap(String subpackageMap)
729     {
730         this.subpackageMap = subpackageMap;
731     }
732 
733     /**
734      * Gets the subpackage for the base Object, Peer, and Manager classes.
735      *
736      * @return the subpackage for the base Object, Peer, and Manager classes,
737      *         or null if not set.
738      */
739     public String getSubpackageBase()
740     {
741         return subpackageBase;
742     }
743 
744     /**
745      * Sets the subpackage for the base Object, Peer, and Manager classes.
746      *
747      * @param subpackageBase the subpackage for the base Object, Peer,
748      *        and Manager classes.
749      */
750     public void setSubpackageBase(String subpackageBase)
751     {
752         this.subpackageBase = subpackageBase;
753     }
754 
755     /**
756      * Gets the subpackage for the base peer, object, and manager classes.
757      *
758      * @return the subpackage for the base peer, object, and manager classes,
759      *         or null if not set.
760      */
761     public String getSubpackageBaseBean()
762     {
763         return subpackageBaseBean;
764     }
765 
766     /**
767      * Sets the subpackage for the base bean classes.
768      *
769      * @param subpackageBaseBean the subpackage for the base bean classes.
770      */
771     public void setSubpackageBaseBean(String subpackageBaseBean)
772     {
773         this.subpackageBaseBean = subpackageBaseBean;
774     }
775 
776     /**
777      * Gets the subpackage for the bean classes.
778      *
779      * @return the subpackage for the bean classes.
780      */
781     public String getSubpackageBean()
782     {
783         return subpackageBean;
784     }
785 
786     /**
787      * Sets the subpackage for the bean classes.
788      *
789      * @param subpackageBean the subpackage for the bean classes.
790      */
791     public void setSubpackageBean(String subpackageBean)
792     {
793         this.subpackageBean = subpackageBean;
794     }
795 
796     /**
797      * Gets the subpackage for the manager classes.
798      *
799      * @return the subpackage for the manager classes, or null if not set.
800      */
801     public String getSubpackageManager()
802     {
803         return subpackageManager;
804     }
805 
806     /**
807      * Sets the subpackage for the manager classes.
808      *
809      * @param subpackageManager the subpackage for the manager classes.
810      */
811     public void setSubpackageManager(String subpackageManager)
812     {
813         this.subpackageManager = subpackageManager;
814     }
815 
816     /**
817      * Gets the subpackage for the data object classes.
818      *
819      * @return the subpackage for the data object classes.
820      */
821     public String getSubpackageObject()
822     {
823         return subpackageObject;
824     }
825 
826     /**
827      * Sets the subpackage for the data object classes.
828      *
829      * @param subpackageObject the subpackage for the data object classes.
830      */
831     public void setSubpackageObject(String subpackageObject)
832     {
833         this.subpackageObject = subpackageObject;
834     }
835 
836     /**
837      * Gets the subpackage for the peer classes.
838      *
839      * @return the subpackage for the peer classes, or null if not set.
840      */
841     public String getSubpackagePeer()
842     {
843         return subpackagePeer;
844     }
845 
846     /**
847      * Sets the subpackage for the peer classes.
848      *
849      * @param subpackagePeer the subpackage for the peer classes.
850      */
851     public void setSubpackagePeer(String subpackagePeer)
852     {
853         this.subpackagePeer = subpackagePeer;
854     }
855 
856     /**
857      * Returns whether Torque adds methods to get database fields
858      * by name/position.
859      *
860      * @return true if Torque adds methods to get database fields
861      *         by name/position, false otherwise.
862      */
863     public boolean isAddGetByNameMethod()
864     {
865         return addGetByNameMethod;
866     }
867 
868     /**
869      * Sets whether Torque should add methods to get database fields
870      * by name/position.
871      *
872      * @param addGetByNameMethod whether Torque should add methods to get
873      *        database fields by name/position.
874      */
875     public void setAddGetByNameMethod(boolean addGetByNameMethod)
876     {
877         this.addGetByNameMethod = addGetByNameMethod;
878     }
879 
880     /**
881      * Returns whether the data objects will implement an Retrievable interface.
882      *
883      * @return true if the data objects will implement an Retrievable interface,
884      *         false otherwise.
885      */
886     public boolean isAddRetrievableInterface()
887     {
888         return addRetrievableInterface;
889     }
890 
891     /**
892      * Sets whether the data objects should implement an Retrievable interface.
893      *
894      * @param addRetrievableInterface whether the data objects should implement
895      *        a Retrievable interface.
896      */
897     public void setAddRetrievableInterface(boolean addRetrievableInterface)
898     {
899         this.addRetrievableInterface = addRetrievableInterface;
900     }
901 
902     /**
903      * Returns whether Torque will add save methods to the data objects.
904      *
905      * @return true if Torque will add save methods to the data objects,
906      *         false otherwise.
907      */
908     public boolean isAddSaveMethod()
909     {
910         return addSaveMethod;
911     }
912 
913     /**
914      * Sets whether Torque should add save methods to the data objects.
915      *
916      * @param addSaveMethod whether Torque should add save methods to the
917      *        data objects.
918      */
919     public void setAddSaveMethod(boolean addSaveMethod)
920     {
921         this.addSaveMethod = addSaveMethod;
922     }
923 
924     /**
925      * Returns whether Torque puts time stamps in generated om files.
926      *
927      * @return true if Torque puts time stamps in generated om files,
928      *         false otherwise.
929      */
930     public boolean isAddTimeStamp()
931     {
932         return addTimeStamp;
933     }
934 
935     /**
936      * Sets whether Torque puts time stamps in generated om files.
937      *
938      * @param addTimeStamp whether Torque puts time stamps in generated
939      *        om files.
940      */
941     public void setAddTimeStamp(boolean addTimeStamp)
942     {
943         this.addTimeStamp = addTimeStamp;
944     }
945 
946     /**
947      * Returns whether Torque generates data objects with collection support
948      * and methods to easily retrieve foreign key relationships.
949      *
950      * @return true if Torque generates data objects with collection support
951      *         and methods to easily retrieve foreign key relationships,
952      *         false otherwise.
953      */
954     public boolean isComplexObjectModel()
955     {
956         return complexObjectModel;
957     }
958 
959     /**
960      * Sets whether Torque generates data objects with collection support
961      * and methods to easily retrieve foreign key relationships.
962      *
963      * @param complexObjectModel whether Torque generates data objects
964      *        with collection support and methods to easily retrieve
965      *        foreign key relationships, false otherwise.
966      */
967     public void setComplexObjectModel(boolean complexObjectModel)
968     {
969         this.complexObjectModel = complexObjectModel;
970     }
971 
972     /**
973      * Returns whether Torque generates isXXX getter methods for boolean
974      * columns.
975      *
976      * @return true if Torque generates isXXX getter methods for boolean
977      *         columns, false if Torque generates getXXX getter methods
978      *         for boolean columns.
979      */
980     public boolean isCorrectGetters()
981     {
982         return correctGetters;
983     }
984 
985     /**
986      * Sets whether Torque generates isXXX getter methods for boolean
987      * columns.
988      *
989      * @param correctGetters true if Torque generates isXXX getter methods
990      *        for boolean columns, false if Torque generates getXXX getter
991      *        methods for boolean columns.
992      */
993     public void setCorrectGetters(boolean correctGetters)
994     {
995         this.correctGetters = correctGetters;
996     }
997 
998     /**
999      * Returns whether Java5 generics and iteration shorthand will be used
1000      * in generated code.
1001      *
1002      * @return true if Java5 generics and iteration shorthand will be used
1003      *         in generated code, false to generate 1.4-compliant code.
1004      */
1005     public boolean isEnableJava5Features()
1006     {
1007         return enableJava5Features;
1008     }
1009 
1010     /**
1011      * Sets whether Java5 generics and iteration shorthand should be used
1012      * in generated code.
1013      *
1014      * @param enableJava5Features true if Java5 generics and iteration
1015      *        shorthand will be used in generated code, false to generate
1016      *        1.4-compliant code.
1017      */
1018     public void setEnableJava5Features(boolean enableJava5Features)
1019     {
1020         this.enableJava5Features = enableJava5Features;
1021     }
1022 
1023     /**
1024      * Returns  whether bean classes will be generated.
1025      *
1026      * @return true if bean classes will be generated, false otherwise.
1027      */
1028     public boolean isGenerateBeans()
1029     {
1030         return generateBeans;
1031     }
1032 
1033     /**
1034      * Sets whether bean classes should be generated.
1035      *
1036      * @param generateBeans whether bean classes should be generated.
1037      */
1038     public void setGenerateBeans(boolean generateBeans)
1039     {
1040         this.generateBeans = generateBeans;
1041     }
1042 
1043     /**
1044      * Returns whether data objects cache their foreign key relationships.
1045      *
1046      * @return true if data objects cache their foreign key relationships,
1047      *         false otherwise.
1048      */
1049     public boolean isObjectIsCaching()
1050     {
1051         return objectIsCaching;
1052     }
1053 
1054     /**
1055      * Sets whether data objects cache their foreign key relationships.
1056      *
1057      * @param objectIsCaching true if data objects cache their
1058      *        foreign key relationships, false otherwise.
1059      */
1060     public void setObjectIsCaching(boolean objectIsCaching)
1061     {
1062         this.objectIsCaching = objectIsCaching;
1063     }
1064 
1065     /**
1066      * Returns the fully qualified class name of the Retrievable interface
1067      * which should be implemented by the generated data objects.
1068      *
1069      * @return the fully qualified class name of the Retrievable interface.
1070      */
1071     public String getRetrievableInterface()
1072     {
1073         return retrievableInterface;
1074     }
1075 
1076     /**
1077      * Sets the fully qualified class name of the Retrievable interface
1078      * which should be implemented by the generated data objects.
1079      *
1080      * @param retrievableInterface the fully qualified class name of the
1081      *        Retrievable interface.
1082      */
1083     public void setRetrievableInterface(String retrievableInterface)
1084     {
1085         this.retrievableInterface = retrievableInterface;
1086     }
1087 
1088     /**
1089      * Returns the class name of the Exception which should be thrown
1090      * by the save methods of the generated data objects.
1091      *
1092      * @return the class name of the Exception which should be thrown
1093      *         by the generated save methods.
1094      */
1095     public String getSaveException()
1096     {
1097         return saveException;
1098     }
1099 
1100     /**
1101      * Sets the class name of the Exception which should be thrown
1102      * by the save methods of the generated data objects.
1103      *
1104      * @param saveException the class name of the Exception
1105      *        which should be thrown by the generated save methods.
1106      */
1107     public void setSaveException(String saveException)
1108     {
1109         this.saveException = saveException;
1110     }
1111 
1112     /**
1113      * Returns whether Torque silently fetches foreign key relation collections
1114      * if the collection is not yet initialized.
1115      *
1116      * @return true if Torque silently fetches foreign key relation collections
1117      *         if the collection is not yet initialized, false otherwise.
1118      */
1119     public boolean isSilentDbFetch()
1120     {
1121         return silentDbFetch;
1122     }
1123 
1124     /**
1125      * Sets whether Torque should silently fetches foreign key relation
1126      * collections if the collection is not yet initialized.
1127      *
1128      * @param silentDbFetch whether Torque should silently fetch
1129      *        foreign key relation collections if the collection
1130      *        is not yet initialized.
1131      */
1132     public void setSilentDbFetch(boolean silentDbFetch)
1133     {
1134         this.silentDbFetch = silentDbFetch;
1135     }
1136 
1137     /**
1138      * Returns whether Torque will generate Manager classes that use JCS
1139      * for caching.
1140      *
1141      * @return true if Torque will generate Manager classes that use JCS
1142      *         for caching, false otherwise.
1143      */
1144     public boolean isUseManagers()
1145     {
1146         return useManagers;
1147     }
1148 
1149     /**
1150      * Sets whether Torque should generate Manager classes that use JCS
1151      * for caching.
1152      *
1153      * @param useManagers whether Torque should generate Manager classes
1154      *        that use JCS for caching.
1155      */
1156     public void setUseManagers(boolean useManagers)
1157     {
1158         this.useManagers = useManagers;
1159     }
1160 
1161     /**
1162      * Returns where the sources for the persistence base classes
1163      * will be generated.
1164      *
1165      * @return where the sources for the persistence base classes
1166      *          will be generated.
1167      */
1168     public String getBaseOutputDir()
1169     {
1170         return baseOutputDir;
1171     }
1172 
1173     /**
1174      * Sets where the sources for the persistence base classes
1175      * will be generated.
1176      *
1177      * @param baseOutputDir where the sources for the persistence base classes
1178      *         will be generated.
1179      */
1180     public void setBaseOutputDir(String baseOutputDir)
1181     {
1182         this.baseOutputDir = baseOutputDir;
1183     }
1184 
1185     /**
1186      * Returns the location where the report file for the base persistence
1187      * classes will be generated.
1188      *
1189      * @return the location where the report file for the base persistence
1190      *          classes will be generated.
1191      */
1192     public String getBaseReportFile()
1193     {
1194         return baseReportFile;
1195     }
1196 
1197     /**
1198      * Sets the location where the report file for the base persistence
1199      * classes will be generated.
1200      *
1201      * @param baseReportFile the location where the report file for the
1202      *         base persistence classes will be generated.
1203      */
1204     public void setBaseReportFile(String baseReportFile)
1205     {
1206         this.baseReportFile = baseReportFile;
1207     }
1208 }