01: // THIS SOFTWARE IS PROVIDED BY SOFTARIS PTY.LTD. AND OTHER METABOSS
02: // CONTRIBUTORS ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING,
03: // BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
04: // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SOFTARIS PTY.LTD.
05: // OR OTHER METABOSS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
06: // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
07: // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
08: // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
09: // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
10: // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
11: // EVEN IF SOFTARIS PTY.LTD. OR OTHER METABOSS CONTRIBUTORS ARE ADVISED OF THE
12: // POSSIBILITY OF SUCH DAMAGE.
13: //
14: // Copyright 2000-2005 © Softaris Pty.Ltd. All Rights Reserved.
15: package com.metaboss.sdlctools.applications.anttasks.convertors;
16:
17: import java.io.File;
18: import java.util.Properties;
19:
20: import org.apache.tools.ant.BuildException;
21:
22: import com.metaboss.sdlctools.applications.anttasks.MetaBossTask;
23: import com.metaboss.sdlctools.applications.anttasks.AntMetaBossUtils;
24: import com.metaboss.sdlctools.models.metabossmodel.ModelUtils;
25:
26: /** Special Ant task used to convert create a "sceleton" UML Model containing MetaBoss UML Profile and save it in the XMI format.
27: * This task extends abstract {@link com.metaboss.sdlctools.applications.anttasks.MetaBossTask MetaBossTask}
28: * and therefore suports all of its attributes. In addition it supports the following attributes:
29: * <table border="1" cellpadding="2" cellspacing="0">
30: * <tr>
31: * <th>Attribute Name</th>
32: * <th>Attribute Description</th>
33: * </tr>
34: * <tr>
35: * <td valign="top">umlfile</td>
36: * <td valign="top">The mandatory path and name of the uml file where model should be saved to.
37: * If this file exists it will be overwritten.
38: * </td>
39: * </tr>
40: * </table>
41: */
42: public class MetaBossUMLProfile extends MetaBossTask {
43: private File mUMLFile = null;
44:
45: /** The setter for the "UMLFile" attribute */
46: public void setUMLFile(File pUMLFile) {
47: mUMLFile = pUMLFile;
48: }
49:
50: // The getter for the "UMLFile" attribute. Passed to the destination application as an argument
51: protected File getUMLFile() {
52: if (mUMLFile == null)
53: throw new BuildException(
54: "Missing 'umlfile' attribute, which is mandatory for <"
55: + getTaskName() + "> task.");
56: return mUMLFile;
57: }
58:
59: // The method actually executing the task
60: public void execute() throws BuildException {
61: try {
62: // Do not have to use default model for this
63: String lTempUMLModelName = getUMLFile().getAbsolutePath();
64: // Convert model to UML
65: ModelUtils.createMetaBossUMLProfileModel(lTempUMLModelName);
66: // Export model into the file
67: AntMetaBossUtils.getModelRepository().exportModel(
68: lTempUMLModelName, false, getUMLFile(),
69: new Properties());
70: // Delete temporary model
71: AntMetaBossUtils.getModelRepository().closeModel(
72: lTempUMLModelName);
73: } catch (Throwable t) {
74: handleException(t);
75: }
76: }
77: }
|