1 /**
2 The contents of this file are subject to the Mozilla Public License Version 1.1
3 (the "License"); you may not use this file except in compliance with the License.
4 You may obtain a copy of the License at http://www.mozilla.org/MPL/
5 Software distributed under the License is distributed on an "AS IS" basis,
6 WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the
7 specific language governing rights and limitations under the License.
8
9 The Original Code is "DeploymentManager.java". Description:
10 "This Class Starts the build process and generates the Class files"
11
12 The Initial Developer of the Original Code is University Health Network. Copyright (C)
13 2001. All Rights Reserved.
14
15 Contributor(s): James Agnew
16 Paul Brohman
17 Mitch Delachevrotiere
18 Shawn Dyck
19 Cory Metcalf
20
21 Alternatively, the contents of this file may be used under the terms of the
22 GNU General Public License (the ?GPL?), in which case the provisions of the GPL are
23 applicable instead of those above. If you wish to allow use of your version of this
24 file only under the terms of the GPL and not to allow others to use your version
25 of this file under the MPL, indicate your decision by deleting the provisions above
26 and replace them with the notice and other provisions required by the GPL License.
27 If you do not delete the provisions above, a recipient may use your version of
28 this file under either the MPL or the GPL.
29
30 */
31 package ca.uhn.hl7v2.conf.classes.generator.builders;
32
33 import java.io.*;
34 import ca.uhn.hl7v2.conf.parser.ProfileParser;
35 import ca.uhn.hl7v2.conf.spec.*;
36 import ca.uhn.hl7v2.conf.classes.generator.genclasses.*;
37 import ca.uhn.hl7v2.conf.classes.exceptions.*;
38
39 /** This Class Starts the build process and generates the Class files
40 * @author <table><tr>James Agnew</tr>
41 * <tr>Paul Brohman</tr>
42 * <tr>Mitch Delachevrotiere</tr>
43 * <tr>Shawn Dyck</tr>
44 * <tr>Cory Metcalf</tr></table>
45 */
46 public class DeploymentManager {
47
48 private final ConformanceMessageBuilder confMsgBuilder;
49 private final FileGenerator fg;
50 private final String packageName;
51 private boolean verbose = false;
52
53 /** Creates a new instance of DeploymentManager */
54 public DeploymentManager(String dest, String packageName) {
55 this.fg = new FileGenerator(dest);
56 this.packageName = packageName;
57 this.confMsgBuilder = new ConformanceMessageBuilder(packageName);
58 }
59
60 /** This method generates a Java representation of an XML profile message
61 * @param xml an XML representation of a profile message
62 */
63 public void generate(String xml) throws ConformanceException{
64 try {
65 ProfileParserer/ProfileParser.html#ProfileParser">ProfileParser pp = new ProfileParser(false);
66 AntGeneratorsses/generator/builders/AntGenerator.html#AntGenerator">AntGenerator an = new AntGenerator();
67 RuntimeProfile spec = pp.parse(xml);
68
69 if( spec.getHL7Version() == null || spec.getHL7Version().equals("") )
70 throw new ConformanceException("Error: Runtime Profile does not specify HL7Version");
71
72 if( spec.getMessage().getMsgStructID() == null || spec.getMessage().getMsgStructID().equals("") )
73 throw new ConformanceException("Error: Runtime Profile does not specify MsgStructID");
74
75 this.confMsgBuilder.buildClass(spec, this);
76 an.createAnt(fg.getBasePath(), packageName);
77
78 } catch (ca.uhn.hl7v2.conf.ProfileException e) {
79 e.printStackTrace();
80 System.out.println(e.getCause().toString());
81 e.getCause().printStackTrace();
82 System.out.println("ProfileException: " + e.toString());
83 }
84
85 }
86
87 /** This method is used to generate a file containng the Generated Class
88 * @param gc the Generated Class
89 * @param packageName the name of the package
90 * @param filename the name to save the generated class under
91 */
92 public void generateFile(GeneratedClass gc, String packageName, String filename) {
93 //fg.storeFile(gc, filename, packageName);
94 try {
95 fg.storeFile(gc, packageName, filename);
96 } catch (IOException e) {
97 System.err.println(e.getMessage());
98 }
99 }
100
101 /** This method returns the value of the member variable verbose
102 * @return the value of the verbose flag of either true or false
103 */
104 public boolean getVerbose() {
105 return this.verbose;
106 }
107
108 /** This method sets the member variable verbose
109 * @param verbose sets verbose flag to true or false
110 */
111 public void setVerbose(boolean verbose) {
112 this.verbose = verbose;
113 }
114
115 }