To reorganize the modules of existing projects, run the following script from the administration console
var pageDao = serviceManager.lookup(org.ametys.web.repository.page.PageDAO.ROLE);
var query = session.getWorkspace().getQueryManager().createQuery("//element(*, ametys:site)[@ametys:type = 'org.ametys.plugins.workspaces.project.sitetype']/ametys-internal:sitemaps/*", javax.jcr.query.Query.XPATH);
var nodes = query.execute().getNodes();
var count = 0;
var positions = ["index", "calendars", "documents", "forum", "tasks", "wiki"];
while (nodes.hasNext())
{
var node = nodes.next();
var parentId = node.getId();
for (var i=0; i < positions.length; i++)
{
var page = node.getNode(positions[i]);
var pageId = page.getId();
pageDao.movePage("page://" + pageId, "sitemap://" + parentId, i+1);
}
count++;
}
print(count + " sitemaps have been updated");
var pageDao = serviceManager.lookup(org.ametys.web.repository.page.PageDAO.ROLE);
var query = session.getWorkspace().getQueryManager().createQuery("//element(*, ametys:site)[@ametys:type = 'org.ametys.plugins.workspaces.project.sitetype']/ametys-internal:sitemaps/*", javax.jcr.query.Query.XPATH);
var nodes = query.execute().getNodes();
var count = 0;
var positions = ["index", "calendars", "documents", "forum", "tasks", "wiki"];
while (nodes.hasNext())
{
var node = nodes.next();
var parentId = node.getId();
for (var i=0; i < positions.length; i++)
{
var page = node.getNode(positions[i]);
var pageId = page.getId();
pageDao.movePage("page://" + pageId, "sitemap://" + parentId, i+1);
}
count++;
}
print(count + " sitemaps have been updated");
var pageDao = serviceManager.lookup(org.ametys.web.repository.page.PageDAO.ROLE);
var query = session.getWorkspace().getQueryManager().createQuery("//element(*, ametys:site)[@ametys:type = 'org.ametys.plugins.workspaces.project.sitetype']/ametys-internal:sitemaps/*", javax.jcr.query.Query.XPATH);
var nodes = query.execute().getNodes();
var count = 0;
var positions = ["index", "calendars", "documents", "forum", "tasks", "wiki"];
while (nodes.hasNext())
{
var node = nodes.next();
var parentId = node.getId();
for (var i=0; i < positions.length; i++)
{
var page = node.getNode(positions[i]);
var pageId = page.getId();
pageDao.movePage("page://" + pageId, "sitemap://" + parentId, i+1);
}
count++;
}
print(count + " sitemaps have been updated");