incubator-hise-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r.@apache.org
Subject svn commit: r965842 [1/2] - in /incubator/hise/trunk: hise-services/src/main/java/org/apache/hise/engine/jaxws/ hise-services/src/main/java/org/apache/hise/utils/ hise-test-example-osgi/src/main/resources/ itest/
Date Tue, 20 Jul 2010 13:39:04 GMT
Author: rr
Date: Tue Jul 20 13:39:04 2010
New Revision: 965842

URL: http://svn.apache.org/viewvc?rev=965842&view=rev
Log:
HISE-47: Rendering improvement (Thanks to PaweĊ‚ Byszewski)

Modified:
    incubator/hise/trunk/hise-services/src/main/java/org/apache/hise/engine/jaxws/TaskOperationsImpl.java
    incubator/hise/trunk/hise-services/src/main/java/org/apache/hise/utils/DOMUtils.java
    incubator/hise/trunk/hise-test-example-osgi/src/main/resources/testHtd1.xml
    incubator/hise/trunk/itest/hise-soapui-project.xml

Modified: incubator/hise/trunk/hise-services/src/main/java/org/apache/hise/engine/jaxws/TaskOperationsImpl.java
URL: http://svn.apache.org/viewvc/incubator/hise/trunk/hise-services/src/main/java/org/apache/hise/engine/jaxws/TaskOperationsImpl.java?rev=965842&r1=965841&r2=965842&view=diff
==============================================================================
--- incubator/hise/trunk/hise-services/src/main/java/org/apache/hise/engine/jaxws/TaskOperationsImpl.java
(original)
+++ incubator/hise/trunk/hise-services/src/main/java/org/apache/hise/engine/jaxws/TaskOperationsImpl.java
Tue Jul 20 13:39:04 2010
@@ -78,6 +78,7 @@ import org.apache.hise.utils.DOMUtils;
 import org.apache.hise.utils.XQueryEvaluator;
 import org.springframework.transaction.annotation.Transactional;
 import org.w3c.dom.Document;
+import org.w3c.dom.Element;
 import org.w3c.dom.Node;
 import org.w3c.dom.NodeList;
 
@@ -540,28 +541,54 @@ public class TaskOperationsImpl implemen
             		break;
             	}
             }
-            TaskEvaluator evaluator=task.getTaskEvaluator();
-            if(rendering != null){
-            	List<Object> content = rendering.getAny();
-            	if(!content.isEmpty() && content.get(0) instanceof org.w3c.dom.Element){
-            		NodeList nodes=((org.w3c.dom.Element)content.get(0)).getChildNodes();
-            		
-            		if(nodes.getLength()==0) 
-            			return null;
-            		
-            		String expression=nodes.item(0).getTextContent();
-            		List queryResponse=evaluator.buildQueryEvaluator().evaluateExpression(expression,
null);
-            		Object r = DOMUtils.domToString((Node)queryResponse.get(0));
-            		Document result = DOMUtils.parse(r.toString());
-            		return result.getDocumentElement();
-            	}
-            }
+            if(rendering == null) return null;
+            return convertRendering(rendering, task);
         }
-
         return null;
+   
     }
 
