You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by ad...@apache.org on 2007/06/10 10:30:39 UTC

svn commit: r545855 - in /incubator/tuscany/java/das/samples/sample-ajax-das: readme.htm src/main/java/org/apache/tuscany/samples/das/DASQueryProcessor.java src/main/webapp/jsp/default.css src/main/webapp/jsp/main.css

Author: adrianocrestani
Date: Sun Jun 10 01:30:39 2007
New Revision: 545855

URL: http://svn.apache.org/viewvc?view=rev&rev=545855
Log:
- added Apache License header to files: samples/sample-ajax-das/readme.htm, sample-ajax-das/src/main/java/org/apache/tuscany/samples/das/DASQueryProcessor.java, sample-ajax-das/src/main/webapp/jsp/main.css, sample-ajax-das/src/main/webapp/jsp/default.css

Modified:
    incubator/tuscany/java/das/samples/sample-ajax-das/readme.htm
    incubator/tuscany/java/das/samples/sample-ajax-das/src/main/java/org/apache/tuscany/samples/das/DASQueryProcessor.java
    incubator/tuscany/java/das/samples/sample-ajax-das/src/main/webapp/jsp/default.css
    incubator/tuscany/java/das/samples/sample-ajax-das/src/main/webapp/jsp/main.css

Modified: incubator/tuscany/java/das/samples/sample-ajax-das/readme.htm
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/das/samples/sample-ajax-das/readme.htm?view=diff&rev=545855&r1=545854&r2=545855
==============================================================================
--- incubator/tuscany/java/das/samples/sample-ajax-das/readme.htm (original)
+++ incubator/tuscany/java/das/samples/sample-ajax-das/readme.htm Sun Jun 10 01:30:39 2007
@@ -1,3 +1,29 @@
+<!--
+
+
+<p class=MsoNormal><span style="font-size: 9pt">&nbsp;</span></p>
+<pre><a name="header-text">Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+&quot;License&quot;); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+&quot;AS IS&quot; BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.   </a></pre>
+<p class=MsoNormal><span style="font-size: 9pt"><br>
+&nbsp;</span></p>
+<p class=MsoNormal><span style='font-size:9.0pt'>
+<o:p>&nbsp;</o:p></span></p>
+
+-->
 <html xmlns:o="urn:schemas-microsoft-com:office:office"
 xmlns:w="urn:schemas-microsoft-com:office:word"
 xmlns:st1="urn:schemas-microsoft-com:office:smarttags"

Modified: incubator/tuscany/java/das/samples/sample-ajax-das/src/main/java/org/apache/tuscany/samples/das/DASQueryProcessor.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/das/samples/sample-ajax-das/src/main/java/org/apache/tuscany/samples/das/DASQueryProcessor.java?view=diff&rev=545855&r1=545854&r2=545855
==============================================================================
--- incubator/tuscany/java/das/samples/sample-ajax-das/src/main/java/org/apache/tuscany/samples/das/DASQueryProcessor.java (original)
+++ incubator/tuscany/java/das/samples/sample-ajax-das/src/main/java/org/apache/tuscany/samples/das/DASQueryProcessor.java Sun Jun 10 01:30:39 2007
@@ -1,3 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
 package org.apache.tuscany.samples.das;
 
 import java.io.ByteArrayInputStream;
@@ -40,15 +59,15 @@
 	public String execute(String queryOrcommand, String configFile) throws Exception{
     	String status = null;
     	this.configFile = configFile;
-    	
+
 		try{
         	Properties props = validate(queryOrcommand);
-        	
+
         	if(props != null){
-        		status = this.getResult((String)props.values().iterator().next(), 
+        		status = this.getResult((String)props.values().iterator().next(),
         			(String)props.keys().nextElement());
         	}
-        	
+
     		if(queryOrcommand.startsWith("occ:")){
     			status = this.getOcc();
     		}
@@ -56,10 +75,10 @@
     		if(queryOrcommand.startsWith("converter:")){
     			status = this.getConverter(queryOrcommand.substring(10));
     		}
-    		
+
     		if(queryOrcommand.startsWith("rss:")){
     			status = this.getRss(queryOrcommand.substring(4));
-    		}    		
+    		}
         }catch(Exception e){
         	das.releaseResources();
         	e.printStackTrace();
@@ -68,12 +87,12 @@
         das.releaseResources();
         return status ;
 	}
-	
+
 	private Properties validate(String queryOrcommand) throws Exception{
 		if(queryOrcommand == null){
 			throw new Exception("Invalid Command URL -> COMMAND is NULL");
 		}
-		
+
 		if(queryOrcommand.startsWith("query:")){
 			String qry = queryOrcommand.substring(6);
 			if(qry == null || qry.trim().length() == 0){
@@ -85,7 +104,7 @@
 				return props;
 			}
 		}
-		
+
 		if(queryOrcommand.startsWith("command:")){
 			String cmd = queryOrcommand.substring(8);
 			if(cmd == null || cmd.trim().length() == 0){
@@ -97,8 +116,8 @@
 				return props;
 			}
 		}
-		
-				
+
+
 		return null;
 	}
 
@@ -120,9 +139,9 @@
 		if(root.getList("CUSTOMER") != null && root.getList("CUSTOMER").size() >0){
 			elemNames.add("CUSTOMER");
 		}
-		
+
     	return formatResult(root, elemNames);
-    	
+
     }
 
     /* Get DAS config */
