chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject svn commit: r1296075 - in /chemistry/playground/chemistry-opencmis-javascript-client/src: main/webapp/cmislib.js main/webapp/index.html test/resources/testcmislib.js
Date Fri, 02 Mar 2012 07:53:34 GMT
Author: jens
Date: Fri Mar  2 07:53:33 2012
New Revision: 1296075

URL: http://svn.apache.org/viewvc?rev=1296075&view=rev
Log:
Add reading the type system

Modified:
    chemistry/playground/chemistry-opencmis-javascript-client/src/main/webapp/cmislib.js
    chemistry/playground/chemistry-opencmis-javascript-client/src/main/webapp/index.html
    chemistry/playground/chemistry-opencmis-javascript-client/src/test/resources/testcmislib.js

Modified: chemistry/playground/chemistry-opencmis-javascript-client/src/main/webapp/cmislib.js
URL: http://svn.apache.org/viewvc/chemistry/playground/chemistry-opencmis-javascript-client/src/main/webapp/cmislib.js?rev=1296075&r1=1296074&r2=1296075&view=diff
==============================================================================
--- chemistry/playground/chemistry-opencmis-javascript-client/src/main/webapp/cmislib.js (original)
+++ chemistry/playground/chemistry-opencmis-javascript-client/src/main/webapp/cmislib.js Fri
Mar  2 07:53:33 2012
@@ -29,7 +29,7 @@ function OperationContext() {
     this.renditionFilter = null;
     this.includePathSegments = false;
     this.orderBy = null;
-
+    this.includePropertyDefinitions = true;
 }
 
 
@@ -178,6 +178,33 @@ function CmisSession(urlPrefix, reposito
         });
     };
 
+    this.getTypeDefinition = function(typeId, cbFct) {
+        var url = this.getUrl();
+        var data = {
+            typeId: typeId,
+            cmisselector: "typeDefinition",
+            includePropertyDefinitions: this.opCtx.includePropertyDefinitions,
+            suppressResponseCodes: true
+        };
+
+        console.log("getTypeDefinition() " + url);
+        this.doJson(url, data, cbFct);        
+    }
+    
+    this.getTypeChildren = function(typeIdent, cbFct) {
+        var url = this.getUrl();
+        var data = {
+            typeId: typeIdent,
+            cmisselector: "typeChildren",
+            includePropertyDefinitions: this.opCtx.includePropertyDefinitions,
+            skipCount: this.opCtx.skipCount,
+            suppressResponseCodes: true
+        };
+
+        console.log("getTypeDefinition() " + url);
+        this.doJson(url, data, cbFct);        
+    }
+    
     this.doJson = function(urlPrefix, params, cbFct) {
         $.ajax( { 
             url: urlPrefix,

Modified: chemistry/playground/chemistry-opencmis-javascript-client/src/main/webapp/index.html
URL: http://svn.apache.org/viewvc/chemistry/playground/chemistry-opencmis-javascript-client/src/main/webapp/index.html?rev=1296075&r1=1296074&r2=1296075&view=diff
==============================================================================
--- chemistry/playground/chemistry-opencmis-javascript-client/src/main/webapp/index.html (original)
+++ chemistry/playground/chemistry-opencmis-javascript-client/src/main/webapp/index.html Fri
Mar  2 07:53:33 2012
@@ -37,7 +37,7 @@
 	  
     function init1(connectionUrl, cbFct) {
          var factory = new CmisSessionFactory({
-              url : connectionUrl,
+              url : connectionUrl
         	});
          factory.getRepositories(cbFct);
     }
@@ -90,6 +90,25 @@
 		
         return tbl;
     }
+
+    function getTypesRecursive(typeId, tbl) {
+        console.log("getTypesRecursive: " + typeId );
+    	session.getTypeChildren(typeId, function(types) {
+	    	if (!checkError(types)) {
+	    	    for (var i in types.types) {	    	        
+	                tbl.append(row = $('<tr>'));
+	                row.append($('<td>').text(types.types[i].id ));
+	                row.append($('<td>').text(types.types[i].parentId ));
+	                for (var key in types.types[i].propertyDefinitions)
+		                row.append($('<td>').text( types.types[i].propertyDefinitions[key].id));
+	            }
+	    	    for (var i in types.types) {
+	    	        console.log("getTypeChildren() Found type definition: " + types.types[i].id
);
+			       	getTypesRecursive(types.types[i].id, tbl);
+	    	    }
+	        }
+    	});
+    }
     
     function checkSession() {
 	    if (null == session)
@@ -132,6 +151,8 @@
                 $("#repositoriessection *").remove();
             	$("#repositoriessection").append(tbl);
             	$("#repoidfield").attr('value', firstRepoId);
+            	$("#folderidfield").attr('value', repoInfos[firstRepoId].rootFolderId);
+            	
                 init2($("#reposfield").val(), "A1");
             });
         });
