06-12-2014 12:50 PM
<webscript>
<shortname>Get all IT Projects</shortname>
<description>Returns a list of active IT Projects</description>
<url>/org/donaanacounty/itprojects?path={path}</url>
<url>/org/donaanacounty/itprojects.xml?path={path}</url>
<format default="xml">extension</format>
<authentication runas="admin">none</authentication>
<transaction>none</transaction>
</webscript>
var path = args.path + "";
if (path.substring(path.length-1, path.length) != "/") {
path = path + "/";
}
var projects = search.luceneSearch("PATH:\""+path+"*\" AND ASPECT:\"dac:itproject\"");
if (projects == null || projects.length == 0) {
status.code = 404;
status.message = "No projects found";
status.redirect = true;
} else {
var projectInfo = new Array();
for (i=0; i < projects.length; i++){
projectInfo[i] = {};
/* dac:itproject properties */
var nr = projects[i].nodeRef.toString().split('/');
projectInfo[i].id = nr[nr.length - 1];
projectInfo[i].title = projects[i].properties["dac:itproject-title"];
projectInfo[i].inceptdate = projects[i].properties["dac:itproject-inceptdate"];
projectInfo[i].completedate = projects[i].properties["dac:itproject-completedate"];
/* dac:itproject associations */
if (projects[i].assocs["dac:itproject-owner"] !== null) {
projectInfo[i].owner = projects[i].assocs["dac:itproject-owner"][0].properties["cm:firstName"] + " " + projects[i].assocs["dac:itproject-owner"][0].properties["cm:lastName"];
}
if (projects[i].assocs["dac:itproject-itmanager"] !== null) {
projectInfo[i].itmanager = projects[i].assocs["dac:itproject-itmanager"][0].properties["cm:firstName"] + " " + projects[i].assocs["dac:itproject-itmanager"][0].properties["cm:lastName"];
}
if (projects[i].properties["dac:itproject-department"] !== null){
projectInfo[i].departments = projects[i].properties["dac:itproject-department"].split(',');
}
if (projects[i].tags !== null){
projectInfo[i].tags = projects[i].tags;
}
if (projects[i].childAssocs["fm:discussion"] !== null){
var comments = new Array();
var discussion = projects[i].childAssocs["fm:discussion"][0].childAssocs["cm:contains"][0].children;
for (j=0; j < discussion.length; j++){
comments[j] = {};
comments[j].creator = discussion[j].properties["cm:creator"];
comments[j].created = discussion[j].properties["cm:created"];
comments[j].modifier = discussion[j].properties["cm:modifier"];
comments[j].modified = discussion[j].properties["cm:modified"];
comments[j].content = discussion[j].content;
}
projectInfo[i].comments = comments;
}
}
model.itprojects = projectInfo;
}
<?xml version="1.0" encoding="UTF-8"?>
<root xmlns:dac="http://www.donaanacounty.org/model/donaanacounty/1.0">
<dac:projects>
<#list itprojects as project>
<dac:project id="${project.id}">
<#if project.title??><dac:title>${project.title}</dac:title></#if>
<#if project.inceptdate??><dac:inceptdate>${project.inceptdate?datetime?string("yyyy-MM-dd")}</dac:inceptdate></#if>
<#if project.completedate??><dac:completedate>${project.completedate?datetime?string("yyyy-MM-dd")}</dac:completedate></#if>
<#if project.owner??><dac:owner>${project.owner}</dac:owner></#if>
<#if project.itmanager??><dac:itmanager>${project.itmanager}</dac:itmanager></#if>
<#if project.departments??>
<dac:departments>
<#list project.departments as department>
<dac:department>${department}</dac:department>
</#list>
</dac:departments>
</#if>
<#if project.tags??>
<dac:tags>
<#list project.tags as tag>
<dac:tag>${tag}</dac:tag>
</#list>
</dac:tags>
</#if>
<#if project.comments??>
<dac:comments>
<#list project.comments as comment>
<dac:comment creator="${comment.creator}" created="${comment.created?datetime?string("yyyy-MM-dd")}" modifier="${comment.modifier}" modified="${comment.modified?datetime?string("yyyy-MM-dd")}">
${comment.content?xml}
</dac:comment>
</#list>
</dac:comments>
</#if>
</dac:project>
</#list>
</dac:projects>
</root>
06-12-2014 12:52 PM
<?xml version="1.0" encoding="UTF-8"?>
<root xmlns:dac="http://www.donaanacounty.org/model/donaanacounty/1.0">
<dac:projects>
<dac:project id="44081c20-7229-437b-866d-082d27b50570">
<dac:title>abc</dac:title>
<dac:inceptdate>2014-06-10</dac:inceptdate>
<dac:completedate>2014-06-28</dac:completedate>
<dac:owner>Alice Beecher</dac:owner>
<dac:itmanager>Mike Jackson</dac:itmanager>
<dac:departments>
<dac:department>BOCC</dac:department>
</dac:departments>
<dac:tags>
<dac:tag>evil</dac:tag>
<dac:tag>good</dac:tag>
</dac:tags>
<dac:comments>
<dac:comment creator="admin" created="2014-06-10" modifier="admin" modified="2014-06-10">
<p>this sucks</p>
</dac:comment>
<dac:comment creator="admin" created="2014-06-10" modifier="admin" modified="2014-06-10">
<p>this really sucks</p>
</dac:comment>
</dac:comments>
</dac:project>
</dac:projects>
</root>
06-12-2014 03:37 PM
06-13-2014 12:05 PM
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.