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 org.apache.tools.ant.taskdefs.optional.metaboss;
16:
17: import java.util.Iterator;
18: import java.util.List;
19:
20: import javax.naming.Context;
21: import javax.naming.InitialContext;
22:
23: import org.apache.tools.ant.BuildException;
24:
25: import com.metaboss.sdlctools.applications.anttasks.AntMetaBossUtils;
26: import com.metaboss.sdlctools.applications.anttasks.MetaBossModelToolTask;
27: import com.metaboss.sdlctools.models.metabossmodel.ModelElement;
28: import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.Enterprise;
29: import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.systemimplementationmodel.Domain;
30: import com.metaboss.sdlctools.services.metadatamanagement.BSDomainSupportServicesManagement;
31:
32: /** Special Ant task used to invoke MetaBoss Domain support metadata generator. */
33: public class DomainSupportMetadataGeneratorTask extends
34: MetaBossModelToolTask {
35: private String mRef = null;
36:
37: /** Default constructor */
38: public DomainSupportMetadataGeneratorTask() {
39: // This task uses existing model
40: super (true);
41: }
42:
43: /** The setter for the "ref" attribute */
44: public void setRef(String pRef) {
45: mRef = pRef;
46: }
47:
48: // The getter for the "Ref" attribute. Passed to the destination application as an argument
49: protected String getRef() {
50: if (mRef == null)
51: throw new BuildException(
52: "Missing 'ref' attribute, which is mandatory for <"
53: + getTaskName() + "> task.");
54: return mRef;
55: }
56:
57: // The method executing the tool
58: public void runTool() throws Exception {
59: // Obtain the system here, so we can complain if something is wrong
60: ModelElement lModelElement = (ModelElement) getModelElement(
61: getRef(),
62: new Class[] {
63: com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.System.class,
64: Domain.class, Enterprise.class });
65:
66: // Get the generator
67: Context ctx = new InitialContext();
68: BSDomainSupportServicesManagement lGenerator = (BSDomainSupportServicesManagement) ctx
69: .lookup(BSDomainSupportServicesManagement.COMPONENT_URL);
70:
71: // Use XPath to locate all domains under specified ref and generate metadata for it
72: List lDomains = AntMetaBossUtils.getModelRepository()
73: .searchByXPath(lModelElement,
74: "descendant-or-self::Domain");
75: for (Iterator lDomainsIter = lDomains.iterator(); lDomainsIter
76: .hasNext();) {
77: lGenerator.updateMetadataForDomain(((Domain) lDomainsIter
78: .next()).getRef());
79: }
80: }
81: }
|