@@ -131,29 +150,29 @@
     }
 
 	/* Instantiate DAS*/
-	private void getDAS(){        
-        das = DAS.FACTORY.createDAS(getConfig(configFile));        
+	private void getDAS(){
+        das = DAS.FACTORY.createDAS(getConfig(configFile));
 	}
-	
+
 	/*For any query starting with query: or command: */
 	private DataObject runCommand(String qry, String qryOrCommand)throws Exception{
-        DataObject root = null;       
+        DataObject root = null;
 
         //adhoc queries
 		if(qryOrCommand.startsWith("query")){//query can come single or batch, when batch, it will be {}{}
 			if(!qry.startsWith("{")){
-				read = das.createCommand(qry);	        
-				root = read.executeQuery();        
+				read = das.createCommand(qry);
+				root = read.executeQuery();
 			}
 			else{
 				Vector<String> batch = formQueries(qry);//separate {}{} in different queries
-				
+
 				if(batch != null){
 					for(int i=0; i<batch.size(); i++){
 						String curQry = batch.get(i);
 						if(curQry.substring(0, 6).equalsIgnoreCase("select")){
 							read = das.createCommand(curQry);
-							root = read.executeQuery();   
+							root = read.executeQuery();
 						}
 						else{
 							read = das.createCommand(curQry);
@@ -167,13 +186,13 @@
 		//DAS config commands
 		if(qryOrCommand.startsWith("command")){
 			String methodName = "get"+qry; //some convention to form method name instead of lenghtening code
-			
+
 			Method commandMethod = this.getClass().getMethod(methodName, new Class[]{String.class});
-			root = (DataObject)commandMethod.invoke(this, qry);        	
+			root = (DataObject)commandMethod.invoke(this, qry);
         }
         return root;
 	}
-	
+
 	/* Separate batch of queries into vector of queries - for adhoc*/
 	private Vector<String> formQueries(String qry){
 		Vector<String> batch = new Vector<String>();
@@ -185,7 +204,7 @@
 		}
 		return batch;
 	}
-	
+
     public static String formatResult(DataObject root, Vector elementNames){
     	String xmlStr = "";
     	XMLHelper helper = XMLHelper.INSTANCE;
@@ -195,50 +214,50 @@
         	for(int i=0; i<elemList.size(); i++){
         		DataObject curComp = (DataObject)elemList.get(i);
         		xmlStr = xmlStr+helper.save(curComp,null, curElemName);
-        		
+
             	//System.out.println("xmlStr:"+xmlStr);
-            	
+
             	//format xmlstr
             	while(true){
                 	String rmvStr = "<?xml version=\"1.0\" encoding=\"ASCII\"?>";
                 	int idx = xmlStr.indexOf("<?xml version", 0);
                 	if(idx == -1) break;
                 	xmlStr = xmlStr.substring(0, idx)+xmlStr.substring(idx+rmvStr.length());
-                	
+
                 	rmvStr = "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"";
                 	idx = xmlStr.indexOf("xmlns:xsi=", 0);
                 	if(idx == -1) break;
                 	xmlStr = xmlStr.substring(0, idx)+xmlStr.substring(idx+rmvStr.length());
-                	
+
                 	rmvStr = "xmlns:das=\"http:///org.apache.tuscany.das.rdb/das\"";
                 	idx = xmlStr.indexOf("xmlns:das=", 0);
                 	if(idx == -1) break;
                 	xmlStr = xmlStr.substring(0, idx)+xmlStr.substring(idx+rmvStr.length());
-                	
+
                 	//System.out.println("xmlStr:"+xmlStr);
             	}
-            	
+
             	while(true){
                 	String rmvStr =  "xsi:type=\"";
                 	int idx = xmlStr.indexOf(rmvStr, 0);
                 	if(idx == -1) break;
                 	int idxEnd = xmlStr.indexOf("\"", idx+rmvStr.length());
                 	xmlStr = xmlStr.substring(0, idx)+xmlStr.substring(idxEnd+1);
-                	
+
                 	//System.out.println("xmlStr:"+xmlStr);
-            	}     	
-        	}        	
+            	}
+        	}
     	}
 
 		String add0Str = "<?xml version='1.0' encoding='ISO-8859-1' ?>\n";
 		String add1Str = "<root  xmlns:das='http://org.apache.tuscany.das.rdb/config.xsd'  xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>\n";
 		String add2Str = "<das:DataGraphRoot>";
 		String addEndStr = "</das:DataGraphRoot> </root>";
-		
+
 		xmlStr = add0Str+add1Str+add2Str+xmlStr+"\n"+addEndStr;
 		return xmlStr;
     }
-    
+
     //below has improper serialization due to SDO bugs
 	/*From DataGraph get contents related to element <das:DataGraphRoot>*/
 	/*private String xmlizeContent(DataGraph graph) throws Exception{
@@ -249,7 +268,7 @@
         out.flush();
         //oos.close();
         out.close();
-        
+
         //there are UTF-8 chars which are not ISO-8859-1 ones and xsl transformation does not happen due to that
         //so filter unwanted.
         byte[] graphBytes = out.toByteArray();
@@ -261,25 +280,25 @@
         	graphChars[j] = (char)curChar;
         	j++;
         }
-        
+
         String finalStr = new String(graphChars);
-		
+
         //remove any junk before first <
-        finalStr = finalStr.substring(finalStr.indexOf("<"), finalStr.indexOf("</sdo:datagraph>")+16);       
+        finalStr = finalStr.substring(finalStr.indexOf("<"), finalStr.indexOf("</sdo:datagraph>")+16);
         String xmlSerializationContent = filterJunk(finalStr);//further remove extra characters appearing
         System.out.println("xmlSerializationContent:"+xmlSerializationContent);
-        String xmlContent = XmlUtil.getXmlContents(xmlSerializationContent, "<das:DataGraphRoot>", "</das:DataGraphRoot>");        
+        String xmlContent = XmlUtil.getXmlContents(xmlSerializationContent, "<das:DataGraphRoot>", "</das:DataGraphRoot>");
         System.out.println("xmlContent:"+xmlContent);
-        return xmlContent;		
+        return xmlContent;
 	}
-	
+
 	//for some reason control chars are appearing, need to filter those
     //this is ugly solution, need to know why from SDO DataGraph these
 	//chars are coming in the first place.
 	private String filterJunk(String inStr){
         char[] myCharArr  = inStr.toCharArray();
         StringBuffer strBuf = new StringBuffer();
-        
+
         for(int i=0; i<myCharArr.length; i++){
         	if((myCharArr[i]>=33 && myCharArr[i]<=125) ||
         			Character.isWhitespace(myCharArr[i])){
@@ -288,18 +307,18 @@
         }
         return strBuf.toString();
 	}*/
-	
+
     /* Start CRUD example */
     public DataObject getAllCompanies(String qry) {
     	read = das.getCommand(qry);
         DataObject root = read.executeQuery();
         return root;
     }
-    
+
     public DataObject getAllCompaniesAndDepartments(String qry) {
     	read = das.getCommand(qry);
         DataObject root = read.executeQuery();
-        return root;    	
+        return root;
     }
 
     public DataObject getAddDepartmentToFirstCompany(String qry) {
@@ -310,14 +329,14 @@
         DataObject newDepartment = root.createDataObject("DEPARTMENT");
         newDepartment.setString("NAME", "Default Name");
         List deptList = firstCompany.getList("departments");
-        
+
         deptList.add(newDepartment);
         das.applyChanges(root);
-        
+
         root = read.executeQuery();
         return root;
     }
-    
+
     public DataObject getDeleteDepartmentFromFirstCompany(String qry) {
         Command read = das.getCommand("AllCompaniesAndDepartments");
         DataObject root = read.executeQuery();
@@ -326,18 +345,18 @@
         List departments = firstCompany.getList("departments");
         DataObject departmentToDelete = (DataObject)departments.get(departments.size()-1);
         departmentToDelete.delete();
-        das.applyChanges(root);        
-        root = read.executeQuery();                
+        das.applyChanges(root);
+        root = read.executeQuery();
         return root;
-    }  
-    
+    }
+
     public  DataObject getUpdateCompanyDepartmentNames(String qry) {
         Command read = das.getCommand("AllCompaniesAndDepartments");
         DataObject root = read.executeQuery();
         DataObject firstCompany = root.getDataObject("COMPANY[1]");
 
         Iterator i = firstCompany.getList("departments").iterator();
-        
+
         DataObject department;
         while (i.hasNext()) {
             department = (DataObject) i.next();
@@ -346,18 +365,18 @@
             break;
         }
         das.applyChanges(root);
-        
-        root = read.executeQuery();        
+
+        root = read.executeQuery();
         return root;
     }
-    
+
     /* @return random new department name    */
     private String getRandomDepartmentName() {
         int number = generator.nextInt(1000) + 1;
         return "Dept-" + number;
     }
     /*End CRUD example */
-    
+
     /*Start OCC example */
     public String getOcc() throws Exception{
     	getDAS();
@@ -373,19 +392,19 @@
 
         // Build apply changes command
         try {
-            das.applyChanges(root);      
+            das.applyChanges(root);
         } catch (OptimisticConcurrencyException ex) {
             if (!ex.getMessage().equals("An update collision occurred")) {
                 throw ex;
             }
             else{
-            	return ex.getMessage(); 
+            	return ex.getMessage();
             }
         }
         return "Success";
     }
     /* End OCC example */
-        
+
     /* Start Result Set Shape example*/
     public String getRss(String stmt) throws Exception{
     	getDAS();
@@ -394,7 +413,7 @@
 		DataObject root = read.executeQuery();
 		Vector elemNames = new Vector();
 		elemNames.add("CUSTOMER");
-		return formatResult(root, elemNames);		
+		return formatResult(root, elemNames);
     }
     /* End Result Set Shape example*/
 
@@ -413,17 +432,17 @@
 		read = das.getCommand("testArbitraryConverter");
 		//Read
 		DataObject root = read.executeQuery();
-    	
+
     	if(stmt.equals("stmt0")){//Select * from CUSTOMER where ID = 1;
     		Vector elemNames = new Vector();
     		elemNames.add("CUSTOMER");
     		return this.formatResult(root, elemNames);
     	}
-        
+
     	if(stmt.equals("stmt1")){//Check First Customer's LastName is 1957.09.27
     		return myformat.format(root.getDate("CUSTOMER[1]/LASTNAME"));
     	}
-    	
+
     	if(stmt.equals("stmt2")||stmt.equals("stmt3")){//Set First Customer's LastName to 1966.12.20 OR
     												//Check First Customer's LastName is 1966.12.20
     		root.setDate("CUSTOMER[1]/LASTNAME", tbday);
@@ -432,20 +451,20 @@
             root = read.executeQuery();
     		return myformat.format(root.getDate("CUSTOMER[1]/LASTNAME"));
     	}
-    	
+
         return null;
     }
     /* Converter example end**/
