From 6c5763e8f496fdf5e554385c5dc7212f00ac0cc9 Mon Sep 17 00:00:00 2001 From: Michael Uzqu Date: Sun, 25 May 2008 16:06:01 +0000 Subject: [PATCH] Updated metadata retrieval webscript for Web Framework - now writes out child nodes and hasChildren property git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@9263 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../webframework/metadata.get.html.ftl | 74 ++++++++++++++++--- .../org/alfresco/webframework/metadata.get.js | 3 +- 2 files changed, 65 insertions(+), 12 deletions(-) diff --git a/config/alfresco/templates/webscripts/org/alfresco/webframework/metadata.get.html.ftl b/config/alfresco/templates/webscripts/org/alfresco/webframework/metadata.get.html.ftl index 9677c4e8d5..a4a48cfe12 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/webframework/metadata.get.html.ftl +++ b/config/alfresco/templates/webscripts/org/alfresco/webframework/metadata.get.html.ftl @@ -1,4 +1,8 @@ { + <@serialize object=object includeChildren=includeChildren includeContent=includeContent/> +} + +<#macro serialize object includeChildren includeContent> "isContainer" : ${object.isContainer?string} , "isDocument" : ${object.isDocument?string} @@ -21,7 +25,7 @@ , "isLocked" : ${object.isLocked?string} , - "id" : ${object.id} + "id" : "${object.id}" , "nodeRef" : "${object.nodeRef}" , @@ -30,24 +34,72 @@ "type" : "${object.type}" , "isCategory" : ${object.isCategory?string} + , -<#if properties?exists> +<#if object.children?exists> + <#if object.children?size > 0> + "hasChildren" : true + <#else> + "hasChildren" : false + + + +<#if object.properties?exists> , "properties" : { - <#assign first = false> - <#list properties?keys as key> - <#assign val = properties[key]> + <#assign first = true> + <#list object.properties?keys as key> + <#assign val = object.properties[key]> <#if val?exists> - <#if first == true> - , + <#assign renderable = false> + <#if val?is_string == true> + <#assign renderable = true> + + <#if val?is_date == true> + <#assign renderable = true> + + <#if val?is_boolean == true> + <#assign renderable = true> + + <#if renderable == true> + <#if first == false> + , + + <#if val?is_string == true> + "${key}" : "${val}" + + <#if val?is_date == true> + "${key}" : "${val?datetime}" + + <#if val?is_boolean == true> + "${key}" : "${val}" + + <#assign first = false> - "${key}" : "${val}" - <#assign first = true> - } -} \ No newline at end of file +<#if includeChildren && object.children?exists> + , + "children" : + [ + <#assign first = true> + <#list object.children as child> + <#if first == false> + , + + { + <@serialize object=child includeChildren=false includeContent=includeContent/> + } + <#assign first = false> + + ] +<#else> + , + "children" : [ ] + + + \ No newline at end of file diff --git a/config/alfresco/templates/webscripts/org/alfresco/webframework/metadata.get.js b/config/alfresco/templates/webscripts/org/alfresco/webframework/metadata.get.js index 6bc208f4e4..d05e35ef2f 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/webframework/metadata.get.js +++ b/config/alfresco/templates/webscripts/org/alfresco/webframework/metadata.get.js @@ -30,4 +30,5 @@ if(object == null) // store onto model model.object = object; model.mimetype = object.mimetype; -model.properties = object.properties; +model.includeChildren = true; +model.includeContent = false; \ No newline at end of file