1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/enterprise/openesbaddons/workflow/build.xml Thu Apr 26 02:33:27 2007 +0000
1.3 @@ -0,0 +1,29 @@
1.4 +<?xml version="1.0" encoding="UTF-8"?>
1.5 +
1.6 +<!--
1.7 + The contents of this file are subject to the terms of the Common Development
1.8 + and Distribution License (the License). You may not use this file except in
1.9 + compliance with the License.
1.10 +
1.11 + You can obtain a copy of the License at http://www.netbeans.org/cddl.html
1.12 + or http://www.netbeans.org/cddl.txt.
1.13 +
1.14 + When distributing Covered Code, include this CDDL Header Notice in each file
1.15 + and include the License file at http://www.netbeans.org/cddl.txt.
1.16 + If applicable, add the following below the CDDL Header, with the fields
1.17 + enclosed by brackets [] replaced by your own identifying information:
1.18 + "Portions Copyrighted [year] [name of copyright owner]"
1.19 +
1.20 + The Original Software is NetBeans. The Initial Developer of the Original
1.21 + Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
1.22 + Microsystems, Inc. All Rights Reserved.
1.23 +-->
1.24 +
1.25 +<!-- You may freely edit this file. See harness/README in the NetBeans platform -->
1.26 +<!-- for some information on what you could do (e.g. targets to override). -->
1.27 +<!-- If you delete this file and reopen the project it will be recreated. -->
1.28 +<project name="workflow" basedir=".">
1.29 + <description>Builds the module suite workflow.</description>
1.30 + <import file="nbproject/build-impl.xml"/>
1.31 + <import file="../../../nbbuild/entpack/templates/suite-impl.xml"/>
1.32 +</project>
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
2.2 +++ b/enterprise/openesbaddons/workflow/editor/build.xml Thu Apr 26 02:33:27 2007 +0000
2.3 @@ -0,0 +1,5 @@
2.4 +<?xml version="1.0" encoding="UTF-8"?>
2.5 +<project basedir="." default="netbeans" name="org.netbeans.modules.workflow.editor">
2.6 + <description>Builds, tests, and runs the project org.netbeans.modules.workflow.editor</description>
2.7 + <import file="nbproject/build-impl.xml"/>
2.8 +</project>
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
3.2 +++ b/enterprise/openesbaddons/workflow/editor/manifest.mf Thu Apr 26 02:33:27 2007 +0000
3.3 @@ -0,0 +1,6 @@
3.4 +Manifest-Version: 1.0
3.5 +OpenIDE-Module: org.netbeans.modules.workflow.editor
3.6 +OpenIDE-Module-Layer: org/netbeans/modules/workflow/editor/layer.xml
3.7 +OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/workflow/editor/Bundle.properties
3.8 +OpenIDE-Module-Specification-Version: 1.0
3.9 +
4.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
4.2 +++ b/enterprise/openesbaddons/workflow/editor/nbproject/build-impl.xml Thu Apr 26 02:33:27 2007 +0000
4.3 @@ -0,0 +1,30 @@
4.4 +<?xml version="1.0" encoding="UTF-8"?>
4.5 +<!--
4.6 +*** GENERATED FROM project.xml - DO NOT EDIT ***
4.7 +*** EDIT ../build.xml INSTEAD ***
4.8 +-->
4.9 +<project name="com.sun.jbi.ui.devtool.projects.workflowpro-impl" basedir=".." xmlns:nbmproject="http://www.netbeans.org/ns/nb-module-project/2">
4.10 + <property file="nbproject/private/suite-private.properties"/>
4.11 + <property file="nbproject/suite.properties"/>
4.12 + <fail unless="suite.dir">You must set 'suite.dir' to point to your containing module suite</fail>
4.13 + <property file="${suite.dir}/nbproject/private/platform-private.properties"/>
4.14 + <property file="${suite.dir}/nbproject/platform.properties"/>
4.15 + <macrodef name="property" uri="http://www.netbeans.org/ns/nb-module-project/2">
4.16 + <attribute name="name"/>
4.17 + <attribute name="value"/>
4.18 + <sequential>
4.19 + <property name="@{name}" value="${@{value}}"/>
4.20 + </sequential>
4.21 + </macrodef>
4.22 + <property file="${user.properties.file}"/>
4.23 + <nbmproject:property name="harness.dir" value="nbplatform.${nbplatform.active}.harness.dir"/>
4.24 + <nbmproject:property name="netbeans.dest.dir" value="nbplatform.${nbplatform.active}.netbeans.dest.dir"/>
4.25 + <fail message="You must define 'nbplatform.${nbplatform.active}.harness.dir'">
4.26 + <condition>
4.27 + <not>
4.28 + <available file="${harness.dir}" type="dir"/>
4.29 + </not>
4.30 + </condition>
4.31 + </fail>
4.32 + <import file="${harness.dir}/build.xml"/>
4.33 +</project>
5.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
5.2 +++ b/enterprise/openesbaddons/workflow/editor/nbproject/project.properties Thu Apr 26 02:33:27 2007 +0000
5.3 @@ -0,0 +1,1 @@
5.4 +javac.source=1.5
6.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
6.2 +++ b/enterprise/openesbaddons/workflow/editor/nbproject/project.xml Thu Apr 26 02:33:27 2007 +0000
6.3 @@ -0,0 +1,12 @@
6.4 +<?xml version="1.0" encoding="UTF-8"?>
6.5 +<project xmlns="http://www.netbeans.org/ns/project/1">
6.6 + <type>org.netbeans.modules.apisupport.project</type>
6.7 + <configuration>
6.8 + <data xmlns="http://www.netbeans.org/ns/nb-module-project/3">
6.9 + <code-name-base>org.netbeans.modules.workflow.editor</code-name-base>
6.10 + <suite-component/>
6.11 + <module-dependencies/>
6.12 + <public-packages/>
6.13 + </data>
6.14 + </configuration>
6.15 +</project>
7.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
7.2 +++ b/enterprise/openesbaddons/workflow/editor/nbproject/suite.properties Thu Apr 26 02:33:27 2007 +0000
7.3 @@ -0,0 +1,19 @@
7.4 +#
7.5 +# The contents of this file are subject to the terms of the Common Development
7.6 +# and Distribution License (the License). You may not use this file except in
7.7 +# compliance with the License.
7.8 +#
7.9 +# You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7.10 +# or http://www.netbeans.org/cddl.txt.
7.11 +#
7.12 +# When distributing Covered Code, include this CDDL Header Notice in each file
7.13 +# and include the License file at http://www.netbeans.org/cddl.txt.
7.14 +# If applicable, add the following below the CDDL Header, with the fields
7.15 +# enclosed by brackets [] replaced by your own identifying information:
7.16 +# "Portions Copyrighted [year] [name of copyright owner]"
7.17 +#
7.18 +# The Original Software is NetBeans. The Initial Developer of the Original
7.19 +# Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
7.20 +# Microsystems, Inc. All Rights Reserved.
7.21 +#
7.22 +suite.dir=${basedir}/../../workflow
8.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
8.2 +++ b/enterprise/openesbaddons/workflow/nbproject/build-impl.xml Thu Apr 26 02:33:27 2007 +0000
8.3 @@ -0,0 +1,27 @@
8.4 +<?xml version="1.0" encoding="UTF-8"?>
8.5 +<!--
8.6 +*** GENERATED FROM project.xml - DO NOT EDIT ***
8.7 +*** EDIT ../build.xml INSTEAD ***
8.8 +-->
8.9 +<project name="workflow-impl" basedir=".." xmlns:sproject="http://www.netbeans.org/ns/nb-module-suite-project/1">
8.10 + <property file="nbproject/private/platform-private.properties"/>
8.11 + <property file="nbproject/platform.properties"/>
8.12 + <macrodef name="property" uri="http://www.netbeans.org/ns/nb-module-suite-project/1">
8.13 + <attribute name="name"/>
8.14 + <attribute name="value"/>
8.15 + <sequential>
8.16 + <property name="@{name}" value="${@{value}}"/>
8.17 + </sequential>
8.18 + </macrodef>
8.19 + <property file="${user.properties.file}"/>
8.20 + <sproject:property name="harness.dir" value="nbplatform.${nbplatform.active}.harness.dir"/>
8.21 + <sproject:property name="netbeans.dest.dir" value="nbplatform.${nbplatform.active}.netbeans.dest.dir"/>
8.22 + <fail message="You must define 'nbplatform.${nbplatform.active}.harness.dir'">
8.23 + <condition>
8.24 + <not>
8.25 + <available file="${harness.dir}" type="dir"/>
8.26 + </not>
8.27 + </condition>
8.28 + </fail>
8.29 + <import file="${harness.dir}/suite.xml"/>
8.30 +</project>
9.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
9.2 +++ b/enterprise/openesbaddons/workflow/nbproject/genfiles.properties Thu Apr 26 02:33:27 2007 +0000
9.3 @@ -0,0 +1,8 @@
9.4 +build.xml.data.CRC32=903152f2
9.5 +build.xml.script.CRC32=bd27ae7e
9.6 +build.xml.stylesheet.CRC32=722e7a4f
9.7 +# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
9.8 +# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
9.9 +nbproject/build-impl.xml.data.CRC32=903152f2
9.10 +nbproject/build-impl.xml.script.CRC32=077c0121
9.11 +nbproject/build-impl.xml.stylesheet.CRC32=121e7282
10.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
10.2 +++ b/enterprise/openesbaddons/workflow/nbproject/platform.properties Thu Apr 26 02:33:27 2007 +0000
10.3 @@ -0,0 +1,7 @@
10.4 +nbplatform.active=default
10.5 +suite.dir=${basedir}
10.6 +cluster.dir.name=soa1
10.7 +cluster=${suite.dir}/../../../nbbuild/netbeans/${cluster.dir.name}
10.8 +nbplatform.EntPack.netbeans.dest.dir=${suite.dir}/../../nbbuild/netbeans
10.9 +nbplatform.EntPack.label=EntPack
10.10 +nbplatform.EntPack.harness.dir=${suite.dir}/../../../nbbuild/netbeans/harness
11.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
11.2 +++ b/enterprise/openesbaddons/workflow/nbproject/project.properties Thu Apr 26 02:33:27 2007 +0000
11.3 @@ -0,0 +1,11 @@
11.4 +disabled.clusters=\
11.5 + harness
11.6 +
11.7 +modules=\
11.8 + ${project.org.netbeans.modules.workflow.project}:\
11.9 + ${project.org.netbeans.modules.workflow.editor}
11.10 +project.org.netbeans.modules.iep.editor=editor
11.11 +project.org.netbeans.modules.iep.project=project
11.12 +project.org.netbeans.modules.workflow.project=project
11.13 +project.org.netbeans.modules.workflow.editor=editor
11.14 +run.args.extra=-J-Xmx512m
12.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
12.2 +++ b/enterprise/openesbaddons/workflow/nbproject/project.xml Thu Apr 26 02:33:27 2007 +0000
12.3 @@ -0,0 +1,9 @@
12.4 +<?xml version="1.0" encoding="UTF-8"?>
12.5 +<project xmlns="http://www.netbeans.org/ns/project/1">
12.6 + <type>org.netbeans.modules.apisupport.project.suite</type>
12.7 + <configuration>
12.8 + <data xmlns="http://www.netbeans.org/ns/nb-module-suite-project/1">
12.9 + <name>workflow</name>
12.10 + </data>
12.11 + </configuration>
12.12 +</project>
13.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
13.2 +++ b/enterprise/openesbaddons/workflow/project/antsrc-test/org/netbeans/modules/workflow/project/anttasks/test/BaseSchemaFormBuilderTest.java Thu Apr 26 02:33:27 2007 +0000
13.3 @@ -0,0 +1,130 @@
13.4 +package org.netbeans.modules.workflow.project.anttasks.test;
13.5 +
13.6 +import java.io.File;
13.7 +import java.net.URL;
13.8 +import java.util.HashMap;
13.9 +import java.util.Map;
13.10 +
13.11 +import javax.xml.transform.dom.DOMSource;
13.12 +import javax.xml.transform.stream.StreamSource;
13.13 +
13.14 +import junit.framework.TestCase;
13.15 +
13.16 +import org.chiba.tools.schemabuilder.SchemaFormBuilder;
13.17 +import org.netbeans.modules.workflow.project.anttasks.BaseSchemaFormBuilder;
13.18 +import org.netbeans.modules.workflow.project.anttasks.XmlUtil;
13.19 +import org.w3c.dom.Document;
13.20 +import org.w3c.dom.Element;
13.21 +import org.w3c.dom.Node;
13.22 +import org.xml.sax.Attributes;
13.23 +import org.xml.sax.SAXException;
13.24 +
13.25 +
13.26 +public class BaseSchemaFormBuilderTest extends TestCase {
13.27 +
13.28 + /**
13.29 + * Test build xform from purchaseOrder2.xsd and transform the xform to
13.30 + * xhtml
13.31 + * @throws Exception
13.32 + */
13.33 + public void testBuildForm_PurchaseOrder2() throws Exception {
13.34 + SchemaFormBuilder builder1;
13.35 + SchemaFormBuilder builder2;
13.36 +
13.37 + URL url = getClass().getResource("purchaseOrder2.xsd");
13.38 +
13.39 + // builder = new BaseSchemaFormBuilder("purchaseOrder");
13.40 + Map defaultValue = new HashMap();
13.41 + // defaultValue.put ("po:orderId", "instance('input')/po:orderId");
13.42 + // defaultValue.put ("po:approveDate", "local-date()");
13.43 +
13.44 + org.xml.sax.XMLReader reader = makeXMLReader();
13.45 + reader.setContentHandler(new Sink(defaultValue));
13.46 +
13.47 + reader.parse(new org.xml.sax.InputSource(getClass().getResourceAsStream("mappings.xml")));
13.48 +
13.49 +// defaultValue = new HashMap();
13.50 +
13.51 + builder1 = new BaseSchemaFormBuilder("orderReply", true, defaultValue);
13.52 + builder2 = new BaseSchemaFormBuilder("purchaseOrder");
13.53 + Document form1 = builder1.buildForm(url.getPath());
13.54 + Document form2 = builder2.buildForm(url.getPath());
13.55 +
13.56 + url = getClass().getResource("inputtransform.xsl");
13.57 + File inputXslt = new File (url.getPath());
13.58 + url = getClass().getResource("outputtransform.xsl");
13.59 + File outputXslt = new File (url.getPath());
13.60 +
13.61 +
13.62 + Node outtransformed = XmlUtil.transformToDoc(new DOMSource(form1), new StreamSource(outputXslt));
13.63 + Node intransformed = XmlUtil.transformToDoc(new DOMSource(form2), new StreamSource(inputXslt));
13.64 +
13.65 + Element root = ((Document)intransformed).createElement("body");
13.66 + root.appendChild(((Document)intransformed).getDocumentElement());
13.67 + root.appendChild(((Document)intransformed).importNode(((Document)outtransformed).getDocumentElement(), true));
13.68 +
13.69 +
13.70 + String xmlString = XmlUtil.toXml(root, "UTF-8", true);
13.71 +
13.72 +
13.73 +
13.74 + System.out.println(xmlString);
13.75 + }
13.76 +
13.77 +
13.78 + /**
13.79 + * __UNDOCUMENTED__
13.80 + *
13.81 + * @throws Exception
13.82 + * __UNDOCUMENTED__
13.83 + */
13.84 + protected void setUp() throws Exception {
13.85 + }
13.86 +
13.87 + /**
13.88 + * __UNDOCUMENTED__
13.89 + */
13.90 + protected void tearDown() {
13.91 + }
13.92 +
13.93 + final public static org.xml.sax.XMLReader makeXMLReader() throws Exception {
13.94 + final javax.xml.parsers.SAXParserFactory saxParserFactory = javax.xml.parsers.SAXParserFactory
13.95 + .newInstance();
13.96 + final javax.xml.parsers.SAXParser saxParser = saxParserFactory.newSAXParser();
13.97 + final org.xml.sax.XMLReader parser = saxParser.getXMLReader();
13.98 + return parser;
13.99 + }
13.100 +
13.101 + final class Sink extends org.xml.sax.helpers.DefaultHandler implements
13.102 + org.xml.sax.ContentHandler {
13.103 + private Map mMap = null;
13.104 +
13.105 + public Sink(Map map) {
13.106 + super();
13.107 + mMap = map;
13.108 + }
13.109 +
13.110 + public void startElement(String uri, String localName, String qName, Attributes attributes)
13.111 + throws SAXException {
13.112 + // TODO Auto-generated method stub
13.113 + if (qName.equals("mp:mapping")) {
13.114 + String path = "";
13.115 + String value = "";
13.116 + for (int i = 0; i < attributes.getLength(); i++) {
13.117 + String attName = attributes.getQName(i);
13.118 + if (attName.equals("path")) {
13.119 + path = attributes.getValue(i);
13.120 + } else if (attName.equals("value")) {
13.121 + value = attributes.getValue(i);
13.122 + }
13.123 + }
13.124 + mMap.put(path, value);
13.125 + }
13.126 + super.startElement(uri, localName, qName, attributes);
13.127 + }
13.128 +
13.129 + }
13.130 +
13.131 +}
13.132 +
13.133 +// end of class
14.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
14.2 +++ b/enterprise/openesbaddons/workflow/project/antsrc-test/org/netbeans/modules/workflow/project/anttasks/test/inputTry.xml Thu Apr 26 02:33:27 2007 +0000
14.3 @@ -0,0 +1,37 @@
14.4 +<?xml version="1.0" encoding="UTF-8"?>
14.5 +<inputXForm xmlns:html="http://www.w3.org/1999/xhtml" xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:xforms="http://www.w3.org/2002/xforms" xmlns="http://www.w3.org/1999/xhtml">
14.6 + <xforms:group>
14.7 + <p>
14.8 + <b>
14.9 + <i>Purchase Order</i>
14.10 + </b>
14.11 + </p>
14.12 + <p/>
14.13 + <table border="1">
14.14 + <tr>
14.15 + <td>Order Id</td>
14.16 + <td>
14.17 + <xforms:output xmlns:chiba="http://chiba.sourceforge.net/xforms" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:po="http://wlmse.sample/po" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" incremental="true" model="inputModel" ref="po:orderId"/>
14.18 + </td>
14.19 + </tr>
14.20 + <tr>
14.21 + <td>Purchaser Name</td>
14.22 + <td>
14.23 + <xforms:output xmlns:chiba="http://chiba.sourceforge.net/xforms" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:po="http://wlmse.sample/po" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" incremental="true" model="inputModel" ref="po:purchaserName"/>
14.24 + </td>
14.25 + </tr>
14.26 + <tr>
14.27 + <td>Product Id</td>
14.28 + <td>
14.29 + <xforms:output xmlns:chiba="http://chiba.sourceforge.net/xforms" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:po="http://wlmse.sample/po" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" incremental="true" model="inputModel" ref="po:productId"/>
14.30 + </td>
14.31 + </tr>
14.32 + <tr>
14.33 + <td>Amount</td>
14.34 + <td>
14.35 + <xforms:output xmlns:chiba="http://chiba.sourceforge.net/xforms" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:po="http://wlmse.sample/po" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" incremental="true" model="inputModel" ref="po:amount"/>
14.36 + </td>
14.37 + </tr>
14.38 + </table>
14.39 + </xforms:group>
14.40 +</inputXForm>
15.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
15.2 +++ b/enterprise/openesbaddons/workflow/project/antsrc-test/org/netbeans/modules/workflow/project/anttasks/test/inputmodel.xml Thu Apr 26 02:33:27 2007 +0000
15.3 @@ -0,0 +1,37 @@
15.4 +<html:html xmlns:chiba="http://chiba.sourceforge.net/xforms" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:html="http://www.w3.org/1999/xhtml" xmlns:po="http://wlmse.sample/po" xmlns:xforms="http://www.w3.org/2002/xforms" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
15.5 +<html:head>
15.6 +<xforms:model id="model_0">
15.7 +<xforms:instance id="instance_0">
15.8 +<po:purchaseOrder xsi="http://www.w3.org/2001/XMLSchema-instance"/>
15.9 +</xforms:instance>
15.10 +<xforms:bind id="bind_0" nodeset="/po:purchaseOrder">
15.11 +<xforms:bind id="bind_1" nodeset="po:orderId" xforms:required="true()" xforms:type="string"/>
15.12 +<xforms:bind id="bind_2" nodeset="po:purchaserName" xforms:required="true()" xforms:type="string"/>
15.13 +<xforms:bind id="bind_3" nodeset="po:productId" xforms:required="true()" xforms:type="string"/>
15.14 +<xforms:bind id="bind_4" nodeset="po:amount" xforms:required="true()" xforms:type="decimal"/>
15.15 +</xforms:bind>
15.16 +</xforms:model>
15.17 +</html:head>
15.18 +<html:body>
15.19 +<xforms:group id="group_0">
15.20 +<xforms:label id="label_0">Purchase Order</xforms:label>
15.21 +<xforms:output incremental="true" model="inputModel" ref="po:orderId">
15.22 +<xforms:label>Order Id</xforms:label>
15.23 +<xforms:alert id="alert_0">Please provide a valid value for 'Order Id'. 'Order Id' is a required 'String' value.</xforms:alert>
15.24 +</xforms:output>
15.25 +<xforms:output incremental="true" model="inputModel" ref="po:purchaserName">
15.26 +<xforms:label>Purchaser Name</xforms:label>
15.27 +<xforms:alert id="alert_1">Please provide a valid value for 'Purchaser Name'. 'Purchaser Name' is a required 'String' value.</xforms:alert>
15.28 +</xforms:output>
15.29 +<xforms:output incremental="true" model="inputModel" ref="po:productId">
15.30 +<xforms:label>Product Id</xforms:label>
15.31 +<xforms:alert id="alert_2">Please provide a valid value for 'Product Id'. 'Product Id' is a required 'String' value.</xforms:alert>
15.32 +</xforms:output>
15.33 +<xforms:output incremental="true" model="inputModel" ref="po:amount">
15.34 +<xforms:label>Amount</xforms:label>
15.35 +<xforms:alert id="alert_3">Please provide a valid value for 'Amount'. 'Amount' is a required 'Decimal' value.</xforms:alert>
15.36 +</xforms:output>
15.37 +</xforms:group>
15.38 +</html:body>
15.39 +</html:html>
15.40 +
16.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
16.2 +++ b/enterprise/openesbaddons/workflow/project/antsrc-test/org/netbeans/modules/workflow/project/anttasks/test/inputtransform.xsl Thu Apr 26 02:33:27 2007 +0000
16.3 @@ -0,0 +1,40 @@
16.4 +<?xml version="1.0" encoding="UTF-8"?>
16.5 +<!-- edited with XMLSpy v2006 sp1 U (http://www.altova.com) by Mei Wu (SeeBeyond Technology Corp.) -->
16.6 +<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:xforms="http://www.w3.org/2002/xforms" xmlns:html="http://www.w3.org/1999/xhtml" xmlns="http://www.w3.org/1999/xhtml">
16.7 + <xsl:template match="html:body">
16.8 + <inputXForm>
16.9 + <xsl:apply-templates select="xforms:group"/>
16.10 + </inputXForm>
16.11 + </xsl:template>
16.12 + <xsl:template match="xforms:group">
16.13 + <xforms:group xmlns:xforms="http://www.w3.org/2002/xforms">
16.14 + <p>
16.15 + <b>
16.16 + <i><xsl:value-of select="xforms:label"/></i>
16.17 + </b>
16.18 + </p>
16.19 + <p>
16.20 + </p>
16.21 + <table border="1">
16.22 + <xsl:apply-templates select="xforms:output"/>
16.23 + </table>
16.24 + </xforms:group>
16.25 + </xsl:template>
16.26 + <xsl:template match="xforms:output">
16.27 + <tr>
16.28 + <td>
16.29 + <xsl:apply-templates select="xforms:label"/>
16.30 + </td>
16.31 + <td>
16.32 + <xsl:copy>
16.33 + <xsl:apply-templates select="@*"/>
16.34 + </xsl:copy>
16.35 + </td>
16.36 + </tr>
16.37 + </xsl:template>
16.38 +
16.39 + <xsl:template match="@*">
16.40 + <xsl:copy>
16.41 + </xsl:copy>
16.42 + </xsl:template>
16.43 +</xsl:stylesheet>
17.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
17.2 +++ b/enterprise/openesbaddons/workflow/project/antsrc-test/org/netbeans/modules/workflow/project/anttasks/test/inputview.xml Thu Apr 26 02:33:27 2007 +0000
17.3 @@ -0,0 +1,38 @@
17.4 +<?xml version="1.0" encoding="UTF-8"?>
17.5 +<inputXForm>
17.6 + <!-- see the table and tr/td here. Also note we generate <<xforms:output> in one <td> and order Id: in another <td> , so it does not use <xforms:label> -->
17.7 + <xforms:group xmlns:xforms="http://www.w3.org/2002/xforms" xmlns="http://www.w3.org/1999/xhtml">
17.8 + <p>
17.9 + <b>
17.10 + <i>This is purchase Order Input.</i>
17.11 + </b>
17.12 + </p>
17.13 + <p> </p>
17.14 + <table border="1">
17.15 + <tr>
17.16 + <td> order Id: </td>
17.17 + <td>
17.18 + <xforms:output xmlns:po="http://wlmse.sample/po" incremental="true" model="inputModel" ref="po:orderId"/>
17.19 + </td>
17.20 + </tr>
17.21 + <tr>
17.22 + <td> product Id: </td>
17.23 + <td>
17.24 + <xforms:output xmlns:po="http://wlmse.sample/po" incremental="true" model="inputModel" ref="po:purchaserName"/>
17.25 + </td>
17.26 + </tr>
17.27 + <tr>
17.28 + <td> purchaser Name: </td>
17.29 + <td>
17.30 + <xforms:output xmlns:po="http://wlmse.sample/po" incremental="true" model="inputModel" ref="po:productId"/>
17.31 + </td>
17.32 + </tr>
17.33 + <tr>
17.34 + <td> amount: </td>
17.35 + <td>
17.36 + <xforms:output xmlns:po="http://wlmse.sample/po" incremental="true" model="inputModel" ref="po:amount"/>
17.37 + </td>
17.38 + </tr>
17.39 + </table>
17.40 + </xforms:group>
17.41 +</inputXForm>
18.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
18.2 +++ b/enterprise/openesbaddons/workflow/project/antsrc-test/org/netbeans/modules/workflow/project/anttasks/test/mappings.xml Thu Apr 26 02:33:27 2007 +0000
18.3 @@ -0,0 +1,6 @@
18.4 +<?xml version="1.0" encoding="UTF-8"?>
18.5 +<!-- edited with XMLSpy v2006 sp1 U (http://www.altova.com) by Mei Wu (SeeBeyond Technology Corp.) -->
18.6 +<mp:DefaultValues xmlns:mp="http://jbi.com.sun/wfse/project/mappings">
18.7 + <mp:mapping path="po:orderId" value="instance('input')/po:orderId"/>
18.8 + <mp:mapping path="po:approveDate" value="local-date()"/>
18.9 +</mp:DefaultValues>
19.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
19.2 +++ b/enterprise/openesbaddons/workflow/project/antsrc-test/org/netbeans/modules/workflow/project/anttasks/test/outputTry.xml Thu Apr 26 02:33:27 2007 +0000
19.3 @@ -0,0 +1,42 @@
19.4 +<?xml version="1.0" encoding="UTF-8"?>
19.5 +<outputXForm xmlns:html="http://www.w3.org/1999/xhtml" xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:xforms="http://www.w3.org/2002/xforms" xmlns="http://www.w3.org/1999/xhtml">
19.6 + <xforms:group>
19.7 + <p>
19.8 + <b>
19.9 + <i>Order Reply</i>
19.10 + </b>
19.11 + </p>
19.12 + <p/>
19.13 + <table border="1">
19.14 + <tr>
19.15 + <td>Approve Result</td>
19.16 + <td>
19.17 + <xforms:select1 xmlns:chiba="http://chiba.sourceforge.net/xforms" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:po="http://wlmse.sample/po" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="select1_0" incremental="true" model="outputModel" ref="po:approveResult" xforms:appearance="full">
19.18 + <xforms:item id="item_0">
19.19 + <xforms:label id="label_2">Approved</xforms:label>
19.20 + <xforms:value id="value_0">Approved</xforms:value>
19.21 + </xforms:item>
19.22 + <xforms:item id="item_1">
19.23 + <xforms:label id="label_3">Rejected</xforms:label>
19.24 + <xforms:value id="value_1">Rejected</xforms:value>
19.25 + </xforms:item>
19.26 + </xforms:select1>
19.27 + </td>
19.28 + </tr>
19.29 + <tr>
19.30 + <td>Description</td>
19.31 + <td>
19.32 + <xforms:textarea xmlns:chiba="http://chiba.sourceforge.net/xforms" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:po="http://wlmse.sample/po" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" incremental="true" model="outputModel" ref="po:description"/>
19.33 + </td>
19.34 + </tr>
19.35 + </table>
19.36 + </xforms:group>
19.37 + <p/>
19.38 + <xforms:submit xmlns:chiba="http://chiba.sourceforge.net/xforms" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:po="http://wlmse.sample/po" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="submit_0" submission="default-submission">
19.39 + <xforms:label id="label_5">Submit</xforms:label>
19.40 + <xforms:action ev:event="DOMActivate">
19.41 + <xforms:setvalue model="outputMode" ref="instance('output')/po:approveDate" value="local-date()"/>
19.42 + <xforms:setvalue model="outputMode" ref="instance('output')/po:orderId" value="instance('input')/po:orderId"/>
19.43 + </xforms:action>
19.44 + </xforms:submit>
19.45 +</outputXForm>
20.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
20.2 +++ b/enterprise/openesbaddons/workflow/project/antsrc-test/org/netbeans/modules/workflow/project/anttasks/test/outputmodel.xml Thu Apr 26 02:33:27 2007 +0000
20.3 @@ -0,0 +1,46 @@
20.4 +<html:html xmlns:chiba="http://chiba.sourceforge.net/xforms" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:html="http://www.w3.org/1999/xhtml" xmlns:po="http://wlmse.sample/po" xmlns:xforms="http://www.w3.org/2002/xforms" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
20.5 +<html:head>
20.6 +<xforms:model id="model_0">
20.7 +<xforms:instance id="instance_0">
20.8 +<po:orderReply xsi="http://www.w3.org/2001/XMLSchema-instance"/>
20.9 +</xforms:instance>
20.10 +<xforms:bind id="bind_0" nodeset="/po:orderReply">
20.11 +<xforms:bind id="bind_1" nodeset="po:orderId" xforms:required="true()" xforms:type="string"/>
20.12 +<xforms:bind id="bind_2" nodeset="po:approveResult" xforms:required="true()" xforms:type="string"/>
20.13 +<xforms:bind id="bind_3" nodeset="po:approveDate" xforms:required="true()" xforms:type="date"/>
20.14 +<xforms:bind id="bind_4" nodeset="po:description" xforms:required="true()" xforms:type="string"/>
20.15 +</xforms:bind>
20.16 +<xforms:submission action="" id="submission_0" method="post"/>
20.17 +</xforms:model>
20.18 +</html:head>
20.19 +<html:body>
20.20 +<xforms:group id="group_0">
20.21 +<xforms:label id="label_0">Order Reply</xforms:label>
20.22 +<xforms:select1 id="select1_0" incremental="true" model="outputModel" ref="po:approveResult" xforms:appearance="full">
20.23 +<xforms:label id="label_1">Approve Result</xforms:label>
20.24 +<xforms:choices id="choices_0">
20.25 +<xforms:item id="item_0">
20.26 +<xforms:label id="label_2">Approved</xforms:label>
20.27 +<xforms:value id="value_0">Approved</xforms:value>
20.28 +</xforms:item>
20.29 +<xforms:item id="item_1">
20.30 +<xforms:label id="label_3">Rejected</xforms:label>
20.31 +<xforms:value id="value_1">Rejected</xforms:value>
20.32 +</xforms:item>
20.33 +</xforms:choices>
20.34 +<xforms:alert id="alert_0">Please provide a valid value for 'Approve Result'. 'Approve Result' is a required 'String' value.</xforms:alert>
20.35 +</xforms:select1>
20.36 +<xforms:textarea incremental="true" model="outputModel" ref="po:description">
20.37 +<xforms:label id="label_4">Description</xforms:label>
20.38 +<xforms:alert id="alert_1">Please provide a valid value for 'Description'. 'Description' is a required 'String' value.</xforms:alert>
20.39 +</xforms:textarea>
20.40 +</xforms:group>
20.41 +<xforms:submit id="submit_0" submission="default-submission">
20.42 +<xforms:label id="label_5">Submit</xforms:label>
20.43 +<xforms:action ev:event="DOMActivate">
20.44 +<xforms:setvalue model="outputMode" ref="instance('output')/po:approveDate" value="local-date()"/>
20.45 +<xforms:setvalue model="outputMode" ref="instance('output')/po:orderId" value="instance('input')/po:orderId"/>
20.46 +</xforms:action>
20.47 +</xforms:submit>
20.48 +</html:body>
20.49 +</html:html>
21.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
21.2 +++ b/enterprise/openesbaddons/workflow/project/antsrc-test/org/netbeans/modules/workflow/project/anttasks/test/outputtransform.xsl Thu Apr 26 02:33:27 2007 +0000
21.3 @@ -0,0 +1,67 @@
21.4 +<?xml version="1.0" encoding="UTF-8"?>
21.5 +<!-- edited with XMLSpy v2006 sp1 U (http://www.altova.com) by Mei Wu (SeeBeyond Technology Corp.) -->
21.6 +<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:xforms="http://www.w3.org/2002/xforms" xmlns:html="http://www.w3.org/1999/xhtml" xmlns="http://www.w3.org/1999/xhtml">
21.7 + <xsl:template match="html:body">
21.8 + <outputXForm>
21.9 + <xsl:apply-templates select="xforms:group"/>
21.10 + <xsl:apply-templates select="xforms:submit"/>
21.11 + </outputXForm>
21.12 + </xsl:template>
21.13 + <xsl:template match="xforms:group">
21.14 + <xforms:group xmlns:xforms="http://www.w3.org/2002/xforms">
21.15 + <p>
21.16 + <b>
21.17 + <i><xsl:value-of select="xforms:label"/></i>
21.18 + </b>
21.19 + </p>
21.20 + <p>
21.21 + </p>
21.22 + <table border="1">
21.23 + <xsl:apply-templates select="*[name() != 'xforms:label']"/>
21.24 + </table>
21.25 + </xforms:group>
21.26 + </xsl:template>
21.27 + <xsl:template match="xforms:input | xforms:textarea | xforms:secret">
21.28 + <tr>
21.29 + <td>
21.30 + <xsl:apply-templates select="xforms:label"/>
21.31 + </td>
21.32 + <td>
21.33 + <xsl:copy>
21.34 + <xsl:apply-templates select="@*"/>
21.35 + </xsl:copy>
21.36 + </td>
21.37 + </tr>
21.38 + </xsl:template>
21.39 +
21.40 + <xsl:template match="@*">
21.41 + <xsl:copy>
21.42 + </xsl:copy>
21.43 + </xsl:template>
21.44 +
21.45 +<xsl:template match="xforms:select1" >
21.46 + <tr>
21.47 + <td>
21.48 + <xsl:apply-templates select="xforms:label"/>
21.49 + </td>
21.50 + <td>
21.51 + <xsl:copy>
21.52 + <xsl:apply-templates select="@*"/>
21.53 + <xsl:copy-of select="xforms:choices/*"/>
21.54 + </xsl:copy>
21.55 + </td>
21.56 + </tr>
21.57 + </xsl:template>
21.58 +
21.59 +<xsl:template match="xforms:submit">
21.60 +<p>
21.61 +</p>
21.62 + <xsl:copy>
21.63 + <xsl:apply-templates select="@*"/>
21.64 + <xsl:copy-of select="*"/>
21.65 + </xsl:copy>
21.66 +</xsl:template>
21.67 +
21.68 +
21.69 +</xsl:stylesheet>
21.70 +
22.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
22.2 +++ b/enterprise/openesbaddons/workflow/project/antsrc-test/org/netbeans/modules/workflow/project/anttasks/test/outputview.xml Thu Apr 26 02:33:27 2007 +0000
22.3 @@ -0,0 +1,52 @@
22.4 +<outputXForm>
22.5 + <!-- see the table and tr/td here. same as input we generate two <td> s one for display and another for control. The <label> is used for select1 and its item -->
22.6 + <xforms:group xmlns:xforms="http://www.w3.org/2002/xforms" xmlns="http://www.w3.org/1999/xhtml">
22.7 + <p>
22.8 + <b>
22.9 + <i>This is purchase Order Output.</i>
22.10 + </b>
22.11 + </p>
22.12 + <p>
22.13 + <table border="1">
22.14 + <tr>
22.15 + <td> Approve: </td>
22.16 + <td>
22.17 + <xforms:select1 xmlns:po="http://wlmse.sample/po" incremental="true" model="outputModel" ref="po:approveResult">
22.18 + <xforms:label/>
22.19 + <xforms:item>
22.20 + <xforms:label>Approved</xforms:label>
22.21 + <xforms:value>Approved</xforms:value>
22.22 + </xforms:item>
22.23 + <xforms:item>
22.24 + <xforms:label>Rejected</xforms:label>
22.25 + <xforms:value>Rejected</xforms:value>
22.26 + </xforms:item>
22.27 + </xforms:select1>
22.28 + </td>
22.29 + </tr>
22.30 + <tr>
22.31 + <td> Description: </td>
22.32 + <td>
22.33 + <xforms:textarea xmlns:po="http://wlmse.sample/po" model="outputModel" ref="po:description">
22.34 + <xforms:label/>
22.35 + </xforms:textarea>
22.36 + </td>
22.37 + </tr>
22.38 + <tr>
22.39 + <td> </td>
22.40 + </tr>
22.41 + <tr>
22.42 + <td>
22.43 + <xforms:submit submission="default-submission">
22.44 + <xforms:label>Submit</xforms:label>
22.45 + <xforms:action ev:event="DOMActivate">
22.46 + <xforms:setvalue xmlns:po="http://wlmse.sample/po" model="outputModel" ref="instance('output')/po:orderId" value="instance('input')/po:orderId"/>
22.47 + <xforms:message level="modal">hell0</xforms:message>
22.48 + </xforms:action>
22.49 + </xforms:submit>
22.50 + </td>
22.51 + </tr>
22.52 + </table>
22.53 + </p>
22.54 + </xforms:group>
22.55 +</outputXForm>
23.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
23.2 +++ b/enterprise/openesbaddons/workflow/project/antsrc-test/org/netbeans/modules/workflow/project/anttasks/test/purchaseOrder2.xsd Thu Apr 26 02:33:27 2007 +0000
23.3 @@ -0,0 +1,38 @@
23.4 +<?xml version="1.0" encoding="UTF-8"?>
23.5 +
23.6 +<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
23.7 + targetNamespace="http://wlmse.sample/po"
23.8 + xmlns:tns="http://wlmse.sample/po"
23.9 + xmlns="http://wlmse.sample/po"
23.10 + elementFormDefault="qualified">
23.11 +
23.12 + <xsd:element name="purchaseOrder" type="PurchaseOrderType"/>
23.13 +
23.14 + <xsd:element name="orderReply" type="OrderReplyType"/>
23.15 +
23.16 + <xsd:complexType name="PurchaseOrderType">
23.17 + <xsd:sequence>
23.18 + <xsd:element name="orderId" type="xsd:string"/>
23.19 + <xsd:element name="purchaserName" type="xsd:string"/>
23.20 + <xsd:element name="productId" type="xsd:string"/>
23.21 + <xsd:element name="amount" type="xsd:decimal"/>
23.22 + </xsd:sequence>
23.23 + </xsd:complexType>
23.24 +
23.25 + <xsd:simpleType name="ApprovalResult">
23.26 + <xsd:restriction base="xsd:string">
23.27 + <xsd:enumeration value="Approved"/>
23.28 + <xsd:enumeration value="Rejected"/>
23.29 + <!-- and so on ... -->
23.30 + </xsd:restriction>
23.31 + </xsd:simpleType>
23.32 +
23.33 + <xsd:complexType name="OrderReplyType">
23.34 + <xsd:sequence>
23.35 + <xsd:element name="orderId" type="xsd:string"/>
23.36 + <xsd:element name="approveResult" type="ApprovalResult"/>
23.37 + <xsd:element name="approveDate" type="xsd:date"/>
23.38 + <xsd:element name="description" type="xsd:string"/>
23.39 + </xsd:sequence>
23.40 + </xsd:complexType>
23.41 +</xsd:schema>
24.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
24.2 +++ b/enterprise/openesbaddons/workflow/project/antsrc-test/org/netbeans/modules/workflow/project/anttasks/test/transformed.xml Thu Apr 26 02:33:27 2007 +0000
24.3 @@ -0,0 +1,79 @@
24.4 +<body>
24.5 + <inputXForm xmlns="http://www.w3.org/1999/xhtml" xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:html="http://www.w3.org/1999/xhtml" xmlns:xforms="http://www.w3.org/2002/xforms">
24.6 + <xforms:group>
24.7 + <p>
24.8 + <b>
24.9 + <i>Purchase Order</i>
24.10 + </b>
24.11 + </p>
24.12 + <p/>
24.13 + <table border="1">
24.14 + <tr>
24.15 + <td>Order Id</td>
24.16 + <td>
24.17 + <xforms:output xmlns:chiba="http://chiba.sourceforge.net/xforms" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:po="http://wlmse.sample/po" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" incremental="true" model="inputModel" ref="po:orderId"/>
24.18 + </td>
24.19 + </tr>
24.20 + <tr>
24.21 + <td>Purchaser Name</td>
24.22 + <td>
24.23 + <xforms:output xmlns:chiba="http://chiba.sourceforge.net/xforms" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:po="http://wlmse.sample/po" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" incremental="true" model="inputModel" ref="po:purchaserName"/>
24.24 + </td>
24.25 + </tr>
24.26 + <tr>
24.27 + <td>Product Id</td>
24.28 + <td>
24.29 + <xforms:output xmlns:chiba="http://chiba.sourceforge.net/xforms" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:po="http://wlmse.sample/po" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" incremental="true" model="inputModel" ref="po:productId"/>
24.30 + </td>
24.31 + </tr>
24.32 + <tr>
24.33 + <td>Amount</td>
24.34 + <td>
24.35 + <xforms:output xmlns:chiba="http://chiba.sourceforge.net/xforms" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:po="http://wlmse.sample/po" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" incremental="true" model="inputModel" ref="po:amount"/>
24.36 + </td>
24.37 + </tr>
24.38 + </table>
24.39 + </xforms:group>
24.40 + </inputXForm>
24.41 + <outputXForm xmlns="http://www.w3.org/1999/xhtml" xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:html="http://www.w3.org/1999/xhtml" xmlns:xforms="http://www.w3.org/2002/xforms">
24.42 + <xforms:group>
24.43 + <p>
24.44 + <b>
24.45 + <i>Order Reply</i>
24.46 + </b>
24.47 + </p>
24.48 + <p/>
24.49 + <table border="1">
24.50 + <tr>
24.51 + <td>Approve Result</td>
24.52 + <td>
24.53 + <xforms:select1 xmlns:chiba="http://chiba.sourceforge.net/xforms" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:po="http://wlmse.sample/po" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="select1_0" incremental="true" model="outputModel" ref="po:approveResult" xforms:appearance="full">
24.54 + <xforms:item id="item_0">
24.55 + <xforms:label id="label_2">Approved</xforms:label>
24.56 + <xforms:value id="value_0">Approved</xforms:value>
24.57 + </xforms:item>
24.58 + <xforms:item id="item_1">
24.59 + <xforms:label id="label_3">Rejected</xforms:label>
24.60 + <xforms:value id="value_1">Rejected</xforms:value>
24.61 + </xforms:item>
24.62 + </xforms:select1>
24.63 + </td>
24.64 + </tr>
24.65 + <tr>
24.66 + <td>Description</td>
24.67 + <td>
24.68 + <xforms:textarea xmlns:chiba="http://chiba.sourceforge.net/xforms" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:po="http://wlmse.sample/po" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" incremental="true" model="outputModel" ref="po:description"/>
24.69 + </td>
24.70 + </tr>
24.71 + </table>
24.72 + </xforms:group>
24.73 + <p/>
24.74 + <xforms:submit xmlns:chiba="http://chiba.sourceforge.net/xforms" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:po="http://wlmse.sample/po" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="submit_0" submission="default-submission">
24.75 + <xforms:label id="label_5">Submit</xforms:label>
24.76 + <xforms:action ev:event="DOMActivate">
24.77 + <xforms:setvalue model="outputMode" ref="instance('output')/po:approveDate" value="local-date()"/>
24.78 + <xforms:setvalue model="outputMode" ref="instance('output')/po:orderId" value="instance('input')/po:orderId"/>
24.79 + </xforms:action>
24.80 + </xforms:submit>
24.81 + </outputXForm>
24.82 +</body>
25.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
25.2 +++ b/enterprise/openesbaddons/workflow/project/antsrc/org/netbeans/modules/workflow/project/antlib.xml Thu Apr 26 02:33:27 2007 +0000
25.3 @@ -0,0 +1,6 @@
25.4 +<?xml version="1.0" encoding="UTF-8"?>
25.5 + <antlib>
25.6 + <typedef name="WFGenClientWSDL" classname="org.netbeans.modules.workflow.project.anttasks.IDEGenerateWSDLTask"/>
25.7 + <typedef name="XFormGen" classname="org.netbeans.modules.workflow.project.anttasks.IDEXFormGenerationTask"/>
25.8 + <typedef name="generate-asa-artifacts" classname="org.netbeans.modules.workflow.project.anttasks.GenerateAsaArtifacts"/>
25.9 + </antlib>
26.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
26.2 +++ b/enterprise/openesbaddons/workflow/project/antsrc/org/netbeans/modules/workflow/project/anttasks/AbstractSchemaFormBuilder.java Thu Apr 26 02:33:27 2007 +0000
26.3 @@ -0,0 +1,3702 @@
26.4 +package org.netbeans.modules.workflow.project.anttasks;
26.5 +/*
26.6 + * Sun Public License Notice
26.7 + *
26.8 + * The contents of this file are subject to the Sun Public License
26.9 + * Version 1.0 (the "License"). You may not use this file except in
26.10 + * compliance with the License. A copy of the License is available at
26.11 + * http://www.sun.com/
26.12 + *
26.13 + * The Original Code is NetBeans. The Initial Developer of the Original
26.14 + * Code is Sun Microsystems, Inc. Portions Copyright 1997-2004 Sun
26.15 + * Microsystems, Inc. All Rights Reserved.
26.16 + */
26.17 +
26.18 +/*
26.19 + * This class is modified based on {@link org.chiba.tools.schemabuilder.AbstractSchemaFormBuilder} from chiba
26.20 + * (http://chiba.sourceforge.net/).
26.21 + *
26.22 + * The modifications made on AbstractSchemaFormBuilder are :
26.23 + *
26.24 + * 1. Add new constructor to differentiate controls generated for readonly xforms
26.25 + * 2. Make attributes unqualified
26.26 + * 3. Remove bind attribute in form control
26.27 + * 4. Add ref attribute in form control
26.28 + * 5. Add incremental attribute in form control
26.29 + * 6. Add new constructors for setting default values in xform
26.30 + */
26.31 +
26.32 +
26.33 +
26.34 +import org.apache.commons.jxpath.JXPathContext;
26.35 +import org.apache.commons.jxpath.Pointer;
26.36 +import org.apache.log4j.ConsoleAppender;
26.37 +import org.apache.log4j.Layout;
26.38 +import org.apache.log4j.SimpleLayout;
26.39 +
26.40 +import com.sun.org.apache.xerces.internal.xs.*;
26.41 +
26.42 +import org.chiba.tools.schemabuilder.FormBuilderException;
26.43 +import org.chiba.tools.schemabuilder.SchemaFormBuilder;
26.44 +import org.chiba.tools.schemabuilder.TypeExtensionSorter;
26.45 +import org.chiba.tools.schemabuilder.WrapperElementsBuilder;
26.46 +import org.chiba.tools.schemabuilder.XHTMLWrapperElementsBuilder;
26.47 +import org.chiba.xml.dom.DOMUtil;
26.48 +import org.chiba.xml.ns.NamespaceResolver;
26.49 +import org.w3c.dom.*;
26.50 +import org.w3c.dom.bootstrap.DOMImplementationRegistry;
26.51 +import org.xml.sax.InputSource;
26.52 +
26.53 +import javax.xml.parsers.DocumentBuilder;
26.54 +import javax.xml.parsers.DocumentBuilderFactory;
26.55 +import javax.xml.parsers.ParserConfigurationException;
26.56 +import javax.xml.transform.*;
26.57 +import javax.xml.transform.dom.DOMSource;
26.58 +import javax.xml.transform.stream.StreamResult;
26.59 +import java.io.IOException;
26.60 +import java.io.StringWriter;
26.61 +import java.util.*;
26.62 +import java.util.Map.Entry;
26.63 +
26.64 +/*
26.65 + * Search for TODO for things remaining to-do in this implementation.
26.66 + *
26.67 + * TODO: Support configuration mechanism to allow properties to be set without programming.
26.68 + * TODO: i18n/l10n of messages, hints, captions. Possibly leverage org.chiba.i18n classes.
26.69 + * TODO: When Chiba supports itemset, use schema keyref and key constraints for validation.
26.70 + * TODO: Support namespaces in instance documents. Currently can't do this due to Chiba bugs.
26.71 + * TODO: Place default values for list and enumeration types at the beginning of the item list.
26.72 + *
26.73 + */
26.74 +
26.75 +/**
26.76 + * An abstract implementation of the SchemaFormBuilder interface allowing
26.77 + * an XForm to be automatically generated for an XML Schema definition.
26.78 + * This abstract class implements the buildForm and buildFormAsString methods
26.79 + * and associated helper but relies on concrete subclasses to implement other
26.80 + * required interface methods (createXXX, startXXX, and endXXX methods).
26.81 + *
26.82 + * @author $Author$
26.83 + * @version $Id$
26.84 + * @deprecated
26.85 + */
26.86 +public abstract class AbstractSchemaFormBuilder implements SchemaFormBuilder
26.87 +{
26.88 + private static final String PROPERTY_PREFIX =
26.89 + "http://www.chiba.org/properties/schemaFormBuilder/";
26.90 +
26.91 + /**
26.92 + * Property to control the cascading style sheet used for the XForm - corresponds to envelope@chiba:css-style.
26.93 + */
26.94 + public static final String CSS_STYLE_PROP =
26.95 + PROPERTY_PREFIX + "envelope@css-style";
26.96 + private static final String DEFAULT_CSS_STYLE_PROP = "style.css";
26.97 +
26.98 + /**
26.99 + * Property to control the selection of UI control for a selectOne control.
26.100 + * If a selectOne control has >= the number of values specified in this property,
26.101 + * it is considered a <b>long</b> list, and the UI control specified by
26.102 + * SELECTONE_UI_CONTROL_LONG_PROP is used. Otherwise, the value of SELECTONE_UI_CONTROL_SHORT_PROP
26.103 + * is used.
26.104 + */
26.105 + public static final String SELECTONE_LONG_LIST_SIZE_PROP =
26.106 + PROPERTY_PREFIX + "select1@longListSize";
26.107 +
26.108 + /**
26.109 + * Property to specify the selectMany UI control to be used when there are releatively few items
26.110 + * to choose from.
26.111 + */
26.112 + public static final String SELECTONE_UI_CONTROL_SHORT_PROP =
26.113 + PROPERTY_PREFIX + "select1@appearance/short";
26.114 +
26.115 + /**
26.116 + * Property to specify the selectMany UI control to be used when there are large numbers of items
26.117 + * to choose from.
26.118 + */
26.119 + public static final String SELECTONE_UI_CONTROL_LONG_PROP =
26.120 + PROPERTY_PREFIX + "select1@appearance/long";
26.121 + private static final String DEFAULT_SELECTONE_UI_CONTROL_SHORT_PROP =
26.122 + "full";
26.123 + private static final String DEFAULT_SELECTONE_UI_CONTROL_LONG_PROP =
26.124 + "minimal";
26.125 +
26.126 + /**
26.127 + * Property to control the selection of UI control for a selectMany control.
26.128 + * If a selectMany control has >= the number of values specified in this property,
26.129 + * it is considered a <b>long</b> list, and the UI control specified by
26.130 + * SELECTMANY_UI_CONTROL_LONG_PROP is used. Otherwise, the value of SELECTMANY_UI_CONTROL_SHORT_PROP
26.131 + * is used.
26.132 + */
26.133 + public static final String SELECTMANY_LONG_LIST_SIZE_PROP =
26.134 + PROPERTY_PREFIX + "select@longListSize";
26.135 +
26.136 + /**
26.137 + * Property to specify the selectMany UI control to be used when there are releatively few items
26.138 + * to choose from.
26.139 + */
26.140 + public static final String SELECTMANY_UI_CONTROL_SHORT_PROP =
26.141 + PROPERTY_PREFIX + "select@appearance/short";
26.142 +
26.143 + /**
26.144 + * Property to specify the selectMany UI control to be used when there are large numbers of items
26.145 + * to choose from.
26.146 + */
26.147 + public static final String SELECTMANY_UI_CONTROL_LONG_PROP =
26.148 + PROPERTY_PREFIX + "select@appearance/long";
26.149 + private static final String DEFAULT_SELECTMANY_UI_CONTROL_SHORT_PROP =
26.150 + "full";
26.151 + private static final String DEFAULT_SELECTMANY_UI_CONTROL_LONG_PROP =
26.152 + "compact";
26.153 + private static final String DEFAULT_LONG_LIST_MAX_SIZE = "6";
26.154 +
26.155 + /**
26.156 + * Property to control the box alignment of a group - corresponds to xforms:group@chiba:box-align.
26.157 + * There are four valid values for this property - right, left, top, and bottom.
26.158 + * The default value is <b>right</b>.
26.159 + */
26.160 + public static final String GROUP_BOX_ALIGN_PROP =
26.161 + PROPERTY_PREFIX + "group@box-align";
26.162 + private static final String DEFAULT_GROUP_BOX_ALIGN = "right";
26.163 +
26.164 + /**
26.165 + * Property to control the box orientation of a group - corresponds to xforms:group@chiba:box-orient.
26.166 + * There are two valid values for this property - vertical and horizontal.
26.167 + * The default value is <b>vertical</b>.
26.168 + */
26.169 + public static final String GROUP_BOX_ORIENT_PROP =
26.170 + PROPERTY_PREFIX + "group@box-orient";
26.171 + private static final String DEFAULT_GROUP_BOX_ORIENT = "vertical";
26.172 +
26.173 + /**
26.174 + * Property to control the width of a group - corresponds to xforms:group/@chiba:width.
26.175 + * This value may be expressed as a percentage value or as an absolute size.
26.176 + */
26.177 + public static final String GROUP_WIDTH_PROP =
26.178 + PROPERTY_PREFIX + "group@width";
26.179 + private static final String DEFAULT_GROUP_WIDTH = "60%";
26.180 +
26.181 + /**
26.182 + * Property to control the caption width of a group - corresponds to xforms:group/@chiba:caption-width.
26.183 + * This value may be expressed as a percentage value or as an absolute size.
26.184 + */
26.185 + public static final String GROUP_CAPTION_WIDTH_PROP =
26.186 + PROPERTY_PREFIX + "group@caption-width";
26.187 + private static final String DEFAULT_GROUP_CAPTION_WIDTH = "30%";
26.188 +
26.189 + /**
26.190 + * Property to control the border of a group - corresponds to xforms:group/@chiba:border.
26.191 + * A value of <b>0</b> indicates no border, a value of <b>1</b> indicates a border is provided.
26.192 + */
26.193 + public static final String GROUP_BORDER_PROP =
26.194 + PROPERTY_PREFIX + "group@border";
26.195 + private static final String DEFAULT_GROUP_BORDER = "0";
26.196 +
26.197 + /**
26.198 + * Prossible values of the "@method" on the "submission" element
26.199 + */
26.200 + public static final String SUBMIT_METHOD_POST = "post";
26.201 +
26.202 + /**
26.203 + * __UNDOCUMENTED__
26.204 + */
26.205 + public static final String SUBMIT_METHOD_PUT = "put";
26.206 +
26.207 + /**
26.208 + * __UNDOCUMENTED__
26.209 + */
26.210 + public static final String SUBMIT_METHOD_GET = "get";
26.211 +
26.212 + /**
26.213 + * __UNDOCUMENTED__
26.214 + */
26.215 + public static final String SUBMIT_METHOD_FORM_DATA_POST = "form-data-post";
26.216 +
26.217 + /**
26.218 + * __UNDOCUMENTED__
26.219 + */
26.220 + public static final String SUBMIT_METHOD_URLENCODED_POST =
26.221 + "urlencoded-post";
26.222 +
26.223 + /**
26.224 + * possible instance modes
26.225 + */
26.226 + public static final int INSTANCE_MODE_NONE = 0;
26.227 +
26.228 + /**
26.229 + * __UNDOCUMENTED__
26.230 + */
26.231 + public static final int INSTANCE_MODE_INCLUDED = 1;
26.232 +
26.233 + /**
26.234 + * __UNDOCUMENTED__
26.235 + */
26.236 + public static final int INSTANCE_MODE_HREF = 2;
26.237 +
26.238 + /**
26.239 + * __UNDOCUMENTED__
26.240 + */
26.241 + protected Source _instanceSource;
26.242 +
26.243 + /**
26.244 + * __UNDOCUMENTED__
26.245 + */
26.246 + protected String _action;
26.247 +
26.248 + /**
26.249 + * __UNDOCUMENTED__
26.250 + */
26.251 + protected String _instanceHref;
26.252 +
26.253 + /**
26.254 + * Properties choosed by the user
26.255 + */
26.256 + protected String _rootTagName;
26.257 +
26.258 + /**
26.259 + * __UNDOCUMENTED__
26.260 + */
26.261 + protected String _stylesheet;
26.262 +
26.263 + /**
26.264 + * __UNDOCUMENTED__
26.265 + */
26.266 + protected String _submitMethod;
26.267 +
26.268 + /**
26.269 + * __UNDOCUMENTED__
26.270 + */
26.271 + protected String _base;
26.272 +
26.273 + /**
26.274 + * __UNDOCUMENTED__
26.275 + */
26.276 + protected WrapperElementsBuilder _wrapper;
26.277 +
26.278 + /**
26.279 + * __UNDOCUMENTED__
26.280 + */
26.281 + protected int _instanceMode = 0;
26.282 +
26.283 + /**
26.284 + * __UNDOCUMENTED__
26.285 + */
26.286 + protected boolean _useSchemaTypes = false;
26.287 +
26.288 + protected boolean writable = false;
26.289 +
26.290 + protected Map defaultValues = new HashMap ();
26.291 +
26.292 + private Map defaultSets = new HashMap ();
26.293 +
26.294 + private DocumentBuilder documentBuilder;
26.295 +
26.296 + /**
26.297 + * generic counter -> replaced by an hashMap with:
26.298 + * keys: name of the elements
26.299 + * values: "Long" representing the counter for this element
26.300 + */
26.301 +
26.302 + //private long refCounter;
26.303 + private HashMap counter;
26.304 + private Properties properties;
26.305 + protected XSModel schema;
26.306 + private String targetNamespace;
26.307 +
26.308 + private Map namespacePrefixes = new HashMap();
26.309 +
26.310 + // typeTree
26.311 + // each entry is keyed by the type name
26.312 + // value is an ArrayList that contains the XSTypeDefinition's which
26.313 + // are compatible with the specific type. Compatible means that
26.314 + // can be used as a substituted type using xsi:type
26.315 + // In order for it to be compatible, it cannot be abstract, and
26.316 + // it must be derived by extension.
26.317 +// The ArrayList does not contain its own type + has the other types only once
26.318 + //
26.319 + private TreeMap typeTree;
26.320 +
26.321 + /**
26.322 + * configure LOGGER
26.323 + */
26.324 + static {
26.325 + Layout layout = new SimpleLayout();
26.326 + LOGGER.addAppender(new ConsoleAppender(layout));
26.327 + }
26.328 +
26.329 + /**
26.330 + * Creates a new instance of AbstractSchemaFormBuilder
26.331 + */
26.332 + public AbstractSchemaFormBuilder(String rootTagName) {
26.333 + this._rootTagName = rootTagName;
26.334 + typeTree = new TreeMap();
26.335 + properties = new Properties();
26.336 +
26.337 + DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
26.338 +
26.339 + try {
26.340 + factory.setNamespaceAware(true);
26.341 + factory.setValidating(false);
26.342 + documentBuilder = factory.newDocumentBuilder();
26.343 + } catch (ParserConfigurationException x) {
26.344 + x.printStackTrace();
26.345 + }
26.346 +
26.347 + //default wrapper: HTML
26.348 + //_wrapper = new BaseWrapperElementsBuilder();
26.349 + _wrapper = new XHTMLWrapperElementsBuilder();
26.350 + reset();
26.351 + }
26.352 +
26.353 + /**
26.354 + * Creates a new instance of AbstractSchemaFormBuilder
26.355 + */
26.356 + public AbstractSchemaFormBuilder(String rootTagName, boolean writable, Map defaultValues) {
26.357 + this._rootTagName = rootTagName;
26.358 + typeTree = new TreeMap();
26.359 + properties = new Properties();
26.360 +
26.361 + DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
26.362 +
26.363 + try {
26.364 + factory.setNamespaceAware(true);
26.365 + factory.setValidating(false);
26.366 + documentBuilder = factory.newDocumentBuilder();
26.367 + } catch (ParserConfigurationException x) {
26.368 + x.printStackTrace();
26.369 + }
26.370 +
26.371 + //default wrapper: HTML
26.372 + //_wrapper = new BaseWrapperElementsBuilder();
26.373 + _wrapper = new XHTMLWrapperElementsBuilder();
26.374 + reset();
26.375 + this.writable = writable;
26.376 + this.defaultValues = defaultValues;
26.377 + }
26.378 +
26.379 +
26.380 + /**
26.381 + * Creates a new AbstractSchemaFormBuilder object.
26.382 + *
26.383 + * @param rootTagName __UNDOCUMENTED__
26.384 + * @param instanceSource __UNDOCUMENTED__
26.385 + * @param action __UNDOCUMENTED__
26.386 + * @param submitMethod __UNDOCUMENTED__
26.387 + * @param wrapper __UNDOCUMENTED__
26.388 + * @param stylesheet __UNDOCUMENTED__
26.389 + */
26.390 + public AbstractSchemaFormBuilder(String rootTagName,
26.391 + Source instanceSource,
26.392 + String action,
26.393 + String submitMethod,
26.394 + WrapperElementsBuilder wrapper,
26.395 + String stylesheet,
26.396 + String base,
26.397 + boolean userSchemaTypes,
26.398 + boolean writable,
26.399 + Map defaultValues) {
26.400 + this(rootTagName);
26.401 + this._instanceSource = instanceSource;
26.402 +
26.403 + if (instanceSource != null) {
26.404 + this._instanceMode =
26.405 + AbstractSchemaFormBuilder.INSTANCE_MODE_INCLUDED;
26.406 + }
26.407 +
26.408 + this._action = action;
26.409 + this._stylesheet = stylesheet;
26.410 + this._base = base;
26.411 + this._useSchemaTypes = userSchemaTypes;
26.412 +
26.413 + //control if it is one of the SUBMIT_METHOD attributes?
26.414 + this._submitMethod = submitMethod;
26.415 + this._wrapper = wrapper;
26.416 + this.writable = writable;
26.417 + this.defaultValues = defaultValues;
26.418 + }
26.419 +
26.420 + /**
26.421 + * Creates a new AbstractSchemaFormBuilder object.
26.422 + *
26.423 + * @param rootTagName __UNDOCUMENTED__
26.424 + * @param instanceHref __UNDOCUMENTED__
26.425 + * @param action __UNDOCUMENTED__
26.426 + * @param submitMethod __UNDOCUMENTED__
26.427 + * @param wrapper __UNDOCUMENTED__
26.428 + * @param stylesheet __UNDOCUMENTED__
26.429 + */
26.430 + public AbstractSchemaFormBuilder(String rootTagName,
26.431 + String instanceHref,
26.432 + String action,
26.433 + String submitMethod,
26.434 + WrapperElementsBuilder wrapper,
26.435 + String stylesheet,
26.436 + String base,
26.437 + boolean userSchemaTypes,
26.438 + boolean writable,
26.439 + Map defaultValues
26.440 + ) {
26.441 + this(rootTagName);
26.442 + this._instanceHref = instanceHref;
26.443 +
26.444 + if ((instanceHref != null) && !instanceHref.equals("")) {
26.445 + this._instanceMode = AbstractSchemaFormBuilder.INSTANCE_MODE_HREF;
26.446 + }
26.447 +
26.448 + this._action = action;
26.449 + this._stylesheet = stylesheet;
26.450 + this._base = base;
26.451 + this._useSchemaTypes = userSchemaTypes;
26.452 +
26.453 + //control if it is one of the SUBMIT_METHOD attributes?
26.454 + this._submitMethod = submitMethod;
26.455 + this._wrapper = wrapper;
26.456 + this.writable = writable;
26.457 + this.defaultValues = defaultValues;
26.458 +
26.459 + }
26.460 +
26.461 + /**
26.462 + * __UNDOCUMENTED__
26.463 + *
26.464 + * @return __UNDOCUMENTED__
26.465 + */
26.466 + public String getAction() {
26.467 + return _action;
26.468 + }
26.469 +
26.470 + /**
26.471 + * __UNDOCUMENTED__
26.472 + *
26.473 + * @return __UNDOCUMENTED__
26.474 + */
26.475 + public String getInstanceHref() {
26.476 + return _instanceHref;
26.477 + }
26.478 +
26.479 + /**
26.480 + * __UNDOCUMENTED__
26.481 + *
26.482 + * @return __UNDOCUMENTED__
26.483 + */
26.484 + public int getInstanceMode() {
26.485 + return _instanceMode;
26.486 + }
26.487 +
26.488 + /**
26.489 + * __UNDOCUMENTED__
26.490 + *
26.491 + * @return __UNDOCUMENTED__
26.492 + */
26.493 + public Source getInstanceSource() {
26.494 + return _instanceSource;
26.495 + }
26.496 +
26.497 + /**
26.498 + * __UNDOCUMENTED__
26.499 + *
26.500 + * @return __UNDOCUMENTED__
26.501 + */
26.502 + public Properties getProperties() {
26.503 + return properties;
26.504 + }
26.505 +
26.506 + /**
26.507 + * __UNDOCUMENTED__
26.508 + *
26.509 + * @param key __UNDOCUMENTED__
26.510 + * @param value __UNDOCUMENTED__
26.511 + */
26.512 + public void setProperty(String key, String value) {
26.513 + getProperties().setProperty(key, value);
26.514 + }
26.515 +
26.516 + /**
26.517 + * __UNDOCUMENTED__
26.518 + *
26.519 + * @param key __UNDOCUMENTED__
26.520 + * @return __UNDOCUMENTED__
26.521 + */
26.522 + public String getProperty(String key) {
26.523 + return getProperties().getProperty(key);
26.524 + }
26.525 +
26.526 + /**
26.527 + * __UNDOCUMENTED__
26.528 + *
26.529 + * @param key __UNDOCUMENTED__
26.530 + * @param defaultValue __UNDOCUMENTED__
26.531 + * @return __UNDOCUMENTED__
26.532 + */
26.533 + public String getProperty(String key, String defaultValue) {
26.534 + return getProperties().getProperty(key, defaultValue);
26.535 + }
26.536 +
26.537 + /**
26.538 + * __UNDOCUMENTED__
26.539 + *
26.540 + * @return __UNDOCUMENTED__
26.541 + */
26.542 + public String getRootTagName() {
26.543 + return _rootTagName;
26.544 + }
26.545 +
26.546 + /**
26.547 + * __UNDOCUMENTED__
26.548 + *
26.549 + * @return __UNDOCUMENTED__
26.550 + */
26.551 + public String getStylesheet() {
26.552 + return _stylesheet;
26.553 + }
26.554 +
26.555 + /**
26.556 + * __UNDOCUMENTED__
26.557 + *
26.558 + * @return __UNDOCUMENTED__
26.559 + */
26.560 + public String getSubmitMethod() {
26.561 + return _submitMethod;
26.562 + }
26.563 +
26.564 + private void loadSchema(String inputURI)
26.565 + throws
26.566 + java.lang.ClassNotFoundException,
26.567 + java.lang.InstantiationException,
26.568 + java.lang.IllegalAccessException {
26.569 +
26.570 +// Get DOM Implementation using DOM Registry
26.571 + System.setProperty(DOMImplementationRegistry.PROPERTY,
26.572 + "com.sun.org.apache.xerces.internal.dom.DOMXSImplementationSourceImpl");
26.573 + DOMImplementationRegistry registry =
26.574 + DOMImplementationRegistry.newInstance();
26.575 +
26.576 + Object o = registry.getDOMImplementation("XS-Loader");
26.577 + System.out.println (o.getClass().getName());
26.578 + if (o instanceof XSImplementation) {
26.579 + XSImplementation impl = (XSImplementation) o;
26.580 + XSLoader schemaLoader = impl.createXSLoader(null);
26.581 + schema = schemaLoader.loadURI(inputURI);
26.582 + } else if (o != null) {
26.583 + if (LOGGER.isDebugEnabled()) {
26.584 + LOGGER.debug("DOMImplementation is not a XSImplementation: "
26.585 + + o.getClass().getName());
26.586 + }
26.587 + System.exit(1);
26.588 + }
26.589 + }
26.590 +
26.591 + /**
26.592 + * builds a form from a XML schema.
26.593 + *
26.594 + * @param inputURI the URI of the Schema to be used
26.595 + * @return __UNDOCUMENTED__
26.596 + * @throws FormBuilderException __UNDOCUMENTED__
26.597 + */
26.598 + public Document buildForm(String inputURI) throws FormBuilderException {
26.599 + try {
26.600 + this.loadSchema(inputURI);
26.601 + buildTypeTree(schema);
26.602 +
26.603 + //refCounter = 0;
26.604 + counter = new HashMap();
26.605 +
26.606 + Document xForm =
26.607 + createFormTemplate(_rootTagName,
26.608 + _rootTagName + " Form",
26.609 + getProperty(CSS_STYLE_PROP, DEFAULT_CSS_STYLE_PROP));
26.610 +
26.611 + //this.buildInheritenceTree(schema);
26.612 + Element envelopeElement = xForm.getDocumentElement();
26.613 +
26.614 + //Element formSection = (Element) envelopeElement.getElementsByTagNameNS(CHIBA_NS, "form").item(0);
26.615 + //Element formSection =(Element) envelopeElement.getElementsByTagName("body").item(0);
26.616 + //find form element: last element created
26.617 + NodeList children = xForm.getDocumentElement().getChildNodes();
26.618 + int nb = children.getLength();
26.619 + Element formSection = (Element) children.item(nb - 1);
26.620 +
26.621 + Element modelSection =
26.622 + (Element) envelopeElement.getElementsByTagNameNS(XFORMS_NS,
26.623 + "model").item(0);
26.624 +
26.625 + //add XMLSchema if we use schema types
26.626 + if (_useSchemaTypes && modelSection != null) {
26.627 + modelSection.setAttribute("schema",
26.628 + inputURI);
26.629 + }
26.630 +
26.631 + //change stylesheet
26.632 + String stylesheet = this.getStylesheet();
26.633 +
26.634 + if ((stylesheet != null) && !stylesheet.equals("")) {
26.635 + envelopeElement.setAttribute("stylesheet",
26.636 + stylesheet);
26.637 + }
26.638 +
26.639 + // TODO: Commented out because comments aren't output properly by the Transformer.
26.640 + //String comment = "This XForm was automatically generated by " + this.getClass().getName() + " on " + (new Date()) + System.getProperty("line.separator") + " from the '" + rootElementName + "' element from the '" + schema.getSchemaTargetNS() + "' XML Schema.";
26.641 + //xForm.insertBefore(xForm.createComment(comment),envelopeElement);
26.642 + //xxx XSDNode node = findXSDNodeByName(rootElementTagName,schemaNode.getElementSet());
26.643 +
26.644 + //check if target namespace
26.645 + //no way to do this with XS API ? load DOM document ?
26.646 + //TODO: find a better way to find the targetNamespace
26.647 + try {
26.648 + Document domDoc = DOMUtil.parseXmlFile(inputURI, true, false);
26.649 + if (domDoc != null) {
26.650 + Element root = domDoc.getDocumentElement();
26.651 + targetNamespace = root.getAttribute("targetNamespace");
26.652 + if (targetNamespace != null && targetNamespace.equals(""))
26.653 + targetNamespace = null;
26.654 + }
26.655 + } catch (Exception ex) {
26.656 + LOGGER.error("Schema not loaded as DOM document: " + ex.getMessage());
26.657 + }
26.658 +
26.659 + //if target namespace & we use the schema types: add it to form ns declarations
26.660 + if (_useSchemaTypes && targetNamespace != null && !targetNamespace.equals("")) {
26.661 + envelopeElement.setAttribute(
26.662 + "schema",
26.663 + targetNamespace);
26.664 + }
26.665 +
26.666 + //TODO: WARNING: in Xerces 2.6.1, parameters are switched !!! (name, namespace)
26.667 + //XSElementDeclaration rootElementDecl =schema.getElementDeclaration(targetNamespace, _rootTagName);
26.668 + XSElementDeclaration rootElementDecl =
26.669 + schema.getElementDeclaration(_rootTagName, targetNamespace);
26.670 +
26.671 + if (rootElementDecl == null) {
26.672 + //DEBUG
26.673 + rootElementDecl =
26.674 + schema.getElementDeclaration(_rootTagName, targetNamespace);
26.675 + if (rootElementDecl != null && LOGGER.isDebugEnabled())
26.676 + LOGGER.debug("getElementDeclaration: inversed parameters OK !!!");
26.677 +
26.678 + throw new FormBuilderException("Invalid root element tag name ["
26.679 + + _rootTagName
26.680 + + ", targetNamespace="
26.681 + + targetNamespace
26.682 + + "]");
26.683 + }
26.684 +
26.685 + Element instanceElement =
26.686 + (Element) modelSection.appendChild(xForm.createElementNS(XFORMS_NS,
26.687 + getXFormsNSPrefix() + "instance"));
26.688 + this.setXFormsId(instanceElement);
26.689 +
26.690 + Element rootElement;
26.691 +
26.692 + if (_instanceMode == AbstractSchemaFormBuilder.INSTANCE_MODE_NONE) {
26.693 + rootElement = (Element) instanceElement.appendChild(xForm.createElementNS(targetNamespace, getElementName(rootElementDecl, xForm)));
26.694 +
26.695 + String prefix = xmlSchemaInstancePrefix.substring(0, xmlSchemaInstancePrefix.length() - 1);
26.696 + rootElement.setAttribute(prefix, XMLSCHEMA_INSTANCE_NAMESPACE_URI);
26.697 +
26.698 + } else if (_instanceMode == AbstractSchemaFormBuilder.INSTANCE_MODE_INCLUDED)
26.699 + //get the instance element
26.700 + {
26.701 + boolean ok = true;
26.702 +
26.703 + try {
26.704 + /*DOMResult result = new DOMResult();
26.705 + TransformerFactory trFactory =
26.706 + TransformerFactory.newInstance();
26.707 + Transformer tr = trFactory.newTransformer();
26.708 + tr.transform(_instanceSource, result);
26.709 + Document instanceDoc = (Document) result.getNode();*/
26.710 + DocumentBuilderFactory docFact = DocumentBuilderFactory.newInstance();
26.711 + docFact.setNamespaceAware(true);
26.712 + docFact.setValidating(false);
26.713 + DocumentBuilder parser = docFact.newDocumentBuilder();
26.714 + Document instanceDoc = parser.parse(new InputSource(_instanceSource.getSystemId()));
26.715 +
26.716 +//possibility abandonned for the moment:
26.717 +//modify the instance to add the correct "xsi:type" attributes wherever needed
26.718 +//Document instanceDoc=this.setXMLSchemaAndPSVILoad(inputURI, _instanceSource, targetNamespace);
26.719 +
26.720 + if (instanceDoc != null) {
26.721 + Element instanceInOtherDoc =
26.722 + instanceDoc.getDocumentElement();
26.723 +
26.724 + if (instanceInOtherDoc
26.725 + .getNodeName()
26.726 + .equals(_rootTagName)) {
26.727 + rootElement =
26.728 + (Element) xForm.importNode(instanceInOtherDoc,
26.729 + true);
26.730 + instanceElement.appendChild(rootElement);
26.731 +
26.732 +//add XMLSchema instance NS
26.733 + String prefix = xmlSchemaInstancePrefix.substring(0, xmlSchemaInstancePrefix.length() - 1);
26.734 + if (!rootElement.hasAttributeNS(XMLNS_NAMESPACE_URI, prefix))
26.735 + rootElement.setAttribute("xmlns:" + prefix, XMLSCHEMA_INSTANCE_NAMESPACE_URI);
26.736 +
26.737 +//possibility abandonned for the moment:
26.738 +//modify the instance to add the correct "xsi:type" attributes wherever needed
26.739 +//this.addXSITypeAttributes(rootElement);
26.740 + } else {
26.741 + ok = false;
26.742 + }
26.743 + } else {
26.744 + ok = false;
26.745 + }
26.746 + } catch (Exception ex) {
26.747 + ex.printStackTrace();
26.748 +
26.749 + //if there is an exception we put the empty root element
26.750 + ok = false;
26.751 + }
26.752 +
26.753 + //if there was a problem
26.754 + if (!ok) {
26.755 + rootElement =
26.756 + (Element) instanceElement.appendChild(xForm.createElement(_rootTagName));
26.757 + }
26.758 + } else if (
26.759 + _instanceMode == AbstractSchemaFormBuilder.INSTANCE_MODE_HREF)
26.760 + //add the xlink:href attribute
26.761 + {
26.762 + instanceElement.setAttribute("href",
26.763 + _instanceHref);
26.764 + }
26.765 +
26.766 + Element formContentWrapper =
26.767 + _wrapper.createGroupContentWrapper(formSection);
26.768 + addElement(xForm,
26.769 + modelSection,
26.770 + formContentWrapper,
26.771 + rootElementDecl,
26.772 + rootElementDecl.getTypeDefinition(),
26.773 + "/" + getElementName(rootElementDecl,xForm));
26.774 +
26.775 + if (writable) {
26.776 +
26.777 + Element submitInfoElement =
26.778 + (Element) modelSection.appendChild(xForm.createElementNS(XFORMS_NS,
26.779 + getXFormsNSPrefix() + "submission"));
26.780 +
26.781 + //submitInfoElement.setAttributeNS(XFORMS_NS,getXFormsNSPrefix()+"id","save");
26.782 + String submissionId = this.setXFormsId(submitInfoElement);
26.783 +
26.784 + //action
26.785 + if (_action == null) {
26.786 + submitInfoElement.setAttribute("action",
26.787 + "");
26.788 + } else {
26.789 + submitInfoElement.setAttribute("action",
26.790 + _action);
26.791 + }
26.792 +
26.793 + //method
26.794 + if ((_submitMethod != null) && !_submitMethod.equals("")) {
26.795 + submitInfoElement.setAttribute("method",
26.796 + _submitMethod);
26.797 + } else { //default is "post"
26.798 + submitInfoElement.setAttribute("method",
26.799 + AbstractSchemaFormBuilder.SUBMIT_METHOD_POST);
26.800 + }
26.801 +
26.802 + //Element submitButton = (Element) formSection.appendChild(xForm.createElementNS(XFORMS_NS,getXFormsNSPrefix()+"submit"));
26.803 + Element submitButton =
26.804 + xForm.createElementNS(XFORMS_NS,
26.805 + getXFormsNSPrefix() + "submit");
26.806 + Element submitControlWrapper =
26.807 + _wrapper.createControlsWrapper(submitButton);
26.808 + formContentWrapper.appendChild(submitControlWrapper);
26.809 + submitButton.setAttribute("submission",
26.810 + "default-submission");
26.811 + this.setXFormsId(submitButton);
26.812 +
26.813 + Element submitButtonCaption =
26.814 + (Element) submitButton.appendChild(xForm.createElementNS(XFORMS_NS,
26.815 + getXFormsNSPrefix() + "label"));
26.816 + submitButtonCaption.appendChild(xForm.createTextNode("Submit"));
26.817 +
26.818 + if (defaultSets.size() > 0) {
26.819 + Element action = (Element) submitButton.appendChild(xForm.createElementNS(XFORMS_NS,
26.820 + getXFormsNSPrefix() + "action"));
26.821 + action.setAttributeNS(XMLEVENTS_NS, xmleventsNSPrefix + "event", "DOMActivate");
26.822 +
26.823 + for (Iterator it = defaultSets.entrySet().iterator(); it.hasNext();) {
26.824 + Map.Entry entry = (Map.Entry) it.next();
26.825 + Element setValue = (Element) action.appendChild(xForm.createElementNS(XFORMS_NS,
26.826 + getXFormsNSPrefix() + "setvalue"));
26.827 +// addNameSpaces(setValue);
26.828 + setValue.setAttribute("model", "outputMode");
26.829 + setValue.setAttribute("ref", (String) entry.getKey());
26.830 + setValue.setAttribute("value", (String) entry.getValue());
26.831 + }
26.832 + }
26.833 + this.setXFormsId(submitButtonCaption);
26.834 + }
26.835 +
26.836 + return xForm;
26.837 + } catch (ParserConfigurationException x) {
26.838 + throw new FormBuilderException(x);
26.839 + } catch (java.lang.ClassNotFoundException x) {
26.840 + throw new FormBuilderException(x);
26.841 + } catch (java.lang.InstantiationException x) {
26.842 + throw new FormBuilderException(x);
26.843 + } catch (java.lang.IllegalAccessException x) {
26.844 + throw new FormBuilderException(x);
26.845 + }
26.846 + }
26.847 +
26.848 + /**
26.849 + * method to load the instance document using PSVI, by first setting the location of the schema,
26.850 + * resaving it in XML and reloading it with Xerces XMLSchema's API
26.851 + * ABANDONNED -> NOT TESTED
26.852 + **/
26.853 + /*private Document setXMLSchemaAndPSVILoad(String inputURI, Source instanceSource, String targetNamespace){
26.854 + Document newDoc=null;
26.855 +
26.856 + try{
26.857 + //load doc
26.858 + DocumentBuilderFactory domfact=DocumentBuilderFactory.newInstance();
26.859 + domfact.setNamespaceAware(true);
26.860 + DocumentBuilder builder=domfact.newDocumentBuilder();
26.861 + Document doc =builder.parse(new InputSource(instanceSource.getSystemId()));
26.862 + Element rootElement=doc.getDocumentElement();
26.863 +
26.864 + //set namespace & schema location
26.865 + String prefix=xmlSchemaInstancePrefix.substring(0, xmlSchemaInstancePrefix.length()-1);
26.866 + String attr_ns=rootElement.getAttributeNS(XMLNS_NAMESPACE_URI, prefix);
26.867 + if(attr_ns==null || attr_ns.equals("")){
26.868 + rootElement.setAttributeNS(XMLNS_NAMESPACE_URI,"xmlns:"+prefix,XMLSCHEMA_INSTANCE_NAMESPACE_URI);
26.869 + }
26.870 + String attr_val1=rootElement.getAttributeNS(XMLSCHEMA_INSTANCE_NAMESPACE_URI, "noNamespaceSchemaLocation");
26.871 + String attr_val2=rootElement.getAttributeNS(XMLSCHEMA_INSTANCE_NAMESPACE_URI, "schemaLocation");
26.872 + if( (attr_val1==null || attr_val1.equals("") )
26.873 + && (attr_val2==null || attr_val2.equals("") )
26.874 + ){
26.875 + if(targetNamespace==null || targetNamespace.equals(""))
26.876 + rootElement.setAttributeNS(XMLSCHEMA_INSTANCE_NAMESPACE_URI, xmlSchemaInstancePrefix+"noNamespaceSchemaLocation", inputURI);
26.877 + else
26.878 + rootElement.setAttributeNS(XMLSCHEMA_INSTANCE_NAMESPACE_URI, xmlSchemaInstancePrefix+"schemaLocation", inputURI);
26.879 + }
26.880 +
26.881 + //save the file
26.882 + DOMSource source=new DOMSource(doc);
26.883 + File f=File.createTempFile("instance", ".xml");
26.884 + StreamResult result2=new StreamResult(f);
26.885 + TransformerFactory trFactory =TransformerFactory.newInstance();
26.886 + Transformer tr = trFactory.newTransformer();
26.887 + tr.transform(source, result2);
26.888 +
26.889 + //reload it with PSVI
26.890 + newDoc=this.PSVIParse(f);
26.891 +
26.892 + }
26.893 + catch(javax.xml.transform.TransformerConfigurationException ex){
26.894 + LOGGER.error("TransformerConfigurationException in setXMLSchemaAndPSVILoad", ex);
26.895 + }
26.896 + catch(javax.xml.transform.TransformerException ex){
26.897 + LOGGER.error("TransformerException in setXMLSchemaAndPSVILoad", ex);
26.898 + }
26.899 + catch(java.io.IOException ex){
26.900 + LOGGER.error("IOException in setXMLSchemaAndPSVILoad", ex);
26.901 + }
26.902 + catch(javax.xml.parsers.ParserConfigurationException ex){
26.903 + LOGGER.error("ParserConfigurationException in setXMLSchemaAndPSVILoad", ex);
26.904 + }
26.905 + catch(org.xml.sax.SAXException ex){
26.906 + LOGGER.error("SAXException in setXMLSchemaAndPSVILoad", ex);
26.907 + }
26.908 +
26.909 + return newDoc;
26.910 + }*/
26.911 +
26.912 + /*
26.913 + *Method to parse a file with PSVI
26.914 + * ABANDONNED -> NOT TESTED
26.915 + */
26.916 + /*
26.917 + public Document PSVIParse(File f){
26.918 + Document doc=null;
26.919 + try{
26.920 + DOMParser parser=new DOMParser();
26.921 + parser.setFeature("http://xml.org/sax/features/validation", true);
26.922 + parser.setFeature("http://apache.org/xml/features/validation/schema", true);
26.923 + parser.setFeature("http://apache.org/xml/features/validation/schema-full-checking", true);
26.924 + parser.setFeature("http://apache.org/xml/features/continue-after-fatal-error", true);
26.925 + parser.setProperty("http://apache.org/xml/properties/dom/document-class-name", "org.apache.xerces.dom.PSVIDocumentImpl");
26.926 + FileInputStream fin=new FileInputStream(f);
26.927 + InputSource source=new InputSource(fin);
26.928 + parser.parse(source);
26.929 + doc=parser.getDocument();
26.930 + }catch(org.xml.sax.SAXNotRecognizedException ex){
26.931 + LOGGER.error("SAXNotRecognizedException for parameter in PSVIParse", ex);
26.932 + }
26.933 + catch(java.io.FileNotFoundException ex){
26.934 + LOGGER.error("FileNotFoundException for "+f.getAbsolutePath()+" in PSVIParse", ex);
26.935 + }
26.936 + catch(org.xml.sax.SAXException ex){
26.937 + LOGGER.error("SAXException while loading "+f.getAbsolutePath()+" in PSVIParse", ex);
26.938 + }
26.939 + catch(java.io.IOException ex){
26.940 + LOGGER.error("IOException while loading "+f.getAbsolutePath()+" in PSVIParse", ex);
26.941 + }
26.942 + return doc;
26.943 + }
26.944 + */
26.945 +
26.946 + /**
26.947 + * add a "@xsi:type" attribute for all elements of type that are extended
26.948 + * with default value = the type if not abstract, otherwise the first non abstract subtype
26.949 + * ABANDONNED -> NOT TESTED
26.950 + **/
26.951 + /*private void addXSITypeAttributes(Element element){
26.952 + if(element!=null){
26.953 + String ns=element.getNamespaceURI();
26.954 +
26.955 + //set it on this element if it's not already here
26.956 + String attr=element.getAttributeNS(XMLSCHEMA_INSTANCE_NAMESPACE_URI, "type");
26.957 + if(attr==null || attr.equals("")){
26.958 +
26.959 + ElementPSVI el=(ElementPSVI) element;
26.960 + if(el!=null){
26.961 + if(LOGGER.isDebugEnabled())
26.962 + LOGGER.debug("PSVIElement found for "+element.getNodeName()+". Testing type");
26.963 +
26.964 + XSElementDeclaration elDecl=el.getElementDeclaration();
26.965 + XSTypeDefinition type=elDecl.getTypeDefinition();
26.966 + if(type.getTypeCategory()==XSTypeDefinition.COMPLEX_TYPE){
26.967 + XSComplexTypeDefinition complexType=(XSComplexTypeDefinition) type;
26.968 +
26.969 + TreeSet compatibleTypes =(TreeSet) typeTree.get(complexType.getName());
26.970 + if(compatibleTypes!=null && !compatibleTypes.isEmpty()){
26.971 + if(LOGGER.isDebugEnabled())
26.972 + LOGGER.debug("compatible type found for "+element.getNodeName()+" -> setting xsi:type attribute");
26.973 +
26.974 + //add xsi:type attribute
26.975 +
26.976 + //find value of attribute
26.977 + String value=null;
26.978 + if(!complexType.getAbstract())
26.979 + value=complexType.getName();
26.980 + else{ //find the first non abstract subtype
26.981 + Iterator it=compatibleTypes.iterator();
26.982 + while(it.hasNext() && value==null){
26.983 + String subTypeName=(String) it.next();
26.984 + //find type definition
26.985 + XSTypeDefinition subType=schema.getTypeDefinition(subTypeName, ns);
26.986 + if(subType!=null && subType.getTypeCategory()==XSTypeDefinition.COMPLEX_TYPE){
26.987 + XSComplexTypeDefinition subComplexType=(XSComplexTypeDefinition) subType;
26.988 + if(!subComplexType.getAbstract())
26.989 + value=subComplexType.getName();
26.990 + }
26.991 + }
26.992 + }
26.993 +
26.994 + //set attribute
26.995 + element.setAttributeNS(XMLSCHEMA_INSTANCE_NAMESPACE_URI, this.xmlSchemaInstancePrefix+"type", value);
26.996 + }
26.997 + }
26.998 + }
26.999 + }
26.1000 +
26.1001 + //recursive call
26.1002 + NodeList children=element.getChildNodes();
26.1003 + int nb=children.getLength();
26.1004 + for(int i=0;i<nb;i++){
26.1005 + Node child=children.item(i);
26.1006 + if(child.getNodeType()==Node.ELEMENT_NODE){
26.1007 + this.addXSITypeAttributes((Element) child);
26.1008 + }
26.1009 + }
26.1010 + }
26.1011 + }*/
26.1012 +
26.1013 + /**
26.1014 + * __UNDOCUMENTED__
26.1015 + *
26.1016 + * @param inputURI the URI of the XML Schema to be used
26.1017 + * @return __UNDOCUMENTED__
26.1018 + * @throws FormBuilderException __UNDOCUMENTED__
26.1019 + */
26.1020 + public String buildFormAsString(String inputURI)
26.1021 + throws FormBuilderException {
26.1022 + Document xForm = buildForm(inputURI);
26.1023 +
26.1024 + if (xForm != null) {
26.1025 + StringWriter stringWriter = new StringWriter();
26.1026 +
26.1027 + try {
26.1028 + TransformerFactory factory = TransformerFactory.newInstance();
26.1029 + Transformer transformer = factory.newTransformer();
26.1030 + StreamResult result = new StreamResult(stringWriter);
26.1031 + transformer.transform(new DOMSource(xForm), result);
26.1032 +
26.1033 + return stringWriter.getBuffer().toString();
26.1034 + } catch (TransformerConfigurationException x) {
26.1035 + throw new FormBuilderException(x);
26.1036 + } catch (TransformerException x) {
26.1037 + throw new FormBuilderException(x);
26.1038 + }
26.1039 + }
26.1040 +
26.1041 + return "";
26.1042 + }
26.1043 +
26.1044 + /**
26.1045 + * This method is invoked after the form builder is finished creating and processing
26.1046 + * a form control. Implementations may choose to use this method to add/inspect/modify
26.1047 + * the controlElement prior to the builder moving onto the next control.
26.1048 + *
26.1049 + * @param controlElement The form control element that was created.
26.1050 + * @param controlType The XML Schema type for which <b>controlElement</b> was created.
26.1051 + */
26.1052 + public void endFormControl(Element controlElement,
26.1053 + XSTypeDefinition controlType,
26.1054 + int minOccurs,
26.1055 + int maxOccurs) {
26.1056 + }
26.1057 +
26.1058 + /**
26.1059 + * __UNDOCUMENTED__
26.1060 + */
26.1061 + public void reset() {
26.1062 + //refCounter = 0;
26.1063 + counter = new HashMap();
26.1064 + setProperty(CSS_STYLE_PROP, DEFAULT_CSS_STYLE_PROP);
26.1065 + setProperty(SELECTMANY_LONG_LIST_SIZE_PROP, DEFAULT_LONG_LIST_MAX_SIZE);
26.1066 + setProperty(SELECTMANY_UI_CONTROL_SHORT_PROP,
26.1067 + DEFAULT_SELECTMANY_UI_CONTROL_SHORT_PROP);
26.1068 + setProperty(SELECTMANY_UI_CONTROL_LONG_PROP,
26.1069 + DEFAULT_SELECTMANY_UI_CONTROL_LONG_PROP);
26.1070 + setProperty(SELECTONE_LONG_LIST_SIZE_PROP, DEFAULT_LONG_LIST_MAX_SIZE);
26.1071 + setProperty(SELECTONE_UI_CONTROL_SHORT_PROP,
26.1072 + DEFAULT_SELECTONE_UI_CONTROL_SHORT_PROP);
26.1073 + setProperty(SELECTONE_UI_CONTROL_LONG_PROP,
26.1074 + DEFAULT_SELECTONE_UI_CONTROL_LONG_PROP);
26.1075 + setProperty(GROUP_BOX_ALIGN_PROP, DEFAULT_GROUP_BOX_ALIGN);
26.1076 + setProperty(GROUP_BOX_ORIENT_PROP, DEFAULT_GROUP_BOX_ORIENT);
26.1077 + setProperty(GROUP_CAPTION_WIDTH_PROP, DEFAULT_GROUP_CAPTION_WIDTH);
26.1078 + setProperty(GROUP_WIDTH_PROP, DEFAULT_GROUP_WIDTH);
26.1079 + setProperty(GROUP_BORDER_PROP, DEFAULT_GROUP_BORDER);
26.1080 + }
26.1081 +
26.1082 + /**
26.1083 + * Returns the most-specific built-in base type for the provided type.
26.1084 + */
26.1085 + protected short getBuiltInType(XSTypeDefinition type) {
26.1086 + // type.getName() may be 'null' for anonymous types, so compare against
26.1087 + // static string (see bug #1172541 on sf.net)
26.1088 + if (("anyType").equals(type.getName())) {
26.1089 + return XSConstants.ANYSIMPLETYPE_DT;
26.1090 + } else {
26.1091 + XSSimpleTypeDefinition simpleType = (XSSimpleTypeDefinition) type;
26.1092 +
26.1093 + //get built-in type
26.1094 + //only working method found: getBuiltInKind, but it returns a short !
26.1095 + //XSTypeDefinition builtIn = simpleType.getPrimitiveType();
26.1096 + /*XSTypeDefinition builtIn = type.getBaseType();
26.1097 + if (builtIn == null) {
26.1098 + // always null for a ListType
26.1099 + if (simpleType.getItemType() != null) //if not null it's a list
26.1100 + return getBuiltInType(simpleType.getItemType());
26.1101 + else
26.1102 + return simpleType;
26.1103 + }
26.1104 + else if(LOGGER.isDebugEnabled())
26.1105 + LOGGER.debug(" -> builtinType="+builtIn.getName());
26.1106 + return builtIn;*/
26.1107 +
26.1108 + short result = simpleType.getBuiltInKind();
26.1109 + if (result == XSConstants.LIST_DT) {
26.1110 + result = getBuiltInType(simpleType.getItemType());
26.1111 + }
26.1112 + return result;
26.1113 + }
26.1114 + }
26.1115 +
26.1116 + /**
26.1117 + * get the name of a datatype defined by its value in XSConstants
26.1118 + * TODO: find an automatic way to do this !
26.1119 + *
26.1120 + * @param dt the short representating this datatype from XSConstants
26.1121 + * @return the name of the datatype
26.1122 + */
26.1123 + public String getDataTypeName(short dt) {
26.1124 + String name = "";
26.1125 + switch (dt) {
26.1126 + case XSConstants.ANYSIMPLETYPE_DT:
26.1127 + name = "anyType";
26.1128 + break;
26.1129 + case XSConstants.ANYURI_DT:
26.1130 + name = "anyURI";
26.1131 + break;
26.1132 + case XSConstants.BASE64BINARY_DT:
26.1133 + name = "base64Binary";
26.1134 + break;
26.1135 + case XSConstants.BOOLEAN_DT:
26.1136 + name = "boolean";
26.1137 + break;
26.1138 + case XSConstants.BYTE_DT:
26.1139 + name = "byte";
26.1140 + break;
26.1141 + case XSConstants.DATE_DT:
26.1142 + name = "date";
26.1143 + break;
26.1144 + case XSConstants.DATETIME_DT:
26.1145 + name = "dateTime";
26.1146 + break;
26.1147 + case XSConstants.DECIMAL_DT:
26.1148 + name = "decimal";
26.1149 + break;
26.1150 + case XSConstants.DOUBLE_DT:
26.1151 + name = "double";
26.1152 + break;
26.1153 + case XSConstants.DURATION_DT:
26.1154 + name = "duration";
26.1155 + break;
26.1156 + case XSConstants.ENTITY_DT:
26.1157 + name = "ENTITY";
26.1158 + break;
26.1159 + case XSConstants.FLOAT_DT:
26.1160 + name = "float";
26.1161 + break;
26.1162 + case XSConstants.GDAY_DT:
26.1163 + name = "gDay";
26.1164 + break;
26.1165 + case XSConstants.GMONTH_DT:
26.1166 + name = "gMonth";
26.1167 + break;
26.1168 + case XSConstants.GMONTHDAY_DT:
26.1169 + name = "gMonthDay";
26.1170 + break;
26.1171 + case XSConstants.GYEAR_DT:
26.1172 + name = "gYear";
26.1173 + break;
26.1174 + case XSConstants.GYEARMONTH_DT:
26.1175 + name = "gYearMonth";
26.1176 + break;
26.1177 + case XSConstants.ID_DT:
26.1178 + name = "ID";
26.1179 + break;
26.1180 + case XSConstants.IDREF_DT:
26.1181 + name = "IDREF";
26.1182 + break;
26.1183 + case XSConstants.INT_DT:
26.1184 + name = "int";
26.1185 + break;
26.1186 + case XSConstants.INTEGER_DT:
26.1187 + name = "integer";
26.1188 + break;
26.1189 + case XSConstants.LANGUAGE_DT:
26.1190 + name = "language";
26.1191 + break;
26.1192 + case XSConstants.LONG_DT:
26.1193 + name = "long";
26.1194 + break;
26.1195 + case XSConstants.NAME_DT:
26.1196 + name = "Name";
26.1197 + break;
26.1198 + case XSConstants.NCNAME_DT:
26.1199 + name = "NCName";
26.1200 + break;
26.1201 + case XSConstants.NEGATIVEINTEGER_DT:
26.1202 + name = "negativeInteger";
26.1203 + break;
26.1204 + case XSConstants.NMTOKEN_DT:
26.1205 + name = "NMTOKEN";
26.1206 + break;
26.1207 + case XSConstants.NONNEGATIVEINTEGER_DT:
26.1208 + name = "nonNegativeInteger";
26.1209 + break;
26.1210 + case XSConstants.NONPOSITIVEINTEGER_DT:
26.1211 + name = "nonPositiveInteger";
26.1212 + break;
26.1213 + case XSConstants.NORMALIZEDSTRING_DT:
26.1214 + name = "normalizedString";
26.1215 + break;
26.1216 + case XSConstants.NOTATION_DT:
26.1217 + name = "NOTATION";
26.1218 + break;
26.1219 + case XSConstants.POSITIVEINTEGER_DT:
26.1220 + name = "positiveInteger";
26.1221 + break;
26.1222 + case XSConstants.QNAME_DT:
26.1223 + name = "QName";
26.1224 + break;
26.1225 + case XSConstants.SHORT_DT:
26.1226 + name = "short";
26.1227 + break;
26.1228 + case XSConstants.STRING_DT:
26.1229 + name = "string";
26.1230 + break;
26.1231 + case XSConstants.TIME_DT:
26.1232 + name = "time";
26.1233 + break;
26.1234 + case XSConstants.TOKEN_DT:
26.1235 + name = "TOKEN";
26.1236 + break;
26.1237 + case XSConstants.UNSIGNEDBYTE_DT:
26.1238 + name = "unsignedByte";
26.1239 + break;
26.1240 + case XSConstants.UNSIGNEDINT_DT:
26.1241 + name = "unsignedInt";
26.1242 + break;
26.1243 + case XSConstants.UNSIGNEDLONG_DT:
26.1244 + name = "unsignedLong";
26.1245 + break;
26.1246 + case XSConstants.UNSIGNEDSHORT_DT:
26.1247 + name = "unsignedShort";
26.1248 + break;
26.1249 + }
26.1250 + return name;
26.1251 + }
26.1252 +
26.1253 + /**
26.1254 + * Returns the prefix for the Chiba namespace.
26.1255 + */
26.1256 + protected String getChibaNSPrefix() {
26.1257 + return chibaNSPrefix;
26.1258 + }
26.1259 +
26.1260 + /* Increments the xforms:ref attribute counter.
26.1261 + *
26.1262 + */
26.1263 + /*protected long incRefCounter() {
26.1264 + return refCounter++;
26.1265 + }*/
26.1266 + protected String setXFormsId(Element el) {
26.1267 + //remove the eventuel "id" attribute
26.1268 + if (el.hasAttributeNS(SchemaFormBuilder.XFORMS_NS, "id")) {
26.1269 + el.removeAttributeNS(SchemaFormBuilder.XFORMS_NS, "id");
26.1270 + }
26.1271 +
26.1272 + //long count=this.incIdCounter();
26.1273 + long count = 0;
26.1274 + String name = el.getLocalName();
26.1275 + Long l = (Long) counter.get(name);
26.1276 +
26.1277 + if (l != null) {
26.1278 + count = l.longValue();
26.1279 + }
26.1280 +
26.1281 + String id = name + "_" + count;
26.1282 +
26.1283 + //increment the counter
26.1284 + counter.put(name, new Long(count + 1));
26.1285 + el.setAttribute("id",
26.1286 + id);
26.1287 +
26.1288 + return id;
26.1289 + }
26.1290 +
26.1291 + /**
26.1292 + * method to set an Id to this element and to all XForms descendants of this element
26.1293 + */
26.1294 + private void resetXFormIds(Element newControl) {
26.1295 + if (newControl.getNamespaceURI() != null
26.1296 + && newControl.getNamespaceURI().equals(XFORMS_NS))
26.1297 + this.setXFormsId(newControl);
26.1298 +
26.1299 + //recursive call
26.1300 + NodeList children = newControl.getChildNodes();
26.1301 + int nb = children.getLength();
26.1302 + for (int i = 0; i < nb; i++) {
26.1303 + Node child = children.item(i);
26.1304 + if (child.getNodeType() == Node.ELEMENT_NODE)
26.1305 + this.resetXFormIds((Element) child);
26.1306 + }
26.1307 + }
26.1308 +
26.1309 + /**
26.1310 + * Returns the prefix for the XForms namespace.
26.1311 + */
26.1312 + protected String getXFormsNSPrefix() {
26.1313 + return xformsNSPrefix;
26.1314 + }
26.1315 +
26.1316 + /**
26.1317 + * Returns the prefix for the XLink namespace.
26.1318 + */
26.1319 + protected String getXLinkNSPrefix() {
26.1320 + return xlinkNSPrefix;
26.1321 + }
26.1322 +
26.1323 + /**
26.1324 + * __UNDOCUMENTED__
26.1325 + *
26.1326 + * @param xForm __UNDOCUMENTED__
26.1327 + * @param choicesElement __UNDOCUMENTED__
26.1328 + * @param choiceValues __UNDOCUMENTED__
26.1329 + */
26.1330 + protected void addChoicesForSelectControl(Document xForm,
26.1331 + Element choicesElement,
26.1332 + Vector choiceValues) {
26.1333 + // sort the enums values and then add them as choices
26.1334 + //
26.1335 + // TODO: Should really put the default value (if any) at the top of the list.
26.1336 + //
26.1337 + List sortedList = choiceValues.subList(0, choiceValues.size());
26.1338 + Collections.sort(sortedList);
26.1339 +
26.1340 + Iterator iterator = sortedList.iterator();
26.1341 +
26.1342 + while (iterator.hasNext()) {
26.1343 + String textValue = (String) iterator.next();
26.1344 + Element item =
26.1345 + xForm.createElementNS(XFORMS_NS, getXFormsNSPrefix() + "item");
26.1346 + this.setXFormsId(item);
26.1347 + choicesElement.appendChild(item);
26.1348 +
26.1349 + Element captionElement =
26.1350 + xForm.createElementNS(XFORMS_NS, getXFormsNSPrefix() + "label");
26.1351 + this.setXFormsId(captionElement);
26.1352 + item.appendChild(captionElement);
26.1353 + captionElement.appendChild(xForm.createTextNode(createCaption(textValue)));
26.1354 +
26.1355 + Element value =
26.1356 + xForm.createElementNS(XFORMS_NS, getXFormsNSPrefix() + "value");
26.1357 + this.setXFormsId(value);
26.1358 + item.appendChild(value);
26.1359 + value.appendChild(xForm.createTextNode(textValue));
26.1360 + }
26.1361 + }
26.1362 +
26.1363 + //protected void addChoicesForSelectSwitchControl(Document xForm, Element choicesElement, Vector choiceValues, String bindIdPrefix) {
26.1364 + protected void addChoicesForSelectSwitchControl(Document xForm,
26.1365 + Element choicesElement,
26.1366 + Vector choiceValues,
26.1367 + HashMap case_types) {
26.1368 +
26.1369 + if (LOGGER.isDebugEnabled()) {
26.1370 + LOGGER.debug("addChoicesForSelectSwitchControl, values=");
26.1371 + Iterator it = choiceValues.iterator();
26.1372 + while (it.hasNext()) {
26.1373 +//String name=(String) it.next();
26.1374 + XSTypeDefinition type = (XSTypeDefinition) it.next();
26.1375 + String name = type.getName();
26.1376 + LOGGER.debug(" - " + name);
26.1377 + }
26.1378 + }
26.1379 +
26.1380 +
26.1381 + // sort the enums values and then add them as choices
26.1382 + //
26.1383 + // TODO: Should really put the default value (if any) at the top of the list.
26.1384 + //
26.1385 + /*List sortedList = choiceValues.subList(0, choiceValues.size());
26.1386 + Collections.sort(sortedList);
26.1387 + Iterator iterator = sortedList.iterator();*/
26.1388 +// -> no, already sorted
26.1389 + Iterator iterator = choiceValues.iterator();
26.1390 + while (iterator.hasNext()) {
26.1391 + XSTypeDefinition type = (XSTypeDefinition) iterator.next();
26.1392 + String textValue = type.getName();
26.1393 + //String textValue = (String) iterator.next();
26.1394 +
26.1395 + if (LOGGER.isDebugEnabled())
26.1396 + LOGGER.debug("addChoicesForSelectSwitchControl, processing " + textValue);
26.1397 +
26.1398 + Element item =
26.1399 + xForm.createElementNS(XFORMS_NS, getXFormsNSPrefix() + "item");
26.1400 + this.setXFormsId(item);
26.1401 + choicesElement.appendChild(item);
26.1402 +
26.1403 + Element captionElement =
26.1404 + xForm.createElementNS(XFORMS_NS, getXFormsNSPrefix() + "label");
26.1405 + this.setXFormsId(captionElement);
26.1406 + item.appendChild(captionElement);
26.1407 + captionElement.appendChild(xForm.createTextNode(createCaption(textValue)));
26.1408 +
26.1409 + Element value =
26.1410 + xForm.createElementNS(XFORMS_NS, getXFormsNSPrefix() + "value");
26.1411 + this.setXFormsId(value);
26.1412 + item.appendChild(value);
26.1413 + value.appendChild(xForm.createTextNode(textValue));
26.1414 +
26.1415 +/// action in the case
26.1416 +
26.1417 + Element action =
26.1418 + xForm.createElementNS(XFORMS_NS,
26.1419 + getXFormsNSPrefix() + "action");
26.1420 + this.setXFormsId(action);
26.1421 + item.appendChild(action);
26.1422 +
26.1423 + action.setAttribute("event", "xforms-select");
26.1424 +
26.1425 + Element toggle =
26.1426 + xForm.createElementNS(XFORMS_NS,
26.1427 + getXFormsNSPrefix() + "toggle");
26.1428 + this.setXFormsId(toggle);
26.1429 +
26.1430 + //build the case element
26.1431 + Element caseElement =
26.1432 + xForm.createElementNS(XFORMS_NS, getXFormsNSPrefix() + "case");
26.1433 + String case_id = this.setXFormsId(caseElement);
26.1434 + case_types.put(textValue, caseElement);
26.1435 +
26.1436 + toggle.setAttribute("case",
26.1437 + case_id);
26.1438 +
26.1439 + //toggle.setAttributeNS(XFORMS_NS,getXFormsNSPrefix() + "case",bindIdPrefix + "_" + textValue +"_case");
26.1440 + action.appendChild(toggle);
26.1441 + }
26.1442 + }
26.1443 +
26.1444 + /**
26.1445 + * __UNDOCUMENTED__
26.1446 + *
26.1447 + * @param xForm __UNDOCUMENTED__
26.1448 + * @param annotation __UNDOCUMENTED__
26.1449 + * @return __UNDOCUMENTED__
26.1450 + */
26.1451 + protected Element addHintFromDocumentation(Document xForm,
26.1452 + XSAnnotation annotation) {
26.1453 + if (annotation != null) {
26.1454 + Element hintElement =
26.1455 + xForm.createElementNS(XFORMS_NS, getXFormsNSPrefix() + "hint");
26.1456 + this.setXFormsId(hintElement);
26.1457 +
26.1458 + Text hintText =
26.1459 + (Text) hintElement.appendChild(xForm.createTextNode(""));
26.1460 +
26.1461 + //write annotation to empty doc
26.1462 + Document doc = DOMUtil.newDocument(true, false);
26.1463 + annotation.writeAnnotation(doc, XSAnnotation.W3C_DOM_DOCUMENT);
26.1464 +
26.1465 + //get "annotation" element
26.1466 + NodeList annots =
26.1467 + doc.getElementsByTagNameNS("http://www.w3.org/2001/XMLSchema",
26.1468 + "annotation");
26.1469 + if (annots.getLength() > 0) {
26.1470 + Element annotEl = (Element) annots.item(0);
26.1471 +
26.1472 + //documentation
26.1473 + NodeList docos =
26.1474 + annotEl.getElementsByTagNameNS("http://www.w3.org/2001/XMLSchema",
26.1475 + "documentation");
26.1476 + int nbDocos = docos.getLength();
26.1477 + for (int j = 0; j < nbDocos; j++) {
26.1478 + Element doco = (Element) docos.item(j);
26.1479 +
26.1480 + //get text value
26.1481 + String text = DOMUtil.getTextNodeAsString(doco);
26.1482 + hintText.appendData(text);
26.1483 +
26.1484 + if (j < nbDocos - 1) {
26.1485 + hintText.appendData(" ");
26.1486 + }
26.1487 + }
26.1488 + return hintElement;
26.1489 + }
26.1490 + return null;
26.1491 + }
26.1492 +
26.1493 + return null;
26.1494 + }
26.1495 +
26.1496 + private XSModel getSchema() {
26.1497 + return schema;
26.1498 + }
26.1499 +
26.1500 + public XSParticle findCorrespondingParticleInComplexType(XSElementDeclaration elDecl) {
26.1501 + XSParticle thisParticle = null;
26.1502 +
26.1503 + XSComplexTypeDefinition complexType = elDecl.getEnclosingCTDefinition();
26.1504 + if (complexType != null) {
26.1505 + XSParticle particle = complexType.getParticle();
26.1506 + XSTerm term = particle.getTerm();
26.1507 + XSObjectList particles;
26.1508 + if (term instanceof XSModelGroup) {
26.1509 + XSModelGroup group = (XSModelGroup) term;
26.1510 + particles = group.getParticles();
26.1511 + if (particles != null) {
26.1512 + int nb = particles.getLength();
26.1513 + int i = 0;
26.1514 + while (i < nb && thisParticle == null) {
26.1515 + XSParticle part = (XSParticle) particles.item(i);
26.1516 + //test term
26.1517 + XSTerm thisTerm = part.getTerm();
26.1518 + if (thisTerm == elDecl)
26.1519 + thisParticle = part;
26.1520 +
26.1521 + i++;
26.1522 + }
26.1523 + }
26.1524 + }
26.1525 + }
26.1526 + return thisParticle;
26.1527 + }
26.1528 +
26.1529 + /**
26.1530 + * finds the minOccurs and maxOccurs of an element declaration
26.1531 + *
26.1532 + * @return a table containing minOccurs and MaxOccurs
26.1533 + */
26.1534 + public int[] getOccurance(XSElementDeclaration elDecl) {
26.1535 + int minOccurs = 1;
26.1536 + int maxOccurs = 1;
26.1537 +
26.1538 + //get occurance on encosing element declaration
26.1539 + XSParticle particle =
26.1540 + this.findCorrespondingParticleInComplexType(elDecl);
26.1541 + if (particle != null) {
26.1542 + minOccurs = particle.getMinOccurs();
26.1543 + if (particle.getMaxOccursUnbounded())
26.1544 + maxOccurs = -1;
26.1545 + else
26.1546 + maxOccurs = particle.getMaxOccurs();
26.1547 + }
26.1548 +
26.1549 + //if not set, get occurance of model group content
26.1550 + //no -> this is made in "addGroup" directly !
26.1551 + /*if (minOccurs == 1 && maxOccurs == 1) {
26.1552 + XSTypeDefinition type = elDecl.getTypeDefinition();
26.1553 + if (type != null
26.1554 + && type.getTypeCategory() == XSTypeDefinition.COMPLEX_TYPE) {
26.1555 + XSComplexTypeDefinition complexType =
26.1556 + (XSComplexTypeDefinition) type;
26.1557 + XSParticle thisParticle = complexType.getParticle();
26.1558 + if (thisParticle != null) {
26.1559 + minOccurs = thisParticle.getMinOccurs();
26.1560 + if (thisParticle.getMaxOccursUnbounded())
26.1561 + maxOccurs = -1;
26.1562 + else
26.1563 + maxOccurs = thisParticle.getMaxOccurs();
26.1564 + }
26.1565 + }
26.1566 + }*/
26.1567 +
26.1568 + if (LOGGER.isDebugEnabled())
26.1569 + LOGGER.debug("getOccurance for "
26.1570 + + elDecl.getName()
26.1571 + + ", minOccurs="
26.1572 + + minOccurs
26.1573 + + ", maxOccurs="
26.1574 + + maxOccurs);
26.1575 +
26.1576 + int[] result = new int[2];
26.1577 + result[0] = minOccurs;
26.1578 + result[1] = maxOccurs;
26.1579 + return result;
26.1580 + }
26.1581 +
26.1582 + private void addAnyType(Document xForm,
26.1583 + Element modelSection,
26.1584 + Element formSection,
26.1585 + XSTypeDefinition controlType,
26.1586 + XSElementDeclaration owner,
26.1587 + String pathToRoot) {
26.1588 +
26.1589 + int[] occurance = this.getOccurance(owner);
26.1590 +
26.1591 + addSimpleType(xForm,
26.1592 + modelSection,
26.1593 + formSection,
26.1594 + controlType,
26.1595 + owner.getName(),
26.1596 + owner,
26.1597 + pathToRoot,
26.1598 + occurance[0],
26.1599 + occurance[1]);
26.1600 + }
26.1601 +
26.1602 + private void addAttributeSet(Document xForm,
26.1603 + Element modelSection,
26.1604 + Element formSection,
26.1605 + XSComplexTypeDefinition controlType,
26.1606 + XSElementDeclaration owner,
26.1607 + String pathToRoot,
26.1608 + boolean checkIfExtension) {
26.1609 + XSObjectList attrUses = controlType.getAttributeUses();
26.1610 +
26.1611 + if (attrUses != null) {
26.1612 + int nbAttr = attrUses.getLength();
26.1613 + for (int i = 0; i < nbAttr; i++) {
26.1614 + XSAttributeUse currentAttributeUse =
26.1615 + (XSAttributeUse) attrUses.item(i);
26.1616 + XSAttributeDeclaration currentAttribute =
26.1617 + currentAttributeUse.getAttrDeclaration();
26.1618 +
26.1619 +//test if extended !
26.1620 + if (checkIfExtension && this.doesAttributeComeFromExtension(currentAttributeUse, controlType)) {
26.1621 + if (LOGGER.isDebugEnabled()) {
26.1622 + LOGGER.debug("This attribute comes from an extension: recopy form controls. \n Model section: ");
26.1623 + DOMUtil.prettyPrintDOM(modelSection);
26.1624 + }
26.1625 +
26.1626 + String attributeName = currentAttributeUse.getName();
26.1627 + if (attributeName == null || attributeName.equals(""))
26.1628 + attributeName = currentAttributeUse.getAttrDeclaration().getName();
26.1629 +
26.1630 +//find the existing bind Id
26.1631 +//(modelSection is the enclosing bind of the element)
26.1632 + NodeList binds = modelSection.getElementsByTagNameNS(XFORMS_NS, "bind");
26.1633 + int j = 0;
26.1634 + int nb = binds.getLength();
26.1635 + String bindId = null;
26.1636 + while (j < nb && bindId == null) {
26.1637 + Element bind = (Element) binds.item(j);
26.1638 + String nodeset = bind.getAttributeNS(XFORMS_NS, "nodeset");
26.1639 + if (nodeset != null) {
26.1640 + String name = nodeset.substring(1); //remove "@" in nodeset
26.1641 + if (name.equals(attributeName))
26.1642 + bindId = bind.getAttributeNS(XFORMS_NS, "id");
26.1643 + }
26.1644 + j++;
26.1645 + }
26.1646 +
26.1647 +//find the control
26.1648 + Element control = null;
26.1649 + if (bindId != null) {
26.1650 + if (LOGGER.isDebugEnabled())
26.1651 + LOGGER.debug("bindId found: " + bindId);
26.1652 +
26.1653 + JXPathContext context = JXPathContext.newContext(formSection.getOwnerDocument());
26.1654 + Pointer pointer = context.getPointer("//*[@" + this.getXFormsNSPrefix() + "bind='" + bindId + "']");
26.1655 + if (pointer != null)
26.1656 + control = (Element) pointer.getNode();
26.1657 + }
26.1658 +
26.1659 +//copy it
26.1660 + if (control == null) {
26.1661 + LOGGER.warn("Corresponding control not found");
26.1662 + } else {
26.1663 + Element newControl = (Element) control.cloneNode(true);
26.1664 +//set new Ids to XForm elements
26.1665 + this.resetXFormIds(newControl);
26.1666 +
26.1667 + formSection.appendChild(newControl);
26.1668 + }
26.1669 +
26.1670 + } else {
26.1671 + String newPathToRoot;
26.1672 +
26.1673 + if ((pathToRoot == null) || pathToRoot.equals("")) {
26.1674 + newPathToRoot = "@" + currentAttribute.getName();
26.1675 + } else if (pathToRoot.endsWith("/")) {
26.1676 + newPathToRoot =
26.1677 + pathToRoot + "@" + currentAttribute.getName();
26.1678 + } else {
26.1679 + newPathToRoot =
26.1680 + pathToRoot + "/@" + currentAttribute.getName();
26.1681 + }
26.1682 +
26.1683 + XSSimpleTypeDefinition simpleType =
26.1684 + currentAttribute.getTypeDefinition();
26.1685 + //TODO SRA: UrType ?
26.1686 + /*if(simpleType==null){
26.1687 + simpleType=new UrType();
26.1688 + }*/
26.1689 +
26.1690 + addSimpleType(xForm,
26.1691 + modelSection,
26.1692 + formSection,
26.1693 + simpleType,
26.1694 + currentAttributeUse,
26.1695 + newPathToRoot);
26.1696 + }
26.1697 + }
26.1698 + }
26.1699 + }
26.1700 +
26.1701 + private void addComplexType(Document xForm,
26.1702 + Element modelSection,
26.1703 + Element formSection,
26.1704 + XSComplexTypeDefinition controlType,
26.1705 + XSElementDeclaration owner,
26.1706 + String pathToRoot,
26.1707 + boolean relative,
26.1708 + boolean checkIfExtension) {
26.1709 +
26.1710 + if (controlType != null) {
26.1711 + if (LOGGER.isDebugEnabled()) {
26.1712 + LOGGER.debug("addComplexType for " + controlType.getName());
26.1713 + if (owner != null)
26.1714 + LOGGER.debug(" owner=" + owner.getName());
26.1715 + }
26.1716 +
26.1717 + // add a group node and recurse
26.1718 + //
26.1719 + Element groupElement =
26.1720 + createGroup(xForm, modelSection, formSection, owner);
26.1721 + Element groupWrapper = groupElement;
26.1722 +
26.1723 + if (groupElement != modelSection) {
26.1724 + groupWrapper = _wrapper.createGroupContentWrapper(groupElement);
26.1725 + }
26.1726 +
26.1727 + int occurance[] = this.getOccurance(owner);
26.1728 + int minOccurs = occurance[0];
26.1729 + int maxOccurs = occurance[1];
26.1730 +
26.1731 + Element repeatSection =
26.1732 + addRepeatIfNecessary(xForm,
26.1733 + modelSection,
26.1734 + groupWrapper,
26.1735 + controlType,
26.1736 + minOccurs,
26.1737 + maxOccurs,
26.1738 + pathToRoot);
26.1739 + Element repeatContentWrapper = repeatSection;
26.1740 +
26.1741 + /*if(repeatSection!=groupWrapper)
26.1742 + //we have a repeat
26.1743 + {
26.1744 + repeatContentWrapper=_wrapper.createGroupContentWrapper(repeatSection);
26.1745 + addComplexTypeChildren(xForm,modelSection,repeatContentWrapper,controlType,owner,pathToRoot, true);
26.1746 + }
26.1747 + else
26.1748 + addComplexTypeChildren(xForm,modelSection,repeatContentWrapper,controlType,owner,pathToRoot, false);
26.1749 + */
26.1750 + if (repeatSection != groupWrapper) { //we have a repeat
26.1751 + repeatContentWrapper =
26.1752 + _wrapper.createGroupContentWrapper(repeatSection);
26.1753 + relative = true;
26.1754 + }
26.1755 +
26.1756 + addComplexTypeChildren(xForm,
26.1757 + modelSection,
26.1758 + repeatContentWrapper,
26.1759 + controlType,
26.1760 + owner,
26.1761 + pathToRoot,
26.1762 + relative,
26.1763 + checkIfExtension);
26.1764 +
26.1765 + Element realModel = modelSection;
26.1766 + if (relative) {
26.1767 + //modelSection: find the last element put in the modelSection = bind
26.1768 + realModel = DOMUtil.getLastChildElement(modelSection);
26.1769 + }
26.1770 +
26.1771 + endFormGroup(groupElement,
26.1772 + controlType,
26.1773 + minOccurs,
26.1774 + maxOccurs,
26.1775 + realModel);
26.1776 +
26.1777 + } else if (LOGGER.isDebugEnabled())
26.1778 + LOGGER.debug("addComplexType: control type is null for pathToRoot="
26.1779 + + pathToRoot);
26.1780 + }
26.1781 +
26.1782 + private void addComplexTypeChildren(Document xForm,
26.1783 + Element modelSection,
26.1784 + Element formSection,
26.1785 + XSComplexTypeDefinition controlType,
26.1786 + XSElementDeclaration owner,
26.1787 + String pathToRoot,
26.1788 + boolean relative,
26.1789 + boolean checkIfExtension) {
26.1790 +
26.1791 + if (controlType != null) {
26.1792 +
26.1793 + if (LOGGER.isDebugEnabled()) {
26.1794 + LOGGER.debug("addComplexTypeChildren for " + controlType.getName());
26.1795 + if (owner != null)
26.1796 + LOGGER.debug(" owner=" + owner.getName());
26.1797 + }
26.1798 +
26.1799 +//no need to add base type when extension-> with Xerces XMLSchema API,
26.1800 +//the elements of the base type are directly in the ModelGroup
26.1801 + /*XSTypeDefinition base = controlType.getBaseType();
26.1802 + if (base != null && base != controlType) {
26.1803 + if (LOGGER.isDebugEnabled())
26.1804 + LOGGER.debug(" base type=" + base.getName());
26.1805 +
26.1806 + if (base.getTypeCategory() == XSTypeDefinition.COMPLEX_TYPE) {
26.1807 +
26.1808 + if (base.getName() == null
26.1809 + || !base.getName().equals("anyType")) {
26.1810 +
26.1811 + if (LOGGER.isDebugEnabled())
26.1812 + LOGGER.debug(
26.1813 + " recursive call for base type "
26.1814 + + base.getName());
26.1815 +
26.1816 + addComplexTypeChildren(
26.1817 + xForm,
26.1818 + modelSection,
26.1819 + formSection,
26.1820 + (XSComplexTypeDefinition) base,
26.1821 + owner,
26.1822 + pathToRoot,
26.1823 + relative);
26.1824 + }
26.1825 + } else {
26.1826 + addSimpleType(
26.1827 + xForm,
26.1828 + modelSection,
26.1829 + formSection,
26.1830 + (XSSimpleTypeDefinition) base,
26.1831 + owner,
26.1832 + pathToRoot);
26.1833 + }
26.1834 + }*/
26.1835 +
26.1836 +/*if(!checkIfExtension){ //add it anyway
26.1837 + XSTypeDefinition base = controlType.getBaseType();
26.1838 + if (base != null && base != controlType) {
26.1839 +
26.1840 + if (LOGGER.isDebugEnabled())
26.1841 + LOGGER.debug(" base type=" + base.getName());
26.1842 +
26.1843 + if (base.getTypeCategory() == XSTypeDefinition.COMPLEX_TYPE) {
26.1844 +
26.1845 + if (base.getName() == null
26.1846 + || !base.getName().equals("anyType")) {
26.1847 +
26.1848 + if (LOGGER.isDebugEnabled())
26.1849 + LOGGER.debug(
26.1850 + " recursive call for base type "
26.1851 + + base.getName());
26.1852 +
26.1853 + addComplexTypeChildren(
26.1854 + xForm,
26.1855 + modelSection,
26.1856 + formSection,
26.1857 + (XSComplexTypeDefinition) base,
26.1858 + owner,
26.1859 + pathToRoot,
26.1860 + relative,
26.1861 + false);
26.1862 + }
26.1863 + } else {
26.1864 + addSimpleType(
26.1865 + xForm,
26.1866 + modelSection,
26.1867 + formSection,
26.1868 + (XSSimpleTypeDefinition) base,
26.1869 + owner,
26.1870 + pathToRoot);
26.1871 + }
26.1872 + }
26.1873 +
26.1874 + }
26.1875 + //we need the call for base type when type is a mixed content
26.1876 + //WARNING: simple type given for simple type + attribute (should be mixed ?)
26.1877 + else */
26.1878 + if (controlType.getContentType() == XSComplexTypeDefinition.CONTENTTYPE_MIXED
26.1879 + || (controlType.getContentType() == XSComplexTypeDefinition.CONTENTTYPE_SIMPLE
26.1880 + && controlType.getAttributeUses() != null && controlType.getAttributeUses().getLength() > 0)
26.1881 + ) {
26.1882 + XSTypeDefinition base = controlType.getBaseType();
26.1883 + if (LOGGER.isDebugEnabled())
26.1884 + LOGGER.debug(" Control type is mixed . base type=" + base.getName());
26.1885 +
26.1886 + if (base != null && base != controlType) {
26.1887 + if (base.getTypeCategory() == XSTypeDefinition.SIMPLE_TYPE) {
26.1888 + addSimpleType(xForm,
26.1889 + modelSection,
26.1890 + formSection,
26.1891 + (XSSimpleTypeDefinition) base,
26.1892 + owner,
26.1893 + pathToRoot);
26.1894 + } else
26.1895 + LOGGER.warn("addComplexTypeChildren for mixed type with basic type complex !");
26.1896 + }
26.1897 + } else if (LOGGER.isDebugEnabled())
26.1898 + LOGGER.debug(" Content type = " + controlType.getContentType());
26.1899 +
26.1900 +
26.1901 + // check for compatible subtypes
26.1902 + // of controlType.
26.1903 + // add a type switch if there are any
26.1904 + // compatible sub-types (i.e. anything
26.1905 + // that derives from controlType)
26.1906 + // add child elements
26.1907 + if (relative) {
26.1908 + pathToRoot = "";
26.1909 +
26.1910 + //modelSection: find the last element put in the modelSection = bind
26.1911 + modelSection = DOMUtil.getLastChildElement(modelSection);
26.1912 + }
26.1913 +
26.1914 + //attributes
26.1915 + addAttributeSet(xForm,
26.1916 + modelSection,
26.1917 + formSection,
26.1918 + controlType,
26.1919 + owner,
26.1920 + pathToRoot,
26.1921 + checkIfExtension);
26.1922 +
26.1923 + //process group
26.1924 + XSParticle particle = controlType.getParticle();
26.1925 + if (particle != null) {
26.1926 + XSTerm term = particle.getTerm();
26.1927 + if (term instanceof XSModelGroup) {
26.1928 + if (LOGGER.isDebugEnabled())
26.1929 + LOGGER.debug(" Particle of "
26.1930 + + controlType.getName()
26.1931 + + " is a group --->");
26.1932 +
26.1933 + XSModelGroup group = (XSModelGroup) term;
26.1934 +
26.1935 + //get maxOccurs
26.1936 + int maxOccurs = particle.getMaxOccurs();
26.1937 + if (particle.getMaxOccursUnbounded()) {
26.1938 + maxOccurs = -1;
26.1939 + }
26.1940 + int minOccurs = particle.getMinOccurs();
26.1941 +
26.1942 + //call addGroup on this group
26.1943 + this.addGroup(xForm,
26.1944 + modelSection,
26.1945 + formSection,
26.1946 + group,
26.1947 + controlType,
26.1948 + owner,
26.1949 + pathToRoot,
26.1950 + minOccurs,
26.1951 + maxOccurs,
26.1952 + checkIfExtension);
26.1953 +
26.1954 + } else if (LOGGER.isDebugEnabled())
26.1955 + LOGGER.debug(" Particle of "
26.1956 + + controlType.getName()
26.1957 + + " is not a group: "
26.1958 + + term.getClass().getName());
26.1959 + }
26.1960 +
26.1961 + if (LOGGER.isDebugEnabled())
26.1962 + LOGGER.debug("--->end of addComplexTypeChildren for "
26.1963 + + controlType.getName());
26.1964 + }
26.1965 + }
26.1966 +
26.1967 + /**
26.1968 + * add an element to the XForms document: the bind + the control
26.1969 + * (only the control if "withBind" is false)
26.1970 + */
26.1971 + private void addElement(Document xForm,
26.1972 + Element modelSection,
26.1973 + Element formSection,
26.1974 + XSElementDeclaration elementDecl,
26.1975 + XSTypeDefinition controlType,
26.1976 + String pathToRoot) {
26.1977 +
26.1978 + if (controlType == null) {
26.1979 + // TODO!!! Figure out why this happens... for now just warn...
26.1980 + // seems to happen when there is an element of type IDREFS
26.1981 + LOGGER.warn("WARNING!!! controlType is null for "
26.1982 + + elementDecl
26.1983 + + ", "
26.1984 + + elementDecl.getName());
26.1985 +
26.1986 + return;
26.1987 + }
26.1988 +
26.1989 + switch (controlType.getTypeCategory()) {
26.1990 + case XSTypeDefinition.SIMPLE_TYPE:
26.1991 + {
26.1992 + addSimpleType(xForm,
26.1993 + modelSection,
26.1994 + formSection,
26.1995 + (XSSimpleTypeDefinition) controlType,
26.1996 + elementDecl,
26.1997 + pathToRoot);
26.1998 +
26.1999 + break;
26.2000 + }
26.2001 + case XSTypeDefinition.COMPLEX_TYPE:
26.2002 + {
26.2003 +
26.2004 + if (controlType.getName() != null
26.2005 + && controlType.getName().equals("anyType")) {
26.2006 + addAnyType(xForm,
26.2007 + modelSection,
26.2008 + formSection,
26.2009 + (XSComplexTypeDefinition) controlType,
26.2010 + elementDecl,
26.2011 + pathToRoot);
26.2012 +
26.2013 + break;
26.2014 + } else {
26.2015 +
26.2016 + // find the types which are compatible(derived from) the parent type.
26.2017 + //
26.2018 + // This is used if we encounter a XML Schema that permits the xsi:type
26.2019 + // attribute to specify subtypes for the element.
26.2020 + //
26.2021 + // For example, the <address> element may be typed to permit any of
26.2022 + // the following scenarios:
26.2023 + // <address xsi:type="USAddress">
26.2024 + // </address>
26.2025 + // <address xsi:type="CanadianAddress">
26.2026 + // </address>
26.2027 + // <address xsi:type="InternationalAddress">
26.2028 + // </address>
26.2029 + //
26.2030 + // What we want to do is generate an XForm' switch element with cases
26.2031 + // representing any valid non-abstract subtype.
26.2032 + //
26.2033 + // <xforms:select1 xforms:bind="xsi_type_13"
26.2034 + // <xforms:label>Address</xforms:label>
26.2035 + // <xforms:choices>
26.2036 + // <xforms:item>
26.2037 + // <xforms:label>US Address Type</xforms:label>
26.2038 + // <xforms:value>USAddressType</xforms:value>
26.2039 + // <xforms:action ev:event="xforms-select">
26.2040 + // <xforms:toggle xforms:case="USAddressType-case"/>
26.2041 + // </xforms:action>
26.2042 + // </xforms:item>
26.2043 + // <xforms:item>
26.2044 + // <xforms:label>Canadian Address Type</xforms:label>
26.2045 + // <xforms:value>CanadianAddressType</xforms:value>
26.2046 + // <xforms:action ev:event="xforms-select">
26.2047 + // <xforms:toggle xforms:case="CanadianAddressType-case"/>
26.2048 + // </xforms:action>
26.2049 + // </xforms:item>
26.2050 + // <xforms:item>
26.2051 + // <xforms:label>International Address Type</xforms:label>
26.2052 + // <xforms:value>InternationalAddressType</xforms:value>
26.2053 + // <xforms:action ev:event="xforms-select">
26.2054 + // <xforms:toggle xforms:case="InternationalAddressType-case"/>
26.2055 + // </xforms:action>
26.2056 + // </xforms:item>
26.2057 + //
26.2058 + // </xforms:choices>
26.2059 + // <xforms:select1>
26.2060 + // <xforms:trigger>
26.2061 + // <xforms:label>validate Address type</xforms:label>
26.2062 + // <xforms:action>
26.2063 + // <xforms:dispatch id="dispatcher" xforms:name="xforms-activate" xforms:target="select1_0"/>
26.2064 + // </xforms:action>
26.2065 + //</xforms:trigger>
26.2066 + //
26.2067 + // <xforms:switch id="address_xsi_type_switch">
26.2068 + // <xforms:case id="USAddressType-case" selected="false">
26.2069 + // <!-- US Address Type sub-elements here-->
26.2070 + // </xforms:case>
26.2071 + // <xforms:case id="CanadianAddressType-case" selected="false">
26.2072 + // <!-- US Address Type sub-elements here-->
26.2073 + // </xforms:case>
26.2074 + // ...
26.2075 + // </xforms:switch>
26.2076 + //
26.2077 + // + change bindings to add:
26.2078 + // - a bind for the "@xsi:type" attribute
26.2079 + // - for each possible element that can be added through the use of an inheritance, add a "relevant" attribute:
26.2080 + // ex: xforms:relevant="../@xsi:type='USAddress'"
26.2081 +
26.2082 + // look for compatible types
26.2083 + //
26.2084 + String typeName = controlType.getName();
26.2085 + boolean relative = true;
26.2086 +
26.2087 + if (typeName != null) {
26.2088 + TreeSet compatibleTypes = (TreeSet) typeTree.get(controlType.getName());
26.2089 + //TreeSet compatibleTypes = (TreeSet) typeTree.get(controlType);
26.2090 +
26.2091 + if (compatibleTypes != null) {
26.2092 + relative = false;
26.2093 +
26.2094 + if (LOGGER.isDebugEnabled()) {
26.2095 + LOGGER.debug("compatible types for "
26.2096 + + typeName
26.2097 + + ":");
26.2098 + Iterator it1 = compatibleTypes.iterator();
26.2099 + while (it1.hasNext()) {
26.2100 + //String name = (String) it1.next();
26.2101 + XSTypeDefinition compType = (XSTypeDefinition) it1.next();
26.2102 + LOGGER.debug(" compatible type name=" + compType.getName());
26.2103 + }
26.2104 + }
26.2105 +
26.2106 + Element control =
26.2107 + xForm.createElementNS(XFORMS_NS,
26.2108 + getXFormsNSPrefix() + "select1");
26.2109 + String select1_id = this.setXFormsId(control);
26.2110 +
26.2111 + Element choices =
26.2112 + xForm.createElementNS(XFORMS_NS,
26.2113 + getXFormsNSPrefix() + "choices");
26.2114 + this.setXFormsId(choices);
26.2115 +
26.2116 + //get possible values
26.2117 + Vector enumValues = new Vector();
26.2118 + //add the type (if not abstract)
26.2119 + if (!((XSComplexTypeDefinition) controlType).getAbstract())
26.2120 + enumValues.add(controlType);
26.2121 + //enumValues.add(typeName);
26.2122 +
26.2123 + //add compatible types
26.2124 + Iterator it = compatibleTypes.iterator();
26.2125 + while (it.hasNext()) {
26.2126 + enumValues.add(it.next());
26.2127 + }
26.2128 +
26.2129 + if (enumValues.size() > 1) {
26.2130 +
26.2131 + String caption =
26.2132 + createCaption(elementDecl.getName() + " Type");
26.2133 + Element controlCaption =
26.2134 + (Element) control.appendChild(xForm.createElementNS(XFORMS_NS,
26.2135 + getXFormsNSPrefix() + "label"));
26.2136 + this.setXFormsId(controlCaption);
26.2137 + controlCaption.appendChild(xForm.createTextNode(caption));
26.2138 +
26.2139 + // multiple compatible types for this element exist
26.2140 + // in the schema - allow the user to choose from
26.2141 + // between compatible non-abstract types
26.2142 + Element bindElement =
26.2143 + xForm.createElementNS(XFORMS_NS,
26.2144 + getXFormsNSPrefix() + "bind");
26.2145 + String bindId =
26.2146 + this.setXFormsId(bindElement);
26.2147 +
26.2148 + bindElement.setAttribute("nodeset",
26.2149 + pathToRoot + "/@xsi:type");
26.2150 +
26.2151 + modelSection.appendChild(bindElement);
26.2152 + control.setAttribute("bind",
26.2153 + bindId);
26.2154 +
26.2155 + //add the "element" bind, in addition
26.2156 + Element bindElement2 =
26.2157 + xForm.createElementNS(XFORMS_NS,
26.2158 + getXFormsNSPrefix() + "bind");
26.2159 + String bindId2 =
26.2160 + this.setXFormsId(bindElement2);
26.2161 + bindElement2.setAttribute("nodeset",
26.2162 + pathToRoot);
26.2163 +
26.2164 + modelSection.appendChild(bindElement2);
26.2165 +
26.2166 + if (enumValues.size()
26.2167 + < Long.parseLong(getProperty(SELECTONE_LONG_LIST_SIZE_PROP))) {
26.2168 + control.setAttribute("appearance",
26.2169 + getProperty(SELECTONE_UI_CONTROL_SHORT_PROP));
26.2170 + } else {
26.2171 + control.setAttribute("appearance",
26.2172 + getProperty(SELECTONE_UI_CONTROL_LONG_PROP));
26.2173 +
26.2174 + // add the "Please select..." instruction item for the combobox
26.2175 + // and set the isValid attribute on the bind element to check for the "Please select..."
26.2176 + // item to indicate that is not a valid value
26.2177 + //
26.2178 + String pleaseSelect =
26.2179 + "[Select1 " + caption + "]";
26.2180 + Element item =
26.2181 + xForm.createElementNS(XFORMS_NS,
26.2182 + getXFormsNSPrefix()
26.2183 + + "item");
26.2184 + this.setXFormsId(item);
26.2185 + choices.appendChild(item);
26.2186 +
26.2187 + Element captionElement =
26.2188 + xForm.createElementNS(XFORMS_NS,
26.2189 + getXFormsNSPrefix()
26.2190 + + "label");
26.2191 + this.setXFormsId(captionElement);
26.2192 + item.appendChild(captionElement);
26.2193 + captionElement.appendChild(xForm.createTextNode(pleaseSelect));
26.2194 +
26.2195 + Element value =
26.2196 + xForm.createElementNS(XFORMS_NS,
26.2197 + getXFormsNSPrefix()
26.2198 + + "value");
26.2199 + this.setXFormsId(value);
26.2200 + item.appendChild(value);
26.2201 + value.appendChild(xForm.createTextNode(pleaseSelect));
26.2202 +
26.2203 + // not(purchaseOrder/state = '[Choose State]')
26.2204 + //String isValidExpr = "not(" + bindElement.getAttributeNS(XFORMS_NS, "nodeset") + " = '" + pleaseSelect + "')";
26.2205 + // ->no, not(. = '[Choose State]')
26.2206 + String isValidExpr =
26.2207 + "not( . = '"
26.2208 + + pleaseSelect
26.2209 + + "')";
26.2210 +
26.2211 + //check if there was a constraint
26.2212 + String constraint =
26.2213 + bindElement.getAttributeNS(XFORMS_NS,
26.2214 + "constraint");
26.2215 +
26.2216 + if ((constraint != null)
26.2217 + && !constraint.equals("")) {
26.2218 + constraint =
26.2219 + constraint
26.2220 + + " && "
26.2221 + + isValidExpr;
26.2222 + } else {
26.2223 + constraint = isValidExpr;
26.2224 + }
26.2225 +
26.2226 + bindElement.setAttribute("constraint",
26.2227 + constraint);
26.2228 + }
26.2229 +
26.2230 + Element choicesControlWrapper =
26.2231 + _wrapper.createControlsWrapper(choices);
26.2232 + control.appendChild(choicesControlWrapper);
26.2233 +
26.2234 + Element controlWrapper =
26.2235 + _wrapper.createControlsWrapper(control);
26.2236 + formSection.appendChild(controlWrapper);
26.2237 +
26.2238 + ///////////////// ///////////////
26.2239 + // add content to select1
26.2240 + HashMap case_types = new HashMap();
26.2241 + addChoicesForSelectSwitchControl(xForm,
26.2242 + choices,
26.2243 + enumValues,
26.2244 + case_types);
26.2245 +
26.2246 + /////////////////
26.2247 + //add a trigger for this control (is there a way to not need it ?)
26.2248 + Element trigger = xForm.createElementNS(XFORMS_NS,
26.2249 + getXFormsNSPrefix() + "trigger");
26.2250 + formSection.appendChild(trigger);
26.2251 + this.setXFormsId(trigger);
26.2252 + Element label_trigger = xForm.createElementNS(XFORMS_NS,
26.2253 + getXFormsNSPrefix() + "label");
26.2254 + this.setXFormsId(label_trigger);
26.2255 + trigger.appendChild(label_trigger);
26.2256 + String trigger_caption = createCaption("validate choice");
26.2257 + label_trigger.appendChild(xForm.createTextNode(trigger_caption));
26.2258 + Element action_trigger = xForm.createElementNS(XFORMS_NS,
26.2259 + getXFormsNSPrefix() + "action");
26.2260 + this.setXFormsId(action_trigger);
26.2261 + trigger.appendChild(action_trigger);
26.2262 + Element dispatch_trigger = xForm.createElementNS(XFORMS_NS,
26.2263 + getXFormsNSPrefix() + "dispatch");
26.2264 + this.setXFormsId(dispatch_trigger);
26.2265 + action_trigger.appendChild(dispatch_trigger);
26.2266 + dispatch_trigger.setAttribute("name",
26.2267 + "DOMActivate");
26.2268 + dispatch_trigger.setAttribute("target",
26.2269 + select1_id);
26.2270 +
26.2271 + /////////////////
26.2272 + //add switch
26.2273 + Element switchElement =
26.2274 + xForm.createElementNS(XFORMS_NS,
26.2275 + getXFormsNSPrefix() + "switch");
26.2276 + this.setXFormsId(switchElement);
26.2277 +
26.2278 + Element switchControlWrapper =
26.2279 + _wrapper.createControlsWrapper(switchElement);
26.2280 + formSection.appendChild(switchControlWrapper);
26.2281 + //formSection.appendChild(switchElement);
26.2282 +
26.2283 + /////////////// add this type //////////////
26.2284 + Element firstCaseElement = (Element) case_types.get(controlType.getName());
26.2285 + switchElement.appendChild(firstCaseElement);
26.2286 + addComplexType(xForm,
26.2287 + modelSection,
26.2288 + firstCaseElement,
26.2289 + (XSComplexTypeDefinition) controlType,
26.2290 + elementDecl,
26.2291 + pathToRoot,
26.2292 + true,
26.2293 + false);
26.2294 +
26.2295 + /////////////// add sub types //////////////
26.2296 + it = compatibleTypes.iterator();
26.2297 + // add each compatible type within
26.2298 + // a case statement
26.2299 + while (it.hasNext()) {
26.2300 + /*String compatibleTypeName = (String) it.next();
26.2301 + //WARNING: order of parameters inversed from the doc for 2.6.0 !!!
26.2302 + XSTypeDefinition type =getSchema().getTypeDefinition(
26.2303 + compatibleTypeName,
26.2304 + targetNamespace);*/
26.2305 + XSTypeDefinition type = (XSTypeDefinition) it.next();
26.2306 + String compatibleTypeName = type.getName();
26.2307 +
26.2308 + if (LOGGER.isDebugEnabled()) {
26.2309 + if (type == null)
26.2310 + LOGGER.debug(">>>addElement: compatible type is null!! type="
26.2311 + + compatibleTypeName
26.2312 + + ", targetNamespace="
26.2313 + + targetNamespace);
26.2314 + else
26.2315 + LOGGER.debug(" >>>addElement: adding compatible type "
26.2316 + + type.getName());
26.2317 + }
26.2318 +
26.2319 + if (type != null
26.2320 + && type.getTypeCategory()
26.2321 + == XSTypeDefinition
26.2322 + .COMPLEX_TYPE) {
26.2323 +
26.2324 + //Element caseElement = (Element) xForm.createElementNS(XFORMS_NS,getXFormsNSPrefix() + "case");
26.2325 + //caseElement.setAttributeNS(XFORMS_NS,getXFormsNSPrefix() + "id",bindId + "_" + type.getName() +"_case");
26.2326 + //String case_id=this.setXFormsId(caseElement);
26.2327 + Element caseElement =
26.2328 + (Element) case_types.get(type.getName());
26.2329 + switchElement.appendChild(caseElement);
26.2330 +
26.2331 + addComplexType(xForm,
26.2332 + modelSection,
26.2333 + caseElement,
26.2334 + (XSComplexTypeDefinition) type,
26.2335 + elementDecl,
26.2336 + pathToRoot,
26.2337 + true,
26.2338 + true);
26.2339 +
26.2340 + //////
26.2341 + // modify bind to add a "relevant" attribute that checks the value of @xsi:type
26.2342 + //
26.2343 + if (LOGGER.isDebugEnabled())
26.2344 + DOMUtil.prettyPrintDOM(bindElement2);
26.2345 + NodeList binds = bindElement2.getElementsByTagNameNS(XFORMS_NS, "bind");
26.2346 + Element thisBind = null;
26.2347 + int nb_binds = binds.getLength();
26.2348 + int i = 0;
26.2349 + while (i < nb_binds && thisBind == null) {
26.2350 + Element subBind = (Element) binds.item(i);
26.2351 + String name = subBind.getAttributeNS(XFORMS_NS, "nodeset");
26.2352 +
26.2353 + if (LOGGER.isDebugEnabled())
26.2354 + LOGGER.debug("Testing sub-bind with nodeset " + name);
26.2355 +
26.2356 + if (this.isElementDeclaredIn(name, (XSComplexTypeDefinition) type, false)
26.2357 + || this.isAttributeDeclaredIn(name, (XSComplexTypeDefinition) type, false)
26.2358 + ) {
26.2359 + if (LOGGER.isDebugEnabled())
26.2360 + LOGGER.debug("Element/Attribute " + name + " declared in type " + type.getName() + ": adding relevant attribute");
26.2361 +
26.2362 + //test sub types of this type
26.2363 + TreeSet subCompatibleTypes = (TreeSet) typeTree.get(type.getName());
26.2364 + //TreeSet subCompatibleTypes = (TreeSet) typeTree.get(type);
26.2365 +
26.2366 + String newRelevant = null;
26.2367 + if (subCompatibleTypes == null || subCompatibleTypes.isEmpty()) {
26.2368 + //just add ../@xsi:type='type'
26.2369 + newRelevant = "../@xsi:type='" + type.getName() + "'";
26.2370 + } else {
26.2371 + //add ../@xsi:type='type' or ../@xsi:type='otherType' or ...
26.2372 + newRelevant = "../@xsi:type='" + type.getName() + "'";
26.2373 + Iterator it_ct = subCompatibleTypes.iterator();
26.2374 + while (it_ct.hasNext()) {
26.2375 + //String otherTypeName = (String) it_ct.next();
26.2376 + XSTypeDefinition otherType = (XSTypeDefinition) it_ct.next();
26.2377 + String otherTypeName = otherType.getName();
26.2378 + newRelevant = newRelevant + " or ../@xsi:type='" + otherTypeName + "'";
26.2379 + }
26.2380 + }
26.2381 +
26.2382 + //change relevant attribute
26.2383 + String relevant = subBind.getAttributeNS(XFORMS_NS, "relevant");
26.2384 + if (relevant != null && !relevant.equals("")) {
26.2385 + newRelevant = "(" + relevant + ") and " + newRelevant;
26.2386 + }
26.2387 + if (newRelevant != null && !newRelevant.equals(""))
26.2388 + subBind.setAttribute("relevant", newRelevant);
26.2389 + }
26.2390 +
26.2391 + i++;
26.2392 + }
26.2393 + }
26.2394 + }
26.2395 +
26.2396 + /*if (LOGGER.isDebugEnabled()) {
26.2397 + LOGGER.debug(
26.2398 + "###addElement for derived type: bind created:");
26.2399 + DOMUtil.prettyPrintDOM(bindElement2);
26.2400 + }*/
26.2401 +
26.2402 + // we're done
26.2403 + //
26.2404 + break;
26.2405 +
26.2406 + } else if (enumValues.size() == 1) {
26.2407 + // only one compatible type, set the controlType value
26.2408 + // and fall through
26.2409 + //
26.2410 + //controlType = getSchema().getComplexType((String)enumValues.get(0));
26.2411 + controlType =
26.2412 + getSchema().getTypeDefinition((String) enumValues.get(0),
26.2413 + targetNamespace);
26.2414 + }
26.2415 + } else if (LOGGER.isDebugEnabled())
26.2416 + LOGGER.debug("No compatible type found for " + typeName);
26.2417 +
26.2418 + //name not null but no compatibleType?
26.2419 + relative = true;
26.2420 + }
26.2421 +
26.2422 + if (relative) //create the bind in case it is a repeat
26.2423 + {
26.2424 + if (LOGGER.isDebugEnabled())
26.2425 + LOGGER.debug(">>>Adding empty bind for " + typeName);
26.2426 +
26.2427 + // create the <xforms:bind> element and add it to the model.
26.2428 + Element bindElement =
26.2429 + xForm.createElementNS(XFORMS_NS,
26.2430 + getXFormsNSPrefix() + "bind");
26.2431 + String bindId = this.setXFormsId(bindElement);
26.2432 + bindElement.setAttribute("nodeset",
26.2433 + pathToRoot);
26.2434 +
26.2435 + modelSection.appendChild(bindElement);
26.2436 + } else if (LOGGER.isDebugEnabled()) {
26.2437 + LOGGER.debug("addElement: bind is not relative for "
26.2438 + + elementDecl.getName());
26.2439 + }
26.2440 +
26.2441 + //addComplexType(xForm,modelSection, formSection,(ComplexType)controlType,elementDecl,pathToRoot, relative);
26.2442 + addComplexType(xForm,
26.2443 + modelSection,
26.2444 + formSection,
26.2445 + (XSComplexTypeDefinition) controlType,
26.2446 + elementDecl,
26.2447 + pathToRoot,
26.2448 + true,
26.2449 + false);
26.2450 +
26.2451 + break;
26.2452 + }
26.2453 + }
26.2454 +
26.2455 + default : // TODO: add wildcard support
26.2456 + LOGGER.warn("\nWARNING!!! - Unsupported type ["
26.2457 + + elementDecl.getType()
26.2458 + + "] for node ["
26.2459 + + controlType.getName()
26.2460 + + "]");
26.2461 + }
26.2462 + }
26.2463 +
26.2464 + /**
26.2465 + * check that the element defined by this name is declared directly in the type
26.2466 + **/
26.2467 + /*private boolean isElementDeclaredIn(String name, XSComplexTypeDefinition type){
26.2468 + boolean found=false;
26.2469 +
26.2470 + XSParticle particle=type.getParticle();
26.2471 + XSTerm term=particle.getTerm();
26.2472 + if(term instanceof XSModelGroup){
26.2473 + XSModelGroup group=(XSModelGroup) term;
26.2474 + XSObjectList particles=group.getParticles();
26.2475 + int i=0;
26.2476 + int nb=particles.getLength();
26.2477 + while(i<nb){
26.2478 + XSParticle subPart=(XSParticle) particles.item(i);
26.2479 + XSTerm subTerm=subPart.getTerm();
26.2480 + if(subTerm instanceof XSElementDeclaration){
26.2481 + XSElementDeclaration elDecl=(XSElementDeclaration) subTerm;
26.2482 + if(name.equals(elDecl.getName()))
26.2483 + found=true;
26.2484 + }
26.2485 +
26.2486 + i++;
26.2487 + }
26.2488 + }
26.2489 +
26.2490 + return found;
26.2491 + }*/
26.2492 + /**
26.2493 + * check that the element defined by this name is declared directly in the type
26.2494 + */
26.2495 + private boolean isElementDeclaredIn(String name, XSComplexTypeDefinition type, boolean recursive) {
26.2496 + boolean found = false;
26.2497 +
26.2498 + if (LOGGER.isDebugEnabled())
26.2499 + LOGGER.debug("isElement " + name + " declared in " + type.getName());
26.2500 +
26.2501 +//test if extension + declared in parent + not recursive -> NOK
26.2502 + if (!recursive && type.getDerivationMethod() == XSConstants.DERIVATION_EXTENSION) {
26.2503 + XSComplexTypeDefinition parent = (XSComplexTypeDefinition) type.getBaseType();
26.2504 + if (LOGGER.isDebugEnabled())
26.2505 + LOGGER.debug("testing if it is not on parent " + parent.getName());
26.2506 + if (this.isElementDeclaredIn(name, parent, true))
26.2507 + return false;
26.2508 + }
26.2509 +
26.2510 + XSParticle particle = type.getParticle();
26.2511 + if (particle != null) {
26.2512 + XSTerm term = particle.getTerm();
26.2513 + if (term instanceof XSModelGroup) {
26.2514 + XSModelGroup group = (XSModelGroup) term;
26.2515 + found = this.isElementDeclaredIn(name, group);
26.2516 + }
26.2517 + }
26.2518 +
26.2519 + if (LOGGER.isDebugEnabled())
26.2520 + LOGGER.debug("isElement " + name + " declared in " + type.getName() + ": " + found);
26.2521 +
26.2522 + return found;
26.2523 + }
26.2524 +
26.2525 + /**
26.2526 + * private recursive method called by isElementDeclaredIn(String name, XSComplexTypeDefinition type)
26.2527 + */
26.2528 + private boolean isElementDeclaredIn(String name, XSModelGroup group) {
26.2529 +
26.2530 + if (LOGGER.isDebugEnabled())
26.2531 + LOGGER.debug("isElement " + name + " declared in group " + group.getName());
26.2532 +
26.2533 + boolean found = false;
26.2534 + XSObjectList particles = group.getParticles();
26.2535 + int i = 0;
26.2536 + int nb = particles.getLength();
26.2537 + while (i < nb) {
26.2538 + XSParticle subPart = (XSParticle) particles.item(i);
26.2539 + XSTerm subTerm = subPart.getTerm();
26.2540 + if (subTerm instanceof XSElementDeclaration) {
26.2541 + XSElementDeclaration elDecl = (XSElementDeclaration) subTerm;
26.2542 + if (name.equals(elDecl.getName()))
26.2543 + found = true;
26.2544 + } else if (subTerm instanceof XSModelGroup) { //recursive
26.2545 + found = this.isElementDeclaredIn(name, (XSModelGroup) subTerm);
26.2546 + }
26.2547 +
26.2548 + i++;
26.2549 + }
26.2550 +
26.2551 + if (LOGGER.isDebugEnabled())
26.2552 + LOGGER.debug("isElement " + name + " declared in group " + group.getName() + ": " + found);
26.2553 + return found;
26.2554 + }
26.2555 +
26.2556 + private boolean doesElementComeFromExtension(XSElementDeclaration element, XSComplexTypeDefinition controlType) {
26.2557 + if (LOGGER.isDebugEnabled())
26.2558 + LOGGER.debug("doesElementComeFromExtension for " + element.getName() + " and controlType=" + controlType.getName());
26.2559 + boolean comesFromExtension = false;
26.2560 + if (controlType.getDerivationMethod() == XSConstants.DERIVATION_EXTENSION) {
26.2561 + XSTypeDefinition baseType = controlType.getBaseType();
26.2562 + if (baseType.getTypeCategory() == XSTypeDefinition.COMPLEX_TYPE) {
26.2563 + XSComplexTypeDefinition complexType = (XSComplexTypeDefinition) baseType;
26.2564 + if (this.isElementDeclaredIn(element.getName(), complexType, true)) {
26.2565 + if (LOGGER.isDebugEnabled())
26.2566 + LOGGER.debug("doesElementComeFromExtension: yes");
26.2567 + comesFromExtension = true;
26.2568 + } else { //recursive call
26.2569 + if (LOGGER.isDebugEnabled())
26.2570 + LOGGER.debug("doesElementComeFromExtension: recursive call on previous level");
26.2571 + comesFromExtension = this.doesElementComeFromExtension(element, complexType);
26.2572 + }
26.2573 + }
26.2574 + }
26.2575 + return comesFromExtension;
26.2576 + }
26.2577 +
26.2578 + /**
26.2579 + * check that the element defined by this name is declared directly in the type
26.2580 + */
26.2581 + private boolean isAttributeDeclaredIn(XSAttributeUse attr, XSComplexTypeDefinition type, boolean recursive) {
26.2582 + boolean found = false;
26.2583 +
26.2584 + if (LOGGER.isDebugEnabled())
26.2585 + LOGGER.debug("is Attribute " + attr.getAttrDeclaration().getName() + " declared in " + type.getName());
26.2586 +
26.2587 +//check on parent if not recursive
26.2588 + if (!recursive && type.getDerivationMethod() == XSConstants.DERIVATION_EXTENSION) {
26.2589 + XSComplexTypeDefinition parent = (XSComplexTypeDefinition) type.getBaseType();
26.2590 + if (LOGGER.isDebugEnabled())
26.2591 + LOGGER.debug("testing if it is not on parent " + parent.getName());
26.2592 + if (this.isAttributeDeclaredIn(attr, parent, true))
26.2593 + return false;
26.2594 + }
26.2595 +
26.2596 +//check on this type (also checks recursively)
26.2597 + XSObjectList attrs = type.getAttributeUses();
26.2598 + int nb = attrs.getLength();
26.2599 + int i = 0;
26.2600 + while (i < nb && !found) {
26.2601 + XSAttributeUse anAttr = (XSAttributeUse) attrs.item(i);
26.2602 + if (anAttr == attr)
26.2603 + found = true;
26.2604 + i++;
26.2605 + }
26.2606 +
26.2607 +//recursive call
26.2608 +/*if(!found && recursive &&
26.2609 + type.getDerivationMethod()==XSConstants.DERIVATION_EXTENSION){
26.2610 + XSComplexTypeDefinition base=(XSComplexTypeDefinition) type.getBaseType();
26.2611 + if(base!=null && base!=type)
26.2612 + found = this.isAttributeDeclaredIn(attr, base, true);
26.2613 + }*/
26.2614 +
26.2615 + if (LOGGER.isDebugEnabled())
26.2616 + LOGGER.debug("is Attribute " + attr.getName() + " declared in " + type.getName() + ": " + found);
26.2617 +
26.2618 + return found;
26.2619 + }
26.2620 +
26.2621 + /**
26.2622 + * check that the element defined by this name is declared directly in the type
26.2623 + * -> idem with string
26.2624 + */
26.2625 + private boolean isAttributeDeclaredIn(String attrName, XSComplexTypeDefinition type, boolean recursive) {
26.2626 + boolean found = false;
26.2627 +
26.2628 + if (LOGGER.isDebugEnabled())
26.2629 + LOGGER.debug("is Attribute " + attrName + " declared in " + type.getName());
26.2630 +
26.2631 + if (attrName.startsWith("@"))
26.2632 + attrName = attrName.substring(1);
26.2633 +
26.2634 +//check on parent if not recursive
26.2635 + if (!recursive && type.getDerivationMethod() == XSConstants.DERIVATION_EXTENSION) {
26.2636 + XSComplexTypeDefinition parent = (XSComplexTypeDefinition) type.getBaseType();
26.2637 + if (LOGGER.isDebugEnabled())
26.2638 + LOGGER.debug("testing if it is not on parent " + parent.getName());
26.2639 + if (this.isAttributeDeclaredIn(attrName, parent, true))
26.2640 + return false;
26.2641 + }
26.2642 +
26.2643 +//check on this type (also checks recursively)
26.2644 + XSObjectList attrs = type.getAttributeUses();
26.2645 + int nb = attrs.getLength();
26.2646 + int i = 0;
26.2647 + while (i < nb && !found) {
26.2648 + XSAttributeUse anAttr = (XSAttributeUse) attrs.item(i);
26.2649 + if (anAttr != null) {
26.2650 + String name = anAttr.getName();
26.2651 + if (name == null || name.equals(""))
26.2652 + name = anAttr.getAttrDeclaration().getName();
26.2653 + if (attrName.equals(name))
26.2654 + found = true;
26.2655 + }
26.2656 + i++;
26.2657 + }
26.2658 +
26.2659 +//recursive call -> no need
26.2660 +/*if(!found && recursive &&
26.2661 + type.getDerivationMethod()==XSConstants.DERIVATION_EXTENSION){
26.2662 + XSComplexTypeDefinition base=(XSComplexTypeDefinition) type.getBaseType();
26.2663 + if(base!=null && base!=type)
26.2664 + found = this.isAttributeDeclaredIn(attrName, base, true);
26.2665 + }*/
26.2666 +
26.2667 + if (LOGGER.isDebugEnabled())
26.2668 + LOGGER.debug("is Attribute " + attrName + " declared in " + type.getName() + ": " + found);
26.2669 +
26.2670 + return found;
26.2671 + }
26.2672 +
26.2673 + private boolean doesAttributeComeFromExtension(XSAttributeUse attr, XSComplexTypeDefinition controlType) {
26.2674 + if (LOGGER.isDebugEnabled())
26.2675 + LOGGER.debug("doesAttributeComeFromExtension for " + attr.getAttrDeclaration().getName() + " and controlType=" + controlType.getName());
26.2676 + boolean comesFromExtension = false;
26.2677 + if (controlType.getDerivationMethod() == XSConstants.DERIVATION_EXTENSION) {
26.2678 + XSTypeDefinition baseType = controlType.getBaseType();
26.2679 + if (baseType.getTypeCategory() == XSTypeDefinition.COMPLEX_TYPE) {
26.2680 + XSComplexTypeDefinition complexType = (XSComplexTypeDefinition) baseType;
26.2681 + if (this.isAttributeDeclaredIn(attr, complexType, true)) {
26.2682 + if (LOGGER.isDebugEnabled())
26.2683 + LOGGER.debug("doesAttributeComeFromExtension: yes");
26.2684 + comesFromExtension = true;
26.2685 + } else { //recursive call
26.2686 + if (LOGGER.isDebugEnabled())
26.2687 + LOGGER.debug("doesAttributeComeFromExtension: recursive call on previous level");
26.2688 + comesFromExtension = this.doesAttributeComeFromExtension(attr, complexType);
26.2689 + }
26.2690 + }
26.2691 + }
26.2692 + return comesFromExtension;
26.2693 + }
26.2694 +
26.2695 + /**
26.2696 + * checkIfExtension: if false, addElement is called wether it is an extension or not
26.2697 + * if true, if it is an extension, element is recopied (and no additional bind)
26.2698 + */
26.2699 + private void addGroup(Document xForm,
26.2700 + Element modelSection,
26.2701 + Element formSection,
26.2702 + XSModelGroup group,
26.2703 + XSComplexTypeDefinition controlType,
26.2704 + XSElementDeclaration owner,
26.2705 + String pathToRoot,
26.2706 + int minOccurs,
26.2707 + int maxOccurs,
26.2708 + boolean checkIfExtension) {
26.2709 + if (group != null) {
26.2710 +
26.2711 + Element repeatSection =
26.2712 + addRepeatIfNecessary(xForm,
26.2713 + modelSection,
26.2714 + formSection,
26.2715 + owner.getTypeDefinition(),
26.2716 + minOccurs,
26.2717 + maxOccurs,
26.2718 + pathToRoot);
26.2719 + Element repeatContentWrapper = repeatSection;
26.2720 +
26.2721 + if (repeatSection != formSection) {
26.2722 + //selector -> no more needed?
26.2723 + //this.addSelector(xForm, repeatSection);
26.2724 + //group wrapper
26.2725 + repeatContentWrapper =
26.2726 + _wrapper.createGroupContentWrapper(repeatSection);
26.2727 + }
26.2728 +
26.2729 + if (LOGGER.isDebugEnabled())
26.2730 + LOGGER.debug("addGroup from owner=" + owner.getName() + " and controlType=" + controlType.getName());
26.2731 +
26.2732 + XSObjectList particles = group.getParticles();
26.2733 + for (int counter = 0; counter < particles.getLength(); counter++) {
26.2734 + XSParticle currentNode = (XSParticle) particles.item(counter);
26.2735 + XSTerm term = currentNode.getTerm();
26.2736 +
26.2737 + if (LOGGER.isDebugEnabled())
26.2738 + LOGGER.debug(" : next term = " + term.getName());
26.2739 +
26.2740 + int childMaxOccurs = currentNode.getMaxOccurs();
26.2741 + if (currentNode.getMaxOccursUnbounded())
26.2742 + childMaxOccurs = -1;
26.2743 + int childMinOccurs = currentNode.getMinOccurs();
26.2744 +
26.2745 + if (term instanceof XSModelGroup) {
26.2746 +
26.2747 + if (LOGGER.isDebugEnabled())
26.2748 + LOGGER.debug(" term is a group");
26.2749 +
26.2750 + addGroup(xForm,
26.2751 + modelSection,
26.2752 + repeatContentWrapper,
26.2753 + ((XSModelGroup) term),
26.2754 + controlType,
26.2755 + owner,
26.2756 + pathToRoot,
26.2757 + childMinOccurs,
26.2758 + childMaxOccurs,
26.2759 + checkIfExtension);
26.2760 + } else if (term instanceof XSElementDeclaration) {
26.2761 + XSElementDeclaration element = (XSElementDeclaration) term;
26.2762 +
26.2763 + if (LOGGER.isDebugEnabled())
26.2764 + LOGGER.debug(" term is an element declaration: "
26.2765 + + term.getName());
26.2766 +
26.2767 + //special case for types already added because used in an extension
26.2768 + //do not add it when it comes from an extension !!!
26.2769 + //-> make a copy from the existing form control
26.2770 + if (checkIfExtension && this.doesElementComeFromExtension(element, controlType)) {
26.2771 + if (LOGGER.isDebugEnabled()) {
26.2772 + LOGGER.debug("This element comes from an extension: recopy form controls.\n Model Section=");
26.2773 + DOMUtil.prettyPrintDOM(modelSection);
26.2774 + }
26.2775 +
26.2776 + //find the existing bind Id
26.2777 + //(modelSection is the enclosing bind of the element)
26.2778 + NodeList binds = modelSection.getElementsByTagNameNS(XFORMS_NS, "bind");
26.2779 + int i = 0;
26.2780 + int nb = binds.getLength();
26.2781 + String bindId = null;
26.2782 + while (i < nb && bindId == null) {
26.2783 + Element bind = (Element) binds.item(i);
26.2784 + String nodeset = bind.getAttributeNS(XFORMS_NS, "nodeset");
26.2785 + if (nodeset != null && nodeset.equals(element.getName()))
26.2786 + bindId = bind.getAttributeNS(XFORMS_NS, "id");
26.2787 + i++;
26.2788 + }
26.2789 +
26.2790 + //find the control
26.2791 + Element control = null;
26.2792 + if (bindId != null) {
26.2793 + if (LOGGER.isDebugEnabled())
26.2794 + LOGGER.debug("bindId found: " + bindId);
26.2795 +
26.2796 + JXPathContext context = JXPathContext.newContext(formSection.getOwnerDocument());
26.2797 + Pointer pointer = context.getPointer("//*[@" + this.getXFormsNSPrefix() + "bind='" + bindId + "']");
26.2798 + if (pointer != null)
26.2799 + control = (Element) pointer.getNode();
26.2800 + }
26.2801 +
26.2802 + //copy it
26.2803 + if (control == null) {
26.2804 + LOGGER.warn("Corresponding control not found");
26.2805 + } else {
26.2806 + Element newControl = (Element) control.cloneNode(true);
26.2807 + //set new Ids to XForm elements
26.2808 + this.resetXFormIds(newControl);
26.2809 +
26.2810 + repeatContentWrapper.appendChild(newControl);
26.2811 + }
26.2812 +
26.2813 + } else { //add it normally
26.2814 + String elementName = getElementName(element, xForm);
26.2815 +
26.2816 + String path = pathToRoot + "/" + elementName;
26.2817 +
26.2818 + if (pathToRoot.equals("")) { //relative
26.2819 + path = elementName;
26.2820 + }
26.2821 +
26.2822 + addElement(xForm,
26.2823 + modelSection,
26.2824 + repeatContentWrapper,
26.2825 + element,
26.2826 + element.getTypeDefinition(),
26.2827 + path);
26.2828 + }
26.2829 + } else { //XSWildcard -> ignore ?
26.2830 + //LOGGER.warn("XSWildcard found in group from "+owner.getName()+" for pathToRoot="+pathToRoot);
26.2831 + }
26.2832 + }
26.2833 +
26.2834 + if (LOGGER.isDebugEnabled())
26.2835 + LOGGER.debug("--- end of addGroup from owner=" + owner.getName());
26.2836 + }
26.2837 + }
26.2838 +
26.2839 + /**
26.2840 + * Add a repeat section if maxOccurs > 1.
26.2841 + */
26.2842 + private Element addRepeatIfNecessary(Document xForm,
26.2843 + Element modelSection,
26.2844 + Element formSection,
26.2845 + XSTypeDefinition controlType,
26.2846 + int minOccurs,
26.2847 + int maxOccurs,
26.2848 + String pathToRoot) {
26.2849 + Element repeatSection = formSection;
26.2850 +
26.2851 + // add xforms:repeat section if this element re-occurs
26.2852 + //
26.2853 + if (maxOccurs != 1) {
26.2854 +
26.2855 + if (LOGGER.isDebugEnabled())
26.2856 + LOGGER.debug("DEBUG: AddRepeatIfNecessary for multiple element for type "
26.2857 + + controlType.getName()
26.2858 + + ", maxOccurs=" + maxOccurs);
26.2859 +
26.2860 + //repeatSection = (Element) formSection.appendChild(xForm.createElementNS(XFORMS_NS,getXFormsNSPrefix() + "repeat"));
26.2861 + repeatSection =
26.2862 + xForm.createElementNS(XFORMS_NS,
26.2863 + getXFormsNSPrefix() + "repeat");
26.2864 +
26.2865 + //bind instead of repeat
26.2866 + //repeatSection.setAttributeNS(XFORMS_NS,getXFormsNSPrefix() + "nodeset",pathToRoot);
26.2867 + // bind -> last element in the modelSection
26.2868 + Element bind = DOMUtil.getLastChildElement(modelSection);
26.2869 + String bindId = null;
26.2870 +
26.2871 + if ((bind != null)
26.2872 + && (bind.getLocalName() != null)
26.2873 + && bind.getLocalName().equals("bind")) {
26.2874 + bindId = bind.getAttributeNS(SchemaFormBuilder.XFORMS_NS, "id");
26.2875 + } else {
26.2876 + LOGGER.warn("addRepeatIfNecessary: bind not found: "
26.2877 + + bind
26.2878 + + " (model selection name="
26.2879 + + modelSection.getNodeName()
26.2880 + + ")");
26.2881 +
26.2882 + //if no bind is found -> modelSection is already a bind, get its parent last child
26.2883 + bind =
26.2884 + DOMUtil.getLastChildElement(modelSection.getParentNode());
26.2885 +
26.2886 + if ((bind != null)
26.2887 + && (bind.getLocalName() != null)
26.2888 + && bind.getLocalName().equals("bind")) {
26.2889 + bindId =
26.2890 + bind.getAttributeNS(SchemaFormBuilder.XFORMS_NS, "id");
26.2891 + } else {
26.2892 + LOGGER.warn("addRepeatIfNecessary: bind really not found");
26.2893 + }
26.2894 + }
26.2895 +
26.2896 + repeatSection.setAttribute("bind",
26.2897 + bindId);
26.2898 + this.setXFormsId(repeatSection);
26.2899 +
26.2900 + //appearance=full is more user friendly
26.2901 + repeatSection.setAttribute("appearance",
26.2902 + "full");
26.2903 +
26.2904 + //triggers
26.2905 + this.addTriggersForRepeat(xForm,
26.2906 + formSection,
26.2907 + repeatSection,
26.2908 + minOccurs,
26.2909 + maxOccurs,
26.2910 + bindId);
26.2911 +
26.2912 + Element controlWrapper =
26.2913 + _wrapper.createControlsWrapper(repeatSection);
26.2914 + formSection.appendChild(controlWrapper);
26.2915 +
26.2916 + //add a group inside the repeat?
26.2917 + Element group =
26.2918 + xForm.createElementNS(XFORMS_NS,
26.2919 + this.getXFormsNSPrefix() + "group");
26.2920 + this.setXFormsId(group);
26.2921 + repeatSection.appendChild(group);
26.2922 + repeatSection = group;
26.2923 + }
26.2924 +
26.2925 + return repeatSection;
26.2926 + }
26.2927 +
26.2928 + /**
26.2929 + * if "createBind", a bind is created, otherwise bindId is used
26.2930 + */
26.2931 + private void addSimpleType(Document xForm,
26.2932 + Element modelSection,
26.2933 + Element formSection,
26.2934 + XSTypeDefinition controlType,
26.2935 + String owningElementName,
26.2936 + XSObject owner,
26.2937 + String pathToRoot,
26.2938 + int minOccurs,
26.2939 + int maxOccurs) {
26.2940 +
26.2941 + if (LOGGER.isDebugEnabled())
26.2942 + LOGGER.debug("addSimpleType for "
26.2943 + + controlType.getName()
26.2944 + + " (owningElementName="
26.2945 + + owningElementName
26.2946 + + ")");
26.2947 +
26.2948 + // create the <xforms:bind> element and add it to the model.
26.2949 + Element bindElement = xForm.createElementNS(XFORMS_NS, getXFormsNSPrefix() + "bind");
26.2950 + String bindId = this.setXFormsId(bindElement);
26.2951 + bindElement.setAttribute("nodeset",
26.2952 + pathToRoot);
26.2953 + bindElement = (Element) modelSection.appendChild(bindElement);
26.2954 + bindElement = startBindElement(bindElement, controlType, minOccurs, maxOccurs);
26.2955 +
26.2956 + // add a group if a repeat !
26.2957 + if (owner instanceof XSElementDeclaration
26.2958 + && maxOccurs != 1
26.2959 + ) {
26.2960 + Element groupElement = createGroup(xForm, modelSection, formSection, (XSElementDeclaration) owner);
26.2961 + //set content
26.2962 + Element groupWrapper = groupElement;
26.2963 + if (groupElement != modelSection) {
26.2964 + groupWrapper = _wrapper.createGroupContentWrapper(groupElement);
26.2965 + }
26.2966 + formSection = groupWrapper;
26.2967 + }
26.2968 +
26.2969 + //eventual repeat
26.2970 + Element repeatSection =
26.2971 + addRepeatIfNecessary(xForm,
26.2972 + modelSection,
26.2973 + formSection,
26.2974 + controlType,
26.2975 + minOccurs,
26.2976 + maxOccurs,
26.2977 + pathToRoot);
26.2978 +
26.2979 + // create the form control element
26.2980 + //put a wrapper for the repeat content, but only if it is really a repeat
26.2981 + Element contentWrapper = repeatSection;
26.2982 +
26.2983 + if (repeatSection != formSection) {
26.2984 + //content of repeat
26.2985 + contentWrapper = _wrapper.createGroupContentWrapper(repeatSection);
26.2986 +
26.2987 + //if there is a repeat -> create another bind with "."
26.2988 + Element bindElement2 =
26.2989 + xForm.createElementNS(XFORMS_NS, getXFormsNSPrefix() + "bind");
26.2990 + String bindId2 = this.setXFormsId(bindElement2);
26.2991 + bindElement2.setAttribute("nodeset",
26.2992 + ".");
26.2993 +
26.2994 + //recopy other attributes: required and type
26.2995 + // ->no, attributes shouldn't be copied
26.2996 + /*String required = "required";
26.2997 + String type = "type";
26.2998 + if (bindElement.hasAttributeNS(XFORMS_NS, required)) {
26.2999 + bindElement2.setAttributeNS(XFORMS_NS, getXFormsNSPrefix() + required,
26.3000 + bindElement.getAttributeNS(XFORMS_NS, required));
26.3001 + }
26.3002 + if (bindElement.hasAttributeNS(XFORMS_NS, type)) {
26.3003 + bindElement2.setAttributeNS(XFORMS_NS, getXFormsNSPrefix() + type,
26.3004 + bindElement.getAttributeNS(XFORMS_NS, type));
26.3005 + }*/
26.3006 +
26.3007 + bindElement.appendChild(bindElement2);
26.3008 + bindId = bindId2;
26.3009 + }
26.3010 +
26.3011 + String caption = createCaption(owningElementName);
26.3012 +
26.3013 + //Element formControl = (Element) contentWrapper.appendChild(createFormControl(xForm,caption,controlType,bindId,bindElement,minOccurs,maxOccurs));
26.3014 + Element formControl =
26.3015 + createFormControl(xForm,
26.3016 + caption,
26.3017 + controlType,
26.3018 + bindId,
26.3019 + bindElement,
26.3020 + minOccurs,
26.3021 + maxOccurs,
26.3022 + pathToRoot);
26.3023 + if (formControl == null)
26.3024 + return;
26.3025 +
26.3026 + Element controlWrapper = _wrapper.createControlsWrapper(formControl);
26.3027 + contentWrapper.appendChild(controlWrapper);
26.3028 +
26.3029 + // if this is a repeatable then set ref to point to current element
26.3030 + // not sure if this is a workaround or this is just the way XForms works...
26.3031 + //
26.3032 + if (!repeatSection.equals(formSection)) {
26.3033 + formControl.setAttribute("ref",
26.3034 + ".");
26.3035 + }
26.3036 +
26.3037 + Element hint = createHint(xForm, owner);
26.3038 +
26.3039 + if (hint != null) {
26.3040 + formControl.appendChild(hint);
26.3041 + }
26.3042 +
26.3043 + //add selector if repeat
26.3044 + //if (repeatSection != formSection)
26.3045 + //this.addSelector(xForm, (Element) formControl.getParentNode());
26.3046 + //
26.3047 + // TODO: Generate help message based on datatype and restrictions
26.3048 + endFormControl(formControl, controlType, minOccurs, maxOccurs);
26.3049 + endBindElement(bindElement);
26.3050 + }
26.3051 +
26.3052 + private void addSimpleType(Document xForm,
26.3053 + Element modelSection,
26.3054 + Element formSection,
26.3055 + XSSimpleTypeDefinition controlType,
26.3056 + XSElementDeclaration owner,
26.3057 + String pathToRoot) {
26.3058 +
26.3059 + int[] occurance = this.getOccurance(owner);
26.3060 + addSimpleType(xForm,
26.3061 + modelSection,
26.3062 + formSection,
26.3063 + controlType,
26.3064 + owner.getName(),
26.3065 + owner,
26.3066 + pathToRoot,
26.3067 + occurance[0],
26.3068 + occurance[1]);
26.3069 + }
26.3070 +
26.3071 + private void addSimpleType(Document xForm,
26.3072 + Element modelSection,
26.3073 + Element formSection,
26.3074 + XSSimpleTypeDefinition controlType,
26.3075 + XSAttributeUse owningAttribute,
26.3076 + String pathToRoot) {
26.3077 +
26.3078 + addSimpleType(xForm,
26.3079 + modelSection,
26.3080 + formSection,
26.3081 + controlType,
26.3082 + owningAttribute.getAttrDeclaration().getName(),
26.3083 + owningAttribute,
26.3084 + pathToRoot,
26.3085 + owningAttribute.getRequired() ? 1 : 0,
26.3086 + 1);
26.3087 + }
26.3088 +
26.3089 + /**
26.3090 + * adds a "chiba:selector" in the specified element
26.3091 + **/
26.3092 +
26.3093 + /*private void addSelector(Document xForm, Element el) {
26.3094 + Element extension = xForm.createElementNS(XFORMS_NS, getXFormsNSPrefix() + "extension");
26.3095 + el.appendChild(extension);
26.3096 + Element selector = xForm.createElementNS(XFORMS_NS, getChibaNSPrefix() + "selector");
26.3097 + extension.appendChild(selector);
26.3098 + }*/
26.3099 +
26.3100 + /**
26.3101 + * add triggers to use the repeat elements (allow to add an element, ...)
26.3102 + */
26.3103 + private void addTriggersForRepeat(Document xForm,
26.3104 + Element formSection,
26.3105 + Element repeatSection,
26.3106 + int minOccurs,
26.3107 + int maxOccurs,
26.3108 + String bindId) {
26.3109 + ///////////// insert //////////////////
26.3110 + //trigger insert
26.3111 + Element trigger_insert =
26.3112 + xForm.createElementNS(SchemaFormBuilder.XFORMS_NS,
26.3113 + SchemaFormBuilder.xformsNSPrefix + "trigger");
26.3114 + this.setXFormsId(trigger_insert);
26.3115 +
26.3116 + //label insert
26.3117 + Element triggerLabel_insert =
26.3118 + xForm.createElementNS(SchemaFormBuilder.XFORMS_NS,
26.3119 + SchemaFormBuilder.xformsNSPrefix + "label");
26.3120 + this.setXFormsId(triggerLabel_insert);
26.3121 + trigger_insert.appendChild(triggerLabel_insert);
26.3122 + triggerLabel_insert.setAttribute("href",
26.3123 + "images/add_new.gif");
26.3124 +
26.3125 + Text label_insert = xForm.createTextNode("Insert after selected");
26.3126 + triggerLabel_insert.appendChild(label_insert);
26.3127 +
26.3128 + //hint insert
26.3129 + Element hint_insert =
26.3130 + xForm.createElementNS(SchemaFormBuilder.XFORMS_NS,
26.3131 + SchemaFormBuilder.xformsNSPrefix + "hint");
26.3132 + this.setXFormsId(hint_insert);
26.3133 + Text hint_insert_text =
26.3134 + xForm.createTextNode("inserts a new entry in this collection");
26.3135 + hint_insert.appendChild(hint_insert_text);
26.3136 + trigger_insert.appendChild(hint_insert);
26.3137 +
26.3138 + //insert action
26.3139 + Element action_insert =
26.3140 + xForm.createElementNS(SchemaFormBuilder.XFORMS_NS,
26.3141 + SchemaFormBuilder.xformsNSPrefix + "action");
26.3142 + trigger_insert.appendChild(action_insert);
26.3143 + this.setXFormsId(action_insert);
26.3144 +
26.3145 + Element insert =
26.3146 + xForm.createElementNS(SchemaFormBuilder.XFORMS_NS,
26.3147 + SchemaFormBuilder.xformsNSPrefix + "insert");
26.3148 + action_insert.appendChild(insert);
26.3149 + this.setXFormsId(insert);
26.3150 +
26.3151 + //insert: bind & other attributes
26.3152 + if (bindId != null) {
26.3153 + insert.setAttribute("bind",
26.3154 + bindId);
26.3155 + }
26.3156 +
26.3157 + insert.setAttribute("position",
26.3158 + "after");
26.3159 +
26.3160 + //xforms:at = xforms:index from the "id" attribute on the repeat element
26.3161 + String repeatId =
26.3162 + repeatSection.getAttributeNS(SchemaFormBuilder.XFORMS_NS, "id");
26.3163 +
26.3164 + if (repeatId != null) {
26.3165 + insert.setAttribute("at",
26.3166 + "index('" + repeatId + "')");
26.3167 + }
26.3168 +
26.3169 + ///////////// delete //////////////////
26.3170 + //trigger delete
26.3171 + Element trigger_delete =
26.3172 + xForm.createElementNS(SchemaFormBuilder.XFORMS_NS,
26.3173 + SchemaFormBuilder.xformsNSPrefix + "trigger");
26.3174 + this.setXFormsId(trigger_delete);
26.3175 +
26.3176 + //label delete
26.3177 + Element triggerLabel_delete =
26.3178 + xForm.createElementNS(SchemaFormBuilder.XFORMS_NS,
26.3179 + SchemaFormBuilder.xformsNSPrefix + "label");
26.3180 + this.setXFormsId(triggerLabel_delete);
26.3181 + trigger_delete.appendChild(triggerLabel_delete);
26.3182 + triggerLabel_delete.setAttribute( "href",
26.3183 + "images/delete.gif");
26.3184 +
26.3185 + Text label_delete = xForm.createTextNode("Delete selected");
26.3186 + triggerLabel_delete.appendChild(label_delete);
26.3187 +
26.3188 + //hint delete
26.3189 + Element hint_delete =
26.3190 + xForm.createElementNS(SchemaFormBuilder.XFORMS_NS,
26.3191 + SchemaFormBuilder.xformsNSPrefix + "hint");
26.3192 + this.setXFormsId(hint_delete);
26.3193 + Text hint_delete_text =
26.3194 + xForm.createTextNode("deletes selected entry from this collection");
26.3195 + hint_delete.appendChild(hint_delete_text);
26.3196 + trigger_delete.appendChild(hint_delete);
26.3197 +
26.3198 + //delete action
26.3199 + Element action_delete =
26.3200 + xForm.createElementNS(SchemaFormBuilder.XFORMS_NS,
26.3201 + SchemaFormBuilder.xformsNSPrefix + "action");
26.3202 + trigger_delete.appendChild(action_delete);
26.3203 + this.setXFormsId(action_delete);
26.3204 +
26.3205 + Element delete =
26.3206 + xForm.createElementNS(SchemaFormBuilder.XFORMS_NS,
26.3207 + SchemaFormBuilder.xformsNSPrefix + "delete");
26.3208 + action_delete.appendChild(delete);
26.3209 + this.setXFormsId(delete);
26.3210 +
26.3211 + //delete: bind & other attributes
26.3212 + if (bindId != null) {
26.3213 + delete.setAttribute("bind",
26.3214 + bindId);
26.3215 + }
26.3216 +
26.3217 + //xforms:at = xforms:index from the "id" attribute on the repeat element
26.3218 + if (repeatId != null) {
26.3219 + delete.setAttribute("at",
26.3220 + "index('" + repeatId + "')");
26.3221 + }
26.3222 +
26.3223 + //add the triggers
26.3224 + Element wrapper_triggers =
26.3225 + _wrapper.createControlsWrapper(trigger_insert);
26.3226 +
26.3227 + if (wrapper_triggers == trigger_insert) { //no wrapper
26.3228 + formSection.appendChild(trigger_insert);
26.3229 + formSection.appendChild(trigger_delete);
26.3230 + } else {
26.3231 + formSection.appendChild(wrapper_triggers);
26.3232 +
26.3233 + Element insert_parent = (Element) trigger_insert.getParentNode();
26.3234 +
26.3235 + if (insert_parent != null) {
26.3236 + insert_parent.appendChild(trigger_delete);
26.3237 + }
26.3238 + }
26.3239 + }
26.3240 +
26.3241 + /**
26.3242 + * Build the type tree
26.3243 + */
26.3244 + /*private void buildTypeTree(XSTypeDefinition type, TreeSet descendents) {
26.3245 + if (type != null) {
26.3246 +
26.3247 + if (descendents.size() > 0) {
26.3248 + TreeSet compatibleTypes = (TreeSet) typeTree.get(type.getName());
26.3249 +
26.3250 + if (compatibleTypes == null) {
26.3251 + compatibleTypes = new TreeSet(descendents);
26.3252 + typeTree.put(type.getName(), compatibleTypes);
26.3253 + } else {
26.3254 + compatibleTypes.addAll(descendents);
26.3255 + }
26.3256 + }
26.3257 +
26.3258 + XSTypeDefinition parentType = type.getBaseType();
26.3259 +
26.3260 + if (parentType != null
26.3261 + && type.getTypeCategory() == parentType.getTypeCategory()) {
26.3262 + String typeName = type.getName();
26.3263 + String parentTypeName = parentType.getName();
26.3264 + if ((typeName == null && parentTypeName != null)
26.3265 + || (typeName != null && parentTypeName == null)
26.3266 + || (typeName != null
26.3267 + && parentTypeName != null
26.3268 + && !type.getName().equals(parentType.getName())
26.3269 + && !parentType.getName().equals("anyType"))) {
26.3270 +
26.3271 +TreeSet newDescendents=new TreeSet(descendents);
26.3272 +//extension (we only add it to "newDescendants" because we don't want
26.3273 +//to have a type descendant to itself, but to consider it for the parent
26.3274 +if (type.getTypeCategory() == XSTypeDefinition.COMPLEX_TYPE) {
26.3275 +XSComplexTypeDefinition complexType =
26.3276 + (XSComplexTypeDefinition) type;
26.3277 +if (complexType.getDerivationMethod()
26.3278 + == XSConstants.DERIVATION_EXTENSION
26.3279 + && !complexType.getAbstract()
26.3280 + && !descendents.contains(type.getName()) //to be tested
26.3281 + ) {
26.3282 +newDescendents.add(type.getName());
26.3283 +}
26.3284 +}
26.3285 +//note: extensions are impossible on simpleTypes !
26.3286 +
26.3287 + buildTypeTree(parentType, newDescendents);
26.3288 + }
26.3289 + }
26.3290 + }
26.3291 + }*/
26.3292 + private void buildTypeTree(XSTypeDefinition type, TreeSet descendents) {
26.3293 + if (type != null) {
26.3294 +
26.3295 + if (descendents.size() > 0) {
26.3296 + //TreeSet compatibleTypes = (TreeSet) typeTree.get(type.getName());
26.3297 + TreeSet compatibleTypes = (TreeSet) typeTree.get(type.getName());
26.3298 +
26.3299 + if (compatibleTypes == null) {
26.3300 + //compatibleTypes = new TreeSet(descendents);
26.3301 + compatibleTypes = new TreeSet(TypeExtensionSorter.getInstance());
26.3302 + compatibleTypes.addAll(descendents);
26.3303 + //typeTree.put(type.getName(), compatibleTypes);
26.3304 + typeTree.put(type.getName(), compatibleTypes);
26.3305 + } else {
26.3306 + compatibleTypes.addAll(descendents);
26.3307 + }
26.3308 + }
26.3309 +
26.3310 + XSTypeDefinition parentType = type.getBaseType();
26.3311 +
26.3312 + if (parentType != null
26.3313 + && type.getTypeCategory() == parentType.getTypeCategory()) {
26.3314 + /*String typeName = type.getName();
26.3315 + String parentTypeName = parentType.getName();
26.3316 + if ((typeName == null && parentTypeName != null)
26.3317 + || (typeName != null && parentTypeName == null)
26.3318 + || (typeName != null
26.3319 + && parentTypeName != null
26.3320 + && !type.getName().equals(parentType.getName())
26.3321 + && !parentType.getName().equals("anyType"))) {*/
26.3322 + if (type != parentType
26.3323 + && (parentType.getName() == null
26.3324 + || !parentType.getName().equals("anyType"))) {
26.3325 +
26.3326 +//TreeSet newDescendents=new TreeSet(descendents);
26.3327 + TreeSet newDescendents = new TreeSet(TypeExtensionSorter.getInstance());
26.3328 + newDescendents.addAll(descendents);
26.3329 +
26.3330 +//extension (we only add it to "newDescendants" because we don't want
26.3331 +//to have a type descendant to itself, but to consider it for the parent
26.3332 + if (type.getTypeCategory() == XSTypeDefinition.COMPLEX_TYPE) {
26.3333 + XSComplexTypeDefinition complexType =
26.3334 + (XSComplexTypeDefinition) type;
26.3335 + if (complexType.getDerivationMethod()
26.3336 + == XSConstants.DERIVATION_EXTENSION
26.3337 + && !complexType.getAbstract()
26.3338 + && !descendents.contains(type) //to be tested
26.3339 + //&& !descendents.contains(type.getName()) //to be tested
26.3340 + ) {
26.3341 +//newDescendents.add(type.getName());
26.3342 + newDescendents.add(type);
26.3343 + }
26.3344 + }
26.3345 +//note: extensions are impossible on simpleTypes !
26.3346 +
26.3347 + buildTypeTree(parentType, newDescendents);
26.3348 + }
26.3349 + }
26.3350 + }
26.3351 + }
26.3352 +
26.3353 + private void buildTypeTree(XSModel schema) {
26.3354 + // build the type tree for complex types
26.3355 + //
26.3356 + XSNamedMap types = schema.getComponents(XSConstants.TYPE_DEFINITION);
26.3357 + int nb = types.getLength();
26.3358 + for (int i = 0; i < nb; i++) {
26.3359 + XSTypeDefinition t = (XSTypeDefinition) types.item(i);
26.3360 + if (t.getTypeCategory() == XSTypeDefinition.COMPLEX_TYPE) {
26.3361 + XSComplexTypeDefinition type = (XSComplexTypeDefinition) t;
26.3362 + buildTypeTree(type, new TreeSet(TypeExtensionSorter.getInstance()));
26.3363 + }
26.3364 + }
26.3365 +
26.3366 + // build the type tree for simple types
26.3367 + for (int i = 0; i < nb; i++) {
26.3368 + XSTypeDefinition t = (XSTypeDefinition) types.item(i);
26.3369 + if (t.getTypeCategory() == XSTypeDefinition.SIMPLE_TYPE) {
26.3370 + XSSimpleTypeDefinition type = (XSSimpleTypeDefinition) t;
26.3371 + buildTypeTree(type, new TreeSet(TypeExtensionSorter.getInstance()));
26.3372 + }
26.3373 + }
26.3374 +
26.3375 + // print out type hierarchy for debugging purposes
26.3376 + if (LOGGER.isDebugEnabled()) {
26.3377 + Iterator keys = typeTree.keySet().iterator();
26.3378 + while (keys.hasNext()) {
26.3379 + String typeName = (String) keys.next();
26.3380 + TreeSet descendents = (TreeSet) typeTree.get(typeName);
26.3381 + LOGGER.debug(">>>> for " + typeName + " Descendants=\n ");
26.3382 + Iterator it = descendents.iterator();
26.3383 + while (it.hasNext()) {
26.3384 + XSTypeDefinition desc = (XSTypeDefinition) it.next();
26.3385 + LOGGER.debug(" " + desc.getName());
26.3386 + }
26.3387 + }
26.3388 + }
26.3389 + }
26.3390 +
26.3391 + private Element createFormControl(Document xForm,
26.3392 + String caption,
26.3393 + XSTypeDefinition controlType,
26.3394 + String bindId,
26.3395 + Element bindElement,
26.3396 + int minOccurs,
26.3397 + int maxOccurs,
26.3398 + String pathToRoot) {
26.3399 + // Select1 xform control to use:
26.3400 + // Will use one of the following: input, textarea, selectOne, selectBoolean, selectMany, range
26.3401 + // secret, output, button, do not apply
26.3402 + //
26.3403 + // select1: enumeration or keyref constrained value
26.3404 + // select: list
26.3405 + // range: union (? not sure about this)
26.3406 + // textarea : ???
26.3407 + // input: default
26.3408 + //
26.3409 + Element formControl = null;
26.3410 +
26.3411 + // Read only, just output
26.3412 + if (!writable) {
26.3413 + formControl = xForm.createElementNS(XFORMS_NS, getXFormsNSPrefix() + "output");
26.3414 + formControl.setAttribute("model", "inputModel");
26.3415 + Element captionElement =
26.3416 + (Element) formControl.appendChild(xForm.createElementNS(XFORMS_NS,
26.3417 + getXFormsNSPrefix() + "label"));
26.3418 + captionElement.appendChild(xForm.createTextNode(caption));
26.3419 +
26.3420 + } else {
26.3421 +
26.3422 + if (defaultValues.containsKey(pathToRoot)) {
26.3423 + defaultSets.put("instance('output')/"+pathToRoot, defaultValues.get(pathToRoot));
26.3424 + return null;
26.3425 + }
26.3426 +
26.3427 + if (controlType.getTypeCategory() == XSTypeDefinition.SIMPLE_TYPE) {
26.3428 + XSSimpleTypeDefinition simpleType = (XSSimpleTypeDefinition) controlType;
26.3429 + if (simpleType.getItemType() != null) // list
26.3430 + {
26.3431 + formControl = createControlForListType(xForm, simpleType, caption, bindElement);
26.3432 + } else { // other simple type
26.3433 + // need to check constraints to determine which form control to use
26.3434 + //
26.3435 + // use the selectOne control
26.3436 + //
26.3437 + // XSObjectList enumerationFacets =
26.3438 + // simpleType.getFacets(XSSimpleTypeDefinition.FACET_ENUMERATION);
26.3439 + // if(enumerationFacets.getLength()>0){
26.3440 + if (simpleType.isDefinedFacet(XSSimpleTypeDefinition.FACET_ENUMERATION)) {
26.3441 + formControl = createControlForEnumerationType(xForm, simpleType, caption,
26.3442 + bindElement);
26.3443 +
26.3444 + }
26.3445 + /*
26.3446 + * if (enumerationFacets.hasMoreElements()) { formControl =
26.3447 + * createControlForEnumerationType(xForm, (SimpleType)controlType, caption,
26.3448 + * bindElement); }
26.3449 + */
26.3450 + }
26.3451 + } else if (controlType.getTypeCategory() == XSTypeDefinition.COMPLEX_TYPE
26.3452 + && controlType.getName().equals("anyType")) {
26.3453 + formControl = createControlForAnyType(xForm, caption, controlType);
26.3454 + }
26.3455 +
26.3456 + if (formControl == null) {
26.3457 + // default situation - use an input control
26.3458 + //
26.3459 + formControl = createControlForAtomicType(xForm, caption,
26.3460 + (XSSimpleTypeDefinition) controlType);
26.3461 + }
26.3462 +
26.3463 + startFormControl(formControl, controlType);
26.3464 + formControl.setAttribute("model", "outputModel");
26.3465 + }
26.3466 +// formControl.setAttributeNS(XFORMS_NS,
26.3467 +// getXFormsNSPrefix() + "bind",
26.3468 +// bindId);
26.3469 +
26.3470 + formControl.setAttribute("ref",
26.3471 + pathToRoot);
26.3472 +
26.3473 + formControl.setAttribute("incremental",
26.3474 + "true");
26.3475 +
26.3476 +// addNameSpaces(formControl);
26.3477 + //put the label before
26.3478 + // no -> put in the "createControlFor..." methods
26.3479 +
26.3480 + /*Element captionElement=xForm.createElementNS(XFORMS_NS,getXFormsNSPrefix() + "label");
26.3481 + this.setXFormsId(captionElement);
26.3482 + captionElement.appendChild(xForm.createTextNode(caption));
26.3483 + if(formControl.hasChildNodes())
26.3484 + {
26.3485 + Node first=formControl.getFirstChild();
26.3486 + captionElement = (Element) formControl.insertBefore(captionElement, first);
26.3487 + }
26.3488 + else
26.3489 + captionElement = (Element) formControl.appendChild(captionElement); */
26.3490 +
26.3491 + // TODO: Enhance alert statement based on facet restrictions.
26.3492 + // TODO: Enhance to support minOccurs > 1 and maxOccurs > 1.
26.3493 + // TODO: Add i18n/l10n suppport to this - use java MessageFormatter...
26.3494 + //
26.3495 + // e.g. Please provide a valid value for 'Address'. 'Address' is a mandatory decimal field.
26.3496 + //
26.3497 + Element alertElement =
26.3498 + (Element) formControl.appendChild(xForm.createElementNS(XFORMS_NS,
26.3499 + getXFormsNSPrefix() + "alert"));
26.3500 + this.setXFormsId(alertElement);
26.3501 +
26.3502 + StringBuffer alert =
26.3503 + new StringBuffer("Please provide a valid value for '" + caption + "'.");
26.3504 +
26.3505 + Element enveloppe = xForm.getDocumentElement();
26.3506 +
26.3507 + if (minOccurs != 0) {
26.3508 + alert.append(" '"
26.3509 + + caption
26.3510 + + "' is a required '"
26.3511 + + createCaption(this.getXFormsTypeName(enveloppe, controlType))
26.3512 + + "' value.");
26.3513 + } else {
26.3514 + alert.append(" '"
26.3515 + + caption
26.3516 + + "' is an optional '"
26.3517 + + createCaption(this.getXFormsTypeName(enveloppe, controlType))
26.3518 + + "' value.");
26.3519 + }
26.3520 +
26.3521 + alertElement.appendChild(xForm.createTextNode(alert.toString()));
26.3522 +
26.3523 + return formControl;
26.3524 + }
26.3525 +
26.3526 + /**
26.3527 + * used to get the type name that will be used in the XForms document
26.3528 + *
26.3529 + * @param context the element which will serve as context for namespaces
26.3530 + * @param controlType the type from which we want the name
26.3531 + * @return the complete type name (with namespace prefix) of the type in the XForms doc
26.3532 + */
26.3533 + protected String getXFormsTypeName(Element context, XSTypeDefinition controlType) {
26.3534 + String result = null;
26.3535 +
26.3536 + String typeName = controlType.getName();
26.3537 + String typeNS = controlType.getNamespace();
26.3538 +
26.3539 + //if we use XMLSchema types:
26.3540 + //first check if it is a simple type named in the XMLSchema
26.3541 + if (_useSchemaTypes
26.3542 + && controlType.getTypeCategory() == XSTypeDefinition.SIMPLE_TYPE
26.3543 + && typeName != null && !typeName.equals("")
26.3544 + && schema.getTypeDefinition(typeName, typeNS) != null) { //type is globally defined
26.3545 + //use schema type
26.3546 +
26.3547 + //local type name
26.3548 + String localTypeName = typeName;
26.3549 + int index = typeName.indexOf(":");
26.3550 + if (index > -1 && typeName.length() > index)
26.3551 + localTypeName = typeName.substring(index + 1);
26.3552 +
26.3553 + //namespace prefix in this document
26.3554 + String prefix = NamespaceResolver.getPrefix(context, typeNS);
26.3555 +
26.3556 + //completeTypeName = new prefix + local name
26.3557 + result = localTypeName;
26.3558 + if (prefix != null && !prefix.equals(""))
26.3559 + result = prefix + ":" + localTypeName;
26.3560 +
26.3561 + if (LOGGER.isDebugEnabled())
26.3562 + LOGGER.debug("getXFormsTypeName: typeName=" + typeName + ", typeNS=" + typeNS + ", result=" + result);
26.3563 + } else { //use built in type
26.3564 + result = this.getDataTypeName(getBuiltInType(controlType));
26.3565 + }
26.3566 + return result;
26.3567 + }
26.3568 +
26.3569 + private Document createFormTemplate(String formId)
26.3570 + throws IOException, ParserConfigurationException {
26.3571 + return createFormTemplate(formId,
26.3572 + "Form " + formId,
26.3573 + getProperty(CSS_STYLE_PROP, DEFAULT_CSS_STYLE_PROP));
26.3574 + }
26.3575 +
26.3576 + private Document createFormTemplate(String formId,
26.3577 + String formName,
26.3578 + String stylesheet)
26.3579 + throws ParserConfigurationException {
26.3580 + Document xForm = documentBuilder.newDocument();
26.3581 +
26.3582 + Element envelopeElement = _wrapper.createEnvelope(xForm);
26.3583 +
26.3584 + // set required namespace attributes
26.3585 + envelopeElement.setAttributeNS(XMLNS_NAMESPACE_URI,
26.3586 + "xmlns:"
26.3587 + + getChibaNSPrefix().substring(0,
26.3588 + getChibaNSPrefix().length() - 1),
26.3589 + CHIBA_NS);
26.3590 + envelopeElement.setAttributeNS(XMLNS_NAMESPACE_URI,
26.3591 + "xmlns:"
26.3592 + + getXFormsNSPrefix().substring(0,
26.3593 + getXFormsNSPrefix().length() - 1),
26.3594 + XFORMS_NS);
26.3595 + envelopeElement.setAttributeNS(XMLNS_NAMESPACE_URI,
26.3596 + "xmlns:"
26.3597 + + getXLinkNSPrefix().substring(0,
26.3598 + getXLinkNSPrefix().length() - 1),
26.3599 + XLINK_NS);
26.3600 +//XMLEvent
26.3601 + envelopeElement.setAttributeNS(XMLNS_NAMESPACE_URI,
26.3602 + "xmlns:" +
26.3603 + xmleventsNSPrefix.substring(0, xmleventsNSPrefix.length() - 1),
26.3604 + XMLEVENTS_NS);
26.3605 +//XML Schema Instance
26.3606 + envelopeElement.setAttributeNS(XMLNS_NAMESPACE_URI,
26.3607 + "xmlns:" +
26.3608 + xmlSchemaInstancePrefix.substring(0, xmlSchemaInstancePrefix.length() - 1),
26.3609 + XMLSCHEMA_INSTANCE_NAMESPACE_URI);
26.3610 +//base
26.3611 + if (_base != null && !_base.equals("")) {
26.3612 + envelopeElement.setAttributeNS(XML_NAMESPACE_URI,
26.3613 + "xml:base",
26.3614 + _base);
26.3615 + }
26.3616 +
26.3617 + //model element
26.3618 + Element modelElement =
26.3619 + xForm.createElementNS(XFORMS_NS, getXFormsNSPrefix() + "model");
26.3620 + this.setXFormsId(modelElement);
26.3621 + Element modelWrapper = _wrapper.createModelWrapper(modelElement);
26.3622 + envelopeElement.appendChild(modelWrapper);
26.3623 +
26.3624 + //form control wrapper -> created by wrapper
26.3625 + //Element formWrapper = xForm.createElement("body");
26.3626 + //envelopeElement.appendChild(formWrapper);
26.3627 + Element formWrapper = _wrapper.createFormWrapper(envelopeElement);
26.3628 +
26.3629 + return xForm;
26.3630 + }
26.3631 +
26.3632 + private Element createGroup(Document xForm,
26.3633 + Element modelSection,
26.3634 + Element formSection,
26.3635 + XSElementDeclaration owner) {
26.3636 + // add a group node and recurse
26.3637 + //
26.3638 + Element groupElement =
26.3639 + xForm.createElementNS(XFORMS_NS, getXFormsNSPrefix() + "group");
26.3640 + groupElement = startFormGroup(groupElement, owner);
26.3641 +
26.3642 + if (groupElement != null) {
26.3643 + this.setXFormsId(groupElement);
26.3644 +
26.3645 + Element controlsWrapper =
26.3646 + _wrapper.createControlsWrapper(groupElement);
26.3647 +
26.3648 + //groupElement = (Element) formSection.appendChild(groupElement);
26.3649 + formSection.appendChild(controlsWrapper);
26.3650 +
26.3651 + Element captionElement =
26.3652 + (Element) groupElement.appendChild(xForm.createElementNS(XFORMS_NS,
26.3653 + getXFormsNSPrefix() + "label"));
26.3654 + this.setXFormsId(captionElement);
26.3655 + captionElement.appendChild(xForm.createTextNode(createCaption(owner)));
26.3656 +
26.3657 + //no hint in groups
26.3658 +
26.3659 + /*Element hint = createHint(xForm,owner);
26.3660 + if (hint != null) {
26.3661 + groupElement.appendChild(hint);
26.3662 + }*/
26.3663 + } else {
26.3664 + groupElement = modelSection;
26.3665 + }
26.3666 +
26.3667 + return groupElement;
26.3668 + }
26.3669 +
26.3670 + /**
26.3671 + * Get a fully qualified name for this element, and eventually declares a new prefix for the namespace if
26.3672 + * it was not declared before
26.3673 + *
26.3674 + * @param element
26.3675 + * @param xForm
26.3676 + * @return
26.3677 + */
26.3678 + private String getElementName(XSElementDeclaration element, Document xForm) {
26.3679 + String elementName = element.getName();
26.3680 + String namespace = element.getNamespace();
26.3681 + if (namespace != null && !namespace.equals("")) {
26.3682 + String prefix;
26.3683 + if ((prefix = (String) namespacePrefixes.get(namespace)) == null) {
26.3684 + String basePrefix = (namespace.substring(namespace.lastIndexOf('/', namespace.length()-2)+1));
26.3685 + int i=1;
26.3686 + prefix = basePrefix;
26.3687 + while (namespacePrefixes.containsValue(prefix)) {
26.3688 + prefix = basePrefix + (i++);
26.3689 + }
26.3690 + namespacePrefixes.put(namespace, prefix);
26.3691 + Element envelope = xForm.getDocumentElement();
26.3692 + envelope.setAttributeNS(XMLNS_NAMESPACE_URI, "xmlns:"+prefix, namespace);
26.3693 + }
26.3694 + elementName = prefix + ":" + elementName;
26.3695 + }
26.3696 + return elementName;
26.3697 + }
26.3698 +
26.3699 + private void addNameSpaces(Element element) {
26.3700 + for (Iterator it = namespacePrefixes.entrySet().iterator(); it.hasNext();) {
26.3701 + Map.Entry entry = (Entry) it.next();
26.3702 + element.setAttributeNS(XMLNS_NAMESPACE_URI, "xmlns:"+ entry.getValue(), (String ) entry.getKey());
26.3703 + }
26.3704 + }
26.3705 +}
27.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
27.2 +++ b/enterprise/openesbaddons/workflow/project/antsrc/org/netbeans/modules/workflow/project/anttasks/BaseSchemaFormBuilder.java Thu Apr 26 02:33:27 2007 +0000
27.3 @@ -0,0 +1,651 @@
27.4 +package org.netbeans.modules.workflow.project.anttasks;
27.5 +
27.6 +/*
27.7 + * Sun Public License Notice
27.8 + *
27.9 + * The contents of this file are subject to the Sun Public License
27.10 + * Version 1.0 (the "License"). You may not use this file except in
27.11 + * compliance with the License. A copy of the License is available at
27.12 + * http://www.sun.com/
27.13 + *
27.14 + * The Original Code is NetBeans. The Initial Developer of the Original
27.15 + * Code is Sun Microsystems, Inc. Portions Copyright 1997-2004 Sun
27.16 + * Microsystems, Inc. All Rights Reserved.
27.17 + */
27.18 +
27.19 +/*
27.20 + * This class is modified based on {@link org.chiba.tools.schemabuilder.BaseSchemaFormBuilder} from chiba
27.21 + * (http://chiba.sourceforge.net/).
27.22 + *
27.23 + * The modifications made on AbstractSchemaFormBuilder are :
27.24 + *
27.25 + * 1. Add new constructor to differentiate controls generated for readonly xforms
27.26 + * 2. Generate textarea control for certain captions
27.27 + * 3. Add new constructors for setting default vlaue in xform
27.28 + */
27.29 +
27.30 +import com.sun.org.apache.xerces.internal.xs.*;
27.31 +import org.chiba.tools.schemabuilder.SchemaFormBuilder;
27.32 +import org.chiba.tools.schemabuilder.StringUtil;
27.33 +import org.chiba.tools.schemabuilder.WrapperElementsBuilder;
27.34 +import org.w3c.dom.Document;
27.35 +import org.w3c.dom.Element;
27.36 +import org.w3c.dom.Text;
27.37 +
27.38 +import javax.xml.transform.Source;
27.39 +
27.40 +import java.util.Map;
27.41 +import java.util.Vector;
27.42 +
27.43 +/*
27.44 + * Search for TODO for things remaining to-do in this implementation.
27.45 + *
27.46 + * TODO: i18n/l10n of messages, hints, captions. Possibly leverage org.chiba.i18n classes.
27.47 + * TODO: When Chiba supports itemset, use schema keyref and key constraints for validation.
27.48 + * TODO: Add support for default and fixed values.
27.49 + * TODO: Add support for use=prohibited.
27.50 + */
27.51 +
27.52 +/**
27.53 + * A concrete base implementation of the SchemaFormBuilder interface allowing
27.54 + * an XForm to be automatically generated for an XML Schema definition.
27.55 + *
27.56 + * @author Brian Dueck
27.57 + * @version $Id$
27.58 + * @deprecated
27.59 + */
27.60 +public class BaseSchemaFormBuilder
27.61 + extends AbstractSchemaFormBuilder
27.62 + implements SchemaFormBuilder {
27.63 + /**
27.64 + * Creates a new instance of BaseSchemaForBuilder
27.65 + */
27.66 + public BaseSchemaFormBuilder(String rootTagName) {
27.67 + super(rootTagName);
27.68 + }
27.69 +
27.70 + public BaseSchemaFormBuilder(String rootTagName, boolean addSubmit, Map defaultValues) {
27.71 + super(rootTagName, addSubmit, defaultValues);
27.72 + }
27.73 +
27.74 +
27.75 + /**
27.76 + * Creates a new BaseSchemaFormBuilder object.
27.77 + *
27.78 + * @param rootTagName __UNDOCUMENTED__
27.79 + * @param instanceSource __UNDOCUMENTED__
27.80 + * @param action __UNDOCUMENTED__
27.81 + * @param submitMethod __UNDOCUMENTED__
27.82 + * @param wrapper __UNDOCUMENTED__
27.83 + * @param stylesheet __UNDOCUMENTED__
27.84 + */
27.85 + public BaseSchemaFormBuilder(String rootTagName,
27.86 + Source instanceSource,
27.87 + String action,
27.88 + String submitMethod,
27.89 + WrapperElementsBuilder wrapper,
27.90 + String stylesheet,
27.91 + String base,
27.92 + boolean userSchemaTypes,
27.93 + boolean addSubmit,
27.94 + Map defaultValues) {
27.95 + super(rootTagName,
27.96 + instanceSource,
27.97 + action,
27.98 + submitMethod,
27.99 + wrapper,
27.100 + stylesheet,
27.101 + base,
27.102 + userSchemaTypes,
27.103 + addSubmit, defaultValues);
27.104 + }
27.105 +
27.106 + /**
27.107 + * Creates a new BaseSchemaFormBuilder object.
27.108 + *
27.109 + * @param rootTagName __UNDOCUMENTED__
27.110 + * @param instanceHref __UNDOCUMENTED__
27.111 + * @param action __UNDOCUMENTED__
27.112 + * @param submitMethod __UNDOCUMENTED__
27.113 + * @param wrapper __UNDOCUMENTED__
27.114 + * @param stylesheet __UNDOCUMENTED__
27.115 + */
27.116 + public BaseSchemaFormBuilder(String rootTagName,
27.117 + String instanceHref,
27.118 + String action,
27.119 + String submitMethod,
27.120 + WrapperElementsBuilder wrapper,
27.121 + String stylesheet,
27.122 + String base,
27.123 + boolean userSchemaTypes,
27.124 + boolean addSubmit,
27.125 + Map defaultValues) {
27.126 + super(rootTagName,
27.127 + instanceHref,
27.128 + action,
27.129 + submitMethod,
27.130 + wrapper,
27.131 + stylesheet,
27.132 + base,
27.133 + userSchemaTypes,
27.134 + addSubmit, defaultValues);
27.135 + }
27.136 +
27.137 + /**
27.138 + * __UNDOCUMENTED__
27.139 + *
27.140 + * @param text __UNDOCUMENTED__
27.141 + * @return __UNDOCUMENTED__
27.142 + */
27.143 + public String createCaption(String text) {
27.144 + return StringUtil.capitalizeIdentifier(text);
27.145 + }
27.146 +
27.147 + /**
27.148 + * __UNDOCUMENTED__
27.149 + *
27.150 + * @param attribute __UNDOCUMENTED__
27.151 + * @return __UNDOCUMENTED__
27.152 + */
27.153 + public String createCaption(XSAttributeDeclaration attribute) {
27.154 + // TODO: Improve i18n/l10n of caption - may have to use
27.155 + // a custom <appinfo> element in the XML Schema to do this.
27.156 + //
27.157 + return createCaption(attribute.getName());
27.158 + }
27.159 +
27.160 + public String createCaption(XSAttributeUse attribute) {
27.161 + // TODO: Improve i18n/l10n of caption - may have to use
27.162 + // a custom <appinfo> element in the XML Schema to do this.
27.163 + //
27.164 + return createCaption(attribute.getAttrDeclaration().getName());
27.165 + }
27.166 +
27.167 + /**
27.168 + * __UNDOCUMENTED__
27.169 + *
27.170 + * @param element __UNDOCUMENTED__
27.171 + * @return __UNDOCUMENTED__
27.172 + */
27.173 + public String createCaption(XSElementDeclaration element) {
27.174 + // TODO: Improve i18n/l10n of caption - may have to use
27.175 + // a custom <appinfo> element in the XML Schema to do this.
27.176 + //
27.177 + return createCaption(element.getName());
27.178 + }
27.179 +
27.180 + /**
27.181 + * __UNDOCUMENTED__
27.182 + *
27.183 + * @param element __UNDOCUMENTED__
27.184 + * @return __UNDOCUMENTED__
27.185 + */
27.186 + public String createCaption(XSObject element) {
27.187 + // TODO: Improve i18n/l10n of caption - may have to use
27.188 + // a custom <appinfo> element in the XML Schema to do this.
27.189 + //
27.190 + if (element instanceof XSElementDeclaration) {
27.191 + return createCaption(((XSElementDeclaration) element).getName());
27.192 + } else if (element instanceof XSAttributeDeclaration) {
27.193 + return createCaption(((XSAttributeDeclaration) element).getName());
27.194 + } else if (element instanceof XSAttributeUse) {
27.195 + return createCaption(((XSAttributeUse) element).getAttrDeclaration().getName());
27.196 + } else
27.197 +// LOGGER.warn("WARNING: createCaption: element is not an attribute nor an element: "
27.198 +// + element.getClass().getName());
27.199 +
27.200 + return null;
27.201 + }
27.202 +
27.203 + /**
27.204 + * __UNDOCUMENTED__
27.205 + *
27.206 + * @param xForm __UNDOCUMENTED__
27.207 + * @param caption __UNDOCUMENTED__
27.208 + * @param controlType __UNDOCUMENTED__
27.209 + * @return __UNDOCUMENTED__
27.210 + */
27.211 + public Element createControlForAnyType(Document xForm,
27.212 + String caption,
27.213 + XSTypeDefinition controlType) {
27.214 + Element control =
27.215 + xForm.createElementNS(XFORMS_NS, getXFormsNSPrefix() + "textarea");
27.216 + this.setXFormsId(control);
27.217 + control.setAttributeNS(CHIBA_NS, getChibaNSPrefix() + "height", "3");
27.218 +
27.219 + //label
27.220 + Element captionElement =
27.221 + (Element) control.appendChild(xForm.createElementNS(XFORMS_NS,
27.222 + getXFormsNSPrefix() + "label"));
27.223 + this.setXFormsId(captionElement);
27.224 + captionElement.appendChild(xForm.createTextNode(caption));
27.225 +
27.226 + return control;
27.227 + }
27.228 +
27.229 + /**
27.230 + * __UNDOCUMENTED__
27.231 + *
27.232 + * @param xForm __UNDOCUMENTED__
27.233 + * @param caption __UNDOCUMENTED__
27.234 + * @param controlType __UNDOCUMENTED__
27.235 + * @return __UNDOCUMENTED__
27.236 + */
27.237 + public Element createControlForAtomicType(Document xForm,
27.238 + String caption,
27.239 + XSSimpleTypeDefinition controlType) {
27.240 + Element control;
27.241 +
27.242 + //remove while select1 do not work correctly in repeats
27.243 + if ((controlType.getName() != null)
27.244 + && controlType.getName().equals("boolean")) {
27.245 + control =
27.246 + xForm.createElementNS(XFORMS_NS,
27.247 + getXFormsNSPrefix() + "select1");
27.248 + control.setAttributeNS(XFORMS_NS,
27.249 + getXFormsNSPrefix() + "appearance",
27.250 + "full");
27.251 + this.setXFormsId(control);
27.252 +
27.253 + Element item_true =
27.254 + xForm.createElementNS(XFORMS_NS, getXFormsNSPrefix() + "item");
27.255 + this.setXFormsId(item_true);
27.256 + Element label_true =
27.257 + xForm.createElementNS(XFORMS_NS, getXFormsNSPrefix() + "label");
27.258 + this.setXFormsId(label_true);
27.259 + Text label_true_text = xForm.createTextNode("true");
27.260 + label_true.appendChild(label_true_text);
27.261 + item_true.appendChild(label_true);
27.262 +
27.263 + Element value_true =
27.264 + xForm.createElementNS(XFORMS_NS, getXFormsNSPrefix() + "value");
27.265 + this.setXFormsId(value_true);
27.266 + Text value_true_text = xForm.createTextNode("true");
27.267 + value_true.appendChild(value_true_text);
27.268 + item_true.appendChild(value_true);
27.269 + control.appendChild(item_true);
27.270 +
27.271 + Element item_false =
27.272 + xForm.createElementNS(XFORMS_NS, getXFormsNSPrefix() + "item");
27.273 + this.setXFormsId(item_false);
27.274 + Element label_false =
27.275 + xForm.createElementNS(XFORMS_NS, getXFormsNSPrefix() + "label");
27.276 + this.setXFormsId(label_false);
27.277 + Text label_false_text = xForm.createTextNode("false");
27.278 + label_false.appendChild(label_false_text);
27.279 + item_false.appendChild(label_false);
27.280 +
27.281 + Element value_false =
27.282 + xForm.createElementNS(XFORMS_NS, getXFormsNSPrefix() + "value");
27.283 + this.setXFormsId(value_false);
27.284 + Text value_false_text = xForm.createTextNode("false");
27.285 + value_false.appendChild(value_false_text);
27.286 + item_false.appendChild(value_false);
27.287 + control.appendChild(item_false);
27.288 + } else {
27.289 + String lowerCap = caption.toLowerCase();
27.290 + if (lowerCap.contains("description") || lowerCap.contains("comments")
27.291 + || lowerCap.contains("feedback")) {
27.292 + control = xForm.createElementNS(XFORMS_NS, getXFormsNSPrefix() + "textarea");
27.293 + } else {
27.294 + control = xForm.createElementNS(XFORMS_NS, getXFormsNSPrefix() + "input");
27.295 + this.setXFormsId(control);
27.296 + }
27.297 + }
27.298 +
27.299 + //label
27.300 + Element captionElement =
27.301 + (Element) control.appendChild(xForm.createElementNS(XFORMS_NS,
27.302 + getXFormsNSPrefix() + "label"));
27.303 + this.setXFormsId(captionElement);
27.304 + captionElement.appendChild(xForm.createTextNode(caption));
27.305 +
27.306 + return control;
27.307 + }
27.308 +
27.309 + /**
27.310 + * __UNDOCUMENTED__
27.311 + *
27.312 + * @param xForm __UNDOCUMENTED__
27.313 + * @param controlType __UNDOCUMENTED__
27.314 + * @param caption __UNDOCUMENTED__
27.315 + * @param bindElement __UNDOCUMENTED__
27.316 + * @return __UNDOCUMENTED__
27.317 + */
27.318 + public Element createControlForEnumerationType(Document xForm,
27.319 + XSSimpleTypeDefinition controlType,
27.320 + String caption,
27.321 + Element bindElement) {
27.322 + // TODO: Figure out an intelligent or user determined way to decide between
27.323 + // selectUI style (listbox, menu, combobox, radio) (radio and listbox best apply)
27.324 + // Possibly look for special appInfo section in the schema and if not present default to comboBox...
27.325 + //
27.326 + // For now, use radio if enumValues < DEFAULT_LONG_LIST_MAX_SIZE otherwise use combobox
27.327 + //
27.328 + StringList enumFacets = controlType.getLexicalEnumeration();
27.329 + int nbFacets = enumFacets.getLength();
27.330 + if (nbFacets > 0) {
27.331 + Vector enumValues = new Vector();
27.332 +
27.333 + Element control =
27.334 + xForm.createElementNS(XFORMS_NS,
27.335 + getXFormsNSPrefix() + "select1");
27.336 + this.setXFormsId(control);
27.337 +
27.338 + //label
27.339 + Element captionElement1 =
27.340 + (Element) control.appendChild(xForm.createElementNS(XFORMS_NS,
27.341 + getXFormsNSPrefix() + "label"));
27.342 + this.setXFormsId(captionElement1);
27.343 + captionElement1.appendChild(xForm.createTextNode(caption));
27.344 +
27.345 + Element choices =
27.346 + xForm.createElementNS(XFORMS_NS,
27.347 + getXFormsNSPrefix() + "choices");
27.348 + this.setXFormsId(choices);
27.349 +
27.350 + for (int i = 0; i < nbFacets; i++) {
27.351 + String facet = enumFacets.item(i);
27.352 + enumValues.add(facet);
27.353 + }
27.354 +
27.355 + if (nbFacets
27.356 + < Long.parseLong(getProperty(SELECTONE_LONG_LIST_SIZE_PROP))) {
27.357 + control.setAttributeNS(XFORMS_NS,
27.358 + getXFormsNSPrefix() + "appearance",
27.359 + getProperty(SELECTONE_UI_CONTROL_SHORT_PROP));
27.360 + } else {
27.361 + control.setAttributeNS(XFORMS_NS,
27.362 + getXFormsNSPrefix() + "appearance",
27.363 + getProperty(SELECTONE_UI_CONTROL_LONG_PROP));
27.364 +
27.365 + // add the "Please select..." instruction item for the combobox
27.366 + // and set the isValid attribute on the bind element to check for the "Please select..."
27.367 + // item to indicate that is not a valid value
27.368 + //
27.369 + {
27.370 + String pleaseSelect = "[Select1 " + caption + "]";
27.371 + Element item =
27.372 + xForm.createElementNS(XFORMS_NS,
27.373 + getXFormsNSPrefix() + "item");
27.374 + this.setXFormsId(item);
27.375 + choices.appendChild(item);
27.376 +
27.377 + Element captionElement =
27.378 + xForm.createElementNS(XFORMS_NS,
27.379 + getXFormsNSPrefix() + "label");
27.380 + this.setXFormsId(captionElement);
27.381 + item.appendChild(captionElement);
27.382 + captionElement.appendChild(xForm.createTextNode(pleaseSelect));
27.383 +
27.384 + Element value =
27.385 + xForm.createElementNS(XFORMS_NS,
27.386 + getXFormsNSPrefix() + "value");
27.387 + this.setXFormsId(value);
27.388 + item.appendChild(value);
27.389 + value.appendChild(xForm.createTextNode(pleaseSelect));
27.390 +
27.391 + // not(purchaseOrder/state = '[Choose State]')
27.392 + //String isValidExpr = "not(" + bindElement.getAttributeNS(XFORMS_NS,"nodeset") + " = '" + pleaseSelect + "')";
27.393 + // ->no, not(. = '[Choose State]')
27.394 + String isValidExpr = "not( . = '" + pleaseSelect + "')";
27.395 +
27.396 + //check if there was a constraint
27.397 + String constraint =
27.398 + bindElement.getAttributeNS(XFORMS_NS, "constraint");
27.399 +
27.400 + if ((constraint != null) && !constraint.equals("")) {
27.401 + constraint = constraint + " and " + isValidExpr;
27.402 + } else {
27.403 + constraint = isValidExpr;
27.404 + }
27.405 +
27.406 + bindElement.setAttributeNS(XFORMS_NS,
27.407 + getXFormsNSPrefix() + "constraint",
27.408 + constraint);
27.409 + }
27.410 + }
27.411 +
27.412 + control.appendChild(choices);
27.413 +
27.414 + addChoicesForSelectControl(xForm, choices, enumValues);
27.415 +
27.416 + return control;
27.417 + } else {
27.418 + return null;
27.419 + }
27.420 + }
27.421 +
27.422 + /**
27.423 + * __UNDOCUMENTED__
27.424 + *
27.425 + * @param xForm __UNDOCUMENTED__
27.426 + * @param listType __UNDOCUMENTED__
27.427 + * @param caption __UNDOCUMENTED__
27.428 + * @param bindElement __UNDOCUMENTED__
27.429 + * @return __UNDOCUMENTED__
27.430 + */
27.431 + public Element createControlForListType(Document xForm,
27.432 + XSSimpleTypeDefinition listType,
27.433 + String caption,
27.434 + Element bindElement) {
27.435 + XSSimpleTypeDefinition controlType = listType.getItemType();
27.436 +
27.437 + StringList enumFacets = controlType.getLexicalEnumeration();
27.438 + int nbFacets = enumFacets.getLength();
27.439 + if (nbFacets > 0) {
27.440 + Element control =
27.441 + xForm.createElementNS(XFORMS_NS,
27.442 + getXFormsNSPrefix() + "select");
27.443 + this.setXFormsId(control);
27.444 +
27.445 + //label
27.446 + Element captionElement =
27.447 + (Element) control.appendChild(xForm.createElementNS(XFORMS_NS,
27.448 + getXFormsNSPrefix() + "label"));
27.449 + this.setXFormsId(captionElement);
27.450 + captionElement.appendChild(xForm.createTextNode(caption));
27.451 +
27.452 + Vector enumValues = new Vector();
27.453 + for (int i = 0; i < nbFacets; i++) {
27.454 + String facet = enumFacets.item(i);
27.455 + enumValues.add(facet);
27.456 + }
27.457 +
27.458 + // TODO: Figure out an intelligent or user determined way to decide between
27.459 + // selectUI style (listbox, menu, combobox, radio) (radio and listbox best apply)
27.460 + // Possibly look for special appInfo section in the schema and if not present default to checkBox...
27.461 + //
27.462 + // For now, use checkbox if there are < DEFAULT_LONG_LIST_MAX_SIZE items, otherwise use long control
27.463 + //
27.464 + if (enumValues.size()
27.465 + < Long.parseLong(getProperty(SELECTMANY_LONG_LIST_SIZE_PROP))) {
27.466 + control.setAttributeNS(XFORMS_NS,
27.467 + getXFormsNSPrefix() + "appearance",
27.468 + getProperty(SELECTMANY_UI_CONTROL_SHORT_PROP));
27.469 + } else {
27.470 + control.setAttributeNS(XFORMS_NS,
27.471 + getXFormsNSPrefix() + "appearance",
27.472 + getProperty(SELECTMANY_UI_CONTROL_LONG_PROP));
27.473 + }
27.474 +
27.475 + Element choices =
27.476 + xForm.createElementNS(XFORMS_NS,
27.477 + getXFormsNSPrefix() + "choices");
27.478 + this.setXFormsId(choices);
27.479 + control.appendChild(choices);
27.480 +
27.481 + addChoicesForSelectControl(xForm, choices, enumValues);
27.482 +
27.483 + return control;
27.484 + } else {
27.485 + return null;
27.486 + }
27.487 + }
27.488 +
27.489 + /**
27.490 + * __UNDOCUMENTED__
27.491 + *
27.492 + * @param xForm __UNDOCUMENTED__
27.493 + * @param node __UNDOCUMENTED__
27.494 + * @return __UNDOCUMENTED__
27.495 + */
27.496 + public Element createHint(Document xForm, XSObject node) {
27.497 + XSAnnotation annotation = null;
27.498 + if (node instanceof XSElementDeclaration)
27.499 + annotation = ((XSElementDeclaration) node).getAnnotation();
27.500 + else if (node instanceof XSAttributeDeclaration)
27.501 + annotation = ((XSAttributeDeclaration) node).getAnnotation();
27.502 + else if (node instanceof XSAttributeUse)
27.503 + annotation =
27.504 + ((XSAttributeUse) node).getAttrDeclaration().getAnnotation();
27.505 +
27.506 + if (annotation != null)
27.507 + return addHintFromDocumentation(xForm, annotation);
27.508 + else
27.509 + return null;
27.510 + }
27.511 +
27.512 + /**
27.513 + * __UNDOCUMENTED__
27.514 + *
27.515 + * @param bindElement __UNDOCUMENTED__
27.516 + */
27.517 + public void endBindElement(Element bindElement) {
27.518 + return;
27.519 + }
27.520 +
27.521 + /**
27.522 + * __UNDOCUMENTED__
27.523 + *
27.524 + * @param controlElement __UNDOCUMENTED__
27.525 + * @param controlType __UNDOCUMENTED__
27.526 + */
27.527 + public void endFormControl(Element controlElement,
27.528 + XSTypeDefinition controlType,
27.529 + int minOccurs,
27.530 + int maxOccurs) {
27.531 + return;
27.532 + }
27.533 +
27.534 + /**
27.535 + * __UNDOCUMENTED__
27.536 + *
27.537 + * @param groupElement __UNDOCUMENTED__
27.538 + */
27.539 + public void endFormGroup(Element groupElement,
27.540 + XSTypeDefinition controlType,
27.541 + int minOccurs,
27.542 + int maxOccurs,
27.543 + Element modelSection) {
27.544 + return;
27.545 + }
27.546 +
27.547 + /**
27.548 + * __UNDOCUMENTED__
27.549 + *
27.550 + * @param bindElement __UNDOCUMENTED__
27.551 + * @param controlType __UNDOCUMENTED__
27.552 + * @param minOccurs __UNDOCUMENTED__
27.553 + * @param maxOccurs __UNDOCUMENTED__
27.554 + * @return __UNDOCUMENTED__
27.555 + */
27.556 + public Element startBindElement(Element bindElement,
27.557 + XSTypeDefinition controlType,
27.558 + int minOccurs,
27.559 + int maxOccurs) {
27.560 + // START WORKAROUND
27.561 + // Due to a Chiba bug, anyType is not a recognized type name.
27.562 + // so, if this is an anyType, then we'll just skip the type
27.563 + // setting.
27.564 + //
27.565 + // type.getName() may be 'null' for anonymous types, so compare against
27.566 + // static string (see bug #1172541 on sf.net)
27.567 + if (!("anyType").equals(controlType.getName())) {
27.568 + Element enveloppe = bindElement.getOwnerDocument().getDocumentElement();
27.569 + String typeName = this.getXFormsTypeName(enveloppe, controlType);
27.570 + if (typeName != null && !typeName.equals(""))
27.571 + bindElement.setAttributeNS(XFORMS_NS,
27.572 + getXFormsNSPrefix() + "type",
27.573 + typeName);
27.574 + }
27.575 +
27.576 + if (minOccurs == 0) {
27.577 + bindElement.setAttributeNS(XFORMS_NS,
27.578 + getXFormsNSPrefix() + "required",
27.579 + "false()");
27.580 + } else {
27.581 + bindElement.setAttributeNS(XFORMS_NS,
27.582 + getXFormsNSPrefix() + "required",
27.583 + "true()");
27.584 + }
27.585 +
27.586 + //no more minOccurs & maxOccurs element: add a constraint if maxOccurs>1:
27.587 + //count(.) <= maxOccurs && count(.) >= minOccurs
27.588 + String minConstraint = null;
27.589 + String maxConstraint = null;
27.590 +
27.591 + if (minOccurs > 1) {
27.592 + //if 0 or 1 -> no constraint (managed by "required")
27.593 + minConstraint = "count(.) >= " + minOccurs;
27.594 + }
27.595 +
27.596 + if (maxOccurs > 1) {
27.597 + //if 1 or unbounded -> no constraint
27.598 + maxConstraint = "count(.) <= " + maxOccurs;
27.599 + }
27.600 +
27.601 + String constraint = null;
27.602 +
27.603 + if ((minConstraint != null) && (maxConstraint != null)) {
27.604 + constraint = minConstraint + " and " + maxConstraint;
27.605 + } else if (minConstraint != null) {
27.606 + constraint = minConstraint;
27.607 + } else {
27.608 + constraint = maxConstraint;
27.609 + }
27.610 +
27.611 + if ((constraint != null) && !constraint.equals("")) {
27.612 + bindElement.setAttributeNS(XFORMS_NS,
27.613 + getXFormsNSPrefix() + "constraint",
27.614 + constraint);
27.615 + }
27.616 +
27.617 + /*if (minOccurs != 1) {
27.618 + bindElement.setAttributeNS(XFORMS_NS,getXFormsNSPrefix() + "minOccurs",String.valueOf(minOccurs));
27.619 + }
27.620 + if (maxOccurs != 1) {
27.621 + bindElement.setAttributeNS(XFORMS_NS,getXFormsNSPrefix() + "maxOccurs",maxOccurs == -1 ? "unbounded" : String.valueOf((maxOccurs)));
27.622 + }*/
27.623 + return bindElement;
27.624 + }
27.625 +
27.626 + /**
27.627 + * __UNDOCUMENTED__
27.628 + *
27.629 + * @param controlElement __UNDOCUMENTED__
27.630 + * @param controlType __UNDOCUMENTED__
27.631 + * @return __UNDOCUMENTED__
27.632 + */
27.633 + public Element startFormControl(Element controlElement,
27.634 + XSTypeDefinition controlType) {
27.635 + return controlElement;
27.636 + }
27.637 +
27.638 + /**
27.639 + * __UNDOCUMENTED__
27.640 + *
27.641 + * @param groupElement __UNDOCUMENTED__
27.642 + * @param schemaElement __UNDOCUMENTED__
27.643 + * @return __UNDOCUMENTED__
27.644 + */
27.645 + public Element startFormGroup(Element groupElement,
27.646 + XSElementDeclaration schemaElement) {
27.647 + //groupElement.setAttributeNS(CHIBA_NS,getChibaNSPrefix() + "box-align",getProperty(GROUP_BOX_ALIGN_PROP));
27.648 + //groupElement.setAttributeNS(CHIBA_NS,getChibaNSPrefix() + "box-orient",getProperty(GROUP_BOX_ORIENT_PROP));
27.649 + //groupElement.setAttributeNS(CHIBA_NS,getChibaNSPrefix() + "caption-width",getProperty(GROUP_CAPTION_WIDTH_PROP));
27.650 + //groupElement.setAttributeNS(CHIBA_NS,getChibaNSPrefix() + "width",getProperty(GROUP_WIDTH_PROP));
27.651 + //groupElement.setAttributeNS(CHIBA_NS,getChibaNSPrefix() + "border",getProperty(GROUP_BORDER_PROP));
27.652 + return groupElement;
27.653 + }
27.654 +}
28.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
28.2 +++ b/enterprise/openesbaddons/workflow/project/antsrc/org/netbeans/modules/workflow/project/anttasks/Bundle.properties Thu Apr 26 02:33:27 2007 +0000
28.3 @@ -0,0 +1,16 @@
28.4 +#
28.5 +# Sun Public License Notice
28.6 +#
28.7 +# The contents of this file are subject to the Sun Public License
28.8 +# Version 1.0 (the "License"). You may not use this file except in
28.9 +# compliance with the License. A copy of the License is available at
28.10 +# http://www.sun.com/
28.11 +#
28.12 +# The Original Code is NetBeans. The Initial Developer of the Original
28.13 +# Code is Sun Microsystems, Inc. Portions Copyright 1997-2004 Sun
28.14 +# Microsystems, Inc. All Rights Reserved.
28.15 +#
28.16 +
28.17 +#Exception
28.18 +EX_FILE_NOT_FOUND=File is not found {0}
28.19 +EX_IOException=IO exception happened {0}
29.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
29.2 +++ b/enterprise/openesbaddons/workflow/project/antsrc/org/netbeans/modules/workflow/project/anttasks/CommandlineGenerateWSDLTask.java Thu Apr 26 02:33:27 2007 +0000
29.3 @@ -0,0 +1,112 @@
29.4 +/*
29.5 + * The contents of this file are subject to the terms of the Common Development
29.6 + * and Distribution License (the License). You may not use this file except in
29.7 + * compliance with the License.
29.8 + *
29.9 + * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
29.10 + * or http://www.netbeans.org/cddl.txt.
29.11 +
29.12 + * When distributing Covered Code, include this CDDL Header Notice in each file
29.13 + * and include the License file at http://www.netbeans.org/cddl.txt.
29.14 + * If applicable, add the following below the CDDL Header, with the fields
29.15 + * enclosed by brackets [] replaced by your own identifying information:
29.16 + * "Portions Copyrighted [year] [name of copyright owner]"
29.17 + *
29.18 + * The Original Software is NetBeans. The Initial Developer of the Original
29.19 + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
29.20 + * Microsystems, Inc. All Rights Reserved.
29.21 + */
29.22 +package org.netbeans.modules.workflow.project.anttasks;
29.23 +
29.24 +import java.io.File;
29.25 +import java.util.logging.Logger;
29.26 +
29.27 +import org.apache.tools.ant.BuildException;
29.28 +import org.apache.tools.ant.Task;
29.29 +
29.30 +/**
29.31 + * Generates client WSDL
29.32 + * @author Sreenivasan Genipudi
29.33 + */
29.34 +public class CommandlineGenerateWSDLTask extends Task {
29.35 + //Member variable representing source directory
29.36 + /**
29.37 + * Project name
29.38 + */
29.39 + private String mProjectname = null;
29.40 + //Member variable representing source dir
29.41 + private File mSourceDir;
29.42 + //Member variable representing build dir
29.43 + private File mBuildDir;
29.44 + //Member variable representing Client WSDL file.
29.45 + private File mClientWSDLFile;
29.46 + /**
29.47 + * Logger instance
29.48 + */
29.49 + private Logger logger = Logger.getLogger(CommandlineGenerateWSDLTask.class.getName());
29.50 +
29.51 + /**
29.52 + * Constructor
29.53 + */
29.54 + public CommandlineGenerateWSDLTask() {
29.55 + }
29.56 +
29.57 +
29.58 + /**
29.59 + * Set the source directory
29.60 + * @param srcDir Source directory
29.61 + */
29.62 + public void setSourceDirectory(String srcDir) {
29.63 + this.mSourceDir = new File(srcDir);
29.64 + }
29.65 +
29.66 + /**
29.67 + * Set the build directory
29.68 + * @param buildDir build directory
29.69 + */
29.70 + public void setBuildDirectory(String buildDir) {
29.71 + this.mBuildDir = new File(buildDir);
29.72 + }
29.73 +
29.74 + /**
29.75 + * Set the project name
29.76 + * @param String project name
29.77 + */
29.78 + public void setProjectName(String projectName) {
29.79 + this.mProjectname = projectName;
29.80 + }
29.81 +
29.82 + public void setClientWSDL(String clientWSDL) {
29.83 + this.mClientWSDLFile = new File(clientWSDL);
29.84 + }
29.85 +
29.86 + /**
29.87 +
29.88 + /**
29.89 + * Generate client WSDL
29.90 + */
29.91 + public void execute() throws BuildException {
29.92 +
29.93 + if(this.mSourceDir == null) {
29.94 + throw new BuildException("No directory is set for source files.");
29.95 + }
29.96 +
29.97 + if(this.mBuildDir == null) {
29.98 + throw new BuildException("No build directory is set.");
29.99 + }
29.100 +
29.101 + if(this.mProjectname== null) {
29.102 + throw new BuildException("No Project Name is set.");
29.103 + }
29.104 +
29.105 + if (this.mClientWSDLFile == null) {
29.106 + throw new BuildException("No Client WSDL File is set.");
29.107 + }
29.108 +
29.109 + WSDLGenerator wsdlGen = new WSDLGenerator();
29.110 + wsdlGen.setCommandlineMode(true);
29.111 + wsdlGen.generate(this.mProjectname,this.mSourceDir,this.mBuildDir,this.mClientWSDLFile);
29.112 +
29.113 + }
29.114 +
29.115 +}
30.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
30.2 +++ b/enterprise/openesbaddons/workflow/project/antsrc/org/netbeans/modules/workflow/project/anttasks/CommandlineGenerateWSDLTaskWrapper.java Thu Apr 26 02:33:27 2007 +0000
30.3 @@ -0,0 +1,221 @@
30.4 +/*
30.5 + * The contents of this file are subject to the terms of the Common Development
30.6 + * and Distribution License (the License). You may not use this file except in
30.7 + * compliance with the License.
30.8 + *
30.9 + * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
30.10 + * or http://www.netbeans.org/cddl.txt.
30.11 +
30.12 + * When distributing Covered Code, include this CDDL Header Notice in each file
30.13 + * and include the License file at http://www.netbeans.org/cddl.txt.
30.14 + * If applicable, add the following below the CDDL Header, with the fields
30.15 + * enclosed by brackets [] replaced by your own identifying information:
30.16 + * "Portions Copyrighted [year] [name of copyright owner]"
30.17 + *
30.18 + * The Original Software is NetBeans. The Initial Developer of the Original
30.19 + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
30.20 + * Microsystems, Inc. All Rights Reserved.
30.21 + */
30.22 +package org.netbeans.modules.workflow.project.anttasks;
30.23 +
30.24 +import java.lang.reflect.Method;
30.25 +import java.util.logging.Level;
30.26 +import java.util.logging.Logger;
30.27 +
30.28 +import org.apache.tools.ant.AntClassLoader;
30.29 +import org.apache.tools.ant.BuildException;
30.30 +import org.apache.tools.ant.types.Path;
30.31 +import org.apache.tools.ant.types.Reference;
30.32 +
30.33 +
30.34 +/**
30.35 + * Ant task wrapper which invokes the JBI Generation task
30.36 + * @author Sreenivasan Genipudi
30.37 + */
30.38 +public class CommandlineGenerateWSDLTaskWrapper extends org.apache.tools.ant.Task{
30.39 + // Member variable representing source directory
30.40 + /**
30.41 + * Source directory
30.42 + */
30.43 + private String mSourceDirectory = null;
30.44 + // Member variable representing build directory
30.45 + /**
30.46 + * Build directory
30.47 + */
30.48 + private String mBuildDirectory = null;
30.49 + // Member variable representing project classpath
30.50 + /**
30.51 + * Project classpath
30.52 + */
30.53 + private String mProjectClassPath= null;
30.54 + /**
30.55 + * Custom classloader used to invoke the JBI Generation task
30.56 + */
30.57 + private AntClassLoader m_myClassLoader = null;
30.58 + /**
30.59 + * Classpath Reference
30.60 + */
30.61 + private Reference m_ref = null;
30.62 + private Reference m_wkFlowRef = null;
30.63 + private String mClientWSDL;
30.64 + private String mProjectname = null;
30.65 + /**
30.66 + * Logger instance
30.67 + */
30.68 + private Logger logger = Logger.getLogger(CommandlineGenerateWSDLTaskWrapper.class.getName());
30.69 + /**
30.70 + * Constructor
30.71 + */
30.72 + public CommandlineGenerateWSDLTaskWrapper() {
30.73 + }
30.74 +
30.75 + /**
30.76 + * Set the classpath reference
30.77 + * @param ref Classpath Reference
30.78 + */
30.79 + public void setClasspathRef(Reference ref) {
30.80 + this.m_ref = ref;
30.81 + }
30.82 +
30.83 + public void setTaskFlowClasspath(Reference ref) {
30.84 + this.m_wkFlowRef = ref;
30.85 + }
30.86 + /**
30.87 + * Set the classpath reference
30.88 + * @param ref Classpath Reference
30.89 + */
30.90 + public void setClientWSDL(String clientWSDL) {
30.91 + this.mClientWSDL = clientWSDL;
30.92 + }
30.93 +
30.94 + /**
30.95 + * Set the build directory
30.96 + * @param buildDir build directory
30.97 + */
30.98 + public void setBuildDirectory(String buildDir) {
30.99 + mBuildDirectory = buildDir;
30.100 + }
30.101 + /**
30.102 + * Set the source directory
30.103 + * @param srcDir source directory
30.104 + */
30.105 + public void setSourceDirectory(String srcDir) {
30.106 + this.mSourceDirectory = srcDir;
30.107 + }
30.108 +
30.109 + /**
30.110 + * Set the source directory
30.111 + * @param srcDir source directory
30.112 + */
30.113 + public void setProjectName(String prjName) {
30.114 + this.mProjectname = prjName;
30.115 + }
30.116 +
30.117 + /**
30.118 + * Get the source directory
30.119 + * @return String value of the source directory
30.120 + */
30.121 + public String getSourceDirectory() {
30.122 + return this.mSourceDirectory;
30.123 + }
30.124 +
30.125 + /**
30.126 + * Set the project classpath
30.127 + * @param projectClassPath Project classpath
30.128 + */
30.129 + public void setProjectClassPath(String projectClassPath) {
30.130 + this.mProjectClassPath = projectClassPath;
30.131 + }
30.132 +
30.133 +
30.134 + /**
30.135 + * Invoke the task that generates the JBI.xml
30.136 + */
30.137 + public void execute() throws BuildException {
30.138 + try {
30.139 + m_myClassLoader = new AntClassLoader();
30.140 + initClassLoader();
30.141 + Class antTaskClass = Class.forName("org.netbeans.modules.workflow.project.anttasks.CommandlineGenerateWSDLTask", true,m_myClassLoader );
30.142 + Thread.currentThread().setContextClassLoader(m_myClassLoader);
30.143 + Object genJBIInstObj = antTaskClass.newInstance();
30.144 +
30.145 + Method driver = antTaskClass.getMethod("setBuildDirectory",
30.146 + new Class[] { java.lang.String.class });
30.147 + Object[] param = new Object[] {
30.148 + this.mBuildDirectory
30.149 + };
30.150 + driver.invoke(genJBIInstObj,
30.151 + param);
30.152 +
30.153 + driver = antTaskClass.getMethod("setSourceDirectory",
30.154 + new Class[] { java.lang.String.class });
30.155 + param = new Object[] {
30.156 + this.mSourceDirectory
30.157 + };
30.158 + driver.invoke(genJBIInstObj,
30.159 + param);
30.160 +/*
30.161 + driver = antTaskClass.getMethod("setProjectClassPath",
30.162 + new Class[] { java.lang.String.class });
30.163 + param = new Object[] {
30.164 + this.mProjectClassPath
30.165 + };
30.166 + driver.invoke(genJBIInstObj,
30.167 + param);
30.168 +*/
30.169 +
30.170 + driver = antTaskClass.getMethod("setProjectName",
30.171 + new Class[] { java.lang.String.class });
30.172 + param = new Object[] {
30.173 + this.mProjectname
30.174 + };
30.175 + driver.invoke(genJBIInstObj,
30.176 + param);
30.177 +
30.178 +
30.179 + driver = antTaskClass.getMethod("setClientWSDL",
30.180 + new Class[] { java.lang.String.class });
30.181 + param = new Object[] {
30.182 + this.mClientWSDL
30.183 + };
30.184 + driver.invoke(genJBIInstObj,
30.185 + param);
30.186 +
30.187 + driver = antTaskClass.getMethod("execute",
30.188 + null);
30.189 + driver.invoke(genJBIInstObj, null);
30.190 +
30.191 + }catch (Exception ex) {
30.192 + logger.log(Level.FINE, "Compilation Errors found", ex);
30.193 + throw new BuildException("Compilation Errors found");
30.194 + }
30.195 + }
30.196 +
30.197 + /**
30.198 + * Set the custom classloader and make the parent first reference
30.199 + * by the classloader to False
30.200 + */
30.201 + private void initClassLoader() {
30.202 + Path path = new Path(getProject());
30.203 + path.setRefid(m_ref);
30.204 + AntClassLoader basCl = new AntClassLoader();
30.205 +
30.206 + Path parentPath = new Path(getProject());
30.207 + ClassLoader cl = this.getClass().getClassLoader();
30.208 + if (cl instanceof AntClassLoader) {
30.209 + parentPath.setPath(((AntClassLoader)cl).getClasspath());
30.210 + ((AntClassLoader)cl).setParent(null);
30.211 + parentPath.add(path);
30.212 + path = parentPath;
30.213 + }
30.214 + basCl.setClassPath(path);
30.215 + basCl.setParent(null);
30.216 + basCl.setParentFirst(false);
30.217 +
30.218 + path = new Path(getProject());
30.219 + path.setRefid(this.m_wkFlowRef);
30.220 + this.m_myClassLoader.setClassPath(path);
30.221 + m_myClassLoader.setParent(basCl);
30.222 + //m_myClassLoader.setParentFirst(false);
30.223 + }
30.224 +}
31.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
31.2 +++ b/enterprise/openesbaddons/workflow/project/antsrc/org/netbeans/modules/workflow/project/anttasks/GenerateAsaArtifacts.java Thu Apr 26 02:33:27 2007 +0000
31.3 @@ -0,0 +1,424 @@
31.4 +/* *************************************************************************
31.5 + *
31.6 + * Copyright (c) 2002, SeeBeyond Technology Corporation,
31.7 + * All Rights Reserved
31.8 + *
31.9 + * This program, and all the routines referenced herein,
31.10 + * are the proprietary properties and trade secrets of
31.11 + * SEEBEYOND TECHNOLOGY CORPORATION.
31.12 + *
31.13 + * Except as provided for by license agreement, this
31.14 + * program shall not be duplicated, used, or disclosed
31.15 + * without written consent signed by an officer of
31.16 + * SEEBEYOND TECHNOLOGY CORPORATION.
31.17 + *
31.18 + ***************************************************************************/
31.19 +package org.netbeans.modules.workflow.project.anttasks;
31.20 +
31.21 +import java.io.File;
31.22 +import java.io.FileInputStream;
31.23 +import java.io.FileNotFoundException;
31.24 +import java.io.FileOutputStream;
31.25 +import java.io.FilenameFilter;
31.26 +import java.io.IOException;
31.27 +import java.io.InputStream;
31.28 +import java.net.MalformedURLException;
31.29 +import java.net.URL;
31.30 +import java.util.ArrayList;
31.31 +import java.util.HashMap;
31.32 +import java.util.List;
31.33 +import java.util.Map;
31.34 +import java.util.Properties;
31.35 +
31.36 +import javax.wsdl.PortType;
31.37 +import javax.xml.namespace.QName;
31.38 +
31.39 +import org.apache.tools.ant.BuildException;
31.40 +import org.apache.tools.ant.Task;
31.41 +import org.openide.util.NbBundle;
31.42 +
31.43 +import com.sun.jbi.workflow.model.ModelFactory;
31.44 +import com.sun.jbi.workflow.model.Tasks;
31.45 +import com.sun.jbi.workflow.model.xmlbeans.TaskType;
31.46 +
31.47 +/**
31.48 + *
31.49 + * @author SUN Microsystems
31.50 + */
31.51 +public class GenerateAsaArtifacts extends Task {
31.52 +
31.53 + private static final String PROP_FILE = "resources/jbi_gen.properties";
31.54 +
31.55 + private static final String WF_SUFFIX = "WF_SUFFIX";
31.56 +
31.57 + private static final String TASK_SERVICE_NAME = "Task_ServiceName";
31.58 +
31.59 + private static final String TASK_COMMON_END_POINT = "TaskCommon_EndPoint";
31.60 +
31.61 + private static final String TASK_COMMON_WSDL_URI = "TaskCommon_WSDL_URI";
31.62 +
31.63 + private static final String TASK_COMMON_INTERFACE = "TaskCommon_Interface";
31.64 +
31.65 + private static final String WFSE_WSDL_URI_PREFIX = "WFSE_WSDL_URI_Prefix";
31.66 +
31.67 + private static final String WFSE_WSDL_URI_CLIENT_SUFFIX = "WFSE_WSDL_URI_Client_Suffix";
31.68 +
31.69 + private static final String TASK_CLIENT_END_POINT_PREFIX = "TaskClient_EndPoint_Prefix";
31.70 +
31.71 + private static final String TASK_CLIENT_END_POINT_SUFFIX = "TaskClient_EndPoint_Suffix";
31.72 +
31.73 + private static final String TASK_CLIENT_INTERFACE_SUFFIX = "TaskClient_Interface_Suffix";
31.74 +
31.75 + private static class Provide {
31.76 + private String interfaceName;
31.77 +
31.78 + private String serviceName;
31.79 +
31.80 + private String endPointName;
31.81 + }
31.82 +
31.83 + private String mSrcDirectoryLocation;
31.84 +
31.85 + private String mJbiDescriptorFileLocation;
31.86 +
31.87 + private String mProjectName;
31.88 +
31.89 + private Properties mProps;
31.90 +
31.91 + /** Creates a new instance of GenerateIEPASAArtifacts */
31.92 + public GenerateAsaArtifacts() {
31.93 + loadProps();
31.94 + }
31.95 +
31.96 + private void loadProps() {
31.97 + mProps = new Properties();
31.98 + URL propUrl = getClass().getResource(PROP_FILE);
31.99 + InputStream inputStream = null;
31.100 + try {
31.101 + inputStream = getClass().getResourceAsStream(PROP_FILE);
31.102 + mProps.load(inputStream);
31.103 + } catch (FileNotFoundException e) {
31.104 + // TODO Auto-generated catch block
31.105 + throw new RuntimeException(NbBundle.getMessage(GenerateAsaArtifacts.class,
31.106 + "EX_FILE_NOT_FOUND", propUrl.toString()), e);
31.107 + } catch (IOException e) {
31.108 + // TODO Auto-generated catch block
31.109 + throw new RuntimeException(NbBundle.getMessage(GenerateAsaArtifacts.class,
31.110 + "EX_IOException", propUrl.toString()), e);
31.111 + } finally {
31.112 + if (inputStream != null) {
31.113 + try {
31.114 + inputStream.close();
31.115 + } catch (IOException e) {
31.116 + // TODO Auto-generated catch block
31.117 + e.printStackTrace();
31.118 + }
31.119 + }
31.120 + }
31.121 +
31.122 + }
31.123 +
31.124 + /**
31.125 + * @return Returns the srcDirectoryLocation.
31.126 + */
31.127 + public String getSrcDirectoryLocation() {
31.128 + return mSrcDirectoryLocation;
31.129 + }
31.130 +
31.131 + /**
31.132 + * @param workflowMapFileLocation
31.133 + * The workflowMapFileLocation to set.
31.134 + */
31.135 + public void setSrcDirectoryLocation(String workflowMapFileLocation) {
31.136 + mSrcDirectoryLocation = workflowMapFileLocation;
31.137 + }
31.138 +
31.139 + /**
31.140 + * @return Returns the portMapFileLocation.
31.141 + */
31.142 + public String getJbiDescriptorFileLocation() {
31.143 + return mJbiDescriptorFileLocation;
31.144 + }
31.145 +
31.146 + /**
31.147 + * @param portMapFileLocation
31.148 + * The portMapFileLocation to set.
31.149 + */
31.150 + public void setJbiDescriptorFileLocation(String jbiDescriptorFileLocation) {
31.151 + mJbiDescriptorFileLocation = jbiDescriptorFileLocation;
31.152 + }
31.153 +
31.154 + public String getProjectName() {
31.155 + return mProjectName;
31.156 + }
31.157 +
31.158 + public void setProjectName(String projectName) {
31.159 + mProjectName = projectName;
31.160 + }
31.161 +
31.162 + public void execute() throws BuildException {
31.163 + final String wfSuffix = mProps.getProperty(WF_SUFFIX);
31.164 + File srcFolder = new File(mSrcDirectoryLocation);
31.165 + if (!srcFolder.exists()) {
31.166 + throw new BuildException("Folder " + mSrcDirectoryLocation + " does not exit.");
31.167 + }
31.168 + // Find all .wf file
31.169 + String[] allwfs = srcFolder.list(new FilenameFilter() {
31.170 + public boolean accept(File dir, String name) {
31.171 + // TODO Auto-generated method stub
31.172 + if (name.endsWith(wfSuffix)) {
31.173 + return true;
31.174 + }
31.175 + return false;
31.176 + }
31.177 + });
31.178 +
31.179 + Map prefixTable = new HashMap(); // keyed by prefix
31.180 + Map nsTable = new HashMap(); // keyed by name space
31.181 + List provides = new ArrayList();
31.182 +
31.183 + if (allwfs != null && allwfs.length > 0) {
31.184 + int nsIndex = 0;
31.185 + try {
31.186 + for (int i = 0; i < allwfs.length; i++) {
31.187 + String wfFileName = new File(srcFolder, allwfs[i]).getAbsolutePath();
31.188 + Tasks tasks = ModelFactory.getInstance().getTasksModel(wfFileName);
31.189 + com.sun.jbi.workflow.model.Task task = (com.sun.jbi.workflow.model.Task) tasks
31.190 + .getTasks().get(0);
31.191 + String wfns = tasks.getTargetNamespace();
31.192 + String wfnsprefix = "ns" + nsIndex;
31.193 + nsIndex++;
31.194 + prefixTable.put(wfnsprefix, wfns);
31.195 + nsTable.put(wfns, wfnsprefix);
31.196 +
31.197 + Provide provide = new Provide();
31.198 + provides.add(provide);
31.199 +
31.200 + provide.serviceName = wfnsprefix + ":" + task.getPartnerLink();
31.201 + provide.endPointName = ((TaskType) task.getDelegate()).getRole();
31.202 +
31.203 + PortType portType = task.getPortType();
31.204 + String bpelwsdlns = portType.getQName().getNamespaceURI();
31.205 + String bpelwsdlnsprefix = "ns" + nsIndex;
31.206 + nsIndex++;
31.207 + prefixTable.put(bpelwsdlnsprefix, bpelwsdlns);
31.208 + nsTable.put(bpelwsdlns, bpelwsdlnsprefix);
31.209 +
31.210 + provide.interfaceName = bpelwsdlnsprefix + ":"
31.211 + + portType.getQName().getLocalPart();
31.212 + nsIndex = createClientAPIProvides(prefixTable, nsTable, provides, task
31.213 + .getName(), nsIndex);
31.214 + }
31.215 + FileOutputStream fos = null;
31.216 + try {
31.217 + // Generate jbi.xml
31.218 + // <?xml version='1.0'?>
31.219 + // <jbi version="1.0"
31.220 + // xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
31.221 + // xmlns="http://java.sun.com/xml/ns/jbi"
31.222 + // xsi:schemaLocation="http://java.sun.com/xml/ns/jbi jbi.xsd"
31.223 + // xmlns:ns0=${ns1} ... xmlns:nsN=${nsN} >
31.224 + // <services binding-component="false">
31.225 + // <provides interface-name=port-type service-name=partner-link
31.226 + // endpoint-name=role-name/>
31.227 + // <consumes interface-name=port-type service-name=partner-link
31.228 + // endpoint-name=role-name link-type="standard"/>
31.229 + // </services>
31.230 + // </jbi>
31.231 + StringBuffer sb = new StringBuffer();
31.232 + sb.append("<!--start of generated code -->\n");
31.233 + sb.append("<jbi version=\"1.0\"\n");
31.234 + sb.append(" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n");
31.235 + sb.append(" xmlns=\"http://java.sun.com/xml/ns/jbi\"\n");
31.236 + sb
31.237 + .append(" xsi:schemaLocation=\"http://java.sun.com/xml/ns/jbi jbi.xsd\"\n");
31.238 + for (int i = 0, I = nsTable.size(); i < I; i++) {
31.239 + String ns = "ns" + i;
31.240 + sb.append(" xmlns:" + ns + "=\"" + prefixTable.get(ns) + "\"");
31.241 + if (i < I - 1) {
31.242 + sb.append("\n");
31.243 + }
31.244 + }
31.245 + sb.append(">\n");
31.246 + sb.append(" <services binding-component=\"false\">\n");
31.247 + // Generate all <provides> first
31.248 + for (int i = 0, I = provides.size(); i < I; i++) {
31.249 + Provide provide = (Provide) provides.get(i);
31.250 + sb.append(" <provides interface-name=\"" + provide.interfaceName);
31.251 + sb.append("\" service-name=\"" + provide.serviceName);
31.252 + sb.append("\" endpoint-name=\"" + provide.endPointName);
31.253 + sb.append("\"/>\n");
31.254 +
31.255 + }
31.256 + sb.append(" </services>\n");
31.257 + sb.append(" </jbi>\n");
31.258 + sb.append("<!--end of generated code -->\n");
31.259 +
31.260 + String content = sb.toString();
31.261 + fos = new FileOutputStream(mJbiDescriptorFileLocation);
31.262 + IOUtil.copy(content.getBytes("UTF-8"), fos);
31.263 + } catch (Exception e) {
31.264 + throw e;
31.265 + } finally {
31.266 + if (fos != null) {
31.267 + try {
31.268 + fos.close();
31.269 + } catch (Exception e1) {
31.270 + e1.printStackTrace();
31.271 + }
31.272 + }
31.273 + }
31.274 +
31.275 + } catch (Exception e) {
31.276 + throw new BuildException(e.getMessage(), e);
31.277 + }
31.278 + }
31.279 +
31.280 + // FileOutputStream fos = null;
31.281 + // try {
31.282 + // List workflowEntryList = WorkflowMapReader.parse(workflowMapFile);
31.283 + //
31.284 + // // Populate prefixTable
31.285 + // int nsIndex = 1;
31.286 + // for (int i = 0, I = workflowEntryList.size(); i < I; i++) {
31.287 + // WorkflowMapEntry entry = (WorkflowMapEntry)workflowEntryList.get(i);
31.288 + // String ns = entry.getPartnerLink().getNamespaceURI();
31.289 + // if (ns != null && !ns.trim().equals("") && !nsTable.containsKey(ns)) {
31.290 + // nsTable.put(ns, "ns" + nsIndex);
31.291 + // prefixTable.put("ns" + nsIndex, ns);
31.292 + // nsIndex++;
31.293 + // }
31.294 + //
31.295 + // ns = entry.getPortType().getNamespaceURI();
31.296 + // if (ns != null && !ns.trim().equals("") && !nsTable.containsKey(ns)) {
31.297 + // nsTable.put(ns, "ns" + nsIndex);
31.298 + // prefixTable.put("ns" + nsIndex, ns);
31.299 + // nsIndex++;
31.300 + // }
31.301 + //
31.302 + // if (entry.getType() != WorkflowMapEntry.REQUEST_REPLY_SERVICE) {
31.303 + // ns = entry.getOutPartnerLink().getNamespaceURI();
31.304 + // if (ns != null && !ns.trim().equals("") && !nsTable.containsKey(ns)) {
31.305 + // nsTable.put(ns, "ns" + nsIndex);
31.306 + // prefixTable.put("ns" + nsIndex, ns);
31.307 + // nsIndex++;
31.308 + // }
31.309 + //
31.310 + // ns = entry.getOutPortType().getNamespaceURI();
31.311 + // if (ns != null && !ns.trim().equals("") && !nsTable.containsKey(ns)) {
31.312 + // nsTable.put(ns, "ns" + nsIndex);
31.313 + // prefixTable.put("ns" + nsIndex, ns);
31.314 + // nsIndex++;
31.315 + // }
31.316 + // }
31.317 + // }
31.318 + //
31.319 + //
31.320 +
31.321 + // try {
31.322 +
31.323 + // for (int i = 0, I = workflowEntryList.size(); i < I; i++) {
31.324 + // WorkflowMapEntry xme = (WorkflowMapEntry)workflowEntryList.get(i);
31.325 + // sb.append(" <provides interface-name=\"" + getDottedQName(xme.getPortType(), nsTable));
31.326 + // sb.append("\" service-name=\"" + getDottedQName(xme.getPartnerLink(), nsTable));
31.327 + // sb.append("\" endpoint-name=\"" + xme.getRoleName());
31.328 + // sb.append("\"/>\n");
31.329 + // }
31.330 + // // Generate all <consumes> second
31.331 + // for (int i = 0, I = workflowEntryList.size(); i < I; i++) {
31.332 + // WorkflowMapEntry xme = (WorkflowMapEntry)workflowEntryList.get(i);
31.333 + // if (!xme.getType().equals(WorkflowMapEntry.REQUEST_REPLY_SERVICE)) {
31.334 + // sb.append(" <consumes interface-name=\"" + getDottedQName(xme.getOutPortType(),
31.335 + // nsTable));
31.336 + // sb.append("\" service-name=\"" + getDottedQName(xme.getOutPartnerLink(), nsTable));
31.337 + // sb.append("\" endpoint-name=\"" + xme.getOutRoleName());
31.338 + // sb.append("\" link-type=\"standard\"/>\n");
31.339 + // }
31.340 + // }
31.341 +
31.342 + // } catch (Exception e) {
31.343 + // throw new BuildException(e.getMessage());
31.344 + // }
31.345 + }
31.346 +
31.347 + private int createClientAPIProvides(Map prefixTable, Map nsTable, List provides,
31.348 + String taskName, int nsIndex) {
31.349 +
31.350 + String clientwsdlns = mProps.getProperty(TASK_COMMON_WSDL_URI);
31.351 + String clientwsdlnsprefix = null;
31.352 + Provide provide = null;
31.353 + if ((clientwsdlnsprefix = (String)nsTable.get(clientwsdlns)) == null) {
31.354 + clientwsdlnsprefix = "ns" + nsIndex;
31.355 + nsIndex++;
31.356 + prefixTable.put(clientwsdlnsprefix, clientwsdlns);
31.357 + nsTable.put(clientwsdlns, clientwsdlnsprefix);
31.358 +
31.359 + provide = new Provide();
31.360 + provides.add(provide);
31.361 +
31.362 + provide.endPointName = mProps.getProperty(TASK_COMMON_END_POINT);
31.363 + provide.interfaceName = clientwsdlnsprefix + ":"
31.364 + + mProps.getProperty(TASK_COMMON_INTERFACE);
31.365 + provide.serviceName = clientwsdlnsprefix + ":" + mProps.getProperty(TASK_SERVICE_NAME);
31.366 + }
31.367 +
31.368 + String dynamicClientwsdlns = mProps.getProperty(WFSE_WSDL_URI_PREFIX) + "/" + mProjectName + mProps.getProperty(WFSE_WSDL_URI_CLIENT_SUFFIX);
31.369 + String dynamicClientwsdlnsprefix = null;
31.370 +
31.371 + if ((dynamicClientwsdlnsprefix = (String)nsTable.get(dynamicClientwsdlns)) == null) {
31.372 + dynamicClientwsdlnsprefix = "ns" + nsIndex;
31.373 + nsIndex++;
31.374 + prefixTable.put(dynamicClientwsdlnsprefix, dynamicClientwsdlns);
31.375 + nsTable.put(dynamicClientwsdlns, dynamicClientwsdlnsprefix);
31.376 +
31.377 + provide = new Provide();
31.378 + provides.add(provide);
31.379 + provide.endPointName = mProps.getProperty(TASK_CLIENT_END_POINT_PREFIX) + this.mProjectName
31.380 + + mProps.getProperty(TASK_CLIENT_END_POINT_SUFFIX);
31.381 + provide.interfaceName = dynamicClientwsdlnsprefix + ":" + taskName
31.382 + + mProps.getProperty(TASK_CLIENT_INTERFACE_SUFFIX);
31.383 + provide.serviceName = dynamicClientwsdlnsprefix + ":" + mProps.getProperty(TASK_SERVICE_NAME);
31.384 + }
31.385 +
31.386 + return nsIndex;
31.387 + // TODO Auto-generated method stub
31.388 +
31.389 + }
31.390 +
31.391 + private static String getDottedQName(QName qn, Map nsTable) {
31.392 + String ns = qn.getNamespaceURI();
31.393 + String prefix = (String) nsTable.get(ns);
31.394 + if (prefix == null) {
31.395 + return qn.getLocalPart();
31.396 + }
31.397 + return prefix + ":" + qn.getLocalPart();
31.398 + }
31.399 +
31.400 + public static void main(String[] args) throws MalformedURLException {
31.401 + GenerateAsaArtifacts tsk = new GenerateAsaArtifacts();
31.402 + tsk.setJbiDescriptorFileLocation("c:/work/test/jbi.xml");
31.403 + tsk
31.404 + .setSrcDirectoryLocation("c:/Alaska/root/sharedlibrary/workflowmodel/test/data/samples/approvePurchase");
31.405 + tsk.execute();
31.406 +
31.407 + // String urlStr =
31.408 + // "jar:file:/D:/darkhorse/nbbuild/netbeans/BusinessIntegration/modules/ext/workflowpro/anttask.jar!/com/sun/jbi/ui/devtool/projects/workflowpro/anttasks/jbi_gen.properties";
31.409 + // String urlStr =
31.410 + // "jar:file:/C:/work/test/anttask.jar!/com/sun/jbi/ui/devtool/projects/workflowpro/anttasks/jbi_gen.properties";
31.411 + // String urlStr = "file:/C:/work/test/anttask.jar";
31.412 + //
31.413 + //
31.414 + // URL url = new URL (urlStr);
31.415 + // String file = url.getFile();
31.416 + // System.out.println(new File (file).exists());
31.417 +
31.418 + // try {
31.419 + // FileInputStream fileInputStream = new FileInputStream(url.getFile());
31.420 + // } catch (FileNotFoundException e) {
31.421 + // // TODO Auto-generated catch block
31.422 + // e.printStackTrace();
31.423 + // }
31.424 +
31.425 + }
31.426 +
31.427 +}
32.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
32.2 +++ b/enterprise/openesbaddons/workflow/project/antsrc/org/netbeans/modules/workflow/project/anttasks/IDEGenerateWSDLTask.java Thu Apr 26 02:33:27 2007 +0000
32.3 @@ -0,0 +1,117 @@
32.4 +/*
32.5 + * The contents of this file are subject to the terms of the Common Development
32.6 + * and Distribution License (the License). You may not use this file except in
32.7 + * compliance with the License.
32.8 + *
32.9 + * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
32.10 + * or http://www.netbeans.org/cddl.txt.
32.11 +
32.12 + * When distributing Covered Code, include this CDDL Header Notice in each file
32.13 + * and include the License file at http://www.netbeans.org/cddl.txt.
32.14 + * If applicable, add the following below the CDDL Header, with the fields
32.15 + * enclosed by brackets [] replaced by your own identifying information:
32.16 + * "Portions Copyrighted [year] [name of copyright owner]"
32.17 + *
32.18 + * The Original Software is NetBeans. The Initial Developer of the Original
32.19 + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
32.20 + * Microsystems, Inc. All Rights Reserved.
32.21 + */
32.22 +package org.netbeans.modules.workflow.project.anttasks;
32.23 +
32.24 +import java.io.File;
32.25 +import java.util.logging.Logger;
32.26 +
32.27 +import org.apache.tools.ant.BuildException;
32.28 +import org.apache.tools.ant.Task;
32.29 +import org.apache.tools.ant.types.Reference;
32.30 +/**
32.31 + * Generates client WSDL
32.32 + * @author Sreenivasan Genipudi
32.33 + */
32.34 +public class IDEGenerateWSDLTask extends Task {
32.35 + //Member variable representing source directory
32.36 + /**
32.37 + * Project name
32.38 + */
32.39 + private String mProjectname = null;
32.40 + //Member variable representing source dir
32.41 + private File mSourceDir;
32.42 + //Member variable representing build dir
32.43 + private File mBuildDir;
32.44 + //Member variable representing Client WSDL file.
32.45 + private File mClientWSDLFile;
32.46 + /**
32.47 + * Logger instance
32.48 + */
32.49 + private Logger logger = Logger.getLogger(IDEGenerateWSDLTask.class.getName());
32.50 +
32.51 + /**
32.52 + * Constructor
32.53 + */
32.54 + public IDEGenerateWSDLTask() {
32.55 + }
32.56 +
32.57 +
32.58 + /**
32.59 + * Set the source directory
32.60 + * @param srcDir Source directory
32.61 + */
32.62 + public void setSourceDirectory(String srcDir) {
32.63 + this.mSourceDir = new File(srcDir);
32.64 + }
32.65 +
32.66 + /**
32.67 + * Set the build directory
32.68 + * @param buildDir build directory
32.69 + */
32.70 + public void setBuildDirectory(String buildDir) {
32.71 + this.mBuildDir = new File(buildDir);
32.72 + }
32.73 +
32.74 + public void setClasspathRef(Reference ref) {
32.75 + }
32.76 +
32.77 + public void setTaskFlowClasspath(Reference ref) {
32.78 + }
32.79 +
32.80 + /**
32.81 + * Set the project name
32.82 + * @param String project name
32.83 + */
32.84 + public void setProjectName(String projectName) {
32.85 + this.mProjectname = projectName;
32.86 + }
32.87 +
32.88 + public void setClientWSDL(String clientWSDL) {
32.89 + this.mClientWSDLFile = new File(clientWSDL);
32.90 + }
32.91 +
32.92 + /**
32.93 +
32.94 + /**
32.95 + * Generate client WSDL
32.96 + */
32.97 + public void execute() throws BuildException {
32.98 +
32.99 + if(this.mSourceDir == null) {
32.100 + throw new BuildException("No directory is set for source files.");
32.101 + }
32.102 +
32.103 + if(this.mBuildDir == null) {
32.104 + throw new BuildException("No build directory is set.");
32.105 + }
32.106 +
32.107 + if(this.mProjectname== null) {
32.108 + throw new BuildException("No Project Name is set.");
32.109 + }
32.110 +
32.111 + if (this.mClientWSDLFile == null) {
32.112 + throw new BuildException("No Client WSDL File is set.");
32.113 + }
32.114 +
32.115 + WSDLGenerator wsdlGen = new WSDLGenerator();
32.116 + wsdlGen.generate(this.mProjectname,this.mSourceDir,this.mBuildDir,this.mClientWSDLFile);
32.117 +
32.118 + }
32.119 +
32.120 +}
33.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
33.2 +++ b/enterprise/openesbaddons/workflow/project/antsrc/org/netbeans/modules/workflow/project/anttasks/IDEXFormGenerationTask.java Thu Apr 26 02:33:27 2007 +0000
33.3 @@ -0,0 +1,99 @@
33.4 +/*
33.5 + * The contents of this file are subject to the terms of the Common Development
33.6 + * and Distribution License (the License). You may not use this file except in
33.7 + * compliance with the License.
33.8 + *
33.9 + * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
33.10 + * or http://www.netbeans.org/cddl.txt.
33.11 +
33.12 + * When distributing Covered Code, include this CDDL Header Notice in each file
33.13 + * and include the License file at http://www.netbeans.org/cddl.txt.
33.14 + * If applicable, add the following below the CDDL Header, with the fields
33.15 + * enclosed by brackets [] replaced by your own identifying information:
33.16 + * "Portions Copyrighted [year] [name of copyright owner]"
33.17 + *
33.18 + * The Original Software is NetBeans. The Initial Developer of the Original
33.19 + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
33.20 + * Microsystems, Inc. All Rights Reserved.
33.21 + */
33.22 +package org.netbeans.modules.workflow.project.anttasks;
33.23 +
33.24 +import java.io.File;
33.25 +import java.util.logging.Logger;
33.26 +
33.27 +import org.apache.tools.ant.BuildException;
33.28 +import org.apache.tools.ant.Task;
33.29 +/**
33.30 + * Generates client WSDL
33.31 + * @author Sreenivasan Genipudi
33.32 + */
33.33 +public class IDEXFormGenerationTask extends Task {
33.34 + //Member variable representing source directory
33.35 +
33.36 + //Member variable representing source dir
33.37 + private File mSourceDir;
33.38 + //Member variable representing build dir
33.39 + private File mBuildDir;
33.40 + private boolean mAlways;
33.41 + /**
33.42 + * Logger instance
33.43 + */
33.44 + private Logger logger = Logger.getLogger(IDEXFormGenerationTask.class.getName());
33.45 +
33.46 + /**
33.47 + * Constructor
33.48 + */
33.49 + public IDEXFormGenerationTask() {
33.50 + }
33.51 +
33.52 +
33.53 + /**
33.54 + * Set the source directory
33.55 + * @param srcDir Source directory
33.56 + */
33.57 + public void setSourceDirectory(String srcDir) {
33.58 + this.mSourceDir = new File(srcDir);
33.59 + }
33.60 +
33.61 + /**
33.62 + * Set the build directory
33.63 + * @param buildDir build directory
33.64 + */
33.65 + public void setBuildDirectory(String buildDir) {
33.66 + this.mBuildDir = new File(buildDir);
33.67 + }
33.68 +
33.69 +
33.70 + public void setAlways(String always) {
33.71 + if (always.endsWith("true")) {
33.72 + mAlways = true;
33.73 + } else {
33.74 + mAlways = false;
33.75 + }
33.76 + }
33.77 + /**
33.78 +
33.79 + /**
33.80 + * Generate client WSDL
33.81 + */
33.82 + public void execute() throws BuildException {
33.83 +
33.84 + if(this.mSourceDir == null) {
33.85 + throw new BuildException("No directory is set for source files.");
33.86 + }
33.87 +
33.88 + if(this.mBuildDir == null) {
33.89 + throw new BuildException("No build directory is set.");
33.90 + }
33.91 +
33.92 +
33.93 + XformGenerator xformGen = new XformGenerator();
33.94 + try {
33.95 + xformGen.generate(this.mSourceDir,this.mBuildDir,this.mAlways);
33.96 + } catch (Exception e) {
33.97 + throw new BuildException (e);
33.98 + }
33.99 +
33.100 + }
33.101 +
33.102 +}
34.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
34.2 +++ b/enterprise/openesbaddons/workflow/project/antsrc/org/netbeans/modules/workflow/project/anttasks/IOUtil.java Thu Apr 26 02:33:27 2007 +0000
34.3 @@ -0,0 +1,310 @@
34.4 +/* *************************************************************************
34.5 + *
34.6 + * Copyright (c) 2002, SeeBeyond Technology Corporation,
34.7 + * All Rights Reserved
34.8 + *
34.9 + * This program, and all the routines referenced herein,
34.10 + * are the proprietary properties and trade secrets of
34.11 + * SEEBEYOND TECHNOLOGY CORPORATION.
34.12 + *
34.13 + * Except as provided for by license agreement, this
34.14 + * program shall not be duplicated, used, or disclosed
34.15 + * without written consent signed by an officer of
34.16 + * SEEBEYOND TECHNOLOGY CORPORATION.
34.17 + *
34.18 + ***************************************************************************/
34.19 +package org.netbeans.modules.workflow.project.anttasks;
34.20 +
34.21 +import java.io.FileOutputStream;
34.22 +import java.io.BufferedInputStream;
34.23 +import java.io.BufferedOutputStream;
34.24 +import java.io.File;
34.25 +import java.io.ByteArrayInputStream;
34.26 +import java.io.ByteArrayOutputStream;
34.27 +import java.io.IOException;
34.28 +import java.io.InputStream;
34.29 +import java.io.InputStreamReader;
34.30 +import java.io.OutputStream;
34.31 +import java.io.OutputStreamWriter;
34.32 +import java.io.Reader;
34.33 +import java.io.StringWriter;
34.34 +import java.io.Writer;
34.35 +import java.util.Enumeration;
34.36 +import java.util.zip.ZipFile;
34.37 +import java.util.zip.ZipEntry;
34.38 +
34.39 +public class IOUtil {
34.40 + private static final java.util.logging.Logger mLog = java.util.logging.Logger.getLogger("com.sun.jbi.ui.devtool.tcg.util");
34.41 +
34.42 + private static final int DEFAULT_BUFFER_SIZE = 1024 * 4;
34.43 +
34.44 + // UTF-8
34.45 + public static void encode(
34.46 + InputStream input, String srcEncoding, OutputStream output, String targetEncoding)
34.47 + throws IOException {
34.48 + Reader in = new InputStreamReader(
34.49 + input, srcEncoding);
34.50 + Writer out = new OutputStreamWriter(
34.51 + output, targetEncoding);
34.52 + copy(in, out);
34.53 + }
34.54 +
34.55 + // UTF-8
34.56 + public static byte[] encode(
34.57 + byte[] srcBuf, String srcEncoding, String targetEncoding)
34.58 + throws IOException {
34.59 + String s = new String(srcBuf, srcEncoding);
34.60 + byte[] ret = s.getBytes(targetEncoding);
34.61 + return ret;
34.62 + }
34.63 +
34.64 + /**
34.65 + * Copys the input stream to the output stream
34.66 + *
34.67 + * @param input the input stream
34.68 + * @param output the output stream
34.69 + * @exception IOException Description of the Exception
34.70 + */
34.71 + public static void copy(InputStream input, OutputStream output)
34.72 + throws IOException {
34.73 + byte[] buf = new byte[DEFAULT_BUFFER_SIZE];
34.74 + int n = 0;
34.75 + while ((n = input.read(buf)) != -1) {
34.76 + output.write(buf, 0, n);
34.77 + }
34.78 + output.flush();
34.79 + }
34.80 +
34.81 + /**
34.82 + * Copys the input bytes to the output stream
34.83 + *
34.84 + * @param input the input bytes
34.85 + * @param output the output stream
34.86 + * @exception IOException Description of the Exception
34.87 + */
34.88 + public static void copy(byte[] input, OutputStream output)
34.89 + throws IOException {
34.90 + ByteArrayInputStream in = new ByteArrayInputStream(input);
34.91 + copy(in, output);
34.92 + }
34.93 +
34.94 + /**
34.95 + * Copys the input stream to the output stream
34.96 + *
34.97 + * @param input the input stream
34.98 + * @param output the output stream
34.99 + * @exception IOException Description of the Exception
34.100 + */
34.101 + public static void copy(Reader input, Writer output)
34.102 + throws IOException {
34.103 + char[] buf = new char[DEFAULT_BUFFER_SIZE];
34.104 + int n = 0;
34.105 + while ((n = input.read(buf)) != -1) {
34.106 + output.write(buf, 0, n);
34.107 + }
34.108 + output.flush();
34.109 + }
34.110 +
34.111 + /**
34.112 + * Copys the input bytes to the output stream
34.113 + *
34.114 + * @param input the input bytes
34.115 + * @param output the output stream
34.116 + * @exception IOException Description of the Exception
34.117 + */
34.118 + public static void copy(byte[] input, Writer output)
34.119 + throws IOException {
34.120 + ByteArrayInputStream in = new ByteArrayInputStream(input);
34.121 + copy(in, output);
34.122 + }
34.123 +
34.124 + /**
34.125 + * Copys the input stream to the output stream
34.126 + *
34.127 + * @param input the input stream
34.128 + * @param output the output stream
34.129 + * @exception IOException Description of the Exception
34.130 + */
34.131 + public static void copy(InputStream input, Writer output)
34.132 + throws IOException {
34.133 + InputStreamReader in = new InputStreamReader(input);
34.134 + copy(in, output);
34.135 + }
34.136 +
34.137 + /**
34.138 + * Copys the input stream to the output stream
34.139 + *
34.140 + * @param input the input stream
34.141 + * @param output the output stream
34.142 + * @exception IOException Description of the Exception
34.143 + */
34.144 + public static void copy(Reader input, OutputStream output)
34.145 + throws IOException {
34.146 + OutputStreamWriter out = new OutputStreamWriter(output);
34.147 + copy(input, out);
34.148 + }
34.149 +
34.150 + /**
34.151 + * Returns the contents of the input stream as a String
34.152 + *
34.153 + * @param input the input stream
34.154 + * @return The text value
34.155 + * @exception IOException Description of the Exception
34.156 + */
34.157 + /*public static String getText(InputStream input)
34.158 + throws IOException {
34.159 + StringWriter out = new StringWriter();
34.160 + copy(input, out);
34.161 + String ret = out.toString();
34.162 + //mLog.debug("ret: " + ret);
34.163 + return ret;
34.164 + }*/
34.165 +
34.166 + // UTF-8
34.167 + public static String getText(InputStream input, String srcEncoding)
34.168 + throws IOException {
34.169 + InputStreamReader in = new InputStreamReader(input, srcEncoding);
34.170 + StringWriter out = new StringWriter();
34.171 + copy(in, out);
34.172 + String ret = out.toString();
34.173 + //mLog.debug("ret: " + ret);
34.174 + return ret;
34.175 + }
34.176 +
34.177 + public static String getText(String name, String srcEncoding)
34.178 + throws IOException {
34.179 + InputStream inputStream = null;
34.180 + String ret = null;
34.181 + try {
34.182 + inputStream = getResourceAsStream(name);
34.183 + ret = getText(inputStream, srcEncoding);
34.184 + } catch (IOException e) {
34.185 + throw e;
34.186 + } finally {
34.187 + if (inputStream != null) {
34.188 + inputStream.close();
34.189 + }
34.190 + }
34.191 + //mLog.debug("ret: " + ret);
34.192 + return ret;
34.193 + }
34.194 +
34.195 + /**
34.196 + * Returns the contents of the input stream as a String
34.197 + *
34.198 + * @param input the input stream
34.199 + * @return The text value
34.200 + * @exception IOException Description of the Exception
34.201 + */
34.202 + public static String getText(Reader input)
34.203 + throws IOException {
34.204 + StringWriter sw = new StringWriter();
34.205 + copy(input, sw);
34.206 + return sw.toString();
34.207 + }
34.208 +
34.209 + /**
34.210 + * Returns the contents of the input stream as a byte array
34.211 + *
34.212 + * @param input the input stream
34.213 + * @return The byte array
34.214 + * @exception IOException Description of the Exception
34.215 + */
34.216 + public static byte[] getBytes(InputStream input)
34.217 + throws IOException {
34.218 + ByteArrayOutputStream output = new ByteArrayOutputStream();
34.219 + copy(input, output);
34.220 + return output.toByteArray();
34.221 + }
34.222 +
34.223 + public static byte[] getBytes(String name)
34.224 + throws IOException {
34.225 + return getBytes(getResourceAsStream(name));
34.226 + }
34.227 +
34.228 + /**
34.229 + * Returns the contents of the input stream as a byte array
34.230 + *
34.231 + * @param input the input stream
34.232 + * @return The byte array
34.233 + * @exception IOException Description of the Exception
34.234 + */
34.235 + public static byte[] getBytes(Reader input)
34.236 + throws IOException {
34.237 + ByteArrayOutputStream output = new ByteArrayOutputStream();
34.238 + copy(input, output);
34.239 + return output.toByteArray();
34.240 + }
34.241 +
34.242 + //==========================================================================
34.243 + public static InputStream getResourceAsStream(String name) {
34.244 + InputStream ret = null;
34.245 + try {
34.246 + if (new java.io.File(name).exists()) {
34.247 + ret = new java.io.FileInputStream(name);
34.248 + } else {
34.249 + ret = new java.net.URL(name).openStream();
34.250 + }
34.251 + } catch (Exception e) {
34.252 + ret = IOUtil.class.getClassLoader(
34.253 + ).getResourceAsStream(name);
34.254 + if (ret == null) {
34.255 + mLog.warning("resource " + name + " not found");
34.256 + } else {
34.257 + //mLog.debug("IOUtil.getResourceAsStream " + name + " found");
34.258 + }
34.259 + }
34.260 + return ret;
34.261 + }
34.262 +
34.263 + public static Enumeration getResources() {
34.264 + return null; // ClassLoader.getResources(name);
34.265 + }
34.266 +
34.267 + public static void unzip(String zipFilePath, String targetDirPath)
34.268 + throws IOException {
34.269 + ZipFile zipFile = new ZipFile(zipFilePath);
34.270 + for (Enumeration e = zipFile.entries(); e.hasMoreElements();) {
34.271 + ZipEntry entry = (ZipEntry) e.nextElement();
34.272 +
34.273 + String path;
34.274 + if (targetDirPath != null) {
34.275 + path = targetDirPath + "/" + entry.getName();
34.276 + } else {
34.277 + path = entry.getName();
34.278 + }
34.279 +
34.280 + if (entry.isDirectory()) {
34.281 + File dir = new File(path);
34.282 + if (!dir.exists()) {
34.283 + dir.mkdirs();
34.284 + }
34.285 + } else {
34.286 + InputStream input =
34.287 + new BufferedInputStream(zipFile.getInputStream(entry));
34.288 + OutputStream output =
34.289 + new BufferedOutputStream(
34.290 + new FileOutputStream(path));
34.291 + copy(input, output);
34.292 + input.close();
34.293 + output.close();
34.294 + }
34.295 + }
34.296 + zipFile.close();
34.297 + }
34.298 +
34.299 + public static final void main(String[] args) {
34.300 + if (args.length != 2) {
34.301 + System.err.println("Usage: java IOUtil zipfile targetdirectory");
34.302 + } else {
34.303 + try {
34.304 + unzip(args[0], args[1]);
34.305 + } catch (Exception e) {
34.306 + e.printStackTrace();
34.307 + }
34.308 + }
34.309 + //mLog.debug("args " + args[0]);
34.310 + //mLog.debug(IOUtil.class.getClassLoader().getResource(args[0]));
34.311 + //mLog.debug(IOUtil.getResourceAsStream(args[0]));
34.312 + }
34.313 +}
35.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
35.2 +++ b/enterprise/openesbaddons/workflow/project/antsrc/org/netbeans/modules/workflow/project/anttasks/MyLookup.java Thu Apr 26 02:33:27 2007 +0000
35.3 @@ -0,0 +1,54 @@
35.4 +/*
35.5 + * The contents of this file are subject to the terms of the Common Development
35.6 + * and Distribution License (the License). You may not use this file except in
35.7 + * compliance with the License.
35.8 + *
35.9 + * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
35.10 + * or http://www.netbeans.org/cddl.txt.
35.11 +
35.12 + * When distributing Covered Code, include this CDDL Header Notice in each file
35.13 + * and include the License file at http://www.netbeans.org/cddl.txt.
35.14 + * If applicable, add the following below the CDDL Header, with the fields
35.15 + * enclosed by brackets [] replaced by your own identifying information:
35.16 + * "Portions Copyrighted [year] [name of copyright owner]"
35.17 + *
35.18 + * The Original Software is NetBeans. The Initial Developer of the Original
35.19 + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
35.20 + * Microsystems, Inc. All Rights Reserved.
35.21 + */
35.22 +package org.netbeans.modules.workflow.project.anttasks;
35.23 +
35.24 +import org.openide.util.Lookup;
35.25 +import org.openide.util.lookup.Lookups;
35.26 +
35.27 +
35.28 +public class MyLookup extends Lookup {
35.29 + static Lookup mylookup = null;
35.30 + static MyLookup m_instance = null;
35.31 +
35.32 + public MyLookup() {
35.33 +
35.34 + }
35.35 + private static Lookup getInstance(){
35.36 + if (m_instance == null ) {
35.37 + m_instance = new MyLookup();
35.38 + }
35.39 + if (mylookup == null) {
35.40 + mylookup = Lookups.metaInfServices(m_instance.getClass().getClassLoader());
35.41 + }
35.42 + return mylookup;
35.43 + }
35.44 +
35.45 + public Object lookup(Class clazz) {
35.46 + return getInstance().lookup(clazz);
35.47 + }
35.48 +
35.49 + public Lookup.Result lookup(Lookup.Template template) {
35.50 + return getInstance().lookup(template);
35.51 + }
35.52 +
35.53 + public Lookup.Item lookupItem(Lookup.Template template) {
35.54 + return getInstance().lookupItem(template);
35.55 + }
35.56 +
35.57 +}
36.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
36.2 +++ b/enterprise/openesbaddons/workflow/project/antsrc/org/netbeans/modules/workflow/project/anttasks/SchemaManager.java Thu Apr 26 02:33:27 2007 +0000
36.3 @@ -0,0 +1,73 @@
36.4 +/* *************************************************************************
36.5 + *
36.6 + * Copyright (c) 2005, SeeBeyond Technology Corporation,
36.7 + * All Rights Reserved
36.8 + *
36.9 + * This program, and all the routines referenced herein,
36.10 + * are the proprietary properties and trade secrets of
36.11 + * SEEBEYOND TECHNOLOGY CORPORATION.
36.12 + *
36.13 + * Except as provided for by license agreement, this
36.14 + * program shall not be duplicated, used, or disclosed
36.15 + * without written consent signed by an officer of
36.16 + * SEEBEYOND TECHNOLOGY CORPORATION.
36.17 + *
36.18 + ***************************************************************************/
36.19 +package org.netbeans.modules.workflow.project.anttasks;
36.20 +
36.21 +import java.io.File;
36.22 +
36.23 +import org.netbeans.modules.xml.schema.model.SchemaModel;
36.24 +import org.netbeans.modules.xml.schema.model.SchemaModelFactory;
36.25 +import org.netbeans.modules.xml.xam.ModelSource;
36.26 +import org.openide.filesystems.FileUtil;
36.27 +
36.28 +/**
36.29 + * @author sgenipudi
36.30 + */
36.31 +public class SchemaManager {
36.32 +
36.33 + private static SchemaManager mInstance = null;
36.34 +
36.35 + private SchemaManager() {
36.36 +
36.37 + }
36.38 +
36.39 + public static SchemaManager getInstance() {
36.40 + if (mInstance == null ) {
36.41 + mInstance = new SchemaManager();
36.42 + }
36.43 + return mInstance;
36.44 + }
36.45 +
36.46 + public SchemaModel getSchemaModel(File file) {
36.47 + ModelSource ms = getModuleSource(file);
36.48 + SchemaModelFactory factory = SchemaModelFactory.getDefault();
36.49 + SchemaModel model = factory.getModel(ms);
36.50 + try {
36.51 + model.sync();
36.52 + }catch (Exception ex) {
36.53 + throw new RuntimeException("Error during sync operation of Client WSDL file");
36.54 + }
36.55 + return model;
36.56 + }
36.57 +
36.58 + public ModelSource getModuleSource(File file) {
36.59 + ModelSource source = null;
36.60 + try {
36.61 + if (WSDLGenerator.isCommandlineMode()) {
36.62 + source = WorkflowCatalogModel.getDefault().createModelSource(file, true);
36.63 + } else {
36.64 + source = org.netbeans.modules.xml.retriever.catalog.Utilities.createModelSource(FileUtil.toFileObject(file),true);
36.65 + }
36.66 + }catch (Exception ex){
36.67 + throw new RuntimeException("Error while creating model source for "+file);
36.68 + }
36.69 +
36.70 + return source;
36.71 + }
36.72 +
36.73 +
36.74 +// public WSDLOperation getOperation()
36.75 +
36.76 +}
37.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
37.2 +++ b/enterprise/openesbaddons/workflow/project/antsrc/org/netbeans/modules/workflow/project/anttasks/Util.java Thu Apr 26 02:33:27 2007 +0000
37.3 @@ -0,0 +1,730 @@
37.4 +/* *************************************************************************
37.5 + *
37.6 + * Copyright (c) 2005, SeeBeyond Technology Corporation,
37.7 + * All Rights Reserved
37.8 + *
37.9 + * This program, and all the routines referenced herein,
37.10 + * are the proprietary properties and trade secrets of
37.11 + * SEEBEYOND TECHNOLOGY CORPORATION.
37.12 + *
37.13 + * Except as provided for by license agreement, this
37.14 + * program shall not be duplicated, used, or disclosed
37.15 + * without written consent signed by an officer of
37.16 + * SEEBEYOND TECHNOLOGY CORPORATION.
37.17 + *
37.18 + ***************************************************************************/
37.19 +package org.netbeans.modules.workflow.project.anttasks;
37.20 +
37.21 +import java.io.BufferedWriter;
37.22 +import java.io.File;
37.23 +import java.io.FileOutputStream;
37.24 +import java.io.FileReader;
37.25 +import java.io.IOException;
37.26 +import java.io.InputStream;
37.27 +import java.io.OutputStreamWriter;
37.28 +import java.net.MalformedURLException;
37.29 +import java.net.URI;
37.30 +import java.net.URL;
37.31 +import java.net.URLClassLoader;
37.32 +import java.util.ArrayList;
37.33 +import java.util.Collection;
37.34 +import java.util.HashMap;
37.35 +import java.util.HashSet;
37.36 +import java.util.Iterator;
37.37 +import java.util.List;
37.38 +import java.util.Map;
37.39 +import java.util.Set;
37.40 +import java.util.logging.Level;
37.41 +import java.util.logging.Logger;
37.42 +
37.43 +import javax.wsdl.Input;
37.44 +import javax.wsdl.Message;
37.45 +import javax.wsdl.Part;
37.46 +import javax.xml.namespace.QName;
37.47 +import javax.xml.transform.dom.DOMSource;
37.48 +import javax.xml.transform.stream.StreamSource;
37.49 +
37.50 +import com.sun.org.apache.xerces.internal.xs.*;
37.51 +
37.52 +import org.apache.xmlbeans.SchemaType;
37.53 +import org.apache.xmlbeans.SchemaTypeSystem;
37.54 +import org.apache.xmlbeans.XmlBeans;
37.55 +import org.apache.xmlbeans.XmlError;
37.56 +import org.apache.xmlbeans.XmlException;
37.57 +import org.apache.xmlbeans.XmlObject;
37.58 +import org.apache.xmlbeans.XmlOptions;
37.59 +import org.apache.xmlbeans.impl.xb.xsdschema.SchemaDocument;
37.60 +import org.apache.xmlbeans.impl.xsd2inst.SampleXmlUtil;
37.61 +import org.netbeans.modules.workflow.project.anttasks.wsdl.WSDLMessage;
37.62 +import org.netbeans.modules.workflow.project.anttasks.wsdl.WSDLOperation;
37.63 +import org.netbeans.modules.workflow.project.anttasks.wsdl.WSDLPart;
37.64 +import org.netbeans.modules.xml.schema.model.GlobalComplexType;
37.65 +import org.netbeans.modules.xml.schema.model.GlobalElement;
37.66 +import org.netbeans.modules.xml.schema.model.GlobalSimpleType;
37.67 +import org.netbeans.modules.xml.schema.model.GlobalType;
37.68 +import org.netbeans.modules.xml.schema.model.Schema;
37.69 +import org.netbeans.modules.xml.schema.model.SchemaModel;
37.70 +import org.netbeans.modules.xml.wsdl.model.Types;
37.71 +import org.netbeans.modules.xml.wsdl.model.WSDLModel;
37.72 +import org.netbeans.modules.xml.wsdl.model.extensions.xsd.WSDLSchema;
37.73 +import org.w3c.dom.Document;
37.74 +import org.w3c.dom.Element;
37.75 +import org.w3c.dom.Node;
37.76 +import org.w3c.dom.bootstrap.DOMImplementationRegistry;
37.77 +import org.xml.sax.Attributes;
37.78 +import org.xml.sax.SAXException;
37.79 +
37.80 +import com.sun.jbi.workflow.model.ModelFactory;
37.81 +import com.sun.jbi.workflow.model.Task;
37.82 +import com.sun.jbi.workflow.model.Tasks;
37.83 +import com.sun.org.apache.xerces.internal.xs.XSModel;
37.84 +
37.85 +/**
37.86 + *
37.87 + * This class is used to obtain the Task Model from workflow file and form relation between
37.88 + * PartnerLink+PartnerLinkType to TaskModel. This class is used by ServiceUnitManager to obtain the
37.89 + * taskmodel
37.90 + *
37.91 + * @author sgenipudi
37.92 + */
37.93 +public class Util {
37.94 + private static final Logger mLogger = Logger.getLogger(Util.class.getName());
37.95 +
37.96 + public Util() {
37.97 +
37.98 + }
37.99 +
37.100 + /**
37.101 + * Generate *TaskName*xform.xhtml based on the workflowFile in projectSourceDir
37.102 + *
37.103 + * @param workFlowFile
37.104 + * @param buildDir
37.105 + * @param projectSourceDir
37.106 + * @throws Exception
37.107 + */
37.108 + public static boolean generateXForm(File workFlowFile, File buildDir, File projectSourceDir,
37.109 + boolean always) throws Exception {
37.110 + try {
37.111 + Tasks tasks = null;
37.112 + try {
37.113 + tasks = ModelFactory.getInstance().getTasksModel(workFlowFile.getAbsolutePath());
37.114 + } catch (Exception me) {
37.115 + mLogger.severe("Error creating WorkFlowModel " + workFlowFile.getAbsolutePath()
37.116 + + " Reason " + me.toString());
37.117 + throw me;
37.118 + }
37.119 + List<com.sun.jbi.workflow.model.WSDLDefinition> listOfWSDLDefs = null;
37.120 + try {
37.121 + listOfWSDLDefs = tasks.getImportWSDLs();
37.122 + } catch (Exception ex) {
37.123 + throw new RuntimeException(
37.124 + "Error encountered while retrieving the imported WSDL in workfile "
37.125 + + workFlowFile.getAbsolutePath());
37.126 + }
37.127 + HashMap mapOfTNSToWsdlDef = new HashMap();
37.128 + for (com.sun.jbi.workflow.model.WSDLDefinition impWsdls : listOfWSDLDefs) {
37.129 + String wsdlTNS = impWsdls.getTargetNamespace();
37.130 + mapOfTNSToWsdlDef.put(impWsdls.getTargetNamespace(), impWsdls);
37.131 + }
37.132 +
37.133 + Task task = (Task) tasks.getTasks().get(0);
37.134 + String taskName = task.getName();
37.135 + File xhtml = new File(projectSourceDir, taskName + "Xform.xhtml");
37.136 + if (xhtml.exists() && !always) {
37.137 + return false;
37.138 + }
37.139 +
37.140 + javax.wsdl.PortType taskPT = null;
37.141 + javax.wsdl.Operation taskOpn = null;
37.142 + try {
37.143 + if (task == null) {
37.144 + System.out.println(" task is null");
37.145 + }
37.146 + if (task.getWSDLOperation() == null) {
37.147 + System.out.println("WSDL opn is null");
37.148 + }
37.149 +
37.150 + taskOpn = task.getWSDLOperation();
37.151 + taskPT = task.getPortType();
37.152 + } catch (Exception ex) {
37.153 + throw new RuntimeException(
37.154 + "Error encountered while retreiving WSDL operation in workfile "
37.155 + + workFlowFile.getAbsolutePath());
37.156 + }
37.157 +
37.158 + Input taskOpnInp = taskOpn.getInput();
37.159 + javax.wsdl.Output taskOpnOut = taskOpn.getOutput();
37.160 + // Get the input message
37.161 + Message taskOpnInMsg = taskOpnInp.getMessage();
37.162 +
37.163 + Message taskOpnOutMsg = taskOpnOut.getMessage();
37.164 + // Get the WSDLDefenition for the input message
37.165 + com.sun.jbi.workflow.model.WSDLDefinition wsdlDef = (com.sun.jbi.workflow.model.WSDLDefinition) mapOfTNSToWsdlDef
37.166 + .get(taskOpnInMsg.getQName().getNamespaceURI());
37.167 +
37.168 + File WSDLFileFromURI = null;
37.169 + try {
37.170 + URI wsdlURI = new URI(wsdlDef.getDocumentBaseURI());
37.171 + WSDLFileFromURI = new File(wsdlURI);
37.172 + } catch (Exception e1) {
37.173 + throw new RuntimeException("Invalid WSDL Location " + wsdlDef.getDocumentBaseURI());
37.174 + }
37.175 +
37.176 + SchemaUnit schemaUnitIn = getSchemaUnit(wsdlDef, taskOpnInMsg, WSDLFileFromURI,
37.177 + buildDir, projectSourceDir);
37.178 + SchemaUnit schemaUnitOut = getSchemaUnit(wsdlDef, taskOpnOutMsg, WSDLFileFromURI,
37.179 + buildDir, projectSourceDir);
37.180 +
37.181 + return writeXform(schemaUnitIn.getSchemaFile(), schemaUnitIn.getElementName(),
37.182 + schemaUnitOut.getSchemaFile(), schemaUnitOut.getElementName(),
37.183 + projectSourceDir, xhtml, taskName);
37.184 + } catch (Exception e) {
37.185 + mLogger.log(Level.SEVERE, "Error in creating Xform", e);
37.186 + throw e;
37.187 +
37.188 + }
37.189 +
37.190 + }
37.191 +
37.192 + private static boolean writeXform(File inSchemaFile, QName inElementName, File outSchemaFile,
37.193 + QName outElementName, File projectSourceDir, File xhtml, String taskName)
37.194 + throws Exception {
37.195 + // create input, output xml instance
37.196 + XmlOptions compileOptions = new XmlOptions();
37.197 + compileOptions.setCompileDownloadUrls();
37.198 + XmlObject[] schemas;
37.199 + URL[] urls;
37.200 +
37.201 + ArrayList errorList = new ArrayList();
37.202 + compileOptions.setErrorListener(errorList);
37.203 + SchemaTypeSystem sts = null;
37.204 + Thread thread = Thread.currentThread();
37.205 + ClassLoader oldCl = thread.getContextClassLoader();
37.206 + try {
37.207 + if (inSchemaFile.getAbsolutePath().equals(outSchemaFile.getAbsolutePath())) {
37.208 + urls = new URL[1];
37.209 + urls[0] = inSchemaFile.getParentFile().toURL();
37.210 + } else {
37.211 + urls = new URL[2];
37.212 + urls[0] = inSchemaFile.getParentFile().toURL();
37.213 + urls[1] = outSchemaFile.getParentFile().toURL();
37.214 + }
37.215 + URLClassLoader cl = new URLClassLoader(urls, oldCl);
37.216 + thread.setContextClassLoader(cl);
37.217 + if (inSchemaFile.getAbsolutePath().equals(outSchemaFile.getAbsolutePath())) {
37.218 + schemas = new XmlObject[1];
37.219 + schemas[0] = SchemaDocument.Factory.parse(inSchemaFile, (new XmlOptions())
37.220 + .setLoadLineNumbers().setLoadMessageDigest());
37.221 + } else {
37.222 + schemas = new XmlObject[2];
37.223 + schemas[0] = SchemaDocument.Factory.parse(inSchemaFile, (new XmlOptions())
37.224 + .setLoadLineNumbers().setLoadMessageDigest());
37.225 + schemas[1] = XmlObject.Factory.parse(outSchemaFile, (new XmlOptions())
37.226 + .setLoadLineNumbers().setLoadMessageDigest());
37.227 + }
37.228 + try {
37.229 + sts = XmlBeans.compileXsd(schemas, XmlBeans.getBuiltinTypeSystem(), compileOptions);
37.230 + } catch (XmlException e) {
37.231 + // TODO Auto-generated catch block
37.232 + for (int i = 0; i < errorList.size(); i++) {
37.233 + XmlError error = (XmlError) errorList.get(i);
37.234 + StringBuffer buffer = new StringBuffer();
37.235 + buffer.append("\n");
37.236 + buffer.append("Message: " + error.getMessage() + "\n");
37.237 + buffer.append("Location of invalid XML: " + error.getCursorLocation().xmlText()
37.238 + + "\n");
37.239 + throw new RuntimeException(buffer.toString(), e);
37.240 + }
37.241 + throw e;
37.242 + }
37.243 +
37.244 + } catch (Exception e) {
37.245 + throw e;
37.246 + } finally {
37.247 + thread.setContextClassLoader(oldCl);
37.248 + }
37.249 +
37.250 + SchemaType[] globalElems = sts.documentTypes();
37.251 + SchemaType inElem = null;
37.252 + SchemaType outElem = null;
37.253 + for (int i = 0; i < globalElems.length; i++) {
37.254 + if (inElementName.equals(globalElems[i].getDocumentElementName())) {
37.255 + inElem = globalElems[i];
37.256 + }
37.257 + if (outElementName.equals(globalElems[i].getDocumentElementName())) {
37.258 + outElem = globalElems[i];
37.259 + }
37.260 + if (inElem != null && outElem != null) {
37.261 + break;
37.262 + }
37.263 + }
37.264 + if (inElem != null) {
37.265 + String xmlString = SampleXmlUtil.createSampleForType(inElem);
37.266 + writeFile(new File(xhtml.getParentFile(), taskName + "InputInstance.xml")
37.267 + .getAbsolutePath(), xmlString, false);
37.268 + }
37.269 + if (outElem != null) {
37.270 + String xmlString = SampleXmlUtil.createSampleForType(outElem);
37.271 + writeFile(new File(xhtml.getParentFile(), taskName + "OutputInstance.xml")
37.272 + .getAbsolutePath(), xmlString, false);
37.273 + }
37.274 + URL urlIn = inSchemaFile.toURL();
37.275 + URL urlOut = outSchemaFile.toURL();
37.276 +
37.277 + Map defaultValue = new HashMap();
37.278 +
37.279 + org.xml.sax.XMLReader reader = makeXMLReader();
37.280 + reader.setContentHandler(new Sink(defaultValue));
37.281 +
37.282 + File mappingFile = new File(projectSourceDir, "mappings.xml");
37.283 + FileReader fileReader = new FileReader(mappingFile);
37.284 + if (mappingFile.exists()) {
37.285 + reader.parse(new org.xml.sax.InputSource(fileReader));
37.286 + fileReader.close();
37.287 + }
37.288 +
37.289 + BaseSchemaFormBuilder builderIn = new BaseSchemaFormBuilder(inElementName.getLocalPart());
37.290 + BaseSchemaFormBuilder builderOut = new BaseSchemaFormBuilder(outElementName.getLocalPart(),
37.291 + true, defaultValue);
37.292 + Document formIn = builderIn.buildForm(urlIn.getPath());
37.293 + Document formOut = builderOut.buildForm(urlOut.getPath());
37.294 +
37.295 + InputStream urlInXSLT = Util.class.getResourceAsStream("resources/inputtransform.xsl");
37.296 + InputStream urlOutXSLT = Util.class.getResourceAsStream("resources/outputtransform.xsl");
37.297 +
37.298 + Node intransformed = XmlUtil.transformToDoc(new DOMSource(formIn), new StreamSource(
37.299 + urlInXSLT));
37.300 + Node outtransformed = XmlUtil.transformToDoc(new DOMSource(formOut), new StreamSource(
37.301 + urlOutXSLT));
37.302 +
37.303 + Element root = ((Document) intransformed).createElement("body");
37.304 + root.appendChild(((Document) intransformed).getDocumentElement());
37.305 + root.appendChild(((Document) intransformed).importNode(((Document) outtransformed)
37.306 + .getDocumentElement(), true));
37.307 +
37.308 + String xmlString = XmlUtil.toXml(root, "UTF-8", true);
37.309 +
37.310 + writeFile(xhtml.getAbsolutePath(), xmlString, false);
37.311 + return true;
37.312 +
37.313 + }
37.314 +
37.315 + public static void addOperationInfo(File workFlowFile, ArrayList listOfOperations,
37.316 + WSDLModel clientWSDLModel, File buildDir, File projectSourceDir) {
37.317 + Tasks tasks = null;
37.318 + try {
37.319 + tasks = ModelFactory.getInstance().getTasksModel(workFlowFile.getAbsolutePath());
37.320 + } catch (Exception me) {
37.321 + mLogger.severe("Error creating WorkFlowModel " + workFlowFile.getAbsolutePath()
37.322 + + " Reason " + me.toString());
37.323 + return;
37.324 + }
37.325 + String targetNameSpaceForWorkFile = tasks.getTargetNamespace();
37.326 + QName partnerLinkQName = null;
37.327 + QName portTypeQName = null;
37.328 +
37.329 + List<com.sun.jbi.workflow.model.WSDLDefinition> listOfWSDLDefs = null;
37.330 + try {
37.331 + listOfWSDLDefs = tasks.getImportWSDLs();
37.332 + } catch (Exception ex) {
37.333 + throw new RuntimeException(
37.334 + "Error encountered while retrieving the imported WSDL in workfile "
37.335 + + workFlowFile.getAbsolutePath());
37.336 + }
37.337 + HashMap mapOfTNSToWsdlDef = new HashMap();
37.338 +
37.339 + for (com.sun.jbi.workflow.model.WSDLDefinition impWsdls : listOfWSDLDefs) {
37.340 + String wsdlTNS = impWsdls.getTargetNamespace();
37.341 + mapOfTNSToWsdlDef.put(impWsdls.getTargetNamespace(), impWsdls);
37.342 + }
37.343 + Object taObj = null;
37.344 + for (int index = 0; index < tasks.getTasks().size(); index++) {
37.345 + try {
37.346 + taObj = tasks.getTasks().get(index);
37.347 + } catch (Exception ex) {
37.348 +
37.349 + }
37.350 +
37.351 + Task task = (Task) tasks.getTasks().get(index);
37.352 + javax.wsdl.PortType taskPT = null;
37.353 + javax.wsdl.Operation taskOpn = null;
37.354 + try {
37.355 + if (task == null) {
37.356 + System.out.println(" task is null");
37.357 + }
37.358 + if (task.getWSDLOperation() == null) {
37.359 + System.out.println("WSDL opn is null");
37.360 + }
37.361 +
37.362 + taskOpn = task.getWSDLOperation();
37.363 + taskPT = task.getPortType();
37.364 + } catch (Exception ex) {
37.365 + throw new RuntimeException(
37.366 + "Error encountered while retreiving WSDL operation in workfile "
37.367 + + workFlowFile.getAbsolutePath());
37.368 + }
37.369 +
37.370 + // Populate WSDLOperation
37.371 + WSDLOperation wsdlOpn = new WSDLOperation();
37.372 + wsdlOpn.setOperationName(taskOpn.getName());
37.373 + wsdlOpn.setTaskName(task.getName());
37.374 + wsdlOpn.setPortTypeName(taskPT.getQName());
37.375 + listOfOperations.add(wsdlOpn);
37.376 +
37.377 + WSDLMessage wsdlInMsg = new WSDLMessage();
37.378 + WSDLMessage wsdlOutMsg = new WSDLMessage();
37.379 + wsdlOpn.setInputWSDLMessage(wsdlInMsg);
37.380 + wsdlOpn.setOutputWSDLMessage(wsdlOutMsg);
37.381 +
37.382 + // Process Input Message
37.383 +
37.384 + Input taskOpnInp = taskOpn.getInput();
37.385 + // Get the input message
37.386 + Message taskOpnInMsg = taskOpnInp.getMessage();
37.387 +
37.388 + // Get the WSDLDefenition for the input message
37.389 + com.sun.jbi.workflow.model.WSDLDefinition wsdlDef = (com.sun.jbi.workflow.model.WSDLDefinition) mapOfTNSToWsdlDef
37.390 + .get(taskOpnInMsg.getQName().getNamespaceURI());
37.391 + // Get the physical locaton of the WSDL in file system.
37.392 + String wsdlPath = null;
37.393 + File WSDLFileFromURI = null;
37.394 + try {
37.395 + URI wsdlURI = new URI(wsdlDef.getDocumentBaseURI());
37.396 + WSDLFileFromURI = new File(wsdlURI);
37.397 + wsdlPath = WSDLFileFromURI.getAbsolutePath();
37.398 + } catch (Exception e1) {
37.399 + throw new RuntimeException("Invalid WSDL Location " + wsdlDef.getDocumentBaseURI());
37.400 + }
37.401 +
37.402 + populateWSDLOperation(wsdlDef, wsdlInMsg, taskOpnInMsg, WSDLFileFromURI, buildDir,
37.403 + projectSourceDir, clientWSDLModel);
37.404 + javax.wsdl.Output taskOpnOut = taskOpn.getOutput();
37.405 + // Get the output message
37.406 + Message taskOpnOutMsg = taskOpnOut.getMessage();
37.407 + populateWSDLOperation(wsdlDef, wsdlOutMsg, taskOpnOutMsg, WSDLFileFromURI, buildDir,
37.408 + projectSourceDir, clientWSDLModel);
37.409 + }
37.410 + }
37.411 +
37.412 + /**
37.413 + * Get the schema unit related to the wsdl Message, returns the
37.414 + *
37.415 + * @param wsdlDef
37.416 + * @param taskOpnInMsg
37.417 + * @param WSDLFileFromURI
37.418 + * @param buildDir
37.419 + * @param projectSourceDir
37.420 + * @return
37.421 + */
37.422 +
37.423 + public static SchemaUnit getSchemaUnit(com.sun.jbi.workflow.model.WSDLDefinition wsdlDef,
37.424 + Message taskOpnInMsg, File WSDLFileFromURI, File buildDir, File projectSourceDir) {
37.425 + // Get the list of parts defined in the message
37.426 + SchemaUnit result = null;
37.427 + List<Part> listOfParts = taskOpnInMsg.getOrderedParts(null);
37.428 + ArrayList listOfSchemaLocation = new ArrayList();
37.429 + Set<WSDL4JUtil.SchemaLocation> setOfSchemaLoc = null;//
37.430 + for (Part taskPart : listOfParts) {
37.431 + QName taskPartTypeType = taskPart.getTypeName();
37.432 + QName taskPartElementType = taskPart.getElementName(); // taskPart.getTypeName();
37.433 + setOfSchemaLoc = new HashSet();
37.434 + WSDL4JUtil wsdlUtil = WSDL4JUtil.getInstance();
37.435 + QName typeOrElementQName = (taskPartElementType != null) ? taskPartElementType
37.436 + : taskPartTypeType;
37.437 + wsdlUtil.getSchemaLocations(wsdlDef, typeOrElementQName.getNamespaceURI(),
37.438 + WSDLFileFromURI, buildDir, projectSourceDir, setOfSchemaLoc);
37.439 + Iterator<WSDL4JUtil.SchemaLocation> schmLocItr = setOfSchemaLoc.iterator();
37.440 + if (schmLocItr.hasNext()) {
37.441 + WSDL4JUtil.SchemaLocation wsdlUtilSchLoc = schmLocItr.next();
37.442 + if (!wsdlUtilSchLoc.isSimpleType()) {
37.443 + if (setOfSchemaLoc.size() == 1) {
37.444 + result = new SchemaUnit(wsdlUtilSchLoc.getFileLocation(),
37.445 + typeOrElementQName);
37.446 + return result;
37.447 + } else {
37.448 + File schemaFile = wsdlUtilSchLoc.getFileLocation();
37.449 + XSModel model = null;
37.450 + try {
37.451 + model = loadSchema(schemaFile.toURL().getPath());
37.452 + } catch (MalformedURLException e) {
37.453 + // TODO Auto-generated catch block
37.454 + e.printStackTrace();
37.455 + } catch (ClassNotFoundException e) {
37.456 + // TODO Auto-generated catch block
37.457 + e.printStackTrace();
37.458 + } catch (InstantiationException e) {
37.459 + // TODO Auto-generated catch block
37.460 + e.printStackTrace();
37.461 + } catch (IllegalAccessException e) {
37.462 + // TODO Auto-generated catch block
37.463 + e.printStackTrace();
37.464 + }
37.465 + if (model != null) {
37.466 + if (hasElement(model, typeOrElementQName)) {
37.467 + result = new SchemaUnit(wsdlUtilSchLoc.getFileLocation(),
37.468 + typeOrElementQName);
37.469 + return result;
37.470 + }
37.471 + }
37.472 +
37.473 + }
37.474 + }
37.475 + }
37.476 +
37.477 + }
37.478 + return result;
37.479 + }
37.480 +
37.481 + private static void populateWSDLOperation(com.sun.jbi.workflow.model.WSDLDefinition wsdlDef,
37.482 + WSDLMessage wsdlInMsg, Message taskOpnInMsg, File WSDLFileFromURI, File buildDir,
37.483 + File projectSourceDir, WSDLModel clientWSDLModel) {
37.484 +
37.485 + // Get the list of parts defined in the message
37.486 + List<Part> listOfParts = taskOpnInMsg.getOrderedParts(null);
37.487 + ArrayList listOfSchemaLocation = new ArrayList();
37.488 + Set<WSDL4JUtil.SchemaLocation> setOfSchemaLoc = null;//
37.489 + // Iterate each part
37.490 + for (Part taskPart : listOfParts) {
37.491 + // Create WSDLPart for each part
37.492 + WSDLPart wsdlPart = new WSDLPart();
37.493 + wsdlPart.setPartName(taskPart.getName());
37.494 + wsdlInMsg.addPart(wsdlPart);
37.495 + // Get the type name ( QName)
37.496 + QName taskPartTypeType = taskPart.getTypeName();
37.497 + QName taskPartElementType = taskPart.getElementName(); // taskPart.getTypeName();
37.498 + setOfSchemaLoc = new HashSet();
37.499 + WSDL4JUtil wsdlUtil = WSDL4JUtil.getInstance();
37.500 + QName typeOrElementQName = (taskPartElementType != null) ? taskPartElementType
37.501 + : taskPartTypeType;
37.502 + wsdlUtil.getSchemaLocations(wsdlDef, typeOrElementQName.getNamespaceURI(),
37.503 + WSDLFileFromURI, buildDir, projectSourceDir, setOfSchemaLoc);
37.504 +
37.505 + Iterator<WSDL4JUtil.SchemaLocation> schmLocItr = setOfSchemaLoc.iterator();
37.506 +
37.507 + if (schmLocItr.hasNext()) {
37.508 + WSDL4JUtil.SchemaLocation wsdlUtilSchLoc = schmLocItr.next();
37.509 + if (wsdlUtilSchLoc.isSimpleType()) {
37.510 + wsdlPart.setQueueName(taskPartTypeType);
37.511 + } else {
37.512 + String relativeLocation = wsdlUtilSchLoc.getRelativeLocation();
37.513 + String schLocURI = wsdlUtilSchLoc.getLocationURI();
37.514 + String schemaLocation = null;
37.515 + if (relativeLocation != null) {
37.516 + // Relative Location
37.517 + listOfSchemaLocation.add(relativeLocation);
37.518 + schemaLocation = relativeLocation;
37.519 + } else if (schLocURI != null) {
37.520 + // All other location that are not relative.
37.521 + listOfSchemaLocation.add(schLocURI);
37.522 + schemaLocation = schLocURI;
37.523 + }
37.524 + Schema schema = null;
37.525 + if ((schema = wsdlUtil.getImportedSchema(clientWSDLModel, wsdlUtilSchLoc)) == null) {
37.526 + // Add schema to Client WSDL
37.527 + Types wsdlTypes = clientWSDLModel.getDefinitions().getTypes();
37.528 + WSDLSchema wsdlSchema = clientWSDLModel.getFactory().createWSDLSchema();
37.529 + SchemaModel schemaModel = wsdlSchema.getSchemaModel();
37.530 + schema = schemaModel.getSchema();
37.531 + schema.setTargetNamespace(clientWSDLModel.getDefinitions()
37.532 + .getTargetNamespace());
37.533 + org.netbeans.modules.xml.schema.model.Import schemaImp = schemaModel
37.534 + .getFactory().createImport();
37.535 + schemaImp.setSchemaLocation(schemaLocation);
37.536 + schemaImp.setNamespace(wsdlUtilSchLoc.getNamespaceURI());
37.537 +
37.538 + schema.addExternalReference(schemaImp);
37.539 + if (wsdlSchema != null) {
37.540 + wsdlTypes.addExtensibilityElement(wsdlSchema);
37.541 + }
37.542 + }
37.543 +
37.544 + if (wsdlUtilSchLoc.isSimpleType()) {
37.545 + wsdlPart.setStandardXMLSchemaSimpleType(true);
37.546 + } else if (wsdlUtilSchLoc.getFileLocation() != null) {
37.547 + SchemaModel schModOfImportedSchema = SchemaManager.getInstance()
37.548 + .getSchemaModel(wsdlUtilSchLoc.getFileLocation());
37.549 + if (taskPartElementType != null) {
37.550 + Collection<GlobalElement> globElementColl = schModOfImportedSchema
37.551 + .getSchema().getElements();
37.552 + GlobalElement partElement = findSchemaElement(globElementColl,
37.553 + taskPartElementType);
37.554 + wsdlPart.setElement(partElement);
37.555 + } else {
37.556 + Collection<GlobalSimpleType> gst = schModOfImportedSchema.getSchema()
37.557 + .getSimpleTypes();
37.558 + GlobalType gt = findSimpleType(gst, taskPartTypeType);
37.559 + if (gt != null) {
37.560 + wsdlPart.setType(gt);
37.561 + } else {
37.562 + Collection<GlobalComplexType> gct = schModOfImportedSchema
37.563 + .getSchema().getComplexTypes();
37.564 + gt = findComplexTypes(gct, taskPartTypeType);
37.565 + if (gt != null) {
37.566 + wsdlPart.setType(gt);
37.567 + }
37.568 + }
37.569 +
37.570 + }
37.571 + }
37.572 +
37.573 + wsdlPart.setSchema(schema);
37.574 +
37.575 + }
37.576 + }
37.577 + }
37.578 + }
37.579 +
37.580 + public static GlobalElement findSchemaElement(Collection<GlobalElement> globElementColl,
37.581 + QName taskPartType) {
37.582 + for (GlobalElement gelem : globElementColl) {
37.583 + if (taskPartType.getLocalPart().equals(gelem.getName())) {
37.584 + return gelem;
37.585 + }
37.586 +
37.587 + }
37.588 + return null;
37.589 + }
37.590 +
37.591 + /*
37.592 + * private static QName findMatchingQName(String namespace, Map<Attribute> mapOfAttrNames) {
37.593 + * Iterator<Map.Entry> attrEntryMapItr = mapOfAttrNames.entrySet().iterator(); while
37.594 + * (attrEntryMapItr.hasNext()) { Attribute attr = attrEntryMapItr.next(); attr. if (attr.get
37.595 + * .getLocalPart().equals(namespace)) { return tempQName; } } return null; }
37.596 + */
37.597 +
37.598 + private static GlobalType findSimpleType(Collection<GlobalSimpleType> colSimpTypes,
37.599 + QName schemaType) {
37.600 + Iterator<GlobalSimpleType> gstItr = colSimpTypes.iterator();
37.601 + while (gstItr.hasNext()) {
37.602 + GlobalSimpleType gst = gstItr.next();
37.603 + if (gst.getName().equals(schemaType.getLocalPart())) {
37.604 + return gst;
37.605 + }
37.606 + }
37.607 + return null;
37.608 + }
37.609 +
37.610 + private static GlobalType findComplexTypes(Collection<GlobalComplexType> colCmplxTypes,
37.611 + QName schemaType) {
37.612 + Iterator<GlobalComplexType> gstItr = colCmplxTypes.iterator();
37.613 + while (gstItr.hasNext()) {
37.614 + GlobalComplexType gst = gstItr.next();
37.615 + if (gst.getName().equals(schemaType.getLocalPart())) {
37.616 + return gst;
37.617 + }
37.618 + }
37.619 + return null;
37.620 + }
37.621 +
37.622 + private static class SchemaUnit {
37.623 + private File schemaFile;
37.624 +
37.625 + private QName elementName;
37.626 +
37.627 + public SchemaUnit(File schemaFile, QName elementName) {
37.628 + this.schemaFile = schemaFile;
37.629 + this.elementName = elementName;
37.630 + }
37.631 +
37.632 + public QName getElementName() {
37.633 + return elementName;
37.634 + }
37.635 +
37.636 + public void setElementName(QName elementName) {
37.637 + this.elementName = elementName;
37.638 + }
37.639 +
37.640 + public File getSchemaFile() {
37.641 + return schemaFile;
37.642 + }
37.643 +
37.644 + public void setSchemaFile(File schemaFile) {
37.645 + this.schemaFile = schemaFile;
37.646 + }
37.647 +
37.648 + }
37.649 +
37.650 + private static XSModel loadSchema(String inputURI) throws java.lang.ClassNotFoundException,
37.651 + java.lang.InstantiationException, java.lang.IllegalAccessException {
37.652 +
37.653 + XSModel schema = null;
37.654 + // Get DOM Implementation using DOM Registry
37.655 + System.setProperty(DOMImplementationRegistry.PROPERTY,
37.656 + "org.apache.xerces.dom.DOMXSImplementationSourceImpl");
37.657 + DOMImplementationRegistry registry = DOMImplementationRegistry.newInstance();
37.658 + Object o = registry.getDOMImplementation("XS-Loader");
37.659 + if (o instanceof XSImplementation) {
37.660 + com.sun.org.apache.xerces.internal.xs.XSImplementation impl = (com.sun.org.apache.xerces.internal.xs.XSImplementation) o;
37.661 + com.sun.org.apache.xerces.internal.xs.XSLoader schemaLoader = impl.createXSLoader(null);
37.662 + schema = schemaLoader.loadURI(inputURI);
37.663 + }
37.664 + return schema;
37.665 + }
37.666 +
37.667 + public static boolean hasElement(XSModel schema, QName elementName) {
37.668 + return (schema.getElementDeclaration(elementName.getNamespaceURI(), elementName
37.669 + .getLocalPart()) != null);
37.670 + }
37.671 +
37.672 + public static org.xml.sax.XMLReader makeXMLReader() throws Exception {
37.673 + final javax.xml.parsers.SAXParserFactory saxParserFactory = javax.xml.parsers.SAXParserFactory
37.674 + .newInstance();
37.675 + final javax.xml.parsers.SAXParser saxParser = saxParserFactory.newSAXParser();
37.676 + final org.xml.sax.XMLReader parser = saxParser.getXMLReader();
37.677 + return parser;
37.678 + }
37.679 +
37.680 + private static class Sink extends org.xml.sax.helpers.DefaultHandler implements
37.681 + org.xml.sax.ContentHandler {
37.682 + private Map mMap = null;
37.683 +
37.684 + public Sink(Map map) {
37.685 + super();
37.686 + mMap = map;
37.687 + }
37.688 +
37.689 + public void startElement(String uri, String localName, String qName, Attributes attributes)
37.690 + throws SAXException {
37.691 + // TODO Auto-generated method stub
37.692 + if (qName.equals("mp:mapping")) {
37.693 + String path = "";
37.694 + String value = "";
37.695 + for (int i = 0; i < attributes.getLength(); i++) {
37.696 + String attName = attributes.getQName(i);
37.697 + if (attName.equals("path")) {
37.698 + path = attributes.getValue(i);
37.699 + } else if (attName.equals("value")) {
37.700 + value = attributes.getValue(i);
37.701 + }
37.702 + }
37.703 + mMap.put(path, value);
37.704 + }
37.705 + super.startElement(uri, localName, qName, attributes);
37.706 + }
37.707 + }
37.708 +
37.709 + public static void writeFile(String filename, String output, boolean append) throws IOException {
37.710 +
37.711 + BufferedWriter out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(
37.712 + filename, append), "UTF-8"));
37.713 +
37.714 + out.write(output);
37.715 + out.close();
37.716 + }
37.717 +
37.718 + public static void main(String[] args) {
37.719 + File workFlowFile = new File(
37.720 + "C:/Alaska/jbicomps/wlmweb/orbeon/sample/purchaseOrderReview/PurchaseOrderWorkflowApp/src/ApprovePurchase.wf");
37.721 + File buildDir = new File(
37.722 + "C:/Alaska/jbicomps/wlmweb/orbeon/sample/purchaseOrderReview/PurchaseOrderWorkflowApp/build");
37.723 + File projectSourceDir = new File(
37.724 + "C:/Alaska/jbicomps/wlmweb/orbeon/sample/purchaseOrderReview/PurchaseOrderWorkflowApp/src");
37.725 + try {
37.726 + generateXForm(workFlowFile, buildDir, projectSourceDir, true);
37.727 + } catch (Exception e) {
37.728 + // TODO Auto-generated catch block
37.729 + e.printStackTrace();
37.730 + }
37.731 + }
37.732 +
37.733 +}
38.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
38.2 +++ b/enterprise/openesbaddons/workflow/project/antsrc/org/netbeans/modules/workflow/project/anttasks/WSDL4JUtil.java Thu Apr 26 02:33:27 2007 +0000
38.3 @@ -0,0 +1,462 @@
38.4 +/* *************************************************************************
38.5 + *
38.6 + * Copyright (c) 2005, SeeBeyond Technology Corporation,
38.7 + * All Rights Reserved
38.8 + *
38.9 + * This program, and all the routines referenced herein,
38.10 + * are the proprietary properties and trade secrets of
38.11 + * SEEBEYOND TECHNOLOGY CORPORATION.
38.12 + *
38.13 + * Except as provided for by license agreement, this
38.14 + * program shall not be duplicated, used, or disclosed
38.15 + * without written consent signed by an officer of
38.16 + * SEEBEYOND TECHNOLOGY CORPORATION.
38.17 + *
38.18 + ***************************************************************************/
38.19 +package org.netbeans.modules.workflow.project.anttasks;
38.20 +
38.21 +import java.io.File;
38.22 +import java.io.PrintWriter;
38.23 +import java.util.Collection;
38.24 +import java.util.HashSet;
38.25 +import java.util.Iterator;
38.26 +import java.util.List;
38.27 +import java.util.Map;
38.28 +import java.util.Set;
38.29 +
38.30 +import javax.wsdl.Definition;
38.31 +import javax.wsdl.Types;
38.32 +import javax.wsdl.extensions.ExtensibilityElement;
38.33 +import javax.wsdl.extensions.schema.Schema;
38.34 +import javax.wsdl.extensions.schema.SchemaImport;
38.35 +import javax.xml.transform.OutputKeys;
38.36 +import javax.xml.transform.Transformer;
38.37 +import javax.xml.transform.TransformerFactory;
38.38 +import javax.xml.transform.dom.DOMSource;
38.39 +import javax.xml.transform.stream.StreamResult;
38.40 +
38.41 +import org.netbeans.modules.xml.wsdl.model.WSDLModel;
38.42 +import org.w3c.dom.Element;
38.43 +
38.44 +/**
38.45 + * Utility class for WSDL4J used in generation of client WSDL
38.46 + *
38.47 + * @author sgenipudi
38.48 + *
38.49 + */
38.50 +public class
38.51 +
38.52 +WSDL4JUtil {
38.53 + private static WSDL4JUtil mInstance = null;
38.54 + private static final String DIRSEP = "/";
38.55 + private static final String XSD_EXT = ".xsd";
38.56 + private static final String XSD_GEN_DELIM = "_";
38.57 +
38.58 + private WSDL4JUtil() {
38.59 + }
38.60 +
38.61 + public static WSDL4JUtil getInstance() {
38.62 + if (mInstance == null) {
38.63 + mInstance = new WSDL4JUtil();
38.64 + }
38.65 + return mInstance;
38.66 + }
38.67 +
38.68 + /**
38.69 + * Reads the wsdl file , searches for matching schema using the input
38.70 + * schemaNamespace and returns the list of physical locations of the
38.71 + * schema file relative to either project source directory or build directory
38.72 + * depending on the schema is imported or inline.
38.73 + *
38.74 + * If the schema is imported the location will be relative to project source directory
38.75 + * else relative to build directory as schema will be serialized to build directory if the
38.76 + * schema is inline in WSDL.
38.77 + *
38.78 + * @param wsdlDef WSDL Definition
38.79 + * @param schemaNameSpace Namespace of the schema
38.80 + * @param wsdlFileLocation File location of the WSDL .This must be relative to project source directory
38.81 + * @param buildDir build directory
38.82 + * @param projectSourceDirectory project source directory.
38.83 + * @return List of WSDL4JUtil.SchemaLocation
38.84 + */
38.85 + public
38.86 +
38.87 + Set<WSDL4JUtil.SchemaLocation> getSchemaLocations(Definition wsdlDef,
38.88 + String schemaNameSpace,
38.89 + File wsdlFileLocation,
38.90 + File buildDir,
38.91 + File projectSourceDirectory,
38.92 + Set<WSDL4JUtil.SchemaLocation> listOfSchLoc) {
38.93 +
38.94 + if (wsdlFileLocation == null || !wsdlFileLocation.exists()) {
38.95 + throw new RuntimeException(" WSDLFileLocation is invalid");
38.96 + }
38.97 + if (buildDir == null || !buildDir.exists()) {
38.98 + throw new RuntimeException(" Build directory is invalid");
38.99 + }
38.100 + if (schemaNameSpace == null) {
38.101 + return null;
38.102 + }
38.103 + String wsdlFileParentDirPath = wsdlFileLocation.getParent();
38.104 + if (wsdlFileParentDirPath == null) {
38.105 + throw new RuntimeException(" WSDLFileLocation is invalid");
38.106 + }
38.107 + Map wsdlNamespaceMap = wsdlDef.getNamespaces();
38.108 +
38.109 + wsdlFileParentDirPath = wsdlFileParentDirPath.replace('\\', '/');
38.110 + String projectSourceDirPath =
38.111 + projectSourceDirectory.getAbsolutePath().replace('\\', '/');
38.112 + String buildDirPath = buildDir.getAbsolutePath().replace('\\', '/');
38.113 +
38.114 +
38.115 + int ind1 = wsdlFileParentDirPath.indexOf(projectSourceDirPath);
38.116 + if (ind1 == -1) {
38.117 + throw new RuntimeException("WSDL Location is not relative to Project source directory");
38.118 + }
38.119 + String prjRelativeWSDLFileDirPath =
38.120 + wsdlFileParentDirPath.substring(ind1 +
38.121 + projectSourceDirPath.length());
38.122 +
38.123 + if (listOfSchLoc == null) {
38.124 + listOfSchLoc = new HashSet<WSDL4JUtil.SchemaLocation>();
38.125 + }
38.126 +
38.127 + //If the Schema is Standard XSD Simple Types
38.128 + if ( schemaNameSpace.equals("http://www.w3.org/2001/XMLSchema") ) {
38.129 + SchemaLocation schLoc =
38.130 + new SchemaLocation(null, null, null,
38.131 + false, schemaNameSpace);
38.132 + schLoc.setSimpleType(true);
38.133 + listOfSchLoc.add(schLoc);
38.134 + return listOfSchLoc;
38.135 +
38.136 + }
38.137 +
38.138 + Types types = wsdlDef.getTypes();
38.139 +
38.140 + List<ExtensibilityElement> listOfExElems =
38.141 + types.getExtensibilityElements();
38.142 + int inlineSchInd = 1;
38.143 + boolean bMatchingNSFound = false;
38.144 + for (ExtensibilityElement exElem: listOfExElems) {
38.145 + bMatchingNSFound = false;
38.146 + if (exElem instanceof javax.wsdl.extensions.schema.Schema) {
38.147 + Schema schm = (Schema)exElem;
38.148 + Map mapOfImports = schm.getImports();
38.149 + Element schmElem = schm.getElement();
38.150 + String schemaTNS = schmElem.getAttribute("targetNamespace");
38.151 + List listOfSchemaIncludes = schm.getIncludes();
38.152 + if (schemaTNS.equals(schemaNameSpace)) {
38.153 + bMatchingNSFound = true;
38.154 + }
38.155 + SchemaLocation schLoc = null;
38.156 + if (mapOfImports.size() > 0) {
38.157 + Iterator<Map.Entry> schImpItr =
38.158 + mapOfImports.entrySet().iterator();
38.159 + while (schImpItr.hasNext()) {
38.160 + Map.Entry schImpEntry = schImpItr.next();
38.161 + List<SchemaImport> listOfSchImp =
38.162 + (List)schImpEntry.getValue();
38.163 + for (SchemaImport schImp: listOfSchImp) {
38.164 + // Check if the schemalocation is File and
38.165 + // if it is relative
38.166 + // then find out the relative
38.167 + // location from project source directory
38.168 + // for other type of schema location
38.169 + // use the location as it is.
38.170 + File schemaFile = null;
38.171 + String schemaLocationURIString =
38.172 + schImp.getSchemaLocationURI();
38.173 + String schemaNamepsaceURI =
38.174 + schImp.getNamespaceURI();
38.175 + String relativeLocation = null;
38.176 + if (prjRelativeWSDLFileDirPath.equals("")) {
38.177 + relativeLocation = schemaLocationURIString;
38.178 + } else {
38.179 + relativeLocation = prjRelativeWSDLFileDirPath +
38.180 + DIRSEP +
38.181 + schemaLocationURIString.replace('\\','/' );
38.182 +
38.183 + }
38.184 + if (bMatchingNSFound ||
38.185 + (!bMatchingNSFound && schemaNamepsaceURI !=
38.186 + null &&
38.187 + schemaNamepsaceURI.equals(schemaNameSpace))) {
38.188 + bMatchingNSFound = true;
38.189 + try {
38.190 + schemaFile =
38.191 + new File(wsdlFileParentDirPath,
38.192 + schemaLocationURIString);
38.193 + if (schemaFile.exists()) {
38.194 + schLoc =
38.195 + new SchemaLocation(schemaLocationURIString,
38.196 + schemaFile,
38.197 + relativeLocation,
38.198 + true,
38.199 + schemaNamepsaceURI);
38.200 +
38.201 + } else {
38.202 + schemaFile =
38.203 + new File(schemaLocationURIString);
38.204 + if (schemaFile.exists()) {
38.205 + schLoc =
38.206 + new SchemaLocation(schemaLocationURIString,
38.207 + schemaFile,
38.208 + null,
38.209 + false,
38.210 + schemaNamepsaceURI);
38.211 + }
38.212 + }
38.213 + listOfSchLoc.add(schLoc);
38.214 + } catch (Exception ex) {
38.215 + schLoc =
38.216 + new SchemaLocation(schemaLocationURIString,
38.217 + null, null,
38.218 + false,
38.219 + schemaNamepsaceURI);
38.220 + listOfSchLoc.add(schLoc);
38.221 + }
38.222 + }
38.223 +
38.224 + }
38.225 +
38.226 + }
38.227 + } else {
38.228 + //Inline schema - Generate Schema.
38.229 + if (bMatchingNSFound) {
38.230 + String genSchemaFilePath =
38.231 + buildDir.getAbsolutePath() + DIRSEP +
38.232 + prjRelativeWSDLFileDirPath;
38.233 + String xsdFileName =
38.234 + wsdlFileLocation.getName().replace('.', '_') +
38.235 + XSD_GEN_DELIM + inlineSchInd + XSD_EXT;
38.236 + genSchemaFilePath =
38.237 + genSchemaFilePath.replace('\\', '/') + DIRSEP +
38.238 + xsdFileName;
38.239 + //Add missing namespace defenition to schema
38.240 + //as inline schema is saved as seperate file.
38.241 + addWSDLNamespacesToXMLElement(schmElem,
38.242 + wsdlNamespaceMap);
38.243 + writeXML(genSchemaFilePath, schmElem);
38.244 + File genSchemaFile = new File(genSchemaFilePath);
38.245 + if (genSchemaFile.exists()) {
38.246 + schLoc =
38.247 + new SchemaLocation(null, genSchemaFile, prjRelativeWSDLFileDirPath +
38.248 + DIRSEP + xsdFileName,
38.249 + false, schemaTNS);
38.250 + listOfSchLoc.add(schLoc);
38.251 + } else {
38.252 + throw new RuntimeException("Could not create " +
38.253 + genSchemaFilePath);
38.254 + }
38.255 + inlineSchInd++;
38.256 + } else {
38.257 + if ( schemaNameSpace.equals("http://www.w3.org/2001/XMLSchema")) {
38.258 + schLoc =
38.259 + new SchemaLocation(null, null, null,
38.260 + false, schemaNameSpace);
38.261 + schLoc.setSimpleType(true);
38.262 + listOfSchLoc.add(schLoc);
38.263 + inlineSchInd++;
38.264 + }
38.265 + }
38.266 +
38.267 + }
38.268 + }
38.269 +
38.270 +
38.271 + // exElem.
38.272 + }
38.273 + return listOfSchLoc;
38.274 + }
38.275 +
38.276 + public org.netbeans.modules.xml.schema.model.Schema getImportedSchema(WSDLModel wsdlModel, WSDL4JUtil.SchemaLocation schemaLoc ) {
38.277 + Collection<org.netbeans.modules.xml.schema.model.Schema> colSchema = wsdlModel.getDefinitions().getTypes().getSchemas();
38.278 + boolean bMatchingNSFound = false;
38.279 + String compareLocation = null;
38.280 + compareLocation = schemaLoc.getLocationURI();
38.281 +
38.282 + for (org.netbeans.modules.xml.schema.model.Schema exElem: colSchema) {
38.283 + bMatchingNSFound = false;
38.284 + org.netbeans.modules.xml.schema.model.Schema schm = (org.netbeans.modules.xml.schema.model.Schema)exElem;
38.285 + Collection<org.netbeans.modules.xml.schema.model.Import> mapOfImports = schm.getImports();
38.286 + SchemaLocation schLoc = null;
38.287 + if (mapOfImports.size() > 0) {
38.288 + Iterator<org.netbeans.modules.xml.schema.model.Import> schImpItr =
38.289 + mapOfImports.iterator();
38.290 + while (schImpItr.hasNext()) {
38.291 + org.netbeans.modules.xml.schema.model.Import schImp = schImpItr.next();
38.292 + String schemaLocationURIString = schImp.getSchemaLocation();
38.293 + if ( compareLocation.equals(schemaLocationURIString)) {
38.294 + return schm;
38.295 + }
38.296 + }
38.297 + }
38.298 +
38.299 + }
38.300 + return null;
38.301 +
38.302 +
38.303 + }
38.304 +
38.305 +
38.306 + private void addWSDLNamespacesToXMLElement(Element elem,
38.307 + Map mapOfNamespaces) {
38.308 + // NamedNodeMap nmMap = elem.getAttributes();
38.309 + Iterator<Map.Entry> nsMapEntryItr =
38.310 + mapOfNamespaces.entrySet().iterator();
38.311 + elem.setAttribute("xmlns", "http://schemas.xmlsoap.org/wsdl/");
38.312 + while (nsMapEntryItr.hasNext()) {
38.313 + Map.Entry nsMapEntry = nsMapEntryItr.next();
38.314 + String mapPrefix = (String)nsMapEntry.getKey();
38.315 + if (mapPrefix.equals("")) {
38.316 + continue;
38.317 + }
38.318 + String mapNS = (String)nsMapEntry.getValue();
38.319 + if (!elem.hasAttribute("xmlns:" + mapPrefix)) {
38.320 + elem.setAttribute("xmlns:" + mapPrefix, mapNS);
38.321 + }
38.322 + }
38.323 +
38.324 + }
38.325 +
38.326 + public static void writeXML(String genFile, Element elem) {
38.327 + PrintWriter pw = null;
38.328 + try {
38.329 + // Use a Transformer for output
38.330 + TransformerFactory tFactory = TransformerFactory.newInstance();
38.331 + Transformer transformer = tFactory.newTransformer();
38.332 + DOMSource source = new DOMSource(elem);
38.333 + pw = new PrintWriter(genFile, "UTF-8");
38.334 + StreamResult result = new StreamResult(pw);
38.335 +
38.336 + transformer.setOutputProperty(OutputKeys.METHOD, "xml"); // NOI18N
38.337 + transformer.setOutputProperty(OutputKeys.ENCODING,
38.338 + "UTF-8"); // NOI18N
38.339 + transformer.setOutputProperty(OutputKeys.MEDIA_TYPE,
38.340 + "text/xml"); // NOI18N
38.341 + transformer.setOutputProperty(OutputKeys.STANDALONE,
38.342 + "yes"); // NOI18N
38.343 +
38.344 + // indent the output to make it more legible...
38.345 + // transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4"); // NOI18N
38.346 + // transformer.setOutputProperty(OutputKeys.INDENT, "yes"); // NOI18N
38.347 + transformer.transform(source, result);
38.348 + } catch (Exception ex) {
38.349 +
38.350 + } finally {
38.351 + if (pw != null) {
38.352 + try {
38.353 + pw.flush();
38.354 + } catch (Exception ex) {
38.355 +
38.356 + }
38.357 +
38.358 + try {
38.359 + pw.close();
38.360 + } catch (Exception ex) {
38.361 +
38.362 + }
38.363 + }
38.364 + }
38.365 +
38.366 +
38.367 + }
38.368 +
38.369 + public class SchemaLocation {
38.370 + //Physical Location of the Schema File
38.371 + private File mPhysicalFileLocation = null;
38.372 + //Relative location of schema ( either to project or build dir)
38.373 + private String mRelativeLocation = null;
38.374 + //If mRelativeLocation is relative to Project source directory
38.375 + private boolean mbRelativeToPrjSrcDir = true;
38.376 + //Locaton URI
38.377 + private String mLocationURI = null;
38.378 + //Namespace URI
38.379 + private String mNamespaceURI = null;
38.380 +
38.381 + private boolean mbSimpleType = false;
38.382 +
38.383 + public SchemaLocation(String locationURI, File physicalFileLocation,
38.384 + String relativeLocation,
38.385 + boolean bRelativeToProject,
38.386 + String namespaceURI) {
38.387 + mLocationURI = locationURI;
38.388 + mPhysicalFileLocation = physicalFileLocation;
38.389 + mRelativeLocation = relativeLocation;
38.390 + mbRelativeToPrjSrcDir = bRelativeToProject;
38.391 + mNamespaceURI = namespaceURI;
38.392 +
38.393 + }
38.394 +
38.395 + public File getFileLocation() {
38.396 + return mPhysicalFileLocation;
38.397 + }
38.398 +
38.399 + public String getRelativeLocation() {
38.400 + return mRelativeLocation;
38.401 + }
38.402 +
38.403 + public String getLocationURI() {
38.404 + return mLocationURI;
38.405 + }
38.406 +
38.407 + public boolean isRelativeToProject() {
38.408 + return mbRelativeToPrjSrcDir;
38.409 + }
38.410 +
38.411 + public String getNamespaceURI() {
38.412 + return mNamespaceURI;
38.413 + }
38.414 +
38.415 + public boolean isSimpleType() {
38.416 + return mbSimpleType;
38.417 + }
38.418 +
38.419 + public void setSimpleType(boolean simpleType) {
38.420 + mbSimpleType = simpleType;
38.421 + }
38.422 +
38.423 + public int hashCode() {
38.424 + if (mNamespaceURI != null) {
38.425 + return mNamespaceURI.hashCode();
38.426 + }
38.427 + return 1;
38.428 +
38.429 + }
38.430 +
38.431 + public boolean equals(Object obj) {
38.432 + if (!(obj instanceof SchemaLocation)) {
38.433 + return false;
38.434 + }
38.435 + SchemaLocation compSchLoc = (SchemaLocation)obj;
38.436 + if (((mPhysicalFileLocation != null &&
38.437 + compSchLoc.getFileLocation() != null &&
38.438 + compSchLoc.getFileLocation().equals(mPhysicalFileLocation)) ||
38.439 + (mPhysicalFileLocation == null &&
38.440 + compSchLoc.getFileLocation() == null)) &&
38.441 + ((mRelativeLocation != null &&
38.442 + compSchLoc.getRelativeLocation() != null &&
38.443 + compSchLoc.getRelativeLocation().equals(mRelativeLocation)) ||
38.444 + (mRelativeLocation == null &&
38.445 + compSchLoc.getRelativeLocation() == null)) &&
38.446 + ((mNamespaceURI != null &&
38.447 + compSchLoc.getNamespaceURI() != null &&
38.448 + compSchLoc.getNamespaceURI().equals(mNamespaceURI)) ||
38.449 + (mNamespaceURI == null &&
38.450 + compSchLoc.getNamespaceURI() == null)) &&
38.451 + ((mLocationURI != null &&
38.452 + compSchLoc.getLocationURI() != null &&
38.453 + compSchLoc.getLocationURI().equals(mLocationURI)) ||
38.454 + (mLocationURI == null &&
38.455 + compSchLoc.getLocationURI() == null))) {
38.456 + return true;
38.457 + }
38.458 + return false;
38.459 +
38.460 +
38.461 + }
38.462 +
38.463 +
38.464 + }
38.465 +}
39.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
39.2 +++ b/enterprise/openesbaddons/workflow/project/antsrc/org/netbeans/modules/workflow/project/anttasks/WSDLGenerator.java Thu Apr 26 02:33:27 2007 +0000
39.3 @@ -0,0 +1,904 @@
39.4 +/* *************************************************************************
39.5 + *
39.6 + * Copyright (c) 2005, SeeBeyond Technology Corporation,
39.7 + * All Rights Reserved
39.8 + *
39.9 + * This program, and all the routines referenced herein,
39.10 + * are the proprietary properties and trade secrets of
39.11 + * SEEBEYOND TECHNOLOGY CORPORATION.
39.12 + *
39.13 + * Except as provided for by license agreement, this
39.14 + * program shall not be duplicated, used, or disclosed
39.15 + * without written consent signed by an officer of
39.16 + * SEEBEYOND TECHNOLOGY CORPORATION.
39.17 + *
39.18 + ***************************************************************************/
39.19 +package org.netbeans.modules.workflow.project.anttasks;
39.20 +
39.21 +import java.io.File;
39.22 +import java.io.FileWriter;
39.23 +import java.util.ArrayList;
39.24 +import java.util.Collection;
39.25 +import java.util.HashMap;
39.26 +import java.util.Iterator;
39.27 +
39.28 +import javax.xml.namespace.QName;
39.29 +
39.30 +import org.netbeans.modules.workflow.project.anttasks.wsdl.WSDLMessage;
39.31 +import org.netbeans.modules.workflow.project.anttasks.wsdl.WSDLOperation;
39.32 +import org.netbeans.modules.workflow.project.anttasks.wsdl.WSDLPart;
39.33 +import org.netbeans.modules.xml.schema.model.GlobalElement;
39.34 +import org.netbeans.modules.xml.schema.model.GlobalSimpleType;
39.35 +import org.netbeans.modules.xml.schema.model.GlobalType;
39.36 +import org.netbeans.modules.xml.schema.model.LocalType;
39.37 +import org.netbeans.modules.xml.schema.model.SchemaModel;
39.38 +import org.netbeans.modules.xml.schema.model.SchemaModelFactory;
39.39 +import org.netbeans.modules.xml.wsdl.model.Binding;
39.40 +import org.netbeans.modules.xml.wsdl.model.BindingFault;
39.41 +import org.netbeans.modules.xml.wsdl.model.BindingInput;
39.42 +import org.netbeans.modules.xml.wsdl.model.BindingOperation;
39.43 +import org.netbeans.modules.xml.wsdl.model.BindingOutput;
39.44 +import org.netbeans.modules.xml.wsdl.model.Definitions;
39.45 +import org.netbeans.modules.xml.wsdl.model.ExtensibilityElement;
39.46 +import org.netbeans.modules.xml.wsdl.model.Message;
39.47 +import org.netbeans.modules.xml.wsdl.model.Operation;
39.48 +import org.netbeans.modules.xml.wsdl.model.Part;
39.49 +import org.netbeans.modules.xml.wsdl.model.Port;
39.50 +import org.netbeans.modules.xml.wsdl.model.RequestResponseOperation;
39.51 +import org.netbeans.modules.xml.wsdl.model.Service;
39.52 +import org.netbeans.modules.xml.wsdl.model.WSDLModel;
39.53 +import org.netbeans.modules.xml.wsdl.model.extensions.bpel.BPELComponentFactory;
39.54 +import org.netbeans.modules.xml.wsdl.model.extensions.bpel.PartnerLinkType;
39.55 +import org.netbeans.modules.xml.wsdl.model.extensions.bpel.Role;
39.56 +import org.netbeans.modules.xml.wsdl.model.extensions.soap.SOAPAddress;
39.57 +import org.netbeans.modules.xml.wsdl.model.extensions.soap.SOAPBinding;
39.58 +import org.netbeans.modules.xml.wsdl.model.extensions.soap.SOAPBody;
39.59 +import org.netbeans.modules.xml.wsdl.model.extensions.soap.SOAPFault;
39.60 +import org.netbeans.modules.xml.wsdl.model.extensions.soap.SOAPMessageBase;
39.61 +import org.netbeans.modules.xml.wsdl.model.extensions.soap.SOAPOperation;
39.62 +import org.netbeans.modules.xml.xam.Referenceable;
39.63 +import org.netbeans.modules.xml.xam.dom.NamedComponentReference;
39.64 +
39.65 +/**
39.66 + * @author sgenipudi
39.67 + */
39.68 +public class WSDLGenerator {
39.69 +
39.70 + private ArrayList mListOfOperations = new ArrayList();
39.71 + private WSDLModel mClientWSDLModel = null;
39.72 + private File mProjectDir = null;
39.73 + private String mProjectName = null;
39.74 + private static final String CLIENTWSDL_NS_TEMPLATE_PREFIX =
39.75 + "http://jbi.com.sun/wfse/wsdl/";
39.76 + private static final String CLIENTWSDL_NS_TEMPLATE_SUFFIX = "_wf_client";
39.77 + private static final String WSDL_EXT = ".wsdl";
39.78 + private static final String CLIENTWSDL_DEF_NAME_TEMPLATE_SUFFIX =
39.79 + "WFClient";
39.80 + private File mBuildDir = null;
39.81 + private static boolean mbCommandline = false;
39.82 + private org.netbeans.modules.xml.schema.model.Schema mClientWSDLSchema =
39.83 + null;
39.84 + private long mClientWSDLLastSavedTime = 0l;
39.85 + private File mClientFile = null;
39.86 + private HashMap<String, org.netbeans.modules.xml.wsdl.model.Message> mMapOfOpnToMessage =
39.87 + new HashMap<String, org.netbeans.modules.xml.wsdl.model.Message>();
39.88 +
39.89 + public WSDLGenerator() {
39.90 + }
39.91 +
39.92 + public static void setCommandlineMode(boolean value) {
39.93 + mbCommandline = value;
39.94 + }
39.95 +
39.96 + public static boolean isCommandlineMode() {
39.97 + return mbCommandline;
39.98 + }
39.99 +
39.100 + public void generate(String projectName, File projectDir, File buildDir,
39.101 + File clientWSDL) {
39.102 + //Get the static WSDL File
39.103 + //Build will copy the static wsdl to build directory
39.104 + //assume the template is already there in the build directory.
39.105 + this.mProjectDir = projectDir;
39.106 + this.mBuildDir = buildDir;
39.107 + this.mProjectName = projectName;
39.108 + this.mClientWSDLLastSavedTime = clientWSDL.lastModified();
39.109 + this.mClientFile = clientWSDL;
39.110 +
39.111 + //copy this file to build dir
39.112 + mClientWSDLModel = WSDLManager.getInstance().getWSDLModel(clientWSDL);
39.113 + initializeClientWSDLModel(projectName);
39.114 + //Scan the project dir and process each workflow files
39.115 + // Load Static Task Client WSDL Template
39.116 + // Set defenition Name/ TargetName space in the defenitions
39.117 +
39.118 + // From Workflow file,
39.119 + // get the Operation
39.120 + // From Operation get the WSDL Model
39.121 + // From Operation
39.122 + // get the Input and
39.123 + // Output messages
39.124 + // For each Input and Output message
39.125 + // Get the part information
39.126 + // Get the schema type for each part
39.127 + // If the schema is File then get the File information
39.128 + // If this is inline schema then serialize the schema to File
39.129 + // and store the File Information
39.130 +
39.131 + // Proper Datastructure is needed to accomodate this
39.132 + // Operation Class - with 3 members OperationName,
39.133 + // TaskName , Input and Output Message
39.134 + // Message Class - With list Of Parts
39.135 + // Each PartClass with 3 members
39.136 + // PartName
39.137 + // QName of the ElementType
39.138 + // File location of the schema
39.139 + // Import the Schema File to Gen WSDL and get the QName for it
39.140 + // and store.
39.141 + //
39.142 + // Populate the Operation Class for each task and workflow file
39.143 + // Iterate the operations
39.144 + // For each operation Name
39.145 + // 3 operations has to be created.
39.146 + // opn1: Get<TaskName_opnName>Input
39.147 + // 3 messages
39.148 + // TaskName_opnNameInputMessage1
39.149 + // <part name="taskId" element="ns1:taskIdentifer"/>
39.150 + // TaskName_opnNameOutputMessage1
39.151 + // part is Operation's input message
39.152 + // FaultMessage
39.153 + // opn2: Get<opnName>Output
39.154 + // TaskName_opnNameInputMessage2
39.155 + // <part name="taskId" element="ns1:taskIdentifer"/>
39.156 + // TaskName_opnNameOutputMessage2
39.157 + // part is Operation's output message
39.158 + // FaultMessage
39.159 + // opn3: set<OpnName>Output
39.160 + // TaskName_opnNameInputMessage3
39.161 + // <part name="taskId" element="ns1:taskIdentifer"/>
39.162 + // part is operation's output message
39.163 + // and for each operation 2 messages and the last one one message
39.164 + //
39.165 + // Create InputMessage1/OutputMessage1
39.166 + // Create Get<opn>Input
39.167 + // Create binding with HTTP://soapbc
39.168 + // Create InputMessage2/OutMsg2
39.169 + // Create Get<opn>Output
39.170 + // Create InputMessg3
39.171 + // Create set<opn>Out
39.172 + //
39.173 +
39.174 + //Implementation start:
39.175 + // Iterate the source directory and find out each Task Workflow files
39.176 + processSourceDir();
39.177 + javax.swing.text.Document doc = null;
39.178 +
39.179 + try {
39.180 + doc = this.mClientWSDLModel.getBaseDocument();
39.181 + } catch (Exception ex) {
39.182 +
39.183 + }
39.184 + this.mClientWSDLModel.endTransaction();
39.185 + //this.mClientFile.setLastModified(this.mClientWSDLLastSavedTime);
39.186 +
39.187 +
39.188 + //addOperationToClientWSDL(listOfOperations);
39.189 + FileWriter writer = null;
39.190 + try {
39.191 + File clientWSDLFile =
39.192 + new File(this.mBuildDir, this.mProjectName + "_wf_client.wsdl");
39.193 +
39.194 + writer = new FileWriter(clientWSDLFile);
39.195 + writer.write(doc.getText(0, doc.getLength()));
39.196 + writer.flush();
39.197 + writer.close();
39.198 + } catch (Exception ex) {
39.199 + throw new RuntimeException("Error during sync operation of client WSDL");
39.200 + } finally {
39.201 + try {
39.202 + writer.close();
39.203 + } catch (Exception e1) {
39.204 + }
39.205 + writer = null;
39.206 + }
39.207 +
39.208 +
39.209 + }
39.210 +
39.211 + /**
39.212 + * Proces the source directory to generate JBI.xml
39.213 + * @param sourceDir
39.214 + */
39.215 + private void processSourceDir() {
39.216 + processFileObject(this.mProjectDir);
39.217 + }
39.218 +
39.219 + /**
39.220 + * Process the file object to generate JBI.xml
39.221 + * @param file BPEL file location
39.222 + */
39.223 + private void processFileObject(File file) {
39.224 + if (file.isDirectory()) {
39.225 + processFolder(file);
39.226 + } else {
39.227 + processFile(file);
39.228 + }
39.229 + }
39.230 +
39.231 + /**
39.232 + * Process the folder to generate JBI.xml
39.233 + * @param fileDir Folder location
39.234 + */
39.235 + private void processFolder(File fileDir) {
39.236 + File[] children = fileDir.listFiles();
39.237 +
39.238 + for (int i = 0; i < children.length; i++) {
39.239 + processFileObject(children[i]);
39.240 + }
39.241 + }
39.242 +
39.243 + /**
39.244 + * Process the file to generate JBI.xml
39.245 + * @param file input file
39.246 + */
39.247 + protected void processFile(File file) {
39.248 + String fileName = file.getName();
39.249 + String fileExtension = null;
39.250 + int dotIndex = fileName.lastIndexOf('.');
39.251 + if (dotIndex != -1) {
39.252 + fileExtension = fileName.substring(dotIndex + 1);
39.253 + }
39.254 +
39.255 + if (fileExtension != null && fileExtension.equalsIgnoreCase("wf")) {
39.256 + ArrayList<WSDLOperation> listOfOperations =
39.257 + new ArrayList<WSDLOperation>();
39.258 + Util.addOperationInfo(file, listOfOperations,
39.259 + this.mClientWSDLModel, this.mBuildDir,
39.260 + this.mProjectDir);
39.261 +
39.262 + for (WSDLOperation wsdlOp: listOfOperations) {
39.263 + String operationName = wsdlOp.getOperationName();
39.264 + String taskName = wsdlOp.getTaskName();
39.265 + String generatedOpnName = "Get" + operationName + "Input";
39.266 + //Create new port type
39.267 + org.netbeans.modules.xml.wsdl.model.PortType clientWSDLPortType = this.mClientWSDLModel.getFactory().createPortType();
39.268 + clientWSDLPortType.setName(wsdlOp.getPortTypeName().getLocalPart());
39.269 + this.mClientWSDLModel.getDefinitions().addPortType(clientWSDLPortType);
39.270 +
39.271 +
39.272 + RequestResponseOperation reqResOpn =
39.273 + this.mClientWSDLModel.getFactory().createRequestResponseOperation();
39.274 + reqResOpn.setName(generatedOpnName);
39.275 + org.netbeans.modules.xml.wsdl.model.Input opn1Inp1 =
39.276 + this.mClientWSDLModel.getFactory().createInput();
39.277 + org.netbeans.modules.xml.wsdl.model.Message taskIdMsg =
39.278 + this.getTaskIdMessage(taskName); //getMessage("TaskIdMsg");
39.279 +
39.280 + NamedComponentReference opn1Inp1NCR =
39.281 + reqResOpn.createReferenceTo(taskIdMsg,
39.282 + org.netbeans.modules.xml.wsdl.model.Message.class);
39.283 + opn1Inp1.setMessage(opn1Inp1NCR);
39.284 + opn1Inp1.setName(operationName + "InputMsg");
39.285 + reqResOpn.setInput(opn1Inp1);
39.286 + //Output Message
39.287 + String msg2Opn1Name = operationName + "InputData";
39.288 + org.netbeans.modules.xml.wsdl.model.Output opn1out1 =
39.289 + this.mClientWSDLModel.getFactory().createOutput();
39.290 +
39.291 + Message msg1Opn1 =
39.292 + this.mClientWSDLModel.getFactory().createMessage();
39.293 + msg1Opn1.setName(msg2Opn1Name);
39.294 +
39.295 + WSDLMessage inMsg = wsdlOp.getInputWSDLMessage();
39.296 + ArrayList<WSDLPart> listOfParts = inMsg.getParts();
39.297 + int in = 0;
39.298 + for (WSDLPart wsdlPart: listOfParts) {
39.299 + Part msg1Opn1Part1 =
39.300 + this.mClientWSDLModel.getFactory().createPart();
39.301 + if (in == 0) {
39.302 + msg1Opn1Part1.setName("inputMsg");
39.303 +
39.304 + } else {
39.305 + msg1Opn1Part1.setName("inputMsg" + in);
39.306 + }
39.307 + in++;
39.308 + if (wsdlPart.getElement() != null) {
39.309 + GlobalType msg1Opn1Part1Type1 =
39.310 + craeteOrGetSchemaTypeInClientWSDL(wsdlPart.getElement());
39.311 + msg1Opn1Part1.setType(msg1Opn1Part1.createSchemaReference(msg1Opn1Part1Type1,
39.312 + GlobalType.class));
39.313 + msg1Opn1.addPart(msg1Opn1Part1);
39.314 + } else {
39.315 + if (wsdlPart.isStandardXMLSchemaSimpleTypes()) {
39.316 + GlobalType msg1OpnPart1Type1 =
39.317 + createGlobalSimpleType(wsdlPart.getQueueName());
39.318 + msg1Opn1Part1.setType(msg1Opn1Part1.createSchemaReference(msg1OpnPart1Type1,
39.319 + GlobalType.class));
39.320 + msg1Opn1.addPart(msg1Opn1Part1);
39.321 + } else {
39.322 + GlobalType msg1OpnPart1Type1 = wsdlPart.getType();
39.323 + msg1Opn1Part1.setType(msg1Opn1Part1.createSchemaReference(msg1OpnPart1Type1,
39.324 + GlobalType.class));
39.325 + msg1Opn1.addPart(msg1Opn1Part1);
39.326 + }
39.327 + }
39.328 + }
39.329 +
39.330 + NamedComponentReference msg1Opn1NCR =
39.331 + reqResOpn.createReferenceTo(msg1Opn1,
39.332 + org.netbeans.modules.xml.wsdl.model.Message.class);
39.333 + opn1out1.setMessage(msg1Opn1NCR);
39.334 + opn1out1.setName(operationName + "OutputMsg");
39.335 + reqResOpn.setOutput(opn1out1);
39.336 +
39.337 + org.netbeans.modules.xml.wsdl.model.Fault flt =
39.338 + this.mClientWSDLModel.getFactory().createFault();
39.339 + org.netbeans.modules.xml.wsdl.model.Message faultMsg =
39.340 + getFaultMessage(); //getMessage("OptFaultMsg");
39.341 + NamedComponentReference msgFaultNCR =
39.342 + reqResOpn.createReferenceTo(faultMsg,
39.343 + org.netbeans.modules.xml.wsdl.model.Message.class);
39.344 + flt.setMessage(msgFaultNCR);
39.345 + flt.setName("fault1");
39.346 + reqResOpn.addFault(flt);
39.347 +
39.348 + this.mClientWSDLModel.getDefinitions().addMessage(msg1Opn1);
39.349 + clientWSDLPortType.addOperation(reqResOpn);
39.350 + NamedComponentReference ncrPortType =
39.351 + this.mClientWSDLModel.getDefinitions().createReferenceTo(clientWSDLPortType,
39.352 + org.netbeans.modules.xml.wsdl.model.PortType.class);
39.353 +
39.354 + Binding colBinding = this.mClientWSDLModel.getFactory().createBinding();
39.355 + colBinding.setName(taskName);
39.356 + colBinding.setType(ncrPortType);
39.357 + this.mClientWSDLModel.getDefinitions().addBinding(colBinding);
39.358 + BindingInput binIn =
39.359 + this.mClientWSDLModel.getFactory().createBindingInput();
39.360 + BindingOutput binOut =
39.361 + this.mClientWSDLModel.getFactory().createBindingOutput();
39.362 +
39.363 + BindingFault binFault =
39.364 + this.mClientWSDLModel.getFactory().createBindingFault();
39.365 + binFault.setName(flt.getName());
39.366 +
39.367 + BindingOperation bindOp =
39.368 + this.mClientWSDLModel.getFactory().createBindingOperation();
39.369 + bindOp.setOperation(colBinding.createReferenceTo(reqResOpn,
39.370 + Operation.class));
39.371 + bindOp.setBindingInput(binIn);
39.372 + bindOp.setBindingOutput(binOut);
39.373 + bindOp.addBindingFault(binFault);
39.374 + colBinding.addBindingOperation(bindOp);
39.375 +
39.376 + SOAPBinding spBnd = this.mClientWSDLModel.getFactory().createSOAPBinding();
39.377 + spBnd.setStyle(SOAPBinding.Style.RPC);
39.378 + spBnd.setTransportURI("http://schemas.xmlsoap.org/soap/http");
39.379 + colBinding.addExtensibilityElement(spBnd);
39.380 +
39.381 + SOAPOperation spOpn =
39.382 + this.mClientWSDLModel.getFactory().createSOAPOperation();
39.383 + spOpn.setSoapAction(generatedOpnName);
39.384 + bindOp.addExtensibilityElement(spOpn);
39.385 +
39.386 + SOAPBody spBdy =
39.387 + this.mClientWSDLModel.getFactory().createSOAPBody();
39.388 +
39.389 + SOAPFault spFault =
39.390 + this.mClientWSDLModel.getFactory().createSOAPFault();
39.391 + spFault.setName("fault1");
39.392 + spFault.setUse(SOAPMessageBase.Use.LITERAL);
39.393 +
39.394 + spBdy = this.mClientWSDLModel.getFactory().createSOAPBody();
39.395 + spBdy.setNamespace(mClientWSDLModel.getDefinitions().getTargetNamespace());
39.396 +
39.397 + spBdy.setUse(SOAPMessageBase.Use.LITERAL);
39.398 + binIn.addExtensibilityElement(spBdy);
39.399 + spBdy = this.mClientWSDLModel.getFactory().createSOAPBody();
39.400 + spBdy.setNamespace(mClientWSDLModel.getDefinitions().getTargetNamespace());
39.401 +
39.402 + binOut.addExtensibilityElement(spBdy);
39.403 + binFault.addExtensibilityElement(spFault);
39.404 +
39.405 + //2ND MESSAGE
39.406 + generatedOpnName = "Get" + taskName + "Output";
39.407 + reqResOpn =
39.408 + this.mClientWSDLModel.getFactory().createRequestResponseOperation();
39.409 + reqResOpn.setName(generatedOpnName);
39.410 + opn1Inp1 = this.mClientWSDLModel.getFactory().createInput();
39.411 + //------------
39.412 +
39.413 + opn1Inp1NCR =
39.414 + reqResOpn.createReferenceTo(taskIdMsg, org.netbeans.modules.xml.wsdl.model.Message.class);
39.415 + opn1Inp1.setMessage(opn1Inp1NCR);
39.416 + opn1Inp1.setName(operationName + "InputMsg1");
39.417 + reqResOpn.setInput(opn1Inp1);
39.418 +
39.419 + msg2Opn1Name = operationName + "OutputData";
39.420 + opn1out1 = this.mClientWSDLModel.getFactory().createOutput();
39.421 +
39.422 + msg1Opn1 = this.mClientWSDLModel.getFactory().createMessage();
39.423 + msg1Opn1.setName(msg2Opn1Name);
39.424 +
39.425 + inMsg = wsdlOp.getOutputWSDLMessage();
39.426 + listOfParts = inMsg.getParts();
39.427 + in = 0;
39.428 + for (WSDLPart wsdlPart: listOfParts) {
39.429 + Part msg1Opn1Part1 =
39.430 + this.mClientWSDLModel.getFactory().createPart();
39.431 + if (in == 0) {
39.432 + msg1Opn1Part1.setName("outputMsg");
39.433 + } else {
39.434 + msg1Opn1Part1.setName("outputMsg" + in);
39.435 + }
39.436 + in++;
39.437 + if (wsdlPart.getElement() != null) {
39.438 + GlobalType msg1Opn1Part1Type1 =
39.439 + craeteOrGetSchemaTypeInClientWSDL(wsdlPart.getElement());
39.440 + msg1Opn1Part1.setType(msg1Opn1Part1.createSchemaReference(msg1Opn1Part1Type1,
39.441 + GlobalType.class));
39.442 + msg1Opn1.addPart(msg1Opn1Part1);
39.443 + } else {
39.444 + if (wsdlPart.isStandardXMLSchemaSimpleTypes()) {
39.445 + GlobalType msg1OpnPart1Type1 =
39.446 + createGlobalSimpleType(wsdlPart.getQueueName());
39.447 + msg1Opn1Part1.setType(msg1Opn1Part1.createSchemaReference(msg1OpnPart1Type1,
39.448 + GlobalType.class));
39.449 + msg1Opn1.addPart(msg1Opn1Part1);
39.450 + } else {
39.451 + GlobalType msg1OpnPart1Type1 = wsdlPart.getType();
39.452 + msg1Opn1Part1.setType(msg1Opn1Part1.createSchemaReference(msg1OpnPart1Type1,
39.453 + GlobalType.class));
39.454 + msg1Opn1.addPart(msg1Opn1Part1);
39.455 + }
39.456 + }
39.457 + }
39.458 +
39.459 + msg1Opn1NCR =
39.460 + reqResOpn.createReferenceTo(msg1Opn1, org.netbeans.modules.xml.wsdl.model.Message.class);
39.461 + opn1out1.setMessage(msg1Opn1NCR);
39.462 + opn1out1.setName(operationName + "OutputMsg1");
39.463 + reqResOpn.setOutput(opn1out1);
39.464 +
39.465 + flt = this.mClientWSDLModel.getFactory().createFault();
39.466 + msgFaultNCR =
39.467 + reqResOpn.createReferenceTo(faultMsg, org.netbeans.modules.xml.wsdl.model.Message.class);
39.468 + flt.setMessage(msgFaultNCR);
39.469 + flt.setName("fault1");
39.470 + reqResOpn.addFault(flt);
39.471 +
39.472 + this.mClientWSDLModel.getDefinitions().addMessage(msg1Opn1);
39.473 + clientWSDLPortType.addOperation(reqResOpn);
39.474 +
39.475 + binIn =
39.476 + this.mClientWSDLModel.getFactory().createBindingInput();
39.477 + binOut =
39.478 + this.mClientWSDLModel.getFactory().createBindingOutput();
39.479 +
39.480 + binFault =
39.481 + this.mClientWSDLModel.getFactory().createBindingFault();
39.482 + binFault.setName(flt.getName());
39.483 +
39.484 +
39.485 + bindOp =
39.486 + this.mClientWSDLModel.getFactory().createBindingOperation();
39.487 + bindOp.setOperation(colBinding.createReferenceTo(reqResOpn,
39.488 + Operation.class));
39.489 + bindOp.setBindingInput(binIn);
39.490 + bindOp.setBindingOutput(binOut);
39.491 + bindOp.addBindingFault(binFault);
39.492 + colBinding.addBindingOperation(bindOp);
39.493 +
39.494 + spOpn =
39.495 + this.mClientWSDLModel.getFactory().createSOAPOperation();
39.496 + spOpn.setSoapAction(generatedOpnName);
39.497 + bindOp.addExtensibilityElement(spOpn);
39.498 +
39.499 + spBdy = this.mClientWSDLModel.getFactory().createSOAPBody();
39.500 +
39.501 + spFault = this.mClientWSDLModel.getFactory().createSOAPFault();
39.502 + spFault.setName("fault1");
39.503 + spFault.setUse(SOAPMessageBase.Use.LITERAL);
39.504 +
39.505 + spBdy = this.mClientWSDLModel.getFactory().createSOAPBody();
39.506 + spBdy.setNamespace(mClientWSDLModel.getDefinitions().getTargetNamespace());
39.507 +
39.508 + spBdy.setUse(SOAPMessageBase.Use.LITERAL);
39.509 + binIn.addExtensibilityElement(spBdy);
39.510 + spBdy = this.mClientWSDLModel.getFactory().createSOAPBody();
39.511 + spBdy.setNamespace(mClientWSDLModel.getDefinitions().getTargetNamespace());
39.512 +
39.513 + binOut.addExtensibilityElement(spBdy);
39.514 + binFault.addExtensibilityElement(spFault);
39.515 +
39.516 + //3
39.517 + generatedOpnName = "Set" + operationName + "Output";
39.518 + reqResOpn =
39.519 + this.mClientWSDLModel.getFactory().createRequestResponseOperation();
39.520 +
39.521 + //OneWayOperation oneWayOpn = this.mClientWSDLModel.getFactory().createOneWayOperation();
39.522 + reqResOpn.setName(generatedOpnName);
39.523 +
39.524 + opn1Inp1 = this.mClientWSDLModel.getFactory().createInput();
39.525 +
39.526 + org.netbeans.modules.xml.wsdl.model.Message inputMsg3 =
39.527 + this.mClientWSDLModel.getFactory().createMessage();
39.528 + org.netbeans.modules.xml.wsdl.model.Part inputMsg3Part1 =
39.529 + this.mClientWSDLModel.getFactory().createPart();
39.530 + NamedComponentReference ncr;
39.531 + ncr = getElementOrType(getMessage("TaskIdMsg"), "taskId");
39.532 + Referenceable ncrRef = ncr.get();
39.533 + if (ncrRef instanceof GlobalElement) {
39.534 + inputMsg3Part1.setElement(ncr);
39.535 + } else {
39.536 + inputMsg3Part1.setType(ncr);
39.537 + }
39.538 + // inputMsg3Part1.setElement(ncr);
39.539 + inputMsg3Part1.setName("taskId");
39.540 + inputMsg3.addPart(inputMsg3Part1);
39.541 +
39.542 +
39.543 + inputMsg3.setName("Set" + taskName + "OutputData");
39.544 + inMsg = wsdlOp.getOutputWSDLMessage();
39.545 + listOfParts = inMsg.getParts();
39.546 + in = 0;
39.547 + for (WSDLPart wsdlPart: listOfParts) {
39.548 + Part msg1Opn1Part1 =
39.549 + this.mClientWSDLModel.getFactory().createPart();
39.550 + if (in == 0) {
39.551 + msg1Opn1Part1.setName("outputMsg");
39.552 + } else {
39.553 + msg1Opn1Part1.setName("inputMsg" + (in++));
39.554 + }
39.555 + if (wsdlPart.getElement() != null) {
39.556 + GlobalType msg1Opn1Part1Type1 =
39.557 + craeteOrGetSchemaTypeInClientWSDL(wsdlPart.getElement());
39.558 + msg1Opn1Part1.setType(msg1Opn1Part1.createSchemaReference(msg1Opn1Part1Type1,
39.559 + GlobalType.class));
39.560 + inputMsg3.addPart(msg1Opn1Part1);
39.561 + } else {
39.562 + if (wsdlPart.isStandardXMLSchemaSimpleTypes()) {
39.563 + GlobalType msg1OpnPart1Type1 =
39.564 + createGlobalSimpleType(wsdlPart.getQueueName());
39.565 + msg1Opn1Part1.setType(msg1Opn1Part1.createSchemaReference(msg1OpnPart1Type1,
39.566 + GlobalType.class));
39.567 + inputMsg3.addPart(msg1Opn1Part1);
39.568 + } else {
39.569 + GlobalType msg1OpnPart1Type1 = wsdlPart.getType();
39.570 + msg1Opn1Part1.setType(msg1Opn1Part1.createSchemaReference(msg1OpnPart1Type1,
39.571 + GlobalType.class));
39.572 + inputMsg3.addPart(msg1Opn1Part1);
39.573 + }
39.574 + }
39.575 + }
39.576 +
39.577 + ncr =
39.578 +reqResOpn.createReferenceTo(inputMsg3, org.netbeans.modules.xml.wsdl.model.Message.class);
39.579 + opn1Inp1.setMessage(ncr);
39.580 + opn1Inp1.setName(taskName + "InputMsg2");
39.581 + reqResOpn.setInput(opn1Inp1);
39.582 +
39.583 + //output
39.584 + msg2Opn1Name = operationName + "InputData";
39.585 + opn1out1 = this.mClientWSDLModel.getFactory().createOutput();
39.586 +
39.587 + Message resultCodeMsg = this.getMessage("SetOptOutput_Output");
39.588 + opn1out1.setMessage(reqResOpn.createReferenceTo(resultCodeMsg,
39.589 + Message.class));
39.590 + opn1out1.setName(taskName + "OutputMsg2");
39.591 + reqResOpn.setOutput(opn1out1);
39.592 + clientWSDLPortType.addOperation(reqResOpn);
39.593 + this.mClientWSDLModel.getDefinitions().addMessage(inputMsg3);
39.594 + binIn =
39.595 + this.mClientWSDLModel.getFactory().createBindingInput();
39.596 + binOut =
39.597 + this.mClientWSDLModel.getFactory().createBindingOutput();
39.598 +
39.599 + bindOp =
39.600 + this.mClientWSDLModel.getFactory().createBindingOperation();
39.601 +
39.602 + bindOp.setOperation(colBinding.createReferenceTo(reqResOpn,
39.603 + Operation.class));
39.604 + bindOp.setBindingInput(binIn);
39.605 + bindOp.setBindingOutput(binOut);
39.606 +
39.607 + colBinding.addBindingOperation(bindOp);
39.608 + spOpn =
39.609 + this.mClientWSDLModel.getFactory().createSOAPOperation();
39.610 + spOpn.setSoapAction(generatedOpnName);
39.611 +
39.612 + ///
39.613 + bindOp.addExtensibilityElement(spOpn);
39.614 +
39.615 + spBdy = this.mClientWSDLModel.getFactory().createSOAPBody();
39.616 + spBdy.setUse(SOAPMessageBase.Use.LITERAL);
39.617 + spBdy.setNamespace(mClientWSDLModel.getDefinitions().getTargetNamespace());
39.618 + binIn.addExtensibilityElement(spBdy);
39.619 +
39.620 +
39.621 + spBdy = this.mClientWSDLModel.getFactory().createSOAPBody();
39.622 + spBdy.setUse(SOAPMessageBase.Use.LITERAL);
39.623 + spBdy.setNamespace(mClientWSDLModel.getDefinitions().getTargetNamespace());
39.624 + binOut.addExtensibilityElement(spBdy);
39.625 +
39.626 + //Add Service
39.627 + Service service =
39.628 + (Service)this.mClientWSDLModel.getDefinitions().getServices().iterator().next();
39.629 +
39.630 + Port port = this.mClientWSDLModel.getFactory().createPort();
39.631 + port.setName("Task" + mProjectName + "ClientPort");
39.632 + NamedComponentReference ncrBinding =
39.633 + this.mClientWSDLModel.getDefinitions().createReferenceTo(colBinding,
39.634 + org.netbeans.modules.xml.wsdl.model.Binding.class);
39.635 +
39.636 + port.setBinding(ncrBinding);
39.637 + service.addPort(port);
39.638 + // port.
39.639 + SOAPAddress soapAddrs =
39.640 + this.mClientWSDLModel.getFactory().createSOAPAddress();
39.641 + soapAddrs.setLocation("http://localhost:18181/wfse/" +
39.642 + mProjectName + "Client");
39.643 + port.addExtensibilityElement(soapAddrs);
39.644 +
39.645 + // Add PartnerLink
39.646 + org.netbeans.modules.xml.wsdl.model.extensions.bpel.BPELComponentFactory bcf =
39.647 + new BPELComponentFactory(this.mClientWSDLModel);
39.648 + PartnerLinkType plt =
39.649 + bcf.createPartnerLinkType(this.mClientWSDLModel.getDefinitions());
39.650 + plt.setName("Task" + mProjectName + "ClientLT");
39.651 +
39.652 + Role role =
39.653 + bcf.createRole(this.mClientWSDLModel.getDefinitions());
39.654 + role.setName("Task" + mProjectName + "Client_Server");
39.655 + role.setPortType(ncrPortType);
39.656 +
39.657 + plt.setRole1(role);
39.658 +
39.659 + this.mClientWSDLModel.getDefinitions().addExtensibilityElement(plt);
39.660 +
39.661 +
39.662 + }
39.663 + }
39.664 + }
39.665 +
39.666 + private org.netbeans.modules.xml.wsdl.model.Message getTaskIdMessage(String taskName) {
39.667 + org.netbeans.modules.xml.wsdl.model.Message msg =
39.668 + this.mMapOfOpnToMessage.get(taskName);
39.669 + if (msg == null) {
39.670 + msg = this.mClientWSDLModel.getFactory().createMessage();
39.671 + msg.setName(taskName + "TaskId");
39.672 + Part part = this.mClientWSDLModel.getFactory().createPart();
39.673 + part.setName("taskId");
39.674 + GlobalType gst = createGlobalSimpleType("int");
39.675 + part.setType(part.createSchemaReference(gst, GlobalType.class));
39.676 + msg.addPart(part);
39.677 + this.mClientWSDLModel.getDefinitions().addMessage(msg);
39.678 + this.mMapOfOpnToMessage.put(taskName, msg);
39.679 + }
39.680 + return msg;
39.681 + }
39.682 +
39.683 + private org.netbeans.modules.xml.wsdl.model.Message getMessage(String msgName) {
39.684 + org.netbeans.modules.xml.wsdl.model.Message resultMsg =
39.685 + this.mMapOfOpnToMessage.get(msgName);
39.686 + if (resultMsg == null) {
39.687 + Collection<org.netbeans.modules.xml.wsdl.model.Message> messages =
39.688 + this.mClientWSDLModel.getDefinitions().getMessages();
39.689 + for (org.netbeans.modules.xml.wsdl.model.Message msg: messages) {
39.690 + if (msg.getName().equals(msgName)) {
39.691 + this.mMapOfOpnToMessage.put(msgName, msg);
39.692 + return msg;
39.693 + }
39.694 + }
39.695 + }
39.696 + return null;
39.697 + }
39.698 +
39.699 + private Message getFaultMessage() {
39.700 + org.netbeans.modules.xml.wsdl.model.Message resultMsg =
39.701 + getMessage("OptFaultMsg");
39.702 + if (resultMsg == null) {
39.703 + resultMsg = this.mClientWSDLModel.getFactory().createMessage();
39.704 + resultMsg.setName("OptFaultMsg");
39.705 + Part part = this.mClientWSDLModel.getFactory().createPart();
39.706 + part.setName("fault");
39.707 + GlobalType gst = createGlobalSimpleType("AnyType");
39.708 + part.setType(part.createSchemaReference(gst, GlobalType.class));
39.709 + resultMsg.addPart(part);
39.710 + this.mClientWSDLModel.getDefinitions().addMessage(resultMsg);
39.711 + this.mMapOfOpnToMessage.put("fault1", resultMsg);
39.712 +
39.713 + }
39.714 + return resultMsg;
39.715 + }
39.716 +
39.717 + private void initializeClientWSDLModel(String projectName) {
39.718 + String clientWSDLName =
39.719 + projectName + "_" + CLIENTWSDL_DEF_NAME_TEMPLATE_SUFFIX;
39.720 + String clientWSDLNS =
39.721 + this.CLIENTWSDL_NS_TEMPLATE_PREFIX + projectName +
39.722 + this.CLIENTWSDL_NS_TEMPLATE_SUFFIX;
39.723 + Definitions clientWSDLDef = this.mClientWSDLModel.getDefinitions();
39.724 +
39.725 + mClientWSDLModel.startTransaction();
39.726 + clientWSDLDef.setName(clientWSDLName);
39.727 + clientWSDLDef.setTargetNamespace(clientWSDLNS);
39.728 +
39.729 +
39.730 + // QName tnsQNAME = new QName()
39.731 + // clientWSDLDef.setAnyAttribute();
39.732 + // mClientWSDLModel
39.733 +
39.734 + }
39.735 +
39.736 +
39.737 + private void addOperationInfo(File workFile) {
39.738 + //Get the Operation information
39.739 + }
39.740 +
39.741 + private NamedComponentReference getElement(Message msg,
39.742 + String elementName) {
39.743 + Collection<Part> partsColl = msg.getParts();
39.744 + Iterator<Part> partsCollItr = partsColl.iterator();
39.745 + while (partsCollItr.hasNext()) {
39.746 + Part part = partsCollItr.next();
39.747 + NamedComponentReference ncr = part.getElement();
39.748 + GlobalElement ge = (GlobalElement)ncr.get();
39.749 + if (ge.getName().equals(elementName)) {
39.750 + return ncr;
39.751 + }
39.752 + }
39.753 + return null;
39.754 + }
39.755 +
39.756 + private NamedComponentReference getElementOrType(Message msg,
39.757 + String elementName) {
39.758 + Collection<Part> partsColl = msg.getParts();
39.759 + Iterator<Part> partsCollItr = partsColl.iterator();
39.760 + while (partsCollItr.hasNext()) {
39.761 + Part part = partsCollItr.next();
39.762 + if (part.getName().equals(elementName)) {
39.763 + NamedComponentReference ncr = part.getType();
39.764 + if (ncr != null) {
39.765 + return ncr;
39.766 + } else {
39.767 + ncr = part.getElement();
39.768 + if (ncr != null) {
39.769 + return ncr;
39.770 + }
39.771 + }
39.772 + }
39.773 + }
39.774 + return null;
39.775 + }
39.776 +
39.777 + private GlobalType craeteOrGetSchemaTypeInClientWSDL(GlobalElement ge) {
39.778 + GlobalType gt = null;
39.779 + NamedComponentReference gtRef = ge.getType();
39.780 + if(gtRef != null) {
39.781 + Object type = gtRef.get();
39.782 + if(type instanceof GlobalType) {
39.783 + gt = (GlobalType) type;
39.784 + }
39.785 +
39.786 +
39.787 +
39.788 + } else {
39.789 + //this is local type so need to create a global type which extends this?
39.790 + LocalType lt = ge.getInlineType();
39.791 + if(lt != null) {
39.792 + //createComplexSchemaInClientWSDL(lt);
39.793 + throw new UnsupportedOperationException("part with element having inline type not yet supported");
39.794 + }
39.795 + }
39.796 +
39.797 + return gt;
39.798 + }
39.799 +
39.800 +
39.801 +
39.802 +// private GlobalComplexType createComplexSchemaInClientWSDL(GlobalElement ge) {
39.803 +// Types wsdlTypes = this.mClientWSDLModel.getDefinitions().getTypes();
39.804 +// Collection<org.netbeans.modules.xml.schema.model.Schema> colSchemas =
39.805 +// wsdlTypes.getSchemas();
39.806 +// Iterator<org.netbeans.modules.xml.schema.model.Schema> colSchemasItr =
39.807 +// colSchemas.iterator();
39.808 +// org.netbeans.modules.xml.schema.model.Schema matchingSchema = null;
39.809 +// org.netbeans.modules.xml.wsdl.model.extensions.xsd.WSDLSchema wsdlSchema =
39.810 +// null;
39.811 +// matchingSchema = findWSDLInlineSchema();
39.812 +// if (matchingSchema == null) {
39.813 +// //Create a schema
39.814 +// wsdlSchema = mClientWSDLModel.getFactory().createWSDLSchema();
39.815 +// SchemaModel schemaModel = wsdlSchema.getSchemaModel();
39.816 +//
39.817 +// matchingSchema = schemaModel.getSchema();
39.818 +// matchingSchema.setTargetNamespace(mClientWSDLModel.getDefinitions().getTargetNamespace());
39.819 +// mClientWSDLSchema = matchingSchema;
39.820 +//
39.821 +// }
39.822 +//
39.823 +// GlobalComplexType gcx = null;
39.824 +// Collection<GlobalComplexType> cmplTypesColl =
39.825 +// matchingSchema.getComplexTypes();
39.826 +// Iterator<GlobalComplexType> cmpTypesItr = cmplTypesColl.iterator();
39.827 +// while (cmpTypesItr.hasNext()) {
39.828 +// GlobalComplexType gct = cmpTypesItr.next();
39.829 +// if (gct.getName().equals(ge.getName() + "CX")) {
39.830 +// gcx = gct;
39.831 +// break;
39.832 +// }
39.833 +// }
39.834 +// if (gcx == null) {
39.835 +// gcx = matchingSchema.getModel().getFactory().createGlobalComplexType();
39.836 +// Sequence seq =
39.837 +// matchingSchema.getModel().getFactory().createSequence();
39.838 +// LocalElement le =
39.839 +// matchingSchema.getModel().getFactory().createLocalElement();
39.840 +// gcx.setName(ge.getName() + "CX");
39.841 +// le.setName(ge.getName() + "Element");
39.842 +// le.setType(ge.getType());
39.843 +//
39.844 +// seq.appendContent(le);
39.845 +// gcx.setDefinition(seq);
39.846 +// matchingSchema.addComplexType(gcx);
39.847 +//
39.848 +// if (wsdlSchema != null) {
39.849 +// this.mClientWSDLModel.getDefinitions().getTypes().addExtensibilityElement(wsdlSchema);
39.850 +// }
39.851 +// }
39.852 +// return gcx;
39.853 +// }
39.854 +
39.855 + private org.netbeans.modules.xml.schema.model.Schema findWSDLInlineSchema() {
39.856 + org.netbeans.modules.xml.schema.model.Schema schema = null;
39.857 + org.netbeans.modules.xml.schema.model.Schema matchingSchema = null;
39.858 + org.netbeans.modules.xml.wsdl.model.extensions.xsd.WSDLSchema matchingWSDLSchema =
39.859 + null;
39.860 +
39.861 + if (mClientWSDLSchema == null) {
39.862 + String wsdlTNS =
39.863 + this.mClientWSDLModel.getDefinitions().getTargetNamespace();
39.864 + Iterator<ExtensibilityElement> colSchemasItr =
39.865 + this.mClientWSDLModel.getDefinitions().getTypes().getExtensibilityElements().iterator();
39.866 + while (colSchemasItr.hasNext()) {
39.867 + ExtensibilityElement exElem = colSchemasItr.next();
39.868 + org.netbeans.modules.xml.wsdl.model.extensions.xsd.WSDLSchema wsdlSchema =
39.869 + null;
39.870 + if (exElem instanceof
39.871 + org.netbeans.modules.xml.wsdl.model.extensions.xsd.WSDLSchema) {
39.872 + wsdlSchema =
39.873 + (org.netbeans.modules.xml.wsdl.model.extensions.xsd.WSDLSchema)exElem;
39.874 + schema = wsdlSchema.getSchemaModel().getSchema();
39.875 + }
39.876 + //Find the inline schema defined in client wsdl
39.877 + if (schema.getTargetNamespace() != null &&
39.878 + schema.getTargetNamespace().equals(wsdlTNS)) {
39.879 + matchingSchema = schema;
39.880 + matchingWSDLSchema = wsdlSchema;
39.881 + mClientWSDLSchema = matchingSchema;
39.882 + break;
39.883 + }
39.884 + }
39.885 +
39.886 + }
39.887 + return mClientWSDLSchema;
39.888 + }
39.889 +
39.890 + private GlobalType createGlobalSimpleType(String typeName) {
39.891 + SchemaModel primitiveModel =
39.892 + SchemaModelFactory.getDefault().getPrimitiveTypesModel();
39.893 + Collection<GlobalSimpleType> primitives =
39.894 + primitiveModel.getSchema().getSimpleTypes();
39.895 + for (GlobalSimpleType ptype: primitives) {
39.896 + if (ptype.getName().equals(typeName)) {
39.897 + return ptype;
39.898 + }
39.899 + }
39.900 + return null;
39.901 + }
39.902 +
39.903 + private GlobalType createGlobalSimpleType(QName simpleTypeQName) {
39.904 + String typeName = simpleTypeQName.getLocalPart();
39.905 + return createGlobalSimpleType(typeName);
39.906 + }
39.907 +}
40.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
40.2 +++ b/enterprise/openesbaddons/workflow/project/antsrc/org/netbeans/modules/workflow/project/anttasks/WSDLManager.java Thu Apr 26 02:33:27 2007 +0000
40.3 @@ -0,0 +1,80 @@
40.4 +/* *************************************************************************
40.5 + *
40.6 + * Copyright (c) 2005, SeeBeyond Technology Corporation,
40.7 + * All Rights Reserved
40.8 + *
40.9 + * This program, and all the routines referenced herein,
40.10 + * are the proprietary properties and trade secrets of
40.11 + * SEEBEYOND TECHNOLOGY CORPORATION.
40.12 + *
40.13 + * Except as provided for by license agreement, this
40.14 + * program shall not be duplicated, used, or disclosed
40.15 + * without written consent signed by an officer of
40.16 + * SEEBEYOND TECHNOLOGY CORPORATION.
40.17 + *
40.18 + ***************************************************************************/
40.19 +package org.netbeans.modules.workflow.project.anttasks;
40.20 +
40.21 +import java.io.File;
40.22 +
40.23 +import org.netbeans.modules.xml.wsdl.model.WSDLModel;
40.24 +import org.netbeans.modules.xml.wsdl.model.WSDLModelFactory;
40.25 +import org.netbeans.modules.xml.xam.ModelSource;
40.26 +import org.openide.filesystems.FileUtil;
40.27 +/**
40.28 + * @author sgenipudi
40.29 + */
40.30 +public class WSDLManager {
40.31 +
40.32 + private static WSDLManager mInstance = null;
40.33 +
40.34 + private WSDLManager() {
40.35 +
40.36 + }
40.37 +
40.38 + public static WSDLManager getInstance() {
40.39 + if (mInstance == null ) {
40.40 + mInstance = new WSDLManager();
40.41 + }
40.42 + return mInstance;
40.43 + }
40.44 +
40.45 + public WSDLModel getWSDLModel(File file) {
40.46 + ModelSource ms = getModuleSource(file);
40.47 + WSDLModelFactory factory = WSDLModelFactory.getDefault();
40.48 + WSDLModel model =null;
40.49 + try {
40.50 + model = factory.getModel(ms);
40.51 + }catch (Throwable ex) {
40.52 + ex.printStackTrace();
40.53 + throw new RuntimeException("Error while creating WSDLModel ",ex);
40.54 + }
40.55 +
40.56 + try {
40.57 + model.sync();
40.58 + }catch (Exception ex) {
40.59 + throw new RuntimeException("Error during sync operation"+file.getAbsolutePath());
40.60 + }
40.61 + return model;
40.62 + }
40.63 +
40.64 + public ModelSource getModuleSource(File file) {
40.65 + ModelSource source = null;
40.66 + try {
40.67 + if (WSDLGenerator.isCommandlineMode()) {
40.68 + source = WorkflowCatalogModel.getDefault().createModelSource(file, true);
40.69 + } else {
40.70 + source = org.netbeans.modules.xml.retriever.catalog.Utilities.createModelSource(FileUtil.toFileObject(file),true);
40.71 + }
40.72 + }catch (Exception ex){
40.73 + throw new RuntimeException("Error while creating model source for "+file);
40.74 + }
40.75 +
40.76 + return source;
40.77 + }
40.78 +
40.79 +
40.80 +
40.81 +// public WSDLOperation getOperation()
40.82 +
40.83 +}
41.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
41.2 +++ b/enterprise/openesbaddons/workflow/project/antsrc/org/netbeans/modules/workflow/project/anttasks/WorkflowCatalogModel.java Thu Apr 26 02:33:27 2007 +0000
41.3 @@ -0,0 +1,364 @@
41.4 +/*
41.5 + * The contents of this file are subject to the terms of the Common Development
41.6 + * and Distribution License (the License). You may not use this file except in
41.7 + * compliance with the License.
41.8 + *
41.9 + * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
41.10 + * or http://www.netbeans.org/cddl.txt.
41.11 +
41.12 + * When distributing Covered Code, include this CDDL Header Notice in each file
41.13 + * and include the License file at http://www.netbeans.org/cddl.txt.
41.14 + * If applicable, add the following below the CDDL Header, with the fields
41.15 + * enclosed by brackets [] replaced by your own identifying information:
41.16 + * "Portions Copyrighted [year] [name of copyright owner]"
41.17 + *
41.18 + * The Original Software is NetBeans. The Initial Developer of the Original
41.19 + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
41.20 + * Microsystems, Inc. All Rights Reserved.
41.21 + */
41.22 +package org.netbeans.modules.workflow.project.anttasks;
41.23 +
41.24 +import java.io.File;
41.25 +import java.io.FileInputStream;
41.26 +import java.io.IOException;
41.27 +import java.net.URI;
41.28 +
41.29 +import javax.swing.text.Document;
41.30 +
41.31 +import org.netbeans.modules.xml.schema.model.SchemaModel;
41.32 +import org.netbeans.modules.xml.schema.model.SchemaModelFactory;
41.33 +import org.netbeans.modules.xml.wsdl.model.WSDLModel;
41.34 +import org.netbeans.modules.xml.wsdl.model.WSDLModelFactory;
41.35 +import org.netbeans.modules.xml.xam.ModelSource;
41.36 +import org.netbeans.modules.xml.xam.locator.CatalogModel;
41.37 +import org.netbeans.modules.xml.xam.locator.CatalogModelException;
41.38 +import org.openide.util.Lookup;
41.39 +import org.openide.util.lookup.Lookups;
41.40 +import org.w3c.dom.ls.LSInput;
41.41 +import org.xml.sax.InputSource;
41.42 +import org.xml.sax.SAXException;
41.43 +
41.44 +/**
41.45 + * This class helps Bpel project to obtain the Bpel model given a
41.46 + * BPEL File URI
41.47 + * @author Sreenivasan Genipudi
41.48 + */
41.49 +public class WorkflowCatalogModel implements CatalogModel {
41.50 +
41.51 + static WorkflowCatalogModel singletonCatMod = null;
41.52 + //static File projectCatalogFileLocation = null;
41.53 +
41.54 +
41.55 + /**
41.56 + * Constructor
41.57 + */
41.58 + public WorkflowCatalogModel() {
41.59 +/* URI catalogFileLocPath= CommandlineBpelProjectXmlCatalogProvider.getInstance().getProjectWideCatalogForWizard();
41.60 + if (catalogFileLocPath != null) {
41.61 + projectCatalogFileLocation = new File(catalogFileLocPath);
41.62 + }*/
41.63 + }
41.64 +
41.65 + /**
41.66 + * Gets the instance of this class internal API
41.67 + * @return current class instance
41.68 + */
41.69 + public static WorkflowCatalogModel getDefault(){
41.70 + if (singletonCatMod == null){
41.71 + singletonCatMod = new WorkflowCatalogModel();
41.72 + }
41.73 + return singletonCatMod;
41.74 + }
41.75 +
41.76 + /*
41.77 + private File getProjectCatalogXML() {
41.78 + if (projectCatalogFileLocation != null && projectCatalogFileLocation.exists()) {
41.79 + return projectCatalogFileLocation;
41.80 + } else {
41.81 + return null;
41.82 + }
41.83 + } */
41.84 +
41.85 + /**
41.86 + * Gets the Model source for BPEL URI
41.87 + * @param locationURI URI location of the BPEL File
41.88 + * @return ModelSource return ModelSource
41.89 + * @throws org.netbeans.modules.xml.xam.locator.CatalogModelException
41.90 + */
41.91 + public ModelSource getModelSource(URI locationURI) throws CatalogModelException {
41.92 + /*List<File> catalogFileList = new ArrayList<File>();
41.93 + File file = null;
41.94 + File projectCatalogXML = getProjectCatalogXML();
41.95 + if (projectCatalogXML != null) {
41.96 + catalogFileList.add(projectCatalogXML );
41.97 + }
41.98 + if (catalogFileList.size() > 0) {
41.99 + URI uri = null;
41.100 +
41.101 + try {
41.102 + uri = resolveUsingApacheCatalog(catalogFileList, locationURI.toString());
41.103 + }catch (IOException ioe) {
41.104 +
41.105 + }
41.106 +
41.107 + if (uri != null ) {
41.108 + file =new File(uri);
41.109 + } else {
41.110 + try {
41.111 + file = new File(locationURI);
41.112 + }catch ( IllegalArgumentException ie) {
41.113 + throw new CatalogModelException("Invalid URI"+locationURI.toString());
41.114 + }
41.115 + }
41.116 + } else {
41.117 + try {
41.118 + file = new File(locationURI);
41.119 + }catch ( IllegalArgumentException ie) {
41.120 + throw new CatalogModelException("Invalid URI"+locationURI.toString());
41.121 + }
41.122 + }*/
41.123 + File file = null;
41.124 + try {
41.125 + file = new File(locationURI);
41.126 + }catch ( IllegalArgumentException ie) {
41.127 + throw new CatalogModelException("Invalid URI"+locationURI.toString());
41.128 + }
41.129 + return createModelSource(file, true);
41.130 + }
41.131 +
41.132 +
41.133 + /**
41.134 + * Implementation of CatalogModel
41.135 + * @param locationURI
41.136 + * @param modelSourceOfSourceDocument
41.137 + * @throws org.netbeans.modules.xml.xam.locator.CatalogModelException
41.138 + * @return
41.139 + */
41.140 + public ModelSource getModelSource(URI locationURI, ModelSource modelSourceOfSourceDocument) throws CatalogModelException {
41.141 + if(locationURI == null) {
41.142 + return null;
41.143 + }
41.144 +
41.145 + URI resolvedURI = locationURI;
41.146 +
41.147 + if(modelSourceOfSourceDocument != null) {
41.148 + File sFile = (File) modelSourceOfSourceDocument.getLookup().lookup(File.class);
41.149 +
41.150 + if(sFile != null) {
41.151 + URI sURI = sFile.toURI();
41.152 + resolvedURI = sURI.resolve(locationURI);
41.153 + }
41.154 +
41.155 + }
41.156 +
41.157 + if(resolvedURI != null) {
41.158 + return getModelSource(resolvedURI);
41.159 + }
41.160 +
41.161 + return null;
41.162 + }
41.163 + /**
41.164 + * Implementation of CatalogModel
41.165 + * @param file
41.166 + * @return
41.167 + */
41.168 + protected Document getDocument(File file) throws CatalogModelException{
41.169 + Document result = null;
41.170 +
41.171 + if (result != null) return result;
41.172 + try {
41.173 +
41.174 +
41.175 + FileInputStream fis = new FileInputStream(file);
41.176 + byte buffer[] = new byte[fis.available()];
41.177 +// result = new org.netbeans.editor.BaseDocument(
41.178 +// org.netbeans.modules.xml.text.syntax.XMLKit.class, false);
41.179 + result = new javax.swing.text.PlainDocument();
41.180 + result.remove(0, result.getLength());
41.181 + fis.read(buffer);
41.182 + fis.close();
41.183 + String str = new String(buffer);
41.184 + result.insertString(0,str,null);
41.185 +
41.186 + } catch (Exception dObjEx) {
41.187 + throw new CatalogModelException(file.getAbsolutePath()+" File Not Found");
41.188 + }
41.189 +
41.190 + return result;
41.191 + }
41.192 +
41.193 + private WSDLModelFactory getWSDLModelFactory() {
41.194 + WSDLModelFactory factory =null;
41.195 + try {
41.196 + factory = (WSDLModelFactory)WSDLModelFactory.getDefault();//Lookups.metaInfServices(getClass().getClassLoader()).lookup(BpelModelFactory.class);
41.197 + //Lookup.getDefault().lookup(BpelModelFactory.class);
41.198 + }catch (Exception cnfe) {
41.199 + System.out.println(cnfe.getMessage());
41.200 + throw new RuntimeException(cnfe);
41.201 + }
41.202 + return factory;
41.203 + }
41.204 +
41.205 +
41.206 +
41.207 + /**
41.208 + * Implementation of CatalogModel
41.209 + * @param file
41.210 + * @param readOnly
41.211 + * @throws org.netbeans.modules.xml.xam.locator.CatalogModelException
41.212 + * @return
41.213 + */
41.214 + public ModelSource createModelSource(File file, boolean readOnly) throws CatalogModelException{
41.215 +
41.216 + Lookup lookup = Lookups.fixed(new Object[]{
41.217 + file,
41.218 + getDocument(file),
41.219 + getDefault(),
41.220 + // new StreamSource(file)
41.221 + file
41.222 + });
41.223 +
41.224 + return new ModelSource(lookup, readOnly);
41.225 + }
41.226 +
41.227 +
41.228 +
41.229 +
41.230 + /**
41.231 + * Creates BPEL Model from BPEL URI
41.232 + * @param locationURI
41.233 + * @throws java.lang.Exception
41.234 + * @return
41.235 + */
41.236 + public WSDLModel getWSDLModel(URI locationURI) throws Exception {
41.237 + ModelSource source = getDefault().getModelSource(locationURI);
41.238 + WSDLModel model = getWSDLModelFactory().getModel (source);
41.239 + model.sync();
41.240 + return model;
41.241 + }
41.242 +
41.243 + public SchemaModel getSchemaModel(URI locationURI) throws Exception {
41.244 + ModelSource source = getDefault().getModelSource(locationURI);
41.245 + SchemaModel model = SchemaModelFactory.getDefault().getModel (source);
41.246 + model.sync();
41.247 + return model;
41.248 + }
41.249 +
41.250 + /*
41.251 + protected URI resolveUsingApacheCatalog(List<File> catalogFileList, String locationURI) throws CatalogModelException, IOException {
41.252 + CatalogResolver catalogResolver;
41.253 + Catalog apacheCatalogResolverObj;
41.254 +
41.255 +
41.256 + CatalogManager manager = new CatalogManager(null);
41.257 + manager.setUseStaticCatalog(false);
41.258 + manager.setPreferPublic(false);
41.259 + catalogResolver = new CatalogResolver(manager);
41.260 + //catalogResolver = new CatalogResolver(true);
41.261 + apacheCatalogResolverObj = catalogResolver.getCatalog();
41.262 +
41.263 + for(File catFile : catalogFileList){
41.264 + if (catFile.length() > 0) {
41.265 + try {
41.266 + apacheCatalogResolverObj.parseCatalog(catFile.getAbsolutePath());
41.267 + } catch (Throwable ex) {
41.268 + throw new CatalogModelException(ex);
41.269 + }
41.270 +
41.271 + String result = null;
41.272 + try {
41.273 + result = apacheCatalogResolverObj.resolveSystem(locationURI);
41.274 + } catch (MalformedURLException ex) {
41.275 + result = "";
41.276 + } catch (IOException ex) {
41.277 + result = "";
41.278 + }
41.279 + if(result == null){
41.280 + result = "";
41.281 + }else{
41.282 + try {
41.283 + //This is a workaround for a bug in resolver module on windows.
41.284 + //the String returned by resolver is not an URI style
41.285 + result = Utilities.normalizeURI(result);
41.286 + URI uri = new URI(result);
41.287 + if(uri.isOpaque()){
41.288 + if(uri.getScheme().equalsIgnoreCase("file")){
41.289 + StringBuffer resBuff = new StringBuffer(result);
41.290 + result = resBuff.insert("file:".length(), "/").toString();
41.291 + }
41.292 + }
41.293 + } catch (URISyntaxException ex) {
41.294 + return null;
41.295 + }
41.296 + }
41.297 + if(result.length() > 0 ){
41.298 + try {
41.299 + URI res = new URI(result);
41.300 + return res;
41.301 + } catch (URISyntaxException ex) {
41.302 + }
41.303 + }
41.304 + }
41.305 + }
41.306 + return null;
41.307 + } */
41.308 + /*
41.309 + private static String normalizeURI(String uriref) {
41.310 + StringBuilder newRef = new StringBuilder();
41.311 + byte[] bytes;
41.312 +
41.313 + if (uriref == null) {
41.314 + return null;
41.315 + }
41.316 +
41.317 + try {
41.318 + bytes = uriref.getBytes("UTF-8");
41.319 + } catch (UnsupportedEncodingException uee) {
41.320 + // this can't happen
41.321 + return uriref;
41.322 + }
41.323 +
41.324 + for (int count = 0; count < bytes.length; count++) {
41.325 + int ch = bytes[count] & 0xFF;
41.326 +
41.327 + if ((ch <= 0x20) // ctrl
41.328 + || (ch > 0x7F) // high ascii
41.329 + || (ch == 0x22) // "
41.330 + || (ch == 0x3C) // <
41.331 + || (ch == 0x3E) // >
41.332 + || (ch == 0x5C) // \
41.333 + || (ch == 0x5E) // ^
41.334 + || (ch == 0x60) // `
41.335 + || (ch == 0x7B) // {
41.336 + || (ch == 0x7C) // |
41.337 + || (ch == 0x7D) // }
41.338 + || (ch == 0x7F)) {
41.339 + newRef.append(encodedByte(ch));
41.340 + } else {
41.341 + newRef.append((char) bytes[count]);
41.342 + }
41.343 + }
41.344 +
41.345 + return newRef.toString();
41.346 + }
41.347 +
41.348 + public static String encodedByte(int b) {
41.349 + String hex = Integer.toHexString(b).toUpperCase();
41.350 + if (hex.length() < 2) {
41.351 + return "%0" + hex;
41.352 + } else {
41.353 + return "%" + hex;
41.354 + }
41.355 + } */
41.356 +
41.357 + public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException {
41.358 + //TODO FIXME: this is to fix a build break. Please implement this method.
41.359 + return null;
41.360 + }
41.361 +
41.362 + public LSInput resolveResource(String type, String namespaceURI, String publicId, String systemId, String baseURI) {
41.363 + //TODO FIXME: this is to fix a build break. Please implement this method.
41.364 + return null;
41.365 + }
41.366 +
41.367 +}
42.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
42.2 +++ b/enterprise/openesbaddons/workflow/project/antsrc/org/netbeans/modules/workflow/project/anttasks/WorkflowMapEntry.java Thu Apr 26 02:33:27 2007 +0000
42.3 @@ -0,0 +1,133 @@
42.4 +/* *************************************************************************
42.5 + *
42.6 + * Copyright (c) 2005, SeeBeyond Technology Corporation,
42.7 + * All Rights Reserved
42.8 + *
42.9 + * This program, and all the routines referenced herein,
42.10 + * are the proprietary properties and trade secrets of
42.11 + * SEEBEYOND TECHNOLOGY CORPORATION.
42.12 + *
42.13 + * Except as provided for by license agreement, this
42.14 + * program shall not be duplicated, used, or disclosed
42.15 + * without written consent signed by an officer of
42.16 + * SEEBEYOND TECHNOLOGY CORPORATION.
42.17 + *
42.18 + ***************************************************************************/
42.19 +package org.netbeans.modules.workflow.project.anttasks;
42.20 +
42.21 +import javax.xml.namespace.QName;
42.22 +
42.23 +public class WorkflowMapEntry {
42.24 + public static final String REQUEST_REPLY_SERVICE = "requestReplyService";
42.25 + public static final String FILTER_ONE_WAY = "filterOneWay";
42.26 + public static final String FILTER_REQUEST_REPLY = "filterRequestReply";
42.27 +
42.28 + public static final String INPUT_MESSAGE_TYPE = "input";
42.29 + public static final String OUTPUT_MESSAGE_TYPE = "output";
42.30 + public static final String REPLY_MESSAGE_TYPE = "reply";
42.31 +
42.32 + private String mType;
42.33 + private QName mPartnerLink;
42.34 + private QName mPortType;
42.35 + private String mRoleName;
42.36 +
42.37 + private QName mOutPartnerLink;
42.38 + private QName mOutPortType;
42.39 + private String mOutRoleName;
42.40 +
42.41 +
42.42 + /**
42.43 + * Creates a new instance of PortMapEntry
42.44 + */
42.45 + private WorkflowMapEntry(String type,
42.46 + QName partnerLink,
42.47 + QName portType,
42.48 + String roleName,
42.49 + QName outPartnerLink,
42.50 + QName outPortType,
42.51 + String outRoleName)
42.52 + {
42.53 + mType = type;
42.54 + mPartnerLink = partnerLink;
42.55 + mPortType = portType;
42.56 + mRoleName = roleName;
42.57 +
42.58 + mOutPartnerLink = outPartnerLink;
42.59 + mOutPortType = outPortType;
42.60 + mOutRoleName = outRoleName;
42.61 + }
42.62 +
42.63 + public static WorkflowMapEntry newRequestReplyService(QName partnerLink,
42.64 + QName portType,
42.65 + String roleName)
42.66 + {
42.67 + return new WorkflowMapEntry(REQUEST_REPLY_SERVICE,
42.68 + partnerLink,
42.69 + portType,
42.70 + roleName,
42.71 + null, null, null);
42.72 + }
42.73 +
42.74 + public static WorkflowMapEntry newFilterOneWay(QName partnerLink,
42.75 + QName portType,
42.76 + String roleName,
42.77 + QName outPartnerLink,
42.78 + QName outPortType,
42.79 + String outRoleName)
42.80 + {
42.81 + return new WorkflowMapEntry(FILTER_ONE_WAY,
42.82 + partnerLink,
42.83 + portType,
42.84 + roleName,
42.85 + outPartnerLink,
42.86 + outPortType,
42.87 + outRoleName);
42.88 + }
42.89 +
42.90 + public static WorkflowMapEntry newFilterRequestReply(QName partnerLink,
42.91 + QName portType,
42.92 + String roleName,
42.93 + QName outPartnerLink,
42.94 + QName outPortType,
42.95 + String outRoleName)
42.96 + {
42.97 + return new WorkflowMapEntry(FILTER_REQUEST_REPLY,
42.98 + partnerLink,
42.99 + portType,
42.100 + roleName,
42.101 + outPartnerLink,
42.102 + outPortType,
42.103 + outRoleName);
42.104 + }
42.105 +
42.106 + public String getType() {
42.107 + assert mType != null;
42.108 + return mType;
42.109 + }
42.110 +
42.111 + public QName getPartnerLink() {
42.112 + assert mPartnerLink != null;
42.113 + return mPartnerLink;
42.114 + }
42.115 +
42.116 + public QName getPortType() {
42.117 + return mPortType;
42.118 + }
42.119 +
42.120 + public String getRoleName() {
42.121 + return mRoleName;
42.122 + }
42.123 +
42.124 + public QName getOutPartnerLink() {
42.125 + return mOutPartnerLink;
42.126 + }
42.127 +
42.128 + public QName getOutPortType() {
42.129 + return mOutPortType;
42.130 + }
42.131 +
42.132 + public String getOutRoleName() {
42.133 + return mOutRoleName;
42.134 + }
42.135 +
42.136 +}
43.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
43.2 +++ b/enterprise/openesbaddons/workflow/project/antsrc/org/netbeans/modules/workflow/project/anttasks/WorkflowMapReader.java Thu Apr 26 02:33:27 2007 +0000
43.3 @@ -0,0 +1,121 @@
43.4 +/* *************************************************************************
43.5 +*
43.6 +* Copyright (c) 2005, SeeBeyond Technology Corporation,
43.7 +* All Rights Reserved
43.8 +*
43.9 +* This program, and all the routines referenced herein,
43.10 +* are the proprietary properties and trade secrets of
43.11 +* SEEBEYOND TECHNOLOGY CORPORATION.
43.12 +*
43.13 +* Except as provided for by license agreement, this
43.14 +* program shall not be duplicated, used, or disclosed
43.15 +* without written consent signed by an officer of
43.16 +* SEEBEYOND TECHNOLOGY CORPORATION.
43.17 +*
43.18 +***************************************************************************/
43.19 +package org.netbeans.modules.workflow.project.anttasks;
43.20 +
43.21 +import java.io.File;
43.22 +import java.util.ArrayList;
43.23 +import java.util.List;
43.24 +
43.25 +import javax.xml.namespace.QName;
43.26 +import javax.xml.parsers.DocumentBuilderFactory;
43.27 +
43.28 +import org.w3c.dom.Document;
43.29 +import org.w3c.dom.Element;
43.30 +import org.w3c.dom.NodeList;
43.31 +
43.32 +public class WorkflowMapReader {
43.33 + private static final String PARTNERLINK_ATTR = "partnerLink";
43.34 + private static final String PORTTYPE_ATTR = "portType";
43.35 + private static final String ROLE_NAME_ATTR = "roleName";
43.36 +
43.37 + protected WorkflowMapReader() {
43.38 + }
43.39 +
43.40 + /**
43.41 + * Parses Workflow service unit configuration file.
43.42 + *
43.43 + * @param workflowmapfile The service unit configuration file.
43.44 + * @return list of transformation mappings.
43.45 + * @throws org.xml.sax.SAXException if a parsing error occurs.
43.46 + * @throws java.io.IOException if an error occurs reading configuration file.
43.47 + * @throws javax.xml.parsers.ParserConfigurationException if a parsing error occurs.
43.48 + */
43.49 + public static List parse(File workflowmapfile)
43.50 + throws org.xml.sax.SAXException,
43.51 + java.io.IOException,
43.52 + javax.xml.parsers.ParserConfigurationException {
43.53 + // parse entries into list
43.54 + List retList = new ArrayList();
43.55 + Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(workflowmapfile);
43.56 + Element elem = doc.getDocumentElement();
43.57 + NodeList portmaps = elem.getChildNodes();
43.58 + for (int i = 0; i < portmaps.getLength(); i++) {
43.59 + if (!(portmaps.item(i) instanceof Element)) continue;
43.60 +
43.61 + Element mappingElem = (Element) portmaps.item(i);
43.62 + String type = mappingElem.getNodeName();
43.63 + Element inputElem = (Element)
43.64 + mappingElem.getElementsByTagName(
43.65 + WorkflowMapEntry.INPUT_MESSAGE_TYPE).item(0);
43.66 + if (inputElem != null) {
43.67 + QName partnerLink = getQName(inputElem.getAttribute(PARTNERLINK_ATTR));
43.68 + QName portType = getQName(inputElem.getAttribute(PORTTYPE_ATTR));
43.69 + String roleName = inputElem.getAttribute(ROLE_NAME_ATTR);
43.70 +
43.71 + if (WorkflowMapEntry.REQUEST_REPLY_SERVICE.equals(type)) {
43.72 + retList.add(
43.73 + WorkflowMapEntry.newRequestReplyService(partnerLink,
43.74 + portType,
43.75 + roleName));
43.76 + }
43.77 + else if (WorkflowMapEntry.FILTER_ONE_WAY.equals(type)) {
43.78 + Element outputElem = (Element)
43.79 + mappingElem.getElementsByTagName(
43.80 + WorkflowMapEntry.OUTPUT_MESSAGE_TYPE).item(0);
43.81 + if (outputElem != null) {
43.82 + QName outPartnerLink =
43.83 + getQName(outputElem.getAttribute(PARTNERLINK_ATTR));
43.84 + QName outPortType =
43.85 + getQName(outputElem.getAttribute(PORTTYPE_ATTR));
43.86 + String outRoleName = outputElem.getAttribute(ROLE_NAME_ATTR);
43.87 + retList.add(
43.88 + WorkflowMapEntry.newFilterOneWay(partnerLink,
43.89 + portType,
43.90 + roleName,
43.91 + outPartnerLink,
43.92 + outPortType,
43.93 + outRoleName));
43.94 + }
43.95 + }
43.96 + else if (WorkflowMapEntry.FILTER_REQUEST_REPLY.equals(type)) {
43.97 + Element outputElem = (Element)
43.98 + mappingElem.getElementsByTagName(
43.99 + WorkflowMapEntry.OUTPUT_MESSAGE_TYPE).item(0);
43.100 + if (outputElem != null) {
43.101 + QName outPartnerLink =
43.102 + getQName(outputElem.getAttribute(PARTNERLINK_ATTR));
43.103 + QName outPortType =
43.104 + getQName(outputElem.getAttribute(PORTTYPE_ATTR));
43.105 + String outRoleName = outputElem.getAttribute(ROLE_NAME_ATTR);
43.106 + retList.add(
43.107 + WorkflowMapEntry.newFilterRequestReply(partnerLink,
43.108 + portType,
43.109 + roleName,
43.110 + outPartnerLink,
43.111 + outPortType,
43.112 + outRoleName));
43.113 + }
43.114 + }
43.115 + }
43.116 + // TODO throw exception if input is missing?
43.117 + }
43.118 + return retList;
43.119 + }
43.120 +
43.121 + private static QName getQName(String qname) {
43.122 + return QName.valueOf(qname);
43.123 + }
43.124 +}
44.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
44.2 +++ b/enterprise/openesbaddons/workflow/project/antsrc/org/netbeans/modules/workflow/project/anttasks/XformGenerator.java Thu Apr 26 02:33:27 2007 +0000
44.3 @@ -0,0 +1,142 @@
44.4 +/* *************************************************************************
44.5 + *
44.6 + * Copyright (c) 2005, SeeBeyond Technology Corporation,
44.7 + * All Rights Reserved
44.8 + *
44.9 + * This program, and all the routines referenced herein,
44.10 + * are the proprietary properties and trade secrets of
44.11 + * SEEBEYOND TECHNOLOGY CORPORATION.
44.12 + *
44.13 + * Except as provided for by license agreement, this
44.14 + * program shall not be duplicated, used, or disclosed
44.15 + * without written consent signed by an officer of
44.16 + * SEEBEYOND TECHNOLOGY CORPORATION.
44.17 + *
44.18 + ***************************************************************************/
44.19 +package org.netbeans.modules.workflow.project.anttasks;
44.20 +
44.21 +import java.io.File;
44.22 +import java.io.FileWriter;
44.23 +import java.util.ArrayList;
44.24 +
44.25 +import org.netbeans.modules.workflow.project.anttasks.wsdl.WSDLOperation;
44.26 +import org.netbeans.modules.xml.wsdl.model.WSDLModel;
44.27 +
44.28 +
44.29 +/**
44.30 + * @author sgenipudi
44.31 + */
44.32 +public class XformGenerator {
44.33 +
44.34 + private WSDLModel mClientWSDLModel = null;
44.35 + private File mProjectDir = null;
44.36 + private String mProjectName = null;
44.37 + private File mBuildDir = null;
44.38 + private static boolean mbCommandline = false;
44.39 + private boolean mAlways= false;
44.40 +
44.41 + public XformGenerator() {
44.42 + }
44.43 +
44.44 + public static void setCommandlineMode(boolean value) {
44.45 + mbCommandline = value;
44.46 + }
44.47 +
44.48 + public static boolean isCommandlineMode() {
44.49 + return mbCommandline;
44.50 + }
44.51 +
44.52 + public void generate(File projectDir, File buildDir, boolean always) {
44.53 + //Get the static WSDL File
44.54 + //Build will copy the static wsdl to build directory
44.55 + //assume the template is already there in the build directory.
44.56 + this.mProjectDir = projectDir;
44.57 + this.mBuildDir = buildDir;
44.58 + this.mAlways = always;
44.59 +
44.60 + //Scan the project dir and process each workflow files
44.61 + // Load Static Task Client WSDL Template
44.62 + // Set defenition Name/ TargetName space in the defenitions
44.63 +
44.64 + // From Workflow file,
44.65 + // get the Operation
44.66 + // From Operation get the WSDL Model
44.67 + // From Operation
44.68 + // get the Input and
44.69 + // Output messages
44.70 + // For each Input and Output message
44.71 + // Get the part information
44.72 + // Get the schema type for each part
44.73 + // If the schema is File then get the File information
44.74 + // If this is inline schema then serialize the schema to File
44.75 + // and store the File Information
44.76 + // Generate XForm based on schema
44.77 +
44.78 + //Implementation start:
44.79 + // Iterate the source directory and find out each Task Workflow files
44.80 + processSourceDir();
44.81 +
44.82 + }
44.83 +
44.84 + /**
44.85 + * Proces the source directory to generate JBI.xml
44.86 + * @param sourceDir
44.87 + */
44.88 + private void processSourceDir() {
44.89 + processFileObject(this.mProjectDir);
44.90 + }
44.91 +
44.92 + /**
44.93 + * Process the file object to generate JBI.xml
44.94 + * @param file BPEL file location
44.95 + */
44.96 + private void processFileObject(File file) {
44.97 + if (file.isDirectory()) {
44.98 + processFolder(file);
44.99 + } else {
44.100 + processFile(file);
44.101 + }
44.102 + }
44.103 +
44.104 + /**
44.105 + * Process the folder to generate JBI.xml
44.106 + * @param fileDir Folder location
44.107 + */
44.108 + private void processFolder(File fileDir) {
44.109 + File[] children = fileDir.listFiles();
44.110 +
44.111 + for (int i = 0; i < children.length; i++) {
44.112 + processFileObject(children[i]);
44.113 + }
44.114 + }
44.115 +
44.116 + /**
44.117 + * Process the file to generate JBI.xml
44.118 + * @param file input file
44.119 + * @throws Exception
44.120 + */
44.121 + protected void processFile(File file) {
44.122 + String fileName = file.getName();
44.123 + String fileExtension = null;
44.124 + int dotIndex = fileName.lastIndexOf('.');
44.125 + if (dotIndex != -1) {
44.126 + fileExtension = fileName.substring(dotIndex + 1);
44.127 + }
44.128 +
44.129 + if (fileExtension != null && fileExtension.equalsIgnoreCase("wf")) {
44.130 + ArrayList<WSDLOperation> listOfOperations =
44.131 + new ArrayList<WSDLOperation>();
44.132 + try {
44.133 + Util.generateXForm(file, mBuildDir, mProjectDir, mAlways);
44.134 + } catch (RuntimeException e) {
44.135 + // TODO Auto-generated catch block
44.136 + throw e;
44.137 + } catch (Exception e) {
44.138 + throw new RuntimeException (e);
44.139 + }
44.140 + }
44.141 +
44.142 + }
44.143 +
44.144 +
44.145 +}
45.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
45.2 +++ b/enterprise/openesbaddons/workflow/project/antsrc/org/netbeans/modules/workflow/project/anttasks/XmlUtil.java Thu Apr 26 02:33:27 2007 +0000
45.3 @@ -0,0 +1,213 @@
45.4 +package org.netbeans.modules.workflow.project.anttasks;
45.5 +
45.6 +
45.7 +
45.8 +import java.io.*;
45.9 +
45.10 +import java.util.logging.Logger;
45.11 +
45.12 +import javax.xml.parsers.DocumentBuilder;
45.13 +import javax.xml.parsers.DocumentBuilderFactory;
45.14 +import javax.xml.transform.OutputKeys;
45.15 +import javax.xml.transform.Source;
45.16 +import javax.xml.transform.Transformer;
45.17 +import javax.xml.transform.TransformerFactory;
45.18 +import javax.xml.transform.dom.DOMResult;
45.19 +import javax.xml.transform.dom.DOMSource;
45.20 +import javax.xml.transform.stream.StreamResult;
45.21 +
45.22 +import org.w3c.dom.*;
45.23 +
45.24 +import org.xml.sax.InputSource;
45.25 +
45.26 +/**
45.27 + * Description of the Class
45.28 + *
45.29 + * @author Bing Lu
45.30 + * @created May 5, 2005
45.31 + */
45.32 +public class XmlUtil {
45.33 + private static Logger mLogger = Logger.getLogger(XmlUtil.class.getName());
45.34 +
45.35 + /**
45.36 + * Description of the Method
45.37 + *
45.38 + * @param namespaceAware Description of the Parameter
45.39 + * @return Description of the Return Value
45.40 + * @exception Exception Description of the Exception
45.41 + */
45.42 + public static Document createDocument(boolean namespaceAware)
45.43 + throws Exception {
45.44 +
45.45 + DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
45.46 +
45.47 + factory.setNamespaceAware(namespaceAware);
45.48 +
45.49 + DocumentBuilder builder = factory.newDocumentBuilder();
45.50 + Document document = builder.newDocument();
45.51 +
45.52 + return document;
45.53 + }
45.54 +
45.55 + /**
45.56 + * Description of the Method
45.57 + *
45.58 + * @param namespaceAware Description of the Parameter
45.59 + * @param source Description of the Parameter
45.60 + * @return Description of the Return Value
45.61 + * @exception Exception Description of the Exception
45.62 + */
45.63 + private static Document createDocument(boolean namespaceAware,
45.64 + InputSource source)
45.65 + throws Exception {
45.66 +
45.67 + DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
45.68 +
45.69 + factory.setNamespaceAware(true);
45.70 + //factory.setValidating();
45.71 +
45.72 + DocumentBuilder builder = factory.newDocumentBuilder();
45.73 + Document document = builder.parse(source);
45.74 +
45.75 + document.normalize();
45.76 +
45.77 + return document;
45.78 + }
45.79 +
45.80 + /**
45.81 + * Description of the Method
45.82 + *
45.83 + * @param namespaceAware Description of the Parameter
45.84 + * @param xml Description of the Parameter
45.85 + * @return Description of the Return Value
45.86 + * @exception Exception Description of the Exception
45.87 + */
45.88 + public static Document createDocumentFromXML(boolean namespaceAware,
45.89 + String xml)
45.90 + throws Exception {
45.91 + return createDocument(namespaceAware,
45.92 + new InputSource(new StringReader(xml)));
45.93 + }
45.94 +
45.95 + /**
45.96 + * Gets the text attribute of the DOMUtil class
45.97 + *
45.98 + * @param node Description of the Parameter
45.99 + * @return The text value
45.100 + */
45.101 + public static String getText(Node node) {
45.102 + StringBuffer buf = new StringBuffer();
45.103 + NodeList children = node.getChildNodes();
45.104 + for (int i = 0, I = children.getLength(); i < I; i++) {
45.105 + Node child = children.item(i);
45.106 + if (child.getNodeType() == Node.TEXT_NODE) {
45.107 + buf.append(child.getNodeValue());
45.108 + }
45.109 + }
45.110 + return buf.toString();
45.111 + }
45.112 +
45.113 + /**
45.114 + * Description of the Method
45.115 + *
45.116 + * @param node Description of the Parameter
45.117 + * @return Description of the Return Value
45.118 + */
45.119 + // UTF-8
45.120 + public static String toXml(Node node, String encoding, boolean omitXMLDeclaration) {
45.121 + String ret = null;
45.122 + ByteArrayOutputStream baos = new ByteArrayOutputStream();
45.123 + try {
45.124 + Transformer trans = TransformerFactory.newInstance().newTransformer();
45.125 + trans.setOutputProperty(OutputKeys.ENCODING, encoding);
45.126 + trans.setOutputProperty(OutputKeys.INDENT, "yes");
45.127 + trans.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4");
45.128 + trans.setOutputProperty(OutputKeys.METHOD, "xml");
45.129 + trans.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, omitXMLDeclaration? "yes":"no");
45.130 + trans.transform(new DOMSource(node), new StreamResult(baos));
45.131 + ret = baos.toString(encoding);
45.132 + //mLogger.debug("ret: " + ret);
45.133 + } catch (Exception e) {
45.134 + e.printStackTrace();
45.135 + }
45.136 + return ret;
45.137 + }
45.138 +
45.139 +
45.140 + /**
45.141 + * Description of the Method
45.142 + *
45.143 + * @param node Description of the Parameter
45.144 + * @return Description of the Return Value
45.145 + */
45.146 + // UTF-8
45.147 + public static String transformToString(Source xmlSource, Source xsltSource) {
45.148 + String ret = null;
45.149 + ByteArrayOutputStream baos = new ByteArrayOutputStream();
45.150 + try {
45.151 + Transformer trans = TransformerFactory.newInstance().newTransformer(xsltSource);
45.152 + trans.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
45.153 + trans.setOutputProperty(OutputKeys.INDENT, "yes");
45.154 + trans.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4");
45.155 + trans.setOutputProperty(OutputKeys.METHOD, "xml");
45.156 + trans.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION,"no");
45.157 + trans.transform(xmlSource, new StreamResult(baos));
45.158 + ret = baos.toString("UTF-8");
45.159 + //mLogger.debug("ret: " + ret);
45.160 + } catch (Exception e) {
45.161 + e.printStackTrace();
45.162 + }
45.163 + return ret;
45.164 + }
45.165 +
45.166 + // UTF-8
45.167 + public static Node transformToDoc(Source xmlSource, Source xsltSource) {
45.168 + Node ret = null;
45.169 + DOMResult result = new DOMResult();
45.170 + try {
45.171 + Transformer trans = TransformerFactory.newInstance().newTransformer(xsltSource);
45.172 + trans.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
45.173 + trans.setOutputProperty(OutputKeys.INDENT, "yes");
45.174 + trans.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4");
45.175 + trans.setOutputProperty(OutputKeys.METHOD, "xml");
45.176 + trans.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION,"no");
45.177 + trans.transform(xmlSource, result);
45.178 + ret = result.getNode();
45.179 + //mLogger.debug("ret: " + ret);
45.180 + } catch (Exception e) {
45.181 + e.printStackTrace();
45.182 + }
45.183 + return ret;
45.184 + }
45.185 +
45.186 + //TODO
45.187 + public static Element buildFault(Exception e) {
45.188 + // TODO Auto-generated method stub
45.189 + return null;
45.190 + }
45.191 +
45.192 +
45.193 + public static NodeList newSingleNodeList(Node node) {
45.194 + return new DefaultNodeList(node);
45.195 + }
45.196 +
45.197 + static class DefaultNodeList implements NodeList {
45.198 + private Node mNode;
45.199 +
45.200 + DefaultNodeList(Node node) {
45.201 + this.mNode = node;
45.202 + }
45.203 + public int getLength() {
45.204 + return mNode != null? 1 : 0;
45.205 + }
45.206 +
45.207 + public Node item(int index) {
45.208 + if(index == 0) {
45.209 + return mNode;
45.210 + }
45.211 +
45.212 + throw new IllegalArgumentException("Index out of bound "+ index);
45.213 + }
45.214 +
45.215 + }
45.216 +}
46.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
46.2 +++ b/enterprise/openesbaddons/workflow/project/antsrc/org/netbeans/modules/workflow/project/anttasks/resources/inputtransform.xsl Thu Apr 26 02:33:27 2007 +0000
46.3 @@ -0,0 +1,40 @@
46.4 +<?xml version="1.0" encoding="UTF-8"?>
46.5 +<!-- edited with XMLSpy v2006 sp1 U (http://www.altova.com) by Mei Wu (SeeBeyond Technology Corp.) -->
46.6 +<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:xforms="http://www.w3.org/2002/xforms" xmlns:html="http://www.w3.org/1999/xhtml" xmlns="http://www.w3.org/1999/xhtml">
46.7 + <xsl:template match="html:body">
46.8 + <inputXForm>
46.9 + <xsl:apply-templates select="xforms:group"/>
46.10 + </inputXForm>
46.11 + </xsl:template>
46.12 + <xsl:template match="xforms:group">
46.13 + <xforms:group xmlns:xforms="http://www.w3.org/2002/xforms">
46.14 + <p>
46.15 + <b>
46.16 + <i><xsl:value-of select="xforms:label"/></i>
46.17 + </b>
46.18 + </p>
46.19 + <p>
46.20 + </p>
46.21 + <table border="1">
46.22 + <xsl:apply-templates select="xforms:output"/>
46.23 + </table>
46.24 + </xforms:group>
46.25 + </xsl:template>
46.26 + <xsl:template match="xforms:output">
46.27 + <tr>
46.28 + <td>
46.29 + <xsl:apply-templates select="xforms:label"/>
46.30 + </td>
46.31 + <td>
46.32 + <xsl:copy>
46.33 + <xsl:apply-templates select="@*"/>
46.34 + </xsl:copy>
46.35 + </td>
46.36 + </tr>
46.37 + </xsl:template>
46.38 +
46.39 + <xsl:template match="@*">
46.40 + <xsl:copy>
46.41 + </xsl:copy>
46.42 + </xsl:template>
46.43 +</xsl:stylesheet>
47.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
47.2 +++ b/enterprise/openesbaddons/workflow/project/antsrc/org/netbeans/modules/workflow/project/anttasks/resources/jbi_gen.properties Thu Apr 26 02:33:27 2007 +0000
47.3 @@ -0,0 +1,11 @@
47.4 +Task_ServiceName=TaskService
47.5 +TaskCommon_WSDL_URI=http://jbi.com.sun/wfse/wsdl/TaskCommon
47.6 +TaskCommon_EndPoint=TaskCommonPort
47.7 +TaskCommon_Interface=TaskCommOptPT
47.8 +WFSE_WSDL_URI_Prefix=http://jbi.com.sun/wfse/wsdl
47.9 +WFSE_WSDL_URI_Client_Suffix=_wf_client
47.10 +WF_SUFFIX=.wf
47.11 +TaskClient_EndPoint_Prefix=Task
47.12 +TaskClient_EndPoint_Suffix=ClientPort
47.13 +TaskClient_Interface_Suffix=PT
47.14 +
48.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
48.2 +++ b/enterprise/openesbaddons/workflow/project/antsrc/org/netbeans/modules/workflow/project/anttasks/resources/outputtransform.xsl Thu Apr 26 02:33:27 2007 +0000
48.3 @@ -0,0 +1,67 @@
48.4 +<?xml version="1.0" encoding="UTF-8"?>
48.5 +<!-- edited with XMLSpy v2006 sp1 U (http://www.altova.com) by Mei Wu (SeeBeyond Technology Corp.) -->
48.6 +<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:xforms="http://www.w3.org/2002/xforms" xmlns:html="http://www.w3.org/1999/xhtml" xmlns="http://www.w3.org/1999/xhtml">
48.7 + <xsl:template match="html:body">
48.8 + <outputXForm>
48.9 + <xsl:apply-templates select="xforms:group"/>
48.10 + <xsl:apply-templates select="xforms:submit"/>
48.11 + </outputXForm>
48.12 + </xsl:template>
48.13 + <xsl:template match="xforms:group">
48.14 + <xforms:group xmlns:xforms="http://www.w3.org/2002/xforms">
48.15 + <p>
48.16 + <b>
48.17 + <i><xsl:value-of select="xforms:label"/></i>
48.18 + </b>
48.19 + </p>
48.20 + <p>
48.21 + </p>
48.22 + <table border="1">
48.23 + <xsl:apply-templates select="*[name() != 'xforms:label']"/>
48.24 + </table>
48.25 + </xforms:group>
48.26 + </xsl:template>
48.27 + <xsl:template match="xforms:input | xforms:textarea | xforms:secret">
48.28 + <tr>
48.29 + <td>
48.30 + <xsl:apply-templates select="xforms:label"/>
48.31 + </td>
48.32 + <td>
48.33 + <xsl:copy>
48.34 + <xsl:apply-templates select="@*"/>
48.35 + </xsl:copy>
48.36 + </td>
48.37 + </tr>
48.38 + </xsl:template>
48.39 +
48.40 + <xsl:template match="@*">
48.41 + <xsl:copy>
48.42 + </xsl:copy>
48.43 + </xsl:template>
48.44 +
48.45 +<xsl:template match="xforms:select1" >
48.46 + <tr>
48.47 + <td>
48.48 + <xsl:apply-templates select="xforms:label"/>
48.49 + </td>
48.50 + <td>
48.51 + <xsl:copy>
48.52 + <xsl:apply-templates select="@*"/>
48.53 + <xsl:copy-of select="xforms:choices/*"/>
48.54 + </xsl:copy>
48.55 + </td>
48.56 + </tr>
48.57 + </xsl:template>
48.58 +
48.59 +<xsl:template match="xforms:submit">
48.60 +<p>
48.61 +</p>
48.62 + <xsl:copy>
48.63 + <xsl:apply-templates select="@*"/>
48.64 + <xsl:copy-of select="*"/>
48.65 + </xsl:copy>
48.66 +</xsl:template>
48.67 +
48.68 +
48.69 +</xsl:stylesheet>
48.70 +
49.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
49.2 +++ b/enterprise/openesbaddons/workflow/project/antsrc/org/netbeans/modules/workflow/project/anttasks/wsdl/WSDLMessage.java Thu Apr 26 02:33:27 2007 +0000
49.3 @@ -0,0 +1,34 @@
49.4 +/* *************************************************************************
49.5 + *
49.6 + * Copyright (c) 2005, SeeBeyond Technology Corporation,
49.7 + * All Rights Reserved
49.8 + *
49.9 + * This program, and all the routines referenced herein,
49.10 + * are the proprietary properties and trade secrets of
49.11 + * SEEBEYOND TECHNOLOGY CORPORATION.
49.12 + *
49.13 + * Except as provided for by license agreement, this
49.14 + * program shall not be duplicated, used, or disclosed
49.15 + * without written consent signed by an officer of
49.16 + * SEEBEYOND TECHNOLOGY CORPORATION.
49.17 + *
49.18 + ***************************************************************************/
49.19 +package org.netbeans.modules.workflow.project.anttasks.wsdl;
49.20 +
49.21 +import java.util.ArrayList;
49.22 +/**
49.23 + * @author sgenipudi
49.24 + */
49.25 +public class WSDLMessage {
49.26 +
49.27 + private ArrayList<WSDLPart> mListOfParts = new ArrayList<WSDLPart>();
49.28 + public WSDLMessage() {
49.29 + }
49.30 +
49.31 + public void addPart(WSDLPart part) {
49.32 + mListOfParts.add(part);
49.33 + }
49.34 + public ArrayList<WSDLPart> getParts() {
49.35 + return mListOfParts;
49.36 + }
49.37 +}
50.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
50.2 +++ b/enterprise/openesbaddons/workflow/project/antsrc/org/netbeans/modules/workflow/project/anttasks/wsdl/WSDLOperation.java Thu Apr 26 02:33:27 2007 +0000
50.3 @@ -0,0 +1,72 @@
50.4 +/* *************************************************************************
50.5 + *
50.6 + * Copyright (c) 2005, SeeBeyond Technology Corporation,
50.7 + * All Rights Reserved
50.8 + *
50.9 + * This program, and all the routines referenced herein,
50.10 + * are the proprietary properties and trade secrets of
50.11 + * SEEBEYOND TECHNOLOGY CORPORATION.
50.12 + *
50.13 + * Except as provided for by license agreement, this
50.14 + * program shall not be duplicated, used, or disclosed
50.15 + * without written consent signed by an officer of
50.16 + * SEEBEYOND TECHNOLOGY CORPORATION.
50.17 + *
50.18 + ***************************************************************************/
50.19 +package org.netbeans.modules.workflow.project.anttasks.wsdl;
50.20 +
50.21 +import javax.xml.namespace.QName;
50.22 +
50.23 +/**
50.24 + * @author sgenipudi
50.25 + */
50.26 +
50.27 +public class WSDLOperation {
50.28 + private String mOperationName = null;
50.29 + private String mTaskName = null;
50.30 + private WSDLMessage mInputMsg = null;
50.31 + private WSDLMessage mOutputMsg = null;
50.32 + private QName mPortTypeQName = null;
50.33 + public WSDLOperation() {
50.34 + }
50.35 +
50.36 + public void setOperationName(String operationName) {
50.37 + mOperationName = operationName;
50.38 + }
50.39 +
50.40 + public String getOperationName() {
50.41 + return mOperationName;
50.42 + }
50.43 +
50.44 + public void setTaskName(String taskName) {
50.45 + mTaskName = taskName;
50.46 + }
50.47 +
50.48 + public String getTaskName() {
50.49 + return mTaskName;
50.50 + }
50.51 +
50.52 + public void setPortTypeName(QName ptype) {
50.53 + mPortTypeQName = ptype;
50.54 + }
50.55 +
50.56 + public QName getPortTypeName() {
50.57 + return mPortTypeQName;
50.58 + }
50.59 +
50.60 + public void setInputWSDLMessage(WSDLMessage inMsg) {
50.61 + mInputMsg = inMsg;
50.62 + }
50.63 +
50.64 + public void setOutputWSDLMessage(WSDLMessage outMsg) {
50.65 + mOutputMsg = outMsg;
50.66 + }
50.67 +
50.68 + public WSDLMessage getInputWSDLMessage() {
50.69 + return mInputMsg;
50.70 + }
50.71 +
50.72 + public WSDLMessage getOutputWSDLMessage() {
50.73 + return mOutputMsg;
50.74 + }
50.75 +}
51.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
51.2 +++ b/enterprise/openesbaddons/workflow/project/antsrc/org/netbeans/modules/workflow/project/anttasks/wsdl/WSDLPart.java Thu Apr 26 02:33:27 2007 +0000
51.3 @@ -0,0 +1,97 @@
51.4 +/* *************************************************************************
51.5 + *
51.6 + * Copyright (c) 2005, SeeBeyond Technology Corporation,
51.7 + * All Rights Reserved
51.8 + *
51.9 + * This program, and all the routines referenced herein,
51.10 + * are the proprietary properties and trade secrets of
51.11 + * SEEBEYOND TECHNOLOGY CORPORATION.
51.12 + *
51.13 + * Except as provided for by license agreement, this
51.14 + * program shall not be duplicated, used, or disclosed
51.15 + * without written consent signed by an officer of
51.16 + * SEEBEYOND TECHNOLOGY CORPORATION.
51.17 + *
51.18 + ***************************************************************************/
51.19 +package org.netbeans.modules.workflow.project.anttasks.wsdl;
51.20 +
51.21 +import java.util.List;
51.22 +
51.23 +import javax.xml.namespace.QName;
51.24 +
51.25 +import org.netbeans.modules.xml.schema.model.GlobalElement;
51.26 +import org.netbeans.modules.xml.schema.model.GlobalType;
51.27 +import org.netbeans.modules.xml.schema.model.Schema;
51.28 +
51.29 +/**
51.30 + * @author sgenipudi
51.31 + */
51.32 +public class WSDLPart {
51.33 + private String mPartName = null;
51.34 + private QName mQueueName = null;
51.35 + private List mSchemaLocation = null;
51.36 + private GlobalElement mGElement = null;
51.37 + private GlobalType mType = null;
51.38 + private org.netbeans.modules.xml.schema.model.Schema mSchema = null;
51.39 + private boolean mbStandardXMLSchemaSimpleTypes = false;
51.40 + public WSDLPart() {
51.41 + }
51.42 +
51.43 + public String getPartName() {
51.44 + return mPartName;
51.45 + }
51.46 +
51.47 + public void setPartName(String mPartName) {
51.48 + this.mPartName = mPartName;
51.49 + }
51.50 +
51.51 + public QName getQueueName() {
51.52 + return mQueueName;
51.53 + }
51.54 +
51.55 + public GlobalType getType() {
51.56 + return mType;
51.57 + }
51.58 + public void setType(GlobalType type) {
51.59 + mType = type;
51.60 + }
51.61 +
51.62 + public void setStandardXMLSchemaSimpleType(boolean flag) {
51.63 + mbStandardXMLSchemaSimpleTypes = flag;
51.64 + }
51.65 +
51.66 + public boolean isStandardXMLSchemaSimpleTypes() {
51.67 + return mbStandardXMLSchemaSimpleTypes;
51.68 + }
51.69 +
51.70 +
51.71 + public GlobalElement getElement() {
51.72 + return mGElement;
51.73 + }
51.74 +
51.75 + public void setElement(GlobalElement ge) {
51.76 + mGElement = ge;
51.77 + }
51.78 +
51.79 +
51.80 + public void setQueueName(QName mQueueName) {
51.81 + this.mQueueName = mQueueName;
51.82 + }
51.83 +
51.84 + public List getSchemaLocation() {
51.85 + return mSchemaLocation;
51.86 + }
51.87 +
51.88 + public Schema getSchema() {
51.89 + return mSchema;
51.90 + }
51.91 +
51.92 + public void setSchema(Schema sch) {
51.93 + mSchema = sch;
51.94 + }
51.95 +
51.96 +
51.97 + public void setSchemaLocation(List schemaLocation) {
51.98 + this.mSchemaLocation = schemaLocation;
51.99 + }
51.100 +}
52.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
52.2 +++ b/enterprise/openesbaddons/workflow/project/build.xml Thu Apr 26 02:33:27 2007 +0000
52.3 @@ -0,0 +1,105 @@
52.4 +<?xml version="1.0" encoding="UTF-8"?>
52.5 +<!-- You may freely edit this file. See harness/README in the NetBeans platform -->
52.6 +<!-- for some information on what you could do (e.g. targets to override). -->
52.7 +<!-- If you delete this file and reopen the project it will be recreated. -->
52.8 +<project name="org.netbeans.modules.workflow.project" default="netbeans" basedir=".">
52.9 + <description>Builds, tests, and runs the project org.netbeans.modules.workflow.project.</description>
52.10 + <import file="nbproject/build-impl.xml"/>
52.11 + <target name="chiba-extra" depends="release">
52.12 + <echo>called netbeans-extra</echo>
52.13 + <mkdir dir="build/chibaclasses"/>
52.14 + <javac srcdir="chiba_src" destdir="build/chibaclasses" source="1.5" debug="true" deprecation="true">
52.15 + <classpath>
52.16 + <pathelement location="${harness.dir}/../ide8/ant/lib/ant.jar"/>
52.17 + <pathelement location="${harness.dir}/../soa1/modules/ext/jxpath/jxpath1.1.jar"/>
52.18 + <pathelement location="${harness.dir}/../ide8/modules/ext/xerces-2.8.0.jar"/>
52.19 + <pathelement location="${cluster}/modules/ext/workflow/log4j-1.2.13.jar"/>
52.20 + </classpath>
52.21 + </javac>
52.22 +
52.23 + <jar jarfile="${cluster}/modules/ext/workflow/chiba.jar" compress="false">
52.24 + <fileset dir="build/chibaclasses"/>
52.25 + </jar>
52.26 +
52.27 + </target>
52.28 + <target name="ant-extra" depends="chiba-extra">
52.29 + <echo>called netbeans-extra</echo>
52.30 + <mkdir dir="build/antclasses"/>
52.31 + <javac srcdir="antsrc" destdir="build/antclasses" source="1.5" debug="true" deprecation="true">
52.32 + <classpath>
52.33 + <path refid="cp"/>
52.34 + <pathelement location="${harness.dir}/../ide8/ant/lib/ant.jar"/>
52.35 + <pathelement location="${cluster}/${module.jar}"/>
52.36 + <pathelement location="${cluster}/modules/ext/workflow/workflowmodel.jar"/>
52.37 + <pathelement location="${cluster}/modules/ext/workflow/wfse_def.jar"/>
52.38 + <pathelement location="${cluster}/modules/ext/workflow/wsdl4j.jar"/>
52.39 + <pathelement location="${cluster}/../soa1/modules/ext/xmlbeans-2.1.0/xbean.jar" />
52.40 + <pathelement location="${cluster}/../soa1/modules/ext/xmlbeans-2.1.0/xbean_xpath.jar" />
52.41 + <pathelement location="${cluster}/../soa1/modules/ext/xmlbeans-2.1.0/resolver.jar" />
52.42 + <pathelement location="${cluster}/../soa1/modules/ext/xmlbeans-2.1.0/jsr173_1.0_api.jar" />
52.43 + <pathelement location="${cluster}/../soa1/modules/ext/xmlbeans-2.1.0/xmlpublic.jar" />
52.44 + <pathelement location="${cluster}/modules/ext/workflow/chiba.jar" />
52.45 + <pathelement location="${harness.dir}/../soa1/modules/ext/jxpath/jxpath1.1.jar"/>
52.46 + <pathelement location="${harness.dir}/../ide8/modules/ext/jxpath/xerces-2.8.0.jar"/>
52.47 + <pathelement location="${cluster}/modules/ext/workflow/log4j-1.2.13.jar"/>
52.48 + </classpath>
52.49 + </javac>
52.50 +<!--
52.51 + <mkdir dir="${cluster}/modules/ext/workflow"/>
52.52 +-->
52.53 +
52.54 + <mkdir dir="${cluster}/ant/nblib/"/>
52.55 + <jar jarfile="${cluster}/ant/nblib/org-netbeans-modules-workflow-project.jar" compress="false">
52.56 + <fileset dir="build/antclasses"/>
52.57 + <fileset dir="antsrc">
52.58 + <filename name="**/*.properties"/>
52.59 + </fileset>
52.60 + <fileset dir="antsrc">
52.61 + <include name="**/*.xml"/>
52.62 + </fileset>
52.63 + <fileset dir="build/classes">
52.64 + <filename name="**/TaskStaticTemplate.wsdl"/>
52.65 + </fileset>
52.66 + <fileset dir="antsrc">
52.67 + <include name="**/*.xsl"/>
52.68 + </fileset>
52.69 + </jar>
52.70 +
52.71 +
52.72 + <jar jarfile="${cluster}/modules/ext/workflow/anttask.jar" compress="false">
52.73 + <fileset dir="build/antclasses"/>
52.74 + <fileset dir="antsrc">
52.75 + <filename name="**/*.properties"/>
52.76 + </fileset>
52.77 + <fileset dir="antsrc">
52.78 + <include name="**/*.xml"/>
52.79 + </fileset>
52.80 + <fileset dir="antsrc">
52.81 + <include name="**/*.xsl"/>
52.82 + </fileset>
52.83 + </jar>
52.84 + </target>
52.85 +
52.86 + <target name="netbeans-extra" depends="ant-extra" />
52.87 +
52.88 +
52.89 +<!--
52.90 + <target name="netbeans-extra" depends="ant-extra">
52.91 + <echo>called netbeans-extra</echo>
52.92 + <copy todir="${cluster}/modules/ext/workflow">
52.93 + <fileset dir="${harness.dir}/../soa1/modules/ext">
52.94 + <include name="*.jar"/>
52.95 + </fileset>
52.96 + </copy>
52.97 + </target>
52.98 +-->
52.99 +
52.100 + <!--
52.101 + <target name="clean" depends="projectized-common.clean">
52.102 + <echo message="Cleaning ${project.workflowmodel}"/>
52.103 + <ant target="clean" inheritall="false" antfile="${project.workflowmodel}/build.xml" inheritrefs="false"/>
52.104 + <echo message="Done cleaning ${project.workflowmodel}"/>
52.105 + </target>
52.106 +-->
52.107 +
52.108 +</project>
53.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
53.2 +++ b/enterprise/openesbaddons/workflow/project/chiba_src/org/chiba/tools/schemabuilder/AbstractSchemaFormBuilder.java Thu Apr 26 02:33:27 2007 +0000
53.3 @@ -0,0 +1,3723 @@
53.4 +// Copyright 2006 Chibacon
53.5 +
53.6 +/*
53.7 + *
53.8 + * Artistic License
53.9 + *
53.10 + * Preamble
53.11 + *
53.12 + * The intent of this document is to state the conditions under which a Package may be copied, such that
53.13 + * the Copyright Holder maintains some semblance of artistic control over the development of the
53.14 + * package, while giving the users of the package the right to use and distribute the Package in a
53.15 + * more-or-less customary fashion, plus the right to make reasonable modifications.
53.16 + *
53.17 + * Definitions:
53.18 + *
53.19 + * "Package" refers to the collection of files distributed by the Copyright Holder, and derivatives
53.20 + * of that collection of files created through textual modification.
53.21 + *
53.22 + * "Standard Version" refers to such a Package if it has not been modified, or has been modified
53.23 + * in accordance with the wishes of the Copyright Holder.
53.24 + *
53.25 + * "Copyright Holder" is whoever is named in the copyright or copyrights for the package.
53.26 + *
53.27 + * "You" is you, if you're thinking about copying or distributing this Package.
53.28 + *
53.29 + * "Reasonable copying fee" is whatever you can justify on the basis of media cost, duplication
53.30 + * charges, time of people involved, and so on. (You will not be required to justify it to the
53.31 + * Copyright Holder, but only to the computing community at large as a market that must bear the
53.32 + * fee.)
53.33 + *
53.34 + * "Freely Available" means that no fee is charged for the item itself, though there may be fees
53.35 + * involved in handling the item. It also means that recipients of the item may redistribute it under
53.36 + * the same conditions they received it.
53.37 + *
53.38 + * 1. You may make and give away verbatim copies of the source form of the Standard Version of this
53.39 + * Package without restriction, provided that you duplicate all of the original copyright notices and
53.40 + * associated disclaimers.
53.41 + *
53.42 + * 2. You may apply bug fixes, portability fixes and other modifications derived from the Public Domain
53.43 + * or from the Copyright Holder. A Package modified in such a way shall still be considered the
53.44 + * Standard Version.
53.45 + *
53.46 + * 3. You may otherwise modify your copy of this Package in any way, provided that you insert a
53.47 + * prominent notice in each changed file stating how and when you changed that file, and provided that
53.48 + * you do at least ONE of the following:
53.49 + *
53.50 + * a) place your modifications in the Public Domain or otherwise make them Freely
53.51 + * Available, such as by posting said modifications to Usenet or an equivalent medium, or
53.52 + * placing the modifications on a major archive site such as ftp.uu.net, or by allowing the
53.53 + * Copyright Holder to include your modifications in the Standard Version of the Package.
53.54 + *
53.55 + * b) use the modified Package only within your corporation or organization.
53.56 + *
53.57 + * c) rename any non-standard executables so the names do not conflict with standard
53.58 + * executables, which must also be provided, and provide a separate manual page for each
53.59 + * non-standard executable that clearly documents how it differs from the Standard
53.60 + * Version.
53.61 + *
53.62 + * d) make other distribution arrangements with the Copyright Holder.
53.63 + *
53.64 + * 4. You may distribute the programs of this Package in object code or executable form, provided that
53.65 + * you do at least ONE of the following:
53.66 + *
53.67 + * a) distribute a Standard Version of the executables and library files, together with
53.68 + * instructions (in the manual page or equivalent) on where to get the Standard Version.
53.69 + *
53.70 + * b) accompany the distribution with the machine-readable source of the Package with
53.71 + * your modifications.
53.72 + *
53.73 + * c) accompany any non-standard executables with their corresponding Standard Version
53.74 + * executables, giving the non-standard executables non-standard names, and clearly
53.75 + * documenting the differences in manual pages (or equivalent), together with instructions
53.76 + * on where to get the Standard Version.
53.77 + *
53.78 + * d) make other distribution arrangements with the Copyright Holder.
53.79 + *
53.80 + * 5. You may charge a reasonable copying fee for any distribution of this Package. You may charge
53.81 + * any fee you choose for support of this Package. You may not charge a fee for this Package itself.
53.82 + * However, you may distribute this Package in aggregate with other (possibly commercial) programs as
53.83 + * part of a larger (possibly commercial) software distribution provided that you do not advertise this
53.84 + * Package as a product of your own.
53.85 + *
53.86 + * 6. The scripts and library files supplied as input to or produced as output from the programs of this
53.87 + * Package do not automatically fall under the copyright of this Package, but belong to whomever
53.88 + * generated them, and may be sold commercially, and may be aggregated with this Package.
53.89 + *
53.90 + * 7. C or perl subroutines supplied by you and linked into this Package shall not be considered part of
53.91 + * this Package.
53.92 + *
53.93 + * 8. The name of the Copyright Holder may not be used to endorse or promote products derived from
53.94 + * this software without specific prior written permission.
53.95 + *
53.96 + * 9. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
53.97 + * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
53.98 + * MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
53.99 + *
53.100 + */
53.101 +package org.chiba.tools.schemabuilder;
53.102 +
53.103 +import org.apache.commons.jxpath.JXPathContext;
53.104 +import org.apache.commons.jxpath.Pointer;
53.105 +import org.apache.log4j.ConsoleAppender;
53.106 +import org.apache.log4j.Layout;
53.107 +import org.apache.log4j.SimpleLayout;
53.108 +import com.sun.org.apache.xerces.internal.xs.*;
53.109 +import org.chiba.xml.dom.DOMUtil;
53.110 +import org.chiba.xml.ns.NamespaceResolver;
53.111 +import org.w3c.dom.*;
53.112 +import org.w3c.dom.bootstrap.DOMImplementationRegistry;
53.113 +import org.xml.sax.InputSource;
53.114 +
53.115 +import javax.xml.parsers.DocumentBuilder;
53.116 +import javax.xml.parsers.DocumentBuilderFactory;
53.117 +import javax.xml.parsers.ParserConfigurationException;
53.118 +import javax.xml.transform.*;
53.119 +import javax.xml.transform.dom.DOMSource;
53.120 +import javax.xml.transform.stream.StreamResult;
53.121 +import java.io.IOException;
53.122 +import java.io.StringWriter;
53.123 +import java.util.*;
53.124 +import java.util.Map.Entry;
53.125 +
53.126 +/*
53.127 + * Search for TODO for things remaining to-do in this implementation.
53.128 + *
53.129 + * TODO: Support configuration mechanism to allow properties to be set without programming.
53.130 + * TODO: i18n/l10n of messages, hints, captions. Possibly leverage org.chiba.i18n classes.
53.131 + * TODO: When Chiba supports itemset, use schema keyref and key constraints for validation.
53.132 + * TODO: Support namespaces in instance documents. Currently can't do this due to Chiba bugs.
53.133 + * TODO: Place default values for list and enumeration types at the beginning of the item list.
53.134 + *
53.135 + */
53.136 +
53.137 +/**
53.138 + * An abstract implementation of the SchemaFormBuilder interface allowing
53.139 + * an XForm to be automatically generated for an XML Schema definition.
53.140 + * This abstract class implements the buildForm and buildFormAsString methods
53.141 + * and associated helper but relies on concrete subclasses to implement other
53.142 + * required interface methods (createXXX, startXXX, and endXXX methods).
53.143 + *
53.144 + * @author $Author$
53.145 + * @version $Id$
53.146 + * @deprecated
53.147 + */
53.148 +public abstract class AbstractSchemaFormBuilder implements SchemaFormBuilder {
53.149 + private static final String PROPERTY_PREFIX =
53.150 + "http://www.chiba.org/properties/schemaFormBuilder/";
53.151 +
53.152 + /**
53.153 + * Property to control the cascading style sheet used for the XForm - corresponds to envelope@chiba:css-style.
53.154 + */
53.155 + public static final String CSS_STYLE_PROP =
53.156 + PROPERTY_PREFIX + "envelope@css-style";
53.157 + private static final String DEFAULT_CSS_STYLE_PROP = "style.css";
53.158 +
53.159 + /**
53.160 + * Property to control the selection of UI control for a selectOne control.
53.161 + * If a selectOne control has >= the number of values specified in this property,
53.162 + * it is considered a <b>long</b> list, and the UI control specified by
53.163 + * SELECTONE_UI_CONTROL_LONG_PROP is used. Otherwise, the value of SELECTONE_UI_CONTROL_SHORT_PROP
53.164 + * is used.
53.165 + */
53.166 + public static final String SELECTONE_LONG_LIST_SIZE_PROP =
53.167 + PROPERTY_PREFIX + "select1@longListSize";
53.168 +
53.169 + /**
53.170 + * Property to specify the selectMany UI control to be used when there are releatively few items
53.171 + * to choose from.
53.172 + */
53.173 + public static final String SELECTONE_UI_CONTROL_SHORT_PROP =
53.174 + PROPERTY_PREFIX + "select1@appearance/short";
53.175 +
53.176 + /**
53.177 + * Property to specify the selectMany UI control to be used when there are large numbers of items
53.178 + * to choose from.
53.179 + */
53.180 + public static final String SELECTONE_UI_CONTROL_LONG_PROP =
53.181 + PROPERTY_PREFIX + "select1@appearance/long";
53.182 + private static final String DEFAULT_SELECTONE_UI_CONTROL_SHORT_PROP =
53.183 + "full";
53.184 + private static final String DEFAULT_SELECTONE_UI_CONTROL_LONG_PROP =
53.185 + "minimal";
53.186 +
53.187 + /**
53.188 + * Property to control the selection of UI control for a selectMany control.
53.189 + * If a selectMany control has >= the number of values specified in this property,
53.190 + * it is considered a <b>long</b> list, and the UI control specified by
53.191 + * SELECTMANY_UI_CONTROL_LONG_PROP is used. Otherwise, the value of SELECTMANY_UI_CONTROL_SHORT_PROP
53.192 + * is used.
53.193 + */
53.194 + public static final String SELECTMANY_LONG_LIST_SIZE_PROP =
53.195 + PROPERTY_PREFIX + "select@longListSize";
53.196 +
53.197 + /**
53.198 + * Property to specify the selectMany UI control to be used when there are releatively few items
53.199 + * to choose from.
53.200 + */
53.201 + public static final String SELECTMANY_UI_CONTROL_SHORT_PROP =
53.202 + PROPERTY_PREFIX + "select@appearance/short";
53.203 +
53.204 + /**
53.205 + * Property to specify the selectMany UI control to be used when there are large numbers of items
53.206 + * to choose from.
53.207 + */
53.208 + public static final String SELECTMANY_UI_CONTROL_LONG_PROP =
53.209 + PROPERTY_PREFIX + "select@appearance/long";
53.210 + private static final String DEFAULT_SELECTMANY_UI_CONTROL_SHORT_PROP =
53.211 + "full";
53.212 + private static final String DEFAULT_SELECTMANY_UI_CONTROL_LONG_PROP =
53.213 + "compact";
53.214 + private static final String DEFAULT_LONG_LIST_MAX_SIZE = "6";
53.215 +
53.216 + /**
53.217 + * Property to control the box alignment of a group - corresponds to xforms:group@chiba:box-align.
53.218 + * There are four valid values for this property - right, left, top, and bottom.
53.219 + * The default value is <b>right</b>.
53.220 + */
53.221 + public static final String GROUP_BOX_ALIGN_PROP =
53.222 + PROPERTY_PREFIX + "group@box-align";
53.223 + private static final String DEFAULT_GROUP_BOX_ALIGN = "right";
53.224 +
53.225 + /**
53.226 + * Property to control the box orientation of a group - corresponds to xforms:group@chiba:box-orient.
53.227 + * There are two valid values for this property - vertical and horizontal.
53.228 + * The default value is <b>vertical</b>.
53.229 + */
53.230 + public static final String GROUP_BOX_ORIENT_PROP =
53.231 + PROPERTY_PREFIX + "group@box-orient";
53.232 + private static final String DEFAULT_GROUP_BOX_ORIENT = "vertical";
53.233 +
53.234 + /**
53.235 + * Property to control the width of a group - corresponds to xforms:group/@chiba:width.
53.236 + * This value may be expressed as a percentage value or as an absolute size.
53.237 + */
53.238 + public static final String GROUP_WIDTH_PROP =
53.239 + PROPERTY_PREFIX + "group@width";
53.240 + private static final String DEFAULT_GROUP_WIDTH = "60%";
53.241 +
53.242 + /**
53.243 + * Property to control the caption width of a group - corresponds to xforms:group/@chiba:caption-width.
53.244 + * This value may be expressed as a percentage value or as an absolute size.
53.245 + */
53.246 + public static final String GROUP_CAPTION_WIDTH_PROP =
53.247 + PROPERTY_PREFIX + "group@caption-width";
53.248 + private static final String DEFAULT_GROUP_CAPTION_WIDTH = "30%";
53.249 +
53.250 + /**
53.251 + * Property to control the border of a group - corresponds to xforms:group/@chiba:border.
53.252 + * A value of <b>0</b> indicates no border, a value of <b>1</b> indicates a border is provided.
53.253 + */
53.254 + public static final String GROUP_BORDER_PROP =
53.255 + PROPERTY_PREFIX + "group@border";
53.256 + private static final String DEFAULT_GROUP_BORDER = "0";
53.257 +
53.258 + /**
53.259 + * Prossible values of the "@method" on the "submission" element
53.260 + */
53.261 + public static final String SUBMIT_METHOD_POST = "post";
53.262 +
53.263 + /**
53.264 + * __UNDOCUMENTED__
53.265 + */
53.266 + public static final String SUBMIT_METHOD_PUT = "put";
53.267 +
53.268 + /**
53.269 + * __UNDOCUMENTED__
53.270 + */
53.271 + public static final String SUBMIT_METHOD_GET = "get";
53.272 +
53.273 + /**
53.274 + * __UNDOCUMENTED__
53.275 + */
53.276 + public static final String SUBMIT_METHOD_FORM_DATA_POST = "form-data-post";
53.277 +
53.278 + /**
53.279 + * __UNDOCUMENTED__
53.280 + */
53.281 + public static final String SUBMIT_METHOD_URLENCODED_POST =
53.282 + "urlencoded-post";
53.283 +
53.284 + /**
53.285 + * possible instance modes
53.286 + */
53.287 + public static final int INSTANCE_MODE_NONE = 0;
53.288 +
53.289 + /**
53.290 + * __UNDOCUMENTED__
53.291 + */
53.292 + public static final int INSTANCE_MODE_INCLUDED = 1;
53.293 +
53.294 + /**
53.295 + * __UNDOCUMENTED__
53.296 + */
53.297 + public static final int INSTANCE_MODE_HREF = 2;
53.298 +
53.299 + /**
53.300 + * __UNDOCUMENTED__
53.301 + */
53.302 + protected Source _instanceSource;
53.303 +
53.304 + /**
53.305 + * __UNDOCUMENTED__
53.306 + */
53.307 + protected String _action;
53.308 +
53.309 + /**
53.310 + * __UNDOCUMENTED__
53.311 + */
53.312 + protected String _instanceHref;
53.313 +
53.314 + /**
53.315 + * Properties choosed by the user
53.316 + */
53.317 + protected String _rootTagName;
53.318 +
53.319 + /**
53.320 + * __UNDOCUMENTED__
53.321 + */
53.322 + protected String _stylesheet;
53.323 +
53.324 + /**
53.325 + * __UNDOCUMENTED__
53.326 + */
53.327 + protected String _submitMethod;
53.328 +
53.329 + /**
53.330 + * __UNDOCUMENTED__
53.331 + */
53.332 + protected String _base;
53.333 +
53.334 + /**
53.335 + * __UNDOCUMENTED__
53.336 + */
53.337 + protected WrapperElementsBuilder _wrapper;
53.338 +
53.339 + /**
53.340 + * __UNDOCUMENTED__
53.341 + */
53.342 + protected int _instanceMode = 0;
53.343 +
53.344 + /**
53.345 + * __UNDOCUMENTED__
53.346 + */
53.347 + protected boolean _useSchemaTypes = false;
53.348 +
53.349 + protected boolean addSubmit = false;
53.350 +
53.351 + private DocumentBuilder documentBuilder;
53.352 +
53.353 + /**
53.354 + * generic counter -> replaced by an hashMap with:
53.355 + * keys: name of the elements
53.356 + * values: "Long" representing the counter for this element
53.357 + */
53.358 +
53.359 + //private long refCounter;
53.360 + private HashMap counter;
53.361 + private Properties properties;
53.362 + protected XSModel schema;
53.363 + private String targetNamespace;
53.364 +
53.365 + private Map namespacePrefixes = new HashMap();
53.366 +
53.367 + // typeTree
53.368 + // each entry is keyed by the type name
53.369 + // value is an ArrayList that contains the XSTypeDefinition's which
53.370 + // are compatible with the specific type. Compatible means that
53.371 + // can be used as a substituted type using xsi:type
53.372 + // In order for it to be compatible, it cannot be abstract, and
53.373 + // it must be derived by extension.
53.374 +// The ArrayList does not contain its own type + has the other types only once
53.375 + //
53.376 + private TreeMap typeTree;
53.377 +
53.378 + /**
53.379 + * configure LOGGER
53.380 + */
53.381 + static {
53.382 + Layout layout = new SimpleLayout();
53.383 + LOGGER.addAppender(new ConsoleAppender(layout));
53.384 + }
53.385 +
53.386 + /**
53.387 + * Creates a new instance of AbstractSchemaFormBuilder
53.388 + */
53.389 + public AbstractSchemaFormBuilder(String rootTagName) {
53.390 + this._rootTagName = rootTagName;
53.391 + typeTree = new TreeMap();
53.392 + properties = new Properties();
53.393 +
53.394 + DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
53.395 +
53.396 + try {
53.397 + factory.setNamespaceAware(true);
53.398 + factory.setValidating(false);
53.399 + documentBuilder = factory.newDocumentBuilder();
53.400 + } catch (ParserConfigurationException x) {
53.401 + x.printStackTrace();
53.402 + }
53.403 +
53.404 + //default wrapper: HTML
53.405 + //_wrapper = new BaseWrapperElementsBuilder();
53.406 + _wrapper = new XHTMLWrapperElementsBuilder();
53.407 + reset();
53.408 + }
53.409 +
53.410 + /**
53.411 + * Creates a new instance of AbstractSchemaFormBuilder
53.412 + */
53.413 + public AbstractSchemaFormBuilder(String rootTagName, boolean addSubmit) {
53.414 + this._rootTagName = rootTagName;
53.415 + typeTree = new TreeMap();
53.416 + properties = new Properties();
53.417 +
53.418 + DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
53.419 +
53.420 + try {
53.421 + factory.setNamespaceAware(true);
53.422 + factory.setValidating(false);
53.423 + documentBuilder = factory.newDocumentBuilder();
53.424 + } catch (ParserConfigurationException x) {
53.425 + x.printStackTrace();
53.426 + }
53.427 +
53.428 + //default wrapper: HTML
53.429 + //_wrapper = new BaseWrapperElementsBuilder();
53.430 + _wrapper = new XHTMLWrapperElementsBuilder();
53.431 + reset();
53.432 + this.addSubmit = addSubmit;
53.433 + }
53.434 +
53.435 +
53.436 + /**
53.437 + * Creates a new AbstractSchemaFormBuilder object.
53.438 + *
53.439 + * @param rootTagName __UNDOCUMENTED__
53.440 + * @param instanceSource __UNDOCUMENTED__
53.441 + * @param action __UNDOCUMENTED__
53.442 + * @param submitMethod __UNDOCUMENTED__
53.443 + * @param wrapper __UNDOCUMENTED__
53.444 + * @param stylesheet __UNDOCUMENTED__
53.445 + */
53.446 + public AbstractSchemaFormBuilder(String rootTagName,
53.447 + Source instanceSource,
53.448 + String action,
53.449 + String submitMethod,
53.450 + WrapperElementsBuilder wrapper,
53.451 + String stylesheet,
53.452 + String base,
53.453 + boolean userSchemaTypes,
53.454 + boolean addSumbit) {
53.455 + this(rootTagName);
53.456 + this._instanceSource = instanceSource;
53.457 +
53.458 + if (instanceSource != null) {
53.459 + this._instanceMode =
53.460 + AbstractSchemaFormBuilder.INSTANCE_MODE_INCLUDED;
53.461 + }
53.462 +
53.463 + this._action = action;
53.464 + this._stylesheet = stylesheet;
53.465 + this._base = base;
53.466 + this._useSchemaTypes = userSchemaTypes;
53.467 +
53.468 + //control if it is one of the SUBMIT_METHOD attributes?
53.469 + this._submitMethod = submitMethod;
53.470 + this._wrapper = wrapper;
53.471 + this.addSubmit = addSubmit;
53.472 + }
53.473 +
53.474 + /**
53.475 + * Creates a new AbstractSchemaFormBuilder object.
53.476 + *
53.477 + * @param rootTagName __UNDOCUMENTED__
53.478 + * @param instanceHref __UNDOCUMENTED__
53.479 + * @param action __UNDOCUMENTED__
53.480 + * @param submitMethod __UNDOCUMENTED__
53.481 + * @param wrapper __UNDOCUMENTED__
53.482 + * @param stylesheet __UNDOCUMENTED__
53.483 + */
53.484 + public AbstractSchemaFormBuilder(String rootTagName,
53.485 + String instanceHref,
53.486 + String action,
53.487 + String submitMethod,
53.488 + WrapperElementsBuilder wrapper,
53.489 + String stylesheet,
53.490 + String base,
53.491 + boolean userSchemaTypes,
53.492 + boolean addSumbit) {
53.493 + this(rootTagName);
53.494 + this._instanceHref = instanceHref;
53.495 +
53.496 + if ((instanceHref != null) && !instanceHref.equals("")) {
53.497 + this._instanceMode = AbstractSchemaFormBuilder.INSTANCE_MODE_HREF;
53.498 + }
53.499 +
53.500 + this._action = action;
53.501 + this._stylesheet = stylesheet;
53.502 + this._base = base;
53.503 + this._useSchemaTypes = userSchemaTypes;
53.504 +
53.505 + //control if it is one of the SUBMIT_METHOD attributes?
53.506 + this._submitMethod = submitMethod;
53.507 + this._wrapper = wrapper;
53.508 + this.addSubmit = addSubmit;
53.509 +
53.510 + }
53.511 +
53.512 + /**
53.513 + * __UNDOCUMENTED__
53.514 + *
53.515 + * @return __UNDOCUMENTED__
53.516 + */
53.517 + public String getAction() {
53.518 + return _action;
53.519 + }
53.520 +
53.521 + /**
53.522 + * __UNDOCUMENTED__
53.523 + *
53.524 + * @return __UNDOCUMENTED__
53.525 + */
53.526 + public String getInstanceHref() {
53.527 + return _instanceHref;
53.528 + }
53.529 +
53.530 + /**
53.531 + * __UNDOCUMENTED__
53.532 + *
53.533 + * @return __UNDOCUMENTED__
53.534 + */
53.535 + public int getInstanceMode() {
53.536 + return _instanceMode;
53.537 + }
53.538 +
53.539 + /**
53.540 + * __UNDOCUMENTED__
53.541 + *
53.542 + * @return __UNDOCUMENTED__
53.543 + */
53.544 + public Source getInstanceSource() {
53.545 + return _instanceSource;
53.546 + }
53.547 +
53.548 + /**
53.549 + * __UNDOCUMENTED__
53.550 + *
53.551 + * @return __UNDOCUMENTED__
53.552 + */
53.553 + public Properties getProperties() {
53.554 + return properties;
53.555 + }
53.556 +
53.557 + /**
53.558 + * __UNDOCUMENTED__
53.559 + *
53.560 + * @param key __UNDOCUMENTED__
53.561 + * @param value __UNDOCUMENTED__
53.562 + */
53.563 + public void setProperty(String key, String value) {
53.564 + getProperties().setProperty(key, value);
53.565 + }
53.566 +
53.567 + /**
53.568 + * __UNDOCUMENTED__
53.569 + *
53.570 + * @param key __UNDOCUMENTED__
53.571 + * @return __UNDOCUMENTED__
53.572 + */
53.573 + public String getProperty(String key) {
53.574 + return getProperties().getProperty(key);
53.575 + }
53.576 +
53.577 + /**
53.578 + * __UNDOCUMENTED__
53.579 + *
53.580 + * @param key __UNDOCUMENTED__
53.581 + * @param defaultValue __UNDOCUMENTED__
53.582 + * @return __UNDOCUMENTED__
53.583 + */
53.584 + public String getProperty(String key, String defaultValue) {
53.585 + return getProperties().getProperty(key, defaultValue);
53.586 + }
53.587 +
53.588 + /**
53.589 + * __UNDOCUMENTED__
53.590 + *
53.591 + * @return __UNDOCUMENTED__
53.592 + */
53.593 + public String getRootTagName() {
53.594 + return _rootTagName;
53.595 + }
53.596 +
53.597 + /**
53.598 + * __UNDOCUMENTED__
53.599 + *
53.600 + * @return __UNDOCUMENTED__
53.601 + */
53.602 + public String getStylesheet() {
53.603 + return _stylesheet;
53.604 + }
53.605 +
53.606 + /**
53.607 + * __UNDOCUMENTED__
53.608 + *
53.609 + * @return __UNDOCUMENTED__
53.610 + */
53.611 + public String getSubmitMethod() {
53.612 + return _submitMethod;
53.613 + }
53.614 +
53.615 + private void loadSchema(String inputURI)
53.616 + throws
53.617 + java.lang.ClassNotFoundException,
53.618 + java.lang.InstantiationException,
53.619 + java.lang.IllegalAccessException {
53.620 +
53.621 +// Get DOM Implementation using DOM Registry
53.622 + System.setProperty(DOMImplementationRegistry.PROPERTY,
53.623 + "org.apache.xerces.dom.DOMXSImplementationSourceImpl");
53.624 + DOMImplementationRegistry registry =
53.625 + DOMImplementationRegistry.newInstance();
53.626 + Object o = registry.getDOMImplementation("XS-Loader");
53.627 + if (o instanceof XSImplementation) {
53.628 + XSImplementation impl = (XSImplementation) o;
53.629 + XSLoader schemaLoader = impl.createXSLoader(null);
53.630 + schema = schemaLoader.loadURI(inputURI);
53.631 + } else if (o != null) {
53.632 + if (LOGGER.isDebugEnabled()) {
53.633 + LOGGER.debug("DOMImplementation is not a XSImplementation: "
53.634 + + o.getClass().getName());
53.635 + }
53.636 + System.exit(1);
53.637 + }
53.638 + }
53.639 +
53.640 + /**
53.641 + * builds a form from a XML schema.
53.642 + *
53.643 + * @param inputURI the URI of the Schema to be used
53.644 + * @return __UNDOCUMENTED__
53.645 + * @throws FormBuilderException __UNDOCUMENTED__
53.646 + */
53.647 + public Document buildForm(String inputURI) throws FormBuilderException {
53.648 + try {
53.649 + this.loadSchema(inputURI);
53.650 + buildTypeTree(schema);
53.651 +
53.652 + //refCounter = 0;
53.653 + counter = new HashMap();
53.654 +
53.655 + Document xForm =
53.656 + createFormTemplate(_rootTagName,
53.657 + _rootTagName + " Form",
53.658 + getProperty(CSS_STYLE_PROP, DEFAULT_CSS_STYLE_PROP));
53.659 +
53.660 + //this.buildInheritenceTree(schema);
53.661 + Element envelopeElement = xForm.getDocumentElement();
53.662 +
53.663 + //Element formSection = (Element) envelopeElement.getElementsByTagNameNS(CHIBA_NS, "form").item(0);
53.664 + //Element formSection =(Element) envelopeElement.getElementsByTagName("body").item(0);
53.665 + //find form element: last element created
53.666 + NodeList children = xForm.getDocumentElement().getChildNodes();
53.667 + int nb = children.getLength();
53.668 + Element formSection = (Element) children.item(nb - 1);
53.669 +
53.670 + Element modelSection =
53.671 + (Element) envelopeElement.getElementsByTagNameNS(XFORMS_NS,
53.672 + "model").item(0);
53.673 +
53.674 + //add XMLSchema if we use schema types
53.675 + if (_useSchemaTypes && modelSection != null) {
53.676 + modelSection.setAttribute("schema",
53.677 + inputURI);
53.678 + }
53.679 +
53.680 + //change stylesheet
53.681 + String stylesheet = this.getStylesheet();
53.682 +
53.683 + if ((stylesheet != null) && !stylesheet.equals("")) {
53.684 + envelopeElement.setAttribute("stylesheet",
53.685 + stylesheet);
53.686 + }
53.687 +
53.688 + // TODO: Commented out because comments aren't output properly by the Transformer.
53.689 + //String comment = "This XForm was automatically generated by " + this.getClass().getName() + " on " + (new Date()) + System.getProperty("line.separator") + " from the '" + rootElementName + "' element from the '" + schema.getSchemaTargetNS() + "' XML Schema.";
53.690 + //xForm.insertBefore(xForm.createComment(comment),envelopeElement);
53.691 + //xxx XSDNode node = findXSDNodeByName(rootElementTagName,schemaNode.getElementSet());
53.692 +
53.693 + //check if target namespace
53.694 + //no way to do this with XS API ? load DOM document ?
53.695 + //TODO: find a better way to find the targetNamespace
53.696 + try {
53.697 + Document domDoc = DOMUtil.parseXmlFile(inputURI, true, false);
53.698 + if (domDoc != null) {
53.699 + Element root = domDoc.getDocumentElement();
53.700 + targetNamespace = root.getAttribute("targetNamespace");
53.701 + if (targetNamespace != null && targetNamespace.equals(""))
53.702 + targetNamespace = null;
53.703 + }
53.704 + } catch (Exception ex) {
53.705 + LOGGER.error("Schema not loaded as DOM document: " + ex.getMessage());
53.706 + }
53.707 +
53.708 + //if target namespace & we use the schema types: add it to form ns declarations
53.709 + if (_useSchemaTypes && targetNamespace != null && !targetNamespace.equals("")) {
53.710 + envelopeElement.setAttribute(
53.711 + "schema",
53.712 + targetNamespace);
53.713 + }
53.714 +
53.715 + //TODO: WARNING: in Xerces 2.6.1, parameters are switched !!! (name, namespace)
53.716 + //XSElementDeclaration rootElementDecl =schema.getElementDeclaration(targetNamespace, _rootTagName);
53.717 + XSElementDeclaration rootElementDecl =
53.718 + schema.getElementDeclaration(_rootTagName, targetNamespace);
53.719 +
53.720 + if (rootElementDecl == null) {
53.721 + //DEBUG
53.722 + rootElementDecl =
53.723 + schema.getElementDeclaration(_rootTagName, targetNamespace);
53.724 + if (rootElementDecl != null && LOGGER.isDebugEnabled())
53.725 + LOGGER.debug("getElementDeclaration: inversed parameters OK !!!");
53.726 +
53.727 + throw new FormBuilderException("Invalid root element tag name ["
53.728 + + _rootTagName
53.729 + + ", targetNamespace="
53.730 + + targetNamespace
53.731 + + "]");
53.732 + }
53.733 +
53.734 + Element instanceElement =
53.735 + (Element) modelSection.appendChild(xForm.createElementNS(XFORMS_NS,
53.736 + getXFormsNSPrefix() + "instance"));
53.737 + this.setXFormsId(instanceElement);
53.738 +
53.739 + Element rootElement;
53.740 +
53.741 + if (_instanceMode == AbstractSchemaFormBuilder.INSTANCE_MODE_NONE) {
53.742 + rootElement = (Element) instanceElement.appendChild(xForm.createElementNS(targetNamespace, getElementName(rootElementDecl, xForm)));
53.743 +
53.744 + String prefix = xmlSchemaInstancePrefix.substring(0, xmlSchemaInstancePrefix.length() - 1);
53.745 + rootElement.setAttribute(prefix, XMLSCHEMA_INSTANCE_NAMESPACE_URI);
53.746 +
53.747 + } else if (_instanceMode == AbstractSchemaFormBuilder.INSTANCE_MODE_INCLUDED)
53.748 + //get the instance element
53.749 + {
53.750 + boolean ok = true;
53.751 +
53.752 + try {
53.753 + /*DOMResult result = new DOMResult();
53.754 + TransformerFactory trFactory =
53.755 + TransformerFactory.newInstance();
53.756 + Transformer tr = trFactory.newTransformer();
53.757 + tr.transform(_instanceSource, result);
53.758 + Document instanceDoc = (Document) result.getNode();*/
53.759 + DocumentBuilderFactory docFact = DocumentBuilderFactory.newInstance();
53.760 + docFact.setNamespaceAware(true);
53.761 + docFact.setValidating(false);
53.762 + DocumentBuilder parser = docFact.newDocumentBuilder();
53.763 + Document instanceDoc = parser.parse(new InputSource(_instanceSource.getSystemId()));
53.764 +
53.765 +//possibility abandonned for the moment:
53.766 +//modify the instance to add the correct "xsi:type" attributes wherever needed
53.767 +//Document instanceDoc=this.setXMLSchemaAndPSVILoad(inputURI, _instanceSource, targetNamespace);
53.768 +
53.769 + if (instanceDoc != null) {
53.770 + Element instanceInOtherDoc =
53.771 + instanceDoc.getDocumentElement();
53.772 +
53.773 + if (instanceInOtherDoc
53.774 + .getNodeName()
53.775 + .equals(_rootTagName)) {
53.776 + rootElement =
53.777 + (Element) xForm.importNode(instanceInOtherDoc,
53.778 + true);
53.779 + instanceElement.appendChild(rootElement);
53.780 +
53.781 +//add XMLSchema instance NS
53.782 + String prefix = xmlSchemaInstancePrefix.substring(0, xmlSchemaInstancePrefix.length() - 1);
53.783 + if (!rootElement.hasAttributeNS(XMLNS_NAMESPACE_URI, prefix))
53.784 + rootElement.setAttribute("xmlns:" + prefix, XMLSCHEMA_INSTANCE_NAMESPACE_URI);
53.785 +
53.786 +//possibility abandonned for the moment:
53.787 +//modify the instance to add the correct "xsi:type" attributes wherever needed
53.788 +//this.addXSITypeAttributes(rootElement);
53.789 + } else {
53.790 + ok = false;
53.791 + }
53.792 + } else {
53.793 + ok = false;
53.794 + }
53.795 + } catch (Exception ex) {
53.796 + ex.printStackTrace();
53.797 +
53.798 + //if there is an exception we put the empty root element
53.799 + ok = false;
53.800 + }
53.801 +
53.802 + //if there was a problem
53.803 + if (!ok) {
53.804 + rootElement =
53.805 + (Element) instanceElement.appendChild(xForm.createElement(_rootTagName));
53.806 + }
53.807 + } else if (
53.808 + _instanceMode == AbstractSchemaFormBuilder.INSTANCE_MODE_HREF)
53.809 + //add the xlink:href attribute
53.810 + {
53.811 + instanceElement.setAttribute("href",
53.812 + _instanceHref);
53.813 + }
53.814 +
53.815 + Element formContentWrapper =
53.816 + _wrapper.createGroupContentWrapper(formSection);
53.817 + addElement(xForm,
53.818 + modelSection,
53.819 + formContentWrapper,
53.820 + rootElementDecl,
53.821 + rootElementDecl.getTypeDefinition(),
53.822 + "/" + getElementName(rootElementDecl,xForm));
53.823 +
53.824 + if (addSubmit) {
53.825 +
53.826 + Element submitInfoElement =
53.827 + (Element) modelSection.appendChild(xForm.createElementNS(XFORMS_NS,
53.828 + getXFormsNSPrefix() + "submission"));
53.829 +
53.830 + //submitInfoElement.setAttributeNS(XFORMS_NS,getXFormsNSPrefix()+"id","save");
53.831 + String submissionId = this.setXFormsId(submitInfoElement);
53.832 +
53.833 + //action
53.834 + if (_action == null) {
53.835 + submitInfoElement.setAttribute("action",
53.836 + "");
53.837 + } else {
53.838 + submitInfoElement.setAttribute("action",
53.839 + _action);
53.840 + }
53.841 +
53.842 + //method
53.843 + if ((_submitMethod != null) && !_submitMethod.equals("")) {
53.844 + submitInfoElement.setAttribute("method",
53.845 + _submitMethod);
53.846 + } else { //default is "post"
53.847 + submitInfoElement.setAttribute("method",
53.848 + AbstractSchemaFormBuilder.SUBMIT_METHOD_POST);
53.849 + }
53.850 +
53.851 + //Element submitButton = (Element) formSection.appendChild(xForm.createElementNS(XFORMS_NS,getXFormsNSPrefix()+"submit"));
53.852 + Element submitButton =
53.853 + xForm.createElementNS(XFORMS_NS,
53.854 + getXFormsNSPrefix() + "submit");
53.855 + Element submitControlWrapper =
53.856 + _wrapper.createControlsWrapper(submitButton);
53.857 + formContentWrapper.appendChild(submitControlWrapper);
53.858 + submitButton.setAttribute("submission",
53.859 + submissionId);
53.860 + this.setXFormsId(submitButton);
53.861 +
53.862 + Element submitButtonCaption =
53.863 + (Element) submitButton.appendChild(xForm.createElementNS(XFORMS_NS,
53.864 + getXFormsNSPrefix() + "label"));
53.865 + submitButtonCaption.appendChild(xForm.createTextNode("Submit"));
53.866 + this.setXFormsId(submitButtonCaption);
53.867 + }
53.868 +
53.869 + return xForm;
53.870 + } catch (ParserConfigurationException x) {
53.871 + throw new FormBuilderException(x);
53.872 + } catch (java.lang.ClassNotFoundException x) {
53.873 + throw new FormBuilderException(x);
53.874 + } catch (java.lang.InstantiationException x) {
53.875 + throw new FormBuilderException(x);
53.876 + } catch (java.lang.IllegalAccessException x) {
53.877 + throw new FormBuilderException(x);
53.878 + }
53.879 + }
53.880 +
53.881 + /**
53.882 + * method to load the instance document using PSVI, by first setting the location of the schema,
53.883 + * resaving it in XML and reloading it with Xerces XMLSchema's API
53.884 + * ABANDONNED -> NOT TESTED
53.885 + **/
53.886 + /*private Document setXMLSchemaAndPSVILoad(String inputURI, Source instanceSource, String targetNamespace){
53.887 + Document newDoc=null;
53.888 +
53.889 + try{
53.890 + //load doc
53.891 + DocumentBuilderFactory domfact=DocumentBuilderFactory.newInstance();
53.892 + domfact.setNamespaceAware(true);
53.893 + DocumentBuilder builder=domfact.newDocumentBuilder();
53.894 + Document doc =builder.parse(new InputSource(instanceSource.getSystemId()));
53.895 + Element rootElement=doc.getDocumentElement();
53.896 +
53.897 + //set namespace & schema location
53.898 + String prefix=xmlSchemaInstancePrefix.substring(0, xmlSchemaInstancePrefix.length()-1);
53.899 + String attr_ns=rootElement.getAttributeNS(XMLNS_NAMESPACE_URI, prefix);
53.900 + if(attr_ns==null || attr_ns.equals("")){
53.901 + rootElement.setAttributeNS(XMLNS_NAMESPACE_URI,"xmlns:"+prefix,XMLSCHEMA_INSTANCE_NAMESPACE_URI);
53.902 + }
53.903 + String attr_val1=rootElement.getAttributeNS(XMLSCHEMA_INSTANCE_NAMESPACE_URI, "noNamespaceSchemaLocation");
53.904 + String attr_val2=rootElement.getAttributeNS(XMLSCHEMA_INSTANCE_NAMESPACE_URI, "schemaLocation");
53.905 + if( (attr_val1==null || attr_val1.equals("") )
53.906 + && (attr_val2==null || attr_val2.equals("") )
53.907 + ){
53.908 + if(targetNamespace==null || targetNamespace.equals(""))
53.909 + rootElement.setAttributeNS(XMLSCHEMA_INSTANCE_NAMESPACE_URI, xmlSchemaInstancePrefix+"noNamespaceSchemaLocation", inputURI);
53.910 + else
53.911 + rootElement.setAttributeNS(XMLSCHEMA_INSTANCE_NAMESPACE_URI, xmlSchemaInstancePrefix+"schemaLocation", inputURI);
53.912 + }
53.913 +
53.914 + //save the file
53.915 + DOMSource source=new DOMSource(doc);
53.916 + File f=File.createTempFile("instance", ".xml");
53.917 + StreamResult result2=new StreamResult(f);
53.918 + TransformerFactory trFactory =TransformerFactory.newInstance();
53.919 + Transformer tr = trFactory.newTransformer();
53.920 + tr.transform(source, result2);
53.921 +
53.922 + //reload it with PSVI
53.923 + newDoc=this.PSVIParse(f);
53.924 +
53.925 + }
53.926 + catch(javax.xml.transform.TransformerConfigurationException ex){
53.927 + LOGGER.error("TransformerConfigurationException in setXMLSchemaAndPSVILoad", ex);
53.928 + }
53.929 + catch(javax.xml.transform.TransformerException ex){
53.930 + LOGGER.error("TransformerException in setXMLSchemaAndPSVILoad", ex);
53.931 + }
53.932 + catch(java.io.IOException ex){
53.933 + LOGGER.error("IOException in setXMLSchemaAndPSVILoad", ex);
53.934 + }
53.935 + catch(javax.xml.parsers.ParserConfigurationException ex){
53.936 + LOGGER.error("ParserConfigurationException in setXMLSchemaAndPSVILoad", ex);
53.937 + }
53.938 + catch(org.xml.sax.SAXException ex){
53.939 + LOGGER.error("SAXException in setXMLSchemaAndPSVILoad", ex);
53.940 + }
53.941 +
53.942 + return newDoc;
53.943 + }*/
53.944 +
53.945 + /*
53.946 + *Method to parse a file with PSVI
53.947 + * ABANDONNED -> NOT TESTED
53.948 + */
53.949 + /*
53.950 + public Document PSVIParse(File f){
53.951 + Document doc=null;
53.952 + try{
53.953 + DOMParser parser=new DOMParser();
53.954 + parser.setFeature("http://xml.org/sax/features/validation", true);
53.955 + parser.setFeature("http://apache.org/xml/features/validation/schema", true);
53.956 + parser.setFeature("http://apache.org/xml/features/validation/schema-full-checking", true);
53.957 + parser.setFeature("http://apache.org/xml/features/continue-after-fatal-error", true);
53.958 + parser.setProperty("http://apache.org/xml/properties/dom/document-class-name", "org.apache.xerces.dom.PSVIDocumentImpl");
53.959 + FileInputStream fin=new FileInputStream(f);
53.960 + InputSource source=new InputSource(fin);
53.961 + parser.parse(source);
53.962 + doc=parser.getDocument();
53.963 + }catch(org.xml.sax.SAXNotRecognizedException ex){
53.964 + LOGGER.error("SAXNotRecognizedException for parameter in PSVIParse", ex);
53.965 + }
53.966 + catch(java.io.FileNotFoundException ex){
53.967 + LOGGER.error("FileNotFoundException for "+f.getAbsolutePath()+" in PSVIParse", ex);
53.968 + }
53.969 + catch(org.xml.sax.SAXException ex){
53.970 + LOGGER.error("SAXException while loading "+f.getAbsolutePath()+" in PSVIParse", ex);
53.971 + }
53.972 + catch(java.io.IOException ex){
53.973 + LOGGER.error("IOException while loading "+f.getAbsolutePath()+" in PSVIParse", ex);
53.974 + }
53.975 + return doc;
53.976 + }
53.977 + */
53.978 +
53.979 + /**
53.980 + * add a "@xsi:type" attribute for all elements of type that are extended
53.981 + * with default value = the type if not abstract, otherwise the first non abstract subtype
53.982 + * ABANDONNED -> NOT TESTED
53.983 + **/
53.984 + /*private void addXSITypeAttributes(Element element){
53.985 + if(element!=null){
53.986 + String ns=element.getNamespaceURI();
53.987 +
53.988 + //set it on this element if it's not already here
53.989 + String attr=element.getAttributeNS(XMLSCHEMA_INSTANCE_NAMESPACE_URI, "type");
53.990 + if(attr==null || attr.equals("")){
53.991 +
53.992 + ElementPSVI el=(ElementPSVI) element;
53.993 + if(el!=null){
53.994 + if(LOGGER.isDebugEnabled())
53.995 + LOGGER.debug("PSVIElement found for "+element.getNodeName()+". Testing type");
53.996 +
53.997 + XSElementDeclaration elDecl=el.getElementDeclaration();
53.998 + XSTypeDefinition type=elDecl.getTypeDefinition();
53.999 + if(type.getTypeCategory()==XSTypeDefinition.COMPLEX_TYPE){
53.1000 + XSComplexTypeDefinition complexType=(XSComplexTypeDefinition) type;
53.1001 +
53.1002 + TreeSet compatibleTypes =(TreeSet) typeTree.get(complexType.getName());
53.1003 + if(compatibleTypes!=null && !compatibleTypes.isEmpty()){
53.1004 + if(LOGGER.isDebugEnabled())
53.1005 + LOGGER.debug("compatible type found for "+element.getNodeName()+" -> setting xsi:type attribute");
53.1006 +
53.1007 + //add xsi:type attribute
53.1008 +
53.1009 + //find value of attribute
53.1010 + String value=null;
53.1011 + if(!complexType.getAbstract())
53.1012 + value=complexType.getName();
53.1013 + else{ //find the first non abstract subtype
53.1014 + Iterator it=compatibleTypes.iterator();
53.1015 + while(it.hasNext() && value==null){
53.1016 + String subTypeName=(String) it.next();
53.1017 + //find type definition
53.1018 + XSTypeDefinition subType=schema.getTypeDefinition(subTypeName, ns);
53.1019 + if(subType!=null && subType.getTypeCategory()==XSTypeDefinition.COMPLEX_TYPE){
53.1020 + XSComplexTypeDefinition subComplexType=(XSComplexTypeDefinition) subType;
53.1021 + if(!subComplexType.getAbstract())
53.1022 + value=subComplexType.getName();
53.1023 + }
53.1024 + }
53.1025 + }
53.1026 +
53.1027 + //set attribute
53.1028 + element.setAttributeNS(XMLSCHEMA_INSTANCE_NAMESPACE_URI, this.xmlSchemaInstancePrefix+"type", value);
53.1029 + }
53.1030 + }
53.1031 + }
53.1032 + }
53.1033 +
53.1034 + //recursive call
53.1035 + NodeList children=element.getChildNodes();
53.1036 + int nb=children.getLength();
53.1037 + for(int i=0;i<nb;i++){
53.1038 + Node child=children.item(i);
53.1039 + if(child.getNodeType()==Node.ELEMENT_NODE){
53.1040 + this.addXSITypeAttributes((Element) child);
53.1041 + }
53.1042 + }
53.1043 + }
53.1044 + }*/
53.1045 +
53.1046 + /**
53.1047 + * __UNDOCUMENTED__
53.1048 + *
53.1049 + * @param inputURI the URI of the XML Schema to be used
53.1050 + * @return __UNDOCUMENTED__
53.1051 + * @throws FormBuilderException __UNDOCUMENTED__
53.1052 + */
53.1053 + public String buildFormAsString(String inputURI)
53.1054 + throws FormBuilderException {
53.1055 + Document xForm = buildForm(inputURI);
53.1056 +
53.1057 + if (xForm != null) {
53.1058 + StringWriter stringWriter = new StringWriter();
53.1059 +
53.1060 + try {
53.1061 + TransformerFactory factory = TransformerFactory.newInstance();
53.1062 + Transformer transformer = factory.newTransformer();
53.1063 + StreamResult result = new StreamResult(stringWriter);
53.1064 + transformer.transform(new DOMSource(xForm), result);
53.1065 +
53.1066 + return stringWriter.getBuffer().toString();
53.1067 + } catch (TransformerConfigurationException x) {
53.1068 + throw new FormBuilderException(x);
53.1069 + } catch (TransformerException x) {
53.1070 + throw new FormBuilderException(x);
53.1071 + }
53.1072 + }
53.1073 +
53.1074 + return "";
53.1075 + }
53.1076 +
53.1077 + /**
53.1078 + * This method is invoked after the form builder is finished creating and processing
53.1079 + * a form control. Implementations may choose to use this method to add/inspect/modify
53.1080 + * the controlElement prior to the builder moving onto the next control.
53.1081 + *
53.1082 + * @param controlElement The form control element that was created.
53.1083 + * @param controlType The XML Schema type for which <b>controlElement</b> was created.
53.1084 + */
53.1085 + public void endFormControl(Element controlElement,
53.1086 + XSTypeDefinition controlType,
53.1087 + int minOccurs,
53.1088 + int maxOccurs) {
53.1089 + }
53.1090 +
53.1091 + /**
53.1092 + * __UNDOCUMENTED__
53.1093 + */
53.1094 + public void reset() {
53.1095 + //refCounter = 0;
53.1096 + counter = new HashMap();
53.1097 + setProperty(CSS_STYLE_PROP, DEFAULT_CSS_STYLE_PROP);
53.1098 + setProperty(SELECTMANY_LONG_LIST_SIZE_PROP, DEFAULT_LONG_LIST_MAX_SIZE);
53.1099 + setProperty(SELECTMANY_UI_CONTROL_SHORT_PROP,
53.1100 + DEFAULT_SELECTMANY_UI_CONTROL_SHORT_PROP);
53.1101 + setProperty(SELECTMANY_UI_CONTROL_LONG_PROP,
53.1102 + DEFAULT_SELECTMANY_UI_CONTROL_LONG_PROP);
53.1103 + setProperty(SELECTONE_LONG_LIST_SIZE_PROP, DEFAULT_LONG_LIST_MAX_SIZE);
53.1104 + setProperty(SELECTONE_UI_CONTROL_SHORT_PROP,
53.1105 + DEFAULT_SELECTONE_UI_CONTROL_SHORT_PROP);
53.1106 + setProperty(SELECTONE_UI_CONTROL_LONG_PROP,
53.1107 + DEFAULT_SELECTONE_UI_CONTROL_LONG_PROP);
53.1108 + setProperty(GROUP_BOX_ALIGN_PROP, DEFAULT_GROUP_BOX_ALIGN);
53.1109 + setProperty(GROUP_BOX_ORIENT_PROP, DEFAULT_GROUP_BOX_ORIENT);
53.1110 + setProperty(GROUP_CAPTION_WIDTH_PROP, DEFAULT_GROUP_CAPTION_WIDTH);
53.1111 + setProperty(GROUP_WIDTH_PROP, DEFAULT_GROUP_WIDTH);
53.1112 + setProperty(GROUP_BORDER_PROP, DEFAULT_GROUP_BORDER);
53.1113 + }
53.1114 +
53.1115 + /**
53.1116 + * Returns the most-specific built-in base type for the provided type.
53.1117 + */
53.1118 + protected short getBuiltInType(XSTypeDefinition type) {
53.1119 + // type.getName() may be 'null' for anonymous types, so compare against
53.1120 + // static string (see bug #1172541 on sf.net)
53.1121 + if (("anyType").equals(type.getName())) {
53.1122 + return XSConstants.ANYSIMPLETYPE_DT;
53.1123 + } else {
53.1124 + XSSimpleTypeDefinition simpleType = (XSSimpleTypeDefinition) type;
53.1125 +
53.1126 + //get built-in type
53.1127 + //only working method found: getBuiltInKind, but it returns a short !
53.1128 + //XSTypeDefinition builtIn = simpleType.getPrimitiveType();
53.1129 + /*XSTypeDefinition builtIn = type.getBaseType();
53.1130 + if (builtIn == null) {
53.1131 + // always null for a ListType
53.1132 + if (simpleType.getItemType() != null) //if not null it's a list
53.1133 + return getBuiltInType(simpleType.getItemType());
53.1134 + else
53.1135 + return simpleType;
53.1136 + }
53.1137 + else if(LOGGER.isDebugEnabled())
53.1138 + LOGGER.debug(" -> builtinType="+builtIn.getName());
53.1139 + return builtIn;*/
53.1140 +
53.1141 + short result = simpleType.getBuiltInKind();
53.1142 + if (result == XSConstants.LIST_DT) {
53.1143 + result = getBuiltInType(simpleType.getItemType());
53.1144 + }
53.1145 + return result;
53.1146 + }
53.1147 + }
53.1148 +
53.1149 + /**
53.1150 + * get the name of a datatype defined by its value in XSConstants
53.1151 + * TODO: find an automatic way to do this !
53.1152 + *
53.1153 + * @param dt the short representating this datatype from XSConstants
53.1154 + * @return the name of the datatype
53.1155 + */
53.1156 + public String getDataTypeName(short dt) {
53.1157 + String name = "";
53.1158 + switch (dt) {
53.1159 + case XSConstants.ANYSIMPLETYPE_DT:
53.1160 + name = "anyType";
53.1161 + break;
53.1162 + case XSConstants.ANYURI_DT:
53.1163 + name = "anyURI";
53.1164 + break;
53.1165 + case XSConstants.BASE64BINARY_DT:
53.1166 + name = "base64Binary";
53.1167 + break;
53.1168 + case XSConstants.BOOLEAN_DT:
53.1169 + name = "boolean";
53.1170 + break;
53.1171 + case XSConstants.BYTE_DT:
53.1172 + name = "byte";
53.1173 + break;
53.1174 + case XSConstants.DATE_DT:
53.1175 + name = "date";
53.1176 + break;
53.1177 + case XSConstants.DATETIME_DT:
53.1178 + name = "dateTime";
53.1179 + break;
53.1180 + case XSConstants.DECIMAL_DT:
53.1181 + name = "decimal";
53.1182 + break;
53.1183 + case XSConstants.DOUBLE_DT:
53.1184 + name = "double";
53.1185 + break;
53.1186 + case XSConstants.DURATION_DT:
53.1187 + name = "duration";
53.1188 + break;
53.1189 + case XSConstants.ENTITY_DT:
53.1190 + name = "ENTITY";
53.1191 + break;
53.1192 + case XSConstants.FLOAT_DT:
53.1193 + name = "float";
53.1194 + break;
53.1195 + case XSConstants.GDAY_DT:
53.1196 + name = "gDay";
53.1197 + break;
53.1198 + case XSConstants.GMONTH_DT:
53.1199 + name = "gMonth";
53.1200 + break;
53.1201 + case XSConstants.GMONTHDAY_DT:
53.1202 + name = "gMonthDay";
53.1203 + break;
53.1204 + case XSConstants.GYEAR_DT:
53.1205 + name = "gYear";
53.1206 + break;
53.1207 + case XSConstants.GYEARMONTH_DT:
53.1208 + name = "gYearMonth";
53.1209 + break;
53.1210 + case XSConstants.ID_DT:
53.1211 + name = "ID";
53.1212 + break;
53.1213 + case XSConstants.IDREF_DT:
53.1214 + name = "IDREF";
53.1215 + break;
53.1216 + case XSConstants.INT_DT:
53.1217 + name = "int";
53.1218 + break;
53.1219 + case XSConstants.INTEGER_DT:
53.1220 + name = "integer";
53.1221 + break;
53.1222 + case XSConstants.LANGUAGE_DT:
53.1223 + name = "language";
53.1224 + break;
53.1225 + case XSConstants.LONG_DT:
53.1226 + name = "long";
53.1227 + break;
53.1228 + case XSConstants.NAME_DT:
53.1229 + name = "Name";
53.1230 + break;
53.1231 + case XSConstants.NCNAME_DT:
53.1232 + name = "NCName";
53.1233 + break;
53.1234 + case XSConstants.NEGATIVEINTEGER_DT:
53.1235 + name = "negativeInteger";
53.1236 + break;
53.1237 + case XSConstants.NMTOKEN_DT:
53.1238 + name = "NMTOKEN";
53.1239 + break;
53.1240 + case XSConstants.NONNEGATIVEINTEGER_DT:
53.1241 + name = "nonNegativeInteger";
53.1242 + break;
53.1243 + case XSConstants.NONPOSITIVEINTEGER_DT:
53.1244 + name = "nonPositiveInteger";
53.1245 + break;
53.1246 + case XSConstants.NORMALIZEDSTRING_DT:
53.1247 + name = "normalizedString";
53.1248 + break;
53.1249 + case XSConstants.NOTATION_DT:
53.1250 + name = "NOTATION";
53.1251 + break;
53.1252 + case XSConstants.POSITIVEINTEGER_DT:
53.1253 + name = "positiveInteger";
53.1254 + break;
53.1255 + case XSConstants.QNAME_DT:
53.1256 + name = "QName";
53.1257 + break;
53.1258 + case XSConstants.SHORT_DT:
53.1259 + name = "short";
53.1260 + break;
53.1261 + case XSConstants.STRING_DT:
53.1262 + name = "string";
53.1263 + break;
53.1264 + case XSConstants.TIME_DT:
53.1265 + name = "time";
53.1266 + break;
53.1267 + case XSConstants.TOKEN_DT:
53.1268 + name = "TOKEN";
53.1269 + break;
53.1270 + case XSConstants.UNSIGNEDBYTE_DT:
53.1271 + name = "unsignedByte";
53.1272 + break;
53.1273 + case XSConstants.UNSIGNEDINT_DT:
53.1274 + name = "unsignedInt";
53.1275 + break;
53.1276 + case XSConstants.UNSIGNEDLONG_DT:
53.1277 + name = "unsignedLong";
53.1278 + break;
53.1279 + case XSConstants.UNSIGNEDSHORT_DT:
53.1280 + name = "unsignedShort";
53.1281 + break;
53.1282 + }
53.1283 + return name;
53.1284 + }
53.1285 +
53.1286 + /**
53.1287 + * Returns the prefix for the Chiba namespace.
53.1288 + */
53.1289 + protected String getChibaNSPrefix() {
53.1290 + return chibaNSPrefix;
53.1291 + }
53.1292 +
53.1293 + /* Increments the xforms:ref attribute counter.
53.1294 + *
53.1295 + */
53.1296 + /*protected long incRefCounter() {
53.1297 + return refCounter++;
53.1298 + }*/
53.1299 + protected String setXFormsId(Element el) {
53.1300 + //remove the eventuel "id" attribute
53.1301 + if (el.hasAttributeNS(SchemaFormBuilder.XFORMS_NS, "id")) {
53.1302 + el.removeAttributeNS(SchemaFormBuilder.XFORMS_NS, "id");
53.1303 + }
53.1304 +
53.1305 + //long count=this.incIdCounter();
53.1306 + long count = 0;
53.1307 + String name = el.getLocalName();
53.1308 + Long l = (Long) counter.get(name);
53.1309 +
53.1310 + if (l != null) {
53.1311 + count = l.longValue();
53.1312 + }
53.1313 +
53.1314 + String id = name + "_" + count;
53.1315 +
53.1316 + //increment the counter
53.1317 + counter.put(name, new Long(count + 1));
53.1318 + el.setAttribute("id",
53.1319 + id);
53.1320 +
53.1321 + return id;
53.1322 + }
53.1323 +
53.1324 + /**
53.1325 + * method to set an Id to this element and to all XForms descendants of this element
53.1326 + */
53.1327 + private void resetXFormIds(Element newControl) {
53.1328 + if (newControl.getNamespaceURI() != null
53.1329 + && newControl.getNamespaceURI().equals(XFORMS_NS))
53.1330 + this.setXFormsId(newControl);
53.1331 +
53.1332 + //recursive call
53.1333 + NodeList children = newControl.getChildNodes();
53.1334 + int nb = children.getLength();
53.1335 + for (int i = 0; i < nb; i++) {
53.1336 + Node child = children.item(i);
53.1337 + if (child.getNodeType() == Node.ELEMENT_NODE)
53.1338 + this.resetXFormIds((Element) child);
53.1339 + }
53.1340 + }
53.1341 +
53.1342 + /**
53.1343 + * Returns the prefix for the XForms namespace.
53.1344 + */
53.1345 + protected String getXFormsNSPrefix() {
53.1346 + return xformsNSPrefix;
53.1347 + }
53.1348 +
53.1349 + /**
53.1350 + * Returns the prefix for the XLink namespace.
53.1351 + */
53.1352 + protected String getXLinkNSPrefix() {
53.1353 + return xlinkNSPrefix;
53.1354 + }
53.1355 +
53.1356 + /**
53.1357 + * __UNDOCUMENTED__
53.1358 + *
53.1359 + * @param xForm __UNDOCUMENTED__
53.1360 + * @param choicesElement __UNDOCUMENTED__
53.1361 + * @param choiceValues __UNDOCUMENTED__
53.1362 + */
53.1363 + protected void addChoicesForSelectControl(Document xForm,
53.1364 + Element choicesElement,
53.1365 + Vector choiceValues) {
53.1366 + // sort the enums values and then add them as choices
53.1367 + //
53.1368 + // TODO: Should really put the default value (if any) at the top of the list.
53.1369 + //
53.1370 + List sortedList = choiceValues.subList(0, choiceValues.size());
53.1371 + Collections.sort(sortedList);
53.1372 +
53.1373 + Iterator iterator = sortedList.iterator();
53.1374 +
53.1375 + while (iterator.hasNext()) {
53.1376 + String textValue = (String) iterator.next();
53.1377 + Element item =
53.1378 + xForm.createElementNS(XFORMS_NS, getXFormsNSPrefix() + "item");
53.1379 + this.setXFormsId(item);
53.1380 + choicesElement.appendChild(item);
53.1381 +
53.1382 + Element captionElement =
53.1383 + xForm.createElementNS(XFORMS_NS, getXFormsNSPrefix() + "label");
53.1384 + this.setXFormsId(captionElement);
53.1385 + item.appendChild(captionElement);
53.1386 + captionElement.appendChild(xForm.createTextNode(createCaption(textValue)));
53.1387 +
53.1388 + Element value =
53.1389 + xForm.createElementNS(XFORMS_NS, getXFormsNSPrefix() + "value");
53.1390 + this.setXFormsId(value);
53.1391 + item.appendChild(value);
53.1392 + value.appendChild(xForm.createTextNode(textValue));
53.1393 + }
53.1394 + }
53.1395 +
53.1396 + //protected void addChoicesForSelectSwitchControl(Document xForm, Element choicesElement, Vector choiceValues, String bindIdPrefix) {
53.1397 + protected void addChoicesForSelectSwitchControl(Document xForm,
53.1398 + Element choicesElement,
53.1399 + Vector choiceValues,
53.1400 + HashMap case_types) {
53.1401 +
53.1402 + if (LOGGER.isDebugEnabled()) {
53.1403 + LOGGER.debug("addChoicesForSelectSwitchControl, values=");
53.1404 + Iterator it = choiceValues.iterator();
53.1405 + while (it.hasNext()) {
53.1406 +//String name=(String) it.next();
53.1407 + XSTypeDefinition type = (XSTypeDefinition) it.next();
53.1408 + String name = type.getName();
53.1409 + LOGGER.debug(" - " + name);
53.1410 + }
53.1411 + }
53.1412 +
53.1413 +
53.1414 + // sort the enums values and then add them as choices
53.1415 + //
53.1416 + // TODO: Should really put the default value (if any) at the top of the list.
53.1417 + //
53.1418 + /*List sortedList = choiceValues.subList(0, choiceValues.size());
53.1419 + Collections.sort(sortedList);
53.1420 + Iterator iterator = sortedList.iterator();*/
53.1421 +// -> no, already sorted
53.1422 + Iterator iterator = choiceValues.iterator();
53.1423 + while (iterator.hasNext()) {
53.1424 + XSTypeDefinition type = (XSTypeDefinition) iterator.next();
53.1425 + String textValue = type.getName();
53.1426 + //String textValue = (String) iterator.next();
53.1427 +
53.1428 + if (LOGGER.isDebugEnabled())
53.1429 + LOGGER.debug("addChoicesForSelectSwitchControl, processing " + textValue);
53.1430 +
53.1431 + Element item =
53.1432 + xForm.createElementNS(XFORMS_NS, getXFormsNSPrefix() + "item");
53.1433 + this.setXFormsId(item);
53.1434 + choicesElement.appendChild(item);
53.1435 +
53.1436 + Element captionElement =
53.1437 + xForm.createElementNS(XFORMS_NS, getXFormsNSPrefix() + "label");
53.1438 + this.setXFormsId(captionElement);
53.1439 + item.appendChild(captionElement);
53.1440 + captionElement.appendChild(xForm.createTextNode(createCaption(textValue)));
53.1441 +
53.1442 + Element value =
53.1443 + xForm.createElementNS(XFORMS_NS, getXFormsNSPrefix() + "value");
53.1444 + this.setXFormsId(value);
53.1445 + item.appendChild(value);
53.1446 + value.appendChild(xForm.createTextNode(textValue));
53.1447 +
53.1448 +/// action in the case
53.1449 +
53.1450 + Element action =
53.1451 + xForm.createElementNS(XFORMS_NS,
53.1452 + getXFormsNSPrefix() + "action");
53.1453 + this.setXFormsId(action);
53.1454 + item.appendChild(action);
53.1455 +
53.1456 + action.setAttribute("event", "xforms-select");
53.1457 +
53.1458 + Element toggle =
53.1459 + xForm.createElementNS(XFORMS_NS,
53.1460 + getXFormsNSPrefix() + "toggle");
53.1461 + this.setXFormsId(toggle);
53.1462 +
53.1463 + //build the case element
53.1464 + Element caseElement =
53.1465 + xForm.createElementNS(XFORMS_NS, getXFormsNSPrefix() + "case");
53.1466 + String case_id = this.setXFormsId(caseElement);
53.1467 + case_types.put(textValue, caseElement);
53.1468 +
53.1469 + toggle.setAttribute("case",
53.1470 + case_id);
53.1471 +
53.1472 + //toggle.setAttributeNS(XFORMS_NS,getXFormsNSPrefix() + "case",bindIdPrefix + "_" + textValue +"_case");
53.1473 + action.appendChild(toggle);
53.1474 + }
53.1475 + }
53.1476 +
53.1477 + /**
53.1478 + * __UNDOCUMENTED__
53.1479 + *
53.1480 + * @param xForm __UNDOCUMENTED__
53.1481 + * @param annotation __UNDOCUMENTED__
53.1482 + * @return __UNDOCUMENTED__
53.1483 + */
53.1484 + protected Element addHintFromDocumentation(Document xForm,
53.1485 + XSAnnotation annotation) {
53.1486 + if (annotation != null) {
53.1487 + Element hintElement =
53.1488 + xForm.createElementNS(XFORMS_NS, getXFormsNSPrefix() + "hint");
53.1489 + this.setXFormsId(hintElement);
53.1490 +
53.1491 + Text hintText =
53.1492 + (Text) hintElement.appendChild(xForm.createTextNode(""));
53.1493 +
53.1494 + //write annotation to empty doc
53.1495 + Document doc = DOMUtil.newDocument(true, false);
53.1496 + annotation.writeAnnotation(doc, XSAnnotation.W3C_DOM_DOCUMENT);
53.1497 +
53.1498 + //get "annotation" element
53.1499 + NodeList annots =
53.1500 + doc.getElementsByTagNameNS("http://www.w3.org/2001/XMLSchema",
53.1501 + "annotation");
53.1502 + if (annots.getLength() > 0) {
53.1503 + Element annotEl = (Element) annots.item(0);
53.1504 +
53.1505 + //documentation
53.1506 + NodeList docos =
53.1507 + annotEl.getElementsByTagNameNS("http://www.w3.org/2001/XMLSchema",
53.1508 + "documentation");
53.1509 + int nbDocos = docos.getLength();
53.1510 + for (int j = 0; j < nbDocos; j++) {
53.1511 + Element doco = (Element) docos.item(j);
53.1512 +
53.1513 + //get text value
53.1514 + String text = DOMUtil.getTextNodeAsString(doco);
53.1515 + hintText.appendData(text);
53.1516 +
53.1517 + if (j < nbDocos - 1) {
53.1518 + hintText.appendData(" ");
53.1519 + }
53.1520 + }
53.1521 + return hintElement;
53.1522 + }
53.1523 + return null;
53.1524 + }
53.1525 +
53.1526 + return null;
53.1527 + }
53.1528 +
53.1529 + private XSModel getSchema() {
53.1530 + return schema;
53.1531 + }
53.1532 +
53.1533 + public XSParticle findCorrespondingParticleInComplexType(XSElementDeclaration elDecl) {
53.1534 + XSParticle thisParticle = null;
53.1535 +
53.1536 + XSComplexTypeDefinition complexType = elDecl.getEnclosingCTDefinition();
53.1537 + if (complexType != null) {
53.1538 + XSParticle particle = complexType.getParticle();
53.1539 + XSTerm term = particle.getTerm();
53.1540 + XSObjectList particles;
53.1541 + if (term instanceof XSModelGroup) {
53.1542 + XSModelGroup group = (XSModelGroup) term;
53.1543 + particles = group.getParticles();
53.1544 + if (particles != null) {
53.1545 + int nb = particles.getLength();
53.1546 + int i = 0;
53.1547 + while (i < nb && thisParticle == null) {
53.1548 + XSParticle part = (XSParticle) particles.item(i);
53.1549 + //test term
53.1550 + XSTerm thisTerm = part.getTerm();
53.1551 + if (thisTerm == elDecl)
53.1552 + thisParticle = part;
53.1553 +
53.1554 + i++;
53.1555 + }
53.1556 + }
53.1557 + }
53.1558 + }
53.1559 + return thisParticle;
53.1560 + }
53.1561 +
53.1562 + /**
53.1563 + * finds the minOccurs and maxOccurs of an element declaration
53.1564 + *
53.1565 + * @return a table containing minOccurs and MaxOccurs
53.1566 + */
53.1567 + public int[] getOccurance(XSElementDeclaration elDecl) {
53.1568 + int minOccurs = 1;
53.1569 + int maxOccurs = 1;
53.1570 +
53.1571 + //get occurance on encosing element declaration
53.1572 + XSParticle particle =
53.1573 + this.findCorrespondingParticleInComplexType(elDecl);
53.1574 + if (particle != null) {
53.1575 + minOccurs = particle.getMinOccurs();
53.1576 + if (particle.getMaxOccursUnbounded())
53.1577 + maxOccurs = -1;
53.1578 + else
53.1579 + maxOccurs = particle.getMaxOccurs();
53.1580 + }
53.1581 +
53.1582 + //if not set, get occurance of model group content
53.1583 + //no -> this is made in "addGroup" directly !
53.1584 + /*if (minOccurs == 1 && maxOccurs == 1) {
53.1585 + XSTypeDefinition type = elDecl.getTypeDefinition();
53.1586 + if (type != null
53.1587 + && type.getTypeCategory() == XSTypeDefinition.COMPLEX_TYPE) {
53.1588 + XSComplexTypeDefinition complexType =
53.1589 + (XSComplexTypeDefinition) type;
53.1590 + XSParticle thisParticle = complexType.getParticle();
53.1591 + if (thisParticle != null) {
53.1592 + minOccurs = thisParticle.getMinOccurs();
53.1593 + if (thisParticle.getMaxOccursUnbounded())
53.1594 + maxOccurs = -1;
53.1595 + else
53.1596 + maxOccurs = thisParticle.getMaxOccurs();
53.1597 + }
53.1598 + }
53.1599 + }*/
53.1600 +
53.1601 + if (LOGGER.isDebugEnabled())
53.1602 + LOGGER.debug("getOccurance for "
53.1603 + + elDecl.getName()
53.1604 + + ", minOccurs="
53.1605 + + minOccurs
53.1606 + + ", maxOccurs="
53.1607 + + maxOccurs);
53.1608 +
53.1609 + int[] result = new int[2];
53.1610 + result[0] = minOccurs;
53.1611 + result[1] = maxOccurs;
53.1612 + return result;
53.1613 + }
53.1614 +
53.1615 + private void addAnyType(Document xForm,
53.1616 + Element modelSection,
53.1617 + Element formSection,
53.1618 + XSTypeDefinition controlType,
53.1619 + XSElementDeclaration owner,
53.1620 + String pathToRoot) {
53.1621 +
53.1622 + int[] occurance = this.getOccurance(owner);
53.1623 +
53.1624 + addSimpleType(xForm,
53.1625 + modelSection,
53.1626 + formSection,
53.1627 + controlType,
53.1628 + owner.getName(),
53.1629 + owner,
53.1630 + pathToRoot,
53.1631 + occurance[0],
53.1632 + occurance[1]);
53.1633 + }
53.1634 +
53.1635 + private void addAttributeSet(Document xForm,
53.1636 + Element modelSection,
53.1637 + Element formSection,
53.1638 + XSComplexTypeDefinition controlType,
53.1639 + XSElementDeclaration owner,
53.1640 + String pathToRoot,
53.1641 + boolean checkIfExtension) {
53.1642 + XSObjectList attrUses = controlType.getAttributeUses();
53.1643 +
53.1644 + if (attrUses != null) {
53.1645 + int nbAttr = attrUses.getLength();
53.1646 + for (int i = 0; i < nbAttr; i++) {
53.1647 + XSAttributeUse currentAttributeUse =
53.1648 + (XSAttributeUse) attrUses.item(i);
53.1649 + XSAttributeDeclaration currentAttribute =
53.1650 + currentAttributeUse.getAttrDeclaration();
53.1651 +
53.1652 +//test if extended !
53.1653 + if (checkIfExtension && this.doesAttributeComeFromExtension(currentAttributeUse, controlType)) {
53.1654 + if (LOGGER.isDebugEnabled()) {
53.1655 + LOGGER.debug("This attribute comes from an extension: recopy form controls. \n Model section: ");
53.1656 + DOMUtil.prettyPrintDOM(modelSection);
53.1657 + }
53.1658 +
53.1659 + String attributeName = currentAttributeUse.getName();
53.1660 + if (attributeName == null || attributeName.equals(""))
53.1661 + attributeName = currentAttributeUse.getAttrDeclaration().getName();
53.1662 +
53.1663 +//find the existing bind Id
53.1664 +//(modelSection is the enclosing bind of the element)
53.1665 + NodeList binds = modelSection.getElementsByTagNameNS(XFORMS_NS, "bind");
53.1666 + int j = 0;
53.1667 + int nb = binds.getLength();
53.1668 + String bindId = null;
53.1669 + while (j < nb && bindId == null) {
53.1670 + Element bind = (Element) binds.item(j);
53.1671 + String nodeset = bind.getAttributeNS(XFORMS_NS, "nodeset");
53.1672 + if (nodeset != null) {
53.1673 + String name = nodeset.substring(1); //remove "@" in nodeset
53.1674 + if (name.equals(attributeName))
53.1675 + bindId = bind.getAttributeNS(XFORMS_NS, "id");
53.1676 + }
53.1677 + j++;
53.1678 + }
53.1679 +
53.1680 +//find the control
53.1681 + Element control = null;
53.1682 + if (bindId != null) {
53.1683 + if (LOGGER.isDebugEnabled())
53.1684 + LOGGER.debug("bindId found: " + bindId);
53.1685 +
53.1686 + JXPathContext context = JXPathContext.newContext(formSection.getOwnerDocument());
53.1687 + Pointer pointer = context.getPointer("//*[@" + this.getXFormsNSPrefix() + "bind='" + bindId + "']");
53.1688 + if (pointer != null)
53.1689 + control = (Element) pointer.getNode();
53.1690 + }
53.1691 +
53.1692 +//copy it
53.1693 + if (control == null) {
53.1694 + LOGGER.warn("Corresponding control not found");
53.1695 + } else {
53.1696 + Element newControl = (Element) control.cloneNode(true);
53.1697 +//set new Ids to XForm elements
53.1698 + this.resetXFormIds(newControl);
53.1699 +
53.1700 + formSection.appendChild(newControl);
53.1701 + }
53.1702 +
53.1703 + } else {
53.1704 + String newPathToRoot;
53.1705 +
53.1706 + if ((pathToRoot == null) || pathToRoot.equals("")) {
53.1707 + newPathToRoot = "@" + currentAttribute.getName();
53.1708 + } else if (pathToRoot.endsWith("/")) {
53.1709 + newPathToRoot =
53.1710 + pathToRoot + "@" + currentAttribute.getName();
53.1711 + } else {
53.1712 + newPathToRoot =
53.1713 + pathToRoot + "/@" + currentAttribute.getName();
53.1714 + }
53.1715 +
53.1716 + XSSimpleTypeDefinition simpleType =
53.1717 + currentAttribute.getTypeDefinition();
53.1718 + //TODO SRA: UrType ?
53.1719 + /*if(simpleType==null){
53.1720 + simpleType=new UrType();
53.1721 + }*/
53.1722 +
53.1723 + addSimpleType(xForm,
53.1724 + modelSection,
53.1725 + formSection,
53.1726 + simpleType,
53.1727 + currentAttributeUse,
53.1728 + newPathToRoot);
53.1729 + }
53.1730 + }
53.1731 + }
53.1732 + }
53.1733 +
53.1734 + private void addComplexType(Document xForm,
53.1735 + Element modelSection,
53.1736 + Element formSection,
53.1737 + XSComplexTypeDefinition controlType,
53.1738 + XSElementDeclaration owner,
53.1739 + String pathToRoot,
53.1740 + boolean relative,
53.1741 + boolean checkIfExtension) {
53.1742 +
53.1743 + if (controlType != null) {
53.1744 + if (LOGGER.isDebugEnabled()) {
53.1745 + LOGGER.debug("addComplexType for " + controlType.getName());
53.1746 + if (owner != null)
53.1747 + LOGGER.debug(" owner=" + owner.getName());
53.1748 + }
53.1749 +
53.1750 + // add a group node and recurse
53.1751 + //
53.1752 + Element groupElement =
53.1753 + createGroup(xForm, modelSection, formSection, owner);
53.1754 + Element groupWrapper = groupElement;
53.1755 +
53.1756 + if (groupElement != modelSection) {
53.1757 + groupWrapper = _wrapper.createGroupContentWrapper(groupElement);
53.1758 + }
53.1759 +
53.1760 + int occurance[] = this.getOccurance(owner);
53.1761 + int minOccurs = occurance[0];
53.1762 + int maxOccurs = occurance[1];
53.1763 +
53.1764 + Element repeatSection =
53.1765 + addRepeatIfNecessary(xForm,
53.1766 + modelSection,
53.1767 + groupWrapper,
53.1768 + controlType,
53.1769 + minOccurs,
53.1770 + maxOccurs,
53.1771 + pathToRoot);
53.1772 + Element repeatContentWrapper = repeatSection;
53.1773 +
53.1774 + /*if(repeatSection!=groupWrapper)
53.1775 + //we have a repeat
53.1776 + {
53.1777 + repeatContentWrapper=_wrapper.createGroupContentWrapper(repeatSection);
53.1778 + addComplexTypeChildren(xForm,modelSection,repeatContentWrapper,controlType,owner,pathToRoot, true);
53.1779 + }
53.1780 + else
53.1781 + addComplexTypeChildren(xForm,modelSection,repeatContentWrapper,controlType,owner,pathToRoot, false);
53.1782 + */
53.1783 + if (repeatSection != groupWrapper) { //we have a repeat
53.1784 + repeatContentWrapper =
53.1785 + _wrapper.createGroupContentWrapper(repeatSection);
53.1786 + relative = true;
53.1787 + }
53.1788 +
53.1789 + addComplexTypeChildren(xForm,
53.1790 + modelSection,
53.1791 + repeatContentWrapper,
53.1792 + controlType,
53.1793 + owner,
53.1794 + pathToRoot,
53.1795 + relative,
53.1796 + checkIfExtension);
53.1797 +
53.1798 + Element realModel = modelSection;
53.1799 + if (relative) {
53.1800 + //modelSection: find the last element put in the modelSection = bind
53.1801 + realModel = DOMUtil.getLastChildElement(modelSection);
53.1802 + }
53.1803 +
53.1804 + endFormGroup(groupElement,
53.1805 + controlType,
53.1806 + minOccurs,
53.1807 + maxOccurs,
53.1808 + realModel);
53.1809 +
53.1810 + } else if (LOGGER.isDebugEnabled())
53.1811 + LOGGER.debug("addComplexType: control type is null for pathToRoot="
53.1812 + + pathToRoot);
53.1813 + }
53.1814 +
53.1815 + private void addComplexTypeChildren(Document xForm,
53.1816 + Element modelSection,
53.1817 + Element formSection,
53.1818 + XSComplexTypeDefinition controlType,
53.1819 + XSElementDeclaration owner,
53.1820 + String pathToRoot,
53.1821 + boolean relative,
53.1822 + boolean checkIfExtension) {
53.1823 +
53.1824 + if (controlType != null) {
53.1825 +
53.1826 + if (LOGGER.isDebugEnabled()) {
53.1827 + LOGGER.debug("addComplexTypeChildren for " + controlType.getName());
53.1828 + if (owner != null)
53.1829 + LOGGER.debug(" owner=" + owner.getName());
53.1830 + }
53.1831 +
53.1832 +//no need to add base type when extension-> with Xerces XMLSchema API,
53.1833 +//the elements of the base type are directly in the ModelGroup
53.1834 + /*XSTypeDefinition base = controlType.getBaseType();
53.1835 + if (base != null && base != controlType) {
53.1836 + if (LOGGER.isDebugEnabled())
53.1837 + LOGGER.debug(" base type=" + base.getName());
53.1838 +
53.1839 + if (base.getTypeCategory() == XSTypeDefinition.COMPLEX_TYPE) {
53.1840 +
53.1841 + if (base.getName() == null
53.1842 + || !base.getName().equals("anyType")) {
53.1843 +
53.1844 + if (LOGGER.isDebugEnabled())
53.1845 + LOGGER.debug(
53.1846 + " recursive call for base type "
53.1847 + + base.getName());
53.1848 +
53.1849 + addComplexTypeChildren(
53.1850 + xForm,
53.1851 + modelSection,
53.1852 + formSection,
53.1853 + (XSComplexTypeDefinition) base,
53.1854 + owner,
53.1855 + pathToRoot,
53.1856 + relative);
53.1857 + }
53.1858 + } else {
53.1859 + addSimpleType(
53.1860 + xForm,
53.1861 + modelSection,
53.1862 + formSection,
53.1863 + (XSSimpleTypeDefinition) base,
53.1864 + owner,
53.1865 + pathToRoot);
53.1866 + }
53.1867 + }*/
53.1868 +
53.1869 +/*if(!checkIfExtension){ //add it anyway
53.1870 + XSTypeDefinition base = controlType.getBaseType();
53.1871 + if (base != null && base != controlType) {
53.1872 +
53.1873 + if (LOGGER.isDebugEnabled())
53.1874 + LOGGER.debug(" base type=" + base.getName());
53.1875 +
53.1876 + if (base.getTypeCategory() == XSTypeDefinition.COMPLEX_TYPE) {
53.1877 +
53.1878 + if (base.getName() == null
53.1879 + || !base.getName().equals("anyType")) {
53.1880 +
53.1881 + if (LOGGER.isDebugEnabled())
53.1882 + LOGGER.debug(
53.1883 + " recursive call for base type "
53.1884 + + base.getName());
53.1885 +
53.1886 + addComplexTypeChildren(
53.1887 + xForm,
53.1888 + modelSection,
53.1889 + formSection,
53.1890 + (XSComplexTypeDefinition) base,
53.1891 + owner,
53.1892 + pathToRoot,
53.1893 + relative,
53.1894 + false);
53.1895 + }
53.1896 + } else {
53.1897 + addSimpleType(
53.1898 + xForm,
53.1899 + modelSection,
53.1900 + formSection,
53.1901 + (XSSimpleTypeDefinition) base,
53.1902 + owner,
53.1903 + pathToRoot);
53.1904 + }
53.1905 + }
53.1906 +
53.1907 + }
53.1908 + //we need the call for base type when type is a mixed content
53.1909 + //WARNING: simple type given for simple type + attribute (should be mixed ?)
53.1910 + else */
53.1911 + if (controlType.getContentType() == XSComplexTypeDefinition.CONTENTTYPE_MIXED
53.1912 + || (controlType.getContentType() == XSComplexTypeDefinition.CONTENTTYPE_SIMPLE
53.1913 + && controlType.getAttributeUses() != null && controlType.getAttributeUses().getLength() > 0)
53.1914 + ) {
53.1915 + XSTypeDefinition base = controlType.getBaseType();
53.1916 + if (LOGGER.isDebugEnabled())
53.1917 + LOGGER.debug(" Control type is mixed . base type=" + base.getName());
53.1918 +
53.1919 + if (base != null && base != controlType) {
53.1920 + if (base.getTypeCategory() == XSTypeDefinition.SIMPLE_TYPE) {
53.1921 + addSimpleType(xForm,
53.1922 + modelSection,
53.1923 + formSection,
53.1924 + (XSSimpleTypeDefinition) base,
53.1925 + owner,
53.1926 + pathToRoot);
53.1927 + } else
53.1928 + LOGGER.warn("addComplexTypeChildren for mixed type with basic type complex !");
53.1929 + }
53.1930 + } else if (LOGGER.isDebugEnabled())
53.1931 + LOGGER.debug(" Content type = " + controlType.getContentType());
53.1932 +
53.1933 +
53.1934 + // check for compatible subtypes
53.1935 + // of controlType.
53.1936 + // add a type switch if there are any
53.1937 + // compatible sub-types (i.e. anything
53.1938 + // that derives from controlType)
53.1939 + // add child elements
53.1940 + if (relative) {
53.1941 + pathToRoot = "";
53.1942 +
53.1943 + //modelSection: find the last element put in the modelSection = bind
53.1944 + modelSection = DOMUtil.getLastChildElement(modelSection);
53.1945 + }
53.1946 +
53.1947 + //attributes
53.1948 + addAttributeSet(xForm,
53.1949 + modelSection,
53.1950 + formSection,
53.1951 + controlType,
53.1952 + owner,
53.1953 + pathToRoot,
53.1954 + checkIfExtension);
53.1955 +
53.1956 + //process group
53.1957 + XSParticle particle = controlType.getParticle();
53.1958 + if (particle != null) {
53.1959 + XSTerm term = particle.getTerm();
53.1960 + if (term instanceof XSModelGroup) {
53.1961 + if (LOGGER.isDebugEnabled())
53.1962 + LOGGER.debug(" Particle of "
53.1963 + + controlType.getName()
53.1964 + + " is a group --->");
53.1965 +
53.1966 + XSModelGroup group = (XSModelGroup) term;
53.1967 +
53.1968 + //get maxOccurs
53.1969 + int maxOccurs = particle.getMaxOccurs();
53.1970 + if (particle.getMaxOccursUnbounded()) {
53.1971 + maxOccurs = -1;
53.1972 + }
53.1973 + int minOccurs = particle.getMinOccurs();
53.1974 +
53.1975 + //call addGroup on this group
53.1976 + this.addGroup(xForm,
53.1977 + modelSection,
53.1978 + formSection,
53.1979 + group,
53.1980 + controlType,
53.1981 + owner,
53.1982 + pathToRoot,
53.1983 + minOccurs,
53.1984 + maxOccurs,
53.1985 + checkIfExtension);
53.1986 +
53.1987 + } else if (LOGGER.isDebugEnabled())
53.1988 + LOGGER.debug(" Particle of "
53.1989 + + controlType.getName()
53.1990 + + " is not a group: "
53.1991 + + term.getClass().getName());
53.1992 + }
53.1993 +
53.1994 + if (LOGGER.isDebugEnabled())
53.1995 + LOGGER.debug("--->end of addComplexTypeChildren for "
53.1996 + + controlType.getName());
53.1997 + }
53.1998 + }
53.1999 +
53.2000 + /**
53.2001 + * add an element to the XForms document: the bind + the control
53.2002 + * (only the control if "withBind" is false)
53.2003 + */
53.2004 + private void addElement(Document xForm,
53.2005 + Element modelSection,
53.2006 + Element formSection,
53.2007 + XSElementDeclaration elementDecl,
53.2008 + XSTypeDefinition controlType,
53.2009 + String pathToRoot) {
53.2010 +
53.2011 + if (controlType == null) {
53.2012 + // TODO!!! Figure out why this happens... for now just warn...
53.2013 + // seems to happen when there is an element of type IDREFS
53.2014 + LOGGER.warn("WARNING!!! controlType is null for "
53.2015 + + elementDecl
53.2016 + + ", "
53.2017 + + elementDecl.getName());
53.2018 +
53.2019 + return;
53.2020 + }
53.2021 +
53.2022 + switch (controlType.getTypeCategory()) {
53.2023 + case XSTypeDefinition.SIMPLE_TYPE:
53.2024 + {
53.2025 + addSimpleType(xForm,
53.2026 + modelSection,
53.2027 + formSection,
53.2028 + (XSSimpleTypeDefinition) controlType,
53.2029 + elementDecl,
53.2030 + pathToRoot);
53.2031 +
53.2032 + break;
53.2033 + }
53.2034 + case XSTypeDefinition.COMPLEX_TYPE:
53.2035 + {
53.2036 +
53.2037 + if (controlType.getName() != null
53.2038 + && controlType.getName().equals("anyType")) {
53.2039 + addAnyType(xForm,
53.2040 + modelSection,
53.2041 + formSection,
53.2042 + (XSComplexTypeDefinition) controlType,
53.2043 + elementDecl,
53.2044 + pathToRoot);
53.2045 +
53.2046 + break;
53.2047 + } else {
53.2048 +
53.2049 + // find the types which are compatible(derived from) the parent type.
53.2050 + //
53.2051 + // This is used if we encounter a XML Schema that permits the xsi:type
53.2052 + // attribute to specify subtypes for the element.
53.2053 + //
53.2054 + // For example, the <address> element may be typed to permit any of
53.2055 + // the following scenarios:
53.2056 + // <address xsi:type="USAddress">
53.2057 + // </address>
53.2058 + // <address xsi:type="CanadianAddress">
53.2059 + // </address>
53.2060 + // <address xsi:type="InternationalAddress">
53.2061 + // </address>
53.2062 + //
53.2063 + // What we want to do is generate an XForm' switch element with cases
53.2064 + // representing any valid non-abstract subtype.
53.2065 + //
53.2066 + // <xforms:select1 xforms:bind="xsi_type_13"
53.2067 + // <xforms:label>Address</xforms:label>
53.2068 + // <xforms:choices>
53.2069 + // <xforms:item>
53.2070 + // <xforms:label>US Address Type</xforms:label>
53.2071 + // <xforms:value>USAddressType</xforms:value>
53.2072 + // <xforms:action ev:event="xforms-select">
53.2073 + // <xforms:toggle xforms:case="USAddressType-case"/>
53.2074 + // </xforms:action>
53.2075 + // </xforms:item>
53.2076 + // <xforms:item>
53.2077 + // <xforms:label>Canadian Address Type</xforms:label>
53.2078 + // <xforms:value>CanadianAddressType</xforms:value>
53.2079 + // <xforms:action ev:event="xforms-select">
53.2080 + // <xforms:toggle xforms:case="CanadianAddressType-case"/>
53.2081 + // </xforms:action>
53.2082 + // </xforms:item>
53.2083 + // <xforms:item>
53.2084 + // <xforms:label>International Address Type</xforms:label>
53.2085 + // <xforms:value>InternationalAddressType</xforms:value>
53.2086 + // <xforms:action ev:event="xforms-select">
53.2087 + // <xforms:toggle xforms:case="InternationalAddressType-case"/>
53.2088 + // </xforms:action>
53.2089 + // </xforms:item>
53.2090 + //
53.2091 + // </xforms:choices>
53.2092 + // <xforms:select1>
53.2093 + // <xforms:trigger>
53.2094 + // <xforms:label>validate Address type</xforms:label>
53.2095 + // <xforms:action>
53.2096 + // <xforms:dispatch id="dispatcher" xforms:name="xforms-activate" xforms:target="select1_0"/>
53.2097 + // </xforms:action>
53.2098 + //</xforms:trigger>
53.2099 + //
53.2100 + // <xforms:switch id="address_xsi_type_switch">
53.2101 + // <xforms:case id="USAddressType-case" selected="false">
53.2102 + // <!-- US Address Type sub-elements here-->
53.2103 + // </xforms:case>
53.2104 + // <xforms:case id="CanadianAddressType-case" selected="false">
53.2105 + // <!-- US Address Type sub-elements here-->
53.2106 + // </xforms:case>
53.2107 + // ...
53.2108 + // </xforms:switch>
53.2109 + //
53.2110 + // + change bindings to add:
53.2111 + // - a bind for the "@xsi:type" attribute
53.2112 + // - for each possible element that can be added through the use of an inheritance, add a "relevant" attribute:
53.2113 + // ex: xforms:relevant="../@xsi:type='USAddress'"
53.2114 +
53.2115 + // look for compatible types
53.2116 + //
53.2117 + String typeName = controlType.getName();
53.2118 + boolean relative = true;
53.2119 +
53.2120 + if (typeName != null) {
53.2121 + TreeSet compatibleTypes = (TreeSet) typeTree.get(controlType.getName());
53.2122 + //TreeSet compatibleTypes = (TreeSet) typeTree.get(controlType);
53.2123 +
53.2124 + if (compatibleTypes != null) {
53.2125 + relative = false;
53.2126 +
53.2127 + if (LOGGER.isDebugEnabled()) {
53.2128 + LOGGER.debug("compatible types for "
53.2129 + + typeName
53.2130 + + ":");
53.2131 + Iterator it1 = compatibleTypes.iterator();
53.2132 + while (it1.hasNext()) {
53.2133 + //String name = (String) it1.next();
53.2134 + XSTypeDefinition compType = (XSTypeDefinition) it1.next();
53.2135 + LOGGER.debug(" compatible type name=" + compType.getName());
53.2136 + }
53.2137 + }
53.2138 +
53.2139 + Element control =
53.2140 + xForm.createElementNS(XFORMS_NS,
53.2141 + getXFormsNSPrefix() + "select1");
53.2142 + String select1_id = this.setXFormsId(control);
53.2143 +
53.2144 + Element choices =
53.2145 + xForm.createElementNS(XFORMS_NS,
53.2146 + getXFormsNSPrefix() + "choices");
53.2147 + this.setXFormsId(choices);
53.2148 +
53.2149 + //get possible values
53.2150 + Vector enumValues = new Vector();
53.2151 + //add the type (if not abstract)
53.2152 + if (!((XSComplexTypeDefinition) controlType).getAbstract())
53.2153 + enumValues.add(controlType);
53.2154 + //enumValues.add(typeName);
53.2155 +
53.2156 + //add compatible types
53.2157 + Iterator it = compatibleTypes.iterator();
53.2158 + while (it.hasNext()) {
53.2159 + enumValues.add(it.next());
53.2160 + }
53.2161 +
53.2162 + if (enumValues.size() > 1) {
53.2163 +
53.2164 + String caption =
53.2165 + createCaption(elementDecl.getName() + " Type");
53.2166 + Element controlCaption =
53.2167 + (Element) control.appendChild(xForm.createElementNS(XFORMS_NS,
53.2168 + getXFormsNSPrefix() + "label"));
53.2169 + this.setXFormsId(controlCaption);
53.2170 + controlCaption.appendChild(xForm.createTextNode(caption));
53.2171 +
53.2172 + // multiple compatible types for this element exist
53.2173 + // in the schema - allow the user to choose from
53.2174 + // between compatible non-abstract types
53.2175 + Element bindElement =
53.2176 + xForm.createElementNS(XFORMS_NS,
53.2177 + getXFormsNSPrefix() + "bind");
53.2178 + String bindId =
53.2179 + this.setXFormsId(bindElement);
53.2180 +
53.2181 + bindElement.setAttribute("nodeset",
53.2182 + pathToRoot + "/@xsi:type");
53.2183 +
53.2184 + modelSection.appendChild(bindElement);
53.2185 + control.setAttribute("bind",
53.2186 + bindId);
53.2187 +
53.2188 + //add the "element" bind, in addition
53.2189 + Element bindElement2 =
53.2190 + xForm.createElementNS(XFORMS_NS,
53.2191 + getXFormsNSPrefix() + "bind");
53.2192 + String bindId2 =
53.2193 + this.setXFormsId(bindElement2);
53.2194 + bindElement2.setAttribute("nodeset",
53.2195 + pathToRoot);
53.2196 +
53.2197 + modelSection.appendChild(bindElement2);
53.2198 +
53.2199 + if (enumValues.size()
53.2200 + < Long.parseLong(getProperty(SELECTONE_LONG_LIST_SIZE_PROP))) {
53.2201 + control.setAttribute("appearance",
53.2202 + getProperty(SELECTONE_UI_CONTROL_SHORT_PROP));
53.2203 + } else {
53.2204 + control.setAttribute("appearance",
53.2205 + getProperty(SELECTONE_UI_CONTROL_LONG_PROP));
53.2206 +
53.2207 + // add the "Please select..." instruction item for the combobox
53.2208 + // and set the isValid attribute on the bind element to check for the "Please select..."
53.2209 + // item to indicate that is not a valid value
53.2210 + //
53.2211 + String pleaseSelect =
53.2212 + "[Select1 " + caption + "]";
53.2213 + Element item =
53.2214 + xForm.createElementNS(XFORMS_NS,
53.2215 + getXFormsNSPrefix()
53.2216 + + "item");
53.2217 + this.setXFormsId(item);
53.2218 + choices.appendChild(item);
53.2219 +
53.2220 + Element captionElement =
53.2221 + xForm.createElementNS(XFORMS_NS,
53.2222 + getXFormsNSPrefix()
53.2223 + + "label");
53.2224 + this.setXFormsId(captionElement);
53.2225 + item.appendChild(captionElement);
53.2226 + captionElement.appendChild(xForm.createTextNode(pleaseSelect));
53.2227 +
53.2228 + Element value =
53.2229 + xForm.createElementNS(XFORMS_NS,
53.2230 + getXFormsNSPrefix()
53.2231 + + "value");
53.2232 + this.setXFormsId(value);
53.2233 + item.appendChild(value);
53.2234 + value.appendChild(xForm.createTextNode(pleaseSelect));
53.2235 +
53.2236 + // not(purchaseOrder/state = '[Choose State]')
53.2237 + //String isValidExpr = "not(" + bindElement.getAttributeNS(XFORMS_NS, "nodeset") + " = '" + pleaseSelect + "')";
53.2238 + // ->no, not(. = '[Choose State]')
53.2239 + String isValidExpr =
53.2240 + "not( . = '"
53.2241 + + pleaseSelect
53.2242 + + "')";
53.2243 +
53.2244 + //check if there was a constraint
53.2245 + String constraint =
53.2246 + bindElement.getAttributeNS(XFORMS_NS,
53.2247 + "constraint");
53.2248 +
53.2249 + if ((constraint != null)
53.2250 + && !constraint.equals("")) {
53.2251 + constraint =
53.2252 + constraint
53.2253 + + " && "
53.2254 + + isValidExpr;
53.2255 + } else {
53.2256 + constraint = isValidExpr;
53.2257 + }
53.2258 +
53.2259 + bindElement.setAttribute("constraint",
53.2260 + constraint);
53.2261 + }
53.2262 +
53.2263 + Element choicesControlWrapper =
53.2264 + _wrapper.createControlsWrapper(choices);
53.2265 + control.appendChild(choicesControlWrapper);
53.2266 +
53.2267 + Element controlWrapper =
53.2268 + _wrapper.createControlsWrapper(control);
53.2269 + formSection.appendChild(controlWrapper);
53.2270 +
53.2271 + ///////////////// ///////////////
53.2272 + // add content to select1
53.2273 + HashMap case_types = new HashMap();
53.2274 + addChoicesForSelectSwitchControl(xForm,
53.2275 + choices,
53.2276 + enumValues,
53.2277 + case_types);
53.2278 +
53.2279 + /////////////////
53.2280 + //add a trigger for this control (is there a way to not need it ?)
53.2281 + Element trigger = xForm.createElementNS(XFORMS_NS,
53.2282 + getXFormsNSPrefix() + "trigger");
53.2283 + formSection.appendChild(trigger);
53.2284 + this.setXFormsId(trigger);
53.2285 + Element label_trigger = xForm.createElementNS(XFORMS_NS,
53.2286 + getXFormsNSPrefix() + "label");
53.2287 + this.setXFormsId(label_trigger);
53.2288 + trigger.appendChild(label_trigger);
53.2289 + String trigger_caption = createCaption("validate choice");
53.2290 + label_trigger.appendChild(xForm.createTextNode(trigger_caption));
53.2291 + Element action_trigger = xForm.createElementNS(XFORMS_NS,
53.2292 + getXFormsNSPrefix() + "action");
53.2293 + this.setXFormsId(action_trigger);
53.2294 + trigger.appendChild(action_trigger);
53.2295 + Element dispatch_trigger = xForm.createElementNS(XFORMS_NS,
53.2296 + getXFormsNSPrefix() + "dispatch");
53.2297 + this.setXFormsId(dispatch_trigger);
53.2298 + action_trigger.appendChild(dispatch_trigger);
53.2299 + dispatch_trigger.setAttribute("name",
53.2300 + "DOMActivate");
53.2301 + dispatch_trigger.setAttribute("target",
53.2302 + select1_id);
53.2303 +
53.2304 + /////////////////
53.2305 + //add switch
53.2306 + Element switchElement =
53.2307 + xForm.createElementNS(XFORMS_NS,
53.2308 + getXFormsNSPrefix() + "switch");
53.2309 + this.setXFormsId(switchElement);
53.2310 +
53.2311 + Element switchControlWrapper =
53.2312 + _wrapper.createControlsWrapper(switchElement);
53.2313 + formSection.appendChild(switchControlWrapper);
53.2314 + //formSection.appendChild(switchElement);
53.2315 +
53.2316 + /////////////// add this type //////////////
53.2317 + Element firstCaseElement = (Element) case_types.get(controlType.getName());
53.2318 + switchElement.appendChild(firstCaseElement);
53.2319 + addComplexType(xForm,
53.2320 + modelSection,
53.2321 + firstCaseElement,
53.2322 + (XSComplexTypeDefinition) controlType,
53.2323 + elementDecl,
53.2324 + pathToRoot,
53.2325 + true,
53.2326 + false);
53.2327 +
53.2328 + /////////////// add sub types //////////////
53.2329 + it = compatibleTypes.iterator();
53.2330 + // add each compatible type within
53.2331 + // a case statement
53.2332 + while (it.hasNext()) {
53.2333 + /*String compatibleTypeName = (String) it.next();
53.2334 + //WARNING: order of parameters inversed from the doc for 2.6.0 !!!
53.2335 + XSTypeDefinition type =getSchema().getTypeDefinition(
53.2336 + compatibleTypeName,
53.2337 + targetNamespace);*/
53.2338 + XSTypeDefinition type = (XSTypeDefinition) it.next();
53.2339 + String compatibleTypeName = type.getName();
53.2340 +
53.2341 + if (LOGGER.isDebugEnabled()) {
53.2342 + if (type == null)
53.2343 + LOGGER.debug(">>>addElement: compatible type is null!! type="
53.2344 + + compatibleTypeName
53.2345 + + ", targetNamespace="
53.2346 + + targetNamespace);
53.2347 + else
53.2348 + LOGGER.debug(" >>>addElement: adding compatible type "
53.2349 + + type.getName());
53.2350 + }
53.2351 +
53.2352 + if (type != null
53.2353 + && type.getTypeCategory()
53.2354 + == XSTypeDefinition
53.2355 + .COMPLEX_TYPE) {
53.2356 +
53.2357 + //Element caseElement = (Element) xForm.createElementNS(XFORMS_NS,getXFormsNSPrefix() + "case");
53.2358 + //caseElement.setAttributeNS(XFORMS_NS,getXFormsNSPrefix() + "id",bindId + "_" + type.getName() +"_case");
53.2359 + //String case_id=this.setXFormsId(caseElement);
53.2360 + Element caseElement =
53.2361 + (Element) case_types.get(type.getName());
53.2362 + switchElement.appendChild(caseElement);
53.2363 +
53.2364 + addComplexType(xForm,
53.2365 + modelSection,
53.2366 + caseElement,
53.2367 + (XSComplexTypeDefinition) type,
53.2368 + elementDecl,
53.2369 + pathToRoot,
53.2370 + true,
53.2371 + true);
53.2372 +
53.2373 + //////
53.2374 + // modify bind to add a "relevant" attribute that checks the value of @xsi:type
53.2375 + //
53.2376 + if (LOGGER.isDebugEnabled())
53.2377 + DOMUtil.prettyPrintDOM(bindElement2);
53.2378 + NodeList binds = bindElement2.getElementsByTagNameNS(XFORMS_NS, "bind");
53.2379 + Element thisBind = null;
53.2380 + int nb_binds = binds.getLength();
53.2381 + int i = 0;
53.2382 + while (i < nb_binds && thisBind == null) {
53.2383 + Element subBind = (Element) binds.item(i);
53.2384 + String name = subBind.getAttributeNS(XFORMS_NS, "nodeset");
53.2385 +
53.2386 + if (LOGGER.isDebugEnabled())
53.2387 + LOGGER.debug("Testing sub-bind with nodeset " + name);
53.2388 +
53.2389 + if (this.isElementDeclaredIn(name, (XSComplexTypeDefinition) type, false)
53.2390 + || this.isAttributeDeclaredIn(name, (XSComplexTypeDefinition) type, false)
53.2391 + ) {
53.2392 + if (LOGGER.isDebugEnabled())
53.2393 + LOGGER.debug("Element/Attribute " + name + " declared in type " + type.getName() + ": adding relevant attribute");
53.2394 +
53.2395 + //test sub types of this type
53.2396 + TreeSet subCompatibleTypes = (TreeSet) typeTree.get(type.getName());
53.2397 + //TreeSet subCompatibleTypes = (TreeSet) typeTree.get(type);
53.2398 +
53.2399 + String newRelevant = null;
53.2400 + if (subCompatibleTypes == null || subCompatibleTypes.isEmpty()) {
53.2401 + //just add ../@xsi:type='type'
53.2402 + newRelevant = "../@xsi:type='" + type.getName() + "'";
53.2403 + } else {
53.2404 + //add ../@xsi:type='type' or ../@xsi:type='otherType' or ...
53.2405 + newRelevant = "../@xsi:type='" + type.getName() + "'";
53.2406 + Iterator it_ct = subCompatibleTypes.iterator();
53.2407 + while (it_ct.hasNext()) {
53.2408 + //String otherTypeName = (String) it_ct.next();
53.2409 + XSTypeDefinition otherType = (XSTypeDefinition) it_ct.next();
53.2410 + String otherTypeName = otherType.getName();
53.2411 + newRelevant = newRelevant + " or ../@xsi:type='" + otherTypeName + "'";
53.2412 + }
53.2413 + }
53.2414 +
53.2415 + //change relevant attribute
53.2416 + String relevant = subBind.getAttributeNS(XFORMS_NS, "relevant");
53.2417 + if (relevant != null && !relevant.equals("")) {
53.2418 + newRelevant = "(" + relevant + ") and " + newRelevant;
53.2419 + }
53.2420 + if (newRelevant != null && !newRelevant.equals(""))
53.2421 + subBind.setAttribute("relevant", newRelevant);
53.2422 + }
53.2423 +
53.2424 + i++;
53.2425 + }
53.2426 + }
53.2427 + }
53.2428 +
53.2429 + /*if (LOGGER.isDebugEnabled()) {
53.2430 + LOGGER.debug(
53.2431 + "###addElement for derived type: bind created:");
53.2432 + DOMUtil.prettyPrintDOM(bindElement2);
53.2433 + }*/
53.2434 +
53.2435 + // we're done
53.2436 + //
53.2437 + break;
53.2438 +
53.2439 + } else if (enumValues.size() == 1) {
53.2440 + // only one compatible type, set the controlType value
53.2441 + // and fall through
53.2442 + //
53.2443 + //controlType = getSchema().getComplexType((String)enumValues.get(0));
53.2444 + controlType =
53.2445 + getSchema().getTypeDefinition((String) enumValues.get(0),
53.2446 + targetNamespace);
53.2447 + }
53.2448 + } else if (LOGGER.isDebugEnabled())
53.2449 + LOGGER.debug("No compatible type found for " + typeName);
53.2450 +
53.2451 + //name not null but no compatibleType?
53.2452 + relative = true;
53.2453 + }
53.2454 +
53.2455 + if (relative) //create the bind in case it is a repeat
53.2456 + {
53.2457 + if (LOGGER.isDebugEnabled())
53.2458 + LOGGER.debug(">>>Adding empty bind for " + typeName);
53.2459 +
53.2460 + // create the <xforms:bind> element and add it to the model.
53.2461 + Element bindElement =
53.2462 + xForm.createElementNS(XFORMS_NS,
53.2463 + getXFormsNSPrefix() + "bind");
53.2464 + String bindId = this.setXFormsId(bindElement);
53.2465 + bindElement.setAttribute("nodeset",
53.2466 + pathToRoot);
53.2467 +
53.2468 + modelSection.appendChild(bindElement);
53.2469 + } else if (LOGGER.isDebugEnabled()) {
53.2470 + LOGGER.debug("addElement: bind is not relative for "
53.2471 + + elementDecl.getName());
53.2472 + }
53.2473 +
53.2474 + //addComplexType(xForm,modelSection, formSection,(ComplexType)controlType,elementDecl,pathToRoot, relative);
53.2475 + addComplexType(xForm,
53.2476 + modelSection,
53.2477 + formSection,
53.2478 + (XSComplexTypeDefinition) controlType,
53.2479 + elementDecl,
53.2480 + pathToRoot,
53.2481 + true,
53.2482 + false);
53.2483 +
53.2484 + break;
53.2485 + }
53.2486 + }
53.2487 +
53.2488 + default : // TODO: add wildcard support
53.2489 + LOGGER.warn("\nWARNING!!! - Unsupported type ["
53.2490 + + elementDecl.getType()
53.2491 + + "] for node ["
53.2492 + + controlType.getName()
53.2493 + + "]");
53.2494 + }
53.2495 + }
53.2496 +
53.2497 + /**
53.2498 + * check that the element defined by this name is declared directly in the type
53.2499 + **/
53.2500 + /*private boolean isElementDeclaredIn(String name, XSComplexTypeDefinition type){
53.2501 + boolean found=false;
53.2502 +
53.2503 + XSParticle particle=type.getParticle();
53.2504 + XSTerm term=particle.getTerm();
53.2505 + if(term instanceof XSModelGroup){
53.2506 + XSModelGroup group=(XSModelGroup) term;
53.2507 + XSObjectList particles=group.getParticles();
53.2508 + int i=0;
53.2509 + int nb=particles.getLength();
53.2510 + while(i<nb){
53.2511 + XSParticle subPart=(XSParticle) particles.item(i);
53.2512 + XSTerm subTerm=subPart.getTerm();
53.2513 + if(subTerm instanceof XSElementDeclaration){
53.2514 + XSElementDeclaration elDecl=(XSElementDeclaration) subTerm;
53.2515 + if(name.equals(elDecl.getName()))
53.2516 + found=true;
53.2517 + }
53.2518 +
53.2519 + i++;
53.2520 + }
53.2521 + }
53.2522 +
53.2523 + return found;
53.2524 + }*/
53.2525 + /**
53.2526 + * check that the element defined by this name is declared directly in the type
53.2527 + */
53.2528 + private boolean isElementDeclaredIn(String name, XSComplexTypeDefinition type, boolean recursive) {
53.2529 + boolean found = false;
53.2530 +
53.2531 + if (LOGGER.isDebugEnabled())
53.2532 + LOGGER.debug("isElement " + name + " declared in " + type.getName());
53.2533 +
53.2534 +//test if extension + declared in parent + not recursive -> NOK
53.2535 + if (!recursive && type.getDerivationMethod() == XSConstants.DERIVATION_EXTENSION) {
53.2536 + XSComplexTypeDefinition parent = (XSComplexTypeDefinition) type.getBaseType();
53.2537 + if (LOGGER.isDebugEnabled())
53.2538 + LOGGER.debug("testing if it is not on parent " + parent.getName());
53.2539 + if (this.isElementDeclaredIn(name, parent, true))
53.2540 + return false;
53.2541 + }
53.2542 +
53.2543 + XSParticle particle = type.getParticle();
53.2544 + if (particle != null) {
53.2545 + XSTerm term = particle.getTerm();
53.2546 + if (term instanceof XSModelGroup) {
53.2547 + XSModelGroup group = (XSModelGroup) term;
53.2548 + found = this.isElementDeclaredIn(name, group);
53.2549 + }
53.2550 + }
53.2551 +
53.2552 + if (LOGGER.isDebugEnabled())
53.2553 + LOGGER.debug("isElement " + name + " declared in " + type.getName() + ": " + found);
53.2554 +
53.2555 + return found;
53.2556 + }
53.2557 +
53.2558 + /**
53.2559 + * private recursive method called by isElementDeclaredIn(String name, XSComplexTypeDefinition type)
53.2560 + */
53.2561 + private boolean isElementDeclaredIn(String name, XSModelGroup group) {
53.2562 +
53.2563 + if (LOGGER.isDebugEnabled())
53.2564 + LOGGER.debug("isElement " + name + " declared in group " + group.getName());
53.2565 +
53.2566 + boolean found = false;
53.2567 + XSObjectList particles = group.getParticles();
53.2568 + int i = 0;
53.2569 + int nb = particles.getLength();
53.2570 + while (i < nb) {
53.2571 + XSParticle subPart = (XSParticle) particles.item(i);
53.2572 + XSTerm subTerm = subPart.getTerm();
53.2573 + if (subTerm instanceof XSElementDeclaration) {
53.2574 + XSElementDeclaration elDecl = (XSElementDeclaration) subTerm;
53.2575 + if (name.equals(elDecl.getName()))
53.2576 + found = true;
53.2577 + } else if (subTerm instanceof XSModelGroup) { //recursive
53.2578 + found = this.isElementDeclaredIn(name, (XSModelGroup) subTerm);
53.2579 + }
53.2580 +
53.2581 + i++;
53.2582 + }
53.2583 +
53.2584 + if (LOGGER.isDebugEnabled())
53.2585 + LOGGER.debug("isElement " + name + " declared in group " + group.getName() + ": " + found);
53.2586 + return found;
53.2587 + }
53.2588 +
53.2589 + private boolean doesElementComeFromExtension(XSElementDeclaration element, XSComplexTypeDefinition controlType) {
53.2590 + if (LOGGER.isDebugEnabled())
53.2591 + LOGGER.debug("doesElementComeFromExtension for " + element.getName() + " and controlType=" + controlType.getName());
53.2592 + boolean comesFromExtension = false;
53.2593 + if (controlType.getDerivationMethod() == XSConstants.DERIVATION_EXTENSION) {
53.2594 + XSTypeDefinition baseType = controlType.getBaseType();
53.2595 + if (baseType.getTypeCategory() == XSTypeDefinition.COMPLEX_TYPE) {
53.2596 + XSComplexTypeDefinition complexType = (XSComplexTypeDefinition) baseType;
53.2597 + if (this.isElementDeclaredIn(element.getName(), complexType, true)) {
53.2598 + if (LOGGER.isDebugEnabled())
53.2599 + LOGGER.debug("doesElementComeFromExtension: yes");
53.2600 + comesFromExtension = true;
53.2601 + } else { //recursive call
53.2602 + if (LOGGER.isDebugEnabled())
53.2603 + LOGGER.debug("doesElementComeFromExtension: recursive call on previous level");
53.2604 + comesFromExtension = this.doesElementComeFromExtension(element, complexType);
53.2605 + }
53.2606 + }
53.2607 + }
53.2608 + return comesFromExtension;
53.2609 + }
53.2610 +
53.2611 + /**
53.2612 + * check that the element defined by this name is declared directly in the type
53.2613 + */
53.2614 + private boolean isAttributeDeclaredIn(XSAttributeUse attr, XSComplexTypeDefinition type, boolean recursive) {
53.2615 + boolean found = false;
53.2616 +
53.2617 + if (LOGGER.isDebugEnabled())
53.2618 + LOGGER.debug("is Attribute " + attr.getAttrDeclaration().getName() + " declared in " + type.getName());
53.2619 +
53.2620 +//check on parent if not recursive
53.2621 + if (!recursive && type.getDerivationMethod() == XSConstants.DERIVATION_EXTENSION) {
53.2622 + XSComplexTypeDefinition parent = (XSComplexTypeDefinition) type.getBaseType();
53.2623 + if (LOGGER.isDebugEnabled())
53.2624 + LOGGER.debug("testing if it is not on parent " + parent.getName());
53.2625 + if (this.isAttributeDeclaredIn(attr, parent, true))
53.2626 + return false;
53.2627 + }
53.2628 +
53.2629 +//check on this type (also checks recursively)
53.2630 + XSObjectList attrs = type.getAttributeUses();
53.2631 + int nb = attrs.getLength();
53.2632 + int i = 0;
53.2633 + while (i < nb && !found) {
53.2634 + XSAttributeUse anAttr = (XSAttributeUse) attrs.item(i);
53.2635 + if (anAttr == attr)
53.2636 + found = true;
53.2637 + i++;
53.2638 + }
53.2639 +
53.2640 +//recursive call
53.2641 +/*if(!found && recursive &&
53.2642 + type.getDerivationMethod()==XSConstants.DERIVATION_EXTENSION){
53.2643 + XSComplexTypeDefinition base=(XSComplexTypeDefinition) type.getBaseType();
53.2644 + if(base!=null && base!=type)
53.2645 + found = this.isAttributeDeclaredIn(attr, base, true);
53.2646 + }*/
53.2647 +
53.2648 + if (LOGGER.isDebugEnabled())
53.2649 + LOGGER.debug("is Attribute " + attr.getName() + " declared in " + type.getName() + ": " + found);
53.2650 +
53.2651 + return found;
53.2652 + }
53.2653 +
53.2654 + /**
53.2655 + * check that the element defined by this name is declared directly in the type
53.2656 + * -> idem with string
53.2657 + */
53.2658 + private boolean isAttributeDeclaredIn(String attrName, XSComplexTypeDefinition type, boolean recursive) {
53.2659 + boolean found = false;
53.2660 +
53.2661 + if (LOGGER.isDebugEnabled())
53.2662 + LOGGER.debug("is Attribute " + attrName + " declared in " + type.getName());
53.2663 +
53.2664 + if (attrName.startsWith("@"))
53.2665 + attrName = attrName.substring(1);
53.2666 +
53.2667 +//check on parent if not recursive
53.2668 + if (!recursive && type.getDerivationMethod() == XSConstants.DERIVATION_EXTENSION) {
53.2669 + XSComplexTypeDefinition parent = (XSComplexTypeDefinition) type.getBaseType();
53.2670 + if (LOGGER.isDebugEnabled())
53.2671 + LOGGER.debug("testing if it is not on parent " + parent.getName());
53.2672 + if (this.isAttributeDeclaredIn(attrName, parent, true))
53.2673 + return false;
53.2674 + }
53.2675 +
53.2676 +//check on this type (also checks recursively)
53.2677 + XSObjectList attrs = type.getAttributeUses();
53.2678 + int nb = attrs.getLength();
53.2679 + int i = 0;
53.2680 + while (i < nb && !found) {
53.2681 + XSAttributeUse anAttr = (XSAttributeUse) attrs.item(i);
53.2682 + if (anAttr != null) {
53.2683 + String name = anAttr.getName();
53.2684 + if (name == null || name.equals(""))
53.2685 + name = anAttr.getAttrDeclaration().getName();
53.2686 + if (attrName.equals(name))
53.2687 + found = true;
53.2688 + }
53.2689 + i++;
53.2690 + }
53.2691 +
53.2692 +//recursive call -> no need
53.2693 +/*if(!found && recursive &&
53.2694 + type.getDerivationMethod()==XSConstants.DERIVATION_EXTENSION){
53.2695 + XSComplexTypeDefinition base=(XSComplexTypeDefinition) type.getBaseType();
53.2696 + if(base!=null && base!=type)
53.2697 + found = this.isAttributeDeclaredIn(attrName, base, true);
53.2698 + }*/
53.2699 +
53.2700 + if (LOGGER.isDebugEnabled())
53.2701 + LOGGER.debug("is Attribute " + attrName + " declared in " + type.getName() + ": " + found);
53.2702 +
53.2703 + return found;
53.2704 + }
53.2705 +
53.2706 + private boolean doesAttributeComeFromExtension(XSAttributeUse attr, XSComplexTypeDefinition controlType) {
53.2707 + if (LOGGER.isDebugEnabled())
53.2708 + LOGGER.debug("doesAttributeComeFromExtension for " + attr.getAttrDeclaration().getName() + " and controlType=" + controlType.getName());
53.2709 + boolean comesFromExtension = false;
53.2710 + if (controlType.getDerivationMethod() == XSConstants.DERIVATION_EXTENSION) {
53.2711 + XSTypeDefinition baseType = controlType.getBaseType();
53.2712 + if (baseType.getTypeCategory() == XSTypeDefinition.COMPLEX_TYPE) {
53.2713 + XSComplexTypeDefinition complexType = (XSComplexTypeDefinition) baseType;
53.2714 + if (this.isAttributeDeclaredIn(attr, complexType, true)) {
53.2715 + if (LOGGER.isDebugEnabled())
53.2716 + LOGGER.debug("doesAttributeComeFromExtension: yes");
53.2717 + comesFromExtension = true;
53.2718 + } else { //recursive call
53.2719 + if (LOGGER.isDebugEnabled())
53.2720 + LOGGER.debug("doesAttributeComeFromExtension: recursive call on previous level");
53.2721 + comesFromExtension = this.doesAttributeComeFromExtension(attr, complexType);
53.2722 + }
53.2723 + }
53.2724 + }
53.2725 + return comesFromExtension;
53.2726 + }
53.2727 +
53.2728 + /**
53.2729 + * checkIfExtension: if false, addElement is called wether it is an extension or not
53.2730 + * if true, if it is an extension, element is recopied (and no additional bind)
53.2731 + */
53.2732 + private void addGroup(Document xForm,
53.2733 + Element modelSection,
53.2734 + Element formSection,
53.2735 + XSModelGroup group,
53.2736 + XSComplexTypeDefinition controlType,
53.2737 + XSElementDeclaration owner,
53.2738 + String pathToRoot,
53.2739 + int minOccurs,
53.2740 + int maxOccurs,
53.2741 + boolean checkIfExtension) {
53.2742 + if (group != null) {
53.2743 +
53.2744 + Element repeatSection =
53.2745 + addRepeatIfNecessary(xForm,
53.2746 + modelSection,
53.2747 + formSection,
53.2748 + owner.getTypeDefinition(),
53.2749 + minOccurs,
53.2750 + maxOccurs,
53.2751 + pathToRoot);
53.2752 + Element repeatContentWrapper = repeatSection;
53.2753 +
53.2754 + if (repeatSection != formSection) {
53.2755 + //selector -> no more needed?
53.2756 + //this.addSelector(xForm, repeatSection);
53.2757 + //group wrapper
53.2758 + repeatContentWrapper =
53.2759 + _wrapper.createGroupContentWrapper(repeatSection);
53.2760 + }
53.2761 +
53.2762 + if (LOGGER.isDebugEnabled())
53.2763 + LOGGER.debug("addGroup from owner=" + owner.getName() + " and controlType=" + controlType.getName());
53.2764 +
53.2765 + XSObjectList particles = group.getParticles();
53.2766 + for (int counter = 0; counter < particles.getLength(); counter++) {
53.2767 + XSParticle currentNode = (XSParticle) particles.item(counter);
53.2768 + XSTerm term = currentNode.getTerm();
53.2769 +
53.2770 + if (LOGGER.isDebugEnabled())
53.2771 + LOGGER.debug(" : next term = " + term.getName());
53.2772 +
53.2773 + int childMaxOccurs = currentNode.getMaxOccurs();
53.2774 + if (currentNode.getMaxOccursUnbounded())
53.2775 + childMaxOccurs = -1;
53.2776 + int childMinOccurs = currentNode.getMinOccurs();
53.2777 +
53.2778 + if (term instanceof XSModelGroup) {
53.2779 +
53.2780 + if (LOGGER.isDebugEnabled())
53.2781 + LOGGER.debug(" term is a group");
53.2782 +
53.2783 + addGroup(xForm,
53.2784 + modelSection,
53.2785 + repeatContentWrapper,
53.2786 + ((XSModelGroup) term),
53.2787 + controlType,
53.2788 + owner,
53.2789 + pathToRoot,
53.2790 + childMinOccurs,
53.2791 + childMaxOccurs,
53.2792 + checkIfExtension);
53.2793 + } else if (term instanceof XSElementDeclaration) {
53.2794 + XSElementDeclaration element = (XSElementDeclaration) term;
53.2795 +
53.2796 + if (LOGGER.isDebugEnabled())
53.2797 + LOGGER.debug(" term is an element declaration: "
53.2798 + + term.getName());
53.2799 +
53.2800 + //special case for types already added because used in an extension
53.2801 + //do not add it when it comes from an extension !!!
53.2802 + //-> make a copy from the existing form control
53.2803 + if (checkIfExtension && this.doesElementComeFromExtension(element, controlType)) {
53.2804 + if (LOGGER.isDebugEnabled()) {
53.2805 + LOGGER.debug("This element comes from an extension: recopy form controls.\n Model Section=");
53.2806 + DOMUtil.prettyPrintDOM(modelSection);
53.2807 + }
53.2808 +
53.2809 + //find the existing bind Id
53.2810 + //(modelSection is the enclosing bind of the element)
53.2811 + NodeList binds = modelSection.getElementsByTagNameNS(XFORMS_NS, "bind");
53.2812 + int i = 0;
53.2813 + int nb = binds.getLength();
53.2814 + String bindId = null;
53.2815 + while (i < nb && bindId == null) {
53.2816 + Element bind = (Element) binds.item(i);
53.2817 + String nodeset = bind.getAttributeNS(XFORMS_NS, "nodeset");
53.2818 + if (nodeset != null && nodeset.equals(element.getName()))
53.2819 + bindId = bind.getAttributeNS(XFORMS_NS, "id");
53.2820 + i++;
53.2821 + }
53.2822 +
53.2823 + //find the control
53.2824 + Element control = null;
53.2825 + if (bindId != null) {
53.2826 + if (LOGGER.isDebugEnabled())
53.2827 + LOGGER.debug("bindId found: " + bindId);
53.2828 +
53.2829 + JXPathContext context = JXPathContext.newContext(formSection.getOwnerDocument());
53.2830 + Pointer pointer = context.getPointer("//*[@" + this.getXFormsNSPrefix() + "bind='" + bindId + "']");
53.2831 + if (pointer != null)
53.2832 + control = (Element) pointer.getNode();
53.2833 + }
53.2834 +
53.2835 + //copy it
53.2836 + if (control == null) {
53.2837 + LOGGER.warn("Corresponding control not found");
53.2838 + } else {
53.2839 + Element newControl = (Element) control.cloneNode(true);
53.2840 + //set new Ids to XForm elements
53.2841 + this.resetXFormIds(newControl);
53.2842 +
53.2843 + repeatContentWrapper.appendChild(newControl);
53.2844 + }
53.2845 +
53.2846 + } else { //add it normally
53.2847 + String elementName = getElementName(element, xForm);
53.2848 +
53.2849 + String path = pathToRoot + "/" + elementName;
53.2850 +
53.2851 + if (pathToRoot.equals("")) { //relative
53.2852 + path = elementName;
53.2853 + }
53.2854 +
53.2855 + addElement(xForm,
53.2856 + modelSection,
53.2857 + repeatContentWrapper,
53.2858 + element,
53.2859 + element.getTypeDefinition(),
53.2860 + path);
53.2861 + }
53.2862 + } else { //XSWildcard -> ignore ?
53.2863 + //LOGGER.warn("XSWildcard found in group from "+owner.getName()+" for pathToRoot="+pathToRoot);
53.2864 + }
53.2865 + }
53.2866 +
53.2867 + if (LOGGER.isDebugEnabled())
53.2868 + LOGGER.debug("--- end of addGroup from owner=" + owner.getName());
53.2869 + }
53.2870 + }
53.2871 +
53.2872 + /**
53.2873 + * Add a repeat section if maxOccurs > 1.
53.2874 + */
53.2875 + private Element addRepeatIfNecessary(Document xForm,
53.2876 + Element modelSection,
53.2877 + Element formSection,
53.2878 + XSTypeDefinition controlType,
53.2879 + int minOccurs,
53.2880 + int maxOccurs,
53.2881 + String pathToRoot) {
53.2882 + Element repeatSection = formSection;
53.2883 +
53.2884 + // add xforms:repeat section if this element re-occurs
53.2885 + //
53.2886 + if (maxOccurs != 1) {
53.2887 +
53.2888 + if (LOGGER.isDebugEnabled())
53.2889 + LOGGER.debug("DEBUG: AddRepeatIfNecessary for multiple element for type "
53.2890 + + controlType.getName()
53.2891 + + ", maxOccurs=" + maxOccurs);
53.2892 +
53.2893 + //repeatSection = (Element) formSection.appendChild(xForm.createElementNS(XFORMS_NS,getXFormsNSPrefix() + "repeat"));
53.2894 + repeatSection =
53.2895 + xForm.createElementNS(XFORMS_NS,
53.2896 + getXFormsNSPrefix() + "repeat");
53.2897 +
53.2898 + //bind instead of repeat
53.2899 + //repeatSection.setAttributeNS(XFORMS_NS,getXFormsNSPrefix() + "nodeset",pathToRoot);
53.2900 + // bind -> last element in the modelSection
53.2901 + Element bind = DOMUtil.getLastChildElement(modelSection);
53.2902 + String bindId = null;
53.2903 +
53.2904 + if ((bind != null)
53.2905 + && (bind.getLocalName() != null)
53.2906 + && bind.getLocalName().equals("bind")) {
53.2907 + bindId = bind.getAttributeNS(SchemaFormBuilder.XFORMS_NS, "id");
53.2908 + } else {
53.2909 + LOGGER.warn("addRepeatIfNecessary: bind not found: "
53.2910 + + bind
53.2911 + + " (model selection name="
53.2912 + + modelSection.getNodeName()
53.2913 + + ")");
53.2914 +
53.2915 + //if no bind is found -> modelSection is already a bind, get its parent last child
53.2916 + bind =
53.2917 + DOMUtil.getLastChildElement(modelSection.getParentNode());
53.2918 +
53.2919 + if ((bind != null)
53.2920 + && (bind.getLocalName() != null)
53.2921 + && bind.getLocalName().equals("bind")) {
53.2922 + bindId =
53.2923 + bind.getAttributeNS(SchemaFormBuilder.XFORMS_NS, "id");
53.2924 + } else {
53.2925 + LOGGER.warn("addRepeatIfNecessary: bind really not found");
53.2926 + }
53.2927 + }
53.2928 +
53.2929 + repeatSection.setAttribute("bind",
53.2930 + bindId);
53.2931 + this.setXFormsId(repeatSection);
53.2932 +
53.2933 + //appearance=full is more user friendly
53.2934 + repeatSection.setAttribute("appearance",
53.2935 + "full");
53.2936 +
53.2937 + //triggers
53.2938 + this.addTriggersForRepeat(xForm,
53.2939 + formSection,
53.2940 + repeatSection,
53.2941 + minOccurs,
53.2942 + maxOccurs,
53.2943 + bindId);
53.2944 +
53.2945 + Element controlWrapper =
53.2946 + _wrapper.createControlsWrapper(repeatSection);
53.2947 + formSection.appendChild(controlWrapper);
53.2948 +
53.2949 + //add a group inside the repeat?
53.2950 + Element group =
53.2951 + xForm.createElementNS(XFORMS_NS,
53.2952 + this.getXFormsNSPrefix() + "group");
53.2953 + this.setXFormsId(group);
53.2954 + repeatSection.appendChild(group);
53.2955 + repeatSection = group;
53.2956 + }
53.2957 +
53.2958 + return repeatSection;
53.2959 + }
53.2960 +
53.2961 + /**
53.2962 + * if "createBind", a bind is created, otherwise bindId is used
53.2963 + */
53.2964 + private void addSimpleType(Document xForm,
53.2965 + Element modelSection,
53.2966 + Element formSection,
53.2967 + XSTypeDefinition controlType,
53.2968 + String owningElementName,
53.2969 + XSObject owner,
53.2970 + String pathToRoot,
53.2971 + int minOccurs,
53.2972 + int maxOccurs) {
53.2973 +
53.2974 + if (LOGGER.isDebugEnabled())
53.2975 + LOGGER.debug("addSimpleType for "
53.2976 + + controlType.getName()
53.2977 + + " (owningElementName="
53.2978 + + owningElementName
53.2979 + + ")");
53.2980 +
53.2981 + // create the <xforms:bind> element and add it to the model.
53.2982 + Element bindElement = xForm.createElementNS(XFORMS_NS, getXFormsNSPrefix() + "bind");
53.2983 + String bindId = this.setXFormsId(bindElement);
53.2984 + bindElement.setAttribute("nodeset",
53.2985 + pathToRoot);
53.2986 + bindElement = (Element) modelSection.appendChild(bindElement);
53.2987 + bindElement = startBindElement(bindElement, controlType, minOccurs, maxOccurs);
53.2988 +
53.2989 + // add a group if a repeat !
53.2990 + if (owner instanceof XSElementDeclaration
53.2991 + && maxOccurs != 1
53.2992 + ) {
53.2993 + Element groupElement = createGroup(xForm, modelSection, formSection, (XSElementDeclaration) owner);
53.2994 + //set content
53.2995 + Element groupWrapper = groupElement;
53.2996 + if (groupElement != modelSection) {
53.2997 + groupWrapper = _wrapper.createGroupContentWrapper(groupElement);
53.2998 + }
53.2999 + formSection = groupWrapper;
53.3000 + }
53.3001 +
53.3002 + //eventual repeat
53.3003 + Element repeatSection =
53.3004 + addRepeatIfNecessary(xForm,
53.3005 + modelSection,
53.3006 + formSection,
53.3007 + controlType,
53.3008 + minOccurs,
53.3009 + maxOccurs,
53.3010 + pathToRoot);
53.3011 +
53.3012 + // create the form control element
53.3013 + //put a wrapper for the repeat content, but only if it is really a repeat
53.3014 + Element contentWrapper = repeatSection;
53.3015 +
53.3016 + if (repeatSection != formSection) {
53.3017 + //content of repeat
53.3018 + contentWrapper = _wrapper.createGroupContentWrapper(repeatSection);
53.3019 +
53.3020 + //if there is a repeat -> create another bind with "."
53.3021 + Element bindElement2 =
53.3022 + xForm.createElementNS(XFORMS_NS, getXFormsNSPrefix() + "bind");
53.3023 + String bindId2 = this.setXFormsId(bindElement2);
53.3024 + bindElement2.setAttribute("nodeset",
53.3025 + ".");
53.3026 +
53.3027 + //recopy other attributes: required and type
53.3028 + // ->no, attributes shouldn't be copied
53.3029 + /*String required = "required";
53.3030 + String type = "type";
53.3031 + if (bindElement.hasAttributeNS(XFORMS_NS, required)) {
53.3032 + bindElement2.setAttributeNS(XFORMS_NS, getXFormsNSPrefix() + required,
53.3033 + bindElement.getAttributeNS(XFORMS_NS, required));
53.3034 + }
53.3035 + if (bindElement.hasAttributeNS(XFORMS_NS, type)) {
53.3036 + bindElement2.setAttributeNS(XFORMS_NS, getXFormsNSPrefix() + type,
53.3037 + bindElement.getAttributeNS(XFORMS_NS, type));
53.3038 + }*/
53.3039 +
53.3040 + bindElement.appendChild(bindElement2);
53.3041 + bindId = bindId2;
53.3042 + }
53.3043 +
53.3044 + String caption = createCaption(owningElementName);
53.3045 +
53.3046 + //Element formControl = (Element) contentWrapper.appendChild(createFormControl(xForm,caption,controlType,bindId,bindElement,minOccurs,maxOccurs));
53.3047 + Element formControl =
53.3048 + createFormControl(xForm,
53.3049 + caption,
53.3050 + controlType,
53.3051 + bindId,
53.3052 + bindElement,
53.3053 + minOccurs,
53.3054 + maxOccurs,
53.3055 + pathToRoot);
53.3056 + Element controlWrapper = _wrapper.createControlsWrapper(formControl);
53.3057 + contentWrapper.appendChild(controlWrapper);
53.3058 +
53.3059 + // if this is a repeatable then set ref to point to current element
53.3060 + // not sure if this is a workaround or this is just the way XForms works...
53.3061 + //
53.3062 + if (!repeatSection.equals(formSection)) {
53.3063 + formControl.setAttribute("ref",
53.3064 + ".");
53.3065 + }
53.3066 +
53.3067 + Element hint = createHint(xForm, owner);
53.3068 +
53.3069 + if (hint != null) {
53.3070 + formControl.appendChild(hint);
53.3071 + }
53.3072 +
53.3073 + //add selector if repeat
53.3074 + //if (repeatSection != formSection)
53.3075 + //this.addSelector(xForm, (Element) formControl.getParentNode());
53.3076 + //
53.3077 + // TODO: Generate help message based on datatype and restrictions
53.3078 + endFormControl(formControl, controlType, minOccurs, maxOccurs);
53.3079 + endBindElement(bindElement);
53.3080 + }
53.3081 +
53.3082 + private void addSimpleType(Document xForm,
53.3083 + Element modelSection,
53.3084 + Element formSection,
53.3085 + XSSimpleTypeDefinition controlType,
53.3086 + XSElementDeclaration owner,
53.3087 + String pathToRoot) {
53.3088 +
53.3089 + int[] occurance = this.getOccurance(owner);
53.3090 + addSimpleType(xForm,
53.3091 + modelSection,
53.3092 + formSection,
53.3093 + controlType,
53.3094 + owner.getName(),
53.3095 + owner,
53.3096 + pathToRoot,
53.3097 + occurance[0],
53.3098 + occurance[1]);
53.3099 + }
53.3100 +
53.3101 + private void addSimpleType(Document xForm,
53.3102 + Element modelSection,
53.3103 + Element formSection,
53.3104 + XSSimpleTypeDefinition controlType,
53.3105 + XSAttributeUse owningAttribute,
53.3106 + String pathToRoot) {
53.3107 +
53.3108 + addSimpleType(xForm,
53.3109 + modelSection,
53.3110 + formSection,
53.3111 + controlType,
53.3112 + owningAttribute.getAttrDeclaration().getName(),
53.3113 + owningAttribute,
53.3114 + pathToRoot,
53.3115 + owningAttribute.getRequired() ? 1 : 0,
53.3116 + 1);
53.3117 + }
53.3118 +
53.3119 + /**
53.3120 + * adds a "chiba:selector" in the specified element
53.3121 + **/
53.3122 +
53.3123 + /*private void addSelector(Document xForm, Element el) {
53.3124 + Element extension = xForm.createElementNS(XFORMS_NS, getXFormsNSPrefix() + "extension");
53.3125 + el.appendChild(extension);
53.3126 + Element selector = xForm.createElementNS(XFORMS_NS, getChibaNSPrefix() + "selector");
53.3127 + extension.appendChild(selector);
53.3128 + }*/
53.3129 +
53.3130 + /**
53.3131 + * add triggers to use the repeat elements (allow to add an element, ...)
53.3132 + */
53.3133 + private void addTriggersForRepeat(Document xForm,
53.3134 + Element formSection,
53.3135 + Element repeatSection,
53.3136 + int minOccurs,
53.3137 + int maxOccurs,
53.3138 + String bindId) {
53.3139 + ///////////// insert //////////////////
53.3140 + //trigger insert
53.3141 + Element trigger_insert =
53.3142 + xForm.createElementNS(SchemaFormBuilder.XFORMS_NS,
53.3143 + SchemaFormBuilder.xformsNSPrefix + "trigger");
53.3144 + this.setXFormsId(trigger_insert);
53.3145 +
53.3146 + //label insert
53.3147 + Element triggerLabel_insert =
53.3148 + xForm.createElementNS(SchemaFormBuilder.XFORMS_NS,
53.3149 + SchemaFormBuilder.xformsNSPrefix + "label");
53.3150 + this.setXFormsId(triggerLabel_insert);
53.3151 + trigger_insert.appendChild(triggerLabel_insert);
53.3152 + triggerLabel_insert.setAttribute("href",
53.3153 + "images/add_new.gif");
53.3154 +
53.3155 + Text label_insert = xForm.createTextNode("Insert after selected");
53.3156 + triggerLabel_insert.appendChild(label_insert);
53.3157 +
53.3158 + //hint insert
53.3159 + Element hint_insert =
53.3160 + xForm.createElementNS(SchemaFormBuilder.XFORMS_NS,
53.3161 + SchemaFormBuilder.xformsNSPrefix + "hint");
53.3162 + this.setXFormsId(hint_insert);
53.3163 + Text hint_insert_text =
53.3164 + xForm.createTextNode("inserts a new entry in this collection");
53.3165 + hint_insert.appendChild(hint_insert_text);
53.3166 + trigger_insert.appendChild(hint_insert);
53.3167 +
53.3168 + //insert action
53.3169 + Element action_insert =
53.3170 + xForm.createElementNS(SchemaFormBuilder.XFORMS_NS,
53.3171 + SchemaFormBuilder.xformsNSPrefix + "action");
53.3172 + trigger_insert.appendChild(action_insert);
53.3173 + this.setXFormsId(action_insert);
53.3174 +
53.3175 + Element insert =
53.3176 + xForm.createElementNS(SchemaFormBuilder.XFORMS_NS,
53.3177 + SchemaFormBuilder.xformsNSPrefix + "insert");
53.3178 + action_insert.appendChild(insert);
53.3179 + this.setXFormsId(insert);
53.3180 +
53.3181 + //insert: bind & other attributes
53.3182 + if (bindId != null) {
53.3183 + insert.setAttribute("bind",
53.3184 + bindId);
53.3185 + }
53.3186 +
53.3187 + insert.setAttribute("position",
53.3188 + "after");
53.3189 +
53.3190 + //xforms:at = xforms:index from the "id" attribute on the repeat element
53.3191 + String repeatId =
53.3192 + repeatSection.getAttributeNS(SchemaFormBuilder.XFORMS_NS, "id");
53.3193 +
53.3194 + if (repeatId != null) {
53.3195 + insert.setAttribute("at",
53.3196 + "index('" + repeatId + "')");
53.3197 + }
53.3198 +
53.3199 + ///////////// delete //////////////////
53.3200 + //trigger delete
53.3201 + Element trigger_delete =
53.3202 + xForm.createElementNS(SchemaFormBuilder.XFORMS_NS,
53.3203 + SchemaFormBuilder.xformsNSPrefix + "trigger");
53.3204 + this.setXFormsId(trigger_delete);
53.3205 +
53.3206 + //label delete
53.3207 + Element triggerLabel_delete =
53.3208 + xForm.createElementNS(SchemaFormBuilder.XFORMS_NS,
53.3209 + SchemaFormBuilder.xformsNSPrefix + "label");
53.3210 + this.setXFormsId(triggerLabel_delete);
53.3211 + trigger_delete.appendChild(triggerLabel_delete);
53.3212 + triggerLabel_delete.setAttribute( "href",
53.3213 + "images/delete.gif");
53.3214 +
53.3215 + Text label_delete = xForm.createTextNode("Delete selected");
53.3216 + triggerLabel_delete.appendChild(label_delete);
53.3217 +
53.3218 + //hint delete
53.3219 + Element hint_delete =
53.3220 + xForm.createElementNS(SchemaFormBuilder.XFORMS_NS,
53.3221 + SchemaFormBuilder.xformsNSPrefix + "hint");
53.3222 + this.setXFormsId(hint_delete);
53.3223 + Text hint_delete_text =
53.3224 + xForm.createTextNode("deletes selected entry from this collection");
53.3225 + hint_delete.appendChild(hint_delete_text);
53.3226 + trigger_delete.appendChild(hint_delete);
53.3227 +
53.3228 + //delete action
53.3229 + Element action_delete =
53.3230 + xForm.createElementNS(SchemaFormBuilder.XFORMS_NS,
53.3231 + SchemaFormBuilder.xformsNSPrefix + "action");
53.3232 + trigger_delete.appendChild(action_delete);
53.3233 + this.setXFormsId(action_delete);
53.3234 +
53.3235 + Element delete =
53.3236 + xForm.createElementNS(SchemaFormBuilder.XFORMS_NS,
53.3237 + SchemaFormBuilder.xformsNSPrefix + "delete");
53.3238 + action_delete.appendChild(delete);
53.3239 + this.setXFormsId(delete);
53.3240 +
53.3241 + //delete: bind & other attributes
53.3242 + if (bindId != null) {
53.3243 + delete.setAttribute("bind",
53.3244 + bindId);
53.3245 + }
53.3246 +
53.3247 + //xforms:at = xforms:index from the "id" attribute on the repeat element
53.3248 + if (repeatId != null) {
53.3249 + delete.setAttribute("at",
53.3250 + "index('" + repeatId + "')");
53.3251 + }
53.3252 +
53.3253 + //add the triggers
53.3254 + Element wrapper_triggers =
53.3255 + _wrapper.createControlsWrapper(trigger_insert);
53.3256 +
53.3257 + if (wrapper_triggers == trigger_insert) { //no wrapper
53.3258 + formSection.appendChild(trigger_insert);
53.3259 + formSection.appendChild(trigger_delete);
53.3260 + } else {
53.3261 + formSection.appendChild(wrapper_triggers);
53.3262 +
53.3263 + Element insert_parent = (Element) trigger_insert.getParentNode();
53.3264 +
53.3265 + if (insert_parent != null) {
53.3266 + insert_parent.appendChild(trigger_delete);
53.3267 + }
53.3268 + }
53.3269 + }
53.3270 +
53.3271 + /**
53.3272 + * Build the type tree
53.3273 + */
53.3274 + /*private void buildTypeTree(XSTypeDefinition type, TreeSet descendents) {
53.3275 + if (type != null) {
53.3276 +
53.3277 + if (descendents.size() > 0) {
53.3278 + TreeSet compatibleTypes = (TreeSet) typeTree.get(type.getName());
53.3279 +
53.3280 + if (compatibleTypes == null) {
53.3281 + compatibleTypes = new TreeSet(descendents);
53.3282 + typeTree.put(type.getName(), compatibleTypes);
53.3283 + } else {
53.3284 + compatibleTypes.addAll(descendents);
53.3285 + }
53.3286 + }
53.3287 +
53.3288 + XSTypeDefinition parentType = type.getBaseType();
53.3289 +
53.3290 + if (parentType != null
53.3291 + && type.getTypeCategory() == parentType.getTypeCategory()) {
53.3292 + String typeName = type.getName();
53.3293 + String parentTypeName = parentType.getName();
53.3294 + if ((typeName == null && parentTypeName != null)
53.3295 + || (typeName != null && parentTypeName == null)
53.3296 + || (typeName != null
53.3297 + && parentTypeName != null
53.3298 + && !type.getName().equals(parentType.getName())
53.3299 + && !parentType.getName().equals("anyType"))) {
53.3300 +
53.3301 +TreeSet newDescendents=new TreeSet(descendents);
53.3302 +//extension (we only add it to "newDescendants" because we don't want
53.3303 +//to have a type descendant to itself, but to consider it for the parent
53.3304 +if (type.getTypeCategory() == XSTypeDefinition.COMPLEX_TYPE) {
53.3305 +XSComplexTypeDefinition complexType =
53.3306 + (XSComplexTypeDefinition) type;
53.3307 +if (complexType.getDerivationMethod()
53.3308 + == XSConstants.DERIVATION_EXTENSION
53.3309 + && !complexType.getAbstract()
53.3310 + && !descendents.contains(type.getName()) //to be tested
53.3311 + ) {
53.3312 +newDescendents.add(type.getName());
53.3313 +}
53.3314 +}
53.3315 +//note: extensions are impossible on simpleTypes !
53.3316 +
53.3317 + buildTypeTree(parentType, newDescendents);
53.3318 + }
53.3319 + }
53.3320 + }
53.3321 + }*/
53.3322 + private void buildTypeTree(XSTypeDefinition type, TreeSet descendents) {
53.3323 + if (type != null) {
53.3324 +
53.3325 + if (descendents.size() > 0) {
53.3326 + //TreeSet compatibleTypes = (TreeSet) typeTree.get(type.getName());
53.3327 + TreeSet compatibleTypes = (TreeSet) typeTree.get(type.getName());
53.3328 +
53.3329 + if (compatibleTypes == null) {
53.3330 + //compatibleTypes = new TreeSet(descendents);
53.3331 + compatibleTypes = new TreeSet(TypeExtensionSorter.getInstance());
53.3332 + compatibleTypes.addAll(descendents);
53.3333 + //typeTree.put(type.getName(), compatibleTypes);
53.3334 + typeTree.put(type.getName(), compatibleTypes);
53.3335 + } else {
53.3336 + compatibleTypes.addAll(descendents);
53.3337 + }
53.3338 + }
53.3339 +
53.3340 + XSTypeDefinition parentType = type.getBaseType();
53.3341 +
53.3342 + if (parentType != null
53.3343 + && type.getTypeCategory() == parentType.getTypeCategory()) {
53.3344 + /*String typeName = type.getName();
53.3345 + String parentTypeName = parentType.getName();
53.3346 + if ((typeName == null && parentTypeName != null)
53.3347 + || (typeName != null && parentTypeName == null)
53.3348 + || (typeName != null
53.3349 + && parentTypeName != null
53.3350 + && !type.getName().equals(parentType.getName())
53.3351 + && !parentType.getName().equals("anyType"))) {*/
53.3352 + if (type != parentType
53.3353 + && (parentType.getName() == null
53.3354 + || !parentType.getName().equals("anyType"))) {
53.3355 +
53.3356 +//TreeSet newDescendents=new TreeSet(descendents);
53.3357 + TreeSet newDescendents = new TreeSet(TypeExtensionSorter.getInstance());
53.3358 + newDescendents.addAll(descendents);
53.3359 +
53.3360 +//extension (we only add it to "newDescendants" because we don't want
53.3361 +//to have a type descendant to itself, but to consider it for the parent
53.3362 + if (type.getTypeCategory() == XSTypeDefinition.COMPLEX_TYPE) {
53.3363 + XSComplexTypeDefinition complexType =
53.3364 + (XSComplexTypeDefinition) type;
53.3365 + if (complexType.getDerivationMethod()
53.3366 + == XSConstants.DERIVATION_EXTENSION
53.3367 + && !complexType.getAbstract()
53.3368 + && !descendents.contains(type) //to be tested
53.3369 + //&& !descendents.contains(type.getName()) //to be tested
53.3370 + ) {
53.3371 +//newDescendents.add(type.getName());
53.3372 + newDescendents.add(type);
53.3373 + }
53.3374 + }
53.3375 +//note: extensions are impossible on simpleTypes !
53.3376 +
53.3377 + buildTypeTree(parentType, newDescendents);
53.3378 + }
53.3379 + }
53.3380 + }
53.3381 + }
53.3382 +
53.3383 + private void buildTypeTree(XSModel schema) {
53.3384 + // build the type tree for complex types
53.3385 + //
53.3386 + XSNamedMap types = schema.getComponents(XSConstants.TYPE_DEFINITION);
53.3387 + int nb = types.getLength();
53.3388 + for (int i = 0; i < nb; i++) {
53.3389 + XSTypeDefinition t = (XSTypeDefinition) types.item(i);
53.3390 + if (t.getTypeCategory() == XSTypeDefinition.COMPLEX_TYPE) {
53.3391 + XSComplexTypeDefinition type = (XSComplexTypeDefinition) t;
53.3392 + buildTypeTree(type, new TreeSet(TypeExtensionSorter.getInstance()));
53.3393 + }
53.3394 + }
53.3395 +
53.3396 + // build the type tree for simple types
53.3397 + for (int i = 0; i < nb; i++) {
53.3398 + XSTypeDefinition t = (XSTypeDefinition) types.item(i);
53.3399 + if (t.getTypeCategory() == XSTypeDefinition.SIMPLE_TYPE) {
53.3400 + XSSimpleTypeDefinition type = (XSSimpleTypeDefinition) t;
53.3401 + buildTypeTree(type, new TreeSet(TypeExtensionSorter.getInstance()));
53.3402 + }
53.3403 + }
53.3404 +
53.3405 + // print out type hierarchy for debugging purposes
53.3406 + if (LOGGER.isDebugEnabled()) {
53.3407 + Iterator keys = typeTree.keySet().iterator();
53.3408 + while (keys.hasNext()) {
53.3409 + String typeName = (String) keys.next();
53.3410 + TreeSet descendents = (TreeSet) typeTree.get(typeName);
53.3411 + LOGGER.debug(">>>> for " + typeName + " Descendants=\n ");
53.3412 + Iterator it = descendents.iterator();
53.3413 + while (it.hasNext()) {
53.3414 + XSTypeDefinition desc = (XSTypeDefinition) it.next();
53.3415 + LOGGER.debug(" " + desc.getName());
53.3416 + }
53.3417 + }
53.3418 + }
53.3419 + }
53.3420 +
53.3421 + private Element createFormControl(Document xForm,
53.3422 + String caption,
53.3423 + XSTypeDefinition controlType,
53.3424 + String bindId,
53.3425 + Element bindElement,
53.3426 + int minOccurs,
53.3427 + int maxOccurs,
53.3428 + String pathToRoot) {
53.3429 + // Select1 xform control to use:
53.3430 + // Will use one of the following: input, textarea, selectOne, selectBoolean, selectMany, range
53.3431 + // secret, output, button, do not apply
53.3432 + //
53.3433 + // select1: enumeration or keyref constrained value
53.3434 + // select: list
53.3435 + // range: union (? not sure about this)
53.3436 + // textarea : ???
53.3437 + // input: default
53.3438 + //
53.3439 + Element formControl = null;
53.3440 +
53.3441 + if (controlType.getTypeCategory() == XSTypeDefinition.SIMPLE_TYPE) {
53.3442 + XSSimpleTypeDefinition simpleType =
53.3443 + (XSSimpleTypeDefinition) controlType;
53.3444 + if (simpleType.getItemType() != null) //list
53.3445 + {
53.3446 + formControl =
53.3447 + createControlForListType(xForm,
53.3448 + simpleType,
53.3449 + caption,
53.3450 + bindElement);
53.3451 + } else { //other simple type
53.3452 + // need to check constraints to determine which form control to use
53.3453 + //
53.3454 + // use the selectOne control
53.3455 + //
53.3456 + //XSObjectList enumerationFacets = simpleType.getFacets(XSSimpleTypeDefinition.FACET_ENUMERATION);
53.3457 + //if(enumerationFacets.getLength()>0){
53.3458 + if (simpleType
53.3459 + .isDefinedFacet(XSSimpleTypeDefinition.FACET_ENUMERATION)) {
53.3460 + formControl =
53.3461 + createControlForEnumerationType(xForm,
53.3462 + simpleType,
53.3463 + caption,
53.3464 + bindElement);
53.3465 + }
53.3466 + /*if (enumerationFacets.hasMoreElements()) {
53.3467 + formControl = createControlForEnumerationType(xForm, (SimpleType)controlType, caption,
53.3468 + bindElement);
53.3469 + } */
53.3470 + }
53.3471 + } else if (
53.3472 + controlType.getTypeCategory() == XSTypeDefinition.COMPLEX_TYPE
53.3473 + && controlType.getName().equals("anyType")) {
53.3474 + formControl = createControlForAnyType(xForm, caption, controlType);
53.3475 + }
53.3476 +
53.3477 + if (formControl == null) {
53.3478 + // default situation - use an input control
53.3479 + //
53.3480 + formControl =
53.3481 + createControlForAtomicType(xForm,
53.3482 + caption,
53.3483 + (XSSimpleTypeDefinition) controlType);
53.3484 + }
53.3485 +
53.3486 + startFormControl(formControl, controlType);
53.3487 +// formControl.setAttributeNS(XFORMS_NS,
53.3488 +// getXFormsNSPrefix() + "bind",
53.3489 +// bindId);
53.3490 +
53.3491 + formControl.setAttribute("ref",
53.3492 + pathToRoot);
53.3493 +
53.3494 + formControl.setAttribute("incremental",
53.3495 + "true");
53.3496 +
53.3497 + addNameSpaces(formControl);
53.3498 + //put the label before
53.3499 + // no -> put in the "createControlFor..." methods
53.3500 +
53.3501 + /*Element captionElement=xForm.createElementNS(XFORMS_NS,getXFormsNSPrefix() + "label");
53.3502 + this.setXFormsId(captionElement);
53.3503 + captionElement.appendChild(xForm.createTextNode(caption));
53.3504 + if(formControl.hasChildNodes())
53.3505 + {
53.3506 + Node first=formControl.getFirstChild();
53.3507 + captionElement = (Element) formControl.insertBefore(captionElement, first);
53.3508 + }
53.3509 + else
53.3510 + captionElement = (Element) formControl.appendChild(captionElement); */
53.3511 +
53.3512 + // TODO: Enhance alert statement based on facet restrictions.
53.3513 + // TODO: Enhance to support minOccurs > 1 and maxOccurs > 1.
53.3514 + // TODO: Add i18n/l10n suppport to this - use java MessageFormatter...
53.3515 + //
53.3516 + // e.g. Please provide a valid value for 'Address'. 'Address' is a mandatory decimal field.
53.3517 + //
53.3518 + Element alertElement =
53.3519 + (Element) formControl.appendChild(xForm.createElementNS(XFORMS_NS,
53.3520 + getXFormsNSPrefix() + "alert"));
53.3521 + this.setXFormsId(alertElement);
53.3522 +
53.3523 + StringBuffer alert =
53.3524 + new StringBuffer("Please provide a valid value for '" + caption + "'.");
53.3525 +
53.3526 + Element enveloppe = xForm.getDocumentElement();
53.3527 +
53.3528 + if (minOccurs != 0) {
53.3529 + alert.append(" '"
53.3530 + + caption
53.3531 + + "' is a required '"
53.3532 + + createCaption(this.getXFormsTypeName(enveloppe, controlType))
53.3533 + + "' value.");
53.3534 + } else {
53.3535 + alert.append(" '"
53.3536 + + caption
53.3537 + + "' is an optional '"
53.3538 + + createCaption(this.getXFormsTypeName(enveloppe, controlType))
53.3539 + + "' value.");
53.3540 + }
53.3541 +
53.3542 + alertElement.appendChild(xForm.createTextNode(alert.toString()));
53.3543 +
53.3544 + return formControl;
53.3545 + }
53.3546 +
53.3547 + /**
53.3548 + * used to get the type name that will be used in the XForms document
53.3549 + *
53.3550 + * @param context the element which will serve as context for namespaces
53.3551 + * @param controlType the type from which we want the name
53.3552 + * @return the complete type name (with namespace prefix) of the type in the XForms doc
53.3553 + */
53.3554 + protected String getXFormsTypeName(Element context, XSTypeDefinition controlType) {
53.3555 + String result = null;
53.3556 +
53.3557 + String typeName = controlType.getName();
53.3558 + String typeNS = controlType.getNamespace();
53.3559 +
53.3560 + //if we use XMLSchema types:
53.3561 + //first check if it is a simple type named in the XMLSchema
53.3562 + if (_useSchemaTypes
53.3563 + && controlType.getTypeCategory() == XSTypeDefinition.SIMPLE_TYPE
53.3564 + && typeName != null && !typeName.equals("")
53.3565 + && schema.getTypeDefinition(typeName, typeNS) != null) { //type is globally defined
53.3566 + //use schema type
53.3567 +
53.3568 + //local type name
53.3569 + String localTypeName = typeName;
53.3570 + int index = typeName.indexOf(":");
53.3571 + if (index > -1 && typeName.length() > index)
53.3572 + localTypeName = typeName.substring(index + 1);
53.3573 +
53.3574 + //namespace prefix in this document
53.3575 + String prefix = NamespaceResolver.getPrefix(context, typeNS);
53.3576 +
53.3577 + //completeTypeName = new prefix + local name
53.3578 + result = localTypeName;
53.3579 + if (prefix != null && !prefix.equals(""))
53.3580 + result = prefix + ":" + localTypeName;
53.3581 +
53.3582 + if (LOGGER.isDebugEnabled())
53.3583 + LOGGER.debug("getXFormsTypeName: typeName=" + typeName + ", typeNS=" + typeNS + ", result=" + result);
53.3584 + } else { //use built in type
53.3585 + result = this.getDataTypeName(getBuiltInType(controlType));
53.3586 + }
53.3587 + return result;
53.3588 + }
53.3589 +
53.3590 + private Document createFormTemplate(String formId)
53.3591 + throws IOException, ParserConfigurationException {
53.3592 + return createFormTemplate(formId,
53.3593 + "Form " + formId,
53.3594 + getProperty(CSS_STYLE_PROP, DEFAULT_CSS_STYLE_PROP));
53.3595 + }
53.3596 +
53.3597 + private Document createFormTemplate(String formId,
53.3598 + String formName,
53.3599 + String stylesheet)
53.3600 + throws ParserConfigurationException {
53.3601 + Document xForm = documentBuilder.newDocument();
53.3602 +
53.3603 + Element envelopeElement = _wrapper.createEnvelope(xForm);
53.3604 +
53.3605 + // set required namespace attributes
53.3606 + envelopeElement.setAttributeNS(XMLNS_NAMESPACE_URI,
53.3607 + "xmlns:"
53.3608 + + getChibaNSPrefix().substring(0,
53.3609 + getChibaNSPrefix().length() - 1),
53.3610 + CHIBA_NS);
53.3611 + envelopeElement.setAttributeNS(XMLNS_NAMESPACE_URI,
53.3612 + "xmlns:"
53.3613 + + getXFormsNSPrefix().substring(0,
53.3614 + getXFormsNSPrefix().length() - 1),
53.3615 + XFORMS_NS);
53.3616 + envelopeElement.setAttributeNS(XMLNS_NAMESPACE_URI,
53.3617 + "xmlns:"
53.3618 + + getXLinkNSPrefix().substring(0,
53.3619 + getXLinkNSPrefix().length() - 1),
53.3620 + XLINK_NS);
53.3621 +//XMLEvent
53.3622 + envelopeElement.setAttributeNS(XMLNS_NAMESPACE_URI,
53.3623 + "xmlns:" +
53.3624 + xmleventsNSPrefix.substring(0, xmleventsNSPrefix.length() - 1),
53.3625 + XMLEVENTS_NS);
53.3626 +//XML Schema Instance
53.3627 + envelopeElement.setAttributeNS(XMLNS_NAMESPACE_URI,
53.3628 + "xmlns:" +
53.3629 + xmlSchemaInstancePrefix.substring(0, xmlSchemaInstancePrefix.length() - 1),
53.3630 + XMLSCHEMA_INSTANCE_NAMESPACE_URI);
53.3631 +//base
53.3632 + if (_base != null && !_base.equals("")) {
53.3633 + envelopeElement.setAttributeNS(XML_NAMESPACE_URI,
53.3634 + "xml:base",
53.3635 + _base);
53.3636 + }
53.3637 +
53.3638 + //model element
53.3639 + Element modelElement =
53.3640 + xForm.createElementNS(XFORMS_NS, getXFormsNSPrefix() + "model");
53.3641 + this.setXFormsId(modelElement);
53.3642 + Element modelWrapper = _wrapper.createModelWrapper(modelElement);
53.3643 + envelopeElement.appendChild(modelWrapper);
53.3644 +
53.3645 + //form control wrapper -> created by wrapper
53.3646 + //Element formWrapper = xForm.createElement("body");
53.3647 + //envelopeElement.appendChild(formWrapper);
53.3648 + Element formWrapper = _wrapper.createFormWrapper(envelopeElement);
53.3649 +
53.3650 + return xForm;
53.3651 + }
53.3652 +
53.3653 + private Element createGroup(Document xForm,
53.3654 + Element modelSection,
53.3655 + Element formSection,
53.3656 + XSElementDeclaration owner) {
53.3657 + // add a group node and recurse
53.3658 + //
53.3659 + Element groupElement =
53.3660 + xForm.createElementNS(XFORMS_NS, getXFormsNSPrefix() + "group");
53.3661 + groupElement = startFormGroup(groupElement, owner);
53.3662 +
53.3663 + if (groupElement != null) {
53.3664 + this.setXFormsId(groupElement);
53.3665 +
53.3666 + Element controlsWrapper =
53.3667 + _wrapper.createControlsWrapper(groupElement);
53.3668 +
53.3669 + //groupElement = (Element) formSection.appendChild(groupElement);
53.3670 + formSection.appendChild(controlsWrapper);
53.3671 +
53.3672 + Element captionElement =
53.3673 + (Element) groupElement.appendChild(xForm.createElementNS(XFORMS_NS,
53.3674 + getXFormsNSPrefix() + "label"));
53.3675 + this.setXFormsId(captionElement);
53.3676 + captionElement.appendChild(xForm.createTextNode(createCaption(owner)));
53.3677 +
53.3678 + //no hint in groups
53.3679 +
53.3680 + /*Element hint = createHint(xForm,owner);
53.3681 + if (hint != null) {
53.3682 + groupElement.appendChild(hint);
53.3683 + }*/
53.3684 + } else {
53.3685 + groupElement = modelSection;
53.3686 + }
53.3687 +
53.3688 + return groupElement;
53.3689 + }
53.3690 +
53.3691 + /**
53.3692 + * Get a fully qualified name for this element, and eventually declares a new prefix for the namespace if
53.3693 + * it was not declared before
53.3694 + *
53.3695 + * @param element
53.3696 + * @param xForm
53.3697 + * @return
53.3698 + */
53.3699 + private String getElementName(XSElementDeclaration element, Document xForm) {
53.3700 + String elementName = element.getName();
53.3701 + String namespace = element.getNamespace();
53.3702 + if (namespace != null && !namespace.equals("")) {
53.3703 + String prefix;
53.3704 + if ((prefix = (String) namespacePrefixes.get(namespace)) == null) {
53.3705 + String basePrefix = (namespace.substring(namespace.lastIndexOf('/', namespace.length()-2)+1));
53.3706 + int i=1;
53.3707 + prefix = basePrefix;
53.3708 + while (namespacePrefixes.containsValue(prefix)) {
53.3709 + prefix = basePrefix + (i++);
53.3710 + }
53.3711 + namespacePrefixes.put(namespace, prefix);
53.3712 + Element envelope = xForm.getDocumentElement();
53.3713 + envelope.setAttributeNS(XMLNS_NAMESPACE_URI, "xmlns:"+prefix, namespace);
53.3714 + }
53.3715 + elementName = prefix + ":" + elementName;
53.3716 + }
53.3717 + return elementName;
53.3718 + }
53.3719 +
53.3720 + private void addNameSpaces(Element element) {
53.3721 + for (Iterator it = namespacePrefixes.entrySet().iterator(); it.hasNext();) {
53.3722 + Map.Entry entry = (Entry) it.next();
53.3723 + element.setAttributeNS(XMLNS_NAMESPACE_URI, "xmlns:"+ entry.getValue(), (String ) entry.getKey());
53.3724 + }
53.3725 + }
53.3726 +}
54.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
54.2 +++ b/enterprise/openesbaddons/workflow/project/chiba_src/org/chiba/tools/schemabuilder/BaseSchemaFormBuilder.java Thu Apr 26 02:33:27 2007 +0000
54.3 @@ -0,0 +1,712 @@
54.4 +// Copyright 2006 Chibacon
54.5 +
54.6 +/*
54.7 + *
54.8 + * Artistic License
54.9 + *
54.10 + * Preamble
54.11 + *
54.12 + * The intent of this document is to state the conditions under which a Package may be copied, such that
54.13 + * the Copyright Holder maintains some semblance of artistic control over the development of the
54.14 + * package, while giving the users of the package the right to use and distribute the Package in a
54.15 + * more-or-less customary fashion, plus the right to make reasonable modifications.
54.16 + *
54.17 + * Definitions:
54.18 + *
54.19 + * "Package" refers to the collection of files distributed by the Copyright Holder, and derivatives
54.20 + * of that collection of files created through textual modification.
54.21 + *
54.22 + * "Standard Version" refers to such a Package if it has not been modified, or has been modified
54.23 + * in accordance with the wishes of the Copyright Holder.
54.24 + *
54.25 + * "Copyright Holder" is whoever is named in the copyright or copyrights for the package.
54.26 + *
54.27 + * "You" is you, if you're thinking about copying or distributing this Package.
54.28 + *
54.29 + * "Reasonable copying fee" is whatever you can justify on the basis of media cost, duplication
54.30 + * charges, time of people involved, and so on. (You will not be required to justify it to the
54.31 + * Copyright Holder, but only to the computing community at large as a market that must bear the
54.32 + * fee.)
54.33 + *
54.34 + * "Freely Available" means that no fee is charged for the item itself, though there may be fees
54.35 + * involved in handling the item. It also means that recipients of the item may redistribute it under
54.36 + * the same conditions they received it.
54.37 + *
54.38 + * 1. You may make and give away verbatim copies of the source form of the Standard Version of this
54.39 + * Package without restriction, provided that you duplicate all of the original copyright notices and
54.40 + * associated disclaimers.
54.41 + *
54.42 + * 2. You may apply bug fixes, portability fixes and other modifications derived from the Public Domain
54.43 + * or from the Copyright Holder. A Package modified in such a way shall still be considered the
54.44 + * Standard Version.
54.45 + *
54.46 + * 3. You may otherwise modify your copy of this Package in any way, provided that you insert a
54.47 + * prominent notice in each changed file stating how and when you changed that file, and provided that
54.48 + * you do at least ONE of the following:
54.49 + *
54.50 + * a) place your modifications in the Public Domain or otherwise make them Freely
54.51 + * Available, such as by posting said modifications to Usenet or an equivalent medium, or
54.52 + * placing the modifications on a major archive site such as ftp.uu.net, or by allowing the
54.53 + * Copyright Holder to include your modifications in the Standard Version of the Package.
54.54 + *
54.55 + * b) use the modified Package only within your corporation or organization.
54.56 + *
54.57 + * c) rename any non-standard executables so the names do not conflict with standard
54.58 + * executables, which must also be provided, and provide a separate manual page for each
54.59 + * non-standard executable that clearly documents how it differs from the Standard
54.60 + * Version.
54.61 + *
54.62 + * d) make other distribution arrangements with the Copyright Holder.
54.63 + *
54.64 + * 4. You may distribute the programs of this Package in object code or executable form, provided that
54.65 + * you do at least ONE of the following:
54.66 + *
54.67 + * a) distribute a Standard Version of the executables and library files, together with
54.68 + * instructions (in the manual page or equivalent) on where to get the Standard Version.
54.69 + *
54.70 + * b) accompany the distribution with the machine-readable source of the Package with
54.71 + * your modifications.
54.72 + *
54.73 + * c) accompany any non-standard executables with their corresponding Standard Version
54.74 + * executables, giving the non-standard executables non-standard names, and clearly
54.75 + * documenting the differences in manual pages (or equivalent), together with instructions
54.76 + * on where to get the Standard Version.
54.77 + *
54.78 + * d) make other distribution arrangements with the Copyright Holder.
54.79 + *
54.80 + * 5. You may charge a reasonable copying fee for any distribution of this Package. You may charge
54.81 + * any fee you choose for support of this Package. You may not charge a fee for this Package itself.
54.82 + * However, you may distribute this Package in aggxmlregate with other (possibly commercial) programs as
54.83 + * part of a larger (possibly commercial) software distribution provided that you do not advertise this
54.84 + * Package as a product of your own.
54.85 + *
54.86 + * 6. The scripts and library files supplied as input to or produced as output from the programs of this
54.87 + * Package do not automatically fall under the copyright of this Package, but belong to whomever
54.88 + * generated them, and may be sold commercially, and may be aggregated with this Package.
54.89 + *
54.90 + * 7. C or perl subroutines supplied by you and linked into this Package shall not be considered part of
54.91 + * this Package.
54.92 + *
54.93 + * 8. The name of the Copyright Holder may not be used to endorse or promote products derived from
54.94 + * this software without specific prior written permission.
54.95 + *
54.96 + * 9. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
54.97 + * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
54.98 + * MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
54.99 + *
54.100 + */
54.101 +package org.chiba.tools.schemabuilder;
54.102 +
54.103 +import com.sun.org.apache.xerces.internal.xs.*;
54.104 +import org.w3c.dom.Document;
54.105 +import org.w3c.dom.Element;
54.106 +import org.w3c.dom.Text;
54.107 +
54.108 +import javax.xml.transform.Source;
54.109 +import java.util.Vector;
54.110 +
54.111 +/*
54.112 + * Search for TODO for things remaining to-do in this implementation.
54.113 + *
54.114 + * TODO: i18n/l10n of messages, hints, captions. Possibly leverage org.chiba.i18n classes.
54.115 + * TODO: When Chiba supports itemset, use schema keyref and key constraints for validation.
54.116 + * TODO: Add support for default and fixed values.
54.117 + * TODO: Add support for use=prohibited.
54.118 + */
54.119 +
54.120 +/**
54.121 + * A concrete base implementation of the SchemaFormBuilder interface allowing
54.122 + * an XForm to be automatically generated for an XML Schema definition.
54.123 + *
54.124 + * @author Brian Dueck
54.125 + * @version $Id$
54.126 + * @deprecated
54.127 + */
54.128 +public class BaseSchemaFormBuilder
54.129 + extends AbstractSchemaFormBuilder
54.130 + implements SchemaFormBuilder {
54.131 + /**
54.132 + * Creates a new instance of BaseSchemaForBuilder
54.133 + */
54.134 + public BaseSchemaFormBuilder(String rootTagName) {
54.135 + super(rootTagName);
54.136 + }
54.137 +
54.138 + public BaseSchemaFormBuilder(String rootTagName, boolean addSubmit) {
54.139 + super(rootTagName, addSubmit);
54.140 + }
54.141 +
54.142 +
54.143 + /**
54.144 + * Creates a new BaseSchemaFormBuilder object.
54.145 + *
54.146 + * @param rootTagName __UNDOCUMENTED__
54.147 + * @param instanceSource __UNDOCUMENTED__
54.148 + * @param action __UNDOCUMENTED__
54.149 + * @param submitMethod __UNDOCUMENTED__
54.150 + * @param wrapper __UNDOCUMENTED__
54.151 + * @param stylesheet __UNDOCUMENTED__
54.152 + */
54.153 + public BaseSchemaFormBuilder(String rootTagName,
54.154 + Source instanceSource,
54.155 + String action,
54.156 + String submitMethod,
54.157 + WrapperElementsBuilder wrapper,
54.158 + String stylesheet,
54.159 + String base,
54.160 + boolean userSchemaTypes,
54.161 + boolean addSubmit) {
54.162 + super(rootTagName,
54.163 + instanceSource,
54.164 + action,
54.165 + submitMethod,
54.166 + wrapper,
54.167 + stylesheet,
54.168 + base,
54.169 + userSchemaTypes,
54.170 + addSubmit);
54.171 + }
54.172 +
54.173 + /**
54.174 + * Creates a new BaseSchemaFormBuilder object.
54.175 + *
54.176 + * @param rootTagName __UNDOCUMENTED__
54.177 + * @param instanceHref __UNDOCUMENTED__
54.178 + * @param action __UNDOCUMENTED__
54.179 + * @param submitMethod __UNDOCUMENTED__
54.180 + * @param wrapper __UNDOCUMENTED__
54.181 + * @param stylesheet __UNDOCUMENTED__
54.182 + */
54.183 + public BaseSchemaFormBuilder(String rootTagName,
54.184 + String instanceHref,
54.185 + String action,
54.186 + String submitMethod,
54.187 + WrapperElementsBuilder wrapper,
54.188 + String stylesheet,
54.189 + String base,
54.190 + boolean userSchemaTypes,
54.191 + boolean addSubmit) {
54.192 + super(rootTagName,
54.193 + instanceHref,
54.194 + action,
54.195 + submitMethod,
54.196 + wrapper,
54.197 + stylesheet,
54.198 + base,
54.199 + userSchemaTypes,
54.200 + addSubmit);
54.201 + }
54.202 +
54.203 + /**
54.204 + * __UNDOCUMENTED__
54.205 + *
54.206 + * @param text __UNDOCUMENTED__
54.207 + * @return __UNDOCUMENTED__
54.208 + */
54.209 + public String createCaption(String text) {
54.210 + return StringUtil.capitalizeIdentifier(text);
54.211 + }
54.212 +
54.213 + /**
54.214 + * __UNDOCUMENTED__
54.215 + *
54.216 + * @param attribute __UNDOCUMENTED__
54.217 + * @return __UNDOCUMENTED__
54.218 + */
54.219 + public String createCaption(XSAttributeDeclaration attribute) {
54.220 + // TODO: Improve i18n/l10n of caption - may have to use
54.221 + // a custom <appinfo> element in the XML Schema to do this.
54.222 + //
54.223 + return createCaption(attribute.getName());
54.224 + }
54.225 +
54.226 + public String createCaption(XSAttributeUse attribute) {
54.227 + // TODO: Improve i18n/l10n of caption - may have to use
54.228 + // a custom <appinfo> element in the XML Schema to do this.
54.229 + //
54.230 + return createCaption(attribute.getAttrDeclaration().getName());
54.231 + }
54.232 +
54.233 + /**
54.234 + * __UNDOCUMENTED__
54.235 + *
54.236 + * @param element __UNDOCUMENTED__
54.237 + * @return __UNDOCUMENTED__
54.238 + */
54.239 + public String createCaption(XSElementDeclaration element) {
54.240 + // TODO: Improve i18n/l10n of caption - may have to use
54.241 + // a custom <appinfo> element in the XML Schema to do this.
54.242 + //
54.243 + return createCaption(element.getName());
54.244 + }
54.245 +
54.246 + /**
54.247 + * __UNDOCUMENTED__
54.248 + *
54.249 + * @param element __UNDOCUMENTED__
54.250 + * @return __UNDOCUMENTED__
54.251 + */
54.252 + public String createCaption(XSObject element) {
54.253 + // TODO: Improve i18n/l10n of caption - may have to use
54.254 + // a custom <appinfo> element in the XML Schema to do this.
54.255 + //
54.256 + if (element instanceof XSElementDeclaration) {
54.257 + return createCaption(((XSElementDeclaration) element).getName());
54.258 + } else if (element instanceof XSAttributeDeclaration) {
54.259 + return createCaption(((XSAttributeDeclaration) element).getName());
54.260 + } else if (element instanceof XSAttributeUse) {
54.261 + return createCaption(((XSAttributeUse) element).getAttrDeclaration().getName());
54.262 + } else
54.263 + LOGGER.warn("WARNING: createCaption: element is not an attribute nor an element: "
54.264 + + element.getClass().getName());
54.265 +
54.266 + return null;
54.267 + }
54.268 +
54.269 + /**
54.270 + * __UNDOCUMENTED__
54.271 + *
54.272 + * @param xForm __UNDOCUMENTED__
54.273 + * @param caption __UNDOCUMENTED__
54.274 + * @param controlType __UNDOCUMENTED__
54.275 + * @return __UNDOCUMENTED__
54.276 + */
54.277 + public Element createControlForAnyType(Document xForm,
54.278 + String caption,
54.279 + XSTypeDefinition controlType) {
54.280 + Element control =
54.281 + xForm.createElementNS(XFORMS_NS, getXFormsNSPrefix() + "textarea");
54.282 + this.setXFormsId(control);
54.283 + control.setAttributeNS(CHIBA_NS, getChibaNSPrefix() + "height", "3");
54.284 +
54.285 + //label
54.286 + Element captionElement =
54.287 + (Element) control.appendChild(xForm.createElementNS(XFORMS_NS,
54.288 + getXFormsNSPrefix() + "label"));
54.289 + this.setXFormsId(captionElement);
54.290 + captionElement.appendChild(xForm.createTextNode(caption));
54.291 +
54.292 + return control;
54.293 + }
54.294 +
54.295 + /**
54.296 + * __UNDOCUMENTED__
54.297 + *
54.298 + * @param xForm __UNDOCUMENTED__
54.299 + * @param caption __UNDOCUMENTED__
54.300 + * @param controlType __UNDOCUMENTED__
54.301 + * @return __UNDOCUMENTED__
54.302 + */
54.303 + public Element createControlForAtomicType(Document xForm,
54.304 + String caption,
54.305 + XSSimpleTypeDefinition controlType) {
54.306 + Element control;
54.307 +
54.308 + //remove while select1 do not work correctly in repeats
54.309 + if ((controlType.getName() != null)
54.310 + && controlType.getName().equals("boolean")) {
54.311 + control =
54.312 + xForm.createElementNS(XFORMS_NS,
54.313 + getXFormsNSPrefix() + "select1");
54.314 + control.setAttributeNS(XFORMS_NS,
54.315 + getXFormsNSPrefix() + "appearance",
54.316 + "full");
54.317 + this.setXFormsId(control);
54.318 +
54.319 + Element item_true =
54.320 + xForm.createElementNS(XFORMS_NS, getXFormsNSPrefix() + "item");
54.321 + this.setXFormsId(item_true);
54.322 + Element label_true =
54.323 + xForm.createElementNS(XFORMS_NS, getXFormsNSPrefix() + "label");
54.324 + this.setXFormsId(label_true);
54.325 + Text label_true_text = xForm.createTextNode("true");
54.326 + label_true.appendChild(label_true_text);
54.327 + item_true.appendChild(label_true);
54.328 +
54.329 + Element value_true =
54.330 + xForm.createElementNS(XFORMS_NS, getXFormsNSPrefix() + "value");
54.331 + this.setXFormsId(value_true);
54.332 + Text value_true_text = xForm.createTextNode("true");
54.333 + value_true.appendChild(value_true_text);
54.334 + item_true.appendChild(value_true);
54.335 + control.appendChild(item_true);
54.336 +
54.337 + Element item_false =
54.338 + xForm.createElementNS(XFORMS_NS, getXFormsNSPrefix() + "item");
54.339 + this.setXFormsId(item_false);
54.340 + Element label_false =
54.341 + xForm.createElementNS(XFORMS_NS, getXFormsNSPrefix() + "label");
54.342 + this.setXFormsId(label_false);
54.343 + Text label_false_text = xForm.createTextNode("false");
54.344 + label_false.appendChild(label_false_text);
54.345 + item_false.appendChild(label_false);
54.346 +
54.347 + Element value_false =
54.348 + xForm.createElementNS(XFORMS_NS, getXFormsNSPrefix() + "value");
54.349 + this.setXFormsId(value_false);
54.350 + Text value_false_text = xForm.createTextNode("false");
54.351 + value_false.appendChild(value_false_text);
54.352 + item_false.appendChild(value_false);
54.353 + control.appendChild(item_false);
54.354 + } else {
54.355 + control =
54.356 + xForm.createElementNS(XFORMS_NS, getXFormsNSPrefix() + "input");
54.357 + this.setXFormsId(control);
54.358 + }
54.359 +
54.360 + //label
54.361 + Element captionElement =
54.362 + (Element) control.appendChild(xForm.createElementNS(XFORMS_NS,
54.363 + getXFormsNSPrefix() + "label"));
54.364 + this.setXFormsId(captionElement);
54.365 + captionElement.appendChild(xForm.createTextNode(caption));
54.366 +
54.367 + return control;
54.368 + }
54.369 +
54.370 + /**
54.371 + * __UNDOCUMENTED__
54.372 + *
54.373 + * @param xForm __UNDOCUMENTED__
54.374 + * @param controlType __UNDOCUMENTED__
54.375 + * @param caption __UNDOCUMENTED__
54.376 + * @param bindElement __UNDOCUMENTED__
54.377 + * @return __UNDOCUMENTED__
54.378 + */
54.379 + public Element createControlForEnumerationType(Document xForm,
54.380 + XSSimpleTypeDefinition controlType,
54.381 + String caption,
54.382 + Element bindElement) {
54.383 + // TODO: Figure out an intelligent or user determined way to decide between
54.384 + // selectUI style (listbox, menu, combobox, radio) (radio and listbox best apply)
54.385 + // Possibly look for special appInfo section in the schema and if not present default to comboBox...
54.386 + //
54.387 + // For now, use radio if enumValues < DEFAULT_LONG_LIST_MAX_SIZE otherwise use combobox
54.388 + //
54.389 + StringList enumFacets = controlType.getLexicalEnumeration();
54.390 + int nbFacets = enumFacets.getLength();
54.391 + if (nbFacets > 0) {
54.392 + Vector enumValues = new Vector();
54.393 +
54.394 + Element control =
54.395 + xForm.createElementNS(XFORMS_NS,
54.396 + getXFormsNSPrefix() + "select1");
54.397 + this.setXFormsId(control);
54.398 +
54.399 + //label
54.400 + Element captionElement1 =
54.401 + (Element) control.appendChild(xForm.createElementNS(XFORMS_NS,
54.402 + getXFormsNSPrefix() + "label"));
54.403 + this.setXFormsId(captionElement1);
54.404 + captionElement1.appendChild(xForm.createTextNode(caption));
54.405 +
54.406 + Element choices =
54.407 + xForm.createElementNS(XFORMS_NS,
54.408 + getXFormsNSPrefix() + "choices");
54.409 + this.setXFormsId(choices);
54.410 +
54.411 + for (int i = 0; i < nbFacets; i++) {
54.412 + String facet = enumFacets.item(i);
54.413 + enumValues.add(facet);
54.414 + }
54.415 +
54.416 + if (nbFacets
54.417 + < Long.parseLong(getProperty(SELECTONE_LONG_LIST_SIZE_PROP))) {
54.418 + control.setAttributeNS(XFORMS_NS,
54.419 + getXFormsNSPrefix() + "appearance",
54.420 + getProperty(SELECTONE_UI_CONTROL_SHORT_PROP));
54.421 + } else {
54.422 + control.setAttributeNS(XFORMS_NS,
54.423 + getXFormsNSPrefix() + "appearance",
54.424 + getProperty(SELECTONE_UI_CONTROL_LONG_PROP));
54.425 +
54.426 + // add the "Please select..." instruction item for the combobox
54.427 + // and set the isValid attribute on the bind element to check for the "Please select..."
54.428 + // item to indicate that is not a valid value
54.429 + //
54.430 + {
54.431 + String pleaseSelect = "[Select1 " + caption + "]";
54.432 + Element item =
54.433 + xForm.createElementNS(XFORMS_NS,
54.434 + getXFormsNSPrefix() + "item");
54.435 + this.setXFormsId(item);
54.436 + choices.appendChild(item);
54.437 +
54.438 + Element captionElement =
54.439 + xForm.createElementNS(XFORMS_NS,
54.440 + getXFormsNSPrefix() + "label");
54.441 + this.setXFormsId(captionElement);
54.442 + item.appendChild(captionElement);
54.443 + captionElement.appendChild(xForm.createTextNode(pleaseSelect));
54.444 +
54.445 + Element value =
54.446 + xForm.createElementNS(XFORMS_NS,
54.447 + getXFormsNSPrefix() + "value");
54.448 + this.setXFormsId(value);
54.449 + item.appendChild(value);
54.450 + value.appendChild(xForm.createTextNode(pleaseSelect));
54.451 +
54.452 + // not(purchaseOrder/state = '[Choose State]')
54.453 + //String isValidExpr = "not(" + bindElement.getAttributeNS(XFORMS_NS,"nodeset") + " = '" + pleaseSelect + "')";
54.454 + // ->no, not(. = '[Choose State]')
54.455 + String isValidExpr = "not( . = '" + pleaseSelect + "')";
54.456 +
54.457 + //check if there was a constraint
54.458 + String constraint =
54.459 + bindElement.getAttributeNS(XFORMS_NS, "constraint");
54.460 +
54.461 + if ((constraint != null) && !constraint.equals("")) {
54.462 + constraint = constraint + " and " + isValidExpr;
54.463 + } else {
54.464 + constraint = isValidExpr;
54.465 + }
54.466 +
54.467 + bindElement.setAttributeNS(XFORMS_NS,
54.468 + getXFormsNSPrefix() + "constraint",
54.469 + constraint);
54.470 + }
54.471 + }
54.472 +
54.473 + control.appendChild(choices);
54.474 +
54.475 + addChoicesForSelectControl(xForm, choices, enumValues);
54.476 +
54.477 + return control;
54.478 + } else {
54.479 + return null;
54.480 + }
54.481 + }
54.482 +
54.483 + /**
54.484 + * __UNDOCUMENTED__
54.485 + *
54.486 + * @param xForm __UNDOCUMENTED__
54.487 + * @param listType __UNDOCUMENTED__
54.488 + * @param caption __UNDOCUMENTED__
54.489 + * @param bindElement __UNDOCUMENTED__
54.490 + * @return __UNDOCUMENTED__
54.491 + */
54.492 + public Element createControlForListType(Document xForm,
54.493 + XSSimpleTypeDefinition listType,
54.494 + String caption,
54.495 + Element bindElement) {
54.496 + XSSimpleTypeDefinition controlType = listType.getItemType();
54.497 +
54.498 + StringList enumFacets = controlType.getLexicalEnumeration();
54.499 + int nbFacets = enumFacets.getLength();
54.500 + if (nbFacets > 0) {
54.501 + Element control =
54.502 + xForm.createElementNS(XFORMS_NS,
54.503 + getXFormsNSPrefix() + "select");
54.504 + this.setXFormsId(control);
54.505 +
54.506 + //label
54.507 + Element captionElement =
54.508 + (Element) control.appendChild(xForm.createElementNS(XFORMS_NS,
54.509 + getXFormsNSPrefix() + "label"));
54.510 + this.setXFormsId(captionElement);
54.511 + captionElement.appendChild(xForm.createTextNode(caption));
54.512 +
54.513 + Vector enumValues = new Vector();
54.514 + for (int i = 0; i < nbFacets; i++) {
54.515 + String facet = enumFacets.item(i);
54.516 + enumValues.add(facet);
54.517 + }
54.518 +
54.519 + // TODO: Figure out an intelligent or user determined way to decide between
54.520 + // selectUI style (listbox, menu, combobox, radio) (radio and listbox best apply)
54.521 + // Possibly look for special appInfo section in the schema and if not present default to checkBox...
54.522 + //
54.523 + // For now, use checkbox if there are < DEFAULT_LONG_LIST_MAX_SIZE items, otherwise use long control
54.524 + //
54.525 + if (enumValues.size()
54.526 + < Long.parseLong(getProperty(SELECTMANY_LONG_LIST_SIZE_PROP))) {
54.527 + control.setAttributeNS(XFORMS_NS,
54.528 + getXFormsNSPrefix() + "appearance",
54.529 + getProperty(SELECTMANY_UI_CONTROL_SHORT_PROP));
54.530 + } else {
54.531 + control.setAttributeNS(XFORMS_NS,
54.532 + getXFormsNSPrefix() + "appearance",
54.533 + getProperty(SELECTMANY_UI_CONTROL_LONG_PROP));
54.534 + }
54.535 +
54.536 + Element choices =
54.537 + xForm.createElementNS(XFORMS_NS,
54.538 + getXFormsNSPrefix() + "choices");
54.539 + this.setXFormsId(choices);
54.540 + control.appendChild(choices);
54.541 +
54.542 + addChoicesForSelectControl(xForm, choices, enumValues);
54.543 +
54.544 + return control;
54.545 + } else {
54.546 + return null;
54.547 + }
54.548 + }
54.549 +
54.550 + /**
54.551 + * __UNDOCUMENTED__
54.552 + *
54.553 + * @param xForm __UNDOCUMENTED__
54.554 + * @param node __UNDOCUMENTED__
54.555 + * @return __UNDOCUMENTED__
54.556 + */
54.557 + public Element createHint(Document xForm, XSObject node) {
54.558 + XSAnnotation annotation = null;
54.559 + if (node instanceof XSElementDeclaration)
54.560 + annotation = ((XSElementDeclaration) node).getAnnotation();
54.561 + else if (node instanceof XSAttributeDeclaration)
54.562 + annotation = ((XSAttributeDeclaration) node).getAnnotation();
54.563 + else if (node instanceof XSAttributeUse)
54.564 + annotation =
54.565 + ((XSAttributeUse) node).getAttrDeclaration().getAnnotation();
54.566 +
54.567 + if (annotation != null)
54.568 + return addHintFromDocumentation(xForm, annotation);
54.569 + else
54.570 + return null;
54.571 + }
54.572 +
54.573 + /**
54.574 + * __UNDOCUMENTED__
54.575 + *
54.576 + * @param bindElement __UNDOCUMENTED__
54.577 + */
54.578 + public void endBindElement(Element bindElement) {
54.579 + return;
54.580 + }
54.581 +
54.582 + /**
54.583 + * __UNDOCUMENTED__
54.584 + *
54.585 + * @param controlElement __UNDOCUMENTED__
54.586 + * @param controlType __UNDOCUMENTED__
54.587 + */
54.588 + public void endFormControl(Element controlElement,
54.589 + XSTypeDefinition controlType,
54.590 + int minOccurs,
54.591 + int maxOccurs) {
54.592 + return;
54.593 + }
54.594 +
54.595 + /**
54.596 + * __UNDOCUMENTED__
54.597 + *
54.598 + * @param groupElement __UNDOCUMENTED__
54.599 + */
54.600 + public void endFormGroup(Element groupElement,
54.601 + XSTypeDefinition controlType,
54.602 + int minOccurs,
54.603 + int maxOccurs,
54.604 + Element modelSection) {
54.605 + return;
54.606 + }
54.607 +
54.608 + /**
54.609 + * __UNDOCUMENTED__
54.610 + *
54.611 + * @param bindElement __UNDOCUMENTED__
54.612 + * @param controlType __UNDOCUMENTED__
54.613 + * @param minOccurs __UNDOCUMENTED__
54.614 + * @param maxOccurs __UNDOCUMENTED__
54.615 + * @return __UNDOCUMENTED__
54.616 + */
54.617 + public Element startBindElement(Element bindElement,
54.618 + XSTypeDefinition controlType,
54.619 + int minOccurs,
54.620 + int maxOccurs) {
54.621 + // START WORKAROUND
54.622 + // Due to a Chiba bug, anyType is not a recognized type name.
54.623 + // so, if this is an anyType, then we'll just skip the type
54.624 + // setting.
54.625 + //
54.626 + // type.getName() may be 'null' for anonymous types, so compare against
54.627 + // static string (see bug #1172541 on sf.net)
54.628 + if (!("anyType").equals(controlType.getName())) {
54.629 + Element enveloppe = bindElement.getOwnerDocument().getDocumentElement();
54.630 + String typeName = this.getXFormsTypeName(enveloppe, controlType);
54.631 + if (typeName != null && !typeName.equals(""))
54.632 + bindElement.setAttributeNS(XFORMS_NS,
54.633 + getXFormsNSPrefix() + "type",
54.634 + typeName);
54.635 + }
54.636 +
54.637 + if (minOccurs == 0) {
54.638 + bindElement.setAttributeNS(XFORMS_NS,
54.639 + getXFormsNSPrefix() + "required",
54.640 + "false()");
54.641 + } else {
54.642 + bindElement.setAttributeNS(XFORMS_NS,
54.643 + getXFormsNSPrefix() + "required",
54.644 + "true()");
54.645 + }
54.646 +
54.647 + //no more minOccurs & maxOccurs element: add a constraint if maxOccurs>1:
54.648 + //count(.) <= maxOccurs && count(.) >= minOccurs
54.649 + String minConstraint = null;
54.650 + String maxConstraint = null;
54.651 +
54.652 + if (minOccurs > 1) {
54.653 + //if 0 or 1 -> no constraint (managed by "required")
54.654 + minConstraint = "count(.) >= " + minOccurs;
54.655 + }
54.656 +
54.657 + if (maxOccurs > 1) {
54.658 + //if 1 or unbounded -> no constraint
54.659 + maxConstraint = "count(.) <= " + maxOccurs;
54.660 + }
54.661 +
54.662 + String constraint = null;
54.663 +
54.664 + if ((minConstraint != null) && (maxConstraint != null)) {
54.665 + constraint = minConstraint + " and " + maxConstraint;
54.666 + } else if (minConstraint != null) {
54.667 + constraint = minConstraint;
54.668 + } else {
54.669 + constraint = maxConstraint;
54.670 + }
54.671 +
54.672 + if ((constraint != null) && !constraint.equals("")) {
54.673 + bindElement.setAttributeNS(XFORMS_NS,
54.674 + getXFormsNSPrefix() + "constraint",
54.675 + constraint);
54.676 + }
54.677 +
54.678 + /*if (minOccurs != 1) {
54.679 + bindElement.setAttributeNS(XFORMS_NS,getXFormsNSPrefix() + "minOccurs",String.valueOf(minOccurs));
54.680 + }
54.681 + if (maxOccurs != 1) {
54.682 + bindElement.setAttributeNS(XFORMS_NS,getXFormsNSPrefix() + "maxOccurs",maxOccurs == -1 ? "unbounded" : String.valueOf((maxOccurs)));
54.683 + }*/
54.684 + return bindElement;
54.685 + }
54.686 +
54.687 + /**
54.688 + * __UNDOCUMENTED__
54.689 + *
54.690 + * @param controlElement __UNDOCUMENTED__
54.691 + * @param controlType __UNDOCUMENTED__
54.692 + * @return __UNDOCUMENTED__
54.693 + */
54.694 + public Element startFormControl(Element controlElement,
54.695 + XSTypeDefinition controlType) {
54.696 + return controlElement;
54.697 + }
54.698 +
54.699 + /**
54.700 + * __UNDOCUMENTED__
54.701 + *
54.702 + * @param groupElement __UNDOCUMENTED__
54.703 + * @param schemaElement __UNDOCUMENTED__
54.704 + * @return __UNDOCUMENTED__
54.705 + */
54.706 + public Element startFormGroup(Element groupElement,
54.707 + XSElementDeclaration schemaElement) {
54.708 + //groupElement.setAttributeNS(CHIBA_NS,getChibaNSPrefix() + "box-align",getProperty(GROUP_BOX_ALIGN_PROP));
54.709 + //groupElement.setAttributeNS(CHIBA_NS,getChibaNSPrefix() + "box-orient",getProperty(GROUP_BOX_ORIENT_PROP));
54.710 + //groupElement.setAttributeNS(CHIBA_NS,getChibaNSPrefix() + "caption-width",getProperty(GROUP_CAPTION_WIDTH_PROP));
54.711 + //groupElement.setAttributeNS(CHIBA_NS,getChibaNSPrefix() + "width",getProperty(GROUP_WIDTH_PROP));
54.712 + //groupElement.setAttributeNS(CHIBA_NS,getChibaNSPrefix() + "border",getProperty(GROUP_BORDER_PROP));
54.713 + return groupElement;
54.714 + }
54.715 +}
55.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
55.2 +++ b/enterprise/openesbaddons/workflow/project/chiba_src/org/chiba/tools/schemabuilder/BaseWrapperElementsBuilder.java Thu Apr 26 02:33:27 2007 +0000
55.3 @@ -0,0 +1,175 @@
55.4 +// Copyright 2006 Chibacon
55.5 +
55.6 +/*
55.7 + *
55.8 + * Artistic License
55.9 + *
55.10 + * Preamble
55.11 + *
55.12 + * The intent of this document is to state the conditions under which a Package may be copied, such that
55.13 + * the Copyright Holder maintains some semblance of artistic control over the development of the
55.14 + * package, while giving the users of the package the right to use and distribute the Package in a
55.15 + * more-or-less customary fashion, plus the right to make reasonable modifications.
55.16 + *
55.17 + * Definitions:
55.18 + *
55.19 + * "Package" refers to the collection of files distributed by the Copyright Holder, and derivatives
55.20 + * of that collection of files created through textual modification.
55.21 + *
55.22 + * "Standard Version" refers to such a Package if it has not been modified, or has been modified
55.23 + * in accordance with the wishes of the Copyright Holder.
55.24 + *
55.25 + * "Copyright Holder" is whoever is named in the copyright or copyrights for the package.
55.26 + *
55.27 + * "You" is you, if you're thinking about copying or distributing this Package.
55.28 + *
55.29 + * "Reasonable copying fee" is whatever you can justify on the basis of media cost, duplication
55.30 + * charges, time of people involved, and so on. (You will not be required to justify it to the
55.31 + * Copyright Holder, but only to the computing community at large as a market that must bear the
55.32 + * fee.)
55.33 + *
55.34 + * "Freely Available" means that no fee is charged for the item itself, though there may be fees
55.35 + * involved in handling the item. It also means that recipients of the item may redistribute it under
55.36 + * the same conditions they received it.
55.37 + *
55.38 + * 1. You may make and give away verbatim copies of the source form of the Standard Version of this
55.39 + * Package without restriction, provided that you duplicate all of the original copyright notices and
55.40 + * associated disclaimers.
55.41 + *
55.42 + * 2. You may apply bug fixes, portability fixes and other modifications derived from the Public Domain
55.43 + * or from the Copyright Holder. A Package modified in such a way shall still be considered the
55.44 + * Standard Version.
55.45 + *
55.46 + * 3. You may otherwise modify your copy of this Package in any way, provided that you insert a
55.47 + * prominent notice in each changed file stating how and when you changed that file, and provided that
55.48 + * you do at least ONE of the following:
55.49 + *
55.50 + * a) place your modifications in the Public Domain or otherwise make them Freely
55.51 + * Available, such as by posting said modifications to Usenet or an equivalent medium, or
55.52 + * placing the modifications on a major archive site such as ftp.uu.net, or by allowing the
55.53 + * Copyright Holder to include your modifications in the Standard Version of the Package.
55.54 + *
55.55 + * b) use the modified Package only within your corporation or organization.
55.56 + *
55.57 + * c) rename any non-standard executables so the names do not conflict with standard
55.58 + * executables, which must also be provided, and provide a separate manual page for each
55.59 + * non-standard executable that clearly documents how it differs from the Standard
55.60 + * Version.
55.61 + *
55.62 + * d) make other distribution arrangements with the Copyright Holder.
55.63 + *
55.64 + * 4. You may distribute the programs of this Package in object code or executable form, provided that
55.65 + * you do at least ONE of the following:
55.66 + *
55.67 + * a) distribute a Standard Version of the executables and library files, together with
55.68 + * instructions (in the manual page or equivalent) on where to get the Standard Version.
55.69 + *
55.70 + * b) accompany the distribution with the machine-readable source of the Package with
55.71 + * your modifications.
55.72 + *
55.73 + * c) accompany any non-standard executables with their corresponding Standard Version
55.74 + * executables, giving the non-standard executables non-standard names, and clearly
55.75 + * documenting the differences in manual pages (or equivalent), together with instructions
55.76 + * on where to get the Standard Version.
55.77 + *
55.78 + * d) make other distribution arrangements with the Copyright Holder.
55.79 + *
55.80 + * 5. You may charge a reasonable copying fee for any distribution of this Package. You may charge
55.81 + * any fee you choose for support of this Package. You may not charge a fee for this Package itself.
55.82 + * However, you may distribute this Package in aggregate with other (possibly commercial) programs as
55.83 + * part of a larger (possibly commercial) software distribution provided that you do not advertise this
55.84 + * Package as a product of your own.
55.85 + *
55.86 + * 6. The scripts and library files supplied as input to or produced as output from the programs of this
55.87 + * Package do not automatically fall under the copyright of this Package, but belong to whomever
55.88 + * generated them, and may be sold commercially, and may be aggregated with this Package.
55.89 + *
55.90 + * 7. C or perl subroutines supplied by you and linked into this Package shall not be considered part of
55.91 + * this Package.
55.92 + *
55.93 + * 8. The name of the Copyright Holder may not be used to endorse or promote products derived from
55.94 + * this software without specific prior written permission.
55.95 + *
55.96 + * 9. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
55.97 + * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
55.98 + * MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
55.99 + *
55.100 + */
55.101 +package org.chiba.tools.schemabuilder;
55.102 +
55.103 +import org.w3c.dom.Document;
55.104 +import org.w3c.dom.Element;
55.105 +
55.106 +/**
55.107 + * Basic implementation of WrapperElementsBuilder, with no additional design
55.108 + *
55.109 + * @author - Sophie Ramel
55.110 + * @deprecated
55.111 + */
55.112 +public class BaseWrapperElementsBuilder implements WrapperElementsBuilder {
55.113 + /**
55.114 + * Creates a new instance of BaseWrapperElementsBuilder
55.115 + */
55.116 + public BaseWrapperElementsBuilder() {
55.117 + }
55.118 +
55.119 + /**
55.120 + * create the wrapper element of the different controls
55.121 + *
55.122 + * @param controlElement the control element (input, select, repeat, group, ...)
55.123 + * @return the wrapper element, already containing the control element
55.124 + */
55.125 + public Element createControlsWrapper(Element controlElement) {
55.126 + return controlElement;
55.127 + }
55.128 +
55.129 + /**
55.130 + * creates the global enveloppe of the resulting document, and puts it in the document
55.131 + *
55.132 + * @return the enveloppe
55.133 + */
55.134 + public Element createEnvelope(Document xForm) {
55.135 + Element envelopeElement = xForm.createElement("envelope");
55.136 +
55.137 + //Element envelopeElement = xForm.createElementNS(CHIBA_NS, this.getChibaNSPrefix()+"envelope");
55.138 + xForm.appendChild(envelopeElement);
55.139 +
55.140 + return envelopeElement;
55.141 + }
55.142 +
55.143 + /**
55.144 + * create the wrapper element of the form
55.145 + *
55.146 + * @param enveloppeElement the form element (chiba:form or other)
55.147 + * @return the wrapper element
55.148 + */
55.149 +
55.150 + public Element createFormWrapper(Element enveloppeElement) {
55.151 + //add a "body" element without NS
55.152 + Document doc = enveloppeElement.getOwnerDocument();
55.153 + Element body = doc.createElement("body");
55.154 + //body.appendChild(formElement);
55.155 + enveloppeElement.appendChild(body);
55.156 + return body;
55.157 + }
55.158 +
55.159 + /**
55.160 + * create the element that will contain the content of the group (or repeat) element
55.161 + *
55.162 + * @param groupElement the group or repeat element
55.163 + * @return the wrapper element, already containing the content of the group element
55.164 + */
55.165 + public Element createGroupContentWrapper(Element groupElement) {
55.166 + return groupElement;
55.167 + }
55.168 +
55.169 + /**
55.170 + * create the wrapper element of the xforms:model element
55.171 + *
55.172 + * @param modelElement the xforms:model element
55.173 + * @return the wrapper element, already containing the model
55.174 + */
55.175 + public Element createModelWrapper(Element modelElement) {
55.176 + return modelElement;
55.177 + }
55.178 +}
56.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
56.2 +++ b/enterprise/openesbaddons/workflow/project/chiba_src/org/chiba/tools/schemabuilder/FormBuilderException.java Thu Apr 26 02:33:27 2007 +0000
56.3 @@ -0,0 +1,176 @@
56.4 +// Copyright 2006 Chibacon
56.5 +
56.6 +/*
56.7 + *
56.8 + * Artistic License
56.9 + *
56.10 + * Preamble
56.11 + *
56.12 + * The intent of this document is to state the conditions under which a Package may be copied, such that
56.13 + * the Copyright Holder maintains some semblance of artistic control over the development of the
56.14 + * package, while giving the users of the package the right to use and distribute the Package in a
56.15 + * more-or-less customary fashion, plus the right to make reasonable modifications.
56.16 + *
56.17 + * Definitions:
56.18 + *
56.19 + * "Package" refers to the collection of files distributed by the Copyright Holder, and derivatives
56.20 + * of that collection of files created through textual modification.
56.21 + *
56.22 + * "Standard Version" refers to such a Package if it has not been modified, or has been modified
56.23 + * in accordance with the wishes of the Copyright Holder.
56.24 + *
56.25 + * "Copyright Holder" is whoever is named in the copyright or copyrights for the package.
56.26 + *
56.27 + * "You" is you, if you're thinking about copying or distributing this Package.
56.28 + *
56.29 + * "Reasonable copying fee" is whatever you can justify on the basis of media cost, duplication
56.30 + * charges, time of people involved, and so on. (You will not be required to justify it to the
56.31 + * Copyright Holder, but only to the computing community at large as a market that must bear the
56.32 + * fee.)
56.33 + *
56.34 + * "Freely Available" means that no fee is charged for the item itself, though there may be fees
56.35 + * involved in handling the item. It also means that recipients of the item may redistribute it under
56.36 + * the same conditions they received it.
56.37 + *
56.38 + * 1. You may make and give away verbatim copies of the source form of the Standard Version of this
56.39 + * Package without restriction, provided that you duplicate all of the original copyright notices and
56.40 + * associated disclaimers.
56.41 + *
56.42 + * 2. You may apply bug fixes, portability fixes and other modifications derived from the Public Domain
56.43 + * or from the Copyright Holder. A Package modified in such a way shall still be considered the
56.44 + * Standard Version.
56.45 + *
56.46 + * 3. You may otherwise modify your copy of this Package in any way, provided that you insert a
56.47 + * prominent notice in each changed file stating how and when you changed that file, and provided that
56.48 + * you do at least ONE of the following:
56.49 + *
56.50 + * a) place your modifications in the Public Domain or otherwise make them Freely
56.51 + * Available, such as by posting said modifications to Usenet or an equivalent medium, or
56.52 + * placing the modifications on a major archive site such as ftp.uu.net, or by allowing the
56.53 + * Copyright Holder to include your modifications in the Standard Version of the Package.
56.54 + *
56.55 + * b) use the modified Package only within your corporation or organization.
56.56 + *
56.57 + * c) rename any non-standard executables so the names do not conflict with standard
56.58 + * executables, which must also be provided, and provide a separate manual page for each
56.59 + * non-standard executable that clearly documents how it differs from the Standard
56.60 + * Version.
56.61 + *
56.62 + * d) make other distribution arrangements with the Copyright Holder.
56.63 + *
56.64 + * 4. You may distribute the programs of this Package in object code or executable form, provided that
56.65 + * you do at least ONE of the following:
56.66 + *
56.67 + * a) distribute a Standard Version of the executables and library files, together with
56.68 + * instructions (in the manual page or equivalent) on where to get the Standard Version.
56.69 + *
56.70 + * b) accompany the distribution with the machine-readable source of the Package with
56.71 + * your modifications.
56.72 + *
56.73 + * c) accompany any non-standard executables with their corresponding Standard Version
56.74 + * executables, giving the non-standard executables non-standard names, and clearly
56.75 + * documenting the differences in manual pages (or equivalent), together with instructions
56.76 + * on where to get the Standard Version.
56.77 + *
56.78 + * d) make other distribution arrangements with the Copyright Holder.
56.79 + *
56.80 + * 5. You may charge a reasonable copying fee for any distribution of this Package. You may charge
56.81 + * any fee you choose for support of this Package. You may not charge a fee for this Package itself.
56.82 + * However, you may distribute this Package in aggregate with other (possibly commercial) programs as
56.83 + * part of a larger (possibly commercial) software distribution provided that you do not advertise this
56.84 + * Package as a product of your own.
56.85 + *
56.86 + * 6. The scripts and library files supplied as input to or produced as output from the programs of this
56.87 + * Package do not automatically fall under the copyright of this Package, but belong to whomever
56.88 + * generated them, and may be sold commercially, and may be aggregated with this Package.
56.89 + *
56.90 + * 7. C or perl subroutines supplied by you and linked into this Package shall not be considered part of
56.91 + * this Package.
56.92 + *
56.93 + * 8. The name of the Copyright Holder may not be used to endorse or promote products derived from
56.94 + * this software without specific prior written permission.
56.95 + *
56.96 + * 9. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
56.97 + * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
56.98 + * MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
56.99 + *
56.100 + */
56.101 +package org.chiba.tools.schemabuilder;
56.102 +
56.103 +
56.104 +/**
56.105 + * This exception is thrown when implementations of <code>SchemaFormBuilder</code> encounters an
56.106 + * error building a form.
56.107 + *
56.108 + * @author Brian Dueck
56.109 + * @version $Id$
56.110 + * @deprecated
56.111 + */
56.112 +public class FormBuilderException extends java.lang.Exception {
56.113 + private Exception cause = null;
56.114 +
56.115 + /**
56.116 + * Creates a new instance of <code>FormBuilderException</code> without detail message.
56.117 + */
56.118 + public FormBuilderException() {
56.119 + }
56.120 +
56.121 + /**
56.122 + * Constructs an instance of <code>FormBuilderException</code> with the specified detail message.
56.123 + *
56.124 + * @param msg the detail message.
56.125 + */
56.126 + public FormBuilderException(String msg) {
56.127 + super(msg);
56.128 + }
56.129 +
56.130 + /**
56.131 + * Constructs an instance of <code>FormBuilderException</code> with the specified root exception.
56.132 + *
56.133 + * @param x The root exception.
56.134 + */
56.135 + public FormBuilderException(Exception x) {
56.136 + //THIS DOES NOT WORK WITH JDK 1.3 CAUSE THIS IS NEW IN JDK 1.4
56.137 + //super(x);
56.138 + super(x.getMessage());
56.139 + }
56.140 +}
56.141 +
56.142 +
56.143 +/*
56.144 + $Log$
56.145 + Revision 1.1 2007/04/26 02:34:11 mwu
56.146 + move workflow to the new location, add xform, xml instance generation
56.147 +
56.148 + Revision 1.6 2006/09/29 10:50:18 unl
56.149 + - deprecated tools package
56.150 +
56.151 + Revision 1.5 2006/03/16 09:36:28 joernt
56.152 + fixed Copyright
56.153 +
56.154 + Revision 1.4 2005/01/31 22:49:31 joernt
56.155 + added copyright notice
56.156 +
56.157 + Revision 1.3 2004/08/15 14:14:07 joernt
56.158 + preparing release...
56.159 + -reformatted sources to fix mixture of tabs and spaces
56.160 + -optimized imports on all files
56.161 +
56.162 + Revision 1.2 2003/10/02 15:15:49 joernt
56.163 + applied chiba jalopy settings to whole src tree
56.164 +
56.165 + Revision 1.1 2003/07/12 12:22:48 joernt
56.166 + package refactoring: moved from xforms.builder
56.167 + Revision 1.1.1.1 2003/05/23 14:54:08 unl
56.168 + no message
56.169 + Revision 1.2 2003/02/19 09:09:15 soframel
56.170 + print the exception's message
56.171 + Revision 1.1 2002/12/11 14:50:42 soframel
56.172 + transferred the Schema2XForms generator from chiba2 to chiba1
56.173 + Revision 1.3 2002/06/11 17:13:03 joernt
56.174 + commented out jdk 1.3 incompatible constructor-impl
56.175 + Revision 1.2 2002/06/11 14:06:31 joernt
56.176 + commented out the jdk 1.4 constructor
56.177 + Revision 1.1 2002/05/22 22:24:34 joernt
56.178 + Brian's initial version of schema2xforms builder
56.179 + */
57.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
57.2 +++ b/enterprise/openesbaddons/workflow/project/chiba_src/org/chiba/tools/schemabuilder/SchemaFormBuilder.java Thu Apr 26 02:33:27 2007 +0000
57.3 @@ -0,0 +1,604 @@
57.4 +// Copyright 2006 Chibacon
57.5 +
57.6 +/*
57.7 + *
57.8 + * Artistic License
57.9 + *
57.10 + * Preamble
57.11 + *
57.12 + * The intent of this document is to state the conditions under which a Package may be copied, such that
57.13 + * the Copyright Holder maintains some semblance of artistic control over the development of the
57.14 + * package, while giving the users of the package the right to use and distribute the Package in a
57.15 + * more-or-less customary fashion, plus the right to make reasonable modifications.
57.16 + *
57.17 + * Definitions:
57.18 + *
57.19 + * "Package" refers to the collection of files distributed by the Copyright Holder, and derivatives
57.20 + * of that collection of files created through textual modification.
57.21 + *
57.22 + * "Standard Version" refers to such a Package if it has not been modified, or has been modified
57.23 + * in accordance with the wishes of the Copyright Holder.
57.24 + *
57.25 + * "Copyright Holder" is whoever is named in the copyright or copyrights for the package.
57.26 + *
57.27 + * "You" is you, if you're thinking about copying or distributing this Package.
57.28 + *
57.29 + * "Reasonable copying fee" is whatever you can justify on the basis of media cost, duplication
57.30 + * charges, time of people involved, and so on. (You will not be required to justify it to the
57.31 + * Copyright Holder, but only to the computing community at large as a market that must bear the
57.32 + * fee.)
57.33 + *
57.34 + * "Freely Available" means that no fee is charged for the item itself, though there may be fees
57.35 + * involved in handling the item. It also means that recipients of the item may redistribute it under
57.36 + * the same conditions they received it.
57.37 + *
57.38 + * 1. You may make and give away verbatim copies of the source form of the Standard Version of this
57.39 + * Package without restriction, provided that you duplicate all of the original copyright notices and
57.40 + * associated disclaimers.
57.41 + *
57.42 + * 2. You may apply bug fixes, portability fixes and other modifications derived from the Public Domain
57.43 + * or from the Copyright Holder. A Package modified in such a way shall still be considered the
57.44 + * Standard Version.
57.45 + *
57.46 + * 3. You may otherwise modify your copy of this Package in any way, provided that you insert a
57.47 + * prominent notice in each changed file stating how and when you changed that file, and provided that
57.48 + * you do at least ONE of the following:
57.49 + *
57.50 + * a) place your modifications in the Public Domain or otherwise make them Freely
57.51 + * Available, such as by posting said modifications to Usenet or an equivalent medium, or
57.52 + * placing the modifications on a major archive site such as ftp.uu.net, or by allowing the
57.53 + * Copyright Holder to include your modifications in the Standard Version of the Package.
57.54 + *
57.55 + * b) use the modified Package only within your corporation or organization.
57.56 + *
57.57 + * c) rename any non-standard executables so the names do not conflict with standard
57.58 + * executables, which must also be provided, and provide a separate manual page for each
57.59 + * non-standard executable that clearly documents how it differs from the Standard
57.60 + * Version.
57.61 + *
57.62 + * d) make other distribution arrangements with the Copyright Holder.
57.63 + *
57.64 + * 4. You may distribute the programs of this Package in object code or executable form, provided that
57.65 + * you do at least ONE of the following:
57.66 + *
57.67 + * a) distribute a Standard Version of the executables and library files, together with
57.68 + * instructions (in the manual page or equivalent) on where to get the Standard Version.
57.69 + *
57.70 + * b) accompany the distribution with the machine-readable source of the Package with
57.71 + * your modifications.
57.72 + *
57.73 + * c) accompany any non-standard executables with their corresponding Standard Version
57.74 + * executables, giving the non-standard executables non-standard names, and clearly
57.75 + * documenting the differences in manual pages (or equivalent), together with instructions
57.76 + * on where to get the Standard Version.
57.77 + *
57.78 + * d) make other distribution arrangements with the Copyright Holder.
57.79 + *
57.80 + * 5. You may charge a reasonable copying fee for any distribution of this Package. You may charge
57.81 + * any fee you choose for support of this Package. You may not charge a fee for this Package itself.
57.82 + * However, you may distribute this Package in aggregate with other (possibly commercial) programs as
57.83 + * part of a larger (possibly commercial) software distribution provided that you do not advertise this
57.84 + * Package as a product of your own.
57.85 + *
57.86 + * 6. The scripts and library files supplied as input to or produced as output from the programs of this
57.87 + * Package do not automatically fall under the copyright of this Package, but belong to whomever
57.88 + * generated them, and may be sold commercially, and may be aggregated with this Package.
57.89 + *
57.90 + * 7. C or perl subroutines supplied by you and linked into this Package shall not be considered part of
57.91 + * this Package.
57.92 + *
57.93 + * 8. The name of the Copyright Holder may not be used to endorse or promote products derived from
57.94 + * this software without specific prior written permission.
57.95 + *
57.96 + * 9. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
57.97 + * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
57.98 + * MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
57.99 + *
57.100 + */
57.101 +package org.chiba.tools.schemabuilder;
57.102 +
57.103 +import org.apache.log4j.Category;
57.104 +import com.sun.org.apache.xerces.internal.xs.*;
57.105 +import org.w3c.dom.Document;
57.106 +import org.w3c.dom.Element;
57.107 +
57.108 +import javax.xml.transform.Source;
57.109 +import java.util.Properties;
57.110 +
57.111 +/**
57.112 + * An object that implements this interface can build an XForm that conforms to
57.113 + * the elements and attributes declared in an XML Schema.
57.114 + *
57.115 + * @author Brian Dueck
57.116 + * @version $Id$
57.117 + * @deprecated
57.118 + */
57.119 +public interface SchemaFormBuilder {
57.120 + /**
57.121 + * logging
57.122 + */
57.123 + public static Category LOGGER =
57.124 + Category.getInstance(SchemaFormBuilder.class);
57.125 +
57.126 + /**
57.127 + * XMLSchema Instance Namespace declaration
57.128 + */
57.129 + public static final String XMLSCHEMA_INSTANCE_NAMESPACE_URI = "http://www.w3.org/2001/XMLSchema-instance";
57.130 +
57.131 + /**
57.132 + * XMLNS Namespace declaration.
57.133 + */
57.134 + public static final String XMLNS_NAMESPACE_URI =
57.135 + "http://www.w3.org/2000/xmlns/";
57.136 +
57.137 + /**
57.138 + * XML Namespace declaration
57.139 + */
57.140 + public static final String XML_NAMESPACE_URI =
57.141 + "http://www.w3.org/XML/1998/namespace";
57.142 +
57.143 + /**
57.144 + * XForms namespace declaration.
57.145 + */
57.146 + public static final String XFORMS_NS = "http://www.w3.org/2002/xforms";
57.147 +
57.148 + /**
57.149 + * Chiba namespace declaration.
57.150 + */
57.151 + public static final String CHIBA_NS =
57.152 + "http://chiba.sourceforge.net/xforms";
57.153 +
57.154 + /**
57.155 + * XLink namespace declaration.
57.156 + */
57.157 + public static final String XLINK_NS = "http://www.w3.org/1999/xlink";
57.158 +
57.159 + /**
57.160 + * XML Events namsepace declaration.
57.161 + */
57.162 + public static final String XMLEVENTS_NS = "http://www.w3.org/2001/xml-events";
57.163 +
57.164 + /**
57.165 + * Chiba prefix
57.166 + */
57.167 + public static final String chibaNSPrefix = "chiba:";
57.168 +
57.169 + /**
57.170 + * XForms prefix
57.171 + */
57.172 + public static final String xformsNSPrefix = "xforms:";
57.173 +
57.174 + /**
57.175 + * Xlink prefix
57.176 + */
57.177 + public static final String xlinkNSPrefix = "xlink:";
57.178 +
57.179 + /**
57.180 + * XMLSchema instance prefix *
57.181 + */
57.182 + public static final String xmlSchemaInstancePrefix = "xsi:";
57.183 +
57.184 + /**
57.185 + * XML Events prefix
57.186 + */
57.187 + public static final String xmleventsNSPrefix = "ev:";
57.188 +
57.189 + /**
57.190 + * __UNDOCUMENTED__
57.191 + *
57.192 + * @return __UNDOCUMENTED__
57.193 + */
57.194 + public String getAction();
57.195 +
57.196 + /**
57.197 + * __UNDOCUMENTED__
57.198 + *
57.199 + * @return __UNDOCUMENTED__
57.200 + */
57.201 + public String getInstanceHref();
57.202 +
57.203 + /**
57.204 + * __UNDOCUMENTED__
57.205 + *
57.206 + * @return __UNDOCUMENTED__
57.207 + */
57.208 + public int getInstanceMode();
57.209 +
57.210 + /**
57.211 + * __UNDOCUMENTED__
57.212 + *
57.213 + * @return __UNDOCUMENTED__
57.214 + */
57.215 + public Source getInstanceSource();
57.216 +
57.217 + /**
57.218 + * Get the current set of properties used by implementations of SchemaFormBuilder.
57.219 + *
57.220 + * @return The list of properties.
57.221 + */
57.222 + public Properties getProperties();
57.223 +
57.224 + /**
57.225 + * Sets the property to the specified value. If the property exists, its value is overwritten.
57.226 + *
57.227 + * @param key The implementation defined property key.
57.228 + * @param value The value for the property.
57.229 + */
57.230 + public void setProperty(String key, String value);
57.231 +
57.232 + /**
57.233 + * Gets the value for the specified property.
57.234 + *
57.235 + * @param key The implementation defined property key.
57.236 + * @return The property value if found, or null if the property cannot be located.
57.237 + */
57.238 + public String getProperty(String key);
57.239 +
57.240 + /**
57.241 + * Gets the value for the specified property, with a default if the property cannot be located.
57.242 + *
57.243 + * @param key The implementation defined property key.
57.244 + * @param defaultValue This value will be returned if the property does not exists.
57.245 + * @return The property value if found, or defaultValue if the property cannot be located.
57.246 + */
57.247 + public String getProperty(String key, String defaultValue);
57.248 +
57.249 + /**
57.250 + * Properties choosed by the user
57.251 + */
57.252 + public String getRootTagName();
57.253 +
57.254 + /**
57.255 + * __UNDOCUMENTED__
57.256 + *
57.257 + * @return __UNDOCUMENTED__
57.258 + */
57.259 + public String getStylesheet();
57.260 +
57.261 + /**
57.262 + * __UNDOCUMENTED__
57.263 + *
57.264 + * @return __UNDOCUMENTED__
57.265 + */
57.266 + public String getSubmitMethod();
57.267 +
57.268 + /**
57.269 + * Generate the XForm based on a user supplied XML Schema.
57.270 + *
57.271 + * @param inputURI The document source for the XML Schema.
57.272 + * @return The Document containing the XForm.
57.273 + * @throws org.chiba.tools.schemabuilder.FormBuilderException
57.274 + * If an error occurs building the XForm.
57.275 + */
57.276 + public Document buildForm(String inputURI) throws FormBuilderException;
57.277 +
57.278 + /**
57.279 + * Generate the XForm based on a user supplied XML Schema returning the
57.280 + * XForm as stringified XML.
57.281 + *
57.282 + * @param inputURI The document source for the XML Schema.
57.283 + * @return The stringified XML containing the XForm.
57.284 + * @throws org.chiba.tools.schemabuilder.FormBuilderException
57.285 + * If an error occurs building the XForm.
57.286 + */
57.287 + public String buildFormAsString(String inputURI)
57.288 + throws FormBuilderException;
57.289 +
57.290 + /**
57.291 + * Creates a caption for the provided text extracted from the XML Schema.
57.292 + * The implementation is responsible for reformatting the provided string to make it
57.293 + * suitable to be displayed to users of the XForm. This typically includes translating
57.294 + * XML tag name style identifiers (e.g. customerStreetAddress) into more reader friendly
57.295 + * captions (e.g. Customer Street Address).
57.296 + *
57.297 + * @param text The string value to be reformatted for use as a caption.
57.298 + * @return The caption.
57.299 + */
57.300 + public String createCaption(String text);
57.301 +
57.302 + /**
57.303 + * Creates a caption for the provided XML Schema attribute.
57.304 + * The implementation is responsible for providing an appropriate caption
57.305 + * suitable to be displayed to users of the XForm. This typically includes translating
57.306 + * XML tag name style identifiers (e.g. customerStreetAddress) into more reader friendly
57.307 + * captions (e.g. Customer Street Address).
57.308 + *
57.309 + * @param attribute The XML schema attribute for which a caption is required.
57.310 + * @return The caption.
57.311 + */
57.312 + public String createCaption(XSAttributeDeclaration attribute);
57.313 +
57.314 + /**
57.315 + * Creates a caption for the provided XML Schema element.
57.316 + * The implementation is responsible for providing an appropriate caption
57.317 + * suitable to be displayed to users of the XForm. This typically includes translating
57.318 + * XML tag name style identifiers (e.g. customerStreetAddress) into more reader friendly
57.319 + * captions (e.g. Customer Street Address).
57.320 + *
57.321 + * @param element The XML schema element for which a caption is required.
57.322 + * @return The caption.
57.323 + */
57.324 + public String createCaption(XSElementDeclaration element);
57.325 +
57.326 + /**
57.327 + * Creates a form control for an XML Schema any type.
57.328 + * <p/>
57.329 + * This method is called when the form builder determines a form control is required for
57.330 + * an any type.
57.331 + * The implementation of this method is responsible for creating an XML element of the
57.332 + * appropriate type to receive a value for <b>controlType</b>. The caller is responsible
57.333 + * for adding the returned element to the form and setting caption, bind, and other
57.334 + * standard elements and attributes.
57.335 + *
57.336 + * @param xForm The XForm document.
57.337 + * @param controlType The XML Schema type for which the form control is to be created.
57.338 + * @return The element for the form control.
57.339 + */
57.340 + public Element createControlForAnyType(Document xForm,
57.341 + String caption,
57.342 + XSTypeDefinition controlType);
57.343 +
57.344 + /**
57.345 + * Creates a form control for an XML Schema simple atomic type.
57.346 + * <p/>
57.347 + * This method is called when the form builder determines a form control is required for
57.348 + * an atomic type.
57.349 + * The implementation of this method is responsible for creating an XML element of the
57.350 + * appropriate type to receive a value for <b>controlType</b>. The caller is responsible
57.351 + * for adding the returned element to the form and setting caption, bind, and other
57.352 + * standard elements and attributes.
57.353 + *
57.354 + * @param xForm The XForm document.
57.355 + * @param controlType The XML Schema type for which the form control is to be created.
57.356 + * @return The element for the form control.
57.357 + */
57.358 + public Element createControlForAtomicType(Document xForm,
57.359 + String caption,
57.360 + XSSimpleTypeDefinition controlType);
57.361 +
57.362 + /**
57.363 + * Creates a form control for an XML Schema simple type restricted by an enumeration.
57.364 + * This method is called when the form builder determines a form control is required for
57.365 + * an enumerated type.
57.366 + * The implementation of this method is responsible for creating an XML element of the
57.367 + * appropriate type to receive a value for <b>controlType</b>. The caller is responsible
57.368 + * for adding the returned element to the form and setting caption, bind, and other
57.369 + * standard elements and attributes.
57.370 + *
57.371 + * @param xForm The XForm document.
57.372 + * @param controlType The XML Schema type for which the form control is to be created.
57.373 + * @param caption The caption for the form control. The caller The purpose of providing the caption
57.374 + * is to permit the implementation to add a <b>[Select1 .... ]</b> message that involves the caption.
57.375 + * @param bindElement The bind element for this control. The purpose of providing the bind element
57.376 + * is to permit the implementation to add a isValid attribute to the bind element that prevents
57.377 + * the <b>[Select1 .... ]</b> item from being selected.
57.378 + * @return The element for the form control.
57.379 + */
57.380 + public Element createControlForEnumerationType(Document xForm,
57.381 + XSSimpleTypeDefinition controlType,
57.382 + String caption,
57.383 + Element bindElement);
57.384 +
57.385 + /**
57.386 + * Creates a form control for an XML Schema simple list type.
57.387 + * <p/>
57.388 + * This method is called when the form builder determines a form control is required for
57.389 + * a list type.
57.390 + * The implementation of this method is responsible for creating an XML element of the
57.391 + * appropriate type to receive a value for <b>controlType</b>. The caller is responsible
57.392 + * for adding the returned element to the form and setting caption, bind, and other
57.393 + * standard elements and attributes.
57.394 + *
57.395 + * @param xForm The XForm document.
57.396 + * @param listType The XML Schema list type for which the form control is to be created.
57.397 + * @param caption The caption for the form control. The caller The purpose of providing the caption
57.398 + * is to permit the implementation to add a <b>[Select1 .... ]</b> message that involves the caption.
57.399 + * @param bindElement The bind element for this control. The purpose of providing the bind element
57.400 + * is to permit the implementation to add a isValid attribute to the bind element that prevents
57.401 + * the <b>[Select1 .... ]</b> item from being selected.
57.402 + * @return The element for the form control.
57.403 + */
57.404 + public Element createControlForListType(Document xForm,
57.405 + XSSimpleTypeDefinition listType,
57.406 + String caption,
57.407 + Element bindElement);
57.408 +
57.409 + /**
57.410 + * Creates a hint XML Schema annotated node (AttributeDecl or ElementDecl).
57.411 + * The implementation is responsible for providing an xforms:hint element for the
57.412 + * specified schemaNode suitable to be dsipalayed to users of the XForm. The caller
57.413 + * is responsible for adding the returned element to the form.
57.414 + * This typically includes extracting documentation from the element/attribute's
57.415 + * annotation/documentation elements and/or extracting the same information from the
57.416 + * element/attribute's type annotation/documentation.
57.417 + *
57.418 + * @param schemaNode The string value to be reformatted for use as a caption.
57.419 + * @return The xforms:hint element. If a null value is returned a hint is not added.
57.420 + */
57.421 + public Element createHint(Document xForm, XSObject schemaNode);
57.422 +
57.423 + /**
57.424 + * This method is invoked after the form builder is finished creating and processing
57.425 + * a bind element. Implementations may choose to use this method to add/inspect/modify
57.426 + * the bindElement prior to the builder moving onto the next bind element.
57.427 + *
57.428 + * @param bindElement The bind element being processed.
57.429 + */
57.430 + public void endBindElement(Element bindElement);
57.431 +
57.432 + /**
57.433 + * This method is invoked after the form builder is finished creating and processing
57.434 + * a form control. Implementations may choose to use this method to add/inspect/modify
57.435 + * the controlElement prior to the builder moving onto the next control.
57.436 + *
57.437 + * @param controlElement The form control element that was created.
57.438 + * @param controlType The XML Schema type for which <b>controlElement</b> was created.
57.439 + */
57.440 + public void endFormControl(Element controlElement,
57.441 + XSTypeDefinition controlType,
57.442 + int minOccurs,
57.443 + int maxOccurs);
57.444 +
57.445 + /**
57.446 + * __UNDOCUMENTED__
57.447 + *
57.448 + * @param groupElement __UNDOCUMENTED__
57.449 + */
57.450 + public void endFormGroup(Element groupElement,
57.451 + XSTypeDefinition controlType,
57.452 + int minOccurs,
57.453 + int maxOccurs,
57.454 + Element modelSection);
57.455 +
57.456 + /**
57.457 + * Reset the SchemaFormBuilder to default values.
57.458 + */
57.459 + public void reset();
57.460 +
57.461 + /**
57.462 + * This method is invoked after an xforms:bind element is created for the specified SimpleType.
57.463 + * The implementation is responsible for setting setting any/all bind attributes
57.464 + * except for <b>id</b> and <b>ref</b> - these have been automatically set
57.465 + * by the caller (and should not be touched by implementation of startBindElement)
57.466 + * prior to invoking startBindElement.
57.467 + * The caller automatically adds the returned element to the model section of
57.468 + * the form.
57.469 + *
57.470 + * @param bindElement The bindElement being processed.
57.471 + * @param controlType XML Schema type of the element/attribute this bind is for.
57.472 + * @param minOccurs The minimum number of occurences for this element/attribute.
57.473 + * @param maxOccurs The maximum number of occurences for this element/attribute.
57.474 + * @return The bind Element to use in the XForm - bindElement or a replacement.
57.475 + */
57.476 + public Element startBindElement(Element bindElement,
57.477 + XSTypeDefinition controlType,
57.478 + int minOccurs,
57.479 + int maxOccurs);
57.480 +
57.481 + /**
57.482 + * This method is invoked after the form builder creates a form control
57.483 + * via a createControlForXXX() method but prior to decorating the form control
57.484 + * with common attributes such as a caption, hint, help text elements,
57.485 + * bind attributes, etc.
57.486 + * The returned element is used in the XForm in place of controlElement.
57.487 + * Implementations may choose to use this method to substitute controlElement
57.488 + * with a different element, or perform any other processing on controlElement
57.489 + * prior to it being added to the form.
57.490 + *
57.491 + * @param controlElement The form control element that was created.
57.492 + * @param controlType The XML Schema type for which <b>controlElement</b> was created.
57.493 + * @return The Element to use in the XForm - controlElement or a replacement.
57.494 + */
57.495 + public Element startFormControl(Element controlElement,
57.496 + XSTypeDefinition controlType);
57.497 +
57.498 + /**
57.499 + * This method is invoked after an xforms:group element is created for the specified
57.500 + * ElementDecl. A group is created whenever an element is encountered in the XML Schema
57.501 + * that contains other elements and attributes (complex types or mixed content types).
57.502 + * The caller automatically adds the returned element to the XForm.
57.503 + *
57.504 + * @param groupElement The groupElement being processed.
57.505 + * @param schemaElement The schemaElement for the group.
57.506 + * @return The group Element to use in the XForm - groupElement or a replacement. If a null
57.507 + * value is returned, the group is not created.
57.508 + */
57.509 + public Element startFormGroup(Element groupElement,
57.510 + XSElementDeclaration schemaElement);
57.511 +}
57.512 +
57.513 +/*
57.514 + $Log$
57.515 + Revision 1.1 2007/04/26 02:34:12 mwu
57.516 + move workflow to the new location, add xform, xml instance generation
57.517 +
57.518 + Revision 1.18 2006/09/29 10:50:18 unl
57.519 + - deprecated tools package
57.520 +
57.521 + Revision 1.17 2006/03/16 09:36:28 joernt
57.522 + fixed Copyright
57.523 +
57.524 + Revision 1.16 2005/02/10 13:24:57 joernt
57.525 + changed Chiba namespace
57.526 +
57.527 + Revision 1.15 2005/01/31 22:49:32 joernt
57.528 + added copyright notice
57.529 +
57.530 + Revision 1.14 2004/08/15 16:27:22 joernt
57.531 + preparing release...
57.532 + - fixed some javadoc issues
57.533 + - updated installation and index page for website
57.534 +
57.535 + Revision 1.13 2004/08/15 14:14:07 joernt
57.536 + preparing release...
57.537 + -reformatted sources to fix mixture of tabs and spaces
57.538 + -optimized imports on all files
57.539 +
57.540 + Revision 1.12 2004/07/28 21:43:28 joernt
57.541 + optimized imports
57.542 +
57.543 + Revision 1.11 2004/03/24 16:17:13 soframel
57.544 + - support for inheritance corrected in schemabuilder
57.545 + - basicTest adapted to work with these corrections
57.546 + - other tests cases slightly adapted (namespaces)
57.547 +
57.548 + Revision 1.10 2004/03/05 08:52:34 soframel
57.549 + Refactored completely the schemabuilder tool to use Xerces XMLSchema API instead of Castor's.
57.550 +
57.551 + Revision 1.9 2004/01/27 09:59:57 joernt
57.552 + imports
57.553 +
57.554 + Revision 1.8 2004/01/14 10:54:19 soframel
57.555 + Adapted the schemabuilder to modifications of chiba.
57.556 + - default generation is HTML
57.557 + - namespaces declarations changed
57.558 + - possibility to add a xml:base attribute
57.559 + - debugged constraint replacing "maxOccurs" model item property
57.560 + - adapted the test cases to these modifications, and also to previous modifications which hadn't been taken into account
57.561 +
57.562 + Revision 1.7 2003/11/07 00:16:34 joernt
57.563 + optimized imports
57.564 +
57.565 + Revision 1.6 2003/10/02 15:15:49 joernt
57.566 + applied chiba jalopy settings to whole src tree
57.567 +
57.568 + Revision 1.5 2003/08/18 23:00:46 joernt
57.569 + javadoc fixes + optimize imports
57.570 + Revision 1.4 2003/08/18 13:58:59 soframel
57.571 + adapted/debugged the builder:
57.572 + - removed chiba attributes
57.573 + - transformed minOccurs / maxOccurs into constraints when necessary
57.574 + - corrected a bug on the constraint for list types
57.575 + - removed the selectors for repeats + added the content of each repeat into a group
57.576 + - added a "stylesheet" parameter to specify the chiba:stylesheet attribute on the enveloppe
57.577 + Revision 1.3 2003/08/05 08:57:21 joernt
57.578 + xforms + chiba namespaces adapted
57.579 + Revision 1.2 2003/07/31 02:19:25 joernt
57.580 + optimized imports
57.581 + Revision 1.1 2003/07/12 12:22:48 joernt
57.582 + package refactoring: moved from xforms.builder
57.583 + Revision 1.1.1.1 2003/05/23 14:54:08 unl
57.584 + no message
57.585 + Revision 1.2 2002/12/12 15:21:44 soframel
57.586 + Added an interface "WrapperElementsBuilder" to create the wrappers element (with 2 implementations: a base implementation, for "envelope" elements, and an XHTML implementation).
57.587 + Changed the form builder to use it, and added a "+" trigger for repeats
57.588 + Changed the ant task to leave the choice of the wrapper type.
57.589 + Revision 1.1 2002/12/11 14:50:42 soframel
57.590 + transferred the Schema2XForms generator from chiba2 to chiba1
57.591 + Revision 1.6 2002/11/08 07:30:50 soframel
57.592 + corrected a bug with the reference to the xforms:case id in xforms:toggle elements
57.593 + Revision 1.5 2002/10/29 16:53:53 soframel
57.594 + - removed the chiba layout parameters box-align, border, box-orient, caption-width and width
57.595 + - added parameters to the constructors and removed them from the 'buildForm' method
57.596 + Revision 1.4 2002/10/24 07:43:55 soframel
57.597 + adapted to the 08/2002 working draft
57.598 + Revision 1.3 2002/06/10 14:57:45 bdueck
57.599 + Various Schema2Form enhancements. Support for inheritence, any attribute, and xsi:type through switch element.
57.600 + Check-out basicTest.xsd and basicTest-expected.xml in
57.601 + org\chiba\xml\xforms\schema\builder\test for an example of most features.
57.602 + Revision 1.2 2002/06/04 13:28:27 bdueck
57.603 + Ported Schema2Form builder to work with Castor's XML Schema library (http://www.castor.org).
57.604 + Castor replaces the Oracle schema library used in the initial version.
57.605 + Revision 1.1 2002/05/22 22:24:34 joernt
57.606 + Brian's initial version of schema2xforms builder
57.607 + */
58.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
58.2 +++ b/enterprise/openesbaddons/workflow/project/chiba_src/org/chiba/tools/schemabuilder/StringUtil.java Thu Apr 26 02:33:27 2007 +0000
58.3 @@ -0,0 +1,340 @@
58.4 +// Copyright 2006 Chibacon
58.5 +/*
58.6 + * Artistic License
58.7 + *
58.8 + * Preamble
58.9 + *
58.10 + * The intent of this document is to state the conditions under which a
58.11 + * Package may be copied, such that the Copyright Holder maintains some
58.12 + * semblance of artistic control over the development of the package, while
58.13 + * giving the users of the package the right to use and distribute the
58.14 + * Package in a more-or-less customary fashion, plus the right to make
58.15 + * reasonable modifications.
58.16 + *
58.17 + * Definitions:
58.18 + *
58.19 + * "Package" refers to the collection of files distributed by the Copyright
58.20 + * Holder, and derivatives of that collection of files created through
58.21 + * textual modification.
58.22 + *
58.23 + * "Standard Version" refers to such a Package if it has not been modified,
58.24 + * or has been modified in accordance with the wishes of the Copyright
58.25 + * Holder.
58.26 + *
58.27 + * "Copyright Holder" is whoever is named in the copyright or copyrights
58.28 + * for the package.
58.29 + *
58.30 + * "You" is you, if you're thinking about copying or distributing this
58.31 + * Package.
58.32 + *
58.33 + * "Reasonable copying fee" is whatever you can justify on the basis of
58.34 + * media cost, duplication charges, time of people involved, and so
58.35 + * on. (You will not be required to justify it to the Copyright Holder, but
58.36 + * only to the computing community at large as a market that must bear the
58.37 + * fee.)
58.38 + *
58.39 + * "Freely Available" means that no fee is charged for the item itself,
58.40 + * though there may be fees involved in handling the item. It also means
58.41 + * that recipients of the item may redistribute it under the same
58.42 + * conditions they received it.
58.43 + *
58.44 + * 1. You may make and give away verbatim copies of the source form of the
58.45 + * Standard Version of this Package without restriction, provided that you
58.46 + * duplicate all of the original copyright notices and associated
58.47 + * disclaimers.
58.48 + *
58.49 + * 2. You may apply bug fixes, portability fixes and other modifications
58.50 + * derived from the Public Domain or from the Copyright Holder. A Package
58.51 + * modified in such a way shall still be considered the Standard Version.
58.52 + *
58.53 + * 3. You may otherwise modify your copy of this Package in any way,
58.54 + * provided that you insert a prominent notice in each changed file stating
58.55 + * how and when you changed that file, and provided that you do at least
58.56 + * ONE of the following:
58.57 + *
58.58 + * a) place your modifications in the Public Domain or otherwise make them
58.59 + * Freely Available, such as by posting said modifications to Usenet or an
58.60 + * equivalent medium, or placing the modifications on a major archive site
58.61 + * such as ftp.uu.net, or by allowing the Copyright Holder to include your
58.62 + * modifications in the Standard Version of the Package.
58.63 + *
58.64 + * b) use the modified Package only within your corporation or
58.65 + * organization.
58.66 + *
58.67 + * c) rename any non-standard executables so the names do not conflict with
58.68 + * standard executables, which must also be provided, and provide a
58.69 + * separate manual page for each non-standard executable that clearly
58.70 + * documents how it differs from the Standard Version.
58.71 + *
58.72 + * d) make other distribution arrangements with the Copyright Holder.
58.73 + *
58.74 + * 4. You may distribute the programs of this Package in object code or
58.75 + * executable form, provided that you do at least ONE of the following:
58.76 + *
58.77 + * a) distribute a Standard Version of the executables and library files,
58.78 + * together with instructions (in the manual page or equivalent) on where
58.79 + * to get the Standard Version.
58.80 + *
58.81 + * b) accompany the distribution with the machine-readable source of the
58.82 + * Package with your modifications.
58.83 + *
58.84 + * c) accompany any non-standard executables with their corresponding
58.85 + * Standard Version executables, giving the non-standard executables
58.86 + * non-standard names, and clearly documenting the differences in manual
58.87 + * pages (or equivalent), together with instructions on where to get the
58.88 + * Standard Version.
58.89 + *
58.90 + * d) make other distribution arrangements with the Copyright Holder.
58.91 + *
58.92 + * 5. You may charge a reasonable copying fee for any distribution of this
58.93 + * Package. You may charge any fee you choose for support of this
58.94 + * Package. You may not charge a fee for this Package itself. However, you
58.95 + * may distribute this Package in aggregate with other (possibly
58.96 + * commercial) programs as part of a larger (possibly commercial) software
58.97 + * distribution provided that you do not advertise this Package as a
58.98 + * product of your own.
58.99 + *
58.100 + * 6. The scripts and library files supplied as input to or produced as
58.101 + * output from the programs of this Package do not automatically fall under
58.102 + * the copyright of this Package, but belong to whomever generated them,
58.103 + * and may be sold commercially, and may be aggregated with this Package.
58.104 + *
58.105 + * 7. C or perl subroutines supplied by you and linked into this Package
58.106 + * shall not be considered part of this Package.
58.107 + *
58.108 + * 8. The name of the Copyright Holder may not be used to endorse or
58.109 + * promote products derived from this software without specific prior
58.110 + * written permission.
58.111 + *
58.112 + * 9. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
58.113 + * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
58.114 + * MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
58.115 + *
58.116 + */
58.117 +package org.chiba.tools.schemabuilder;
58.118 +
58.119 +import java.util.StringTokenizer;
58.120 +
58.121 +/**
58.122 + * This class implements some helper string method which may be used in
58.123 + * stylesheets as extensions.
58.124 + *
58.125 + * @author gregor klinke
58.126 + * @version $Id$
58.127 + * @deprecated
58.128 + */
58.129 +public class StringUtil {
58.130 + /**
58.131 + * __UNDOCUMENTED__
58.132 + *
58.133 + * @param idstr __UNDOCUMENTED__
58.134 + * @return __UNDOCUMENTED__
58.135 + */
58.136 + public static Boolean isValidID(String idstr) {
58.137 + String charsfirst = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
58.138 + String charsfollow = charsfirst + "0123456789_-";
58.139 + char[] idarray = idstr.toCharArray();
58.140 +
58.141 + if (idarray.length == 0) {
58.142 + return Boolean.FALSE;
58.143 + }
58.144 +
58.145 + if (charsfirst.indexOf(idarray[0]) == -1) {
58.146 + return Boolean.FALSE;
58.147 + }
58.148 +
58.149 + for (int c = 1; c < idarray.length; c++) {
58.150 + if (charsfollow.indexOf(idarray[c]) == -1) {
58.151 + return Boolean.FALSE;
58.152 + }
58.153 + }
58.154 +
58.155 + return Boolean.TRUE;
58.156 + }
58.157 +
58.158 + /**
58.159 + * Capitalize a string - i.e. Convert something like "purchase order" to "Purchase Order".
58.160 + *
58.161 + * @param value The value to capitalize - e.g. "purchase order".
58.162 + * @return The capitalized value - e.g. "Purchase Order".
58.163 + */
58.164 + public static String capitalize(String value) {
58.165 + if (value == null) {
58.166 + return null;
58.167 + }
58.168 +
58.169 + java.util.StringTokenizer tokenizer = new StringTokenizer(value, " ");
58.170 + StringBuffer result = new StringBuffer();
58.171 +
58.172 + while (tokenizer.hasMoreTokens()) {
58.173 + StringBuffer word = new StringBuffer(tokenizer.nextToken());
58.174 +
58.175 + // upper case first character
58.176 + word.replace(0, 1, word.substring(0, 1).toUpperCase());
58.177 +
58.178 + if (!tokenizer.hasMoreTokens()) {
58.179 + result.append(word);
58.180 + } else {
58.181 + result.append(word + " ");
58.182 + }
58.183 + }
58.184 +
58.185 + return result.toString();
58.186 + }
58.187 +
58.188 + /**
58.189 + * Capitalize an identifier - i.e. Convert something like "purchaseOrder" to "Purchase Order"
58.190 + * or "PURCHASE_ORDER" to "Purchase Order"
58.191 + *
58.192 + * @param value - The identifier to capitalize - e.g. "purchaseOrder" or "PURCHASE_ORDER".
58.193 + * @return The capitalized identifier - e.g. "Purchase Order".
58.194 + */
58.195 + public static String capitalizeIdentifier(String value) {
58.196 + if (value == null) {
58.197 + return null;
58.198 + }
58.199 +
58.200 + // if the word is all upper case, then set to lower case and continue
58.201 + if (value.equals(value.toUpperCase())) {
58.202 + value = value.toLowerCase();
58.203 + }
58.204 +
58.205 + java.util.StringTokenizer tokenizer = new StringTokenizer(value, "ABCDEFGHIJKLMNOPQRSTUVWXYZ_", true);
58.206 + StringBuffer result = new StringBuffer();
58.207 +
58.208 + while (tokenizer.hasMoreTokens()) {
58.209 + String word = tokenizer.nextToken();
58.210 +
58.211 + if ((word.equals(word.toUpperCase())) || (!tokenizer.hasMoreTokens())) {
58.212 + if (!word.equals("_")) {
58.213 + result.append(word);
58.214 + }
58.215 + } else {
58.216 + result.append(word + " ");
58.217 + }
58.218 + }
58.219 +
58.220 + // upper case the first character
58.221 + //
58.222 + return capitalize(result.toString());
58.223 + }
58.224 +
58.225 + /**
58.226 + * __UNDOCUMENTED__
58.227 + *
58.228 + * @param haystack __UNDOCUMENTED__
58.229 + * @param needle __UNDOCUMENTED__
58.230 + * @return __UNDOCUMENTED__
58.231 + */
58.232 + public static Boolean endsWith(String haystack, String needle) {
58.233 + if ((haystack != null) && (needle != null)) {
58.234 + return new Boolean(haystack.endsWith(needle));
58.235 + }
58.236 +
58.237 + return Boolean.FALSE;
58.238 + }
58.239 +
58.240 + /**
58.241 + * scans a string and replaces all occurances of a given pattern with a
58.242 + * replacement string. Thus replacePattern("hello world!", "o w",
58.243 + * "o/w"); result in "hello/world".
58.244 + */
58.245 + public static String replacePattern(String original, String pattern, String replacement) {
58.246 + StringTokenizer strtok = new StringTokenizer(original, pattern, true);
58.247 + StringBuffer result = new StringBuffer();
58.248 +
58.249 + if (replacement == null) {
58.250 + replacement = "";
58.251 + }
58.252 +
58.253 + while (strtok.hasMoreTokens()) {
58.254 + String token = strtok.nextToken();
58.255 +
58.256 + if (token.equals(pattern)) {
58.257 + result.append(replacement);
58.258 + } else {
58.259 + result.append(token);
58.260 + }
58.261 + }
58.262 +
58.263 + return result.toString();
58.264 + }
58.265 +
58.266 + /**
58.267 + * __UNDOCUMENTED__
58.268 + *
58.269 + * @param str __UNDOCUMENTED__
58.270 + * @return __UNDOCUMENTED__
58.271 + */
58.272 + public static String toLowercase(String str) {
58.273 + return (str != null)
58.274 + ? str.toLowerCase()
58.275 + : null;
58.276 + }
58.277 +
58.278 + /**
58.279 + * __UNDOCUMENTED__
58.280 + *
58.281 + * @param str __UNDOCUMENTED__
58.282 + * @return __UNDOCUMENTED__
58.283 + */
58.284 + public static String toUppercase(String str) {
58.285 + return (str != null)
58.286 + ? str.toUpperCase()
58.287 + : null;
58.288 + }
58.289 +
58.290 + /* $Id$ */
58.291 + public static String trim(String str) {
58.292 + return (str != null)
58.293 + ? str.trim()
58.294 + : null;
58.295 + }
58.296 +
58.297 + /**
58.298 + * returns the value of the first parameter if set, otherwise a default value
58.299 + */
58.300 + public static String valueOf(String first, String defaultstr) {
58.301 + if ((first != null) && (first.length() > 0)) {
58.302 + return first;
58.303 + }
58.304 +
58.305 + return defaultstr;
58.306 + }
58.307 +}
58.308 +
58.309 +
58.310 +/*
58.311 + $Log$
58.312 + Revision 1.1 2007/04/26 02:34:13 mwu
58.313 + move workflow to the new location, add xform, xml instance generation
58.314 +
58.315 + Revision 1.1 2006/06/14 14:12:50 unl
58.316 + - cleanup
58.317 +
58.318 + Revision 1.6 2006/03/16 09:36:28 joernt
58.319 + fixed Copyright
58.320 +
58.321 + Revision 1.5 2005/01/31 22:49:35 joernt
58.322 + added copyright notice
58.323 +
58.324 + Revision 1.4 2004/08/15 14:14:08 joernt
58.325 + preparing release...
58.326 + -reformatted sources to fix mixture of tabs and spaces
58.327 + -optimized imports on all files
58.328 +
58.329 + Revision 1.3 2003/10/02 15:15:50 joernt
58.330 + applied chiba jalopy settings to whole src tree
58.331 +
58.332 + Revision 1.2 2003/10/01 23:44:59 joernt
58.333 + fixed javadoc issues
58.334 + Revision 1.1.1.1 2003/05/23 14:54:06 unl
58.335 + no message
58.336 + Revision 1.3 2002/12/11 14:49:30 soframel
58.337 + added 2 methods in StringUtil (from chiba2 "StringUtils").
58.338 + added an ant task for the schema generator
58.339 + Revision 1.2 2001/09/26 09:39:19 gregor
58.340 + added a replacePattern method
58.341 + Revision 1.1 2001/09/20 18:31:59 gregor
58.342 + added (contains code for stylesheets extensions)
58.343 + */
59.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
59.2 +++ b/enterprise/openesbaddons/workflow/project/chiba_src/org/chiba/tools/schemabuilder/TypeExtensionSorter.java Thu Apr 26 02:33:27 2007 +0000
59.3 @@ -0,0 +1,68 @@
59.4 +// Copyright 2006 Chibacon
59.5 +
59.6 +/*
59.7 + * TypeExtensionSorter.java
59.8 + *
59.9 + * Created on 24 March 2004, 09:02
59.10 + */
59.11 +
59.12 +package org.chiba.tools.schemabuilder;
59.13 +
59.14 +import org.apache.log4j.Category;
59.15 +import com.sun.org.apache.xerces.internal.xs.*;
59.16 +
59.17 +import java.util.Comparator;
59.18 +
59.19 +/**
59.20 + * @author sof
59.21 + * @deprecated
59.22 + */
59.23 +public class TypeExtensionSorter implements Comparator {
59.24 + private static Category LOGGER = SchemaFormBuilder.LOGGER;
59.25 +
59.26 + private static TypeExtensionSorter instance;
59.27 +
59.28 + static {
59.29 + instance = new TypeExtensionSorter();
59.30 + }
59.31 +
59.32 + public static TypeExtensionSorter getInstance() {
59.33 + return instance;
59.34 + }
59.35 +
59.36 + /**
59.37 + * Creates a new instance of TypeExtensionSorter
59.38 + */
59.39 + private TypeExtensionSorter() {
59.40 + }
59.41 +
59.42 + public int compare(Object obj1, Object obj2) {
59.43 + if (obj1 == null && obj2 != null)
59.44 + return -1;
59.45 + else if (obj1 != null && obj2 == null)
59.46 + return 1;
59.47 + else if (obj1 == null && obj2 == null)
59.48 + return 0;
59.49 + else if (obj1 == obj2)
59.50 + return 0;
59.51 + else {
59.52 + try {
59.53 + XSTypeDefinition type1 = (XSTypeDefinition) obj1;
59.54 + XSTypeDefinition type2 = (XSTypeDefinition) obj2;
59.55 +
59.56 + if (type1.derivedFromType(type2, XSConstants.DERIVATION_EXTENSION))
59.57 + return 1;
59.58 + else if (type2.derivedFromType(type1, XSConstants.DERIVATION_EXTENSION))
59.59 + return -1;
59.60 + else
59.61 + return 0;
59.62 + } catch (java.lang.ClassCastException ex) {
59.63 + String s = "ClassCastException in TypeExtensionSorter: one of the types is not a type !";
59.64 + s = s + "\n obj1 class = " + obj1.getClass().getName() + ", toString=" + obj1.toString();
59.65 + s = s + "\n obj2 class = " + obj2.getClass().getName() + ", toString=" + obj2.toString();
59.66 + LOGGER.error(s, ex);
59.67 + return 0;
59.68 + }
59.69 + }
59.70 + }
59.71 +}
60.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
60.2 +++ b/enterprise/openesbaddons/workflow/project/chiba_src/org/chiba/tools/schemabuilder/WrapperElementsBuilder.java Thu Apr 26 02:33:27 2007 +0000
60.3 @@ -0,0 +1,150 @@
60.4 +// Copyright 2006 Chibacon
60.5 +/*
60.6 + *
60.7 + * Artistic License
60.8 + *
60.9 + * Preamble
60.10 + *
60.11 + * The intent of this document is to state the conditions under which a Package may be copied, such that
60.12 + * the Copyright Holder maintains some semblance of artistic control over the development of the
60.13 + * package, while giving the users of the package the right to use and distribute the Package in a
60.14 + * more-or-less customary fashion, plus the right to make reasonable modifications.
60.15 + *
60.16 + * Definitions:
60.17 + *
60.18 + * "Package" refers to the collection of files distributed by the Copyright Holder, and derivatives
60.19 + * of that collection of files created through textual modification.
60.20 + *
60.21 + * "Standard Version" refers to such a Package if it has not been modified, or has been modified
60.22 + * in accordance with the wishes of the Copyright Holder.
60.23 + *
60.24 + * "Copyright Holder" is whoever is named in the copyright or copyrights for the package.
60.25 + *
60.26 + * "You" is you, if you're thinking about copying or distributing this Package.
60.27 + *
60.28 + * "Reasonable copying fee" is whatever you can justify on the basis of media cost, duplication
60.29 + * charges, time of people involved, and so on. (You will not be required to justify it to the
60.30 + * Copyright Holder, but only to the computing community at large as a market that must bear the
60.31 + * fee.)
60.32 + *
60.33 + * "Freely Available" means that no fee is charged for the item itself, though there may be fees
60.34 + * involved in handling the item. It also means that recipients of the item may redistribute it under
60.35 + * the same conditions they received it.
60.36 + *
60.37 + * 1. You may make and give away verbatim copies of the source form of the Standard Version of this
60.38 + * Package without restriction, provided that you duplicate all of the original copyright notices and
60.39 + * associated disclaimers.
60.40 + *
60.41 + * 2. You may apply bug fixes, portability fixes and other modifications derived from the Public Domain
60.42 + * or from the Copyright Holder. A Package modified in such a way shall still be considered the
60.43 + * Standard Version.
60.44 + *
60.45 + * 3. You may otherwise modify your copy of this Package in any way, provided that you insert a
60.46 + * prominent notice in each changed file stating how and when you changed that file, and provided that
60.47 + * you do at least ONE of the following:
60.48 + *
60.49 + * a) place your modifications in the Public Domain or otherwise make them Freely
60.50 + * Available, such as by posting said modifications to Usenet or an equivalent medium, or
60.51 + * placing the modifications on a major archive site such as ftp.uu.net, or by allowing the
60.52 + * Copyright Holder to include your modifications in the Standard Version of the Package.
60.53 + *
60.54 + * b) use the modified Package only within your corporation or organization.
60.55 + *
60.56 + * c) rename any non-standard executables so the names do not conflict with standard
60.57 + * executables, which must also be provided, and provide a separate manual page for each
60.58 + * non-standard executable that clearly documents how it differs from the Standard
60.59 + * Version.
60.60 + *
60.61 + * d) make other distribution arrangements with the Copyright Holder.
60.62 + *
60.63 + * 4. You may distribute the programs of this Package in object code or executable form, provided that
60.64 + * you do at least ONE of the following:
60.65 + *
60.66 + * a) distribute a Standard Version of the executables and library files, together with
60.67 + * instructions (in the manual page or equivalent) on where to get the Standard Version.
60.68 + *
60.69 + * b) accompany the distribution with the machine-readable source of the Package with
60.70 + * your modifications.
60.71 + *
60.72 + * c) accompany any non-standard executables with their corresponding Standard Version
60.73 + * executables, giving the non-standard executables non-standard names, and clearly
60.74 + * documenting the differences in manual pages (or equivalent), together with instructions
60.75 + * on where to get the Standard Version.
60.76 + *
60.77 + * d) make other distribution arrangements with the Copyright Holder.
60.78 + *
60.79 + * 5. You may charge a reasonable copying fee for any distribution of this Package. You may charge
60.80 + * any fee you choose for support of this Package. You may not charge a fee for this Package itself.
60.81 + * However, you may distribute this Package in aggregate with other (possibly commercial) programs as
60.82 + * part of a larger (possibly commercial) software distribution provided that you do not advertise this
60.83 + * Package as a product of your own.
60.84 + *
60.85 + * 6. The scripts and library files supplied as input to or produced as output from the programs of this
60.86 + * Package do not automatically fall under the copyright of this Package, but belong to whomever
60.87 + * generated them, and may be sold commercially, and may be aggregated with this Package.
60.88 + *
60.89 + * 7. C or perl subroutines supplied by you and linked into this Package shall not be considered part of
60.90 + * this Package.
60.91 + *
60.92 + * 8. The name of the Copyright Holder may not be used to endorse or promote products derived from
60.93 + * this software without specific prior written permission.
60.94 + *
60.95 + * 9. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
60.96 + * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
60.97 + * MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
60.98 + *
60.99 + */
60.100 +package org.chiba.tools.schemabuilder;
60.101 +
60.102 +import org.w3c.dom.Document;
60.103 +import org.w3c.dom.Element;
60.104 +
60.105 +/**
60.106 + * This interface provides methods to create the "wrappers" elements that will contain the XForms document.
60.107 + * These elements can be:
60.108 + * - the first "enveloppe" element
60.109 + * - other elements specific to a destination language or platform (ex: XHTML tags)
60.110 + *
60.111 + * @author Sophie Ramel
60.112 + * @deprecated
60.113 + */
60.114 +public interface WrapperElementsBuilder {
60.115 + /**
60.116 + * create the wrapper element of the form (exemple_ "body" for HTML)
60.117 + *
60.118 + * @param enveloppeElement the containing enveloppe
60.119 + * @return the wrapper element, already added in the enveloppe
60.120 + */
60.121 + public Element createFormWrapper(Element enveloppeElement);
60.122 +
60.123 + /**
60.124 + * create the wrapper element of the different controls
60.125 + *
60.126 + * @param controlElement the control element (input, select, repeat, group, ...)
60.127 + * @return the wrapper element, already containing the control element
60.128 + */
60.129 + public Element createControlsWrapper(Element controlElement);
60.130 +
60.131 + /**
60.132 + * creates the global enveloppe of the resulting document, and puts it in the document
60.133 + *
60.134 + * @return the enveloppe
60.135 + */
60.136 + public Element createEnvelope(Document xForm);
60.137 +
60.138 + /**
60.139 + * create the element that will contain the content of the group (or repeat) element
60.140 + *
60.141 + * @param groupElement the group or repeat element
60.142 + * @return - the wrapper element, already containing the content of the group element
60.143 + */
60.144 + public Element createGroupContentWrapper(Element groupElement);
60.145 +
60.146 + /**
60.147 + * create the wrapper element of the xforms:model element
60.148 + *
60.149 + * @param modelElement the xforms:model element
60.150 + * @return - the wrapper element, already containing the model
60.151 + */
60.152 + public Element createModelWrapper(Element modelElement);
60.153 +}
61.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
61.2 +++ b/enterprise/openesbaddons/workflow/project/chiba_src/org/chiba/tools/schemabuilder/XHTMLWrapperElementsBuilder.java Thu Apr 26 02:33:27 2007 +0000
61.3 @@ -0,0 +1,332 @@
61.4 +// Copyright 2006 Chibacon
61.5 +
61.6 +/*
61.7 + *
61.8 + * Artistic License
61.9 + *
61.10 + * Preamble
61.11 + *
61.12 + * The intent of this document is to state the conditions under which a Package may be copied, such that
61.13 + * the Copyright Holder maintains some semblance of artistic control over the development of the
61.14 + * package, while giving the users of the package the right to use and distribute the Package in a
61.15 + * more-or-less customary fashion, plus the right to make reasonable modifications.
61.16 + *
61.17 + * Definitions:
61.18 + *
61.19 + * "Package" refers to the collection of files distributed by the Copyright Holder, and derivatives
61.20 + * of that collection of files created through textual modification.
61.21 + *
61.22 + * "Standard Version" refers to such a Package if it has not been modified, or has been modified
61.23 + * in accordance with the wishes of the Copyright Holder.
61.24 + *
61.25 + * "Copyright Holder" is whoever is named in the copyright or copyrights for the package.
61.26 + *
61.27 + * "You" is you, if you're thinking about copying or distributing this Package.
61.28 + *
61.29 + * "Reasonable copying fee" is whatever you can justify on the basis of media cost, duplication
61.30 + * charges, time of people involved, and so on. (You will not be required to justify it to the
61.31 + * Copyright Holder, but only to the computing community at large as a market that must bear the
61.32 + * fee.)
61.33 + *
61.34 + * "Freely Available" means that no fee is charged for the item itself, though there may be fees
61.35 + * involved in handling the item. It also means that recipients of the item may redistribute it under
61.36 + * the same conditions they received it.
61.37 + *
61.38 + * 1. You may make and give away verbatim copies of the source form of the Standard Version of this
61.39 + * Package without restriction, provided that you duplicate all of the original copyright notices and
61.40 + * associated disclaimers.
61.41 + *
61.42 + * 2. You may apply bug fixes, portability fixes and other modifications derived from the Public Domain
61.43 + * or from the Copyright Holder. A Package modified in such a way shall still be considered the
61.44 + * Standard Version.
61.45 + *
61.46 + * 3. You may otherwise modify your copy of this Package in any way, provided that you insert a
61.47 + * prominent notice in each changed file stating how and when you changed that file, and provided that
61.48 + * you do at least ONE of the following:
61.49 + *
61.50 + * a) place your modifications in the Public Domain or otherwise make them Freely
61.51 + * Available, such as by posting said modifications to Usenet or an equivalent medium, or
61.52 + * placing the modifications on a major archive site such as ftp.uu.net, or by allowing the
61.53 + * Copyright Holder to include your modifications in the Standard Version of the Package.
61.54 + *
61.55 + * b) use the modified Package only within your corporation or organization.
61.56 + *
61.57 + * c) rename any non-standard executables so the names do not conflict with standard
61.58 + * executables, which must also be provided, and provide a separate manual page for each
61.59 + * non-standard executable that clearly documents how it differs from the Standard
61.60 + * Version.
61.61 + *
61.62 + * d) make other distribution arrangements with the Copyright Holder.
61.63 + *
61.64 + * 4. You may distribute the programs of this Package in object code or executable form, provided that
61.65 + * you do at least ONE of the following:
61.66 + *
61.67 + * a) distribute a Standard Version of the executables and library files, together with
61.68 + * instructions (in the manual page or equivalent) on where to get the Standard Version.
61.69 + *
61.70 + * b) accompany the distribution with the machine-readable source of the Package with
61.71 + * your modifications.
61.72 + *
61.73 + * c) accompany any non-standard executables with their corresponding Standard Version
61.74 + * executables, giving the non-standard executables non-standard names, and clearly
61.75 + * documenting the differences in manual pages (or equivalent), together with instructions
61.76 + * on where to get the Standard Version.
61.77 + *
61.78 + * d) make other distribution arrangements with the Copyright Holder.
61.79 + *
61.80 + * 5. You may charge a reasonable copying fee for any distribution of this Package. You may charge
61.81 + * any fee you choose for support of this Package. You may not charge a fee for this Package itself.
61.82 + * However, you may distribute this Package in aggregate with other (possibly commercial) programs as
61.83 + * part of a larger (possibly commercial) software distribution provided that you do not advertise this
61.84 + * Package as a product of your own.
61.85 + *
61.86 + * 6. The scripts and library files supplied as input to or produced as output from the programs of this
61.87 + * Package do not automatically fall under the copyright of this Package, but belong to whomever
61.88 + * generated them, and may be sold commercially, and may be aggregated with this Package.
61.89 + *
61.90 + * 7. C or perl subroutines supplied by you and linked into this Package shall not be considered part of
61.91 + * this Package.
61.92 + *
61.93 + * 8. The name of the Copyright Holder may not be used to endorse or promote products derived from
61.94 + * this software without specific prior written permission.
61.95 + *
61.96 + * 9. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
61.97 + * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
61.98 + * MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
61.99 + *
61.100 + */
61.101 +package org.chiba.tools.schemabuilder;
61.102 +
61.103 +import org.w3c.dom.Document;
61.104 +import org.w3c.dom.Element;
61.105 +import org.w3c.dom.Text;
61.106 +
61.107 +import java.util.Enumeration;
61.108 +import java.util.Hashtable;
61.109 +import java.util.Iterator;
61.110 +import java.util.Vector;
61.111 +
61.112 +/**
61.113 + * XHTML implementation of WrapperElementsBuilder: allows to wrap the XForm document in XHTML tags.
61.114 + *
61.115 + * @author Sophie Ramel
61.116 + * @deprecated
61.117 + */
61.118 +public class XHTMLWrapperElementsBuilder implements WrapperElementsBuilder {
61.119 +
61.120 + private final static String XHTML_NS = "http://www.w3.org/1999/xhtml";
61.121 + private final static String XHTML_PREFIX = "html";
61.122 +
61.123 + private String title;
61.124 + private Vector links;
61.125 + private Vector meta;
61.126 + private Hashtable namespaces;
61.127 +
61.128 + /**
61.129 + * Creates a new instance of XHTMLWrapperElementsBuilder
61.130 + */
61.131 + public XHTMLWrapperElementsBuilder() {
61.132 + meta = new Vector();
61.133 + links = new Vector();
61.134 + namespaces = new Hashtable();
61.135 + }
61.136 +
61.137 + /**
61.138 + * add a tag "title" in the header of the HTML document
61.139 + */
61.140 + public void setTitle(String title) {
61.141 + this.title = title;
61.142 + }
61.143 +
61.144 + /**
61.145 + * add a tag "link" in the header of the HTML document
61.146 + *
61.147 + * @param href the "href" parameter of the "link" tag
61.148 + * @param type the "type" parameter of the "link" tag
61.149 + * @param rel the "rel" parameter of the "link" tag
61.150 + */
61.151 + public void addLink(String href, String type, String rel) {
61.152 + String[] l = new String[3];
61.153 + l[0] = href;
61.154 + l[1] = type;
61.155 + l[2] = rel;
61.156 + links.add(l);
61.157 + }
61.158 +
61.159 + /**
61.160 + * add a tag "meta" in the header of the HTML document
61.161 + *
61.162 + * @param http_equiv the "http-equiv" parameter of the "META" tag
61.163 + * @param name the "name" parameter of the "META" tag
61.164 + * @param content the "content" parameter of the "META" tag
61.165 + * @param scheme the "scheme" parameter of the "META" tag
61.166 + */
61.167 + public void addMeta(String http_equiv,
61.168 + String name,
61.169 + String content,
61.170 + String scheme) {
61.171 + String[] s = new String[4];
61.172 + s[0] = http_equiv;
61.173 + s[1] = name;
61.174 + s[2] = content;
61.175 + s[3] = scheme;
61.176 + meta.add(s);
61.177 + }
61.178 +
61.179 + public void addNamespaceDeclaration(String prefix, String url) {
61.180 + namespaces.put(prefix, url);
61.181 + }
61.182 +
61.183 + /**
61.184 + * create the wrapper element of the different controls
61.185 + *
61.186 + * @param controlElement the control element (input, select, repeat, group, ...)
61.187 + * @return the wrapper element, already containing the control element
61.188 + */
61.189 + public Element createControlsWrapper(Element controlElement) {
61.190 + /*Document doc=controlElement.getOwnerDocument();
61.191 + Element tr=doc.createElement("tr");
61.192 + Element td=doc.createElement("td");
61.193 + tr.appendChild(td);
61.194 + td.appendChild(controlElement);
61.195 + return tr;*/
61.196 + return controlElement;
61.197 + }
61.198 +
61.199 + /**
61.200 + * creates the global enveloppe of the resulting document, and puts it in the document
61.201 + *
61.202 + * @return the enveloppe
61.203 + */
61.204 + public Element createEnvelope(Document doc) {
61.205 + Element html = doc.createElementNS(XHTML_NS, XHTML_PREFIX + ":html");
61.206 + //set namespace attribute
61.207 + html.setAttributeNS(SchemaFormBuilder.XMLNS_NAMESPACE_URI,
61.208 + "xmlns:" + XHTML_PREFIX,
61.209 + XHTMLWrapperElementsBuilder.XHTML_NS);
61.210 + doc.appendChild(html);
61.211 +
61.212 + //other namespaces
61.213 + Enumeration enumeration = namespaces.keys();
61.214 + while (enumeration.hasMoreElements()) {
61.215 + String prefix = (String) enumeration.nextElement();
61.216 + String ns = (String) namespaces.get(prefix);
61.217 + html.setAttributeNS(SchemaFormBuilder.XMLNS_NAMESPACE_URI,
61.218 + "xmlns:" + prefix,
61.219 + ns);
61.220 +
61.221 + }
61.222 +
61.223 + return html;
61.224 + }
61.225 +
61.226 + /**
61.227 + * create the element that will contain the content of the group (or repeat) element
61.228 + *
61.229 + * @param groupElement the group or repeat element
61.230 + * @return the wrapper element
61.231 + */
61.232 + public Element createGroupContentWrapper(Element groupElement) {
61.233 + /*Document doc=groupElement.getOwnerDocument();
61.234 + Element table=doc.createElement("table");
61.235 + groupElement.appendChild(table);
61.236 + return table;*/
61.237 + return groupElement;
61.238 + }
61.239 +
61.240 + /**
61.241 + * create the wrapper element of the form
61.242 + *
61.243 + * @param enveloppeElement the form element (chiba:form or other)
61.244 + * @return the wrapper element
61.245 + */
61.246 +
61.247 + public Element createFormWrapper(Element enveloppeElement) {
61.248 + Document doc = enveloppeElement.getOwnerDocument();
61.249 + Element body = doc.createElementNS(XHTML_NS, XHTML_PREFIX + ":body");
61.250 + //body.appendChild(formElement);
61.251 + enveloppeElement.appendChild(body);
61.252 + return body;
61.253 + }
61.254 +
61.255 + /**
61.256 + * create the wrapper element of the xforms:model element
61.257 + *
61.258 + * @param modelElement the xforms:model element
61.259 + * @return the wrapper element, already containing the model
61.260 + */
61.261 + public Element createModelWrapper(Element modelElement) {
61.262 + Document doc = modelElement.getOwnerDocument();
61.263 + Element head = doc.createElementNS(XHTML_NS, XHTML_PREFIX + ":head");
61.264 + head.appendChild(modelElement);
61.265 +
61.266 + //eventually add other info
61.267 + if ((title != null) && !title.equals("")) {
61.268 + Element title_el = doc.createElementNS(XHTML_NS, XHTML_PREFIX + ":title");
61.269 + Text title_text = doc.createTextNode(title);
61.270 + title_el.appendChild(title_text);
61.271 + head.appendChild(title_el);
61.272 + }
61.273 +
61.274 + if ((meta != null) && !meta.isEmpty()) {
61.275 + Iterator it = meta.iterator();
61.276 +
61.277 + while (it.hasNext()) {
61.278 + String[] m = (String[]) it.next();
61.279 + String http_equiv = m[0];
61.280 + String name = m[1];
61.281 + String content = m[2];
61.282 + String scheme = m[3];
61.283 +
61.284 + Element meta_el = doc.createElementNS(XHTML_NS, XHTML_PREFIX + ":META");
61.285 + head.appendChild(meta_el);
61.286 +
61.287 + //attributes
61.288 + if ((http_equiv != null) && !http_equiv.equals("")) {
61.289 + meta_el.setAttributeNS(XHTML_NS, XHTML_PREFIX + ":http-equiv", http_equiv);
61.290 + }
61.291 +
61.292 + if ((name != null) && !name.equals("")) {
61.293 + meta_el.setAttributeNS(XHTML_NS, XHTML_PREFIX + ":name", name);
61.294 + }
61.295 +
61.296 + if ((content != null) && !content.equals("")) {
61.297 + meta_el.setAttributeNS(XHTML_NS, XHTML_PREFIX + ":content", content);
61.298 + }
61.299 +
61.300 + if ((scheme != null) && !scheme.equals("")) {
61.301 + meta_el.setAttributeNS(XHTML_NS, XHTML_PREFIX + ":scheme", scheme);
61.302 + }
61.303 + }
61.304 + }
61.305 +
61.306 + if ((links != null) && !links.isEmpty()) {
61.307 + Iterator it = links.iterator();
61.308 +
61.309 + while (it.hasNext()) {
61.310 + String[] l = (String[]) it.next();
61.311 + String href = l[0];
61.312 + String type = l[1];
61.313 + String rel = l[2];
61.314 +
61.315 + Element link_el = doc.createElementNS(XHTML_NS, XHTML_PREFIX + ":LINK");
61.316 + head.appendChild(link_el);
61.317 +
61.318 + //attributes
61.319 + if ((href != null) && !href.equals("")) {
61.320 + link_el.setAttributeNS(XHTML_NS, XHTML_PREFIX + ":href", href);
61.321 + }
61.322 +
61.323 + if ((type != null) && !type.equals("")) {
61.324 + link_el.setAttributeNS(XHTML_NS, XHTML_PREFIX + ":type", type);
61.325 + }
61.326 +
61.327 + if ((rel != null) && !rel.equals("")) {
61.328 + link_el.setAttributeNS(XHTML_NS, XHTML_PREFIX + ":rel", rel);
61.329 + }
61.330 + }
61.331 + }
61.332 +
61.333 + return head;
61.334 + }
61.335 +}
62.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
62.2 +++ b/enterprise/openesbaddons/workflow/project/chiba_src/org/chiba/xml/dom/DOMComparator.java Thu Apr 26 02:33:27 2007 +0000
62.3 @@ -0,0 +1,578 @@
62.4 +// Copyright 2006 Chibacon
62.5 +/*
62.6 + *
62.7 + * Artistic License
62.8 + *
62.9 + * Preamble
62.10 + *
62.11 + * The intent of this document is to state the conditions under which a Package may be copied, such that
62.12 + * the Copyright Holder maintains some semblance of artistic control over the development of the
62.13 + * package, while giving the users of the package the right to use and distribute the Package in a
62.14 + * more-or-less customary fashion, plus the right to make reasonable modifications.
62.15 + *
62.16 + * Definitions:
62.17 + *
62.18 + * "Package" refers to the collection of files distributed by the Copyright Holder, and derivatives
62.19 + * of that collection of files created through textual modification.
62.20 + *
62.21 + * "Standard Version" refers to such a Package if it has not been modified, or has been modified
62.22 + * in accordance with the wishes of the Copyright Holder.
62.23 + *
62.24 + * "Copyright Holder" is whoever is named in the copyright or copyrights for the package.
62.25 + *
62.26 + * "You" is you, if you're thinking about copying or distributing this Package.
62.27 + *
62.28 + * "Reasonable copying fee" is whatever you can justify on the basis of media cost, duplication
62.29 + * charges, time of people involved, and so on. (You will not be required to justify it to the
62.30 + * Copyright Holder, but only to the computing community at large as a market that must bear the
62.31 + * fee.)
62.32 + *
62.33 + * "Freely Available" means that no fee is charged for the item itself, though there may be fees
62.34 + * involved in handling the item. It also means that recipients of the item may redistribute it under
62.35 + * the same conditions they received it.
62.36 + *
62.37 + * 1. You may make and give away verbatim copies of the source form of the Standard Version of this
62.38 + * Package without restriction, provided that you duplicate all of the original copyright notices and
62.39 + * associated disclaimers.
62.40 + *
62.41 + * 2. You may apply bug fixes, portability fixes and other modifications derived from the Public Domain
62.42 + * or from the Copyright Holder. A Package modified in such a way shall still be considered the
62.43 + * Standard Version.
62.44 + *
62.45 + * 3. You may otherwise modify your copy of this Package in any way, provided that you insert a
62.46 + * prominent notice in each changed file stating how and when you changed that file, and provided that
62.47 + * you do at least ONE of the following:
62.48 + *
62.49 + * a) place your modifications in the Public Domain or otherwise make them Freely
62.50 + * Available, such as by posting said modifications to Usenet or an equivalent medium, or
62.51 + * placing the modifications on a major archive site such as ftp.uu.net, or by allowing the
62.52 + * Copyright Holder to include your modifications in the Standard Version of the Package.
62.53 + *
62.54 + * b) use the modified Package only within your corporation or organization.
62.55 + *
62.56 + * c) rename any non-standard executables so the names do not conflict with standard
62.57 + * executables, which must also be provided, and provide a separate manual page for each
62.58 + * non-standard executable that clearly documents how it differs from the Standard
62.59 + * Version.
62.60 + *
62.61 + * d) make other distribution arrangements with the Copyright Holder.
62.62 + *
62.63 + * 4. You may distribute the programs of this Package in object code or executable form, provided that
62.64 + * you do at least ONE of the following:
62.65 + *
62.66 + * a) distribute a Standard Version of the executables and library files, together with
62.67 + * instructions (in the manual page or equivalent) on where to get the Standard Version.
62.68 + *
62.69 + * b) accompany the distribution with the machine-readable source of the Package with
62.70 + * your modifications.
62.71 + *
62.72 + * c) accompany any non-standard executables with their corresponding Standard Version
62.73 + * executables, giving the non-standard executables non-standard names, and clearly
62.74 + * documenting the differences in manual pages (or equivalent), together with instructions
62.75 + * on where to get the Standard Version.
62.76 + *
62.77 + * d) make other distribution arrangements with the Copyright Holder.
62.78 + *
62.79 + * 5. You may charge a reasonable copying fee for any distribution of this Package. You may charge
62.80 + * any fee you choose for support of this Package. You may not charge a fee for this Package itself.
62.81 + * However, you may distribute this Package in aggregate with other (possibly commercial) programs as
62.82 + * part of a larger (possibly commercial) software distribution provided that you do not advertise this
62.83 + * Package as a product of your own.
62.84 + *
62.85 + * 6. The scripts and library files supplied as input to or produced as output from the programs of this
62.86 + * Package do not automatically fall under the copyright of this Package, but belong to whomever
62.87 + * generated them, and may be sold commercially, and may be aggregated with this Package.
62.88 + *
62.89 + * 7. C or perl subroutines supplied by you and linked into this Package shall not be considered part of
62.90 + * this Package.
62.91 + *
62.92 + * 8. The name of the Copyright Holder may not be used to endorse or promote products derived from
62.93 + * this software without specific prior written permission.
62.94 + *
62.95 + * 9. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
62.96 + * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
62.97 + * MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
62.98 + *
62.99 + */
62.100 +package org.chiba.xml.dom;
62.101 +
62.102 +import org.chiba.xml.ns.NamespaceConstants;
62.103 +import org.w3c.dom.NamedNodeMap;
62.104 +import org.w3c.dom.Node;
62.105 +import org.w3c.dom.NodeList;
62.106 +
62.107 +/**
62.108 + * The DOM Comparator provides a set of comparison methods to check wether
62.109 + * two arbitrary DOM nodes may be considered equal. This may be helpful in
62.110 + * testing as well as in editing environments.
62.111 + * <P>
62.112 + * The comparison behaviour is controllable according to whitespace and
62.113 + * namespaces. By default, the comparator ignores any whitespace outside
62.114 + * element content and is aware of namespaces.
62.115 + * <P>
62.116 + * <EM>NOTE:</EM> It is strongly recommended to normalize the nodes to be
62.117 + * compared <I>before</I> comparison by calling the <CODE>Node.normalize()</CODE>.
62.118 + * Since that method may affect changes in the DOM tree, the comparator won't
62.119 + * do this to be non-intrusive.
62.120 + *
62.121 + * @author Ulrich Nicolas Lissé
62.122 + * @version $Id$
62.123 + */
62.124 +public class DOMComparator {
62.125 +
62.126 + /**
62.127 + * Feature <CODE>ignore-comments</CODE>.
62.128 + */
62.129 + private boolean ignoreComments = false;
62.130 +
62.131 + /**
62.132 + * Feature <CODE>ignore-namespace-declarations</CODE>.
62.133 + */
62.134 + private boolean ignoreNamespaceDeclarations = false;
62.135 +
62.136 + /**
62.137 + * Feature <CODE>ignore-whitespace</CODE>.
62.138 + */
62.139 + private boolean ignoreWhitespace = true;
62.140 +
62.141 + /**
62.142 + * Feature <CODE>namespace-aware</CODE>.
62.143 + */
62.144 + private boolean namespaceAware = true;
62.145 +
62.146 + /**
62.147 + * The error handler.
62.148 + */
62.149 + private ErrorHandler errorHandler = new DefaultErrorHandler();
62.150 +
62.151 + /**
62.152 + * Constructs an empty DOM Comparator.
62.153 + */
62.154 + public DOMComparator() {
62.155 + }
62.156 +
62.157 + // Behaviour control.
62.158 +
62.159 + /**
62.160 + * Sets the state of comment ignoring.
62.161 + *
62.162 + * @param state the state of comment ignoring.
62.163 + */
62.164 + public void setIgnoreComments(boolean state) {
62.165 + this.ignoreComments = state;
62.166 + }
62.167 +
62.168 + /**
62.169 + * Sets the state of namespace declaration ignoring.
62.170 + *
62.171 + * @param state the state of namespace declaration ignoring.
62.172 + */
62.173 + public void setIgnoreNamespaceDeclarations(boolean state) {
62.174 + this.ignoreNamespaceDeclarations = state;
62.175 + }
62.176 +
62.177 + /**
62.178 + * Sets the state of whitespace ignoring.
62.179 + *
62.180 + * @param state the state of whitespace ignoring.
62.181 + */
62.182 + public void setIgnoreWhitespace(boolean state) {
62.183 + this.ignoreWhitespace = state;
62.184 + }
62.185 +
62.186 + /**
62.187 + * Sets the state of namespace awareness.
62.188 + *
62.189 + * @param state the state of namespace awareness.
62.190 + */
62.191 + public void setNamespaceAware(boolean state) {
62.192 + this.namespaceAware = state;
62.193 + }
62.194 +
62.195 + /**
62.196 + * Sets the error handler.
62.197 + *
62.198 + * @param errorHandler the error handler.
62.199 + */
62.200 + public void setErrorHandler(ErrorHandler errorHandler) {
62.201 + this.errorHandler = errorHandler;
62.202 +
62.203 + // Ensure error handler
62.204 + if (this.errorHandler == null) {
62.205 + this.errorHandler = new DefaultErrorHandler();
62.206 + }
62.207 + }
62.208 +
62.209 + // Generic DOM comparison methods.
62.210 +
62.211 + /**
62.212 + * Compares two nodes for equality.
62.213 + * <P>
62.214 + * Two nodes are considered to be equal if either both nodes
62.215 + * are <CODE>null</CODE> or
62.216 + * <UL>
62.217 + * <LI>both nodes are not <CODE>null</CODE>, and
62.218 + * <LI>both node's types are equal, and
62.219 + * <LI>both node's names are equal, and
62.220 + * <LI>both node's values are equal, and
62.221 + * <LI>both node's attributes are equal, and
62.222 + * <LI>both node's children are equal.
62.223 + * </UL>
62.224 + *
62.225 + * @param left one node.
62.226 + * @param right another node.
62.227 + * @return <CODE>true</CODE> if both nodes are considered to be
62.228 + * equal, otherwise <CODE>false</CODE>.
62.229 + */
62.230 + public boolean compare(Node left, Node right) {
62.231 + // Compare object references.
62.232 + if (left == right) {
62.233 + return true;
62.234 + }
62.235 +
62.236 + // Compare object references.
62.237 + if ((left == null) || (right == null)) {
62.238 + this.errorHandler.handleError("a node is null", null, left, right);
62.239 + return false;
62.240 + }
62.241 +
62.242 + // Compare node types.
62.243 + if (left.getNodeType() != right.getNodeType()) {
62.244 + this.errorHandler.handleError("different node types", left.getNodeType() + " vs. " + right.getNodeType(), left, right);
62.245 + return false;
62.246 + }
62.247 +
62.248 + if (this.namespaceAware &&
62.249 + ((left.getNodeType() == Node.ATTRIBUTE_NODE) || (left.getNodeType() == Node.ELEMENT_NODE))) {
62.250 + // Compare node URIs.
62.251 + if (!compare(left.getNamespaceURI(), right.getNamespaceURI())) {
62.252 + this.errorHandler.handleError("different namespaces", left.getNamespaceURI() + " vs. " + right.getNamespaceURI(), left, right);
62.253 + return false;
62.254 + }
62.255 +
62.256 + // It is insufficient to compare the local parts only, since
62.257 + // parsers handle this issue differently: While no URI is
62.258 + // given, a parser may choose to return no local part ...
62.259 + if (left.getNamespaceURI() != null) {
62.260 + // Compare node locals.
62.261 + if (!compare(left.getLocalName(), right.getLocalName())) {
62.262 + this.errorHandler.handleError("different local names", left.getLocalName() + " vs. " + right.getLocalName(), left, right);
62.263 + return false;
62.264 + }
62.265 + } else {
62.266 + // Compare node names.
62.267 + if (!compare(left.getNodeName(), right.getNodeName())) {
62.268 + this.errorHandler.handleError("different node names", left.getNodeName() + " vs. " + right.getNodeName(), left, right);
62.269 + return false;
62.270 + }
62.271 + }
62.272 + } else {
62.273 + // Compare node names.
62.274 + if (!compare(left.getNodeName(), right.getNodeName())) {
62.275 + this.errorHandler.handleError("different node names", left.getNodeName() + " vs. " + right.getNodeName(), left, right);
62.276 + return false;
62.277 + }
62.278 + }
62.279 +
62.280 + // Compare node values.
62.281 + if (!compare(left.getNodeValue(), right.getNodeValue())) {
62.282 + this.errorHandler.handleError("different node values", left.getNodeValue() + " vs. " + right.getNodeValue(), left, right);
62.283 + return false;
62.284 + }
62.285 +
62.286 + // Compare node attributes.
62.287 + if (!compare(left.getAttributes(), right.getAttributes())) {
62.288 + this.errorHandler.handleError("different node attributes", null, left, right);
62.289 + return false;
62.290 + }
62.291 +
62.292 + // Compare node children.
62.293 + if (!compare(left.getChildNodes(), right.getChildNodes())) {
62.294 + this.errorHandler.handleError("different node children", null, left, right);
62.295 + return false;
62.296 + }
62.297 +
62.298 + // All checks passed successfully.
62.299 + return true;
62.300 + }
62.301 +
62.302 + // Helper and concenience methods.
62.303 +
62.304 + /**
62.305 + * Compares two node lists for equality.
62.306 + * <P>
62.307 + * Two node lists are considered to be equal if either both node lists
62.308 + * are <CODE>null</CODE> or
62.309 + * <UL>
62.310 + * <LI>both node lists are not <CODE>null</CODE>, and
62.311 + * <LI>both node list's lengths are equal, and
62.312 + * <LI>both node list's items are equal, and
62.313 + * <LI>both node list's items appear in the same order.
62.314 + * </UL>
62.315 + *
62.316 + * @param left one node list.
62.317 + * @param right another node list.
62.318 + * @return <CODE>true</CODE> if both node lists are considered to be
62.319 + * equal, otherwise <CODE>false</CODE>.
62.320 + */
62.321 + protected boolean compare(NodeList left, NodeList right) {
62.322 + // Compare object references.
62.323 + if (left == right) {
62.324 + return true;
62.325 + }
62.326 +
62.327 + // Compare object references.
62.328 + if ((left == null) || (right == null)) {
62.329 + return false;
62.330 + }
62.331 +
62.332 + // Compare list lengths.
62.333 + if ((!this.ignoreComments) && (!this.ignoreWhitespace) && (left.getLength() != right.getLength())) {
62.334 + return false;
62.335 + }
62.336 +
62.337 + // Get next list items.
62.338 + int leftIndex = getNextIndex(left, 0);
62.339 + int rightIndex = getNextIndex(right, 0);
62.340 +
62.341 + while ((leftIndex < left.getLength()) || (rightIndex < right.getLength())) {
62.342 + // Compare list items.
62.343 + if (!compare(left.item(leftIndex), right.item(rightIndex))) {
62.344 + return false;
62.345 + }
62.346 +
62.347 + // Get next list items.
62.348 + leftIndex = getNextIndex(left, leftIndex + 1);
62.349 + rightIndex = getNextIndex(right, rightIndex + 1);
62.350 + }
62.351 +
62.352 + // All checks passed successfully.
62.353 + return true;
62.354 + }
62.355 +
62.356 + /**
62.357 + * Compares two node maps for equality.
62.358 + * <P>
62.359 + * Two node lists are considered to be equal if either both node maps
62.360 + * are <CODE>null</CODE> or
62.361 + * <UL>
62.362 + * <LI>both node maps are not <CODE>null</CODE>, and
62.363 + * <LI>both node map's lengths are equal, and
62.364 + * <LI>both node map's items are equal with no respect to the order
62.365 + * of their appearance.
62.366 + * </UL>
62.367 + *
62.368 + * @param left one node map.
62.369 + * @param right another node map.
62.370 + * @return <CODE>true</CODE> if both node maps are considered to be
62.371 + * equal, otherwise <CODE>false</CODE>.
62.372 + */
62.373 + protected boolean compare(NamedNodeMap left, NamedNodeMap right) {
62.374 + // Compare object references.
62.375 + if (left == right) {
62.376 + return true;
62.377 + }
62.378 +
62.379 + // Compare object references.
62.380 + if ((left == null) || (right == null)) {
62.381 + return false;
62.382 + }
62.383 +
62.384 + // Compare map lengths.
62.385 + if (getRealLength(left) != getRealLength(right)) {
62.386 + return false;
62.387 + }
62.388 +
62.389 + if (this.namespaceAware) {
62.390 + // Get next map item.
62.391 + int index = getNextIndex(left, 0);
62.392 +
62.393 + // Initialize empty item.
62.394 + Node item = null;
62.395 +
62.396 + while (index < left.getLength()) {
62.397 + // Get item.
62.398 + item = left.item(index);
62.399 +
62.400 + // It is insufficient to compare the local parts only, since
62.401 + // parsers handle this issue differently: While no URI is
62.402 + // given, a parser may choose to return no local part ...
62.403 + if (item.getNamespaceURI() != null) {
62.404 + // Compare map items with no respect to the order of their appearance.
62.405 + if (!compare(item, right.getNamedItemNS(item.getNamespaceURI(), item.getLocalName()))) {
62.406 + return false;
62.407 + }
62.408 + } else {
62.409 + // Compare map items with no respect to the order of their appearance.
62.410 + if (!compare(item, right.getNamedItem(item.getNodeName()))) {
62.411 + return false;
62.412 + }
62.413 + }
62.414 +
62.415 + // Get next map item.
62.416 + index = getNextIndex(left, index + 1);
62.417 + }
62.418 +
62.419 + // All checks passed successfully.
62.420 + return true;
62.421 + }
62.422 +
62.423 + for (int index = 0; index < left.getLength(); index++) {
62.424 + // Compare map items with no respect to the order of their appearance.
62.425 + if (!compare(left.item(index), right.getNamedItem(left.item(index).getNodeName()))) {
62.426 + return false;
62.427 + }
62.428 + }
62.429 +
62.430 + // All checks passed successfully.
62.431 + return true;
62.432 + }
62.433 +
62.434 + /**
62.435 + * Compares two strings for equality.
62.436 + * <P>
62.437 + * Two strings are considered to be equal if either both strings
62.438 + * are <CODE>null</CODE> or both strings are not <CODE>null</CODE>,
62.439 + * and depending on the specified comparison method
62.440 + * <UL>
62.441 + * <LI>both string's object references of the VM internal string pool
62.442 + * are equal, or
62.443 + * <LI>both string's hash codes are equal, or
62.444 + * <LI>both strings are character-wise equal.
62.445 + * </UL>
62.446 + *
62.447 + * @param left one string.
62.448 + * @param right another string.
62.449 + * @return <CODE>true</CODE> if both strings are considered to be
62.450 + * equal, otherwise <CODE>false</CODE>.
62.451 + */
62.452 + protected final boolean compare(String left, String right) {
62.453 + // Compare object references.
62.454 + if (left == right) {
62.455 + return true;
62.456 + }
62.457 +
62.458 + // Compare object references.
62.459 + if ((left == null) || (right == null)) {
62.460 + return false;
62.461 + }
62.462 +
62.463 + // Compare character by character.
62.464 + return left.equals(right);
62.465 + }
62.466 +
62.467 + /**
62.468 + * Returns the index of the next item in the node list to compare.
62.469 + * <P>
62.470 + * The item choosen depends on the comment and whitespace ignoring.
62.471 + *
62.472 + * @param list the node list.
62.473 + * @param start the start index.
62.474 + * @return the index of the next item in the node list to compare.
62.475 + */
62.476 + private int getNextIndex(NodeList list, int start) {
62.477 + if (this.ignoreComments && this.ignoreWhitespace) {
62.478 + // Skip whitespace and comment list items.
62.479 + return DOMWhitespace.skipWhitespaceAndComments(list, start);
62.480 + }
62.481 +
62.482 + if (this.ignoreWhitespace) {
62.483 + // Skip whitespace list items.
62.484 + return DOMWhitespace.skipWhitespace(list, start);
62.485 + }
62.486 +
62.487 + if (this.ignoreComments) {
62.488 + // Skip comment list items.
62.489 + return DOMWhitespace.skipComments(list, start);
62.490 + }
62.491 +
62.492 + return start;
62.493 + }
62.494 +
62.495 + /**
62.496 + * Returns the index of the next item in the node map to compare.
62.497 + * <P>
62.498 + * The item choosen depends on the namespace awareness and
62.499 + * namespace declaration ignoring.
62.500 + *
62.501 + * @param map the node map.
62.502 + * @param start the start index.
62.503 + * @return the index of the next item in the node map to compare.
62.504 + */
62.505 + private int getNextIndex(NamedNodeMap map, int start) {
62.506 + if (this.namespaceAware && this.ignoreNamespaceDeclarations) {
62.507 + for (int index = start; index < map.getLength(); index++) {
62.508 + if (!NamespaceConstants.XMLNS_NS.equals(map.item(index).getNamespaceURI())) {
62.509 + // Deliver index.
62.510 + return index;
62.511 + }
62.512 + }
62.513 +
62.514 + // Return original length.
62.515 + return map.getLength();
62.516 + }
62.517 +
62.518 + return start;
62.519 + }
62.520 +
62.521 + /**
62.522 + * Returns the real length of the map to compare.
62.523 + * <P>
62.524 + * The returned length depends on the namespace awareness and
62.525 + * namespace declaration ignoring.
62.526 + *
62.527 + * @param map the node map.
62.528 + * @return the real length of the map to compare.
62.529 + */
62.530 + private int getRealLength(NamedNodeMap map) {
62.531 + if (this.namespaceAware && this.ignoreNamespaceDeclarations) {
62.532 + // Initialize difference.
62.533 + int difference = 0;
62.534 +
62.535 + for (int index = 0; index < map.getLength(); index++) {
62.536 + if (NamespaceConstants.XMLNS_NS.equals(map.item(index).getNamespaceURI())) {
62.537 + // Increment difference.
62.538 + difference++;
62.539 + }
62.540 + }
62.541 +
62.542 + // Return computed length.
62.543 + return map.getLength() - difference;
62.544 + }
62.545 +
62.546 + // Return original length.
62.547 + return map.getLength();
62.548 + }
62.549 +
62.550 + // Static error handler interface
62.551 +
62.552 + public static interface ErrorHandler {
62.553 + void handleError(String error, String detail, Node left, Node right);
62.554 + }
62.555 +
62.556 + public static class DefaultErrorHandler implements ErrorHandler {
62.557 + public void handleError(String error, String detail, Node left, Node right) {
62.558 + // NOP
62.559 + }
62.560 + }
62.561 +
62.562 + public static class SystemErrorHandler implements ErrorHandler {
62.563 + public void handleError(String error, String detail, Node left, Node right) {
62.564 + StringBuffer buffer = new StringBuffer();
62.565 + buffer.append(error);
62.566 + if (detail != null) {
62.567 + buffer.append(" [");
62.568 + buffer.append(detail);
62.569 + buffer.append("]");
62.570 + }
62.571 + buffer.append(": left='");
62.572 + buffer.append(left == null ? "#null" : left.getNodeName());
62.573 + buffer.append("' right='");
62.574 + buffer.append(right == null ? "#null" : right.getNodeName());
62.575 + buffer.append("'");
62.576 +
62.577 + System.err.println(buffer);
62.578 + }
62.579 + }
62.580 +
62.581 +}
63.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
63.2 +++ b/enterprise/openesbaddons/workflow/project/chiba_src/org/chiba/xml/dom/DOMUtil.java Thu Apr 26 02:33:27 2007 +0000
63.3 @@ -0,0 +1,1083 @@
63.4 +// Copyright 2006 Chibacon
63.5 +/*
63.6 + *
63.7 + * Artistic License
63.8 + *
63.9 + * Preamble
63.10 + *
63.11 + * The intent of this document is to state the conditions under which a
63.12 + * Package may be copied, such that the Copyright Holder maintains some
63.13 + * semblance of artistic control over the development of the package,
63.14 + * while giving the users of the package the right to use and distribute
63.15 + * the Package in a more-or-less customary fashion, plus the right to make
63.16 + * reasonable modifications.
63.17 + *
63.18 + * Definitions:
63.19 + *
63.20 + * "Package" refers to the collection of files distributed by the
63.21 + * Copyright Holder, and derivatives of that collection of files created
63.22 + * through textual modification.
63.23 + *
63.24 + * "Standard Version" refers to such a Package if it has not been
63.25 + * modified, or has been modified in accordance with the wishes of the
63.26 + * Copyright Holder.
63.27 + *
63.28 + * "Copyright Holder" is whoever is named in the copyright or copyrights
63.29 + * for the package.
63.30 + *
63.31 + * "You" is you, if you're thinking about copying or distributing this Package.
63.32 + *
63.33 + * "Reasonable copying fee" is whatever you can justify on the basis of
63.34 + * media cost, duplication charges, time of people involved, and so
63.35 + * on. (You will not be required to justify it to the Copyright Holder,
63.36 + * but only to the computing community at large as a market that must bear
63.37 + * the fee.)
63.38 + *
63.39 + * "Freely Available" means that no fee is charged for the item itself,
63.40 + * though there may be fees involved in handling the item. It also means
63.41 + * that recipients of the item may redistribute it under the same
63.42 + * conditions they received it.
63.43 + *
63.44 + * 1. You may make and give away verbatim copies of the source form of the
63.45 + * Standard Version of this Package without restriction, provided that you
63.46 + * duplicate all of the original copyright notices and associated
63.47 + * disclaimers.
63.48 + *
63.49 + * 2. You may apply bug fixes, portability fixes and other modifications
63.50 + * derived from the Public Domain or from the Copyright Holder. A Package
63.51 + * modified in such a way shall still be considered the Standard Version.
63.52 + *
63.53 + * 3. You may otherwise modify your copy of this Package in any way,
63.54 + * provided that you insert a prominent notice in each changed file
63.55 + * stating how and when you changed that file, and provided that you do at
63.56 + * least ONE of the following:
63.57 + *
63.58 + * a) place your modifications in the Public Domain or otherwise make
63.59 + * them Freely Available, such as by posting said modifications to
63.60 + * Usenet or an equivalent medium, or placing the modifications on a
63.61 + * major archive site such as ftp.uu.net, or by allowing the Copyright
63.62 + * Holder to include your modifications in the Standard Version of the
63.63 + * Package.
63.64 + *
63.65 + * b) use the modified Package only within your corporation or
63.66 + * organization.
63.67 + *
63.68 + * c) rename any non-standard executables so the names do not conflict
63.69 + * with standard executables, which must also be provided, and provide
63.70 + * a separate manual page for each non-standard executable that
63.71 + * clearly documents how it differs from the Standard Version.
63.72 + *
63.73 + * d) make other distribution arrangements with the Copyright Holder.
63.74 + *
63.75 + * 4. You may distribute the programs of this Package in object code or
63.76 + * executable form, provided that you do at least ONE of the following:
63.77 + *
63.78 + * a) distribute a Standard Version of the executables and library
63.79 + * files, together with instructions (in the manual page or
63.80 + * equivalent) on where to get the Standard Version.
63.81 + *
63.82 + * b) accompany the distribution with the machine-readable source of
63.83 + * the Package with your modifications.
63.84 + *
63.85 + * c) accompany any non-standard executables with their corresponding
63.86 + * Standard Version executables, giving the non-standard executables
63.87 + * non-standard names, and clearly documenting the differences in
63.88 + * manual pages (or equivalent), together with instructions on where
63.89 + * to get the Standard Version.
63.90 + *
63.91 + * d) make other distribution arrangements with the Copyright Holder.
63.92 + *
63.93 + * 5. You may charge a reasonable copying fee for any distribution of this
63.94 + * Package. You may charge any fee you choose for support of this
63.95 + * Package. You may not charge a fee for this Package itself. However,
63.96 + * you may distribute this Package in aggregate with other (possibly
63.97 + * commercial) programs as part of a larger (possibly commercial) software
63.98 + * distribution provided that you do not advertise this Package as a
63.99 + * product of your own.
63.100 + *
63.101 + * 6. The scripts and library files supplied as input to or produced as
63.102 + * output from the programs of this Package do not automatically fall
63.103 + * under the copyright of this Package, but belong to whomever generated
63.104 + * them, and may be sold commercially, and may be aggregated with this
63.105 + * Package.
63.106 + *
63.107 + * 7. C or perl subroutines supplied by you and linked into this Package
63.108 + * shall not be considered part of this Package.
63.109 + *
63.110 + * 8. The name of the Copyright Holder may not be used to endorse or
63.111 + * promote products derived from this software without specific prior
63.112 + * written permission.
63.113 + *
63.114 + * 9. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
63.115 + * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
63.116 + * MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
63.117 + * */
63.118 +package org.chiba.xml.dom;
63.119 +
63.120 +import org.w3c.dom.*;
63.121 +import org.w3c.dom.traversal.NodeFilter;
63.122 +import org.xml.sax.SAXException;
63.123 +
63.124 +import javax.xml.parsers.DocumentBuilder;
63.125 +import javax.xml.parsers.DocumentBuilderFactory;
63.126 +import javax.xml.parsers.ParserConfigurationException;
63.127 +import javax.xml.transform.OutputKeys;
63.128 +import javax.xml.transform.Transformer;
63.129 +import javax.xml.transform.TransformerException;
63.130 +import javax.xml.transform.TransformerFactory;
63.131 +import javax.xml.transform.dom.DOMSource;
63.132 +import javax.xml.transform.stream.StreamResult;
63.133 +import java.io.File;
63.134 +import java.io.IOException;
63.135 +import java.io.InputStream;
63.136 +import java.io.OutputStream;
63.137 +import java.util.ArrayList;
63.138 +import java.util.List;
63.139 +
63.140 +/**
63.141 + * some DOM utility methods.
63.142 + *
63.143 + * @author joern turner
63.144 + * @author vrg
63.145 + * @version $Id$
63.146 + */
63.147 +public class DOMUtil {
63.148 +
63.149 + /**
63.150 + * __UNDOCUMENTED__
63.151 + *
63.152 + * @param start __UNDOCUMENTED__
63.153 + * @param name __UNDOCUMENTED__
63.154 + * @return __UNDOCUMENTED__
63.155 + */
63.156 + public static Element getChildElement(Node start, String name) {
63.157 + // NodeList nl=start.getChildNodes();
63.158 + NodeList nl = null;
63.159 +
63.160 + if (start.getNodeType() == Node.DOCUMENT_NODE) {
63.161 + nl = ((Document) start).getDocumentElement().getChildNodes();
63.162 + } else {
63.163 + nl = start.getChildNodes();
63.164 + }
63.165 +
63.166 + int len = nl.getLength();
63.167 + Node n = null;
63.168 +
63.169 + for (int i = 0; i < len; i++) {
63.170 + n = nl.item(i);
63.171 +
63.172 + if (n.getNodeType() == Node.ELEMENT_NODE) {
63.173 + if (n.getNodeName().equals(name)) {
63.174 + return (Element) n;
63.175 + }
63.176 + }
63.177 + }
63.178 +
63.179 + return null;
63.180 + }
63.181 +
63.182 + /**
63.183 + * returns the xpath from the start-element up to the document-root
63.184 + *
63.185 + * @return - returns the xpath from-element up to the document-root.
63.186 + * The start element is included.
63.187 + */
63.188 +
63.189 + // public static String getPath(Node start) {
63.190 + // String path=null;
63.191 + //
63.192 + // if(start.getNodeType()==Node.ELEMENT_NODE || start.getNodeType()==Node.ATTRIBUTE_NODE) {
63.193 + //
63.194 + //// path=start.getNodeName();
63.195 + //
63.196 + // Node n=start;
63.197 + // while(n.getParentNode()!=null) {
63.198 + // path=n.getNodeName() + "/" + path;
63.199 + // }
63.200 + //
63.201 + // }
63.202 + // return path;
63.203 + // }
63.204 +
63.205 + /**
63.206 + * returns a java.util.List of Elements which are children of the start Element.
63.207 + */
63.208 + public static List getChildElements(Node start) {
63.209 + List l = new ArrayList();
63.210 + NodeList nl = start.getChildNodes();
63.211 + int len = nl.getLength();
63.212 + Node n = null;
63.213 +
63.214 + for (int i = 0; i < len; i++) {
63.215 + n = nl.item(i);
63.216 +
63.217 + if (n.getNodeType() == Node.ELEMENT_NODE) {
63.218 + l.add(n);
63.219 + }
63.220 + }
63.221 +
63.222 + return l;
63.223 + }
63.224 +
63.225 + /**
63.226 + * returns an element's position in the given NodeList
63.227 + *
63.228 + * @param refNode the element to get the index for
63.229 + * @param list the NodeList to search
63.230 + * @return the position starting with 1, or -1 if refNode was null
63.231 + */
63.232 + public static int getCurrentListPosition(Node refNode, NodeList list) {
63.233 + if (refNode == null) {
63.234 + return -1;
63.235 + }
63.236 +
63.237 + int counter = 1;
63.238 +
63.239 + for (int n = 0; n < list.getLength(); n++, counter++) {
63.240 + if (list.item(n) == refNode) {
63.241 + return counter;
63.242 + }
63.243 + }
63.244 +
63.245 + return -1;
63.246 + }
63.247 +
63.248 + /**
63.249 + * returns an element's position in the list of its siblings.
63.250 + *
63.251 + * @param refNode the element to get the index for
63.252 + * @return the position starting with 1, or -1 if refNode was null
63.253 + */
63.254 + public static int getCurrentPosition(Node refNode) {
63.255 + if (refNode == null) {
63.256 + return -1;
63.257 + }
63.258 +
63.259 + int counter = 0;
63.260 + Node current = refNode;
63.261 +
63.262 + while (current != null) {
63.263 + if (current.getNodeType() == Node.ELEMENT_NODE) {
63.264 + counter++;
63.265 + }
63.266 +
63.267 + current = current.getPreviousSibling();
63.268 + }
63.269 +
63.270 + return counter;
63.271 + }
63.272 +
63.273 + /**
63.274 + * equivalent to the XPath expression './/tagName[@attrName='attrValue']'
63.275 + */
63.276 + public static Element getElementByAttributeValue(Node start, String tagName, String attrName,
63.277 + String attrValue) {
63.278 + NodeList nl = ((Element) start).getElementsByTagName(tagName);
63.279 + int l = nl.getLength();
63.280 +
63.281 + if (l == 0) {
63.282 + return null;
63.283 + }
63.284 +
63.285 + Element e = null;
63.286 + String compareValue = null;
63.287 +
63.288 + for (int i = 0; i < l; i++) {
63.289 + e = (Element) nl.item(i);
63.290 +
63.291 + if (e.getNodeType() == Node.ELEMENT_NODE) {
63.292 + compareValue = e.getAttribute(attrName);
63.293 +
63.294 + if (compareValue.equals(attrValue)) {
63.295 + return e;
63.296 + }
63.297 + }
63.298 + }
63.299 +
63.300 + return null;
63.301 + }
63.302 +
63.303 + /**
63.304 + * equivalent to the XPath expression './/tnuri:tagName[@anuri:attrName='attrValue']'
63.305 + */
63.306 + public static Element getElementByAttributeValueNS(Node start, String tnuri, String tagName,
63.307 + String anuri, String attrName, String attrValue) {
63.308 + NodeList nl = ((Element) start).getElementsByTagNameNS(tnuri, tagName);
63.309 +
63.310 + if (nl != null) {
63.311 + int l = nl.getLength();
63.312 +
63.313 + if (l == 0) {
63.314 + return null;
63.315 + }
63.316 +
63.317 + Element e = null;
63.318 + String compareValue = null;
63.319 +
63.320 + for (int i = 0; i < l; i++) {
63.321 + e = (Element) nl.item(i);
63.322 +
63.323 + if (e.getNodeType() == Node.ELEMENT_NODE) {
63.324 + compareValue = e.getAttributeNS(anuri, attrName);
63.325 +
63.326 + if (compareValue.equals(attrValue)) {
63.327 + return e;
63.328 + }
63.329 + }
63.330 + }
63.331 + }
63.332 +
63.333 + return null;
63.334 + }
63.335 +
63.336 + /**
63.337 + * returns the first child of the contextnode which has the specified tagname regardless of the depth in the tree.
63.338 + *
63.339 + * @param contextNode where to start the search
63.340 + * @param tag the name of the wanted child
63.341 + * @return the first child found under the contextnode
63.342 + */
63.343 + public static Node getFirstChildByTagName(Node contextNode, String tag) {
63.344 + Node n = null;
63.345 +
63.346 + if (contextNode.getNodeType() == Node.DOCUMENT_NODE) {
63.347 + n = ((Document) contextNode).getDocumentElement();
63.348 +
63.349 + if (!n.getNodeName().equals(tag)) {
63.350 + n = null;
63.351 + }
63.352 + } else {
63.353 + NodeList nodes = ((Element) contextNode).getElementsByTagName(tag);
63.354 +
63.355 + if (nodes != null) {
63.356 + n = nodes.item(0);
63.357 + }
63.358 + }
63.359 +
63.360 + return n;
63.361 + }
63.362 +
63.363 + /**
63.364 + * returns the first child of the contextnode which has the specified tagname and namespace uri regardless of the
63.365 + * depth in the tree.
63.366 + *
63.367 + * @param contextNode where to start the search
63.368 + * @param nsuri the namespace uri
63.369 + * @param tag the local name part of the wanted child
63.370 + * @return the first child found under the contextnode
63.371 + */
63.372 + public static Node getFirstChildByTagNameNS(Node contextNode, String nsuri, String tag) {
63.373 + Node n = null;
63.374 +
63.375 + if (contextNode.getNodeType() == Node.DOCUMENT_NODE) {
63.376 + n = ((Document) contextNode).getDocumentElement();
63.377 +
63.378 + if (!(n.getNamespaceURI().equals(nsuri) && n.getNodeName().equals(tag))) {
63.379 + n = null;
63.380 + }
63.381 + } else {
63.382 + NodeList nodes = ((Element) contextNode).getElementsByTagNameNS(nsuri, tag);
63.383 +
63.384 + if (nodes != null) {
63.385 + n = nodes.item(0);
63.386 + }
63.387 + }
63.388 +
63.389 + return n;
63.390 + }
63.391 +
63.392 + /**
63.393 + * gets the first child of a node which is an element. This avoids the whitespace problems when using
63.394 + * org.w3c.dom.node.getFirstChild(). Whitespace-nodes may also appear as children, but normally are not what you're
63.395 + * looking for.
63.396 + */
63.397 + public static Element getFirstChildElement(Node start) {
63.398 + Node n = null;
63.399 + NodeList nl = start.getChildNodes();
63.400 + int len = nl.getLength();
63.401 +
63.402 + if (len == 0) {
63.403 + return null;
63.404 + }
63.405 +
63.406 + for (int i = 0; i < len; i++) {
63.407 + n = nl.item(i);
63.408 +
63.409 + if (n.getNodeType() == Node.ELEMENT_NODE) {
63.410 + return ((Element) n);
63.411 + }
63.412 + }
63.413 +
63.414 + return null;
63.415 + }
63.416 +
63.417 + /**
63.418 + * __UNDOCUMENTED__
63.419 + *
63.420 + * @param start __UNDOCUMENTED__
63.421 + * @return __UNDOCUMENTED__
63.422 + */
63.423 + public static Element getLastChildElement(Node start) {
63.424 + NodeList children = start.getChildNodes();
63.425 +
63.426 + if (children != null) {
63.427 + int len = children.getLength();
63.428 + Node n = null;
63.429 +
63.430 + for (int i = len - 1; i >= 0; i--) {
63.431 + n = children.item(i);
63.432 +
63.433 + if (n.getNodeType() == Node.ELEMENT_NODE) {
63.434 + return ((Element) n);
63.435 + }
63.436 + }
63.437 + }
63.438 +
63.439 + return null;
63.440 + }
63.441 +
63.442 + /**
63.443 + * Returns the next sibling element of the specified node.
63.444 + * <p/>
63.445 + * If there is no such element, this method returns <code>null</code>.
63.446 + *
63.447 + * @param node the node to process.
63.448 + * @return the next sibling element of the specified node.
63.449 + */
63.450 + public static Element getNextSiblingElement(Node node) {
63.451 + Node sibling = node.getNextSibling();
63.452 +
63.453 + if ((sibling == null) || (sibling.getNodeType() == Node.ELEMENT_NODE)) {
63.454 + return (Element) sibling;
63.455 + }
63.456 +
63.457 + return getNextSiblingElement(sibling);
63.458 + }
63.459 +
63.460 + /**
63.461 + * __UNDOCUMENTED__
63.462 + *
63.463 + * @param nodeToCompare __UNDOCUMENTED__
63.464 + * @param nsuri __UNDOCUMENTED__
63.465 + * @param tagName __UNDOCUMENTED__
63.466 + * @return __UNDOCUMENTED__
63.467 + */
63.468 + public static boolean isNodeInNS(Node nodeToCompare, String nsuri, String tagName) {
63.469 + String ntcnsuri = nodeToCompare.getNamespaceURI();
63.470 +
63.471 + if ((ntcnsuri != null) && (ntcnsuri.length() > 0)) {
63.472 + return (tagName.equals(nodeToCompare.getLocalName()) && ntcnsuri.equals(nsuri));
63.473 + } else {
63.474 + return (tagName.equals(nodeToCompare.getNodeName()));
63.475 + }
63.476 + }
63.477 +
63.478 + /**
63.479 + * Returns the previous sibling element of the specified node.
63.480 + * <p/>
63.481 + * If there is no such element, this method returns <code>null</code>.
63.482 + *
63.483 + * @param node the node to process.
63.484 + * @return the previous sibling element of the specified node.
63.485 + */
63.486 + public static Element getPreviousSiblingElement(Node node) {
63.487 + Node sibling = node.getPreviousSibling();
63.488 +
63.489 + if ((sibling == null) || (sibling.getNodeType() == Node.ELEMENT_NODE)) {
63.490 + return (Element) sibling;
63.491 + }
63.492 +
63.493 + return getPreviousSiblingElement(sibling);
63.494 + }
63.495 +
63.496 + /**
63.497 + * gets the first child of a node which is a text or cdata node.
63.498 + */
63.499 + public static Node getTextNode(Node start) {
63.500 + Node n = null;
63.501 +
63.502 + start.normalize();
63.503 +
63.504 + NodeList nl;
63.505 + if (start.getNodeType() == Node.DOCUMENT_NODE) {
63.506 + nl = ((Document) start).getDocumentElement().getChildNodes();
63.507 + } else {
63.508 + nl = start.getChildNodes();
63.509 + }
63.510 +
63.511 + int len = nl.getLength();
63.512 +
63.513 + if (len == 0) {
63.514 + return null;
63.515 + }
63.516 +
63.517 + for (int i = 0; i < len; i++) {
63.518 + n = nl.item(i);
63.519 +
63.520 + if (n.getNodeType() == Node.TEXT_NODE) {
63.521 + return n;
63.522 + } else if (n.getNodeType() == Node.CDATA_SECTION_NODE) {
63.523 + return n;
63.524 + }
63.525 + }
63.526 +
63.527 + return null;
63.528 + }
63.529 +
63.530 + /**
63.531 + * returns the Text-Node child of Node 'start' as String. If no TextNode exists, an empty string is returned.
63.532 + */
63.533 + public static String getTextNodeAsString(Node start) {
63.534 + Node txt = getTextNode(start);
63.535 +
63.536 + if (txt != null) {
63.537 + return txt.getNodeValue();
63.538 + }
63.539 +
63.540 + return "";
63.541 + }
63.542 +
63.543 + /**
63.544 + * Returns the node value of the element's first child if there is any,
63.545 + * otherwise <code>null</code>.
63.546 + *
63.547 + * @param element the element.
63.548 + * @return the element's value.
63.549 + */
63.550 + public static String getElementValue(Element element) {
63.551 + Node child = element.getFirstChild();
63.552 + if (child != null) {
63.553 + return child.getNodeValue();
63.554 + }
63.555 +
63.556 + return null;
63.557 + }
63.558 +
63.559 + /**
63.560 + * Appends the specified value as a text node to the element. If the
63.561 + * value is <code>null</code>, the element's first child node will be
63.562 + * removed.
63.563 + *
63.564 + * @param element the element.
63.565 + * @param value the element's value.
63.566 + */
63.567 + public static void setElementValue(Element element, String value) {
63.568 + Node child = element.getFirstChild();
63.569 +
63.570 + if (value != null) {
63.571 + if (child == null) {
63.572 + child = element.getOwnerDocument().createTextNode("");
63.573 + element.appendChild(child);
63.574 + }
63.575 +
63.576 + child.setNodeValue(value);
63.577 + }
63.578 + else {
63.579 + if (child != null) {
63.580 + element.removeChild(child);
63.581 + }
63.582 + }
63.583 + }
63.584 +
63.585 + /**
63.586 + * copies all attributes from one Element to another
63.587 + *
63.588 + * @param from - the Element which the source attributes
63.589 + * @param to - the target Element for the Attributes
63.590 + * @param filter - a NodeFilter to apply during copy
63.591 + */
63.592 + public static void copyAttributes(Element from, Element to, NodeFilter filter) {
63.593 + if ((from != null) && (to != null)) {
63.594 + NamedNodeMap map = from.getAttributes();
63.595 +
63.596 + /* if filter is null use our own default filter, which accepts
63.597 + everything (this saves us from always check if filter is
63.598 + null */
63.599 + if (filter == null) {
63.600 + filter = new NodeFilter() {
63.601 + public short acceptNode(Node n) {
63.602 + return NodeFilter.FILTER_ACCEPT;
63.603 + }
63.604 + };
63.605 + }
63.606 +
63.607 + if (map != null) {
63.608 + int len = map.getLength();
63.609 +
63.610 + for (int i = 0; i < len; i++) {
63.611 + Node attr = map.item(i);
63.612 +
63.613 + if (attr.getNodeType() == Node.ATTRIBUTE_NODE) {
63.614 + if (filter.acceptNode(attr) == NodeFilter.FILTER_ACCEPT) {
63.615 + to.setAttributeNS(attr.getNamespaceURI(), attr.getNodeName(), attr.getNodeValue());
63.616 + }
63.617 + }
63.618 + }
63.619 + }
63.620 + }
63.621 + }
63.622 +
63.623 + // return the count of child elements
63.624 + public static int countChildElements(Node node) {
63.625 + NodeList nl = node.getChildNodes();
63.626 + int count = 0;
63.627 +
63.628 + for (int n = 0; n < nl.getLength(); n++) {
63.629 + if (nl.item(n).getNodeType() == Node.ELEMENT_NODE) {
63.630 + count++;
63.631 + }
63.632 + }
63.633 +
63.634 + return count;
63.635 + }
63.636 +
63.637 + /**
63.638 + * find the first child in a parent for a tagname part (only one the child level)
63.639 + *
63.640 + * @param parent the parent to search the child in
63.641 + * @param tagName the local name part of the child node
63.642 + * @return the found child casted to Element or null if no such child was found.
63.643 + */
63.644 + public static Element findFirstChild(Node parent, String tagName) {
63.645 + if (tagName == null) {
63.646 + return null;
63.647 + }
63.648 +
63.649 + NodeList children = parent.getChildNodes();
63.650 +
63.651 + if (children != null) {
63.652 + int len = children.getLength();
63.653 + Node n = null;
63.654 +
63.655 + for (int i = 0; i < len; i++) {
63.656 + n = children.item(i);
63.657 +
63.658 + //System.out.println("child="+n.getNodeName());
63.659 + if ((n.getNodeType() == Node.ELEMENT_NODE) && tagName.equals(n.getNodeName())) {
63.660 + return ((Element) n);
63.661 + }
63.662 + }
63.663 + }
63.664 +
63.665 + return null;
63.666 + }
63.667 +
63.668 + /**
63.669 + * find the first child in a parent for a namespace uri and local name part (equals "/tagName[1]" in xpath)
63.670 + *
63.671 + * @param parent the parent to search the child in
63.672 + * @param nsuri the namespace uri of the child node
63.673 + * @param tagName the local name part of the child node
63.674 + * @return the found child casted to Element or null if no such child was found.
63.675 + */
63.676 + public static Element findFirstChildNS(Node parent, String nsuri, String tagName) {
63.677 + if (tagName == null) {
63.678 + return null;
63.679 + }
63.680 +
63.681 + NodeList children = parent.getChildNodes();
63.682 +
63.683 + if (children != null) {
63.684 + int len = children.getLength();
63.685 + Node n = null;
63.686 +
63.687 + for (int i = 0; i < len; i++) {
63.688 + n = children.item(i);
63.689 +
63.690 + if ((n.getNodeType() == Node.ELEMENT_NODE) && isNodeInNS(n, nsuri, tagName)) {
63.691 + return ((Element) n);
63.692 + }
63.693 + }
63.694 + }
63.695 +
63.696 + return null;
63.697 + }
63.698 +
63.699 + /**
63.700 + * find the last child in a parent for a tagname part
63.701 + *
63.702 + * @param parent the parent to search the child in
63.703 + * @param tagName the local name part of the child node
63.704 + * @return the found child casted to Element or null if no such child was found.
63.705 + */
63.706 + public static Element findLastChild(Node parent, String tagName) {
63.707 + if (tagName == null) {
63.708 + return null;
63.709 + }
63.710 +
63.711 + NodeList children = parent.getChildNodes();
63.712 +
63.713 + if (children != null) {
63.714 + int len = children.getLength();
63.715 + Node n = null;
63.716 +
63.717 + for (int i = len - 1; i >= 0; i--) {
63.718 + n = children.item(i);
63.719 +
63.720 + if ((n.getNodeType() == Node.ELEMENT_NODE) && tagName.equals(n.getNodeName())) {
63.721 + return ((Element) n);
63.722 + }
63.723 + }
63.724 + }
63.725 +
63.726 + return null;
63.727 + }
63.728 +
63.729 + /**
63.730 + * find the last child in a parent for a namespace uri and local name part
63.731 + *
63.732 + * @param parent the parent to search the child in
63.733 + * @param nsuri the namespace uri of the child node
63.734 + * @param tagName the local name part of the child node
63.735 + * @return the found child casted to Element or null if no such child was found.
63.736 + */
63.737 + public static Element findLastChildNS(Node parent, String nsuri, String tagName) {
63.738 + if (tagName == null) {
63.739 + return null;
63.740 + }
63.741 +
63.742 + NodeList children = parent.getChildNodes();
63.743 +
63.744 + if (children != null) {
63.745 + int len = children.getLength();
63.746 + Node n = null;
63.747 +
63.748 + for (int i = len - 1; i >= 0; i--) {
63.749 + n = children.item(i);
63.750 +
63.751 + if ((n.getNodeType() == Node.ELEMENT_NODE) && isNodeInNS(n, nsuri, tagName)) {
63.752 + return ((Element) n);
63.753 + }
63.754 +
63.755 + /* tagName.equals(n.getLocalName())) {
63.756 + if (nsuri == n.getNamespaceURI())
63.757 + return ((Element) n);
63.758 + if (nsuri != null &&
63.759 + nsuri.equals(n.getNamespaceURI()))
63.760 + return ((Element) n);
63.761 + }*/
63.762 + }
63.763 + }
63.764 +
63.765 + return null;
63.766 + }
63.767 +
63.768 + /**
63.769 + * find the nth child in a parent for a namespace uri and local name part (equals "/tagName[idx]" in xpath)
63.770 + *
63.771 + * @param contextNode the parent to search the child in
63.772 + * @param nsuri the namespace uri of the child node
63.773 + * @param tag the local name part of the child node
63.774 + * @param idx the index to use (starting at one)
63.775 + * @return the found child casted to Element or null if no such child was found.
63.776 + */
63.777 + public static Node findNthChildNS(Node contextNode, String nsuri, String tag, int idx) {
63.778 + if (tag == null) {
63.779 + return null;
63.780 + }
63.781 +
63.782 + NodeList children = contextNode.getChildNodes();
63.783 +
63.784 + if (children != null) {
63.785 + int len = children.getLength();
63.786 + Node n = null;
63.787 +
63.788 + // int childcount = 0; // to count the found childs
63.789 + //
63.790 + // idx --; // since index starts at one
63.791 + int childcount = 1;
63.792 +
63.793 + for (int i = 0; i < len; i++) {
63.794 + n = children.item(i);
63.795 +
63.796 + if ((n.getNodeType() == Node.ELEMENT_NODE) && isNodeInNS(n, nsuri, tag)) {
63.797 + if (childcount == idx) {
63.798 + return ((Element) n);
63.799 + } else if (childcount > idx) {
63.800 + return null;
63.801 + }
63.802 +
63.803 + childcount++;
63.804 + }
63.805 + }
63.806 + }
63.807 +
63.808 + return null;
63.809 + }
63.810 +
63.811 + /**
63.812 + * __UNDOCUMENTED__
63.813 + *
63.814 + * @param start __UNDOCUMENTED__
63.815 + * @param name __UNDOCUMENTED__
63.816 + * @return __UNDOCUMENTED__
63.817 + */
63.818 + public static boolean hasChild(Element start, String name) {
63.819 + NodeList nl = start.getChildNodes();
63.820 + int len = nl.getLength();
63.821 +
63.822 + Node n = null;
63.823 +
63.824 + for (int i = 0; i < len; i++) {
63.825 + n = nl.item(i);
63.826 +
63.827 + if (n.getNodeName().equals(name)) {
63.828 + return true;
63.829 + }
63.830 + }
63.831 +
63.832 + return false;
63.833 + }
63.834 +
63.835 + /**
63.836 + * just the same as hasNonWhitespaceChildren, but seen from a different perspective ;)
63.837 + *
63.838 + * @param element
63.839 + * @return true, if any Element nodes are found, otherwise false
63.840 + */
63.841 + public static boolean hasElementChildren(Element element) {
63.842 + return hasNonWhitespaceChildren(element);
63.843 + }
63.844 +
63.845 + /**
63.846 + * check, if the passed element node has non-whitespace children.
63.847 + *
63.848 + * @return true, if any Element nodes are found, otherwise false
63.849 + */
63.850 + public static boolean hasNonWhitespaceChildren(Element element) {
63.851 + if (element.hasChildNodes()) {
63.852 + NodeList children = element.getChildNodes();
63.853 + int len = children.getLength();
63.854 + Node n = null;
63.855 +
63.856 + for (int i = 0; i < len; i++) {
63.857 + n = children.item(i);
63.858 +
63.859 + if (n.getNodeType() == Node.ELEMENT_NODE) {
63.860 + return true;
63.861 + }
63.862 + }
63.863 +
63.864 + return false;
63.865 + } else {
63.866 + return false;
63.867 + }
63.868 + }
63.869 +
63.870 + /**
63.871 + * This is a workaround for very strange behaviour of xerces-1.4.2 DOM importNode.
63.872 + */
63.873 + public static Node importNode(Document document, Node toImport) {
63.874 + if (toImport != null) {
63.875 + Node root = toImport.cloneNode(false); // no deep cloning!
63.876 +
63.877 + root = document.importNode(root, false);
63.878 +
63.879 + for (Node n = toImport.getFirstChild(); n != null; n = n.getNextSibling()) {
63.880 + root.appendChild(document.importNode(n, true));
63.881 + }
63.882 +
63.883 + return root;
63.884 + }
63.885 +
63.886 + return null;
63.887 + }
63.888 +
63.889 + /**
63.890 + * __UNDOCUMENTED__
63.891 + *
63.892 + * @param newChild __UNDOCUMENTED__
63.893 + * @param refChild __UNDOCUMENTED__
63.894 + * @throws DOMException __UNDOCUMENTED__
63.895 + */
63.896 + public static void insertAfter(Node newChild, Node refChild)
63.897 + throws DOMException {
63.898 + if (refChild == null) {
63.899 + throw new DOMException(DOMException.NOT_FOUND_ERR, "refChild == null");
63.900 + }
63.901 +
63.902 + Node nextSibling = refChild.getNextSibling();
63.903 +
63.904 + if (nextSibling == null) {
63.905 + refChild.getParentNode().appendChild(newChild);
63.906 + } else {
63.907 + refChild.getParentNode().insertBefore(newChild, nextSibling);
63.908 + }
63.909 + }
63.910 +
63.911 + /**
63.912 + * Moves a child the given index in a nodelist for a given number of steps.
63.913 + *
63.914 + * @param nodelist the nodelist to work on. if the nodelist is empty, nothing is done
63.915 + * @param index index pointing to the child to move. if the index is not in the list range nothing is done.
63.916 + * @param step the amount of slots to move the child. if step is negative the child is moved up (towards the list
63.917 + * start), if it is positive it is moved down (towards the list end). if the step is zero nothing is done.
63.918 + */
63.919 + public static void moveChild(NodeList nodelist, int index, int step) {
63.920 + if ((nodelist == null) || (nodelist.getLength() == 0)) {
63.921 + return;
63.922 + }
63.923 +
63.924 + if ((index >= nodelist.getLength()) || (index < 0)) {
63.925 + return;
63.926 + }
63.927 +
63.928 + if (step == 0) {
63.929 + return;
63.930 + }
63.931 +
63.932 + Node parent = nodelist.item(0).getParentNode();
63.933 + Node deletedElt = parent.removeChild(nodelist.item(index));
63.934 +
63.935 + if ((index + step) == (nodelist.getLength() - 1)) {
63.936 + parent.appendChild(deletedElt);
63.937 + } else {
63.938 + // SURE? it seems that after a removeChild the indices of the nodes
63.939 + // in the nodelist seem not to change. Checking the DOM spec the
63.940 + // nodelist is live, but this seems not to be true for index changes
63.941 + // is this a bug, or correct?
63.942 + // Due to this behaviour the following seperation betweem step forward
63.943 + // and backward is necessary.
63.944 + if (step < 0) {
63.945 + parent.insertBefore(deletedElt, nodelist.item(index + step));
63.946 + } else {
63.947 + parent.insertBefore(deletedElt, nodelist.item(index + step + 1));
63.948 + }
63.949 + }
63.950 + }
63.951 +
63.952 + /**
63.953 + * Removes all children of the specified node.
63.954 + *
63.955 + * @param node the node.
63.956 + */
63.957 + public static void removeAllChildren(Node node) {
63.958 + Node child;
63.959 + while ((child = node.getFirstChild()) != null) {
63.960 + node.removeChild(child);
63.961 + }
63.962 + }
63.963 +
63.964 + /**
63.965 + * __UNDOCUMENTED__
63.966 + *
63.967 + * @param isNamespaceAware __UNDOCUMENTED__
63.968 + * @param isValidating __UNDOCUMENTED__
63.969 + * @return __UNDOCUMENTED__
63.970 + */
63.971 + public static Document newDocument(boolean isNamespaceAware, boolean isValidating) {
63.972 + // !!! workaround to enable Chiba to run within WebLogic Server
63.973 + // Force JAXP to use xerces as the default JAXP parser doesn't work with Chiba
63.974 + //
63.975 + // String oldFactory = System.getProperty("javax.xml.parsers.DocumentBuilderFactory");
63.976 + // System.setProperty("javax.xml.parsers.DocumentBuilderFactory","org.apache.xerces.jaxp.DocumentBuilderFactoryImpl");
63.977 + DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
63.978 +
63.979 + // restore to original factory
63.980 + //
63.981 + // System.setProperty("javax.xml.parsers.DocumentBuilderFactory",oldFactory);
63.982 + // !!! end workaround
63.983 + factory = DocumentBuilderFactory.newInstance();
63.984 + factory.setNamespaceAware(isNamespaceAware);
63.985 + factory.setValidating(isValidating);
63.986 +
63.987 + try {
63.988 + // Create builder.
63.989 + DocumentBuilder builder = factory.newDocumentBuilder();
63.990 +
63.991 + return builder.newDocument();
63.992 + } catch (ParserConfigurationException pce) {
63.993 + System.err.println(pce.toString());
63.994 + }
63.995 +
63.996 + return null;
63.997 + }
63.998 +
63.999 + /**
63.1000 + * __UNDOCUMENTED__
63.1001 + *
63.1002 + * @param in __UNDOCUMENTED__
63.1003 + * @param namespaces __UNDOCUMENTED__
63.1004 + * @param validating __UNDOCUMENTED__
63.1005 + * @return __UNDOCUMENTED__
63.1006 + * @throws ParserConfigurationException __UNDOCUMENTED__
63.1007 + * @throws SAXException __UNDOCUMENTED__
63.1008 + * @throws IOException __UNDOCUMENTED__
63.1009 + */
63.1010 + public static Document parseInputStream(InputStream in, boolean namespaces, boolean validating)
63.1011 + throws ParserConfigurationException, SAXException, IOException {
63.1012 + DocumentBuilder builder = createDocumentBuilder(namespaces, validating);
63.1013 +
63.1014 + return builder.parse(in);
63.1015 + }
63.1016 +
63.1017 + /**
63.1018 + * parses a Xml-File on disk and returns the parsed DOM Document.
63.1019 + *
63.1020 + * @param fileName - must be an absolute file-path pointing to the file
63.1021 + */
63.1022 + public static Document parseXmlFile(String fileName, boolean namespaces, boolean validating)
63.1023 + throws ParserConfigurationException, SAXException, IOException {
63.1024 + return DOMUtil.parseXmlFile(new File(fileName), namespaces, validating);
63.1025 + }
63.1026 +
63.1027 + /**
63.1028 + * __UNDOCUMENTED__
63.1029 + *
63.1030 + * @param file __UNDOCUMENTED__
63.1031 + * @param namespaces __UNDOCUMENTED__
63.1032 + * @param validating __UNDOCUMENTED__
63.1033 + * @return __UNDOCUMENTED__
63.1034 + * @throws ParserConfigurationException __UNDOCUMENTED__
63.1035 + * @throws SAXException __UNDOCUMENTED__
63.1036 + * @throws IOException __UNDOCUMENTED__
63.1037 + */
63.1038 + public static Document parseXmlFile(File file, boolean namespaces, boolean validating)
63.1039 + throws ParserConfigurationException, SAXException, IOException {
63.1040 + DocumentBuilder builder = createDocumentBuilder(namespaces, validating);
63.1041 +
63.1042 + return builder.parse(file);
63.1043 + }
63.1044 +
63.1045 + /**
63.1046 + * Serializes the specified node to stdout.
63.1047 + *
63.1048 + * @param node the node to serialize
63.1049 + */
63.1050 + public static void prettyPrintDOM(Node node) {
63.1051 + try {
63.1052 + prettyPrintDOM(node, System.out);
63.1053 + } catch (Exception e) {
63.1054 + e.printStackTrace();
63.1055 + }
63.1056 + }
63.1057 +
63.1058 + /**
63.1059 + * Serializes the specified node to the given stream. Serialization is achieved by an identity transform.
63.1060 + *
63.1061 + * @param node the node to serialize
63.1062 + * @param stream the stream to serialize to.
63.1063 + * @throws TransformerException if any error ccurred during the identity transform.
63.1064 + */
63.1065 + public static void prettyPrintDOM(Node node, OutputStream stream) throws TransformerException {
63.1066 + Transformer transformer = TransformerFactory.newInstance().newTransformer();
63.1067 + transformer.setOutputProperty(OutputKeys.INDENT, "yes");
63.1068 + transformer.setOutputProperty(OutputKeys.METHOD, "xml");
63.1069 + transformer.transform(new DOMSource(node), new StreamResult(stream));
63.1070 + }
63.1071 +
63.1072 + private static DocumentBuilder createDocumentBuilder(boolean namespaces, boolean validating)
63.1073 + throws ParserConfigurationException {
63.1074 + DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
63.1075 + factory.setNamespaceAware(namespaces);
63.1076 + factory.setValidating(validating);
63.1077 +
63.1078 + // factory.setAttribute("http://xml.org/sax/features/namespace-prefixes)",new Boolean(true));
63.1079 + DocumentBuilder builder = factory.newDocumentBuilder();
63.1080 +
63.1081 + return builder;
63.1082 + }
63.1083 +
63.1084 +}
63.1085 +
63.1086 +// end of class
64.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
64.2 +++ b/enterprise/openesbaddons/workflow/project/chiba_src/org/chiba/xml/dom/DOMWhitespace.java Thu Apr 26 02:33:27 2007 +0000
64.3 @@ -0,0 +1,253 @@
64.4 +// Copyright 2006 Chibacon
64.5 +/*
64.6 + *
64.7 + * Artistic License
64.8 + *
64.9 + * Preamble
64.10 + *
64.11 + * The intent of this document is to state the conditions under which a Package may be copied, such that
64.12 + * the Copyright Holder maintains some semblance of artistic control over the development of the
64.13 + * package, while giving the users of the package the right to use and distribute the Package in a
64.14 + * more-or-less customary fashion, plus the right to make reasonable modifications.
64.15 + *
64.16 + * Definitions:
64.17 + *
64.18 + * "Package" refers to the collection of files distributed by the Copyright Holder, and derivatives
64.19 + * of that collection of files created through textual modification.
64.20 + *
64.21 + * "Standard Version" refers to such a Package if it has not been modified, or has been modified
64.22 + * in accordance with the wishes of the Copyright Holder.
64.23 + *
64.24 + * "Copyright Holder" is whoever is named in the copyright or copyrights for the package.
64.25 + *
64.26 + * "You" is you, if you're thinking about copying or distributing this Package.
64.27 + *
64.28 + * "Reasonable copying fee" is whatever you can justify on the basis of media cost, duplication
64.29 + * charges, time of people involved, and so on. (You will not be required to justify it to the
64.30 + * Copyright Holder, but only to the computing community at large as a market that must bear the
64.31 + * fee.)
64.32 + *
64.33 + * "Freely Available" means that no fee is charged for the item itself, though there may be fees
64.34 + * involved in handling the item. It also means that recipients of the item may redistribute it under
64.35 + * the same conditions they received it.
64.36 + *
64.37 + * 1. You may make and give away verbatim copies of the source form of the Standard Version of this
64.38 + * Package without restriction, provided that you duplicate all of the original copyright notices and
64.39 + * associated disclaimers.
64.40 + *
64.41 + * 2. You may apply bug fixes, portability fixes and other modifications derived from the Public Domain
64.42 + * or from the Copyright Holder. A Package modified in such a way shall still be considered the
64.43 + * Standard Version.
64.44 + *
64.45 + * 3. You may otherwise modify your copy of this Package in any way, provided that you insert a
64.46 + * prominent notice in each changed file stating how and when you changed that file, and provided that
64.47 + * you do at least ONE of the following:
64.48 + *
64.49 + * a) place your modifications in the Public Domain or otherwise make them Freely
64.50 + * Available, such as by posting said modifications to Usenet or an equivalent medium, or
64.51 + * placing the modifications on a major archive site such as ftp.uu.net, or by allowing the
64.52 + * Copyright Holder to include your modifications in the Standard Version of the Package.
64.53 + *
64.54 + * b) use the modified Package only within your corporation or organization.
64.55 + *
64.56 + * c) rename any non-standard executables so the names do not conflict with standard
64.57 + * executables, which must also be provided, and provide a separate manual page for each
64.58 + * non-standard executable that clearly documents how it differs from the Standard
64.59 + * Version.
64.60 + *
64.61 + * d) make other distribution arrangements with the Copyright Holder.
64.62 + *
64.63 + * 4. You may distribute the programs of this Package in object code or executable form, provided that
64.64 + * you do at least ONE of the following:
64.65 + *
64.66 + * a) distribute a Standard Version of the executables and library files, together with
64.67 + * instructions (in the manual page or equivalent) on where to get the Standard Version.
64.68 + *
64.69 + * b) accompany the distribution with the machine-readable source of the Package with
64.70 + * your modifications.
64.71 + *
64.72 + * c) accompany any non-standard executables with their corresponding Standard Version
64.73 + * executables, giving the non-standard executables non-standard names, and clearly
64.74 + * documenting the differences in manual pages (or equivalent), together with instructions
64.75 + * on where to get the Standard Version.
64.76 + *
64.77 + * d) make other distribution arrangements with the Copyright Holder.
64.78 + *
64.79 + * 5. You may charge a reasonable copying fee for any distribution of this Package. You may charge
64.80 + * any fee you choose for support of this Package. You may not charge a fee for this Package itself.
64.81 + * However, you may distribute this Package in aggregate with other (possibly commercial) programs as
64.82 + * part of a larger (possibly commercial) software distribution provided that you do not advertise this
64.83 + * Package as a product of your own.
64.84 + *
64.85 + * 6. The scripts and library files supplied as input to or produced as output from the programs of this
64.86 + * Package do not automatically fall under the copyright of this Package, but belong to whomever
64.87 + * generated them, and may be sold commercially, and may be aggregated with this Package.
64.88 + *
64.89 + * 7. C or perl subroutines supplied by you and linked into this Package shall not be considered part of
64.90 + * this Package.
64.91 + *
64.92 + * 8. The name of the Copyright Holder may not be used to endorse or promote products derived from
64.93 + * this software without specific prior written permission.
64.94 + *
64.95 + * 9. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
64.96 + * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
64.97 + * MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
64.98 + *
64.99 + */
64.100 +package org.chiba.xml.dom;
64.101 +
64.102 +import org.w3c.dom.Node;
64.103 +import org.w3c.dom.NodeList;
64.104 +
64.105 +import java.util.ArrayList;
64.106 +import java.util.List;
64.107 +
64.108 +/**
64.109 + * The DOM Whitespace helper class provides a set of methods that might
64.110 + * be helpful in implementing adjustable whitespace and comment handling
64.111 + * in DOM processing applications.
64.112 + *
64.113 + * @author <a href="mailto:unl@users.sourceforge.net">Ulrich Nicolas Lissé</a>
64.114 + * @version $Id$
64.115 + */
64.116 +public class DOMWhitespace {
64.117 + // Utility methods.
64.118 +
64.119 + /**
64.120 + * Checks wether the given string consists of Unicode whitespace.
64.121 + *
64.122 + * @param string the string to be checked.
64.123 + * @return <CODE>true</CODE> if the given string consists of
64.124 + * Unicode whitespace, otherwise <CODE>false</CODE>.
64.125 + */
64.126 + public static boolean isWhitespace(String string) {
64.127 + if (string != null) {
64.128 + for (int index = 0; index < string.length(); index++) {
64.129 + if (!Character.isWhitespace(string.charAt(index))) {
64.130 + return false;
64.131 + }
64.132 + }
64.133 + }
64.134 +
64.135 + return true;
64.136 + }
64.137 +
64.138 + /**
64.139 + * Returns the index of the next item in the node list being not a
64.140 + * comment node.
64.141 + *
64.142 + * @param list the node list.
64.143 + * @param start the start index.
64.144 + * @return the index of the next item in the node list being not a
64.145 + * comment node.
64.146 + */
64.147 + public static int skipComments(NodeList list, int start) {
64.148 + for (int index = start; index < list.getLength(); index++) {
64.149 + if (list.item(index).getNodeType() != Node.COMMENT_NODE) {
64.150 + return index;
64.151 + }
64.152 + }
64.153 +
64.154 + return list.getLength();
64.155 + }
64.156 +
64.157 + /**
64.158 + * Returns the index of the next item in the node list being not a
64.159 + * whitespace text node.
64.160 + *
64.161 + * @param list the node list.
64.162 + * @param start the start index.
64.163 + * @return the index of the next item in the node list being not a
64.164 + * whitespace text node.
64.165 + */
64.166 + public static int skipWhitespace(NodeList list, int start) {
64.167 + for (int index = start; index < list.getLength(); index++) {
64.168 + if (list.item(index).getNodeType() != Node.TEXT_NODE) {
64.169 + return index;
64.170 + }
64.171 +
64.172 + if (!isWhitespace(list.item(index).getNodeValue())) {
64.173 + return index;
64.174 + }
64.175 + }
64.176 +
64.177 + return list.getLength();
64.178 + }
64.179 +
64.180 + /**
64.181 + * Returns the index of the next item in the node list being neither a
64.182 + * whitespace text node nor a comment node.
64.183 + *
64.184 + * @param list the node list.
64.185 + * @param start the start index.
64.186 + * @return the index of the next item in the node list being neither a
64.187 + * whitespace text node nor a comment node.
64.188 + */
64.189 + public static int skipWhitespaceAndComments(NodeList list, int start) {
64.190 + for (int index = start; index < list.getLength(); index++) {
64.191 + if (list.item(index) == null) {
64.192 + return index;
64.193 + }
64.194 +
64.195 + if ((list.item(index).getNodeType() != Node.COMMENT_NODE) &&
64.196 + (list.item(index).getNodeType() != Node.TEXT_NODE)) {
64.197 + return index;
64.198 + }
64.199 +
64.200 + if ((list.item(index).getNodeType() == Node.TEXT_NODE) &&
64.201 + !isWhitespace(list.item(index).getNodeValue())) {
64.202 + return index;
64.203 + }
64.204 + }
64.205 +
64.206 + return list.getLength();
64.207 + }
64.208 +
64.209 + /**
64.210 + * Splits the specified text into whitespace and text portions.
64.211 + * <p/>
64.212 + * Any leading or trailing whitespace characters as well as any
64.213 + * two or more adjacent whitespace characters within text are
64.214 + * separated.
64.215 + *
64.216 + * @param text the text to denormalize.
64.217 + * @return a list of whitespace and text portions.
64.218 + */
64.219 + public static List denormalizeText(String text) {
64.220 + if (text == null) {
64.221 + return null;
64.222 + }
64.223 +
64.224 + List list = new ArrayList();
64.225 + if (text.length() == 0) {
64.226 + list.add(text);
64.227 + return list;
64.228 + }
64.229 +
64.230 + int start = 0;
64.231 + boolean whitespace = Character.isWhitespace(text.charAt(start));
64.232 +
64.233 + for (int index = 0; index < text.length(); index++) {
64.234 + if (whitespace && (!Character.isWhitespace(text.charAt(index)))) {
64.235 + // add whitespace and switch mode
64.236 + list.add(text.substring(start, index));
64.237 + start = index;
64.238 + whitespace = false;
64.239 + }
64.240 + if (!whitespace && Character.isWhitespace(text.charAt(index))) {
64.241 + // look ahead to skip a single whitespace character within text
64.242 + if ((index + 1 < text.length() && Character.isWhitespace(text.charAt(index + 1))) ||
64.243 + index + 1 == text.length()) {
64.244 + // add text and switch mode
64.245 + list.add(text.substring(start, index));
64.246 + start = index;
64.247 + whitespace = true;
64.248 + }
64.249 + }
64.250 + }
64.251 +
64.252 + list.add(text.substring(start, text.length()));
64.253 + return list;
64.254 + }
64.255 +
64.256 +}
65.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
65.2 +++ b/enterprise/openesbaddons/workflow/project/chiba_src/org/chiba/xml/ns/NamespaceConstants.java Thu Apr 26 02:33:27 2007 +0000
65.3 @@ -0,0 +1,188 @@
65.4 +// Copyright 2006 Chibacon
65.5 +/*
65.6 + *
65.7 + * Artistic License
65.8 + *
65.9 + * Preamble
65.10 + *
65.11 + * The intent of this document is to state the conditions under which a Package may be copied, such that
65.12 + * the Copyright Holder maintains some semblance of artistic control over the development of the
65.13 + * package, while giving the users of the package the right to use and distribute the Package in a
65.14 + * more-or-less customary fashion, plus the right to make reasonable modifications.
65.15 + *
65.16 + * Definitions:
65.17 + *
65.18 + * "Package" refers to the collection of files distributed by the Copyright Holder, and derivatives
65.19 + * of that collection of files created through textual modification.
65.20 + *
65.21 + * "Standard Version" refers to such a Package if it has not been modified, or has been modified
65.22 + * in accordance with the wishes of the Copyright Holder.
65.23 + *
65.24 + * "Copyright Holder" is whoever is named in the copyright or copyrights for the package.
65.25 + *
65.26 + * "You" is you, if you're thinking about copying or distributing this Package.
65.27 + *
65.28 + * "Reasonable copying fee" is whatever you can justify on the basis of media cost, duplication
65.29 + * charges, time of people involved, and so on. (You will not be required to justify it to the
65.30 + * Copyright Holder, but only to the computing community at large as a market that must bear the
65.31 + * fee.)
65.32 + *
65.33 + * "Freely Available" means that no fee is charged for the item itself, though there may be fees
65.34 + * involved in handling the item. It also means that recipients of the item may redistribute it under
65.35 + * the same conditions they received it.
65.36 + *
65.37 + * 1. You may make and give away verbatim copies of the source form of the Standard Version of this
65.38 + * Package without restriction, provided that you duplicate all of the original copyright notices and
65.39 + * associated disclaimers.
65.40 + *
65.41 + * 2. You may apply bug fixes, portability fixes and other modifications derived from the Public Domain
65.42 + * or from the Copyright Holder. A Package modified in such a way shall still be considered the
65.43 + * Standard Version.
65.44 + *
65.45 + * 3. You may otherwise modify your copy of this Package in any way, provided that you insert a
65.46 + * prominent notice in each changed file stating how and when you changed that file, and provided that
65.47 + * you do at least ONE of the following:
65.48 + *
65.49 + * a) place your modifications in the Public Domain or otherwise make them Freely
65.50 + * Available, such as by posting said modifications to Usenet or an equivalent medium, or
65.51 + * placing the modifications on a major archive site such as ftp.uu.net, or by allowing the
65.52 + * Copyright Holder to include your modifications in the Standard Version of the Package.
65.53 + *
65.54 + * b) use the modified Package only within your corporation or organization.
65.55 + *
65.56 + * c) rename any non-standard executables so the names do not conflict with standard
65.57 + * executables, which must also be provided, and provide a separate manual page for each
65.58 + * non-standard executable that clearly documents how it differs from the Standard
65.59 + * Version.
65.60 + *
65.61 + * d) make other distribution arrangements with the Copyright Holder.
65.62 + *
65.63 + * 4. You may distribute the programs of this Package in object code or executable form, provided that
65.64 + * you do at least ONE of the following:
65.65 + *
65.66 + * a) distribute a Standard Version of the executables and library files, together with
65.67 + * instructions (in the manual page or equivalent) on where to get the Standard Version.
65.68 + *
65.69 + * b) accompany the distribution with the machine-readable source of the Package with
65.70 + * your modifications.
65.71 + *
65.72 + * c) accompany any non-standard executables with their corresponding Standard Version
65.73 + * executables, giving the non-standard executables non-standard names, and clearly
65.74 + * documenting the differences in manual pages (or equivalent), together with instructions
65.75 + * on where to get the Standard Version.
65.76 + *
65.77 + * d) make other distribution arrangements with the Copyright Holder.
65.78 + *
65.79 + * 5. You may charge a reasonable copying fee for any distribution of this Package. You may charge
65.80 + * any fee you choose for support of this Package. You may not charge a fee for this Package itself.
65.81 + * However, you may distribute this Package in aggregate with other (possibly commercial) programs as
65.82 + * part of a larger (possibly commercial) software distribution provided that you do not advertise this
65.83 + * Package as a product of your own.
65.84 + *
65.85 + * 6. The scripts and library files supplied as input to or produced as output from the programs of this
65.86 + * Package do not automatically fall under the copyright of this Package, but belong to whomever
65.87 + * generated them, and may be sold commercially, and may be aggregated with this Package.
65.88 + *
65.89 + * 7. C or perl subroutines supplied by you and linked into this Package shall not be considered part of
65.90 + * this Package.
65.91 + *
65.92 + * 8. The name of the Copyright Holder may not be used to endorse or promote products derived from
65.93 + * this software without specific prior written permission.
65.94 + *
65.95 + * 9. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
65.96 + * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
65.97 + * MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
65.98 + *
65.99 + */
65.100 +package org.chiba.xml.ns;
65.101 +
65.102 +/**
65.103 + * Common namespace URIs and prefixes.
65.104 + *
65.105 + * @author Ulrich Nicolas Lissé
65.106 + * @version $Id$
65.107 + */
65.108 +public interface NamespaceConstants {
65.109 +
65.110 + /**
65.111 + * The Chiba namespace (will be declared automatically).
65.112 + */
65.113 + String CHIBA_NS = "http://chiba.sourceforge.net/xforms";
65.114 +
65.115 + /**
65.116 + * The Chiba namespace prefix.
65.117 + */
65.118 + String CHIBA_PREFIX = "chiba";
65.119 +
65.120 + /**
65.121 + * The XForms namespace.
65.122 + */
65.123 + String XFORMS_NS = "http://www.w3.org/2002/xforms";
65.124 +
65.125 + /**
65.126 + * The XForms namespace prefix.
65.127 + */
65.128 + String XFORMS_PREFIX = "xf";
65.129 +
65.130 + /**
65.131 + * The XHTML namespace (default namespace for generated and transformed
65.132 + * documents).
65.133 + */
65.134 + String XHTML_NS = "http://www.w3.org/1999/xhtml";
65.135 +
65.136 + /**
65.137 + * The XHTML namespace prefix.
65.138 + */
65.139 + String XHTML_PREFIX = "xhtml";
65.140 +
65.141 + /**
65.142 + * The XML namespace.
65.143 + */
65.144 + String XML_NS = "http://www.w3.org/XML/1998/namespace";
65.145 +
65.146 + /**
65.147 + * The XML namespace prefix.
65.148 + */
65.149 + String XML_PREFIX = "xml";
65.150 +
65.151 + /**
65.152 + * The XMLNS namespace.
65.153 + */
65.154 + String XMLNS_NS = "http://www.w3.org/2000/xmlns/";
65.155 +
65.156 + /**
65.157 + * The XMLNS namespace prefix.
65.158 + */
65.159 + String XMLNS_PREFIX = "xmlns";
65.160 +
65.161 + /**
65.162 + * The XML Events namespace.
65.163 + */
65.164 + String XMLEVENTS_NS = "http://www.w3.org/2001/xml-events";
65.165 +
65.166 + /**
65.167 + * The XML Events namespace prefix.
65.168 + */
65.169 + String XMLEVENTS_PREFIX = "ev";
65.170 +
65.171 + /**
65.172 + * The XML Schema namespace.
65.173 + */
65.174 + String XMLSCHEMA_NS = "http://www.w3.org/2001/XMLSchema";
65.175 +
65.176 + /**
65.177 + * The XML Schema namespace prefix.
65.178 + */
65.179 + String XMLSCHEMA_PREFIX = "xs";
65.180 +
65.181 + /**
65.182 + * The XML Schema Instance namespace.
65.183 + */
65.184 + String XMLSCHEMA_INSTANCE_NS = "http://www.w3.org/2001/XMLSchema-instance";
65.185 +
65.186 + /**
65.187 + * The XML Schema Instance namespace prefix.
65.188 + */
65.189 + String XMLSCHEMA_INSTANCE_PREFIX = "xsi";
65.190 +
65.191 +}
66.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
66.2 +++ b/enterprise/openesbaddons/workflow/project/chiba_src/org/chiba/xml/ns/NamespaceResolver.java Thu Apr 26 02:33:27 2007 +0000
66.3 @@ -0,0 +1,305 @@
66.4 +// Copyright 2006 Chibacon
66.5 +/*
66.6 + *
66.7 + * Artistic License
66.8 + *
66.9 + * Preamble
66.10 + *
66.11 + * The intent of this document is to state the conditions under which a Package may be copied, such that
66.12 + * the Copyright Holder maintains some semblance of artistic control over the development of the
66.13 + * package, while giving the users of the package the right to use and distribute the Package in a
66.14 + * more-or-less customary fashion, plus the right to make reasonable modifications.
66.15 + *
66.16 + * Definitions:
66.17 + *
66.18 + * "Package" refers to the collection of files distributed by the Copyright Holder, and derivatives
66.19 + * of that collection of files created through textual modification.
66.20 + *
66.21 + * "Standard Version" refers to such a Package if it has not been modified, or has been modified
66.22 + * in accordance with the wishes of the Copyright Holder.
66.23 + *
66.24 + * "Copyright Holder" is whoever is named in the copyright or copyrights for the package.
66.25 + *
66.26 + * "You" is you, if you're thinking about copying or distributing this Package.
66.27 + *
66.28 + * "Reasonable copying fee" is whatever you can justify on the basis of media cost, duplication
66.29 + * charges, time of people involved, and so on. (You will not be required to justify it to the
66.30 + * Copyright Holder, but only to the computing community at large as a market that must bear the
66.31 + * fee.)
66.32 + *
66.33 + * "Freely Available" means that no fee is charged for the item itself, though there may be fees
66.34 + * involved in handling the item. It also means that recipients of the item may redistribute it under
66.35 + * the same conditions they received it.
66.36 + *
66.37 + * 1. You may make and give away verbatim copies of the source form of the Standard Version of this
66.38 + * Package without restriction, provided that you duplicate all of the original copyright notices and
66.39 + * associated disclaimers.
66.40 + *
66.41 + * 2. You may apply bug fixes, portability fixes and other modifications derived from the Public Domain
66.42 + * or from the Copyright Holder. A Package modified in such a way shall still be considered the
66.43 + * Standard Version.
66.44 + *
66.45 + * 3. You may otherwise modify your copy of this Package in any way, provided that you insert a
66.46 + * prominent notice in each changed file stating how and when you changed that file, and provided that
66.47 + * you do at least ONE of the following:
66.48 + *
66.49 + * a) place your modifications in the Public Domain or otherwise make them Freely
66.50 + * Available, such as by posting said modifications to Usenet or an equivalent medium, or
66.51 + * placing the modifications on a major archive site such as ftp.uu.net, or by allowing the
66.52 + * Copyright Holder to include your modifications in the Standard Version of the Package.
66.53 + *
66.54 + * b) use the modified Package only within your corporation or organization.
66.55 + *
66.56 + * c) rename any non-standard executables so the names do not conflict with standard
66.57 + * executables, which must also be provided, and provide a separate manual page for each
66.58 + * non-standard executable that clearly documents how it differs from the Standard
66.59 + * Version.
66.60 + *
66.61 + * d) make other distribution arrangements with the Copyright Holder.
66.62 + *
66.63 + * 4. You may distribute the programs of this Package in object code or executable form, provided that
66.64 + * you do at least ONE of the following:
66.65 + *
66.66 + * a) distribute a Standard Version of the executables and library files, together with
66.67 + * instructions (in the manual page or equivalent) on where to get the Standard Version.
66.68 + *
66.69 + * b) accompany the distribution with the machine-readable source of the Package with
66.70 + * your modifications.
66.71 + *
66.72 + * c) accompany any non-standard executables with their corresponding Standard Version
66.73 + * executables, giving the non-standard executables non-standard names, and clearly
66.74 + * documenting the differences in manual pages (or equivalent), together with instructions
66.75 + * on where to get the Standard Version.
66.76 + *
66.77 + * d) make other distribution arrangements with the Copyright Holder.
66.78 + *
66.79 + * 5. You may charge a reasonable copying fee for any distribution of this Package. You may charge
66.80 + * any fee you choose for support of this Package. You may not charge a fee for this Package itself.
66.81 + * However, you may distribute this Package in aggregate with other (possibly commercial) programs as
66.82 + * part of a larger (possibly commercial) software distribution provided that you do not advertise this
66.83 + * Package as a product of your own.
66.84 + *
66.85 + * 6. The scripts and library files supplied as input to or produced as output from the programs of this
66.86 + * Package do not automatically fall under the copyright of this Package, but belong to whomever
66.87 + * generated them, and may be sold commercially, and may be aggregated with this Package.
66.88 + *
66.89 + * 7. C or perl subroutines supplied by you and linked into this Package shall not be considered part of
66.90 + * this Package.
66.91 + *
66.92 + * 8. The name of the Copyright Holder may not be used to endorse or promote products derived from
66.93 + * this software without specific prior written permission.
66.94 + *
66.95 + * 9. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
66.96 + * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
66.97 + * MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
66.98 + *
66.99 + */
66.100 +package org.chiba.xml.ns;
66.101 +
66.102 +import org.w3c.dom.Element;
66.103 +import org.w3c.dom.NamedNodeMap;
66.104 +import org.w3c.dom.Node;
66.105 +
66.106 +import java.util.HashMap;
66.107 +import java.util.Map;
66.108 +
66.109 +/**
66.110 + * This class resolves the namespace information used by a given host document.
66.111 + * It contains utility methods for resolving both namespace uris and prefixes as
66.112 + * well as for resolving all namespaces in scope.
66.113 + *
66.114 + * @author Joern Turner
66.115 + * @author Ulrich Nicolas Lissé
66.116 + * @version $Id$
66.117 + */
66.118 +public class NamespaceResolver {
66.119 +
66.120 + /**
66.121 + * Returns a map of all namespace declarations in scope for the specified
66.122 + * context element.
66.123 + * <p/>
66.124 + * Note that if multiple default namespace declarations are found on the way
66.125 + * up to the root of the document, only the first one found is used.
66.126 + *
66.127 + * @param context the context element.
66.128 + * @return a map of all namespace declarations in scope for the specified
66.129 + * context element.
66.130 + */
66.131 + public static Map getAllNamespaces(Element context) {
66.132 + Map map = new HashMap();
66.133 + NamespaceResolver.getAllNamespaces(context, map);
66.134 + return map;
66.135 + }
66.136 +
66.137 + /**
66.138 + * Returns the namespace uri for the specified namespace prefix.
66.139 + * <p/>
66.140 + * When the specified prefix is <code>null</code> or empty, this method
66.141 + * returns the default namespace uri, if any. If the prefix is not bound to
66.142 + * a namespace uri, <code>null</code> is returned.
66.143 + *
66.144 + * @param context the context element.
66.145 + * @param prefix the namespace prefix.
66.146 + * @return the namespace uri for the specified namespace prefix.
66.147 + */
66.148 + public static String getNamespaceURI(Element context, String prefix) {
66.149 + NamedNodeMap attrs = context.getAttributes();
66.150 + for (int c = 0; c < attrs.getLength(); c++) {
66.151 + Node attr = attrs.item(c);
66.152 +
66.153 + if (NamespaceConstants.XMLNS_NS.equals(attr.getNamespaceURI())) {
66.154 + // check for default namespace declaration
66.155 + if (attr.getPrefix() == null && (prefix == null || prefix.length() == 0)) {
66.156 + return attr.getNodeValue();
66.157 + }
66.158 + // check for prefixed namespace declaration
66.159 + if (NamespaceConstants.XMLNS_PREFIX.equals(attr.getPrefix()) && attr.getLocalName().equals(prefix)) {
66.160 + return attr.getNodeValue();
66.161 + }
66.162 + }
66.163 + }
66.164 +
66.165 + Node n = context.getParentNode();
66.166 + if (n != null && n.getNodeType() == Node.ELEMENT_NODE) {
66.167 + return NamespaceResolver.getNamespaceURI((Element) n, prefix);
66.168 + }
66.169 +
66.170 + return null;
66.171 + }
66.172 +
66.173 + /**
66.174 + * Returns the namespace prefix for the specified namespace uri.
66.175 + * <p/>
66.176 + * When the specified namespace uri matches the default namespace uri, an
66.177 + * empty prefix is returned. If no prefix is not bound to the specified
66.178 + * namespace uri, <code>null</code> is returned.
66.179 + *
66.180 + * @param context the context element.
66.181 + * @param uri the namespace uri.
66.182 + * @return the namespace prefix for the specified namespace uri.
66.183 + */
66.184 + public static String getPrefix(Element context, String uri) {
66.185 + if (uri.equals(context.getNamespaceURI())) {
66.186 + return context.getPrefix();
66.187 + }
66.188 + NamedNodeMap attrs = context.getAttributes();
66.189 + for (int c = 0; c < attrs.getLength(); c++) {
66.190 + Node attr = attrs.item(c);
66.191 +
66.192 + if (NamespaceConstants.XMLNS_NS.equals(attr.getNamespaceURI())) {
66.193 + // check for default namespace declaration
66.194 + if (attr.getPrefix() == null && attr.getNodeValue().equals(uri)) {
66.195 + return "";
66.196 + }
66.197 + // check for prefixed namespace declaration
66.198 + if (NamespaceConstants.XMLNS_PREFIX.equals(attr.getPrefix()) && attr.getNodeValue().equals(uri)) {
66.199 + return attr.getLocalName();
66.200 + }
66.201 + }
66.202 + }
66.203 +
66.204 + Node n = context.getParentNode();
66.205 + if (n != null && n.getNodeType() == Node.ELEMENT_NODE) {
66.206 + return NamespaceResolver.getPrefix((Element) n, uri);
66.207 + }
66.208 +
66.209 + return null;
66.210 + }
66.211 +
66.212 + /**
66.213 + * Applies all namespace declarations in scope for the specified context
66.214 + * element to the specified candidate element.
66.215 + * <p/>
66.216 + * Any namespace declarations occurring on the candidate element are
66.217 + * preserved.
66.218 + *
66.219 + * @param context the context element.
66.220 + * @param candidate the candidate element.
66.221 + */
66.222 + public static void applyNamespaces(Element context, Element candidate) {
66.223 + NamedNodeMap attrs = context.getAttributes();
66.224 + for (int c = 0; c < attrs.getLength(); c++) {
66.225 + Node attr = attrs.item(c);
66.226 +
66.227 + // check for namespace declarations unknown by candidate
66.228 + if (NamespaceConstants.XMLNS_NS.equals(attr.getNamespaceURI()) &&
66.229 + !candidate.hasAttributeNS(NamespaceConstants.XMLNS_NS, attr.getLocalName())) {
66.230 + // copy namespace declaration
66.231 + candidate.setAttributeNS(NamespaceConstants.XMLNS_NS, attr.getNodeName(), attr.getNodeValue());
66.232 + }
66.233 + }
66.234 +
66.235 + Node n = context.getParentNode();
66.236 + if (n != null && n.getNodeType() == Node.ELEMENT_NODE) {
66.237 + NamespaceResolver.applyNamespaces((Element) n, candidate);
66.238 + }
66.239 + }
66.240 +
66.241 + /**
66.242 + * Returns an expanded name for the given qualified name.
66.243 + * <p/>
66.244 + * In contrast to a qualified name an expanded name is globally unique. See
66.245 + * http://www.jclark.com/xml/xmlns.htm for reference.
66.246 + *
66.247 + * @param context the context element.
66.248 + * @param name the qualified name.
66.249 + * @return an expanded name for the given qualified name.
66.250 + */
66.251 + public static String getExpandedName(Element context, String name) {
66.252 + int separator = name.indexOf(':');
66.253 + String prefix = separator > -1 ? name.substring(0, separator) : null;
66.254 + String localName = separator > -1 ? name.substring(separator + 1) : name;
66.255 + String namespaceURI = prefix != null ? NamespaceResolver.getNamespaceURI(context, prefix) : null;
66.256 +
66.257 + return NamespaceResolver.expand(namespaceURI, localName);
66.258 + }
66.259 +
66.260 + /**
66.261 + * Returns an expended name from the optional namespace uri and the given
66.262 + * local name.
66.263 + * <p/>
66.264 + * An expanded name is contructed in the following way: <code>'{' +
66.265 + * namespaceURI + '}' + localName</code>. If no namespace uri is specified,
66.266 + * the local name is returned.
66.267 + *
66.268 + * @param namespaceURI the namespace uri.
66.269 + * @param localName the local name.
66.270 + * @return an expanded name.
66.271 + */
66.272 + public static String expand(String namespaceURI, String localName) {
66.273 + StringBuffer buffer = new StringBuffer();
66.274 + if (namespaceURI != null) {
66.275 + buffer.append('{');
66.276 + buffer.append(namespaceURI);
66.277 + buffer.append('}');
66.278 + }
66.279 +
66.280 + buffer.append(localName);
66.281 + return buffer.toString();
66.282 + }
66.283 +
66.284 + private static void getAllNamespaces(Element context, Map namespaces) {
66.285 + String prefix;
66.286 + Node attr;
66.287 + NamedNodeMap attrs = context.getAttributes();
66.288 + for (int c = 0; c < attrs.getLength(); c++) {
66.289 + attr = attrs.item(c);
66.290 +
66.291 + if (NamespaceConstants.XMLNS_NS.equals(attr.getNamespaceURI())) {
66.292 + prefix = attr.getPrefix() == null ? "" : attr.getLocalName();
66.293 +
66.294 + // check for overridden namespace declaration
66.295 + if (namespaces.get(prefix) == null) {
66.296 + namespaces.put(prefix, attr.getNodeValue());
66.297 + }
66.298 + }
66.299 + }
66.300 +
66.301 + Node n = context.getParentNode();
66.302 + if (n != null && n.getNodeType() == Node.ELEMENT_NODE) {
66.303 + NamespaceResolver.getAllNamespaces((Element) n, namespaces);
66.304 + }
66.305 + }
66.306 +}
66.307 +
66.308 +// end of class
67.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
67.2 +++ b/enterprise/openesbaddons/workflow/project/chiba_src/org/w3c/xforms/XFormsModelElement.java Thu Apr 26 02:33:27 2007 +0000
67.3 @@ -0,0 +1,182 @@
67.4 +/*
67.5 + *
67.6 + * Artistic License
67.7 + *
67.8 + * Preamble
67.9 + *
67.10 + * The intent of this document is to state the conditions under which a Package may be copied, such that
67.11 + * the Copyright Holder maintains some semblance of artistic control over the development of the
67.12 + * package, while giving the users of the package the right to use and distribute the Package in a
67.13 + * more-or-less customary fashion, plus the right to make reasonable modifications.
67.14 + *
67.15 + * Definitions:
67.16 + *
67.17 + * "Package" refers to the collection of files distributed by the Copyright Holder, and derivatives
67.18 + * of that collection of files created through textual modification.
67.19 + *
67.20 + * "Standard Version" refers to such a Package if it has not been modified, or has been modified
67.21 + * in accordance with the wishes of the Copyright Holder.
67.22 + *
67.23 + * "Copyright Holder" is whoever is named in the copyright or copyrights for the package.
67.24 + *
67.25 + * "You" is you, if you're thinking about copying or distributing this Package.
67.26 + *
67.27 + * "Reasonable copying fee" is whatever you can justify on the basis of media cost, duplication
67.28 + * charges, time of people involved, and so on. (You will not be required to justify it to the
67.29 + * Copyright Holder, but only to the computing community at large as a market that must bear the
67.30 + * fee.)
67.31 + *
67.32 + * "Freely Available" means that no fee is charged for the item itself, though there may be fees
67.33 + * involved in handling the item. It also means that recipients of the item may redistribute it under
67.34 + * the same conditions they received it.
67.35 + *
67.36 + * 1. You may make and give away verbatim copies of the source form of the Standard Version of this
67.37 + * Package without restriction, provided that you duplicate all of the original copyright notices and
67.38 + * associated disclaimers.
67.39 + *
67.40 + * 2. You may apply bug fixes, portability fixes and other modifications derived from the Public Domain
67.41 + * or from the Copyright Holder. A Package modified in such a way shall still be considered the
67.42 + * Standard Version.
67.43 + *
67.44 + * 3. You may otherwise modify your copy of this Package in any way, provided that you insert a
67.45 + * prominent notice in each changed file stating how and when you changed that file, and provided that
67.46 + * you do at least ONE of the following:
67.47 + *
67.48 + * a) place your modifications in the Public Domain or otherwise make them Freely
67.49 + * Available, such as by posting said modifications to Usenet or an equivalent medium, or
67.50 + * placing the modifications on a major archive site such as ftp.uu.net, or by allowing the
67.51 + * Copyright Holder to include your modifications in the Standard Version of the Package.
67.52 + *
67.53 + * b) use the modified Package only within your corporation or organization.
67.54 + *
67.55 + * c) rename any non-standard executables so the names do not conflict with standard
67.56 + * executables, which must also be provided, and provide a separate manual page for each
67.57 + * non-standard executable that clearly documents how it differs from the Standard
67.58 + * Version.
67.59 + *
67.60 + * d) make other distribution arrangements with the Copyright Holder.
67.61 + *
67.62 + * 4. You may distribute the programs of this Package in object code or executable form, provided that
67.63 + * you do at least ONE of the following:
67.64 + *
67.65 + * a) distribute a Standard Version of the executables and library files, together with
67.66 + * instructions (in the manual page or equivalent) on where to get the Standard Version.
67.67 + *
67.68 + * b) accompany the distribution with the machine-readable source of the Package with
67.69 + * your modifications.
67.70 + *
67.71 + * c) accompany any non-standard executables with their corresponding Standard Version
67.72 + * executables, giving the non-standard executables non-standard names, and clearly
67.73 + * documenting the differences in manual pages (or equivalent), together with instructions
67.74 + * on where to get the Standard Version.
67.75 + *
67.76 + * d) make other distribution arrangements with the Copyright Holder.
67.77 + *
67.78 + * 5. You may charge a reasonable copying fee for any distribution of this Package. You may charge
67.79 + * any fee you choose for support of this Package. You may not charge a fee for this Package itself.
67.80 + * However, you may distribute this Package in aggregate with other (possibly commercial) programs as
67.81 + * part of a larger (possibly commercial) software distribution provided that you do not advertise this
67.82 + * Package as a product of your own.
67.83 + *
67.84 + * 6. The scripts and library files supplied as input to or produced as output from the programs of this
67.85 + * Package do not automatically fall under the copyright of this Package, but belong to whomever
67.86 + * generated them, and may be sold commercially, and may be aggregated with this Package.
67.87 + *
67.88 + * 7. C or perl subroutines supplied by you and linked into this Package shall not be considered part of
67.89 + * this Package.
67.90 + *
67.91 + * 8. The name of the Copyright Holder may not be used to endorse or promote products derived from
67.92 + * this software without specific prior written permission.
67.93 + *
67.94 + * 9. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
67.95 + * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
67.96 + * MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
67.97 + *
67.98 + */
67.99 +package org.w3c.xforms;
67.100 +
67.101 +import org.w3c.dom.DOMException;
67.102 +import org.w3c.dom.Document;
67.103 +
67.104 +/**
67.105 + * Interface as defined by XForms Spec in
67.106 + * <a href="http://www.w3.org/TR/2006/REC-xforms-20060314/slice7.html#expr-instance">7.3
67.107 + * Instance Data</a>
67.108 + * <p/>
67.109 + * <q>For each model element, the XForms Processor maintains the state in an
67.110 + * internal structure called instance data that conforms to the XPath Data Model
67.111 + * [XPath 1.0]. XForms Processors that implement DOM must provide DOM access to
67.112 + * this instance data via the interface defined below.</q>
67.113 + * <p/>
67.114 + * The Interface corresponds to the following IDL:
67.115 + * <pre>
67.116 + * #include "dom.idl"
67.117 + *
67.118 + * pragma prefix "w3c.org"
67.119 + *
67.120 + * module xforms {
67.121 + * interface XFormsModelElement : dom::Element {
67.122 + * dom::Document getInstanceDocument(in dom::DOMString instanceID) raises(dom::DOMException);
67.123 + * void rebuild();
67.124 + * void recalculate();
67.125 + * void revalidate();
67.126 + * void refresh();
67.127 + * };
67.128 + * };
67.129 + * </pre>
67.130 + *
67.131 + * @author Ulrich Nicolas Lissé
67.132 + * @version $Id$
67.133 + */
67.134 +public interface XFormsModelElement {
67.135 +
67.136 + /**
67.137 + * 7.3.1 The getInstanceDocument() Method.
67.138 + * <p/>
67.139 + * This method returns a DOM Document that corresponds to the instance data
67.140 + * associated with the <code>instance</code> element containing an
67.141 + * <code>ID</code> matching the <code>instance-id</code> parameter. If there
67.142 + * is no matching instance data, a <code>DOMException</code> is thrown.
67.143 + *
67.144 + * @param instanceID the instance id.
67.145 + * @return the corresponding DOM document.
67.146 + * @throws DOMException if there is no matching instance data.
67.147 + */
67.148 + Document getInstanceDocument(String instanceID) throws DOMException;
67.149 +
67.150 + /**
67.151 + * 7.3.2 The rebuild() Method.
67.152 + * <p/>
67.153 + * This method signals the XForms Processor to rebuild any internal data
67.154 + * structures used to track computational dependencies within this XForms
67.155 + * Model. This method takes no parameters and raises no exceptions.
67.156 + */
67.157 + void rebuild();
67.158 +
67.159 + /**
67.160 + * 7.3.3 The recalculate() Method.
67.161 + * <p/>
67.162 + * This method signals the XForms Processor to perform a full recalculation
67.163 + * of this XForms Model. This method takes no parameters and raises no
67.164 + * exceptions.
67.165 + */
67.166 + void recalculate();
67.167 +
67.168 + /**
67.169 + * 7.3.4 The revalidate() Method.
67.170 + * <p/>
67.171 + * This method signals the XForms Processor to perform a full revalidation
67.172 + * of this XForms Model. This method takes no parameters and raises no
67.173 + * exceptions.
67.174 + */
67.175 + void revalidate();
67.176 +
67.177 + /**
67.178 + * 7.3.5 The refresh() Method.
67.179 + * <p/>
67.180 + * This method signals the XForms Processor to perform a full refresh of
67.181 + * form controls bound to instance nodes within this XForms Model. This
67.182 + * method takes no parameters and raises no exceptions.
67.183 + */
67.184 + void refresh();
67.185 +}
68.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
68.2 +++ b/enterprise/openesbaddons/workflow/project/manifest.mf Thu Apr 26 02:33:27 2007 +0000
68.3 @@ -0,0 +1,6 @@
68.4 +Manifest-Version: 1.0
68.5 +OpenIDE-Module: org.netbeans.modules.workflow.project
68.6 +OpenIDE-Module-Layer: org/netbeans/modules/workflow/project/ui/resources/layer.xml
68.7 +OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/workflow/project/ui/resources/Bundle.properties
68.8 +OpenIDE-Module-Specification-Version: 1.0
68.9 +
69.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
69.2 +++ b/enterprise/openesbaddons/workflow/project/nbproject/build-impl.xml Thu Apr 26 02:33:27 2007 +0000
69.3 @@ -0,0 +1,30 @@
69.4 +<?xml version="1.0" encoding="UTF-8"?>
69.5 +<!--
69.6 +*** GENERATED FROM project.xml - DO NOT EDIT ***
69.7 +*** EDIT ../build.xml INSTEAD ***
69.8 +-->
69.9 +<project name="com.sun.jbi.ui.devtool.projects.workflowpro-impl" basedir=".." xmlns:nbmproject="http://www.netbeans.org/ns/nb-module-project/2">
69.10 + <property file="nbproject/private/suite-private.properties"/>
69.11 + <property file="nbproject/suite.properties"/>
69.12 + <fail unless="suite.dir">You must set 'suite.dir' to point to your containing module suite</fail>
69.13 + <property file="${suite.dir}/nbproject/private/platform-private.properties"/>
69.14 + <property file="${suite.dir}/nbproject/platform.properties"/>
69.15 + <macrodef name="property" uri="http://www.netbeans.org/ns/nb-module-project/2">
69.16 + <attribute name="name"/>
69.17 + <attribute name="value"/>
69.18 + <sequential>
69.19 + <property name="@{name}" value="${@{value}}"/>
69.20 + </sequential>
69.21 + </macrodef>
69.22 + <property file="${user.properties.file}"/>
69.23 + <nbmproject:property name="harness.dir" value="nbplatform.${nbplatform.active}.harness.dir"/>
69.24 + <nbmproject:property name="netbeans.dest.dir" value="nbplatform.${nbplatform.active}.netbeans.dest.dir"/>
69.25 + <fail message="You must define 'nbplatform.${nbplatform.active}.harness.dir'">
69.26 + <condition>
69.27 + <not>
69.28 + <available file="${harness.dir}" type="dir"/>
69.29 + </not>
69.30 + </condition>
69.31 + </fail>
69.32 + <import file="${harness.dir}/build.xml"/>
69.33 +</project>
70.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
70.2 +++ b/enterprise/openesbaddons/workflow/project/nbproject/project.properties Thu Apr 26 02:33:27 2007 +0000
70.3 @@ -0,0 +1,5 @@
70.4 +javac.source=1.5
70.5 +extra.module.files=\
70.6 + modules/ext/workflowpro/workflowmodel.jar \
70.7 + modules/ext/workflowpro/wfse_def.jar \
70.8 + modules/ext/workflowpro/wsdl4j.jar
71.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
71.2 +++ b/enterprise/openesbaddons/workflow/project/nbproject/project.xml Thu Apr 26 02:33:27 2007 +0000
71.3 @@ -0,0 +1,269 @@
71.4 +<?xml version="1.0" encoding="UTF-8"?>
71.5 +<project xmlns="http://www.netbeans.org/ns/project/1">
71.6 + <type>org.netbeans.modules.apisupport.project</type>
71.7 + <configuration>
71.8 + <data xmlns="http://www.netbeans.org/ns/nb-module-project/2">
71.9 + <code-name-base>org.netbeans.modules.workflow.project</code-name-base>
71.10 + <suite-component/>
71.11 + <module-dependencies>
71.12 + <dependency>
71.13 + <code-name-base>org.apache.tools.ant.module</code-name-base>
71.14 + <build-prerequisite/>
71.15 + <compile-dependency/>
71.16 + <run-dependency>
71.17 + <release-version>3</release-version>
71.18 + <specification-version>3.24.1.1</specification-version>
71.19 + </run-dependency>
71.20 + </dependency>
71.21 + <dependency>
71.22 + <code-name-base>org.netbeans.api.java</code-name-base>
71.23 + <build-prerequisite/>
71.24 + <compile-dependency/>
71.25 + <run-dependency>
71.26 + <release-version>1</release-version>
71.27 + <specification-version>1.9.1</specification-version>
71.28 + </run-dependency>
71.29 + </dependency>
71.30 + <dependency>
71.31 + <code-name-base>org.netbeans.modules.compapp.projects.base</code-name-base>
71.32 + <build-prerequisite/>
71.33 + <compile-dependency/>
71.34 + <run-dependency>
71.35 + <specification-version>1.1</specification-version>
71.36 + </run-dependency>
71.37 + </dependency>
71.38 + <dependency>
71.39 + <code-name-base>org.netbeans.modules.j2eeserver</code-name-base>
71.40 + <build-prerequisite/>
71.41 + <compile-dependency/>
71.42 + <run-dependency>
71.43 + <release-version>4</release-version>
71.44 + <specification-version>1.12.1</specification-version>
71.45 + </run-dependency>
71.46 + </dependency>
71.47 + <dependency>
71.48 + <code-name-base>org.netbeans.modules.java.platform</code-name-base>
71.49 + <build-prerequisite/>
71.50 + <compile-dependency/>
71.51 + <run-dependency>
71.52 + <release-version>1</release-version>
71.53 + <specification-version>1.6.1</specification-version>
71.54 + </run-dependency>
71.55 + </dependency>
71.56 + <dependency>
71.57 + <code-name-base>org.netbeans.modules.java.project</code-name-base>
71.58 + <build-prerequisite/>
71.59 + <compile-dependency/>
71.60 + <run-dependency>
71.61 + <release-version>1</release-version>
71.62 + <specification-version>1.7.1</specification-version>
71.63 + </run-dependency>
71.64 + </dependency>
71.65 + <dependency>
71.66 + <code-name-base>org.netbeans.modules.project.ant</code-name-base>
71.67 + <build-prerequisite/>
71.68 + <compile-dependency/>
71.69 + <run-dependency>
71.70 + <release-version>1</release-version>
71.71 + <specification-version>1.11.1</specification-version>
71.72 + </run-dependency>
71.73 + </dependency>
71.74 + <dependency>
71.75 + <code-name-base>org.netbeans.modules.project.libraries</code-name-base>
71.76 + <build-prerequisite/>
71.77 + <compile-dependency/>
71.78 + <run-dependency>
71.79 + <release-version>1</release-version>
71.80 + <specification-version>1.12.1</specification-version>
71.81 + </run-dependency>
71.82 + </dependency>
71.83 + <dependency>
71.84 + <code-name-base>org.netbeans.modules.projectapi</code-name-base>
71.85 + <build-prerequisite/>
71.86 + <compile-dependency/>
71.87 + <run-dependency>
71.88 + <release-version>1</release-version>
71.89 + <specification-version>1.8.1</specification-version>
71.90 + </run-dependency>
71.91 + </dependency>
71.92 + <dependency>
71.93 + <code-name-base>org.netbeans.modules.projectuiapi</code-name-base>
71.94 + <build-prerequisite/>
71.95 + <compile-dependency/>
71.96 + <run-dependency>
71.97 + <release-version>1</release-version>
71.98 + <specification-version>1.12.1.5</specification-version>
71.99 + </run-dependency>
71.100 + </dependency>
71.101 + <dependency>
71.102 + <code-name-base>org.netbeans.modules.queries</code-name-base>
71.103 + <build-prerequisite/>
71.104 + <compile-dependency/>
71.105 + <run-dependency>
71.106 + <release-version>1</release-version>
71.107 + <specification-version>1.6.1</specification-version>
71.108 + </run-dependency>
71.109 + </dependency>
71.110 + <dependency>
71.111 + <code-name-base>org.netbeans.modules.xml.retriever</code-name-base>
71.112 + <build-prerequisite/>
71.113 + <compile-dependency/>
71.114 + <run-dependency>
71.115 + <release-version>1</release-version>
71.116 + <specification-version>1.0.11</specification-version>
71.117 + </run-dependency>
71.118 + </dependency>
71.119 + <dependency>
71.120 + <code-name-base>org.netbeans.modules.xml.schema.model</code-name-base>
71.121 + <build-prerequisite/>
71.122 + <compile-dependency/>
71.123 + <run-dependency>
71.124 + <release-version>1</release-version>
71.125 + <specification-version>1.1.21</specification-version>
71.126 + </run-dependency>
71.127 + </dependency>
71.128 + <dependency>
71.129 + <code-name-base>org.netbeans.modules.xml.wsdl.extensions</code-name-base>
71.130 + <build-prerequisite/>
71.131 + <compile-dependency/>
71.132 + <run-dependency>
71.133 + <specification-version>1.1</specification-version>
71.134 + </run-dependency>
71.135 + </dependency>
71.136 + <dependency>
71.137 + <code-name-base>org.netbeans.modules.xml.wsdl.model</code-name-base>
71.138 + <build-prerequisite/>
71.139 + <compile-dependency/>
71.140 + <run-dependency>
71.141 + <release-version>1</release-version>
71.142 + <specification-version>1.1.21</specification-version>
71.143 + </run-dependency>
71.144 + </dependency>
71.145 + <dependency>
71.146 + <code-name-base>org.netbeans.modules.xml.xam</code-name-base>
71.147 + <build-prerequisite/>
71.148 + <compile-dependency/>
71.149 + <run-dependency>
71.150 + <release-version>1</release-version>
71.151 + <specification-version>1.1.21</specification-version>
71.152 + </run-dependency>
71.153 + </dependency>
71.154 + <dependency>
71.155 + <code-name-base>org.openide.actions</code-name-base>
71.156 + <build-prerequisite/>
71.157 + <compile-dependency/>
71.158 + <run-dependency>
71.159 + <specification-version>6.4.1</specification-version>
71.160 + </run-dependency>
71.161 + </dependency>
71.162 + <dependency>
71.163 + <code-name-base>org.openide.dialogs</code-name-base>
71.164 + <build-prerequisite/>
71.165 + <compile-dependency/>
71.166 + <run-dependency>
71.167 + <specification-version>6.3.1</specification-version>
71.168 + </run-dependency>
71.169 + </dependency>
71.170 + <dependency>
71.171 + <code-name-base>org.openide.execution</code-name-base>
71.172 + <build-prerequisite/>
71.173 + <compile-dependency/>
71.174 + <run-dependency>
71.175 + <specification-version>1.7.1</specification-version>
71.176 + </run-dependency>
71.177 + </dependency>
71.178 + <dependency>
71.179 + <code-name-base>org.openide.explorer</code-name-base>
71.180 + <build-prerequisite/>
71.181 + <compile-dependency/>
71.182 + <run-dependency>
71.183 + <specification-version>6.4.1</specification-version>
71.184 + </run-dependency>
71.185 + </dependency>
71.186 + <dependency>
71.187 + <code-name-base>org.openide.filesystems</code-name-base>
71.188 + <build-prerequisite/>
71.189 + <compile-dependency/>
71.190 + <run-dependency>
71.191 + <specification-version>6.3.1</specification-version>
71.192 + </run-dependency>
71.193 + </dependency>
71.194 + <dependency>
71.195 + <code-name-base>org.openide.loaders</code-name-base>
71.196 + <build-prerequisite/>
71.197 + <compile-dependency/>
71.198 + <run-dependency>
71.199 + <specification-version>5.8.1</specification-version>
71.200 + </run-dependency>
71.201 + </dependency>
71.202 + <dependency>
71.203 + <code-name-base>org.openide.modules</code-name-base>
71.204 + <build-prerequisite/>
71.205 + <compile-dependency/>
71.206 + <run-dependency>
71.207 + <specification-version>6.4.1</specification-version>
71.208 + </run-dependency>
71.209 + </dependency>
71.210 + <dependency>
71.211 + <code-name-base>org.openide.nodes</code-name-base>
71.212 + <build-prerequisite/>
71.213 + <compile-dependency/>
71.214 + <run-dependency>
71.215 + <specification-version>6.6.1</specification-version>
71.216 + </run-dependency>
71.217 + </dependency>
71.218 + <dependency>
71.219 + <code-name-base>org.openide.options</code-name-base>
71.220 + <build-prerequisite/>
71.221 + <compile-dependency/>
71.222 + <run-dependency>
71.223 + <specification-version>6.3.1</specification-version>
71.224 + </run-dependency>
71.225 + </dependency>
71.226 + <dependency>
71.227 + <code-name-base>org.openide.util</code-name-base>
71.228 + <build-prerequisite/>
71.229 + <compile-dependency/>
71.230 + <run-dependency>
71.231 + <specification-version>6.5.1</specification-version>
71.232 + </run-dependency>
71.233 + </dependency>
71.234 + </module-dependencies>
71.235 + <public-packages/>
71.236 + <class-path-extension>
71.237 + <runtime-relative-path>ext/workflow/workflowmodel.jar</runtime-relative-path>
71.238 + <binary-origin>release/modules/ext/workflow/workflowmodel.jar</binary-origin>
71.239 + </class-path-extension>
71.240 + <class-path-extension>
71.241 + <runtime-relative-path>ext/workflow/wfse_def.jar</runtime-relative-path>
71.242 + <binary-origin>release/modules/ext/workflow/wfse_def.jar</binary-origin>
71.243 + </class-path-extension>
71.244 + <class-path-extension>
71.245 + <runtime-relative-path>ext/workflow/wsdl4j.jar</runtime-relative-path>
71.246 + <binary-origin>release/modules/ext/workflow/wsdl4j.jar</binary-origin>
71.247 + </class-path-extension>
71.248 + <class-path-extension>
71.249 + <runtime-relative-path>ext/workflow/log4j-1.2.13.jar</runtime-relative-path>
71.250 + <binary-origin>release/modules/ext/workflow/log4j-1.2.13.jar</binary-origin>
71.251 + </class-path-extension>
71.252 + <class-path-extension>
71.253 + <runtime-relative-path>ext/workflow/chiba.jar</runtime-relative-path>
71.254 + </class-path-extension>
71.255 + <class-path-extension>
71.256 + <runtime-relative-path>ext/xmlbeans-2.1.0/jsr173_1.0_api.jar</runtime-relative-path>
71.257 + </class-path-extension>
71.258 + <class-path-extension>
71.259 + <runtime-relative-path>ext/xmlbeans-2.1.0/resolver.jar</runtime-relative-path>
71.260 + </class-path-extension>
71.261 + <class-path-extension>
71.262 + <runtime-relative-path>ext/xmlbeans-2.1.0/xbean.jar</runtime-relative-path>
71.263 + </class-path-extension>
71.264 + <class-path-extension>
71.265 + <runtime-relative-path>ext/xmlbeans-2.1.0/xbean_xpath.jar</runtime-relative-path>
71.266 + </class-path-extension>
71.267 + <class-path-extension>
71.268 + <runtime-relative-path>ext/xmlbeans-2.1.0/xmlpublic.jar</runtime-relative-path>
71.269 + </class-path-extension>
71.270 + </data>
71.271 + </configuration>
71.272 +</project>
72.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
72.2 +++ b/enterprise/openesbaddons/workflow/project/nbproject/suite.properties Thu Apr 26 02:33:27 2007 +0000
72.3 @@ -0,0 +1,19 @@
72.4 +#
72.5 +# The contents of this file are subject to the terms of the Common Development
72.6 +# and Distribution License (the License). You may not use this file except in
72.7 +# compliance with the License.
72.8 +#
72.9 +# You can obtain a copy of the License at http://www.netbeans.org/cddl.html
72.10 +# or http://www.netbeans.org/cddl.txt.
72.11 +#
72.12 +# When distributing Covered Code, include this CDDL Header Notice in each file
72.13 +# and include the License file at http://www.netbeans.org/cddl.txt.
72.14 +# If applicable, add the following below the CDDL Header, with the fields
72.15 +# enclosed by brackets [] replaced by your own identifying information:
72.16 +# "Portions Copyrighted [year] [name of copyright owner]"
72.17 +#
72.18 +# The Original Software is NetBeans. The Initial Developer of the Original
72.19 +# Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
72.20 +# Microsystems, Inc. All Rights Reserved.
72.21 +#
72.22 +suite.dir=${basedir}/../../workflow
73.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
73.2 +++ b/enterprise/openesbaddons/workflow/project/src/META-INF/services/org.netbeans.spi.project.support.ant.AntBasedProjectType Thu Apr 26 02:33:27 2007 +0000
73.3 @@ -0,0 +1,1 @@
73.4 +org.netbeans.modules.workflow.project.WorkflowproProjectType
74.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
74.2 +++ b/enterprise/openesbaddons/workflow/project/src/META-INF/services/org.netbeans.spi.queries.CollocationQueryImplementation Thu Apr 26 02:33:27 2007 +0000
74.3 @@ -0,0 +1,1 @@
74.4 +org.netbeans.modules.compapp.projects.base.queries.SameDriveCollocationQuery
75.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
75.2 +++ b/enterprise/openesbaddons/workflow/project/src/org/netbeans/modules/workflow/project/Bundle.properties Thu Apr 26 02:33:27 2007 +0000
75.3 @@ -0,0 +1,1 @@
75.4 +OpenIDE-Module-Name=Workflow Project
76.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
76.2 +++ b/enterprise/openesbaddons/workflow/project/src/org/netbeans/modules/workflow/project/WorkflowproActionProvider.java Thu Apr 26 02:33:27 2007 +0000
76.3 @@ -0,0 +1,155 @@
76.4 +/*
76.5 + * Sun Public License Notice
76.6 + *
76.7 + * The contents of this file are subject to the Sun Public License
76.8 + * Version 1.0 (the "License"). You may not use this file except in
76.9 + * compliance with the License. A copy of the License is available at
76.10 + * http://www.sun.com/
76.11 + *
76.12 + * The Original Code is NetBeans. The Initial Developer of the Original
76.13 + * Code is Sun Microsystems, Inc. Portions Copyright 1997-2004 Sun
76.14 + * Microsystems, Inc. All Rights Reserved.
76.15 + */
76.16 +
76.17 +package org.netbeans.modules.workflow.project;
76.18 +
76.19 +import org.netbeans.modules.compapp.projects.base.IcanproConstants;
76.20 +import org.netbeans.modules.compapp.projects.base.ui.NoSelectedServerWarning;
76.21 +import org.netbeans.modules.compapp.projects.base.ui.customizer.IcanproProjectProperties;
76.22 +import java.awt.Dialog;
76.23 +import java.io.IOException;
76.24 +import java.util.HashMap;
76.25 +import java.util.Map;
76.26 +import java.util.Properties;
76.27 +import org.apache.tools.ant.module.api.support.ActionUtils;
76.28 +import org.netbeans.spi.project.ActionProvider;
76.29 +import org.netbeans.spi.project.support.ant.AntProjectHelper;
76.30 +import org.netbeans.spi.project.support.ant.ReferenceHelper;
76.31 +import org.openide.DialogDescriptor;
76.32 +import org.openide.DialogDisplayer;
76.33 +import org.openide.ErrorManager;
76.34 +import org.openide.filesystems.FileObject;
76.35 +import org.openide.util.Lookup;
76.36 +import org.openide.util.NbBundle;
76.37 +
76.38 +
76.39 +/** Action provider of the Web project. This is the place where to do
76.40 + * strange things to Web actions. E.g. compile-single.
76.41 + */
76.42 +class WorkflowproActionProvider implements ActionProvider {
76.43 +
76.44 + // Definition of commands
76.45 +
76.46 + // Commands available from Web project
76.47 + private static final String[] supportedActions = {
76.48 + COMMAND_BUILD,
76.49 + COMMAND_CLEAN,
76.50 + COMMAND_REBUILD,
76.51 + COMMAND_COMPILE_SINGLE,
76.52 + };
76.53 +
76.54 + // Project
76.55 + WorkflowproProject project;
76.56 +
76.57 + // Ant project helper of the project
76.58 + private AntProjectHelper antProjectHelper;
76.59 + private ReferenceHelper refHelper;
76.60 +
76.61 + /** Map from commands to ant targets */
76.62 + Map/*<String,String[]>*/ commands;
76.63 +
76.64 + public WorkflowproActionProvider(WorkflowproProject project, AntProjectHelper antProjectHelper, ReferenceHelper refHelper) {
76.65 + commands = new HashMap();
76.66 + commands.put(COMMAND_BUILD, new String[] {"dist"}); // NOI18N
76.67 + commands.put(COMMAND_CLEAN, new String[] {"clean"}); // NOI18N
76.68 + commands.put(COMMAND_REBUILD, new String[] {"clean", "dist"}); // NOI18N
76.69 +
76.70 + this.antProjectHelper = antProjectHelper;
76.71 + this.project = project;
76.72 + this.refHelper = refHelper;
76.73 + }
76.74 +
76.75 + private FileObject findBuildXml() {
76.76 + return project.getProjectDirectory().getFileObject(project.getBuildXmlName ());
76.77 + }
76.78 +
76.79 + public String[] getSupportedActions() {
76.80 + return supportedActions;
76.81 + }
76.82 +
76.83 + public void invokeAction( String command, Lookup context ) throws IllegalArgumentException {
76.84 + Properties p = new Properties ();
76.85 + p.setProperty("projectName", project.getName());
76.86 + String[] targetNames = (String[])commands.get(command);
76.87 + //EXECUTION PART
76.88 + if (command.equals (IcanproConstants.COMMAND_DEPLOY) || command.equals (IcanproConstants.COMMAND_REDEPLOY)) {
76.89 + if (!isSelectedServer ()) {
76.90 + return;
76.91 + }
76.92 + } else {
76.93 +// p = null;
76.94 + if (targetNames == null) {
76.95 + throw new IllegalArgumentException(command);
76.96 + }
76.97 + }
76.98 +
76.99 + try {
76.100 + ActionUtils.runTarget(findBuildXml(), targetNames, p);
76.101 + }
76.102 + catch (IOException e) {
76.103 + ErrorManager.getDefault().notify(e);
76.104 + }
76.105 + }
76.106 +
76.107 + public boolean isActionEnabled( String command, Lookup context ) {
76.108 +
76.109 + if ( findBuildXml() == null ) {
76.110 + return false;
76.111 + }
76.112 + return true;
76.113 +
76.114 + }
76.115 +
76.116 + // Private methods -----------------------------------------------------
76.117 +
76.118 + private boolean isDebugged() {
76.119 + return false;
76.120 + }
76.121 +
76.122 +
76.123 + private boolean isSelectedServer () {
76.124 + String instance = antProjectHelper.getStandardPropertyEvaluator ().getProperty (IcanproProjectProperties.J2EE_SERVER_INSTANCE);
76.125 + boolean selected;
76.126 + if (instance != null) {
76.127 + selected = true;
76.128 + } else {
76.129 + // no selected server => warning
76.130 + String server = antProjectHelper.getStandardPropertyEvaluator ().getProperty (IcanproProjectProperties.J2EE_SERVER_TYPE);
76.131 + NoSelectedServerWarning panel = new NoSelectedServerWarning (server);
76.132 +
76.133 + Object[] options = new Object[] {
76.134 + DialogDescriptor.OK_OPTION,
76.135 + DialogDescriptor.CANCEL_OPTION
76.136 + };
76.137 + DialogDescriptor desc = new DialogDescriptor (panel,
76.138 + NbBundle.getMessage (NoSelectedServerWarning.class, "CTL_NoSelectedServerWarning_Title"), // NOI18N
76.139 + true, options, options[0], DialogDescriptor.DEFAULT_ALIGN, null, null);
76.140 + Dialog dlg = DialogDisplayer.getDefault ().createDialog (desc);
76.141 + dlg.setVisible (true);
76.142 + if (desc.getValue() != options[0]) {
76.143 + selected = false;
76.144 + } else {
76.145 + instance = panel.getSelectedInstance ();
76.146 + selected = instance != null;
76.147 + if (selected) {
76.148 + IcanproProjectProperties wpp = new IcanproProjectProperties (project, antProjectHelper, refHelper);
76.149 + wpp.put (IcanproProjectProperties.J2EE_SERVER_INSTANCE, instance);
76.150 + wpp.store ();
76.151 + }
76.152 + }
76.153 + dlg.dispose();
76.154 + }
76.155 + return selected;
76.156 + }
76.157 +
76.158 +}
77.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
77.2 +++ b/enterprise/openesbaddons/workflow/project/src/org/netbeans/modules/workflow/project/WorkflowproProject.java Thu Apr 26 02:33:27 2007 +0000
77.3 @@ -0,0 +1,352 @@
77.4 +/*
77.5 + * Sun Public License Notice
77.6 + *
77.7 + * The contents of this file are subject to the Sun Public License
77.8 + * Version 1.0 (the "License"). You may not use this file except in
77.9 + * compliance with the License. A copy of the License is available at
77.10 + * http://www.sun.com/
77.11 + *
77.12 + * The Original Code is NetBeans. The Initial Developer of the Original
77.13 + * Code is Sun Microsystems, Inc. Portions Copyright 1997-2004 Sun
77.14 + * Microsystems, Inc. All Rights Reserved.
77.15 + */
77.16 +
77.17 +package org.netbeans.modules.workflow.project;
77.18 +
77.19 +import org.netbeans.modules.compapp.projects.base.spi.JbiArtifactProvider;
77.20 +import org.netbeans.modules.compapp.projects.base.ui.IcanproCustomizerProvider;
77.21 +import org.netbeans.modules.compapp.projects.base.ui.IcanproLogicalViewProvider;
77.22 +import org.netbeans.modules.compapp.projects.base.ui.customizer.IcanproProjectProperties;
77.23 +import org.netbeans.modules.workflow.project.ui.WorkflowproLogicalViewProvider;
77.24 +import java.beans.PropertyChangeListener;
77.25 +import java.beans.PropertyChangeSupport;
77.26 +import java.io.File;
77.27 +import java.io.IOException;
77.28 +import javax.swing.Icon;
77.29 +import javax.swing.ImageIcon;
77.30 +import org.netbeans.api.java.project.JavaProjectConstants;
77.31 +import org.netbeans.api.project.FileOwnerQuery;
77.32 +import org.netbeans.api.project.Project;
77.33 +import org.netbeans.api.project.ProjectInformation;
77.34 +import org.netbeans.api.project.ProjectManager;
77.35 +import org.netbeans.api.project.ant.AntArtifact;
77.36 +import org.netbeans.spi.java.project.support.ui.BrokenReferencesSupport;
77.37 +import org.netbeans.spi.project.AuxiliaryConfiguration;
77.38 +import org.netbeans.spi.project.SubprojectProvider;
77.39 +import org.netbeans.spi.project.support.ant.AntProjectEvent;
77.40 +import org.netbeans.spi.project.support.ant.AntProjectHelper;
77.41 +import org.netbeans.spi.project.support.ant.AntProjectListener;
77.42 +import org.netbeans.spi.project.support.ant.EditableProperties;
77.43 +import org.netbeans.spi.project.support.ant.GeneratedFilesHelper;
77.44 +import org.netbeans.spi.project.support.ant.ProjectXmlSavedHook;
77.45 +import org.netbeans.spi.project.support.ant.PropertyEvaluator;
77.46 +import org.netbeans.spi.project.support.ant.ReferenceHelper;
77.47 +import org.netbeans.spi.project.support.ant.SourcesHelper;
77.48 +import org.netbeans.spi.project.ui.PrivilegedTemplates;
77.49 +import org.netbeans.spi.project.ui.ProjectOpenedHook;
77.50 +import org.netbeans.spi.project.ui.RecommendedTemplates;
77.51 +import org.netbeans.spi.queries.FileBuiltQueryImplementation;
77.52 +import org.openide.ErrorManager;
77.53 +import org.openide.filesystems.FileObject;
77.54 +import org.openide.modules.InstalledFileLocator;
77.55 +import org.openide.util.Lookup;
77.56 +import org.openide.util.Mutex;
77.57 +import org.openide.util.Utilities;
77.58 +import org.openide.util.lookup.Lookups;
77.59 +import org.w3c.dom.Element;
77.60 +import org.w3c.dom.Node;
77.61 +import org.w3c.dom.NodeList;
77.62 +import org.w3c.dom.Text;
77.63 +
77.64 +
77.65 +
77.66 +
77.67 +/**
77.68 + * Represents one ejb module project
77.69 + * @author Chris Webster
77.70 + */
77.71 +public final class WorkflowproProject implements Project, AntProjectListener {
77.72 +
77.73 + private static final Icon PROJECT_ICON = new ImageIcon(Utilities.loadImage("org/netbeans/modules/workflow/project/ui/resources/workflowproProjectIcon.gif")); // NOI18N
77.74 + public static final String SOURCES_TYPE_ICANPRO = "BIZPRO";
77.75 + public static final String ARTIFACT_TYPE_JBI_ASA = "CAPS.asa";
77.76 +
77.77 + private final AntProjectHelper helper;
77.78 + private final PropertyEvaluator eval;
77.79 + private final ReferenceHelper refHelper;
77.80 + private final GeneratedFilesHelper genFilesHelper;
77.81 + private final Lookup lookup;
77.82 +
77.83 + public WorkflowproProject(final AntProjectHelper helper) throws IOException {
77.84 + this.helper = helper;
77.85 + eval = createEvaluator();
77.86 + AuxiliaryConfiguration aux = helper.createAuxiliaryConfiguration();
77.87 + refHelper = new ReferenceHelper(helper, aux, helper.getStandardPropertyEvaluator());
77.88 + genFilesHelper = new GeneratedFilesHelper(helper);
77.89 + lookup = createLookup(aux);
77.90 + helper.addAntProjectListener(this);
77.91 + }
77.92 +
77.93 + public FileObject getProjectDirectory() {
77.94 + return helper.getProjectDirectory();
77.95 + }
77.96 +
77.97 + public String toString() {
77.98 + return "WorkflowproProject[" + getProjectDirectory() + "]"; // NOI18N
77.99 + }
77.100 +
77.101 + private PropertyEvaluator createEvaluator() {
77.102 + // XXX might need to use a custom evaluator to handle active platform substitutions... TBD
77.103 + return helper.getStandardPropertyEvaluator();
77.104 + }
77.105 +
77.106 + PropertyEvaluator evaluator() {
77.107 + return eval;
77.108 + }
77.109 +
77.110 + public Lookup getLookup() {
77.111 + return lookup;
77.112 + }
77.113 +
77.114 + private Lookup createLookup(AuxiliaryConfiguration aux) {
77.115 + SubprojectProvider spp = refHelper.createSubprojectProvider();
77.116 + FileBuiltQueryImplementation fileBuilt = helper.createGlobFileBuiltQuery(helper.getStandardPropertyEvaluator(),
77.117 + new String[] {"${src.dir}/*.java"}, // NOI18N
77.118 + new String[] {"${build.classes.dir}/*.class"} // NOI18N
77.119 + );
77.120 + final SourcesHelper sourcesHelper = new SourcesHelper(helper, evaluator());
77.121 + String webModuleLabel = org.openide.util.NbBundle.getMessage(IcanproCustomizerProvider.class, "LBL_Node_EJBModule"); //NOI18N
77.122 + String srcJavaLabel = org.openide.util.NbBundle.getMessage(IcanproCustomizerProvider.class, "LBL_Node_Sources"); //NOI18N
77.123 +
77.124 + sourcesHelper.addPrincipalSourceRoot("${"+IcanproProjectProperties.SOURCE_ROOT+"}", webModuleLabel, /*XXX*/null, null);
77.125 + sourcesHelper.addPrincipalSourceRoot("${"+IcanproProjectProperties.SRC_DIR+"}", srcJavaLabel, /*XXX*/null, null);
77.126 +
77.127 + sourcesHelper.addTypedSourceRoot("${"+IcanproProjectProperties.SRC_DIR+"}", SOURCES_TYPE_ICANPRO, srcJavaLabel, /*XXX*/null, null);
77.128 + sourcesHelper.addTypedSourceRoot("${"+IcanproProjectProperties.SRC_DIR+"}", JavaProjectConstants.SOURCES_TYPE_JAVA, srcJavaLabel, /*XXX*/null, null);
77.129 + ProjectManager.mutex().postWriteRequest(new Runnable() {
77.130 + public void run() {
77.131 + sourcesHelper.registerExternalRoots(FileOwnerQuery.EXTERNAL_ALGORITHM_TRANSIENT);
77.132 + }
77.133 + });
77.134 + return Lookups.fixed(new Object[] {
77.135 + new Info(),
77.136 + aux,
77.137 + helper.createCacheDirectoryProvider(),
77.138 +//B new ProjectWebServicesSupportProvider(),
77.139 + // XXX the helper should not be exposed
77.140 + helper,
77.141 + spp,
77.142 + new WorkflowproActionProvider( this, helper, refHelper ),
77.143 + new WorkflowproLogicalViewProvider(this, helper, evaluator(), spp, refHelper),
77.144 + new IcanproCustomizerProvider( this, helper, refHelper ),
77.145 + new JbiArtifactProviderImpl(),
77.146 + new ProjectXmlSavedHookImpl(),
77.147 + new ProjectOpenedHookImpl(),
77.148 + fileBuilt,
77.149 + new RecommendedTemplatesImpl(),
77.150 + refHelper,
77.151 + sourcesHelper.createSources(),
77.152 + helper.createSharabilityQuery(evaluator(),
77.153 + new String[] {"${"+IcanproProjectProperties.SOURCE_ROOT+"}"},
77.154 + new String[] {
77.155 + "${"+IcanproProjectProperties.BUILD_DIR+"}",
77.156 + "${"+IcanproProjectProperties.DIST_DIR+"}"}
77.157 + )
77.158 + });
77.159 + }
77.160 +
77.161 + public void configurationXmlChanged(AntProjectEvent ev) {
77.162 + if (ev.getPath().equals(AntProjectHelper.PROJECT_XML_PATH)) {
77.163 + // Could be various kinds of changes, but name & displayName might have changed.
77.164 + Info info = (Info)getLookup().lookup(ProjectInformation.class);
77.165 + info.firePropertyChange(ProjectInformation.PROP_NAME);
77.166 + info.firePropertyChange(ProjectInformation.PROP_DISPLAY_NAME);
77.167 + }
77.168 + }
77.169 +
77.170 + public void propertiesChanged(AntProjectEvent ev) {
77.171 + // currently ignored
77.172 + //TODO: should not be ignored!
77.173 + }
77.174 +
77.175 + String getBuildXmlName() {
77.176 + String storedName = helper.getStandardPropertyEvaluator().getProperty(IcanproProjectProperties.BUILD_FILE);
77.177 + return storedName == null ? GeneratedFilesHelper.BUILD_XML_PATH : storedName;
77.178 + }
77.179 +
77.180 + // Package private methods -------------------------------------------------
77.181 +
77.182 + FileObject getSourceDirectory() {
77.183 + String srcDir = helper.getStandardPropertyEvaluator().getProperty("src.dir"); // NOI18N
77.184 + return helper.resolveFileObject(srcDir);
77.185 + }
77.186 +
77.187 + /** Return configured project name. */
77.188 + public String getName() {
77.189 + return (String) ProjectManager.mutex().readAccess(new Mutex.Action() {
77.190 + public Object run() {
77.191 + Element data = helper.getPrimaryConfigurationData(true);
77.192 + // XXX replace by XMLUtil when that has findElement, findText, etc.
77.193 + NodeList nl = data.getElementsByTagNameNS(WorkflowproProjectType.PROJECT_CONFIGURATION_NAMESPACE, "name");
77.194 + if (nl.getLength() == 1) {
77.195 + nl = nl.item(0).getChildNodes();
77.196 + if (nl.getLength() == 1 && nl.item(0).getNodeType() == Node.TEXT_NODE) {
77.197 + return ((Text) nl.item(0)).getNodeValue();
77.198 + }
77.199 + }
77.200 + return "???"; // NOI18N
77.201 + }
77.202 + });
77.203 + }
77.204 +
77.205 + // Private innerclasses ----------------------------------------------------
77.206 +
77.207 + private final class Info implements ProjectInformation {
77.208 +
77.209 + private final PropertyChangeSupport pcs = new PropertyChangeSupport(this);
77.210 +
77.211 + Info() {}
77.212 +
77.213 + void firePropertyChange(String prop) {
77.214 + pcs.firePropertyChange(prop, null, null);
77.215 + }
77.216 +
77.217 + public String getName() {
77.218 + return WorkflowproProject.this.getName();
77.219 + }
77.220 +
77.221 + public String getDisplayName() {
77.222 + return WorkflowproProject.this.getName();
77.223 + }
77.224 +
77.225 + public Icon getIcon() {
77.226 + return PROJECT_ICON;
77.227 + }
77.228 +
77.229 + public Project getProject() {
77.230 + return WorkflowproProject.this;
77.231 + }
77.232 +
77.233 + public void addPropertyChangeListener(PropertyChangeListener listener) {
77.234 + pcs.addPropertyChangeListener(listener);
77.235 + }
77.236 +
77.237 + public void removePropertyChangeListener(PropertyChangeListener listener) {
77.238 + pcs.removePropertyChangeListener(listener);
77.239 + }
77.240 +
77.241 + }
77.242 +
77.243 + private final class ProjectXmlSavedHookImpl extends ProjectXmlSavedHook {
77.244 +
77.245 + ProjectXmlSavedHookImpl() {}
77.246 +
77.247 + protected void projectXmlSaved() throws IOException {
77.248 + genFilesHelper.refreshBuildScript(
77.249 + GeneratedFilesHelper.BUILD_IMPL_XML_PATH,
77.250 + WorkflowproProject.class.getResource("resources/build-impl.xsl"),
77.251 + false);
77.252 + genFilesHelper.refreshBuildScript(
77.253 + getBuildXmlName(),
77.254 + WorkflowproProject.class.getResource("resources/build.xsl"),
77.255 + false);
77.256 + }
77.257 +
77.258 + }
77.259 +
77.260 + private final class ProjectOpenedHookImpl extends ProjectOpenedHook {
77.261 +
77.262 + ProjectOpenedHookImpl() {}
77.263 +
77.264 + protected void projectOpened() {
77.265 + try {
77.266 + // Check up on build scripts.
77.267 + genFilesHelper.refreshBuildScript(
77.268 + GeneratedFilesHelper.BUILD_IMPL_XML_PATH,
77.269 + WorkflowproProject.class.getResource("resources/build-impl.xsl"),
77.270 + true);
77.271 + genFilesHelper.refreshBuildScript(
77.272 + getBuildXmlName(),
77.273 + WorkflowproProject.class.getResource("resources/build.xsl"),
77.274 + true);
77.275 + } catch (IOException e) {
77.276 + ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, e);
77.277 + }
77.278 +
77.279 + // Make it easier to run headless builds on the same machine at least.
77.280 + ProjectManager.mutex().writeAccess(new Mutex.Action() {
77.281 + public Object run() {
77.282 + EditableProperties ep = helper.getProperties(AntProjectHelper.PRIVATE_PROPERTIES_PATH);
77.283 + ep.setProperty("netbeans.user", System.getProperty("netbeans.user"));
77.284 +
77.285 +
77.286 + helper.putProperties(AntProjectHelper.PRIVATE_PROPERTIES_PATH, ep);
77.287 + try {
77.288 + ProjectManager.getDefault().saveProject(WorkflowproProject.this);
77.289 + } catch (IOException e) {
77.290 + ErrorManager.getDefault().notify(e);
77.291 + }
77.292 + return null;
77.293 + }
77.294 + });
77.295 + if (IcanproLogicalViewProvider.hasBrokenLinks(helper, refHelper)) {
77.296 + BrokenReferencesSupport.showAlert();
77.297 + }
77.298 + }
77.299 +
77.300 + protected void projectClosed() {
77.301 + // Probably unnecessary, but just in case:
77.302 + try {
77.303 + ProjectManager.getDefault().saveProject(WorkflowproProject.this);
77.304 + } catch (IOException e) {
77.305 + ErrorManager.getDefault().notify(e);
77.306 + }
77.307 + }
77.308 +
77.309 + }
77.310 +
77.311 + /**
77.312 + * Exports the main JAR as an official build product for use from other scripts.
77.313 + * The type of the artifact will be {@link AntArtifact#TYPE_JAR}.
77.314 + */
77.315 + private final class JbiArtifactProviderImpl implements JbiArtifactProvider {
77.316 +
77.317 + public AntArtifact[] getBuildArtifacts() {
77.318 + return new AntArtifact[] {
77.319 + helper.createSimpleAntArtifact(WorkflowproProject.ARTIFACT_TYPE_JBI_ASA + ":" +
77.320 + helper.getStandardPropertyEvaluator().getProperty(IcanproProjectProperties.JBI_SETYPE_PREFIX),
77.321 + IcanproProjectProperties.SE_DEPLOYMENT_JAR,
77.322 + helper.getStandardPropertyEvaluator(), "dist_se", "clean"), // NOI18N
77.323 + };
77.324 + }
77.325 +
77.326 + public String getJbiServiceAssemblyType() {
77.327 + return helper.getStandardPropertyEvaluator().getProperty(IcanproProjectProperties.JBI_SETYPE_PREFIX);
77.328 + }
77.329 + }
77.330 +
77.331 + private static final class RecommendedTemplatesImpl implements RecommendedTemplates, PrivilegedTemplates {
77.332 +
77.333 + // List of primarily supported templates
77.334 +
77.335 + private static final String[] TYPES = new String[] {
77.336 + "XML", // NOI18N
77.337 + "simple-files" // NOI18N
77.338 + };
77.339 +
77.340 + private static final String[] PRIVILEGED_NAMES = new String[] {
77.341 + "Templates/XML/stylesheet.xsl",
77.342 + "Templates/CAPS/schema.xsd",
77.343 + "Templates/CAPS/untitled.wsdl"
77.344 + };
77.345 +
77.346 + public String[] getRecommendedTypes() {
77.347 + return TYPES;
77.348 + }
77.349 +
77.350 + public String[] getPrivilegedTemplates() {
77.351 + return PRIVILEGED_NAMES;
77.352 + }
77.353 +
77.354 + }
77.355 +}
78.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
78.2 +++ b/enterprise/openesbaddons/workflow/project/src/org/netbeans/modules/workflow/project/WorkflowproProjectGenerator.java Thu Apr 26 02:33:27 2007 +0000
78.3 @@ -0,0 +1,157 @@
78.4 +/*
78.5 + * Sun Public License Notice
78.6 + *
78.7 + * The contents of this file are subject to the Sun Public License
78.8 + * Version 1.0 (the "License"). You may not use this file except in
78.9 + * compliance with the License. A copy of the License is available at
78.10 + * http://www.sun.com/
78.11 + *
78.12 + * The Original Code is NetBeans. The Initial Developer of the Original
78.13 + * Code is Sun Microsystems, Inc. Portions Copyright 1997-2004 Sun
78.14 + * Microsystems, Inc. All Rights Reserved.
78.15 + */
78.16 +
78.17 +package org.netbeans.modules.workflow.project;
78.18 +
78.19 +import org.netbeans.modules.compapp.projects.base.ui.customizer.IcanproProjectProperties;
78.20 +import java.io.File;
78.21 +import java.io.IOException;
78.22 +import org.netbeans.api.project.Project;
78.23 +import org.netbeans.api.project.ProjectManager;
78.24 +import org.netbeans.modules.j2ee.deployment.devmodules.api.Deployment;
78.25 +import org.netbeans.spi.project.support.ant.AntProjectHelper;
78.26 +import org.netbeans.spi.project.support.ant.EditableProperties;
78.27 +import org.netbeans.spi.project.support.ant.ProjectGenerator;
78.28 +import org.openide.filesystems.FileObject;
78.29 +import org.openide.filesystems.FileUtil;
78.30 +import org.openide.filesystems.Repository;
78.31 +import org.w3c.dom.Document;
78.32 +import org.w3c.dom.Element;
78.33 +
78.34 +/**
78.35 + * Create a fresh EjbProject from scratch or by importing and exisitng web module
78.36 + * in one of the recognized directory structures.
78.37 + *
78.38 + * @author Pavel Buzek
78.39 + */
78.40 +public class WorkflowproProjectGenerator {
78.41 +
78.42 + private static final String DEFAULT_DOC_BASE_FOLDER = "conf"; //NOI18N
78.43 + private static final String DEFAULT_SRC_FOLDER = "src"; //NOI18N
78.44 + private static final String DEFAULT_RESOURCE_FOLDER = "setup"; //NOI18N
78.45 + private static final String DEFAULT_BPELASA_FOLDER = "bpelasa"; //NOI18N
78.46 + private static final String DEFAULT_BUILD_DIR = "build"; //NOI18N
78.47 + private static final String PROJECT_NAME="projectName";
78.48 +
78.49 + private static final String DEFAULT_NBPROJECT_DIR = "nbproject"; //NOI18N
78.50 +
78.51 + private WorkflowproProjectGenerator() {}
78.52 +
78.53 + /**
78.54 + * Create a new empty J2SE project.
78.55 + * @param dir the top-level directory (need not yet exist but if it does it must be empty)
78.56 + * @param name the code name for the project
78.57 + * @return the helper object permitting it to be further customized
78.58 + * @throws IOException in case something went wrong
78.59 + */
78.60 + public static AntProjectHelper createProject(File dir, String name, String j2eeLevel) throws IOException {
78.61 + dir.mkdirs();
78.62 + // XXX clumsy way to refresh, but otherwise it doesn't work for new folders
78.63 + File rootF = dir;
78.64 + while (rootF.getParentFile() != null) {
78.65 + rootF = rootF.getParentFile();
78.66 + }
78.67 + FileObject fo = FileUtil.toFileObject (rootF);
78.68 + assert fo != null : "At least disk roots must be mounted! " + rootF;
78.69 + fo.getFileSystem().refresh(false);
78.70 + fo = FileUtil.toFileObject (dir);
78.71 + assert fo != null : "No such dir on disk: " + dir;
78.72 + assert fo.isFolder() : "Not really a dir: " + dir;
78.73 + assert fo.getChildren().length == 0 : "Dir must have been empty: " + dir;
78.74 + AntProjectHelper h = setupProject (fo, name, j2eeLevel);
78.75 + FileObject srcRoot = fo.createFolder(DEFAULT_SRC_FOLDER); // NOI18N
78.76 + FileObject bpelasaRoot = srcRoot;
78.77 +
78.78 + FileObject nbProjectRoot = FileUtil.toFileObject(new File(dir, DEFAULT_NBPROJECT_DIR)); // NOI18N
78.79 +
78.80 + EditableProperties ep = h.getProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH);
78.81 + ep.put (IcanproProjectProperties.SOURCE_ROOT, DEFAULT_SRC_FOLDER); //NOI18N
78.82 + ep.setProperty(IcanproProjectProperties.META_INF, "${"+IcanproProjectProperties.SOURCE_ROOT+"}/"+DEFAULT_DOC_BASE_FOLDER); //NOI18N
78.83 + ep.setProperty(IcanproProjectProperties.SRC_DIR, "${"+IcanproProjectProperties.SOURCE_ROOT+"}"); //NOI18N
78.84 + ep.setProperty(IcanproProjectProperties.RESOURCE_DIR, DEFAULT_RESOURCE_FOLDER);
78.85 + h.putProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH, ep);
78.86 +
78.87 + Project p = ProjectManager.getDefault().findProject(h.getProjectDirectory ());
78.88 + ProjectManager.getDefault().saveProject(p);
78.89 +
78.90 + return h;
78.91 + }
78.92 +
78.93 + private static AntProjectHelper setupProject (FileObject dirFO, String name, String j2eeLevel) throws IOException {
78.94 + AntProjectHelper h = ProjectGenerator.createProject(dirFO, WorkflowproProjectType.TYPE);
78.95 + Element data = h.getPrimaryConfigurationData(true);
78.96 + Document doc = data.getOwnerDocument();
78.97 + Element nameEl = doc.createElementNS(WorkflowproProjectType.PROJECT_CONFIGURATION_NAMESPACE, "name"); // NOI18N
78.98 + nameEl.appendChild(doc.createTextNode(name));
78.99 + data.appendChild(nameEl);
78.100 + Element minant = doc.createElementNS(WorkflowproProjectType.PROJECT_CONFIGURATION_NAMESPACE, "minimum-ant-version"); // NOI18N
78.101 + minant.appendChild(doc.createTextNode("1.6")); // NOI18N
78.102 + data.appendChild(minant);
78.103 + h.putPrimaryConfigurationData(data, true);
78.104 +
78.105 + EditableProperties ep = h.getProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH);
78.106 + // ep.setProperty(IcanproProjectProperties.JAVAC_CLASSPATH, "${libs.j2ee14.classpath}");
78.107 + ep.setProperty(IcanproProjectProperties.DIST_DIR, "dist");
78.108 + ep.setProperty(IcanproProjectProperties.DIST_JAR, "${"+IcanproProjectProperties.DIST_DIR+"}/" + name + ".zip");
78.109 + ep.setProperty(IcanproProjectProperties.J2EE_PLATFORM, j2eeLevel);
78.110 + ep.setProperty(IcanproProjectProperties.JAR_NAME, name + ".jar");
78.111 + ep.setProperty(IcanproProjectProperties.JAR_COMPRESS, "false");
78.112 +// ep.setProperty(IcanproProjectProperties.JAR_CONTENT_ADDITIONAL, "");
78.113 +
78.114 + Deployment deployment = Deployment.getDefault ();
78.115 + String serverInstanceID = deployment.getDefaultServerInstanceID ();
78.116 + ep.setProperty(IcanproProjectProperties.J2EE_SERVER_TYPE, deployment.getServerID (serverInstanceID));
78.117 + ep.setProperty(IcanproProjectProperties.JAVAC_SOURCE, "1.4");
78.118 + ep.setProperty(IcanproProjectProperties.JAVAC_DEBUG, "true");
78.119 + ep.setProperty(IcanproProjectProperties.JAVAC_DEPRECATION, "false");
78.120 +
78.121 + ep.setProperty(IcanproProjectProperties.JAVAC_TARGET, "1.4");
78.122 +
78.123 + ep.setProperty(IcanproProjectProperties.BUILD_DIR, DEFAULT_BUILD_DIR);
78.124 + ep.setProperty(IcanproProjectProperties.BUILD_GENERATED_DIR, "${"+IcanproProjectProperties.BUILD_DIR+"}/generated");
78.125 + ep.setProperty(IcanproProjectProperties.BUILD_CLASSES_DIR, "${"+IcanproProjectProperties.BUILD_DIR+"}/jar");
78.126 + ep.setProperty(IcanproProjectProperties.BUILD_CLASSES_EXCLUDES, "**/*.java,**/*.form,**/.nbattrs");
78.127 + ep.setProperty(IcanproProjectProperties.DIST_JAVADOC_DIR, "${"+IcanproProjectProperties.DIST_DIR+"}/javadoc");
78.128 + ep.setProperty(IcanproProjectProperties.JAVA_PLATFORM, "default_platform");
78.129 + ep.setProperty(PROJECT_NAME,name);
78.130 + ep.setProperty(IcanproProjectProperties.DEBUG_CLASSPATH, "${"+IcanproProjectProperties.JAVAC_CLASSPATH+"}:${"+IcanproProjectProperties.BUILD_CLASSES_DIR+"}");
78.131 +
78.132 + //============= Start of IcanPro========================================//
78.133 + ep.setProperty(IcanproProjectProperties.JBI_SETYPE_PREFIX, "sun-workflow-engine"); // NOI18N
78.134 + ep.setProperty(IcanproProjectProperties.ASSEMBLY_UNIT_ALIAS, "This Assembly Unit"); // NOI18N
78.135 + ep.setProperty(IcanproProjectProperties.ASSEMBLY_UNIT_DESCRIPTION, "Represents this Assembly Unit"); // NOI18N
78.136 + ep.setProperty(IcanproProjectProperties.APPLICATION_SUB_ASSEMBLY_ALIAS, "This Application Sub-Assembly"); // NOI18N
78.137 + ep.setProperty(IcanproProjectProperties.APPLICATION_SUB_ASSEMBLY_DESCRIPTION, "This represents the Application Sub-Assembly"); // NOI18N
78.138 + ep.setProperty(IcanproProjectProperties.JBI_COMPONENT_CONF_ROOT, "nbproject/private"); // NOI18N
78.139 + ep.setProperty(IcanproProjectProperties.JBI_DEPLOYMENT_CONF_ROOT, "nbproject/deployment"); // NOI18N
78.140 +
78.141 + ep.setProperty(IcanproProjectProperties.BC_DEPLOYMENT_JAR, "${"+IcanproProjectProperties.BUILD_DIR+"}/" + "BCDeployment.jar");
78.142 + ep.setProperty(IcanproProjectProperties.SE_DEPLOYMENT_JAR, "${"+IcanproProjectProperties.BUILD_DIR+"}/" + "SEDeployment.jar");
78.143 + //============= End of IcanPro========================================//
78.144 +
78.145 + h.putProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH, ep);
78.146 +
78.147 + ep = h.getProperties(AntProjectHelper.PRIVATE_PROPERTIES_PATH);
78.148 + ep.setProperty(IcanproProjectProperties.J2EE_SERVER_INSTANCE, serverInstanceID);
78.149 + //============= Start of IcanPro========================================//
78.150 + ep.setProperty(IcanproProjectProperties.JBI_COMPONENT_CONF_FILE, "ComponentInformation.xml"); // NOI18N
78.151 + ep.setProperty(IcanproProjectProperties.JBI_DEPLOYMENT_CONF_FILE, "default.xml"); // NOI18N
78.152 + //============= End of IcanPro========================================//
78.153 +
78.154 + h.putProperties(AntProjectHelper.PRIVATE_PROPERTIES_PATH, ep);
78.155 + Project p = ProjectManager.getDefault().findProject(dirFO);
78.156 + ProjectManager.getDefault().saveProject(p);
78.157 + return h;
78.158 + }
78.159 +
78.160 +}
79.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
79.2 +++ b/enterprise/openesbaddons/workflow/project/src/org/netbeans/modules/workflow/project/WorkflowproProjectType.java Thu Apr 26 02:33:27 2007 +0000
79.3 @@ -0,0 +1,55 @@
79.4 +/*
79.5 + * Sun Public License Notice
79.6 + *
79.7 + * The contents of this file are subject to the Sun Public License
79.8 + * Version 1.0 (the "License"). You may not use this file except in
79.9 + * compliance with the License. A copy of the License is available at
79.10 + * http://www.sun.com/
79.11 + *
79.12 + * The Original Code is NetBeans. The Initial Developer of the Original
79.13 + * Code is Sun Microsystems, Inc. Portions Copyright 1997-2004 Sun
79.14 + * Microsystems, Inc. All Rights Reserved.
79.15 + */
79.16 +
79.17 +package org.netbeans.modules.workflow.project;
79.18 +
79.19 +import java.io.IOException;
79.20 +import org.netbeans.api.project.Project;
79.21 +import org.netbeans.spi.project.support.ant.AntBasedProjectType;
79.22 +import org.netbeans.spi.project.support.ant.AntProjectHelper;
79.23 +
79.24 +/**
79.25 + * Factory for EJB Module projects
79.26 + *
79.27 + */
79.28 +public class WorkflowproProjectType implements AntBasedProjectType {
79.29 + public static final String TYPE = "org.netbeans.modules.workflow.project";
79.30 + public static final String PROJECT_CONFIGURATION_NAME = "data";
79.31 + public static final String PROJECT_CONFIGURATION_NAMESPACE = "http://www.netbeans.org/ns/j2ee-workflowpro/1";
79.32 + public static final String PRIVATE_CONFIGURATION_NAME = "data";
79.33 + public static final String PRIVATE_CONFIGURATION_NAMESPACE = "http://www.netbeans.org/ns/j2ee-workflowpro-private/1";
79.34 +
79.35 +
79.36 + public WorkflowproProjectType() {
79.37 + int i = 0;
79.38 + }
79.39 +
79.40 + public String getType() {
79.41 + return TYPE;
79.42 + }
79.43 +
79.44 + public Project createProject(AntProjectHelper helper) throws IOException {
79.45 + if (null == helper)
79.46 + throw new IllegalArgumentException("helper");
79.47 + return new WorkflowproProject(helper);
79.48 + }
79.49 +
79.50 + public String getPrimaryConfigurationDataElementName(boolean shared) {
79.51 + return shared ? PROJECT_CONFIGURATION_NAME : PRIVATE_CONFIGURATION_NAME;
79.52 + }
79.53 +
79.54 + public String getPrimaryConfigurationDataElementNamespace(boolean shared) {
79.55 + return shared ? PROJECT_CONFIGURATION_NAMESPACE : PRIVATE_CONFIGURATION_NAMESPACE;
79.56 + }
79.57 +
79.58 +}
80.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
80.2 +++ b/enterprise/openesbaddons/workflow/project/src/org/netbeans/modules/workflow/project/layer.xml Thu Apr 26 02:33:27 2007 +0000
80.3 @@ -0,0 +1,4 @@
80.4 +<?xml version="1.0" encoding="UTF-8"?>
80.5 +<!DOCTYPE filesystem PUBLIC "-//NetBeans//DTD Filesystem 1.1//EN" "http://www.netbeans.org/dtds/filesystem-1_1.dtd">
80.6 +<filesystem>
80.7 +</filesystem>
81.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
81.2 +++ b/enterprise/openesbaddons/workflow/project/src/org/netbeans/modules/workflow/project/resources/TaskCommon.wsdl Thu Apr 26 02:33:27 2007 +0000
81.3 @@ -0,0 +1,421 @@
81.4 +<?xml version="1.0" encoding="UTF-8"?>
81.5 +<definitions name="TaskStatic" targetNamespace="http://jbi.com.sun/wfse/wsdl/TaskCommon"
81.6 + xmlns="http://schemas.xmlsoap.org/wsdl/"
81.7 + xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
81.8 + xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
81.9 + xmlns:xsd="http://www.w3.org/2001/XMLSchema"
81.10 + xmlns:tns="http://jbi.com.sun/wfse/wsdl/TaskCommon"
81.11 + xmlns:ns1="http://jbi.com.sun/wfse/wsdl/TaskCommon"
81.12 + xmlns:ns2="http://wlmse.sample/po"
81.13 + xmlns:plink="http://docs.oasis-open.org/wsbpel/2.0/plnktype">
81.14 + <types>
81.15 + <xsd:schema targetNamespace="http://jbi.com.sun/wfse/wsdl/TaskCommon" elementFormDefault="qualified">
81.16 + <xsd:complexType name="TaskListType">
81.17 + <xsd:sequence>
81.18 + <xsd:element name="task" type="ns1:TaskType" minOccurs="0" maxOccurs="unbounded"></xsd:element>
81.19 + </xsd:sequence>
81.20 + </xsd:complexType>
81.21 + <xsd:element name="taskList" type="ns1:TaskListType"></xsd:element>
81.22 + <xsd:simpleType name="ResultCodeType">
81.23 + <xsd:restriction base="xsd:string">
81.24 + <xsd:enumeration value="SUCCESS"/>
81.25 + <xsd:enumeration value="FAILED"/>
81.26 + </xsd:restriction>
81.27 + </xsd:simpleType>
81.28 + <xsd:simpleType name="TaskPriority">
81.29 + <xsd:restriction base="xsd:string">
81.30 + <xsd:enumeration value="LOW"/>
81.31 + <xsd:enumeration value="MEDIUM"/>
81.32 + <xsd:enumeration value="HIGH"/>
81.33 + </xsd:restriction>
81.34 + </xsd:simpleType>
81.35 + <xsd:simpleType name="TaskStatus">
81.36 + <xsd:restriction base="xsd:string">
81.37 + <xsd:enumeration value="UNASSIGNED"/>
81.38 + <xsd:enumeration value="ASSIGNED"/>
81.39 + <xsd:enumeration value="CLAIMED"/>
81.40 + <xsd:enumeration value="COMPLETED"/>
81.41 + <xsd:enumeration value="EXPIRED"/>
81.42 + <xsd:enumeration value="ESCALATED"/>
81.43 + <xsd:enumeration value="ABORTED"/>
81.44 + <xsd:enumeration value="FAILED"/>
81.45 + </xsd:restriction>
81.46 + </xsd:simpleType>
81.47 + <xsd:element name="resultCode" type="ns1:ResultCodeType"></xsd:element>
81.48 + <xsd:complexType name="FaultType">
81.49 + <xsd:sequence>
81.50 + <xsd:element name="FaultCode" type="xsd:string"></xsd:element>
81.51 + <xsd:element name="FaultReason" type="xsd:string"></xsd:element>
81.52 + </xsd:sequence>
81.53 + </xsd:complexType>
81.54 + <xsd:element name="fault" type="ns1:FaultType"></xsd:element>
81.55 + <xsd:complexType name="TaskType">
81.56 + <xsd:sequence>
81.57 + <xsd:element name="taskId" type="xsd:long"></xsd:element>
81.58 + <xsd:element name="title" type="xsd:string" minOccurs="0"/>
81.59 + <xsd:element name="client" type="xsd:string" minOccurs="0"/>
81.60 + <xsd:element name="priority" type="ns1:TaskPriority" minOccurs="0"/>
81.61 + <xsd:element name="claimedBy" type="xsd:string" minOccurs="0"/>
81.62 + <xsd:element name="assignedTo" type="xsd:string" minOccurs="0"/>
81.63 + <xsd:element name="submittedDate" type="xsd:date" minOccurs="0"/>
81.64 + <xsd:element name="status" type="ns1:TaskStatus" minOccurs="0" />
81.65 + </xsd:sequence>
81.66 + </xsd:complexType>
81.67 + <xsd:element name="task" type="ns1:TaskType"></xsd:element>
81.68 + <xsd:element name="content" type="xsd:anyType"></xsd:element>
81.69 + <xsd:complexType name="ConnectInfoType">
81.70 + <xsd:sequence>
81.71 + <xsd:element name="userId" type="xsd:string"></xsd:element>
81.72 + <xsd:element name="password" type="xsd:string"></xsd:element>
81.73 + </xsd:sequence>
81.74 + </xsd:complexType>
81.75 + <xsd:element name="connectInfo" type="ns1:ConnectInfoType"></xsd:element>
81.76 + <xsd:complexType name="QueryType">
81.77 + <xsd:sequence>
81.78 + <xsd:element name="users" minOccurs="0">
81.79 + <xsd:complexType>
81.80 + <xsd:sequence>
81.81 + <xsd:element name="user" minOccurs="0" maxOccurs="unbounded" />
81.82 + </xsd:sequence>
81.83 + </xsd:complexType>
81.84 + </xsd:element>
81.85 + <xsd:element name="roles" minOccurs="0">
81.86 + <xsd:complexType>
81.87 + <xsd:sequence>
81.88 + <xsd:element name="role" minOccurs="0" maxOccurs="unbounded" />
81.89 + </xsd:sequence>
81.90 + </xsd:complexType>
81.91 + </xsd:element>
81.92 + <xsd:element name="groups" minOccurs="0">
81.93 + <xsd:complexType>
81.94 + <xsd:sequence>
81.95 + <xsd:element name="group" minOccurs="0" maxOccurs="unbounded" />
81.96 + </xsd:sequence>
81.97 + </xsd:complexType>
81.98 + </xsd:element>
81.99 + <xsd:element name="taskStatus" type="ns1:TaskStatus" minOccurs="0" maxOccurs="unbounded" />
81.100 + </xsd:sequence>
81.101 + <xsd:attribute name="type" default="DEFAULT">
81.102 + <xsd:simpleType>
81.103 + <xsd:restriction base="xsd:string">
81.104 + <xsd:enumeration value="DEFAULT"/>
81.105 + <xsd:enumeration value="FILTERED"/>
81.106 + </xsd:restriction>
81.107 + </xsd:simpleType>
81.108 + </xsd:attribute>
81.109 + </xsd:complexType>
81.110 + <xsd:element name="query" type="ns1:QueryType" />
81.111 + <xsd:element name="taskIdentifer" type="xsd:long"></xsd:element>
81.112 + <xsd:element name="AssigneeRole" type="xsd:string"></xsd:element>
81.113 + <xsd:element name="AssigneeUser" type="xsd:string"></xsd:element>
81.114 + </xsd:schema>
81.115 +
81.116 +
81.117 + </types>
81.118 + <message name="GetTaskList_Input">
81.119 + <part name="queryString" type="ns1:QueryType"/>
81.120 + </message>
81.121 + <message name="GetTaskList_Output">
81.122 + <part name="taskList" type="ns1:TaskListType"/>
81.123 + </message>
81.124 + <message name="ClaimTask_Input">
81.125 + <part name="taskId" type="xsd:long"/>
81.126 + </message>
81.127 + <message name="ClaimTask_Output">
81.128 + <part name="resultCode" type="ns1:ResultCodeType"/>
81.129 + </message>
81.130 + <message name="RevokeTask_Input">
81.131 + <part name="taskId" type="xsd:long"/>
81.132 + </message>
81.133 + <message name="RevokeTask_Output">
81.134 + <part name="resultCode" type="ns1:ResultCodeType"/>
81.135 + </message>
81.136 + <message name="CompleteTask_Input">
81.137 + <part name="taskId" type="xsd:long"/>
81.138 + </message>
81.139 + <message name="CompleteTask_Output">
81.140 + <part name="resultCode" type="ns1:ResultCodeType"/>
81.141 + </message>
81.142 + <message name="ReassignTask_Input">
81.143 + <part name="taskId" type="xsd:long"/>
81.144 + <part name="role" type="xsd:string"/>
81.145 + <part name="user" type="xsd:string"/>
81.146 + </message>
81.147 + <message name="ReassignTask_Output">
81.148 + <part name="resultCode" type="ns1:ResultCodeType"/>
81.149 + </message>
81.150 + <message name="GetOptInput_Input">
81.151 + <part name="taskId" type="xsd:long"/>
81.152 + </message>
81.153 + <message name="GetOptOutput_Output">
81.154 + <part name="outputMsg" type="xsd:anyType"/>
81.155 + </message>
81.156 + <message name="GetOptInput_Output">
81.157 + <part name="inputMsg" type="xsd:anyType"/>
81.158 + </message>
81.159 + <message name="GetOptOutput_Input">
81.160 + <part name="taskId" type="xsd:long"/>
81.161 + </message>
81.162 + <message name="SetOptOutput_Input">
81.163 + <part name="taskId" type="xsd:long"/>
81.164 + <part name="outputMsg" type="xsd:anyType"/>
81.165 + </message>
81.166 + <message name="SetOptOutput_Output">
81.167 + <part name="resultCode" type="ns1:ResultCodeType"/>
81.168 + </message>
81.169 + <message name="OptFaultMsg">
81.170 + <part name="fault" element="ns1:fault"/>
81.171 + </message>
81.172 + <message name="TaskIdMsg">
81.173 + <part name="taskId" type="xsd:long"/>
81.174 + </message>
81.175 +
81.176 + <message name="GetOptInputXForm_Input">
81.177 + <part name="taskId" type="xsd:long"/>
81.178 + </message>
81.179 +
81.180 + <message name="GetOptInputXForm_Output">
81.181 + <part name="inputXForm" type="xsd:anyType"/>
81.182 + </message>
81.183 +
81.184 + <message name="GetOptOutputXForm_Input">
81.185 + <part name="taskId" type="xsd:long"/>
81.186 + </message>
81.187 +
81.188 + <message name="GetOptOutputXForm_Output">
81.189 + <part name="outputXForm" type="xsd:anyType"/>
81.190 + </message>
81.191 +
81.192 + <portType name="TaskCommOptPT">
81.193 + <operation name="GetTaskList">
81.194 + <input name="getTaskList_input" message="tns:GetTaskList_Input"/>
81.195 + <output name="getTaskList_output" message="tns:GetTaskList_Output"/>
81.196 + <fault name="fault1" message="tns:OptFaultMsg"/>
81.197 + </operation>
81.198 + <operation name="ClaimTask">
81.199 + <input name="claimTask_input" message="tns:ClaimTask_Input"/>
81.200 + <output name="claimTask_output" message="tns:ClaimTask_Output"/>
81.201 + <fault name="fault1" message="tns:OptFaultMsg"/>
81.202 + </operation>
81.203 + <operation name="RevokeTask">
81.204 + <input name="revokeTask_input" message="tns:RevokeTask_Input"/>
81.205 + <output name="revokeTask_output" message="tns:RevokeTask_Output"/>
81.206 + <fault name="fault1" message="tns:OptFaultMsg"/>
81.207 + </operation>
81.208 + <operation name="CompleteTask">
81.209 + <input name="completeTask_input" message="tns:CompleteTask_Input"/>
81.210 + <output name="completeTask_output" message="tns:CompleteTask_Output"/>
81.211 + <fault name="fault1" message="tns:OptFaultMsg"/>
81.212 + </operation>
81.213 + <operation name="ReassignTask">
81.214 + <input name="reassignTask_input" message="tns:ReassignTask_Input"/>
81.215 + <output name="reassignTask_output" message="tns:ReassignTask_Output"/>
81.216 + <fault name="fault1" message="tns:OptFaultMsg"/>
81.217 + </operation>
81.218 + <operation name="GetOptInput">
81.219 + <input name="getOptInput_input" message="tns:GetOptInput_Input"/>
81.220 + <output name="getOptInput_output" message="tns:GetOptInput_Output"/>
81.221 + <fault name="fault1" message="tns:OptFaultMsg"/>
81.222 + </operation>
81.223 + <operation name="GetOptOutput">
81.224 + <input name="getOptOutput_input" message="tns:GetOptOutput_Input"/>
81.225 + <output name="getOptOutput_output" message="tns:GetOptOutput_Output"/>
81.226 + <fault name="fault1" message="tns:OptFaultMsg"/>
81.227 + </operation>
81.228 + <operation name="SetOptOutput">
81.229 + <input name="setOptOutput_input" message="tns:SetOptOutput_Input"/>
81.230 + <output name="setOptOutput_output" message="tns:SetOptOutput_Output"/>
81.231 + <fault name="fault1" message="tns:OptFaultMsg"/>
81.232 + </operation>
81.233 + <operation name="GetOptInputSchema">
81.234 + <input name="getOptInputSchema_input" message="tns:GetOptOutput_Input"/>
81.235 + <output name="getOptInputSchema_output" message="tns:GetOptOutput_Output"/>
81.236 + <fault name="fault1" message="tns:OptFaultMsg"/>
81.237 + </operation>
81.238 + <operation name="GetOptOutputSchema">
81.239 + <input name="getOptOutputSchema_input" message="tns:GetOptOutput_Input"/>
81.240 + <output name="getOptOutputSchema_output" message="tns:GetOptOutput_Output"/>
81.241 + <fault name="fault1" message="tns:OptFaultMsg"/>
81.242 + </operation>
81.243 + <operation name="GetOptInputXForm">
81.244 + <input name="getOptInputXForm_input" message="tns:GetOptInputXForm_Input"/>
81.245 + <output name="getOptInputXForm_output" message="tns:GetOptInputXForm_Output"/>
81.246 + <fault name="fault1" message="tns:OptFaultMsg"/>
81.247 + </operation>
81.248 + <operation name="GetOptOutputXForm">
81.249 + <input name="getOptOutputXForm_input" message="tns:GetOptOutputXForm_Input"/>
81.250 + <output name="getOptOutputXForm_output" message="tns:GetOptOutputXForm_Output"/>
81.251 + <fault name="fault1" message="tns:OptFaultMsg"/>
81.252 + </operation>
81.253 + </portType>
81.254 +
81.255 + <binding name="TaskCommonBinding" type="tns:TaskCommOptPT">
81.256 + <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="rpc"/>
81.257 + <operation name="GetTaskList">
81.258 + <soap:operation soapAction="GetTaskList"/>
81.259 + <input name="getTaskList_input" >
81.260 + <soap:body use="literal" namespace="http://jbi.com.sun/wfse/wsdl/TaskCommon"/>
81.261 + </input>
81.262 + <output name="getTaskList_output">
81.263 + <soap:body use="literal" namespace="http://jbi.com.sun/wfse/wsdl/TaskCommon"/>
81.264 + </output>
81.265 + <fault name="fault1">
81.266 + <soap:fault name="fault1" use="literal"/>
81.267 + </fault>
81.268 + </operation>
81.269 + <operation name="ClaimTask">
81.270 + <soap:operation soapAction="ClaimTask"/>
81.271 + <input name="claimTask_input" >
81.272 + <soap:body use="literal" namespace="http://jbi.com.sun/wfse/wsdl/TaskCommon"/>
81.273 + </input>
81.274 + <output name="claimTask_output" >
81.275 + <soap:body use="literal" namespace="http://jbi.com.sun/wfse/wsdl/TaskCommon"/>
81.276 + </output>
81.277 + <fault name="fault1">
81.278 + <soap:fault name="fault1" use="literal"/>
81.279 + </fault>
81.280 + </operation>
81.281 +
81.282 + <operation name="RevokeTask">
81.283 + <soap:operation soapAction="RevokeTask"/>
81.284 + <input name="revokeTask_input" >
81.285 + <soap:body use="literal" namespace="http://jbi.com.sun/wfse/wsdl/TaskCommon"/>
81.286 + </input>
81.287 + <output name="revokeTask_output" >
81.288 + <soap:body use="literal" namespace="http://jbi.com.sun/wfse/wsdl/TaskCommon"/>
81.289 + </output>
81.290 + <fault name="fault1">
81.291 + <soap:fault name="fault1" use="literal"/>
81.292 + </fault>
81.293 + </operation>
81.294 +
81.295 + <operation name="CompleteTask">
81.296 + <soap:operation soapAction="CompleteTask"/>
81.297 + <input>
81.298 + <soap:body use="literal" namespace="http://jbi.com.sun/wfse/wsdl/TaskCommon"/>
81.299 + </input>
81.300 + <output>
81.301 + <soap:body use="literal" namespace="http://jbi.com.sun/wfse/wsdl/TaskCommon"/>
81.302 + </output>
81.303 + <fault name="fault1">
81.304 + <soap:fault name="fault1" use="literal"/>
81.305 + </fault>
81.306 + </operation>
81.307 +
81.308 + <operation name="ReassignTask">
81.309 + <soap:operation soapAction="ReassignTask"/>
81.310 + <input>
81.311 + <soap:body use="literal" namespace="http://jbi.com.sun/wfse/wsdl/TaskCommon"/>
81.312 + </input>
81.313 + <output>
81.314 + <soap:body use="literal" namespace="http://jbi.com.sun/wfse/wsdl/TaskCommon"/>
81.315 + </output>
81.316 + <fault name="fault1">
81.317 + <soap:fault name="fault1" use="literal"/>
81.318 + </fault>
81.319 + </operation>
81.320 +
81.321 + <operation name="GetOptInput">
81.322 + <soap:operation soapAction="GetOptInput"/>
81.323 + <input>
81.324 + <soap:body use="literal" namespace="http://jbi.com.sun/wfse/wsdl/TaskCommon"/>
81.325 + </input>
81.326 + <output>
81.327 + <soap:body use="literal" namespace="http://jbi.com.sun/wfse/wsdl/TaskCommon"/>
81.328 + </output>
81.329 + <fault name="fault1">
81.330 + <soap:fault name="fault1" use="literal"/>
81.331 + </fault>
81.332 + </operation>
81.333 +
81.334 + <operation name="GetOptOutput">
81.335 + <soap:operation soapAction="GetOptOutput"/>
81.336 + <input>
81.337 + <soap:body use="literal" namespace="http://jbi.com.sun/wfse/wsdl/TaskCommon"/>
81.338 + </input>
81.339 + <output>
81.340 + <soap:body use="literal" namespace="http://jbi.com.sun/wfse/wsdl/TaskCommon"/>
81.341 + </output>
81.342 + <fault name="fault1">
81.343 + <soap:fault name="fault1" use="literal"/>
81.344 + </fault>
81.345 + </operation>
81.346 +
81.347 + <operation name="SetOptOutput">
81.348 + <soap:operation soapAction="SetOptOutput"/>
81.349 + <input>
81.350 + <soap:body use="literal" namespace="http://jbi.com.sun/wfse/wsdl/TaskCommon"/>
81.351 + </input>
81.352 + <output>
81.353 + <soap:body use="literal" namespace="http://jbi.com.sun/wfse/wsdl/TaskCommon"/>
81.354 + </output>
81.355 + <fault name="fault1">
81.356 + <soap:fault name="fault1" use="literal"/>
81.357 + </fault>
81.358 + </operation>
81.359 +
81.360 + <operation name="GetOptInputSchema">
81.361 + <soap:operation soapAction="GetOptInputSchema"/>
81.362 + <input>
81.363 + <soap:body use="literal" namespace="http://jbi.com.sun/wfse/wsdl/TaskCommon"/>
81.364 + </input>
81.365 + <output>
81.366 + <soap:body use="literal" namespace="http://jbi.com.sun/wfse/wsdl/TaskCommon"/>
81.367 + </output>
81.368 + <fault name="fault1">
81.369 + <soap:fault name="fault1" use="literal"/>
81.370 + </fault>
81.371 + </operation>
81.372 +
81.373 + <operation name="GetOptOutputSchema">
81.374 + <soap:operation soapAction="GetOptOutputSchema"/>
81.375 + <input>
81.376 + <soap:body use="literal" namespace="http://jbi.com.sun/wfse/wsdl/TaskCommon"/>
81.377 + </input>
81.378 + <output>
81.379 + <soap:body use="literal" namespace="http://jbi.com.sun/wfse/wsdl/TaskCommon"/>
81.380 + </output>
81.381 + <fault name="fault1">
81.382 + <soap:fault name="fault1" use="literal"/>
81.383 + </fault>
81.384 + </operation>
81.385 +
81.386 + <operation name="GetOptInputXForm">
81.387 + <soap:operation soapAction="GetOptInputXForm"/>
81.388 + <input>
81.389 + <soap:body use="literal" namespace="http://jbi.com.sun/wfse/wsdl/TaskCommon"/>
81.390 + </input>
81.391 + <output>
81.392 + <soap:body use="literal" namespace="http://jbi.com.sun/wfse/wsdl/TaskCommon"/>
81.393 + </output>
81.394 + <fault name="fault1">
81.395 + <soap:fault name="fault1" use="literal"/>
81.396 + </fault>
81.397 + </operation>
81.398 +
81.399 + <operation name="GetOptOutputXForm">
81.400 + <soap:operation soapAction="GetOptOutputXForm"/>
81.401 + <input>
81.402 + <soap:body use="literal" namespace="http://jbi.com.sun/wfse/wsdl/TaskCommon"/>
81.403 + </input>
81.404 + <output>
81.405 + <soap:body use="literal" namespace="http://jbi.com.sun/wfse/wsdl/TaskCommon"/>
81.406 + </output>
81.407 + <fault name="fault1">
81.408 + <soap:fault name="fault1" use="literal"/>
81.409 + </fault>
81.410 + </operation>
81.411 +
81.412 +
81.413 + </binding>
81.414 + <service name="TaskService">
81.415 + <port name="TaskCommonPort" binding="tns:TaskCommonBinding">
81.416 + <soap:address location="http://localhost:18181/wfse/TaskCommon"/>
81.417 + </port>
81.418 + </service>
81.419 +
81.420 + <plink:partnerLinkType name="TaskCommonLT">
81.421 + <plink:role name="TaskCommon_Server" portType="tns:TaskCommOptPT"/>
81.422 + </plink:partnerLinkType>
81.423 +
81.424 +</definitions>
82.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
82.2 +++ b/enterprise/openesbaddons/workflow/project/src/org/netbeans/modules/workflow/project/resources/TaskStaticTemplate.wsdl Thu Apr 26 02:33:27 2007 +0000
82.3 @@ -0,0 +1,191 @@
82.4 +<?xml version="1.0" encoding="UTF-8"?>
82.5 +<definitions name="DEFINTION_NAME" targetNamespace="DEFINITON_TARGETNAMESPACE"
82.6 + xmlns="http://schemas.xmlsoap.org/wsdl/"
82.7 + xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
82.8 + xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
82.9 + xmlns:xsd="http://www.w3.org/2001/XMLSchema"
82.10 + xmlns:tns="DEFINITON_TARGETNAMESPACE"
82.11 + xmlns:ns1="http://jbi.com.sun/wfse/wsdl/TaskCommon"
82.12 + xmlns:ns2="http://wlmse.sample/po"
82.13 + xmlns:plink="http://docs.oasis-open.org/wsbpel/2.0/plnktype">
82.14 + <types>
82.15 + <xsd:schema targetNamespace="http://jbi.com.sun/wfse/wsdl/TaskCommon">
82.16 + <xsd:simpleType name="ResultCodeType">
82.17 + <xsd:restriction base="xsd:string">
82.18 + <xsd:enumeration value="SUCCESS"/>
82.19 + <xsd:enumeration value="FAILED"/>
82.20 + </xsd:restriction>
82.21 + </xsd:simpleType>
82.22 + <xsd:element name="resultCode" type="ns1:ResultCodeType"></xsd:element>
82.23 + <xsd:complexType name="FaultType">
82.24 + <xsd:sequence>
82.25 + <xsd:element name="FaultCode" type="xsd:string"></xsd:element>
82.26 + <xsd:element name="FaultReason" type="xsd:string"></xsd:element>
82.27 + </xsd:sequence>
82.28 + </xsd:complexType>
82.29 + <xsd:element name="fault" type="ns1:FaultType"></xsd:element>
82.30 +
82.31 + </xsd:schema>
82.32 +
82.33 + <!-- generate any schema imports from bpel wsdl if it has inline schema we can serailize that to an xsd and import it here-->
82.34 +
82.35 + </types>
82.36 +
82.37 + <message name="GetOptOutput_Input">
82.38 + <part name="taskId" type="xsd:long"/>
82.39 + </message>
82.40 + <message name="SetOptOutput_Output">
82.41 + <part name="resultCode" type="ns1:ResultCodeType"/>
82.42 + </message>
82.43 + <message name="OptFaultMsg">
82.44 + <part name="fault" element="ns1:fault"/>
82.45 + </message>
82.46 +
82.47 + <message name="TaskIdMsg">
82.48 + <part name="taskId" type="xsd:long"/>
82.49 + </message>
82.50 +
82.51 +
82.52 + <!-- 5 message for each task operations , 2 for input 2 for output and 1 for fault set<opnname>Output will not have fault-->
82.53 + <!--
82.54 + <message name="DEFINITON_TASKNAMEInput">
82.55 + <part name="inputMsg" type="ns2:PurchaseOrderType"/>
82.56 + </message>
82.57 + <message name="DEFINITON_TASKNAMEOutput">
82.58 + <part name="outputMsg" type="ns2:OrderReplyType"/>
82.59 + </message>
82.60 +
82.61 + <message name="GetDEFINITON_TASKNAMEInput_Input">
82.62 + <part name="taskId" type="xsd:long"/>
82.63 + </message>
82.64 +
82.65 + <message name="GetDEFINITON_TASKNAMEOutput_Input">
82.66 + <part name="taskId" type="xsd:long"/>
82.67 + </message>
82.68 +
82.69 + <message name="SetDEFINITON_TASKNAMEOutput_Input">
82.70 + <part name="taskId" type="xsd:long"/>
82.71 + <part name="outputMsg" type="ns2:OrderReplyType"/>
82.72 + </message>
82.73 + -->
82.74 +
82.75 + <!-- generate porttype for task operation
82.76 + porttype name: same as task operation's porttype name
82.77 + 3 operations will be generated:
82.78 + (1) Get<operationName>Input
82.79 + generate input message which takes taskid part
82.80 + <part name="taskId" element="ns1:taskIdentifer"/>
82.81 +
82.82 + generate output message which is same as input message of bpel <operation>
82.83 +
82.84 + generate fault which constant use tns:OptFaultMsg for message
82.85 +
82.86 + (2) Get<operationName>Output
82.87 + generate input message which takes taskid part
82.88 + <part name="taskId" element="ns1:taskIdentifer"/>
82.89 +
82.90 + generate output message which is same as output message of bpel <operation>
82.91 +
82.92 + generate fault which constant use tns:OptFaultMsg for message
82.93 +
82.94 + (3) Set<operationName>Output
82.95 + generate one message which has taskid part and part which is output part of the
82.96 + output message of bpel <operation>
82.97 + see SetDEFINITON_TASKNAMEOutput_Input
82.98 +
82.99 + -->
82.100 + <!--
82.101 + <portType name="DEFINITON_TASKNAMEPT">
82.102 + <operation name="GetDEFINITON_TASKNAMEInput">
82.103 + <input name="GetDEFINITON_TASKNAMEInputInput" message="tns:GetDEFINITON_TASKNAMEInput_Input"/>
82.104 + <output name="GetDEFINITON_TASKNAMEInputOutput" message="tns:DEFINITON_TASKNAMEInput"/>
82.105 + <fault name="GetDEFINITON_TASKNAMEInputFault" message="tns:OptFaultMsg"/>
82.106 + </operation>
82.107 + <operation name="GetDEFINITON_TASKNAMEOutput">
82.108 + <input name="GetDEFINITON_TASKNAMEOutputInput" message="tns:GetDEFINITON_TASKNAMEOutput_Input"/>
82.109 + <output name="GetDEFINITON_TASKNAMEOutputOutput" message="tns:DEFINITON_TASKNAMEOutput"/>
82.110 + <fault name="GetDEFINITON_TASKNAMEOutputFault" message="tns:OptFaultMsg"/>
82.111 + </operation>
82.112 + <operation name="SetDEFINITON_TASKNAMEOutput">
82.113 + <input name="SetDEFINITON_TASKNAMEOutputInput" message="tns:SetDEFINITON_TASKNAMEOutput_Input"/>
82.114 + <output name="SetDEFINITON_TASKNAMEOutputOutput" message="tns:SetOptOutput_Output"/>
82.115 + <fault name="SetDEFINITON_TASKNAMEOutputFault" message="tns:OptFaultMsg"/>
82.116 + </operation>
82.117 + </portType>
82.118 + -->
82.119 +
82.120 +
82.121 + <!-- generate binding for generated porttype
82.122 + binding name can be <generate portType name>Binding
82.123 + generate operation
82.124 + generate soap:operation
82.125 + generate input
82.126 + generate soap:body
82.127 + generate output
82.128 + generate soap:body
82.129 + generate fault
82.130 + generate soap:fault
82.131 + -->
82.132 + <!--
82.133 + <binding name="DEFINITON_TASKNAME" type="tns:DEFINITON_TASKNAMEPT">
82.134 + <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="rpc"/>
82.135 + <operation name="GetDEFINITON_TASKNAMEInput">
82.136 + <soap:operation soapAction="GetDEFINITON_TASKNAMEInput"/>
82.137 + <input>
82.138 + <soap:body use="literal" namespace="DEFINITON_TARGETNAMESPACE"/>
82.139 + </input>
82.140 + <output>
82.141 + <soap:body use="literal" namespace="DEFINITON_TARGETNAMESPACE"/>
82.142 + </output>
82.143 + <fault name="GetDEFINITON_TASKNAMEInputFault">
82.144 + <soap:fault name="GetDEFINITON_TASKNAMEInputFault" use="literal"/>
82.145 + </fault>
82.146 + </operation>
82.147 + <operation name="GetDEFINITON_TASKNAMEOutput">
82.148 + <soap:operation soapAction="GetDEFINITON_TASKNAMEOutput"/>
82.149 + <input>
82.150 + <soap:body use="literal" namespace="DEFINITON_TARGETNAMESPACE"/>
82.151 + </input>
82.152 + <output>
82.153 + <soap:body use="literal" namespace="DEFINITON_TARGETNAMESPACE"/>
82.154 + </output>
82.155 + <fault name="GetDEFINITON_TASKNAMEOutputFault">
82.156 + <soap:fault name="GetDEFINITON_TASKNAMEOutputFault" use="literal"/>
82.157 + </fault>
82.158 + </operation>
82.159 + <operation name="SetDEFINITON_TASKNAMEOutput">
82.160 + <soap:operation soapAction="SetDEFINITON_TASKNAMEOutput"/>
82.161 + <input>
82.162 + <soap:body use="literal" namespace="DEFINITON_TARGETNAMESPACE"/>
82.163 + </input>
82.164 + <output>
82.165 + <soap:body use="literal" namespace="DEFINITON_TARGETNAMESPACE"/>
82.166 + </output>
82.167 + <fault name="SetDEFINITON_TASKNAMEOutputFault">
82.168 + <soap:fault name="SetDEFINITON_TASKNAMEOutputFault" use="literal"/>
82.169 + </fault>
82.170 + </operation>
82.171 + </binding>
82.172 +
82.173 + -->
82.174 + <service name="TaskService">
82.175 +
82.176 + <!-- generate port and binding attribute points to the generated binding -->
82.177 + <!--
82.178 + <port name="TaskDEFINITON_TASKNAMEClientPort" binding="tns:DEFINITON_TASKNAME">
82.179 + <soap:address location="http://localhost:18181/wfse/DEFINITON_TASKNAMEClient"/>
82.180 + </port>
82.181 + -->
82.182 + </service>
82.183 +
82.184 + <!-- generate partnerLinkType
82.185 + role's portType attribute will point to generated portType name
82.186 + -->
82.187 +
82.188 + <!--
82.189 + <plink:partnerLinkType name="TaskDEFINITON_TASKNAMEClientLT">
82.190 + <plink:role name="TaskDEFINITON_TASKNAMEClient_Server" portType="tns:DEFINITON_TASKNAMEPT"/>
82.191 + </plink:partnerLinkType>
82.192 + -->
82.193 +
82.194 +</definitions>
83.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
83.2 +++ b/enterprise/openesbaddons/workflow/project/src/org/netbeans/modules/workflow/project/resources/build-impl.xsl Thu Apr 26 02:33:27 2007 +0000
83.3 @@ -0,0 +1,681 @@
83.4 +<?xml version="1.0" encoding="UTF-8"?>
83.5 +<!--
83.6 + Sun Public License Notice
83.7 +
83.8 +The contents of this file are subject to the Sun Public License
83.9 +Version 1.0 (the "License"). You may not use this file except in
83.10 +compliance with the License. A copy of the License is available at
83.11 +http://www.sun.com/
83.12 +
83.13 +The Original Code is NetBeans. The Initial Developer of the Original
83.14 +Code is Sun Microsystems, Inc. Portions Copyright 1997-2004 Sun
83.15 +Microsystems, Inc. All Rights Reserved.
83.16 +-->
83.17 +<xsl:stylesheet version="1.0"
83.18 + xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
83.19 + xmlns:p="http://www.netbeans.org/ns/project/1"
83.20 + xmlns:xalan="http://xml.apache.org/xslt"
83.21 + xmlns:ejb="http://www.netbeans.org/ns/j2ee-ejbjarproject/1"
83.22 + xmlns:projdeps="http://www.netbeans.org/ns/ant-project-references/1"
83.23 + exclude-result-prefixes="xalan p ejb projdeps">
83.24 + <xsl:output method="xml" indent="yes" encoding="UTF-8" xalan:indent-amount="4"/>
83.25 + <xsl:template match="/">
83.26 +
83.27 + <xsl:comment><![CDATA[
83.28 +*** GENERATED FROM project.xml - DO NOT EDIT ***
83.29 +*** EDIT ../build.xml INSTEAD ***
83.30 +
83.31 +For the purpose of easier reading the script
83.32 +is divided into following sections:
83.33 +
83.34 + - initialization
83.35 + - compilation
83.36 + - dist
83.37 + - execution
83.38 + - debugging
83.39 + - javadoc
83.40 + - cleanup
83.41 +
83.42 +]]></xsl:comment>
83.43 +
83.44 + <xsl:variable name="name" select="/p:project/p:configuration/ejb:data/ejb:name"/>
83.45 + <project name="{$name}-impl">
83.46 + <xsl:attribute name="default">build</xsl:attribute>
83.47 + <xsl:attribute name="basedir">..</xsl:attribute>
83.48 +
83.49 + <target name="default">
83.50 + <xsl:attribute name="depends">dist,javadoc</xsl:attribute>
83.51 + <xsl:attribute name="description">Build whole project.</xsl:attribute>
83.52 + </target>
83.53 +
83.54 + <xsl:comment>
83.55 + ======================
83.56 + INITIALIZATION SECTION
83.57 + ======================
83.58 + </xsl:comment>
83.59 +
83.60 + <target name="pre-init">
83.61 + <xsl:comment> Empty placeholder for easier customization. </xsl:comment>
83.62 + <xsl:comment> You can override this target in the ../build.xml file. </xsl:comment>
83.63 + </target>
83.64 +
83.65 + <target name="init-private">
83.66 + <xsl:attribute name="depends">pre-init</xsl:attribute>
83.67 + <property file="nbproject/private/private.properties"/>
83.68 + </target>
83.69 +
83.70 + <target name="init-userdir">
83.71 + <xsl:attribute name="depends">pre-init,init-private</xsl:attribute>
83.72 + <property name="user.properties.file" location="${{netbeans.user}}/build.properties"/>
83.73 + </target>
83.74 +
83.75 + <target name="init-user">
83.76 + <xsl:attribute name="depends">pre-init,init-private,init-userdir</xsl:attribute>
83.77 + <property file="${{user.properties.file}}"/>
83.78 + </target>
83.79 +
83.80 + <target name="init-project">
83.81 + <xsl:attribute name="depends">pre-init,init-private,init-userdir,init-user</xsl:attribute>
83.82 + <property file="nbproject/project.properties"/>
83.83 + <xsl:comment> Points build to Alaska project cluster. </xsl:comment>
83.84 + <xsl:comment> NOTE: If cluster name changes, this property must be updated. </xsl:comment>
83.85 + <property name="module.install.dir" value="${{cluster}}/modules"/>
83.86 + </target>
83.87 +
83.88 + <target name="do-init">
83.89 + <xsl:attribute name="depends">pre-init,init-private,init-userdir,init-user,init-project</xsl:attribute>
83.90 + <xsl:if test="/p:project/p:configuration/ejb:data/ejb:explicit-platform">
83.91 + <!--Setting java and javac default location -->
83.92 + <property name="platforms.${{platform.active}}.javac" value="${{platform.home}}/bin/javac"/>
83.93 + <property name="platforms.${{platform.active}}.java" value="${{platform.home}}/bin/java"/>
83.94 + <!-- XXX Ugly but Ant does not yet support recursive property evaluation: -->
83.95 + <tempfile property="file.tmp" prefix="platform" suffix=".properties"/>
83.96 + <echo file="${{file.tmp}}">
83.97 + platform.home=$${platforms.${platform.active}.home}
83.98 + platform.bootcp=$${platforms.${platform.active}.bootclasspath}
83.99 + build.compiler=$${platforms.${platform.active}.compiler}
83.100 + platform.java=$${platforms.${platform.active}.java}
83.101 + platform.javac=$${platforms.${platform.active}.javac}
83.102 + </echo>
83.103 + <property file="${{file.tmp}}"/>
83.104 + <delete file="${{file.tmp}}"/>
83.105 + <fail unless="platform.home">Must set platform.home</fail>
83.106 + <fail unless="platform.bootcp">Must set platform.bootcp</fail>
83.107 + <fail unless="platform.java">Must set platform.java</fail>
83.108 + <fail unless="platform.javac">Must set platform.javac</fail>
83.109 + </xsl:if>
83.110 + <xsl:comment> The two properties below are usually overridden </xsl:comment>
83.111 + <xsl:comment> by the active platform. Just a fallback. </xsl:comment>
83.112 + <property name="default.javac.source" value="1.4"/>
83.113 + <property name="default.javac.target" value="1.4"/>
83.114 + <xsl:if test="/p:project/p:configuration/ejb:data/ejb:use-manifest">
83.115 + <fail unless="manifest.file">Must set manifest.file</fail>
83.116 + </xsl:if>
83.117 + <condition property="no.javadoc.preview">
83.118 + <isfalse value="${{javadoc.preview}}"/>
83.119 + </condition>
83.120 + </target>
83.121 +
83.122 + <target name="post-init">
83.123 + <xsl:comment> Empty placeholder for easier customization. </xsl:comment>
83.124 + <xsl:comment> You can override this target in the ../build.xml file. </xsl:comment>
83.125 + </target>
83.126 +
83.127 + <target name="init-check">
83.128 + <xsl:attribute name="depends">pre-init,init-private,init-userdir,init-user,init-project,do-init</xsl:attribute>
83.129 + <!-- XXX XSLT 2.0 would make it possible to use a for-each here -->
83.130 + <!-- Note that if the properties were defined in project.xml that would be easy -->
83.131 + <!-- But required props should be defined by the AntBasedProjectType, not stored in each project -->
83.132 + <fail unless="src.dir">Must set src.dir</fail>
83.133 + <fail unless="build.dir">Must set build.dir</fail>
83.134 + <fail unless="build.generated.dir">Must set build.generated.dir</fail>
83.135 + <fail unless="dist.dir">Must set dist.dir</fail>
83.136 + <fail unless="build.classes.dir">Must set build.classes.dir</fail>
83.137 +<!-- //B20050104 <fail unless="dist.javadoc.dir">Must set dist.javadoc.dir</fail> -->
83.138 +<!-- //B20050104 <fail unless="build.classes.excludes">Must set build.classes.excludes</fail> -->
83.139 + <fail unless="dist.jar">Must set dist.jar</fail>
83.140 + </target>
83.141 + <target name="init-taskdefs-1">
83.142 + <path id="ant.task.classpath.models">
83.143 + <pathelement path="${{netbeans.home}}/../soa1/modules/org-netbeans-modules-workflow-project.jar"/>
83.144 + <pathelement path="${{netbeans.home}}/../soa1/modules/ext/workflow/anttask.jar"/>
83.145 + <pathelement location="${{netbeans.home}}/../../ide8/modules/org-netbeans-modules-xml-xam.jar"/>
83.146 + <pathelement location="${{netbeans.home}}/../../ide8/modules/org-netbeans-modules-xml-schema-model.jar"/>
83.147 + <pathelement location="${{netbeans.home}}/../../ide8/modules/org-netbeans-modules-xml-wsdl-model.jar"/>
83.148 + <pathelement location="${{netbeans.home}}/../../platform7/lib/org-openide-util.jar"/>
83.149 + <pathelement location="${{netbeans.home}}/../../platform7/modules/org-openide-loaders.jar"/>
83.150 + <pathelement location="${{netbeans.home}}/../../soa1/modules/org-netbeans-modules-xml-wsdl-extensions.jar"/>
83.151 + <pathelement location="${{netbeans.home}}/../../ide8/modules/org-apache-xml-resolver.jar"/>
83.152 + <pathelement location="${{netbeans.home}}/../../ide8/modules/org-netbeans-modules-xml-retriever.jar"/>
83.153 + <pathelement location="${{netbeans.home}}/../../ide8/modules/ext/resolver-1_1_nb.jar"/>
83.154 + <pathelement location="${{netbeans.home}}/../../soa1/modules/ext/workflow/chiba.jar" />
83.155 + <pathelement location="${{netbeans.home}}/../../soa1/modules/ext/jxpath/jxpath1.1.jar"/>
83.156 + <pathelement location="${{netbeans.home}}/../../ide8/modules/ext/jxpath/xerces-2.8.0.jar"/>
83.157 + <pathelement location="${{netbeans.home}}/../../soa1/modules/ext/workflow/log4j-1.2.13.jar"/>
83.158 + </path>
83.159 +
83.160 + <path id="generate.jbi">
83.161 + <pathelement path="${{netbeans.home}}/../soa1/modules/org-netbeans-modules-workflow-project.jar"/>
83.162 + <pathelement path="${{netbeans.home}}/../soa1/modules/ext/workflow/anttask.jar"/>
83.163 + <pathelement path="${{netbeans.home}}/../soa1/modules/ext/workflow/workflowmodel.jar"/>
83.164 + <pathelement path="${{netbeans.home}}/../soa1/modules/ext/workflow/wfse_def.jar"/>
83.165 + <pathelement path="${{netbeans.home}}/../soa1/modules/ext/workflow/wsdl4j.jar"/>
83.166 + <pathelement path="${{netbeans.home}}/../soa1/modules/ext/xmlbeans-2.1.0/xbean.jar"/>
83.167 + <pathelement path="${{netbeans.home}}/../soa1/modules/ext/xmlbeans-2.1.0/xbean_xpath.jar"/>
83.168 + <pathelement path="${{netbeans.home}}/../soa1/modules/ext/xmlbeans-2.1.0/resolver.jar"/>
83.169 + <pathelement path="${{netbeans.home}}/../soa1/modules/ext/xmlbeans-2.1.0/jsr173_1.0_api.jar"/>
83.170 + <pathelement path="${{netbeans.home}}/../soa1/modules/ext/xmlbeans-2.1.0/xmlpublic.jar"/>
83.171 + <pathelement path="${{netbeans.home}}/../soa1/modules/ext/workflow/chiba.jar" />
83.172 + <pathelement path="${{netbeans.home}}/../soa1/modules/ext/jxpath/jxpath1.1.jar"/>
83.173 + <pathelement path="${{netbeans.home}}/../ide8/modules/ext/jxpath/xerces-2.8.0.jar"/>
83.174 + <pathelement path="${{netbeans.home}}/../soa1/modules/ext/workflow/log4j-1.2.13.jar"/>
83.175 + </path>
83.176 +
83.177 + </target>
83.178 +
83.179 + <target name="init-taskdefs" unless="netbeans.home" depends="init-taskdefs-1">
83.180 + <taskdef name="generate-asa-artifacts" classname="org.netbeans.modules.workflow.project.anttasks.GenerateAsaArtifacts">
83.181 + <classpath refid="generate.jbi"/>
83.182 + </taskdef>
83.183 + <taskdef name="XFormGen" classname="org.netbeans.modules.workflow.project.anttasks.IDEXFormGenerationTask">
83.184 + <classpath refid="generate.jbi"/>
83.185 + </taskdef>
83.186 + </target>
83.187 +
83.188 + <target name="init">
83.189 +<!-- //B20050104 <xsl:attribute name="depends">pre-init,init-private,init-userdir,init-user,init-project,do-init,post-init,init-check,init-macrodef-javac,init-macrodef-nbjpda,init-macrodef-debug,init-taskdefs</xsl:attribute> -->
83.190 + <xsl:attribute name="depends">pre-init,init-private,init-userdir,init-user,init-project,do-init,post-init,init-check,init-taskdefs</xsl:attribute>
83.191 + </target>
83.192 +
83.193 + <xsl:comment>
83.194 + ===================
83.195 + COMPILATION SECTION
83.196 + ===================
83.197 + </xsl:comment>
83.198 +
83.199 + <xsl:call-template name="deps.target">
83.200 + <xsl:with-param name="targetname" select="'deps-jar'"/>
83.201 + <xsl:with-param name="type" select="'jar'"/>
83.202 + </xsl:call-template>
83.203 +
83.204 + <xsl:if test="/p:project/p:configuration/ejb:data/ejb:web-services/ejb:web-service|/p:project/p:configuration/ejb:data/ejb:web-service-clients/ejb:web-service-client">
83.205 + <target name="wscompile-init">
83.206 + <taskdef name="wscompile" classname="com.sun.xml.rpc.tools.ant.Wscompile">
83.207 + <classpath path="${{wscompile.classpath}}"/>
83.208 + </taskdef>
83.209 + <mkdir dir="${{build.classes.dir}}/META-INF/wsdl"/>
83.210 + <mkdir dir="${{build.generated.dir}}/wssrc"/>
83.211 + </target>
83.212 + </xsl:if>
83.213 +
83.214 + <xsl:for-each select="/p:project/p:configuration/ejb:data/ejb:web-services/ejb:web-service">
83.215 + <xsl:variable name="wsname">
83.216 + <xsl:value-of select="ejb:web-service-name"/>
83.217 + </xsl:variable>
83.218 +
83.219 + <target name="{$wsname}_wscompile" depends="wscompile-init">
83.220 + <wscompile
83.221 + server="true"
83.222 + fork="true"
83.223 + keep="true"
83.224 + base="${{build.generated.dir}}/wssrc"
83.225 + xPrintStackTrace="true"
83.226 + verbose="true"
83.227 + nonClassDir="${{build.classes.dir}}/META-INF/wsdl"
83.228 + classpath="${{wscompile.classpath}}:${{build.classes.dir}}"
83.229 + mapping="${{build.classes.dir}}/META-INF/wsdl/${{{$wsname}.mapping}}"
83.230 + config="${{src.dir}}/${{{$wsname}.config.name}}">
83.231 + <!-- HTTPProxy="${http.proxyHost}:${http.proxyPort}" -->
83.232 + </wscompile>
83.233 + </target>
83.234 + </xsl:for-each>
83.235 +
83.236 + <xsl:for-each select="/p:project/p:configuration/ejb:data/ejb:web-service-clients/ejb:web-service-client">
83.237 + <xsl:variable name="wsclientname">
83.238 + <xsl:value-of select="ejb:web-service-client-name"/>
83.239 + </xsl:variable>
83.240 +
83.241 + <target name="{$wsclientname}_client_wscompile" depends="wscompile-init">
83.242 + <copy file="${{web.docbase.dir}}/WEB-INF/wsdl/{$wsclientname}-config.xml"
83.243 + tofile="${{build.generated.dir}}/wssrc/wsdl/{$wsclientname}-config.xml" filtering="on">
83.244 + <filterset>
83.245 + <!-- replace token with reference to WSDL file in source tree, not build tree, since the
83.246 + the file probably has not have been copied to the build tree yet. -->
83.247 + <filter token="CONFIG_ABSOLUTE_PATH" value="${{basedir}}/${{web.docbase.dir}}/WEB-INF/wsdl"/>
83.248 + </filterset>
83.249 + </copy>
83.250 + <wscompile
83.251 + xPrintStackTrace="true" verbose="true"
83.252 + fork="true" keep="true" import="true" features="norpcstructures"
83.253 + base="${{build.classes.dir}}"
83.254 + sourceBase="${{build.generated.dir}}/wssrc"
83.255 + classpath="${{wscompile.classpath}}"
83.256 + mapping="${{build.web.dir}}/WEB-INF/wsdl/{$wsclientname}-mapping.xml"
83.257 + config="${{build.generated.dir}}/wssrc/wsdl/{$wsclientname}-config.xml">
83.258 + </wscompile>
83.259 + </target>
83.260 + </xsl:for-each>
83.261 +
83.262 + <target name="pre-pre-compile">
83.263 + <xsl:attribute name="depends">init,deps-jar</xsl:attribute>
83.264 + <mkdir dir="${{build.classes.dir}}"/>
83.265 + </target>
83.266 +
83.267 + <target name="pre-compile">
83.268 + <xsl:comment> Empty placeholder for easier customization. </xsl:comment>
83.269 + <xsl:comment> You can override this target in the ../build.xml file. </xsl:comment>
83.270 + </target>
83.271 +
83.272 + <target name="library-inclusion-in-archive" depends="compile">
83.273 + <xsl:for-each select="//ejb:included-library">
83.274 + <xsl:variable name="included.prop.name">
83.275 + <xsl:value-of select="."/>
83.276 + </xsl:variable>
83.277 + <unjar dest="${{build.classes.dir}}">
83.278 + <xsl:attribute name="src">${<xsl:value-of select="$included.prop.name"/>}</xsl:attribute>
83.279 + </unjar>
83.280 + </xsl:for-each>
83.281 + </target>
83.282 +
83.283 + <target name="library-inclusion-in-manifest" depends="compile">
83.284 + <xsl:for-each select="//ejb:included-library">
83.285 + <xsl:variable name="included.prop.name">
83.286 + <xsl:value-of select="."/>
83.287 + </xsl:variable>
83.288 + <xsl:variable name="base.prop.name">
83.289 + <xsl:value-of select="concat('included.lib.', $included.prop.name, '')"/>
83.290 + </xsl:variable>
83.291 + <basename>
83.292 + <xsl:attribute name="property"><xsl:value-of select="$base.prop.name"/></xsl:attribute>
83.293 + <xsl:attribute name="file">${<xsl:value-of select="$included.prop.name"/>}</xsl:attribute>
83.294 + </basename>
83.295 + <copy todir="${{build.classes.dir}}">
83.296 + <xsl:attribute name="file">${<xsl:value-of select="$included.prop.name"/>}</xsl:attribute>
83.297 + </copy>
83.298 + </xsl:for-each>
83.299 + <manifest file="${{build.classes.dir}}/META-INF/MANIFEST.MF" mode="update">
83.300 + <attribute>
83.301 + <xsl:attribute name="name">Class-Path</xsl:attribute>
83.302 + <xsl:attribute name="value">
83.303 + <xsl:for-each select="//ejb:included-library">
83.304 + <xsl:variable name="base.prop.name">
83.305 + <xsl:value-of select="concat('${included.lib.', ., '}')"/>
83.306 + </xsl:variable>
83.307 + <xsl:if test="position()>1">,</xsl:if>
83.308 + <xsl:value-of select="$base.prop.name"/>
83.309 + </xsl:for-each>
83.310 + </xsl:attribute>
83.311 + </attribute>
83.312 + </manifest>
83.313 + </target>
83.314 +
83.315 + <target name="do-compile">
83.316 + <xsl:attribute name="depends">init,deps-jar,pre-pre-compile,pre-compile</xsl:attribute>
83.317 + <xsl:if test="/p:project/p:configuration/ejb:data/ejb:web-services/ejb:web-service">
83.318 + <xsl:comment>For web services, refresh the Tie and SerializerRegistry classes</xsl:comment>
83.319 + <delete>
83.320 + <fileset dir="${{build.classes.dir}}" includes="**/*_Tie.* **/*_SerializerRegistry.*"/>
83.321 + </delete>
83.322 + </xsl:if>
83.323 + </target>
83.324 +
83.325 + <target name="post-compile">
83.326 + <xsl:if test="/p:project/p:configuration/ejb:data/ejb:web-services/ejb:web-service">
83.327 + <xsl:attribute name="depends">
83.328 + <xsl:for-each select="/p:project/p:configuration/ejb:data/ejb:web-services/ejb:web-service">
83.329 + <xsl:if test="position()!=1"><xsl:text>, </xsl:text></xsl:if>
83.330 + <xsl:variable name="wsname2">
83.331 + <xsl:value-of select="ejb:web-service-name"/>
83.332 + </xsl:variable>
83.333 + <xsl:value-of select="ejb:web-service-name"/><xsl:text>_wscompile</xsl:text>
83.334 + </xsl:for-each>
83.335 + </xsl:attribute>
83.336 + </xsl:if>
83.337 + <xsl:comment> Empty placeholder for easier customization. </xsl:comment>
83.338 + <xsl:comment> You can override this target in the ../build.xml file. </xsl:comment>
83.339 + </target>
83.340 +
83.341 + <target name="compile">
83.342 + <xsl:attribute name="depends">init,deps-jar,pre-pre-compile,pre-compile,do-compile,post-compile</xsl:attribute>
83.343 + <xsl:attribute name="description">Compile project.</xsl:attribute>
83.344 + </target>
83.345 +
83.346 + <target name="pre-compile-single">
83.347 + <xsl:comment> Empty placeholder for easier customization. </xsl:comment>
83.348 + <xsl:comment> You can override this target in the ../build.xml file. </xsl:comment>
83.349 + </target>
83.350 +
83.351 + <target name="do-compile-single">
83.352 + <xsl:attribute name="depends">init,deps-jar,pre-pre-compile</xsl:attribute>
83.353 + <fail unless="javac.includes">Must select some files in the IDE or set javac.includes</fail>
83.354 + <ejbproject:javac xmlns:ejbproject="http://www.netbeans.org/ns/j2ee-ejbjarproject/1">
83.355 + <customize>
83.356 + <include name="${{javac.includes}}"/>
83.357 + </customize>
83.358 + </ejbproject:javac>
83.359 + </target>
83.360 +
83.361 + <target name="post-compile-single">
83.362 + <xsl:comment> Empty placeholder for easier customization. </xsl:comment>
83.363 + <xsl:comment> You can override this target in the ../build.xml file. </xsl:comment>
83.364 + </target>
83.365 +
83.366 + <target name="compile-single">
83.367 + <xsl:attribute name="depends">init,deps-jar,pre-pre-compile,pre-compile-single,do-compile-single,post-compile-single</xsl:attribute>
83.368 + </target>
83.369 +
83.370 + <xsl:comment>
83.371 + ====================
83.372 + DIST BUILDING SECTION
83.373 + ====================
83.374 + </xsl:comment>
83.375 + <target name="generate-xform">
83.376 + <xsl:attribute name="depends">init</xsl:attribute>
83.377 + <XFormGen sourcedirectory="${{basedir}}/${{src.dir}}" builddirectory="${{basedir}}/${{build.dir}}" always="true"/>
83.378 + </target>
83.379 +
83.380 + <target name="pre-dist">
83.381 + <xsl:comment> Empty placeholder for easier customization. </xsl:comment>
83.382 + <xsl:comment> You can override this target in the ../build.xml file. </xsl:comment>
83.383 + <mkdir dir="${{build.dir}}"/>
83.384 + <mkdir dir="${{build.dir}}/META-INF"/>
83.385 + <copy file="${{netbeans.home}}/../soa1/ant/nblib/org-netbeans-modules-workflow-project.jar" tofile="${{build.dir}}/org-netbeans-modules-workflow-project.jar"/>
83.386 + <unzip dest="${{build.dir}}" src="${{netbeans.home}}/../soa1/modules/org-netbeans-modules-workflow-project.jar" overwrite="true">
83.387 + <patternset>
83.388 + <include name="**/TaskStaticTemplate.wsdl"/>
83.389 + <include name="**/TaskCommon.wsdl"/>
83.390 + </patternset>
83.391 + </unzip>
83.392 + <move file="${{build.dir}}/org/netbeans/modules/workflow/project/resources/TaskStaticTemplate.wsdl" tofile="${{basedir}}/${{build.dir}}/${{projectName}}_wf_client_temp.wsdl"/>
83.393 + <move file="${{build.dir}}/org/netbeans/modules/workflow/project/resources/TaskCommon.wsdl" tofile="${{basedir}}/${{build.dir}}/TaskCommon.wsdl"/>
83.394 + <XFormGen sourcedirectory="${{basedir}}/${{src.dir}}" builddirectory="${{basedir}}/${{build.dir}}" always="false"/>
83.395 +
83.396 + <copy todir="${{build.dir}}" preservelastmodified="true">
83.397 + <fileset includes="**/*.bpel,**/*.wsdl,**/*.xsd,**/*.wf,**/*.xhtml,**/*.xml" dir="${{src.dir}}"/>
83.398 + </copy>
83.399 + <delete file="${{build.dir}}/org-netbeans-modules-workflow-project.jar"/>
83.400 + <delete dir="${{build.dir}}/org" />
83.401 + <replace file="${{basedir}}/${{build.dir}}/${{projectName}}_wf_client_temp.wsdl" token="DEFINITON_TARGETNAMESPACE" value="http://jbi.com.sun/wfse/wsdl/${{projectName}}_wf_client"/>
83.402 + <WFGenClientWSDL sourcedirectory="${{basedir}}/${{src.dir}}" builddirectory="${{basedir}}/${{build.dir}}" clientwsdl="${{basedir}}/${{build.dir}}/${{projectName}}_wf_client_temp.wsdl" projectname="${{projectName}}" classpathRef="ant.task.classpath.models" taskFlowClasspath="generate.jbi"/>
83.403 + <delete file="${{basedir}}/${{build.dir}}/${{projectName}}_wf_client_temp.wsdl"/>
83.404 +
83.405 + <generate-asa-artifacts
83.406 + srcDirectoryLocation="${{basedir}}/${{src.dir}}"
83.407 + jbiDescriptorFileLocation="${{basedir}}/${{build.dir}}/META-INF/jbi.xml"
83.408 + projectName="${{projectName}}"/>
83.409 + </target>
83.410 +
83.411 + <target name="dist_se">
83.412 + <xsl:attribute name="depends">init,pre-dist</xsl:attribute>
83.413 + <jar compress="${{jar.compress}}" jarfile="${{build.dir}}/SEDeployment.jar">
83.414 + <fileset includes="**/*.xsl,**/*.wsdl,**/*.xsd,**/*.wf,**/*.xhtml,**/*.xml" dir="${{build.dir}}"/>
83.415 + <fileset dir="${{src.dir}}/">
83.416 + <include name="xsltmap.xml"/>
83.417 + </fileset>
83.418 + <fileset dir="${{build.dir}}">
83.419 + <include name="META-INF/jbi.xml" />
83.420 + </fileset>
83.421 + </jar>
83.422 + </target>
83.423 +
83.424 + <target name="do-dist">
83.425 + <xsl:attribute name="depends">init,pre-dist,dist_se</xsl:attribute>
83.426 + </target>
83.427 +
83.428 + <target name="post-dist">
83.429 + <xsl:comment> Empty placeholder for easier customization. </xsl:comment>
83.430 + <xsl:comment> You can override this target in the ../build.xml file. </xsl:comment>
83.431 + </target>
83.432 +
83.433 + <target name="dist">
83.434 + <xsl:attribute name="depends">init,pre-dist,do-dist,post-dist</xsl:attribute>
83.435 +<!--
83.436 + <xsl:attribute name="depends">init,compile,pre-dist,do-dist,post-dist,library-inclusion-in-manifest</xsl:attribute>
83.437 +-->
83.438 + <xsl:attribute name="description">Build distribution (JAR).</xsl:attribute>
83.439 + </target>
83.440 +
83.441 + <xsl:comment>
83.442 + =================
83.443 + EXECUTION SECTION
83.444 + =================
83.445 + </xsl:comment>
83.446 + <target name="run">
83.447 + <xsl:attribute name="depends">run-deploy</xsl:attribute>
83.448 + <xsl:attribute name="description">Deploy to server.</xsl:attribute>
83.449 + </target>
83.450 +
83.451 + <target name="init-deploy">
83.452 + <property name="include.jar.manifest" value=""/>
83.453 + </target>
83.454 +
83.455 + <target name="run-deploy">
83.456 + <xsl:attribute name="depends">init,init-deploy,compile,library-inclusion-in-archive</xsl:attribute>
83.457 + <!-- No more deploy action in subprojects
83.458 +
83.459 + <generate-deployment-path
83.460 + jarFileClasspath="${{module.install.dir}}/com-sun-jbi-ui-devtool-projects-xsltpro.jar"
83.461 + privatePropertiesFileLocation="${{basedir}}/nbproject/private/private.properties"
83.462 + netBeansUserPropertyValue="${{netbeans.user}}">
83.463 + </generate-deployment-path>
83.464 +
83.465 + <exec dir="${{basedir}}" executable="${{com.sun.jbi.ui.devtool.appserver.instance.location}}/bin/asant.bat">
83.466 + <arg value="-f"/>
83.467 + <arg value="${{com.sun.jbi.ui.devtool.appserver.instance.location}}/bin/jbi_admin.xml"/>
83.468 + <arg value="-Djbi.host=${{com.sun.jbi.ui.devtool.appserver.instance.hostName}}" />
83.469 + <arg value="-Djbi.port=${{com.sun.jbi.management.JmxPort}}" />
83.470 + <arg value="-Djbi.deploymentId=${{com.sun.jbi.ui.devtool.jbi.guid.assembly-unit}}" />
83.471 + <arg value="undeploy"/>
83.472 + </exec>
83.473 +
83.474 +
83.475 + <exec dir="${{basedir}}" executable="${{com.sun.jbi.ui.devtool.appserver.instance.location}}/bin/asant.bat">
83.476 + <arg value="-f"/>
83.477 + <arg value="${{com.sun.jbi.ui.devtool.appserver.instance.location}}/bin/jbi_admin.xml"/>
83.478 + <arg value="-Djbi.host=${{com.sun.jbi.ui.devtool.appserver.instance.hostName}}" />
83.479 + <arg value="-Djbi.port=${{com.sun.jbi.management.JmxPort}}" />
83.480 + <arg value="-Djbi.deploymentJar=${{basedir}}/${{dist.jar}}" />
83.481 + <arg value="deploy"/>
83.482 + </exec>
83.483 + -->
83.484 + </target>
83.485 +
83.486 + <xsl:comment>
83.487 + =================
83.488 + DEBUGGING SECTION
83.489 + =================
83.490 + </xsl:comment>
83.491 + <target name="debug">
83.492 + <xsl:attribute name="description">Debug project in IDE.</xsl:attribute>
83.493 + <xsl:attribute name ="depends">init,compile</xsl:attribute>
83.494 + <xsl:attribute name="if">netbeans.home</xsl:attribute>
83.495 + <nbdeploy debugmode="true" clientUrlPart="${{client.urlPart}}"/>
83.496 + <nbjpdaconnect name="${{name}}" host="${{jpda.host}}" address="${{jpda.address}}" transport="${{jpda.transport}}">
83.497 + <classpath>
83.498 + <path path="${{debug.classpath}}"/>
83.499 + </classpath>
83.500 + <sourcepath>
83.501 + <path path="${{web.docbase.dir}}"/>
83.502 + </sourcepath>
83.503 + <xsl:if test="/p:project/p:configuration/ejb:data/ejb:explicit-platform">
83.504 + <bootclasspath>
83.505 + <path path="${{platform.bootcp}}"/>
83.506 + </bootclasspath>
83.507 + </xsl:if>
83.508 + </nbjpdaconnect>
83.509 + </target>
83.510 +
83.511 + <target name="pre-debug-fix">
83.512 + <xsl:attribute name="depends">init</xsl:attribute>
83.513 + <fail unless="fix.includes">Must set fix.includes</fail>
83.514 + <property name="javac.includes" value="${{fix.includes}}.java"/>
83.515 + </target>
83.516 +
83.517 + <target name="do-debug-fix">
83.518 + <xsl:attribute name="if">netbeans.home</xsl:attribute>
83.519 + <xsl:attribute name="depends">init,pre-debug-fix,compile-single</xsl:attribute>
83.520 + <j2seproject:nbjpdareload xmlns:j2seproject="http://www.netbeans.org/ns/j2se-project/1"/>
83.521 + </target>
83.522 +
83.523 + <target name="debug-fix">
83.524 + <xsl:attribute name="if">netbeans.home</xsl:attribute>
83.525 + <xsl:attribute name="depends">init,pre-debug-fix,do-debug-fix</xsl:attribute>
83.526 + </target>
83.527 +
83.528 + <xsl:comment>
83.529 + ===============
83.530 + JAVADOC SECTION
83.531 + ===============
83.532 + </xsl:comment>
83.533 +
83.534 + <target name="javadoc-build">
83.535 + <xsl:attribute name="depends">init</xsl:attribute>
83.536 + <mkdir dir="${{dist.javadoc.dir}}"/>
83.537 + <!-- XXX do an up-to-date check first -->
83.538 + <javadoc destdir="${{dist.javadoc.dir}}" source="${{javac.source}}"
83.539 + notree="${{javadoc.notree}}"
83.540 + use="${{javadoc.use}}"
83.541 + nonavbar="${{javadoc.nonavbar}}"
83.542 + noindex="${{javadoc.noindex}}"
83.543 + splitindex="${{javadoc.splitindex}}"
83.544 + author="${{javadoc.author}}"
83.545 + version="${{javadoc.version}}"
83.546 + windowtitle="${{javadoc.windowtitle}}"
83.547 + private="${{javadoc.private}}" >
83.548 + <!-- encoding="${{javadoc.encoding}}" -->
83.549 + <classpath>
83.550 + <path path="${{javac.classpath}}"/>
83.551 + </classpath>
83.552 + <sourcepath>
83.553 + <pathelement location="${{src.dir}}"/>
83.554 + </sourcepath>
83.555 + <xsl:if test="/p:project/p:configuration/ejb:data/ejb:explicit-platform">
83.556 + <bootclasspath>
83.557 + <path path="${{platform.bootcp}}"/>
83.558 + </bootclasspath>
83.559 + </xsl:if>
83.560 + <fileset dir="${{src.dir}}"/>
83.561 + </javadoc>
83.562 + </target>
83.563 +
83.564 + <target name="javadoc-browse">
83.565 + <xsl:attribute name="if">netbeans.home</xsl:attribute>
83.566 + <xsl:attribute name="unless">no.javadoc.preview</xsl:attribute>
83.567 + <xsl:attribute name="depends">init,javadoc-build</xsl:attribute>
83.568 + <nbbrowse file="${{dist.javadoc.dir}}/index.html"/>
83.569 + </target>
83.570 +
83.571 + <target name="javadoc">
83.572 + <xsl:attribute name="depends">init,javadoc-build,javadoc-browse</xsl:attribute>
83.573 + <xsl:attribute name="description">Build Javadoc.</xsl:attribute>
83.574 + </target>
83.575 +
83.576 + <xsl:comment>
83.577 + ===============
83.578 + CLEANUP SECTION
83.579 + ===============
83.580 + </xsl:comment>
83.581 +
83.582 + <xsl:call-template name="deps.target">
83.583 + <xsl:with-param name="targetname" select="'deps-clean'"/>
83.584 + </xsl:call-template>
83.585 +
83.586 + <target name="do-clean">
83.587 + <xsl:attribute name="depends">init</xsl:attribute>
83.588 + <delete dir="${{build.dir}}"/>
83.589 + <delete dir="${{dist.dir}}"/>
83.590 + </target>
83.591 +
83.592 + <target name="post-clean">
83.593 + <xsl:comment> Empty placeholder for easier customization. </xsl:comment>
83.594 + <xsl:comment> You can override this target in the ../build.xml file. </xsl:comment>
83.595 + </target>
83.596 +
83.597 + <target name="clean">
83.598 + <xsl:attribute name="depends">init,deps-clean,do-clean,post-clean</xsl:attribute>
83.599 + <xsl:attribute name="description">Clean build products.</xsl:attribute>
83.600 + </target>
83.601 + </project>
83.602 +
83.603 +<!-- TBD items:
83.604 +
83.605 +Could pass <propertyset> to run, debug, etc. under Ant 1.6,
83.606 +optionally, by doing e.g.
83.607 +
83.608 + <propertyset>
83.609 + <propertyref prefix="sysprop."/>
83.610 + <mapper type="glob" from="sysprop.*" to="*"/>
83.611 + </propertyset>
83.612 +
83.613 +Now user can add to e.g. project.properties e.g.:
83.614 + sysprop.org.netbeans.modules.javahelp=0
83.615 +to simulate
83.616 + -Dorg.netbeans.modules.javahelp=0
83.617 +
83.618 +-->
83.619 +
83.620 + </xsl:template>
83.621 +
83.622 + <!---
83.623 + Generic template to build subdependencies of a certain type.
83.624 + Feel free to copy into other modules.
83.625 + @param targetname required name of target to generate
83.626 + @param type artifact-type from project.xml to filter on; optional, if not specified, uses
83.627 + all references, and looks for clean targets rather than build targets
83.628 + @return an Ant target which builds (or cleans) all known subprojects
83.629 + -->
83.630 + <xsl:template name="deps.target">
83.631 + <xsl:param name="targetname"/>
83.632 + <xsl:param name="type"/>
83.633 + <target name="{$targetname}">
83.634 + <xsl:attribute name="depends">init</xsl:attribute>
83.635 + <xsl:attribute name="unless">${no.dependencies}</xsl:attribute>
83.636 + <xsl:variable name="references" select="/p:project/p:configuration/projdeps:references"/>
83.637 + <xsl:for-each select="$references/projdeps:reference[not($type) or projdeps:artifact-type = $type]">
83.638 + <xsl:variable name="subproj" select="projdeps:foreign-project"/>
83.639 + <xsl:variable name="subtarget">
83.640 + <xsl:choose>
83.641 + <xsl:when test="$type">
83.642 + <xsl:value-of select="projdeps:target"/>
83.643 + </xsl:when>
83.644 + <xsl:otherwise>
83.645 + <xsl:value-of select="projdeps:clean-target"/>
83.646 + </xsl:otherwise>
83.647 + </xsl:choose>
83.648 + </xsl:variable>
83.649 + <xsl:variable name="script" select="projdeps:script"/>
83.650 + <xsl:variable name="scriptdir" select="substring-before($script, '/')"/>
83.651 + <xsl:variable name="scriptdirslash">
83.652 + <xsl:choose>
83.653 + <xsl:when test="$scriptdir = ''"/>
83.654 + <xsl:otherwise>
83.655 + <xsl:text>/</xsl:text>
83.656 + <xsl:value-of select="$scriptdir"/>
83.657 + </xsl:otherwise>
83.658 + </xsl:choose>
83.659 + </xsl:variable>
83.660 + <xsl:variable name="scriptfileorblank" select="substring-after($script, '/')"/>
83.661 + <xsl:variable name="scriptfile">
83.662 + <xsl:choose>
83.663 + <xsl:when test="$scriptfileorblank != ''">
83.664 + <xsl:value-of select="$scriptfileorblank"/>
83.665 + </xsl:when>
83.666 + <xsl:otherwise>
83.667 + <xsl:value-of select="$script"/>
83.668 + </xsl:otherwise>
83.669 + </xsl:choose>
83.670 + </xsl:variable>
83.671 + <ant target="{$subtarget}" inheritall="false">
83.672 + <!-- XXX #43624: cannot use inline attr on JDK 1.5 -->
83.673 + <xsl:attribute name="dir">${project.<xsl:value-of select="$subproj"/>}<xsl:value-of select="$scriptdirslash"/></xsl:attribute>
83.674 + <xsl:if test="$scriptfile != 'build.xml'">
83.675 + <xsl:attribute name="antfile">
83.676 + <xsl:value-of select="$scriptfile"/>
83.677 + </xsl:attribute>
83.678 + </xsl:if>
83.679 + </ant>
83.680 + </xsl:for-each>
83.681 + </target>
83.682 + </xsl:template>
83.683 +
83.684 +</xsl:stylesheet>
84.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
84.2 +++ b/enterprise/openesbaddons/workflow/project/src/org/netbeans/modules/workflow/project/resources/build.xsl Thu Apr 26 02:33:27 2007 +0000
84.3 @@ -0,0 +1,97 @@
84.4 +<?xml version="1.0" encoding="UTF-8"?>
84.5 +<!--
84.6 + Sun Public License Notice
84.7 +
84.8 +The contents of this file are subject to the Sun Public License
84.9 +Version 1.0 (the "License"). You may not use this file except in
84.10 +compliance with the License. A copy of the License is available at
84.11 +http://www.sun.com/
84.12 +
84.13 +The Original Code is NetBeans. The Initial Developer of the Original
84.14 +Code is Sun Microsystems, Inc. Portions Copyright 1997-2004 Sun
84.15 +Microsystems, Inc. All Rights Reserved.
84.16 +-->
84.17 +<xsl:stylesheet version="1.0"
84.18 + xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
84.19 + xmlns:project="http://www.netbeans.org/ns/project/1"
84.20 + xmlns:web="http://www.netbeans.org/ns/j2ee-ejbjarproject/1"
84.21 + xmlns:xalan="http://xml.apache.org/xslt"
84.22 + exclude-result-prefixes="xalan project">
84.23 + <xsl:output method="xml" indent="yes" encoding="UTF-8" xalan:indent-amount="4"/>
84.24 + <xsl:template match="/">
84.25 +
84.26 + <!-- Annoyingly, the JAXP impl in JRE 1.4.2 seems to randomly reorder attrs. -->
84.27 + <!-- (I.e. the DOM tree gets them in an unspecified order?) -->
84.28 + <!-- As a workaround, use xsl:attribute for all but the first attr. -->
84.29 + <!-- This seems to produce them in the order you want. -->
84.30 + <!-- Tedious, but appears to do the job. -->
84.31 + <!-- Important for build.xml, which is very visible; not so much for build-impl.xml. -->
84.32 +
84.33 + <xsl:comment> You may freely edit this file. See commented blocks below for </xsl:comment>
84.34 + <xsl:comment> some examples of how to customize the build. </xsl:comment>
84.35 + <xsl:comment> (If you delete it and reopen the project it will be recreated.) </xsl:comment>
84.36 +
84.37 + <xsl:variable name="name" select="/project:project/project:configuration/web:data/web:name"/>
84.38 + <project name="{$name}">
84.39 + <xsl:attribute name="default">default</xsl:attribute>
84.40 + <xsl:attribute name="basedir">.</xsl:attribute>
84.41 + <description>Builds, tests, and runs the project <xsl:value-of select="$name"/>.</description>
84.42 + <import file="nbproject/build-impl.xml"/>
84.43 +
84.44 + <xsl:comment><![CDATA[
84.45 +
84.46 + There exist several targets which are by default empty and which can be
84.47 + used for execution of your tasks. These targets are usually executed
84.48 + before and after some main targets. They are:
84.49 +
84.50 + pre-init: called before initialization of project properties
84.51 + post-init: called after initialization of project properties
84.52 + pre-compile: called before javac compilation
84.53 + post-compile: called after javac compilation
84.54 + pre-compile-single: called before javac compilation of single file
84.55 + post-compile-single: called after javac compilation of single file
84.56 + pre-dist: called before jar building
84.57 + post-dist: called after jar building
84.58 + post-clean: called after cleaning build products
84.59 +
84.60 + Example of pluging an obfuscator after the compilation could look like
84.61 +
84.62 + <target name="post-compile">
84.63 + <obfuscate>
84.64 + <fileset dir="${build.classes.dir}"/>
84.65 + </obfuscate>
84.66 + </target>
84.67 +
84.68 + For list of available properties check the imported
84.69 + nbproject/build-impl.xml file.
84.70 +
84.71 +
84.72 + Other way how to customize the build is by overriding existing main targets.
84.73 + The target of interest are:
84.74 +
84.75 + init-macrodef-javac: defines macro for javac compilation
84.76 + init-macrodef-debug: defines macro for class debugging
84.77 + do-dist: jar archive building
84.78 + run: execution of project
84.79 + javadoc-build: javadoc generation
84.80 +
84.81 + Example of overriding the target for project execution could look like
84.82 +
84.83 + <target name="run" depends="<PROJNAME>-impl.jar">
84.84 + <exec dir="bin" executable="launcher.exe">
84.85 + <arg file="${dist.jar}"/>
84.86 + </exec>
84.87 + </target>
84.88 +
84.89 + Notice that overridden target depends on jar target and not only on
84.90 + compile target as regular run target does. Again, for list of available
84.91 + properties which you can use check the target you are overriding in
84.92 + nbproject/build-impl.xml file.
84.93 +
84.94 + ]]></xsl:comment>
84.95 +
84.96 + </project>
84.97 +
84.98 + </xsl:template>
84.99 +
84.100 +</xsl:stylesheet>
85.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
85.2 +++ b/enterprise/openesbaddons/workflow/project/src/org/netbeans/modules/workflow/project/ui/WorkflowproLogicalViewProvider.java Thu Apr 26 02:33:27 2007 +0000
85.3 @@ -0,0 +1,237 @@
85.4 +/*
85.5 + * Sun Public License Notice
85.6 + *
85.7 + * The contents of this file are subject to the Sun Public License
85.8 + * Version 1.0 (the "License"). You may not use this file except in
85.9 + * compliance with the License. A copy of the License is available at
85.10 + * http://www.sun.com/
85.11 + *
85.12 + * The Original Code is NetBeans. The Initial Developer of the Original
85.13 + * Code is Sun Microsystems, Inc. Portions Copyright 1997-2004 Sun
85.14 + * Microsystems, Inc. All Rights Reserved.
85.15 + */
85.16 +
85.17 +package org.netbeans.modules.workflow.project.ui;
85.18 +
85.19 +import java.awt.event.ActionEvent;
85.20 +import java.beans.PropertyChangeEvent;
85.21 +import java.beans.PropertyChangeListener;
85.22 +import java.util.ResourceBundle;
85.23 +
85.24 +import javax.swing.AbstractAction;
85.25 +import javax.swing.Action;
85.26 +
85.27 +import org.openide.nodes.*;
85.28 +import org.openide.util.*;
85.29 +import org.openide.util.actions.SystemAction;
85.30 +
85.31 +import org.netbeans.api.project.Project;
85.32 +import org.netbeans.api.project.ProjectUtils;
85.33 +import org.netbeans.spi.project.ui.support.CommonProjectActions;
85.34 +import org.netbeans.spi.project.ActionProvider;
85.35 +import org.netbeans.spi.project.SubprojectProvider;
85.36 +import org.netbeans.spi.project.support.ant.AntProjectHelper;
85.37 +import org.netbeans.spi.project.support.ant.PropertyEvaluator;
85.38 +import org.netbeans.spi.project.support.ant.ReferenceHelper;
85.39 +import org.netbeans.spi.project.ui.LogicalViewProvider;
85.40 +import org.netbeans.spi.project.ui.support.ProjectSensitiveActions;
85.41 +import org.netbeans.spi.java.project.support.ui.BrokenReferencesSupport;
85.42 +import org.netbeans.modules.compapp.projects.base.ui.customizer.IcanproProjectProperties;
85.43 +import org.netbeans.modules.compapp.projects.base.ui.IcanproLogicalViewProvider;
85.44 +import org.netbeans.modules.compapp.projects.base.IcanproConstants;
85.45 +import org.openide.loaders.DataFolder;
85.46 +import org.openide.util.lookup.Lookups;
85.47 +
85.48 +/**
85.49 + * Support for creating logical views.
85.50 + * @author Petr Hrebejk
85.51 + */
85.52 +public class WorkflowproLogicalViewProvider implements LogicalViewProvider {
85.53 +
85.54 + private final Project project;
85.55 + private final AntProjectHelper helper;
85.56 + private final PropertyEvaluator evaluator;
85.57 + private final SubprojectProvider spp;
85.58 + private final ReferenceHelper resolver;
85.59 +
85.60 +
85.61 + public WorkflowproLogicalViewProvider(Project project, AntProjectHelper helper, PropertyEvaluator evaluator, SubprojectProvider spp, ReferenceHelper resolver) {
85.62 + this.project = project;
85.63 + assert project != null;
85.64 + this.helper = helper;
85.65 + assert helper != null;
85.66 + this.evaluator = evaluator;
85.67 + assert evaluator != null;
85.68 + this.spp = spp;
85.69 + assert spp != null;
85.70 + this.resolver = resolver;
85.71 + }
85.72 +
85.73 + public Node createLogicalView() {
85.74 + return new DtelLogicalViewRootNode();
85.75 + }
85.76 +
85.77 + public Node findPath( Node root, Object target ) {
85.78 + // XXX implement
85.79 + return null;
85.80 + }
85.81 +
85.82 + private static Lookup createLookup( Project project ) {
85.83 + DataFolder rootFolder = DataFolder.findFolder( project.getProjectDirectory() );
85.84 + // XXX Remove root folder after FindAction rewrite
85.85 + return Lookups.fixed( new Object[] { project, rootFolder } );
85.86 + }
85.87 +
85.88 + // Private innerclasses ----------------------------------------------------
85.89 +
85.90 + private static final String[] BREAKABLE_PROPERTIES = new String[] {
85.91 + IcanproProjectProperties.JAVAC_CLASSPATH,
85.92 + IcanproProjectProperties.DEBUG_CLASSPATH,
85.93 + IcanproProjectProperties.SRC_DIR,
85.94 + };
85.95 +
85.96 + public static boolean hasBrokenLinks(AntProjectHelper helper, ReferenceHelper resolver) {
85.97 + return BrokenReferencesSupport.isBroken(helper, resolver, BREAKABLE_PROPERTIES,
85.98 + new String[] {IcanproProjectProperties.JAVA_PLATFORM});
85.99 + }
85.100 +
85.101 + /** Filter node containin additional features for the J2SE physical
85.102 + */
85.103 + private final class DtelLogicalViewRootNode extends AbstractNode {
85.104 +
85.105 + private Action brokenLinksAction;
85.106 + private boolean broken;
85.107 +
85.108 +
85.109 + public DtelLogicalViewRootNode() {
85.110 + super( new WorkflowproViews.LogicalViewChildren( helper, evaluator, project ), createLookup( project ) );
85.111 + setIconBaseWithExtension( "org/netbeans/modules/workflow/project/ui/resources/workflowproProjectIcon.gif" ); // NOI18N
85.112 + setName( ProjectUtils.getInformation( project ).getDisplayName() );
85.113 + if (hasBrokenLinks(helper, resolver)) {
85.114 + broken = true;
85.115 + brokenLinksAction = new BrokenLinksAction();
85.116 + }
85.117 + }
85.118 +
85.119 + public Action[] getActions( boolean context ) {
85.120 + if ( context )
85.121 + return super.getActions( true );
85.122 + else
85.123 + return getAdditionalActions();
85.124 + }
85.125 +
85.126 + public boolean canRename() {
85.127 + return false;
85.128 + }
85.129 +
85.130 + // Private methods -------------------------------------------------
85.131 +
85.132 + private Action[] getAdditionalActions() {
85.133 +
85.134 + ResourceBundle bundle = NbBundle.getBundle(IcanproLogicalViewProvider.class);
85.135 +
85.136 + return new Action[] {
85.137 + // disable new action at the top...
85.138 + // CommonProjectActions.newFileAction(),
85.139 + // null,
85.140 + ProjectSensitiveActions.projectCommandAction( ActionProvider.COMMAND_BUILD, bundle.getString( "LBL_BuildAction_Name" ), null ), // NOI18N
85.141 + ProjectSensitiveActions.projectCommandAction( ActionProvider.COMMAND_REBUILD, bundle.getString( "LBL_RebuildAction_Name" ), null ), // NOI18N
85.142 + ProjectSensitiveActions.projectCommandAction( ActionProvider.COMMAND_CLEAN, bundle.getString( "LBL_CleanAction_Name" ), null ), // NOI18N
85.143 + null,
85.144 + ProjectSensitiveActions.projectCommandAction( IcanproConstants.COMMAND_REDEPLOY, bundle.getString( "LBL_RedeployAction_Name" ), null ), // NOI18N
85.145 + ProjectSensitiveActions.projectCommandAction( IcanproConstants.COMMAND_DEPLOY, bundle.getString( "LBL_DeployAction_Name" ), null ), // NOI18N
85.146 + null,
85.147 + CommonProjectActions.setAsMainProjectAction(),
85.148 + CommonProjectActions.openSubprojectsAction(),
85.149 + CommonProjectActions.closeProjectAction(),
85.150 + null,
85.151 + SystemAction.get( org.openide.actions.FindAction.class ),
85.152 + null,
85.153 + SystemAction.get(org.openide.actions.OpenLocalExplorerAction.class),
85.154 + null,
85.155 + brokenLinksAction,
85.156 + CommonProjectActions.customizeProjectAction(),
85.157 + };
85.158 + }
85.159 +
85.160 + /** This action is created only when project has broken references.
85.161 + * Once these are resolved the action is disabled.
85.162 + */
85.163 + private class BrokenLinksAction extends AbstractAction implements PropertyChangeListener {
85.164 +
85.165 + public BrokenLinksAction() {
85.166 + evaluator.addPropertyChangeListener(this);
85.167 + putValue(Action.NAME, NbBundle.getMessage(IcanproLogicalViewProvider.class, "LBL_Fix_Broken_Links_Action"));
85.168 + }
85.169 +
85.170 + public void actionPerformed(ActionEvent e) {
85.171 + BrokenReferencesSupport.showCustomizer(helper, resolver, BREAKABLE_PROPERTIES, new String[]{IcanproProjectProperties.JAVA_PLATFORM});
85.172 + if (!hasBrokenLinks(helper, resolver)) {
85.173 + disable();
85.174 + }
85.175 + }
85.176 +
85.177 + public void propertyChange(PropertyChangeEvent evt) {
85.178 + if (!broken) {
85.179 + disable();
85.180 + return;
85.181 + }
85.182 + broken = hasBrokenLinks(helper, resolver);
85.183 + if (!broken) {
85.184 + disable();
85.185 + }
85.186 + }
85.187 +
85.188 + private void disable() {
85.189 + broken = false;
85.190 + setEnabled(false);
85.191 + evaluator.removePropertyChangeListener(this);
85.192 + fireIconChange();
85.193 + fireOpenedIconChange();
85.194 + }
85.195 +
85.196 + }
85.197 +
85.198 + }
85.199 +
85.200 + /** Factory for project actions.<BR>
85.201 + * XXX This class is a candidate for move to org.netbeans.spi.project.ui.support
85.202 + */
85.203 + public static class Actions {
85.204 +
85.205 + private Actions() {} // This is a factory
85.206 +
85.207 + public static Action createAction( String key, String name, boolean global ) {
85.208 + return new ActionImpl( key, name, global ? Utilities.actionsGlobalContext() : null );
85.209 + }
85.210 +
85.211 + private static class ActionImpl extends AbstractAction implements ContextAwareAction {
85.212 +
85.213 + Lookup context;
85.214 + String name;
85.215 + String command;
85.216 +
85.217 + public ActionImpl( String command, String name, Lookup context ) {
85.218 + super( name );
85.219 + this.context = context;
85.220 + this.command = command;
85.221 + this.name = name;
85.222 + }
85.223 +
85.224 + public void actionPerformed( ActionEvent e ) {
85.225 +
85.226 + Project project = (Project)context.lookup( Project.class );
85.227 + ActionProvider ap = (ActionProvider)project.getLookup().lookup( ActionProvider.class);
85.228 +
85.229 + ap.invokeAction( command, context );
85.230 +
85.231 + }
85.232 +
85.233 + public Action createContextAwareInstance( Lookup lookup ) {
85.234 + return new ActionImpl( command, name, lookup );
85.235 + }
85.236 + }
85.237 +
85.238 + }
85.239 +
85.240 +}
86.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
86.2 +++ b/enterprise/openesbaddons/workflow/project/src/org/netbeans/modules/workflow/project/ui/WorkflowproViews.java Thu Apr 26 02:33:27 2007 +0000
86.3 @@ -0,0 +1,225 @@
86.4 +/*
86.5 + * Sun Public License Notice
86.6 + *
86.7 + * The contents of this file are subject to the Sun Public License
86.8 + * Version 1.0 (the "License"). You may not use this file except in
86.9 + * compliance with the License. A copy of the License is available at
86.10 + * http://www.sun.com/
86.11 + *
86.12 + * The Original Code is NetBeans. The Initial Developer of the Original
86.13 + * Code is Sun Microsystems, Inc. Portions Copyright 1997-2004 Sun
86.14 + * Microsystems, Inc. All Rights Reserved.
86.15 + */
86.16 +
86.17 +package org.netbeans.modules.workflow.project.ui;
86.18 +
86.19 +import java.awt.Image;
86.20 +import java.util.ArrayList;
86.21 +import java.util.Collections;
86.22 +import java.util.List;
86.23 +
86.24 +import org.netbeans.api.java.project.JavaProjectConstants;
86.25 +import org.netbeans.api.project.FileOwnerQuery;
86.26 +import org.netbeans.api.project.Project;
86.27 +import org.netbeans.api.project.ProjectUtils;
86.28 +import org.netbeans.api.project.SourceGroup;
86.29 +
86.30 +import org.openide.filesystems.FileObject;
86.31 +import org.openide.loaders.DataFolder;
86.32 +import org.openide.nodes.Children;
86.33 +import org.openide.nodes.FilterNode;
86.34 +import org.openide.nodes.Node;
86.35 +import org.openide.util.NbBundle;
86.36 +import org.openide.util.Utilities;
86.37 +
86.38 +import org.netbeans.spi.java.project.support.ui.PackageView;
86.39 +import org.netbeans.spi.project.support.ant.AntProjectHelper;
86.40 +import org.netbeans.spi.project.support.ant.PropertyEvaluator;
86.41 +
86.42 +import org.netbeans.modules.compapp.projects.base.ui.customizer.IcanproProjectProperties;
86.43 +import org.netbeans.modules.compapp.projects.base.ui.IcanproLogicalViewProvider;
86.44 +// import org.netbeans.modules.websvc.api.webservices.WebServicesView;
86.45 +import org.openide.filesystems.FileChangeListener;
86.46 +
86.47 +class WorkflowproViews {
86.48 +
86.49 + private WorkflowproViews() {
86.50 + }
86.51 +
86.52 + static final class LogicalViewChildren extends Children.Keys implements FileChangeListener {
86.53 +
86.54 + private static final String KEY_SOURCE_DIR = "srcDir"; // NOI18N
86.55 + private static final String KEY_DOC_BASE = "docBase"; //NOI18N
86.56 + private static final String KEY_EJBS = "ejbKey"; //NOI18N
86.57 + private static final String WEBSERVICES_DIR = "webservicesDir"; // NOI18N
86.58 + private static final String KEY_SETUP_DIR = "setupDir"; //NOI18N
86.59 +
86.60 + private AntProjectHelper helper;
86.61 + private final PropertyEvaluator evaluator;
86.62 + private FileObject projectDir;
86.63 + private Project project;
86.64 +
86.65 + public LogicalViewChildren (AntProjectHelper helper, PropertyEvaluator evaluator, Project project) {
86.66 + assert helper != null;
86.67 + this.helper = helper;
86.68 + projectDir = helper.getProjectDirectory();
86.69 + this.evaluator = evaluator;
86.70 + this.project = project;
86.71 + }
86.72 +
86.73 + protected void addNotify() {
86.74 + super.addNotify();
86.75 + projectDir.addFileChangeListener(this);
86.76 + createNodes();
86.77 + }
86.78 +
86.79 + private void createNodes() {
86.80 + List l = new ArrayList();
86.81 + /*
86.82 + l.add(KEY_EJBS);
86.83 + */
86.84 +
86.85 + DataFolder docBaseDir = getFolder(IcanproProjectProperties.META_INF);
86.86 + if (docBaseDir != null) {
86.87 + /*
86.88 + l.add(KEY_DOC_BASE);
86.89 + */
86.90 + }
86.91 +
86.92 + DataFolder srcDir = getFolder(IcanproProjectProperties.SRC_DIR);
86.93 + if (srcDir != null) {
86.94 + l.add(KEY_SOURCE_DIR);
86.95 + }
86.96 +
86.97 + FileObject setupFolder = getSetupFolder();
86.98 + if (setupFolder != null && setupFolder.isFolder()) {
86.99 + l.add(KEY_SETUP_DIR);
86.100 + }
86.101 +/*
86.102 + l.add(WEBSERVICES_DIR);
86.103 +*/
86.104 + setKeys(l);
86.105 + }
86.106 +
86.107 + private FileObject getSetupFolder() {
86.108 + return projectDir.getFileObject("setup"); //NOI18N
86.109 + }
86.110 +
86.111 + protected void removeNotify() {
86.112 + setKeys(Collections.EMPTY_SET);
86.113 + projectDir.removeFileChangeListener(this);
86.114 + super.removeNotify();
86.115 + }
86.116 +
86.117 + protected Node[] createNodes(Object key) {
86.118 + Node n = null;
86.119 + if (key == KEY_SOURCE_DIR) {
86.120 + FileObject srcRoot = helper.resolveFileObject(evaluator.getProperty (IcanproProjectProperties.SRC_DIR));
86.121 + Project p = FileOwnerQuery.getOwner (srcRoot);
86.122 + SourceGroup sgs [] = ProjectUtils.getSources (p).getSourceGroups (JavaProjectConstants.SOURCES_TYPE_JAVA);
86.123 + for (int i = 0; i < sgs.length; i++) {
86.124 + if (sgs [i].contains (srcRoot)) {
86.125 + n = PackageView.createPackageView (sgs [i]);
86.126 + break;
86.127 + }
86.128 + }
86.129 + /*
86.130 + } else if (key == KEY_DOC_BASE) {
86.131 + n = new DocBaseNode (getFolder(IcanproProjectProperties.META_INF).getNodeDelegate());
86.132 + } else if (key == KEY_EJBS) {
86.133 + FileObject srcRoot = helper.resolveFileObject(evaluator.getProperty (IcanproProjectProperties.SRC_DIR));
86.134 + Project project = FileOwnerQuery.getOwner (srcRoot);
86.135 + DDProvider provider = DDProvider.getDefault();
86.136 + EjbJarImplementation jp = (EjbJarImplementation) project.getLookup().lookup(EjbJarImplementation.class);
86.137 + org.netbeans.modules.j2ee.dd.api.ejb.EjbJar ejbJar = null;
86.138 + try {
86.139 + ejbJar = provider.getDDRoot(jp.getDeploymentDescriptor());
86.140 + } catch (IOException ioe) {
86.141 + ErrorManager.getDefault().notify(ioe);
86.142 + }
86.143 + ClassPathProvider cpp = (ClassPathProvider)
86.144 + project.getLookup().lookup(ClassPathProvider.class);
86.145 + assert cpp != null;
86.146 + ClassPath classPath = cpp.findClassPath(srcRoot, ClassPath.SOURCE);
86.147 + n = new EjbContainerNode(ejbJar, classPath);
86.148 + //Node nws = new WebServicesNode(ejbJar, classPath);
86.149 + return n == null ? new Node[0] : new Node[] {n};
86.150 + } else if (key == WEBSERVICES_DIR){
86.151 + FileObject srcRoot = helper.resolveFileObject(evaluator.getProperty (IcanproProjectProperties.SRC_DIR));
86.152 + WebServicesView webServicesView = WebServicesView.getWebServicesView(srcRoot);
86.153 + if(webServicesView != null)
86.154 + {
86.155 + n = webServicesView.createWebServicesView(srcRoot);
86.156 + }
86.157 + } else if (key == KEY_SETUP_DIR) {
86.158 + try {
86.159 + DataObject sdo = DataObject.find(getSetupFolder());
86.160 + n = new ServerResourceNode(project); // sdo.getNodeDelegate());
86.161 + } catch (org.openide.loaders.DataObjectNotFoundException dnfe) {}
86.162 + */
86.163 + }
86.164 +
86.165 + return n == null ? new Node[0] : new Node[] {n};
86.166 + }
86.167 +
86.168 + private DataFolder getFolder(String propName) {
86.169 + FileObject fo = helper.resolveFileObject(evaluator.getProperty (propName));
86.170 + if (fo != null) {
86.171 + DataFolder df = DataFolder.findFolder(fo);
86.172 + return df;
86.173 + }
86.174 + return null;
86.175 + }
86.176 +
86.177 + // file change events in the project directory
86.178 + public void fileAttributeChanged(org.openide.filesystems.FileAttributeEvent fe) {
86.179 + }
86.180 +
86.181 + public void fileChanged(org.openide.filesystems.FileEvent fe) {
86.182 + }
86.183 +
86.184 + public void fileDataCreated(org.openide.filesystems.FileEvent fe) {
86.185 + }
86.186 +
86.187 + public void fileDeleted(org.openide.filesystems.FileEvent fe) {
86.188 + // setup folder deleted
86.189 + createNodes();
86.190 + }
86.191 +
86.192 + public void fileFolderCreated(org.openide.filesystems.FileEvent fe) {
86.193 + // setup folder could be created
86.194 + createNodes();
86.195 + }
86.196 +
86.197 + public void fileRenamed(org.openide.filesystems.FileRenameEvent fe) {
86.198 + // setup folder could be renamed
86.199 + createNodes();
86.200 + }
86.201 + }
86.202 +
86.203 + private static final class DocBaseNode extends FilterNode {
86.204 + private static Image CONFIGURATION_FILES_BADGE = Utilities.loadImage( "org/netbeans/modules/compapp/projects/base/ui/resources/docjar.gif", true ); // NOI18N
86.205 +
86.206 + DocBaseNode (Node orig) {
86.207 + super (orig);
86.208 + }
86.209 +
86.210 + public Image getIcon( int type ) {
86.211 + return computeIcon( false, type );
86.212 + }
86.213 +
86.214 + public Image getOpenedIcon( int type ) {
86.215 + return computeIcon( true, type );
86.216 + }
86.217 +
86.218 + private Image computeIcon( boolean opened, int type ) {
86.219 + Node folderNode = getOriginal();
86.220 + Image image = opened ? folderNode.getOpenedIcon( type ) : folderNode.getIcon( type );
86.221 + return Utilities.mergeImages( image, CONFIGURATION_FILES_BADGE, 7, 7 );
86.222 + }
86.223 +
86.224 + public String getDisplayName () {
86.225 + return NbBundle.getMessage(IcanproLogicalViewProvider.class, "LBL_Node_DocBase"); //NOI18N
86.226 + }
86.227 + }
86.228 +}
87.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
87.2 +++ b/enterprise/openesbaddons/workflow/project/src/org/netbeans/modules/workflow/project/ui/resources/Bundle.properties Thu Apr 26 02:33:27 2007 +0000
87.3 @@ -0,0 +1,3 @@
87.4 +OpenIDE-Module-Name=Workflow Project
87.5 +OpenIDE-Module-Display-Category=Service-Oriented Architecture
87.6 +OpenIDE-Module-Short-Description=Support for Workflow Application Projects.
88.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
88.2 +++ b/enterprise/openesbaddons/workflow/project/src/org/netbeans/modules/workflow/project/ui/resources/emptyProject.html Thu Apr 26 02:33:27 2007 +0000
88.3 @@ -0,0 +1,21 @@
88.4 +<!--
88.5 + Sun Public License Notice
88.6 +
88.7 + The contents of this file are subject to the Sun Public License
88.8 + Version 1.0 (the "License"). You may not use this file except in
88.9 + compliance with the License. A copy of the License is available at
88.10 + http://www.sun.com/
88.11 +
88.12 + The Original Code is NetBeans. The Initial Developer of the Original
88.13 + Code is Sun Microsystems, Inc. Portions Copyright 1997-2004 Sun
88.14 + Microsystems, Inc. All Rights Reserved.
88.15 +
88.16 +-->
88.17 +
88.18 +<HTML>
88.19 + <BODY>
88.20 + The Empty CAPS Workflow Project creates a project in the system but does not add
88.21 + any files or workflows to the project. This template is best for workflow developers who
88.22 + like to start from scratch.
88.23 + </BODY>
88.24 +</HTML>
89.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
89.2 +++ b/enterprise/openesbaddons/workflow/project/src/org/netbeans/modules/workflow/project/ui/resources/layer.xml Thu Apr 26 02:33:27 2007 +0000
89.3 @@ -0,0 +1,44 @@
89.4 +<?xml version="1.0" encoding="UTF-8"?>
89.5 +<!--
89.6 + Sun Public License Notice
89.7 +
89.8 +The contents of this file are subject to the Sun Public License
89.9 +Version 1.0 (the "License"). You may not use this file except in
89.10 +compliance with the License. A copy of the License is available at
89.11 +http://www.sun.com/
89.12 +
89.13 +The Original Code is NetBeans. The Initial Developer of the Original
89.14 +Code is Sun Microsystems, Inc. Portions Copyright 1997-2004 Sun
89.15 +Microsystems, Inc. All Rights Reserved.
89.16 +-->
89.17 +
89.18 +<?xml-stylesheet type="text/xml" href="http://openide.netbeans.org/fs/filesystem.xsl"?>
89.19 +<!DOCTYPE filesystem PUBLIC "-//NetBeans//DTD Filesystem 1.1//EN" "http://www.netbeans.org/dtds/filesystem-1_1.dtd">
89.20 +<filesystem>
89.21 + <folder name="Templates">
89.22 + <folder name="Project">
89.23 + <folder name="SOA">
89.24 + <attr name="SystemFileSystem.localizingBundle" stringvalue="org.netbeans.modules.workflow.project.ui.wizards.Bundle"/>
89.25 + <attr name="instantiatingWizardURL" urlvalue="nbresloc:/org/netbeans/modules/workflow/project/ui/resources/workflowpro.html"/>
89.26 +
89.27 + <!-- Add template for the J2SE project -->
89.28 + <file name="emptyWorkflowpro.xml">
89.29 + <attr name="template" boolvalue="true"/>
89.30 + <attr name="templateWizardIterator" newvalue="org.netbeans.modules.workflow.project.ui.wizards.NewWorkflowproProjectWizardIterator"/>
89.31 + <attr name="SystemFileSystem.localizingBundle" stringvalue="org.netbeans.modules.workflow.project.ui.wizards.Bundle"/>
89.32 + <attr name="SystemFileSystem.icon" urlvalue="nbresloc:/org/netbeans/modules/workflow/project/ui/resources/workflowproProjectIcon.gif"/>
89.33 + <attr name="templateWizardURL" urlvalue="nbresloc:/org/netbeans/modules/workflow/project/ui/resources/emptyProject.html"/>
89.34 + </file>
89.35 + </folder>
89.36 + </folder>
89.37 + </folder>
89.38 +
89.39 + <folder name="SeeBeyondJbiComponents">
89.40 + <!-- JBI Component -->
89.41 + <file name="com.sun.workflowse">
89.42 + <attr name="id" stringvalue="sun-workflow-engine"/>
89.43 + <attr name="description" stringvalue="This is a workflow service engine."/>
89.44 + <attr name="type" stringvalue="Engine"/>
89.45 + </file>
89.46 + </folder>
89.47 +</filesystem>
90.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
90.2 +++ b/enterprise/openesbaddons/workflow/project/src/org/netbeans/modules/workflow/project/ui/resources/workflowmap.xml Thu Apr 26 02:33:27 2007 +0000
90.3 @@ -0,0 +1,44 @@
90.4 +<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
90.5 +<!--
90.6 + <requestReplyService>
90.7 + <input partnerLink="{foo}pl0"
90.8 + roleName="server"
90.9 + portType="portType"
90.10 + operation="operation"
90.11 + messageType="replyMessageType"
90.12 + file="map.xsl"
90.13 + transformJBI="false" />
90.14 + </requestReplyService>
90.15 + <filterOneWay>
90.16 + <input partnerLink="{foo}pl1"
90.17 + roleName="server"
90.18 + portType="portType"
90.19 + operation="operation"
90.20 + messageType="replyMessageType"
90.21 + file="map.xsl"
90.22 + transformJBI="false" />
90.23 + <output partnerLink="{bar}pl2"
90.24 + roleName="client"
90.25 + portType="outPortType"
90.26 + operation="outOp" />
90.27 + </filterOneWay>
90.28 + <filterRequestReply>
90.29 + <input partnerLink="{foo}pl1"
90.30 + roleName="server"
90.31 + portType="portType"
90.32 + operation="operation"
90.33 + messageType="replyMessageType"
90.34 + file="map.xsl"
90.35 + transformJBI="false" />
90.36 + <output partnerLink="{bar}pl2"
90.37 + roleName="client"
90.38 + portType="outPortType"
90.39 + operation="outOp"
90.40 + messageType="replyMessageType"
90.41 + file="map2.xsl"
90.42 + transformJBI="false" />
90.43 + </filterRequestReply>
90.44 +-->
90.45 +<workflowmap>
90.46 + <!-- Insert configuration here -->
90.47 +</workflowmap>
91.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
91.2 +++ b/enterprise/openesbaddons/workflow/project/src/org/netbeans/modules/workflow/project/ui/resources/workflowpro.html Thu Apr 26 02:33:27 2007 +0000
91.3 @@ -0,0 +1,18 @@
91.4 +<!--
91.5 + - Sun Public License Notice
91.6 + -
91.7 + - The contents of this file are subject to the Sun Public License
91.8 + - Version 1.0 (the "License"). You may not use this file except in
91.9 + - compliance with the License. A copy of the License is available at
91.10 + - http://www.sun.com/
91.11 + -
91.12 + - The Original Code is NetBeans. The Initial Developer of the Original
91.13 + - Code is Sun Microsystems, Inc. Portions Copyright 1997-2004 Sun
91.14 + - Microsystems, Inc. All Rights Reserved.
91.15 + -->
91.16 +
91.17 +<HTML>
91.18 + <BODY>
91.19 + The CAPS Workflow Application Projects.
91.20 + </BODY>
91.21 +</HTML>
92.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
92.2 +++ b/enterprise/openesbaddons/workflow/project/src/org/netbeans/modules/workflow/project/ui/wizards/Bundle.properties Thu Apr 26 02:33:27 2007 +0000
92.3 @@ -0,0 +1,23 @@
92.4 +#
92.5 +# Sun Public License Notice
92.6 +#
92.7 +# The contents of this file are subject to the Sun Public License
92.8 +# Version 1.0 (the "License"). You may not use this file except in
92.9 +# compliance with the License. A copy of the License is available at
92.10 +# http://www.sun.com/
92.11 +#
92.12 +# The Original Code is NetBeans. The Initial Developer of the Original
92.13 +# Code is Sun Microsystems, Inc. Portions Copyright 1997-2004 Sun
92.14 +# Microsystems, Inc. All Rights Reserved.
92.15 +#
92.16 +
92.17 +#System file system
92.18 +Templates/SOA=Service Oriented Architecture
92.19 +Templates/Project/SOA=Service Oriented Architecture
92.20 +Templates/Project/SOA/emptyWorkflowpro.xml=Workflow Module
92.21 +
92.22 +#NewWEjbJarProjectWizardIterator
92.23 +LBL_WizardStepsCount={0} of {1}
92.24 +
92.25 +#PanelProjectAppVisual
92.26 +LBL_NPW1_DefaultProjectName=WorkflowApp{0}
93.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
93.2 +++ b/enterprise/openesbaddons/workflow/project/src/org/netbeans/modules/workflow/project/ui/wizards/NewWorkflowproProjectWizardIterator.java Thu Apr 26 02:33:27 2007 +0000
93.3 @@ -0,0 +1,39 @@
93.4 +/*
93.5 + * Sun Public License Notice
93.6 + *
93.7 + * The contents of this file are subject to the Sun Public License
93.8 + * Version 1.0 (the "License"). You may not use this file except in
93.9 + * compliance with the License. A copy of the License is available at
93.10 + * http://www.sun.com/
93.11 + *
93.12 + * The Original Code is NetBeans. The Initial Developer of the Original
93.13 + * Code is Sun Microsystems, Inc. Portions Copyright 1997-2004 Sun
93.14 + * Microsystems, Inc. All Rights Reserved.
93.15 + */
93.16 +
93.17 +package org.netbeans.modules.workflow.project.ui.wizards;
93.18 +
93.19 +import org.netbeans.modules.compapp.projects.base.ui.wizards.NewIcanproProjectWizardIterator;
93.20 +import org.netbeans.modules.workflow.project.WorkflowproProjectGenerator;
93.21 +import java.io.File;
93.22 +import java.io.IOException;
93.23 +import org.openide.util.NbBundle;
93.24 +
93.25 +
93.26 +
93.27 +/**
93.28 + * Wizard to create a new Web project.
93.29 + * @author Jesse Glick
93.30 + */
93.31 +public class NewWorkflowproProjectWizardIterator extends NewIcanproProjectWizardIterator{
93.32 +
93.33 + private static final long serialVersionUID = 1L;
93.34 +
93.35 + protected String getDefaultName() {
93.36 + return NbBundle.getMessage(NewWorkflowproProjectWizardIterator.class, "LBL_NPW1_DefaultProjectName"); //NOI18N
93.37 + }
93.38 +
93.39 + protected void createProject(File dirF, String name, String j2eeLevel) throws IOException {
93.40 + WorkflowproProjectGenerator.createProject(dirF, name, j2eeLevel);
93.41 + }
93.42 +}