-    /**
+    private Object convertRendering(TRendering rendering, Task task) {
+    	List<Object> content = rendering.getAny();
+        if(!content.isEmpty() && content.get(0) instanceof org.w3c.dom.Element){
+        	NodeList nodes=((org.w3c.dom.Element)content.get(0)).getChildNodes();
+        	if(nodes.getLength()==0) return null;
+            TaskEvaluator evaluator=task.getTaskEvaluator();
+        	String expression=nodes.item(0).getTextContent();
+        	List queryResponse=evaluator.buildQueryEvaluator().evaluateExpression(expression,
null);
+        	if(queryResponse.get(0) instanceof Node){
+        		Document result=convertRenderingFromXML((Node)queryResponse.get(0));
+        		return result==null ? null : result.getDocumentElement();
+        	}
+        	else{
+        		Document result=convertRenderingFromString(queryResponse.get(0).toString());
+        		return result==null ? null : result.getDocumentElement();
+        	}
+        }
+        return null;
+	}
+
+	private Document convertRenderingFromString(String response) {
+		Document resultDocument = DOMUtils.createEmptyDomDocument(); 
+		if(resultDocument==null)//there was problem with create document
+			return null;
+		Element element = resultDocument.createElement("root");
+		element.appendChild(resultDocument.createTextNode(response)); 
+		resultDocument.appendChild(element);
+		return resultDocument;
+	}
+
+	private Document convertRenderingFromXML(Node response) {
+		Document resultDocument = DOMUtils.createEmptyDomDocument(); 
+			if(resultDocument==null)//there was problem with create document
+				return null;
+		Element element = resultDocument.createElement("root"); 
+		resultDocument.appendChild(element); 
+		element.appendChild(resultDocument.importNode(response,true));	
+		return resultDocument;
+	}
+
+	/**
      * Returns the rendering types available for the task or notification.
      * @param identifier task identifier
      * @return available renderings

Modified: incubator/hise/trunk/hise-services/src/main/java/org/apache/hise/utils/DOMUtils.java
URL: http://svn.apache.org/viewvc/incubator/hise/trunk/hise-services/src/main/java/org/apache/hise/utils/DOMUtils.java?rev=965842&r1=965841&r2=965842&view=diff
==============================================================================
--- incubator/hise/trunk/hise-services/src/main/java/org/apache/hise/utils/DOMUtils.java (original)
+++ incubator/hise/trunk/hise-services/src/main/java/org/apache/hise/utils/DOMUtils.java Tue
Jul 20 13:39:04 2010
@@ -28,6 +28,7 @@ import java.util.List;
 import javax.xml.namespace.QName;
 import javax.xml.parsers.DocumentBuilder;
 import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
 import javax.xml.xpath.XPathFactory;
 
 import org.apache.xerces.dom.DOMOutputImpl;
@@ -168,4 +169,12 @@ public class DOMUtils {
 		Node node=nodes.item(0);
 		return new Long(node.getTextContent());
     }
+    public static Document createEmptyDomDocument() { 
+    	try { 
+    		DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();

+    		Document doc = builder.newDocument(); 
+    		return doc; 
+    	} 
+    	catch (ParserConfigurationException e) { } 
+    	return null; } 
 }

Modified: incubator/hise/trunk/hise-test-example-osgi/src/main/resources/testHtd1.xml
URL: http://svn.apache.org/viewvc/incubator/hise/trunk/hise-test-example-osgi/src/main/resources/testHtd1.xml?rev=965842&r1=965841&r2=965842&view=diff
==============================================================================
--- incubator/hise/trunk/hise-test-example-osgi/src/main/resources/testHtd1.xml (original)
+++ incubator/hise/trunk/hise-test-example-osgi/src/main/resources/testHtd1.xml Tue Jul 20
13:39:04 2010
@@ -150,24 +150,24 @@ xs:double(htd:getInput("ClaimApprovalReq
                 <htd:rendering type="NSW/GWT">
                 <expression>
                     <![CDATA[
-                        declare namespace htd="http://www.example.org/WS-HT";           
   
-                        <htd:rendering name="rendering" xmlns:cla="http://www.insurance.example.com/claims">
+                   
+                        declare namespace htd="http://www.example.org/WS-HT"; 
+                                      
+                        <example name="anyname" xmlns:cla="http://www.insurance.example.com/claims">
                             <param name="type" value="{htd:getInput("ClaimApprovalRequest")/cla:cust/cla:firstname/text()}"/>
-                        </htd:rendering>
+                        </example>
+            
                     ]]>
                     </expression>
                 </htd:rendering>
-               <!--   <htd:rendering type="type3">
+              <htd:rendering type="simpleText">
                 <expression>
                     <![CDATA[
-                        declare namespace htd="http://www.example.org/WS-HT";           
   
-                        <htd:searchBy  xmlns:cla="http://www.insurance.example.com/claims">
-                            <param name="type" value="{htd:getInput("ClaimApprovalRequest")/cla:cust/cla:firstname/text()}"/>
-                        </htd:searchBy>
+                      "test_expression"
                     ]]>
                     </expression>
                 </htd:rendering>
-			-->
+			-
    </htd:renderings>      
             
   <htd:deadlines>



Mime
View raw message