-        
+
     /*For test*/
     public static void main(String[] args){
     	DASQueryProcessor qryProc = new DASQueryProcessor();
     	try{
-    		qryProc.execute("command:AllCompaniesAndDepartments", "DasConfig.xml");	
+    		qryProc.execute("command:AllCompaniesAndDepartments", "DasConfig.xml");
     	}catch(Exception e){
     		e.printStackTrace();
     	}
-    	
+
     }
-    
+
 }

Modified: incubator/tuscany/java/das/samples/sample-ajax-das/src/main/webapp/jsp/default.css
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/das/samples/sample-ajax-das/src/main/webapp/jsp/default.css?view=diff&rev=545855&r1=545854&r2=545855
==============================================================================
--- incubator/tuscany/java/das/samples/sample-ajax-das/src/main/webapp/jsp/default.css (original)
+++ incubator/tuscany/java/das/samples/sample-ajax-das/src/main/webapp/jsp/default.css Sun Jun 10 01:30:39 2007
@@ -1,3 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
 BODY {BACKGROUND-COLOR: #FFFFFF; COLOR: #333366;  FONT-FAMILY: 'Times New Roman'}
 H1 {COLOR: #6666CC; FONT-FAMILY: 'Times New Roman'; TEXT-TRANSFORM: capitalize }
 H2 {COLOR: #6666CC; FONT-FAMILY: 'Times New Roman'; TEXT-TRANSFORM: capitalize }

Modified: incubator/tuscany/java/das/samples/sample-ajax-das/src/main/webapp/jsp/main.css
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/das/samples/sample-ajax-das/src/main/webapp/jsp/main.css?view=diff&rev=545855&r1=545854&r2=545855
==============================================================================
--- incubator/tuscany/java/das/samples/sample-ajax-das/src/main/webapp/jsp/main.css (original)
+++ incubator/tuscany/java/das/samples/sample-ajax-das/src/main/webapp/jsp/main.css Sun Jun 10 01:30:39 2007
@@ -1,3 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
 body
 {
 	margin: 0px;



---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org