@@ -153,6 +174,22 @@
             });
         });
 
+        $('#typebutton').click(function() {
+            checkSession();
+            
+            var tbl = $('<table>').attr('id', 'typesTable').attr('border', 1);    
+            $("#typessection *").remove();
+          	$("#typessection").append($('<h4>').text("Type Definitions:")).append(tbl);
+
+          	tbl.append(row = $('<tr>'));
+            row.append($('<td>').text("Type-Id"));
+            row.append($('<td>').text("Parent-Id"));
+            row.append($('<td>').text("Property-Ids"));
+
+          	getTypesRecursive($('#typeidfield').val(), tbl);
+
+        });
+
         $('#getbutton').click(function() {
             checkSession();
             session.getDocument($('#docidfield').val(), function(doc) {
@@ -183,9 +220,9 @@
                   	var tbl1 = createTable(children, "cmis:folder");
                   	var tbl2 = createTable(children, "cmis:document");
                     $("#childrensection *").remove();
-                  	$("#childrensection").append($('<h2>').text("Children of Root Folder")).
-                  	append($('<h3>').text("Folders")).append(tbl1).append($('<br>')).
-                  	append($('<h3>').text("Documents")).append(tbl2);
+                  	$("#childrensection").
+                  	append($('<h4>').text("Folders")).append(tbl1).
+                  	append($('<h4>').text("Documents")).append(tbl2);
             	}
             });
         });
@@ -227,6 +264,21 @@
     <button id="repositoryInfo">Get RepositoryInfo!</button> <br/>
     <div id="repoinfosection">
     </div>
+
+    <hr/>    
+    <form >
+	    <table>
+	      <tr>
+	        <td><label for="typeidfield">Type-Id:</label></td>
+	        <td><input type="text" id="typeidfield" value="cmis:document"/></td>
+	      </tr>
+	    </table>
+	</form>
+    
+    <button id="typebutton">Get Type Descendants!</button>  <br/>
+    <div id="typessection">
+    </div>
+
     <hr/>    
     <form >
 	    <table>
@@ -246,7 +298,7 @@
 	    <table>
 	      <tr>
 	        <td><label for="folderidfield">Folder-Id:</label></td>
-	        <td><input type="text" id="folderidfield" value="100"/></td>
+	        <td><input type="text" id="folderidfield" value="?"/></td>
 	      </tr>
 	    </table>
 	</form>

Modified: chemistry/playground/chemistry-opencmis-javascript-client/src/test/resources/testcmislib.js
URL: http://svn.apache.org/viewvc/chemistry/playground/chemistry-opencmis-javascript-client/src/test/resources/testcmislib.js?rev=1296075&r1=1296074&r2=1296075&view=diff
==============================================================================
--- chemistry/playground/chemistry-opencmis-javascript-client/src/test/resources/testcmislib.js
(original)
+++ chemistry/playground/chemistry-opencmis-javascript-client/src/test/resources/testcmislib.js
Fri Mar  2 07:53:33 2012
@@ -175,4 +175,39 @@ test("testCreateDocumentMustFail()", fun
     });
 });
 
+test("testGetTypeDefinition()", function() {
+    trace("testGetTypeDefinition ");
+    expect(3);
 
+    $(document).unbind('ajaxError'); 
+    stop();
+    this.session.getTypeDefinition("cmis:document", function(type) {
+        var count = 0;
+        trace("Found type definition: " + type.id);
+        ok(type.exception == null, "gGetTypeDefinition() exception");
+        ok(type.id != null, "Type definition has id");
+        for (var key in type.propertyDefinitions) {
+            trace("Found property definition: " + type.propertyDefinitions[key].id);
+            count++;
+        }
+        equal(count, 23, "getTypeChildren found number of property defs: " + count  +" expected
23");
+        start();
+     });
+});
+
+test("testGetTypeChildren()", function() {
+    trace("testGetTypeChildren ");
+    expect(1);
+
+    $(document).unbind('ajaxError'); 
+    stop();
+    this.session.getTypeChildren("cmis:document", function(types) {
+        var count = 0;
+        for (var i in types.types) {
+            trace("Found type: " + types.types[i].id);
+            count++;
+        }
+        equal(count, types.numItems, "getTypeChildren found types: " + count);
+        start();
+     });
+});



Mime
View raw message