Cette page ne doit être appliquée que si l'application vous demande de passer la migration manuelle plugin.workspaces.jcr.v20210702T0000-WORKSPACES-858
Suppression des anciennes tâches
Voici le script pour supprimer les tâches de l'ancien module. Dans un premier temps passer ce script avec la variable saveChanges à false pour lister les tâches qui vont être supprimées.
Ensuite mettre saveChanges à true pour supprimer les tâches.
Oups !
La copie dans le presse papier a échouée. Ouvrez le code et copier-le manuellement.
let saveChanges = false;
let logger = Ametys.getLogger("org.ametys.core.migration.MigrationExtensionPoint.workspaces");
let projectManager = Ametys.serviceManager.lookup(org.ametys.plugins.workspaces.project.ProjectManager.ROLE);
let workspaceModuleExtensionPoint = Ametys.serviceManager.lookup(org.ametys.plugins.workspaces.project.modules.WorkspaceModuleExtensionPoint.ROLE);
projectManager.getProjects().forEach(function (project)
{
let module = workspaceModuleExtensionPoint.getModule('org.ametys.plugins.workspaces.tasks.TasksWorkspaceModule');
let pages = projectManager.getModulePages(project, module);
for (let page of pages)
{
migratePage(project, page);
try
{
let liveProject = Repository.resolver.resolveById(project.getId(), Repository.liveSession);
let livePage = Repository.resolver.resolveById(page.getId(), Repository.liveSession);
migratePage(liveProject, livePage);
}
catch (e) {/* No page live */}
}
});
function migratePage(project, page)
{
if (page.getNode().hasNode("ametys-internal:zones/default/ametys-internal:zoneItems/ametys:zoneItem/ametys:service_parameters"))
{
let serviceNode = page.getNode().getNode("ametys-internal:zones/default/ametys-internal:zoneItems/ametys:zoneItem/ametys:service_parameters");
if (serviceNode.getProperty("ametys:xslt").getString() == "pages/services/modules/taskslist/task-default.xsl")
{
let projectRootNode = project.getExplorerRootNode();
let taskNode = projectRootNode.getChild("tasks");
if (taskNode.hasChild("default"))
{
logger.info("Delete tasks for project '" + project.getTitle() + "'");
logger.info("Delete section default");
let taskNode = projectRootNode.getChild("tasks");
let tasksList = taskNode.getChild("default");
for (let task of tasksList.getChildren())
{
logger.info("Delete task " + task.getLabel());
}
if (saveChanges)
{
tasksList.remove();
projectRootNode.saveChanges();
}
}
}
}
}
let saveChanges = false;
let logger = Ametys.getLogger("org.ametys.core.migration.MigrationExtensionPoint.workspaces");
let projectManager = Ametys.serviceManager.lookup(org.ametys.plugins.workspaces.project.ProjectManager.ROLE);
let workspaceModuleExtensionPoint = Ametys.serviceManager.lookup(org.ametys.plugins.workspaces.project.modules.WorkspaceModuleExtensionPoint.ROLE);
projectManager.getProjects().forEach(function (project)
{
let module = workspaceModuleExtensionPoint.getModule('org.ametys.plugins.workspaces.tasks.TasksWorkspaceModule');
let pages = projectManager.getModulePages(project, module);
for (let page of pages)
{
migratePage(project, page);
try
{
let liveProject = Repository.resolver.resolveById(project.getId(), Repository.liveSession);
let livePage = Repository.resolver.resolveById(page.getId(), Repository.liveSession);
migratePage(liveProject, livePage);
}
catch (e) {/* No page live */}
}
});
function migratePage(project, page)
{
if (page.getNode().hasNode("ametys-internal:zones/default/ametys-internal:zoneItems/ametys:zoneItem/ametys:service_parameters"))
{
let serviceNode = page.getNode().getNode("ametys-internal:zones/default/ametys-internal:zoneItems/ametys:zoneItem/ametys:service_parameters");
if (serviceNode.getProperty("ametys:xslt").getString() == "pages/services/modules/taskslist/task-default.xsl")
{
let projectRootNode = project.getExplorerRootNode();
let taskNode = projectRootNode.getChild("tasks");
if (taskNode.hasChild("default"))
{
logger.info("Delete tasks for project '" + project.getTitle() + "'");
logger.info("Delete section default");
let taskNode = projectRootNode.getChild("tasks");
let tasksList = taskNode.getChild("default");
for (let task of tasksList.getChildren())
{
logger.info("Delete task " + task.getLabel());
}
if (saveChanges)
{
tasksList.remove();
projectRootNode.saveChanges();
}
}
}
}
}
let saveChanges = false;
let logger = Ametys.getLogger("org.ametys.core.migration.MigrationExtensionPoint.workspaces");
let projectManager = Ametys.serviceManager.lookup(org.ametys.plugins.workspaces.project.ProjectManager.ROLE);
let workspaceModuleExtensionPoint = Ametys.serviceManager.lookup(org.ametys.plugins.workspaces.project.modules.WorkspaceModuleExtensionPoint.ROLE);
projectManager.getProjects().forEach(function (project)
{
let module = workspaceModuleExtensionPoint.getModule('org.ametys.plugins.workspaces.tasks.TasksWorkspaceModule');
let pages = projectManager.getModulePages(project, module);
for (let page of pages)
{
migratePage(project, page);
try
{
let liveProject = Repository.resolver.resolveById(project.getId(), Repository.liveSession);
let livePage = Repository.resolver.resolveById(page.getId(), Repository.liveSession);
migratePage(liveProject, livePage);
}
catch (e) {/* No page live */}
}
});
function migratePage(project, page)
{
if (page.getNode().hasNode("ametys-internal:zones/default/ametys-internal:zoneItems/ametys:zoneItem/ametys:service_parameters"))
{
let serviceNode = page.getNode().getNode("ametys-internal:zones/default/ametys-internal:zoneItems/ametys:zoneItem/ametys:service_parameters");
if (serviceNode.getProperty("ametys:xslt").getString() == "pages/services/modules/taskslist/task-default.xsl")
{
let projectRootNode = project.getExplorerRootNode();
let taskNode = projectRootNode.getChild("tasks");
if (taskNode.hasChild("default"))
{
logger.info("Delete tasks for project '" + project.getTitle() + "'");
logger.info("Delete section default");
let taskNode = projectRootNode.getChild("tasks");
let tasksList = taskNode.getChild("default");
for (let task of tasksList.getChildren())
{
logger.info("Delete task " + task.getLabel());
}
if (saveChanges)
{
tasksList.remove();
projectRootNode.saveChanges();
}
}
}
}
}