Technical and graphic migration manual 1.3.0 to 1.4.0
Changing the order of modules
The order of modules is now always the same when a project space is created:
index
calendars
documents
forum
tasks
wiki
To reorganize the modules of existing projects, run the following script from the administration console
Oops!
Copy to clipboard failed. Open the code and copy it manually.
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");
Service
Service
Delete custom_nodetypes.xml
Run the following script to migrate all your project space services. Then rebuild the Live workspace.
Oops!
Copy to clipboard failed. Open the code and copy it manually.
function __getWorkspacesServicesNodes(serviceId)
{
var query = qm.createQuery("//element(*, ametys:zoneItem)[@ametys-internal:type = 'SERVICE' and @ametys-internal:service = 'org.ametys.plugins.workspaces." + serviceId + "']", javax.jcr.query.Query.XPATH);
return query.execute().getNodes();
}
function __migrateService(node, params)
{
var paramsNode = node.getNode("ametys:service_parameters");
var hasChanges = false;
for (var name in params)
{
var hasChanges = false;
var type = params[name];
if (type == 'long')
{
hasChanges = __convertStringPropertyToLong(paramsNode, "ametys:" + name) || hasChanges;
}
else if (type == 'boolean')
{
hasChanges = __convertStringPropertyToBoolean(paramsNode, "ametys:" + name) || hasChanges;
}
}
return hasChanges;
}
function __convertStringPropertyToBoolean(node, propertyName)
{
var hasChanged = false;
if (node.hasProperty(propertyName))
{
var property = node.getProperty(propertyName);
if (property.getType() == 1) // 1 is for string
{
var valueAsString = property.getString();
property.remove();
if (valueAsString == "true")
{
node['setProperty(java.lang.String, boolean)'](propertyName, true);
hasChanged = true;
}
else if (valueAsString == "false")
{
node['setProperty(java.lang.String, boolean)'](propertyName, false);
hasChanged = true;
}
}
}
return hasChanged;
}
function __convertStringPropertyToLong(node, propertyName)
{
var hasChanged = false;
if (node.hasProperty(propertyName))
{
var property = node.getProperty(propertyName);
if (property.getType() == 1) // 1 is for string
{
var valueAsString = property.getString();
property.remove();
if (valueAsString)
{
node['setProperty(java.lang.String, long)'](propertyName, Number(valueAsString));
hasChanged = true;
}
}
}
return hasChanged;
}
function migrateTasksService()
{
var params = {'assigned-to-current-user': 'boolean', 'max-results': 'long', 'results-per-page': 'long', 'enable-add-task': 'boolean'};
var nodes = __getWorkspacesServicesNodes('service.Tasks');
var count = 0;
while (nodes.hasNext())
{
if (__migrateService(nodes.nextNode(), params))
{
count++;
}
}
if (count > 0)
{
session.save();
print(count + " tasks services have been migrated.");
}
}
function migrateFilteredEventsService()
{
var params = {'max-results': 'long', 'results-per-page': 'long', 'search-period': 'long', 'enable-creation': 'boolean'};
var nodes = __getWorkspacesServicesNodes('service.FilteredEvents');
var count = 0;
while (nodes.hasNext())
{
if (__migrateService(nodes.nextNode(), params))
{
count++;
}
}
if (count > 0)
{
session.save();
print(count + " filtered events services have been migrated.");
}
}
function migrateProjectsCatalogueService()
{
var params = {'memberOnly': 'boolean', 'use_old_categories_system': 'boolean', 'display_restricted_pages': 'boolean', 'ping_activated': 'boolean'};
var nodes = __getWorkspacesServicesNodes('service.ProjectsCatalogue');
var count = 0;
while (nodes.hasNext())
{
if (__migrateService(nodes.nextNode(), params))
{
count++;
}
}
if (count > 0)
{
session.save();
print(count + " projects catalogue services have been migrated.");
}
}
function migrateActivityStreamService()
{
var params = {'activities-per-page': 'long', 'max-activities': 'long', 'chronological-order': 'boolean'};
var nodes = __getWorkspacesServicesNodes('service.ActivityStream');
var count = 0;
while (nodes.hasNext())
{
if (__migrateService(nodes.nextNode(), params))
{
count++;
}
}
if (count > 0)
{
session.save();
print(count + " activity stream services have been migrated.");
}
}
function migrateMembersService()
{
var params = {'nbMembers': 'long', 'expandGroup': 'boolean'};
var nodes = __getWorkspacesServicesNodes('service.Members');
var count = 0;
while (nodes.hasNext())
{
if (__migrateService(nodes.nextNode(), params))
{
count++;
}
}
if (count > 0)
{
session.save();
print(count + " members services have been migrated.");
}
}
function migrateModuleMembersService()
{
var params = {'results-per-page': 'long'};
var nodes = __getWorkspacesServicesNodes('module.Members');
var count = 0;
while (nodes.hasNext())
{
if (__migrateService(nodes.nextNode(), params))
{
count++;
}
}
if (count > 0)
{
session.save();
print(count + " module members services have been migrated.");
}
}
function migrateSimpleFilteredEventsService()
{
var params = {'max-results': 'long', 'search-period': 'long'};
var nodes = __getWorkspacesServicesNodes('service.simple.FilteredEvents');
var count = 0;
while (nodes.hasNext())
{
if (__migrateService(nodes.nextNode(), params))
{
count++;
}
}
if (count > 0)
{
session.save();
print(count + " simple filtered events services have been migrated.");
}
}
function migrateSimpleTasksService()
{
var params = {'max-results': 'long'};
var nodes = __getWorkspacesServicesNodes('service.simple.Tasks');
var count = 0;
while (nodes.hasNext())
{
if (__migrateService(nodes.nextNode(), params))
{
count++;
}
}
if (count > 0)
{
session.save();
print(count + " simple tasks services have been migrated.");
}
}
function migrateSimpleDocumentsService()
{
var params = {'max-results': 'long'};
var nodes = __getWorkspacesServicesNodes('service.simple.Documents');
var count = 0;
while (nodes.hasNext())
{
if (__migrateService(nodes.nextNode(), params))
{
count++;
}
}
if (count > 0)
{
session.save();
print(count + " simple documents services have been migrated.");
}
}
function migrateSimpleProjectsCatalogueService()
{
var params = {'max-results': 'long', 'memberOnly': 'boolean'};
var nodes = __getWorkspacesServicesNodes('service.simple.ProjectsCatalogue');
var count = 0;
while (nodes.hasNext())
{
if (__migrateService(nodes.nextNode(), params))
{
count++;
}
}
if (count > 0)
{
session.save();
print(count + " simple projects catalogue services have been migrated.");
}
}
function migrateSimpleActivityStreamService()
{
var params = {'max-results': 'long'};
var nodes = __getWorkspacesServicesNodes('service.simple.ActivityStream');
var count = 0;
while (nodes.hasNext())
{
if (__migrateService(nodes.nextNode(), params))
{
count++;
}
}
if (count > 0)
{
session.save();
print(count + " simple activity stream services have been migrated.");
}
}
function migrateProjectManagers()
{
var query = qm.createQuery("//element(*, ametys:project)", javax.jcr.query.Query.XPATH);
var projectNodes = query.execute().getNodes();
var count = 0;
while (projectNodes.hasNext())
{
var hasChanged = false;
var projectNode = projectNodes.nextNode();
var managersNodeName = 'ametys:managers';
if (!projectNode.hasNode(managersNodeName))
{
var managersNode = projectNode.addNode(managersNodeName, 'ametys:multipleItem');
managersNode.setProperty('ametys-internal:typeId', 'user');
hasChanged = true;
}
var managerNodeName = 'ametys:manager';
if (projectNode.hasNode(managerNodeName))
{
var managerNodes = projectNode.getNodes(managerNodeName);
var index = 1;
while (managerNodes.hasNext())
{
var managerNode = managerNodes.nextNode();
session.move(managerNode.getPath(), managerNode.getParent().getPath() + '/' + managersNodeName + '/ametys:' + index++);
}
hasChanged = true;
}
if (hasChanged)
{
count++;
}
}
if (count > 0)
{
session.save();
print(count + " workspace projects have been migrated.");
}
}
var qm = session.getWorkspace().getQueryManager();
migrateTasksService();
migrateFilteredEventsService();
migrateProjectsCatalogueService();
migrateActivityStreamService();
migrateMembersService();
migrateModuleMembersService();
migrateSimpleFilteredEventsService();
migrateSimpleTasksService();
migrateSimpleDocumentsService();
migrateSimpleProjectsCatalogueService();
migrateSimpleActivityStreamService();
migrateProjectManagers();
print("End of migration, you can rebuild the Live workspace");
function __getWorkspacesServicesNodes(serviceId)
{
var query = qm.createQuery("//element(*, ametys:zoneItem)[@ametys-internal:type = 'SERVICE' and @ametys-internal:service = 'org.ametys.plugins.workspaces." + serviceId + "']", javax.jcr.query.Query.XPATH);
return query.execute().getNodes();
}
function __migrateService(node, params)
{
var paramsNode = node.getNode("ametys:service_parameters");
var hasChanges = false;
for (var name in params)
{
var hasChanges = false;
var type = params[name];
if (type == 'long')
{
hasChanges = __convertStringPropertyToLong(paramsNode, "ametys:" + name) || hasChanges;
}
else if (type == 'boolean')
{
hasChanges = __convertStringPropertyToBoolean(paramsNode, "ametys:" + name) || hasChanges;
}
}
return hasChanges;
}
function __convertStringPropertyToBoolean(node, propertyName)
{
var hasChanged = false;
if (node.hasProperty(propertyName))
{
var property = node.getProperty(propertyName);
if (property.getType() == 1) // 1 is for string
{
var valueAsString = property.getString();
property.remove();
if (valueAsString == "true")
{
node['setProperty(java.lang.String, boolean)'](propertyName, true);
hasChanged = true;
}
else if (valueAsString == "false")
{
node['setProperty(java.lang.String, boolean)'](propertyName, false);
hasChanged = true;
}
}
}
return hasChanged;
}
function __convertStringPropertyToLong(node, propertyName)
{
var hasChanged = false;
if (node.hasProperty(propertyName))
{
var property = node.getProperty(propertyName);
if (property.getType() == 1) // 1 is for string
{
var valueAsString = property.getString();
property.remove();
if (valueAsString)
{
node['setProperty(java.lang.String, long)'](propertyName, Number(valueAsString));
hasChanged = true;
}
}
}
return hasChanged;
}
function migrateTasksService()
{
var params = {'assigned-to-current-user': 'boolean', 'max-results': 'long', 'results-per-page': 'long', 'enable-add-task': 'boolean'};
var nodes = __getWorkspacesServicesNodes('service.Tasks');
var count = 0;
while (nodes.hasNext())
{
if (__migrateService(nodes.nextNode(), params))
{
count++;
}
}
if (count > 0)
{
session.save();
print(count + " tasks services have been migrated.");
}
}
function migrateFilteredEventsService()
{
var params = {'max-results': 'long', 'results-per-page': 'long', 'search-period': 'long', 'enable-creation': 'boolean'};
var nodes = __getWorkspacesServicesNodes('service.FilteredEvents');
var count = 0;
while (nodes.hasNext())
{
if (__migrateService(nodes.nextNode(), params))
{
count++;
}
}
if (count > 0)
{
session.save();
print(count + " filtered events services have been migrated.");
}
}
function migrateProjectsCatalogueService()
{
var params = {'memberOnly': 'boolean', 'use_old_categories_system': 'boolean', 'display_restricted_pages': 'boolean', 'ping_activated': 'boolean'};
var nodes = __getWorkspacesServicesNodes('service.ProjectsCatalogue');
var count = 0;
while (nodes.hasNext())
{
if (__migrateService(nodes.nextNode(), params))
{
count++;
}
}
if (count > 0)
{
session.save();
print(count + " projects catalogue services have been migrated.");
}
}
function migrateActivityStreamService()
{
var params = {'activities-per-page': 'long', 'max-activities': 'long', 'chronological-order': 'boolean'};
var nodes = __getWorkspacesServicesNodes('service.ActivityStream');
var count = 0;
while (nodes.hasNext())
{
if (__migrateService(nodes.nextNode(), params))
{
count++;
}
}
if (count > 0)
{
session.save();
print(count + " activity stream services have been migrated.");
}
}
function migrateMembersService()
{
var params = {'nbMembers': 'long', 'expandGroup': 'boolean'};
var nodes = __getWorkspacesServicesNodes('service.Members');
var count = 0;
while (nodes.hasNext())
{
if (__migrateService(nodes.nextNode(), params))
{
count++;
}
}
if (count > 0)
{
session.save();
print(count + " members services have been migrated.");
}
}
function migrateModuleMembersService()
{
var params = {'results-per-page': 'long'};
var nodes = __getWorkspacesServicesNodes('module.Members');
var count = 0;
while (nodes.hasNext())
{
if (__migrateService(nodes.nextNode(), params))
{
count++;
}
}
if (count > 0)
{
session.save();
print(count + " module members services have been migrated.");
}
}
function migrateSimpleFilteredEventsService()
{
var params = {'max-results': 'long', 'search-period': 'long'};
var nodes = __getWorkspacesServicesNodes('service.simple.FilteredEvents');
var count = 0;
while (nodes.hasNext())
{
if (__migrateService(nodes.nextNode(), params))
{
count++;
}
}
if (count > 0)
{
session.save();
print(count + " simple filtered events services have been migrated.");
}
}
function migrateSimpleTasksService()
{
var params = {'max-results': 'long'};
var nodes = __getWorkspacesServicesNodes('service.simple.Tasks');
var count = 0;
while (nodes.hasNext())
{
if (__migrateService(nodes.nextNode(), params))
{
count++;
}
}
if (count > 0)
{
session.save();
print(count + " simple tasks services have been migrated.");
}
}
function migrateSimpleDocumentsService()
{
var params = {'max-results': 'long'};
var nodes = __getWorkspacesServicesNodes('service.simple.Documents');
var count = 0;
while (nodes.hasNext())
{
if (__migrateService(nodes.nextNode(), params))
{
count++;
}
}
if (count > 0)
{
session.save();
print(count + " simple documents services have been migrated.");
}
}
function migrateSimpleProjectsCatalogueService()
{
var params = {'max-results': 'long', 'memberOnly': 'boolean'};
var nodes = __getWorkspacesServicesNodes('service.simple.ProjectsCatalogue');
var count = 0;
while (nodes.hasNext())
{
if (__migrateService(nodes.nextNode(), params))
{
count++;
}
}
if (count > 0)
{
session.save();
print(count + " simple projects catalogue services have been migrated.");
}
}
function migrateSimpleActivityStreamService()
{
var params = {'max-results': 'long'};
var nodes = __getWorkspacesServicesNodes('service.simple.ActivityStream');
var count = 0;
while (nodes.hasNext())
{
if (__migrateService(nodes.nextNode(), params))
{
count++;
}
}
if (count > 0)
{
session.save();
print(count + " simple activity stream services have been migrated.");
}
}
function migrateProjectManagers()
{
var query = qm.createQuery("//element(*, ametys:project)", javax.jcr.query.Query.XPATH);
var projectNodes = query.execute().getNodes();
var count = 0;
while (projectNodes.hasNext())
{
var hasChanged = false;
var projectNode = projectNodes.nextNode();
var managersNodeName = 'ametys:managers';
if (!projectNode.hasNode(managersNodeName))
{
var managersNode = projectNode.addNode(managersNodeName, 'ametys:multipleItem');
managersNode.setProperty('ametys-internal:typeId', 'user');
hasChanged = true;
}
var managerNodeName = 'ametys:manager';
if (projectNode.hasNode(managerNodeName))
{
var managerNodes = projectNode.getNodes(managerNodeName);
var index = 1;
while (managerNodes.hasNext())
{
var managerNode = managerNodes.nextNode();
session.move(managerNode.getPath(), managerNode.getParent().getPath() + '/' + managersNodeName + '/ametys:' + index++);
}
hasChanged = true;
}
if (hasChanged)
{
count++;
}
}
if (count > 0)
{
session.save();
print(count + " workspace projects have been migrated.");
}
}
var qm = session.getWorkspace().getQueryManager();
migrateTasksService();
migrateFilteredEventsService();
migrateProjectsCatalogueService();
migrateActivityStreamService();
migrateMembersService();
migrateModuleMembersService();
migrateSimpleFilteredEventsService();
migrateSimpleTasksService();
migrateSimpleDocumentsService();
migrateSimpleProjectsCatalogueService();
migrateSimpleActivityStreamService();
migrateProjectManagers();
print("End of migration, you can rebuild the Live workspace");
function __getWorkspacesServicesNodes(serviceId)
{
var query = qm.createQuery("//element(*, ametys:zoneItem)[@ametys-internal:type = 'SERVICE' and @ametys-internal:service = 'org.ametys.plugins.workspaces." + serviceId + "']", javax.jcr.query.Query.XPATH);
return query.execute().getNodes();
}
function __migrateService(node, params)
{
var paramsNode = node.getNode("ametys:service_parameters");
var hasChanges = false;
for (var name in params)
{
var hasChanges = false;
var type = params[name];
if (type == 'long')
{
hasChanges = __convertStringPropertyToLong(paramsNode, "ametys:" + name) || hasChanges;
}
else if (type == 'boolean')
{
hasChanges = __convertStringPropertyToBoolean(paramsNode, "ametys:" + name) || hasChanges;
}
}
return hasChanges;
}
function __convertStringPropertyToBoolean(node, propertyName)
{
var hasChanged = false;
if (node.hasProperty(propertyName))
{
var property = node.getProperty(propertyName);
if (property.getType() == 1) // 1 is for string
{
var valueAsString = property.getString();
property.remove();
if (valueAsString == "true")
{
node['setProperty(java.lang.String, boolean)'](propertyName, true);
hasChanged = true;
}
else if (valueAsString == "false")
{
node['setProperty(java.lang.String, boolean)'](propertyName, false);
hasChanged = true;
}
}
}
return hasChanged;
}
function __convertStringPropertyToLong(node, propertyName)
{
var hasChanged = false;
if (node.hasProperty(propertyName))
{
var property = node.getProperty(propertyName);
if (property.getType() == 1) // 1 is for string
{
var valueAsString = property.getString();
property.remove();
if (valueAsString)
{
node['setProperty(java.lang.String, long)'](propertyName, Number(valueAsString));
hasChanged = true;
}
}
}
return hasChanged;
}
function migrateTasksService()
{
var params = {'assigned-to-current-user': 'boolean', 'max-results': 'long', 'results-per-page': 'long', 'enable-add-task': 'boolean'};
var nodes = __getWorkspacesServicesNodes('service.Tasks');
var count = 0;
while (nodes.hasNext())
{
if (__migrateService(nodes.nextNode(), params))
{
count++;
}
}
if (count > 0)
{
session.save();
print(count + " tasks services have been migrated.");
}
}
function migrateFilteredEventsService()
{
var params = {'max-results': 'long', 'results-per-page': 'long', 'search-period': 'long', 'enable-creation': 'boolean'};
var nodes = __getWorkspacesServicesNodes('service.FilteredEvents');
var count = 0;
while (nodes.hasNext())
{
if (__migrateService(nodes.nextNode(), params))
{
count++;
}
}
if (count > 0)
{
session.save();
print(count + " filtered events services have been migrated.");
}
}
function migrateProjectsCatalogueService()
{
var params = {'memberOnly': 'boolean', 'use_old_categories_system': 'boolean', 'display_restricted_pages': 'boolean', 'ping_activated': 'boolean'};
var nodes = __getWorkspacesServicesNodes('service.ProjectsCatalogue');
var count = 0;
while (nodes.hasNext())
{
if (__migrateService(nodes.nextNode(), params))
{
count++;
}
}
if (count > 0)
{
session.save();
print(count + " projects catalogue services have been migrated.");
}
}
function migrateActivityStreamService()
{
var params = {'activities-per-page': 'long', 'max-activities': 'long', 'chronological-order': 'boolean'};
var nodes = __getWorkspacesServicesNodes('service.ActivityStream');
var count = 0;
while (nodes.hasNext())
{
if (__migrateService(nodes.nextNode(), params))
{
count++;
}
}
if (count > 0)
{
session.save();
print(count + " activity stream services have been migrated.");
}
}
function migrateMembersService()
{
var params = {'nbMembers': 'long', 'expandGroup': 'boolean'};
var nodes = __getWorkspacesServicesNodes('service.Members');
var count = 0;
while (nodes.hasNext())
{
if (__migrateService(nodes.nextNode(), params))
{
count++;
}
}
if (count > 0)
{
session.save();
print(count + " members services have been migrated.");
}
}
function migrateModuleMembersService()
{
var params = {'results-per-page': 'long'};
var nodes = __getWorkspacesServicesNodes('module.Members');
var count = 0;
while (nodes.hasNext())
{
if (__migrateService(nodes.nextNode(), params))
{
count++;
}
}
if (count > 0)
{
session.save();
print(count + " module members services have been migrated.");
}
}
function migrateSimpleFilteredEventsService()
{
var params = {'max-results': 'long', 'search-period': 'long'};
var nodes = __getWorkspacesServicesNodes('service.simple.FilteredEvents');
var count = 0;
while (nodes.hasNext())
{
if (__migrateService(nodes.nextNode(), params))
{
count++;
}
}
if (count > 0)
{
session.save();
print(count + " simple filtered events services have been migrated.");
}
}
function migrateSimpleTasksService()
{
var params = {'max-results': 'long'};
var nodes = __getWorkspacesServicesNodes('service.simple.Tasks');
var count = 0;
while (nodes.hasNext())
{
if (__migrateService(nodes.nextNode(), params))
{
count++;
}
}
if (count > 0)
{
session.save();
print(count + " simple tasks services have been migrated.");
}
}
function migrateSimpleDocumentsService()
{
var params = {'max-results': 'long'};
var nodes = __getWorkspacesServicesNodes('service.simple.Documents');
var count = 0;
while (nodes.hasNext())
{
if (__migrateService(nodes.nextNode(), params))
{
count++;
}
}
if (count > 0)
{
session.save();
print(count + " simple documents services have been migrated.");
}
}
function migrateSimpleProjectsCatalogueService()
{
var params = {'max-results': 'long', 'memberOnly': 'boolean'};
var nodes = __getWorkspacesServicesNodes('service.simple.ProjectsCatalogue');
var count = 0;
while (nodes.hasNext())
{
if (__migrateService(nodes.nextNode(), params))
{
count++;
}
}
if (count > 0)
{
session.save();
print(count + " simple projects catalogue services have been migrated.");
}
}
function migrateSimpleActivityStreamService()
{
var params = {'max-results': 'long'};
var nodes = __getWorkspacesServicesNodes('service.simple.ActivityStream');
var count = 0;
while (nodes.hasNext())
{
if (__migrateService(nodes.nextNode(), params))
{
count++;
}
}
if (count > 0)
{
session.save();
print(count + " simple activity stream services have been migrated.");
}
}
function migrateProjectManagers()
{
var query = qm.createQuery("//element(*, ametys:project)", javax.jcr.query.Query.XPATH);
var projectNodes = query.execute().getNodes();
var count = 0;
while (projectNodes.hasNext())
{
var hasChanged = false;
var projectNode = projectNodes.nextNode();
var managersNodeName = 'ametys:managers';
if (!projectNode.hasNode(managersNodeName))
{
var managersNode = projectNode.addNode(managersNodeName, 'ametys:multipleItem');
managersNode.setProperty('ametys-internal:typeId', 'user');
hasChanged = true;
}
var managerNodeName = 'ametys:manager';
if (projectNode.hasNode(managerNodeName))
{
var managerNodes = projectNode.getNodes(managerNodeName);
var index = 1;
while (managerNodes.hasNext())
{
var managerNode = managerNodes.nextNode();
session.move(managerNode.getPath(), managerNode.getParent().getPath() + '/' + managersNodeName + '/ametys:' + index++);
}
hasChanged = true;
}
if (hasChanged)
{
count++;
}
}
if (count > 0)
{
session.save();
print(count + " workspace projects have been migrated.");
}
}
var qm = session.getWorkspace().getQueryManager();
migrateTasksService();
migrateFilteredEventsService();
migrateProjectsCatalogueService();
migrateActivityStreamService();
migrateMembersService();
migrateModuleMembersService();
migrateSimpleFilteredEventsService();
migrateSimpleTasksService();
migrateSimpleDocumentsService();
migrateSimpleProjectsCatalogueService();
migrateSimpleActivityStreamService();
migrateProjectManagers();
print("End of migration, you can rebuild the Live workspace");
Project Space Catalog Service
Project Space Catalog Service
A new parameter has been added to the project space catalog service (angular service): "Use old categories".
You can manually configure your Catalog services to enable this setting, or go to script JCR which will automatically configure your Catalog services to add the setting and enable it:
Oops!
Copy to clipboard failed. Open the code and copy it manually.
var qm = session.getWorkspace().getQueryManager();
var query = qm.createQuery("//element(*, ametys:zoneItem)[@ametys-internal:type='SERVICE' and @ametys-internal:service='org.ametys.plugins.workspaces.service.ProjectsCatalogue']/ametys:service_parameters", javax.jcr.query.Query.XPATH);
it = query.execute().getNodes();
var count = 0;
while (it.hasNext())
{
var node = it.nextNode();
if (!node.hasProperty("ametys:use_old_categories_system"))
{
node.setProperty("ametys:use_old_categories_system", "true");
node.save();
count++;
}
}
print(count + " services have been updated");
var qm = session.getWorkspace().getQueryManager();
var query = qm.createQuery("//element(*, ametys:zoneItem)[@ametys-internal:type='SERVICE' and @ametys-internal:service='org.ametys.plugins.workspaces.service.ProjectsCatalogue']/ametys:service_parameters", javax.jcr.query.Query.XPATH);
it = query.execute().getNodes();
var count = 0;
while (it.hasNext())
{
var node = it.nextNode();
if (!node.hasProperty("ametys:use_old_categories_system"))
{
node.setProperty("ametys:use_old_categories_system", "true");
node.save();
count++;
}
}
print(count + " services have been updated");
var qm = session.getWorkspace().getQueryManager();
var query = qm.createQuery("//element(*, ametys:zoneItem)[@ametys-internal:type='SERVICE' and @ametys-internal:service='org.ametys.plugins.workspaces.service.ProjectsCatalogue']/ametys:service_parameters", javax.jcr.query.Query.XPATH);
it = query.execute().getNodes();
var count = 0;
while (it.hasNext())
{
var node = it.nextNode();
if (!node.hasProperty("ametys:use_old_categories_system"))
{
node.setProperty("ametys:use_old_categories_system", "true");
node.save();
count++;
}
}
print(count + " services have been updated");