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.AntMetaBossUtils;
23: import com.metaboss.sdlctools.applications.anttasks.MetaBossModelToolTask;
24: import com.metaboss.util.DirectoryUtils;
25:
26: /** Special Ant task used to read MetaBoss model and save it using different storage properties.
27: * Essentialy it converts the storage model without modifying the model itself.
28: * This task extends abstract {@link com.metaboss.sdlctools.applications.anttasks.MetaBossModelToolTask MetaBossModelToolTask}
29: * and therefore suports all of its attributes. In addition it supports the following attributes:
30: * <table border="1" cellpadding="2" cellspacing="0">
31: * <tr>
32: * <th>Attribute Name</th>
33: * <th>Attribute Description</th>
34: * </tr>
35: * <tr>
36: * <td valign="top">destinationdir</td>
37: * <td valign="top">The mandatory path and name of the directory where destination model should be saved to.
38: * If this directory exists, it will be emptied.
39: * </td>
40: * </tr>
41: * </table>
42: */
43: public class MetaBossToMetaBoss extends MetaBossModelToolTask {
44: private File mDestinationDir = null;
45:
46: /** Default constructor */
47: public MetaBossToMetaBoss() {
48: // Convertor from MetaBoss uses existing model
49: super (true);
50: }
51:
52: /** The setter for the "UMLFile" attribute */
53: public void setDestinationDir(File pDestinationDir) {
54: mDestinationDir = pDestinationDir;
55: }
56:
57: // The getter for the "DestinationDir" attribute. Passed to the destination application as an argument
58: protected File getDestinationDir() {
59: if (mDestinationDir == null)
60: throw new BuildException(
61: "Missing 'destinationdir' attribute, which is mandatory for <"
62: + getTaskName() + "> task.");
63: return mDestinationDir;
64: }
65:
66: // The method executing the tool
67: public void runTool() throws Exception {
68: // Ensure that the target file is absent
69: File lDestinationDir = getDestinationDir();
70: DirectoryUtils.ensureNewCleanDirectory(lDestinationDir
71: .getAbsolutePath());
72: // Export model into the new storage tree
73: AntMetaBossUtils.getModelRepository().exportModel(
74: getModelName(),
75: false,
76: new File(lDestinationDir.getAbsolutePath()
77: + File.separator + "Model.xml"),
78: new Properties());
79: }
80: }
|