Les listes des valeurs et libellés possibles pour chacun des champs étant personnalisables, il est possible que vos anciennes valeurs ne correspondent pas exactement aux scripts fournis. Modifiez au besoin la "map" de correspondance en début de script pour faire votre propre correspondance.
Type de diplôme (degree.xml)
Oups !
La copie dans le presse papier a échouée. Ouvrez le code et copier-le manuellement.
// Correspondance {"ancienne valeur", "nouvelle valeur"}
var mapping = {
'CE': '2', // Certificat d école
'HDR': '3', // Habilitation à diriger des recherches
'CED': 'AC', // Capacité en droit
'DUT': 'CB', // DUT
'DEUG': 'CC', // DEUG
'DEUST': 'CD', // DEUST
'DEUP': 'CJ', // DEUP
'PACES': 'CY', // PACES
'LIC': 'DC', // Licence
'MAIT': 'EC', // Maîtrise
'MAITST': 'ED', // MST
'MSG': 'EE', // MSG
'MIAGE': 'EF', // MIAGE
'MSBM': 'EN', // Maîtrise de sciences biologiques et médicales
'DPRBM': 'ER', // Diplôme préparatoire à la recherche biomédicale
'DEA': 'FC', // DEA
'DESS': 'FD', // DESS
'MAG': 'FE', // Magistère
'DRT': 'FF', // Diplome de recherche technologique
'IC': 'FI', // Formation ingénieur
'NFI': 'FN', // Nouvelles formations d ingénieurs
'CECSMO': 'JB', // C.E.C.S.M.O
'CM': 'KG', // Capacité en médecine
'DDEDA': 'PC', // Diplôme d état audio-prothèse
'DESF': 'PE', // Diplôme d état sage-femme
'LILMD': 'XA', // Licence LMD
'MLMD': 'XB', // Master LMD
'DU': 'YA', // Doctorat d université
'IS': 'YI', // Formation ingénieur spécialisé
'DISM': 'YJ', // DIS médecine
'DISP': 'YL', // DIS pharmacie
'AFS': 'YM', // Attestation de formation spécialisée
'AFSA': 'YN', // Attestation de formation spécialisée approfondie
'DNO': 'ZD' // Diplôme national d oenologie
}
// Nom de la métadonnée à modifier
var metadataName = "ametys:degree";
var query = session.getWorkspace().getQueryManager().createQuery("//element(*, ametys:defaultContent)[@ametys-internal:contentType = 'org.ametys.plugins.odf.Content.program']", javax.jcr.query.Query.XPATH);
var nodes = query.execute().getNodes();
var count = 0;
while (nodes.hasNext())
{
var program = nodes.next();
var needSave = false;
if (program.hasProperty(metadataName))
{
var oldValue = program.getProperty(metadataName).getValue().getString();
if (mapping[oldValue] != null)
{
program.setProperty(metadataName, mapping[oldValue]);
needSave = true;
}
}
if (program.hasProperty(metadataName + "_remote"))
{
var oldValue = program.getProperty(metadataName + "_remote").getValue().getString();
if (mapping[oldValue] != null)
{
program.setProperty(metadataName + "_remote", mapping[oldValue]);
needSave = true;
}
}
if (needSave)
{
program.save();
count++;
}
}
println(count + " programs has been modified");
// Correspondance {"ancienne valeur", "nouvelle valeur"}
var mapping = {
'CE': '2', // Certificat d école
'HDR': '3', // Habilitation à diriger des recherches
'CED': 'AC', // Capacité en droit
'DUT': 'CB', // DUT
'DEUG': 'CC', // DEUG
'DEUST': 'CD', // DEUST
'DEUP': 'CJ', // DEUP
'PACES': 'CY', // PACES
'LIC': 'DC', // Licence
'MAIT': 'EC', // Maîtrise
'MAITST': 'ED', // MST
'MSG': 'EE', // MSG
'MIAGE': 'EF', // MIAGE
'MSBM': 'EN', // Maîtrise de sciences biologiques et médicales
'DPRBM': 'ER', // Diplôme préparatoire à la recherche biomédicale
'DEA': 'FC', // DEA
'DESS': 'FD', // DESS
'MAG': 'FE', // Magistère
'DRT': 'FF', // Diplome de recherche technologique
'IC': 'FI', // Formation ingénieur
'NFI': 'FN', // Nouvelles formations d ingénieurs
'CECSMO': 'JB', // C.E.C.S.M.O
'CM': 'KG', // Capacité en médecine
'DDEDA': 'PC', // Diplôme d état audio-prothèse
'DESF': 'PE', // Diplôme d état sage-femme
'LILMD': 'XA', // Licence LMD
'MLMD': 'XB', // Master LMD
'DU': 'YA', // Doctorat d université
'IS': 'YI', // Formation ingénieur spécialisé
'DISM': 'YJ', // DIS médecine
'DISP': 'YL', // DIS pharmacie
'AFS': 'YM', // Attestation de formation spécialisée
'AFSA': 'YN', // Attestation de formation spécialisée approfondie
'DNO': 'ZD' // Diplôme national d oenologie
}
// Nom de la métadonnée à modifier
var metadataName = "ametys:degree";
var query = session.getWorkspace().getQueryManager().createQuery("//element(*, ametys:defaultContent)[@ametys-internal:contentType = 'org.ametys.plugins.odf.Content.program']", javax.jcr.query.Query.XPATH);
var nodes = query.execute().getNodes();
var count = 0;
while (nodes.hasNext())
{
var program = nodes.next();
var needSave = false;
if (program.hasProperty(metadataName))
{
var oldValue = program.getProperty(metadataName).getValue().getString();
if (mapping[oldValue] != null)
{
program.setProperty(metadataName, mapping[oldValue]);
needSave = true;
}
}
if (program.hasProperty(metadataName + "_remote"))
{
var oldValue = program.getProperty(metadataName + "_remote").getValue().getString();
if (mapping[oldValue] != null)
{
program.setProperty(metadataName + "_remote", mapping[oldValue]);
needSave = true;
}
}
if (needSave)
{
program.save();
count++;
}
}
println(count + " programs has been modified");
// Correspondance {"ancienne valeur", "nouvelle valeur"}
var mapping = {
'CE': '2', // Certificat d école
'HDR': '3', // Habilitation à diriger des recherches
'CED': 'AC', // Capacité en droit
'DUT': 'CB', // DUT
'DEUG': 'CC', // DEUG
'DEUST': 'CD', // DEUST
'DEUP': 'CJ', // DEUP
'PACES': 'CY', // PACES
'LIC': 'DC', // Licence
'MAIT': 'EC', // Maîtrise
'MAITST': 'ED', // MST
'MSG': 'EE', // MSG
'MIAGE': 'EF', // MIAGE
'MSBM': 'EN', // Maîtrise de sciences biologiques et médicales
'DPRBM': 'ER', // Diplôme préparatoire à la recherche biomédicale
'DEA': 'FC', // DEA
'DESS': 'FD', // DESS
'MAG': 'FE', // Magistère
'DRT': 'FF', // Diplome de recherche technologique
'IC': 'FI', // Formation ingénieur
'NFI': 'FN', // Nouvelles formations d ingénieurs
'CECSMO': 'JB', // C.E.C.S.M.O
'CM': 'KG', // Capacité en médecine
'DDEDA': 'PC', // Diplôme d état audio-prothèse
'DESF': 'PE', // Diplôme d état sage-femme
'LILMD': 'XA', // Licence LMD
'MLMD': 'XB', // Master LMD
'DU': 'YA', // Doctorat d université
'IS': 'YI', // Formation ingénieur spécialisé
'DISM': 'YJ', // DIS médecine
'DISP': 'YL', // DIS pharmacie
'AFS': 'YM', // Attestation de formation spécialisée
'AFSA': 'YN', // Attestation de formation spécialisée approfondie
'DNO': 'ZD' // Diplôme national d oenologie
}
// Nom de la métadonnée à modifier
var metadataName = "ametys:degree";
var query = session.getWorkspace().getQueryManager().createQuery("//element(*, ametys:defaultContent)[@ametys-internal:contentType = 'org.ametys.plugins.odf.Content.program']", javax.jcr.query.Query.XPATH);
var nodes = query.execute().getNodes();
var count = 0;
while (nodes.hasNext())
{
var program = nodes.next();
var needSave = false;
if (program.hasProperty(metadataName))
{
var oldValue = program.getProperty(metadataName).getValue().getString();
if (mapping[oldValue] != null)
{
program.setProperty(metadataName, mapping[oldValue]);
needSave = true;
}
}
if (program.hasProperty(metadataName + "_remote"))
{
var oldValue = program.getProperty(metadataName + "_remote").getValue().getString();
if (mapping[oldValue] != null)
{
program.setProperty(metadataName + "_remote", mapping[oldValue]);
needSave = true;
}
}
if (needSave)
{
program.save();
count++;
}
}
println(count + " programs has been modified");
Niveau d'étude (level.xml)
Oups !
La copie dans le presse papier a échouée. Ouvrez le code et copier-le manuellement.
// Correspondance {"ancienne valeur", "nouvelle valeur"}
var mapping = {
'baccalaureat': '0',
'licence1': '1',
'licence2': '2',
'licence3': '3',
'master1': '4',
'master2': '5',
'doctorat': '5'
}
// Nom de la métadonnée à modifier
var metadataName = "ametys:educationLevel";
var query = session.getWorkspace().getQueryManager().createQuery("//element(*, ametys:defaultContent)[@ametys-internal:contentType = 'org.ametys.plugins.odf.Content.program']", javax.jcr.query.Query.XPATH);
var nodes = query.execute().getNodes();
var count = 0;
while (nodes.hasNext())
{
var program = nodes.next();
var needSave = false;
if (program.hasProperty(metadataName))
{
var oldValue = program.getProperty(metadataName).getValue().getString();
if (mapping[oldValue] != null)
{
program.setProperty(metadataName, mapping[oldValue]);
needSave = true;
}
}
if (program.hasProperty(metadataName + "_remote"))
{
var oldValue = program.getProperty(metadataName + "_remote").getValue().getString();
if (mapping[oldValue] != null)
{
program.setProperty(metadataName + "_remote", mapping[oldValue]);
needSave = true;
}
}
if (needSave)
{
program.save();
count++;
}
}
println(count + " programs has been modified");
// Correspondance {"ancienne valeur", "nouvelle valeur"}
var mapping = {
'baccalaureat': '0',
'licence1': '1',
'licence2': '2',
'licence3': '3',
'master1': '4',
'master2': '5',
'doctorat': '5'
}
// Nom de la métadonnée à modifier
var metadataName = "ametys:educationLevel";
var query = session.getWorkspace().getQueryManager().createQuery("//element(*, ametys:defaultContent)[@ametys-internal:contentType = 'org.ametys.plugins.odf.Content.program']", javax.jcr.query.Query.XPATH);
var nodes = query.execute().getNodes();
var count = 0;
while (nodes.hasNext())
{
var program = nodes.next();
var needSave = false;
if (program.hasProperty(metadataName))
{
var oldValue = program.getProperty(metadataName).getValue().getString();
if (mapping[oldValue] != null)
{
program.setProperty(metadataName, mapping[oldValue]);
needSave = true;
}
}
if (program.hasProperty(metadataName + "_remote"))
{
var oldValue = program.getProperty(metadataName + "_remote").getValue().getString();
if (mapping[oldValue] != null)
{
program.setProperty(metadataName + "_remote", mapping[oldValue]);
needSave = true;
}
}
if (needSave)
{
program.save();
count++;
}
}
println(count + " programs has been modified");
// Correspondance {"ancienne valeur", "nouvelle valeur"}
var mapping = {
'baccalaureat': '0',
'licence1': '1',
'licence2': '2',
'licence3': '3',
'master1': '4',
'master2': '5',
'doctorat': '5'
}
// Nom de la métadonnée à modifier
var metadataName = "ametys:educationLevel";
var query = session.getWorkspace().getQueryManager().createQuery("//element(*, ametys:defaultContent)[@ametys-internal:contentType = 'org.ametys.plugins.odf.Content.program']", javax.jcr.query.Query.XPATH);
var nodes = query.execute().getNodes();
var count = 0;
while (nodes.hasNext())
{
var program = nodes.next();
var needSave = false;
if (program.hasProperty(metadataName))
{
var oldValue = program.getProperty(metadataName).getValue().getString();
if (mapping[oldValue] != null)
{
program.setProperty(metadataName, mapping[oldValue]);
needSave = true;
}
}
if (program.hasProperty(metadataName + "_remote"))
{
var oldValue = program.getProperty(metadataName + "_remote").getValue().getString();
if (mapping[oldValue] != null)
{
program.setProperty(metadataName + "_remote", mapping[oldValue]);
needSave = true;
}
}
if (needSave)
{
program.save();
count++;
}
}
println(count + " programs has been modified");
Nature de la formation (program_type.xml)
Oups !
La copie dans le presse papier a échouée. Ouvrez le code et copier-le manuellement.
// Correspondance {"ancienne valeur", "nouvelle valeur"}
var mapping = {
'ET4': 'C',
'ET1': 'M',
'ET3': 'S',
'ET2': 'SP'
}
// Nom de la métadonnée à modifier
var metadataName = "ametys:educationKind";
var query = session.getWorkspace().getQueryManager().createQuery("//element(*, ametys:defaultContent)[@ametys-internal:contentType = 'org.ametys.plugins.odf.Content.program']", javax.jcr.query.Query.XPATH);
var nodes = query.execute().getNodes();
var count = 0;
while (nodes.hasNext())
{
var program = nodes.next();
var needSave = false;
if (program.hasProperty(metadataName))
{
var oldValue = program.getProperty(metadataName).getValue().getString();
if (mapping[oldValue] != null)
{
program.setProperty(metadataName, mapping[oldValue]);
needSave = true;
}
}
if (program.hasProperty(metadataName + "_remote"))
{
var oldValue = program.getProperty(metadataName + "_remote").getValue().getString();
if (mapping[oldValue] != null)
{
program.setProperty(metadataName + "_remote", mapping[oldValue]);
needSave = true;
}
}
if (needSave)
{
program.save();
count++;
}
}
println(count + " programs has been modified");
// Correspondance {"ancienne valeur", "nouvelle valeur"}
var mapping = {
'ET4': 'C',
'ET1': 'M',
'ET3': 'S',
'ET2': 'SP'
}
// Nom de la métadonnée à modifier
var metadataName = "ametys:educationKind";
var query = session.getWorkspace().getQueryManager().createQuery("//element(*, ametys:defaultContent)[@ametys-internal:contentType = 'org.ametys.plugins.odf.Content.program']", javax.jcr.query.Query.XPATH);
var nodes = query.execute().getNodes();
var count = 0;
while (nodes.hasNext())
{
var program = nodes.next();
var needSave = false;
if (program.hasProperty(metadataName))
{
var oldValue = program.getProperty(metadataName).getValue().getString();
if (mapping[oldValue] != null)
{
program.setProperty(metadataName, mapping[oldValue]);
needSave = true;
}
}
if (program.hasProperty(metadataName + "_remote"))
{
var oldValue = program.getProperty(metadataName + "_remote").getValue().getString();
if (mapping[oldValue] != null)
{
program.setProperty(metadataName + "_remote", mapping[oldValue]);
needSave = true;
}
}
if (needSave)
{
program.save();
count++;
}
}
println(count + " programs has been modified");
// Correspondance {"ancienne valeur", "nouvelle valeur"}
var mapping = {
'ET4': 'C',
'ET1': 'M',
'ET3': 'S',
'ET2': 'SP'
}
// Nom de la métadonnée à modifier
var metadataName = "ametys:educationKind";
var query = session.getWorkspace().getQueryManager().createQuery("//element(*, ametys:defaultContent)[@ametys-internal:contentType = 'org.ametys.plugins.odf.Content.program']", javax.jcr.query.Query.XPATH);
var nodes = query.execute().getNodes();
var count = 0;
while (nodes.hasNext())
{
var program = nodes.next();
var needSave = false;
if (program.hasProperty(metadataName))
{
var oldValue = program.getProperty(metadataName).getValue().getString();
if (mapping[oldValue] != null)
{
program.setProperty(metadataName, mapping[oldValue]);
needSave = true;
}
}
if (program.hasProperty(metadataName + "_remote"))
{
var oldValue = program.getProperty(metadataName + "_remote").getValue().getString();
if (mapping[oldValue] != null)
{
program.setProperty(metadataName + "_remote", mapping[oldValue]);
needSave = true;
}
}
if (needSave)
{
program.save();
count++;
}
}
println(count + " programs has been modified");
Forme d'enseignement (teaching_activity.xml)
Oups !
La copie dans le presse papier a échouée. Ouvrez le code et copier-le manuellement.
// Correspondance {"ancienne valeur", "nouvelle valeur"}
var mapping = {
'coursMagistral': 'CM',
'colloque': 'CONF',
'projetIndividuel': 'PRJ',
'stage': 'SA',
'travauxDiriges': 'TD',
'travauxPratiques': 'TP'
}
// Nom de la métadonnée à modifier
var metadataName = "ametys:teachingActivity";
var query = session.getWorkspace().getQueryManager().createQuery("//element(*, ametys:defaultContent)[@ametys-internal:contentType = 'org.ametys.plugins.odf.Content.course']", javax.jcr.query.Query.XPATH);
var nodes = query.execute().getNodes();
var count = 0;
while (nodes.hasNext())
{
var course = nodes.next();
var needSave = false;
if (course.hasProperty(metadataName))
{
var oldValue = course.getProperty(metadataName).getValue().getString();
if (mapping[oldValue] != null)
{
course.setProperty(metadataName, mapping[oldValue]);
needSave = true;
}
}
if (course.hasProperty(metadataName + "_remote"))
{
var oldValue = course.getProperty(metadataName + "_remote").getValue().getString();
if (mapping[oldValue] != null)
{
course.setProperty(metadataName + "_remote", mapping[oldValue]);
needSave = true;
}
}
if (needSave)
{
course.save();
count++;
}
}
println(count + " courses has been modified");
// Correspondance {"ancienne valeur", "nouvelle valeur"}
var mapping = {
'coursMagistral': 'CM',
'colloque': 'CONF',
'projetIndividuel': 'PRJ',
'stage': 'SA',
'travauxDiriges': 'TD',
'travauxPratiques': 'TP'
}
// Nom de la métadonnée à modifier
var metadataName = "ametys:teachingActivity";
var query = session.getWorkspace().getQueryManager().createQuery("//element(*, ametys:defaultContent)[@ametys-internal:contentType = 'org.ametys.plugins.odf.Content.course']", javax.jcr.query.Query.XPATH);
var nodes = query.execute().getNodes();
var count = 0;
while (nodes.hasNext())
{
var course = nodes.next();
var needSave = false;
if (course.hasProperty(metadataName))
{
var oldValue = course.getProperty(metadataName).getValue().getString();
if (mapping[oldValue] != null)
{
course.setProperty(metadataName, mapping[oldValue]);
needSave = true;
}
}
if (course.hasProperty(metadataName + "_remote"))
{
var oldValue = course.getProperty(metadataName + "_remote").getValue().getString();
if (mapping[oldValue] != null)
{
course.setProperty(metadataName + "_remote", mapping[oldValue]);
needSave = true;
}
}
if (needSave)
{
course.save();
count++;
}
}
println(count + " courses has been modified");
// Correspondance {"ancienne valeur", "nouvelle valeur"}
var mapping = {
'coursMagistral': 'CM',
'colloque': 'CONF',
'projetIndividuel': 'PRJ',
'stage': 'SA',
'travauxDiriges': 'TD',
'travauxPratiques': 'TP'
}
// Nom de la métadonnée à modifier
var metadataName = "ametys:teachingActivity";
var query = session.getWorkspace().getQueryManager().createQuery("//element(*, ametys:defaultContent)[@ametys-internal:contentType = 'org.ametys.plugins.odf.Content.course']", javax.jcr.query.Query.XPATH);
var nodes = query.execute().getNodes();
var count = 0;
while (nodes.hasNext())
{
var course = nodes.next();
var needSave = false;
if (course.hasProperty(metadataName))
{
var oldValue = course.getProperty(metadataName).getValue().getString();
if (mapping[oldValue] != null)
{
course.setProperty(metadataName, mapping[oldValue]);
needSave = true;
}
}
if (course.hasProperty(metadataName + "_remote"))
{
var oldValue = course.getProperty(metadataName + "_remote").getValue().getString();
if (mapping[oldValue] != null)
{
course.setProperty(metadataName + "_remote", mapping[oldValue]);
needSave = true;
}
}
if (needSave)
{
course.save();
count++;
}
}
println(count + " courses has been modified");
Plage horaire (time_slot.xml)
Oups !
La copie dans le presse papier a échouée. Ouvrez le code et copier-le manuellement.
// Correspondance {"ancienne valeur", "nouvelle valeur"}
var mapping = {
'journee': 'HO',
'coursDuSoir': 'HA'
}
// Nom de la métadonnée à modifier
var metadataName = "ametys:timeSlot";
var query = session.getWorkspace().getQueryManager().createQuery("//element(*, ametys:defaultContent)[@ametys-internal:contentType = 'org.ametys.plugins.odf.Content.course']", javax.jcr.query.Query.XPATH);
var nodes = query.execute().getNodes();
var count = 0;
while (nodes.hasNext())
{
var course = nodes.next();
var needSave = false;
if (course.hasProperty(metadataName))
{
var oldValue = course.getProperty(metadataName).getValue().getString();
if (mapping[oldValue] != null)
{
course.setProperty(metadataName, mapping[oldValue]);
needSave = true;
}
}
if (course.hasProperty(metadataName + "_remote"))
{
var oldValue = course.getProperty(metadataName + "_remote").getValue().getString();
if (mapping[oldValue] != null)
{
course.setProperty(metadataName + "_remote", mapping[oldValue]);
needSave = true;
}
}
if (needSave)
{
course.save();
count++;
}
}
println(count + " courses has been modified");
// Correspondance {"ancienne valeur", "nouvelle valeur"}
var mapping = {
'journee': 'HO',
'coursDuSoir': 'HA'
}
// Nom de la métadonnée à modifier
var metadataName = "ametys:timeSlot";
var query = session.getWorkspace().getQueryManager().createQuery("//element(*, ametys:defaultContent)[@ametys-internal:contentType = 'org.ametys.plugins.odf.Content.course']", javax.jcr.query.Query.XPATH);
var nodes = query.execute().getNodes();
var count = 0;
while (nodes.hasNext())
{
var course = nodes.next();
var needSave = false;
if (course.hasProperty(metadataName))
{
var oldValue = course.getProperty(metadataName).getValue().getString();
if (mapping[oldValue] != null)
{
course.setProperty(metadataName, mapping[oldValue]);
needSave = true;
}
}
if (course.hasProperty(metadataName + "_remote"))
{
var oldValue = course.getProperty(metadataName + "_remote").getValue().getString();
if (mapping[oldValue] != null)
{
course.setProperty(metadataName + "_remote", mapping[oldValue]);
needSave = true;
}
}
if (needSave)
{
course.save();
count++;
}
}
println(count + " courses has been modified");
// Correspondance {"ancienne valeur", "nouvelle valeur"}
var mapping = {
'journee': 'HO',
'coursDuSoir': 'HA'
}
// Nom de la métadonnée à modifier
var metadataName = "ametys:timeSlot";
var query = session.getWorkspace().getQueryManager().createQuery("//element(*, ametys:defaultContent)[@ametys-internal:contentType = 'org.ametys.plugins.odf.Content.course']", javax.jcr.query.Query.XPATH);
var nodes = query.execute().getNodes();
var count = 0;
while (nodes.hasNext())
{
var course = nodes.next();
var needSave = false;
if (course.hasProperty(metadataName))
{
var oldValue = course.getProperty(metadataName).getValue().getString();
if (mapping[oldValue] != null)
{
course.setProperty(metadataName, mapping[oldValue]);
needSave = true;
}
}
if (course.hasProperty(metadataName + "_remote"))
{
var oldValue = course.getProperty(metadataName + "_remote").getValue().getString();
if (mapping[oldValue] != null)
{
course.setProperty(metadataName + "_remote", mapping[oldValue]);
needSave = true;
}
}
if (needSave)
{
course.save();
count++;
}
}
println(count + " courses has been modified");
Période de l'année (teaching_term.xml)
Oups !
La copie dans le presse papier a échouée. Ouvrez le code et copier-le manuellement.
// Correspondance {"ancienne valeur", "nouvelle valeur"}
var mapping = {
'premierSemestre': 'automne',
'secondSemestre': 'printemps',
'premierEtSecondSemestre': 'touslesans'
}
// Nom de la métadonnée à modifier
var metadataName = "ametys:teachingTerm";
var query = session.getWorkspace().getQueryManager().createQuery("//element(*, ametys:defaultContent)[@ametys-internal:contentType = 'org.ametys.plugins.odf.Content.course']", javax.jcr.query.Query.XPATH);
var nodes = query.execute().getNodes();
var count = 0;
while (nodes.hasNext())
{
var course = nodes.next();
var needSave = false;
if (course.hasProperty(metadataName))
{
var oldValue = course.getProperty(metadataName).getValue().getString();
if (mapping[oldValue] != null)
{
course.setProperty(metadataName, mapping[oldValue]);
needSave = true;
}
}
if (course.hasProperty(metadataName + "_remote"))
{
var oldValue = course.getProperty(metadataName + "_remote").getValue().getString();
if (mapping[oldValue] != null)
{
course.setProperty(metadataName + "_remote", mapping[oldValue]);
needSave = true;
}
}
if (needSave)
{
course.save();
count++;
}
}
println(count + " courses has been modified");
// Correspondance {"ancienne valeur", "nouvelle valeur"}
var mapping = {
'premierSemestre': 'automne',
'secondSemestre': 'printemps',
'premierEtSecondSemestre': 'touslesans'
}
// Nom de la métadonnée à modifier
var metadataName = "ametys:teachingTerm";
var query = session.getWorkspace().getQueryManager().createQuery("//element(*, ametys:defaultContent)[@ametys-internal:contentType = 'org.ametys.plugins.odf.Content.course']", javax.jcr.query.Query.XPATH);
var nodes = query.execute().getNodes();
var count = 0;
while (nodes.hasNext())
{
var course = nodes.next();
var needSave = false;
if (course.hasProperty(metadataName))
{
var oldValue = course.getProperty(metadataName).getValue().getString();
if (mapping[oldValue] != null)
{
course.setProperty(metadataName, mapping[oldValue]);
needSave = true;
}
}
if (course.hasProperty(metadataName + "_remote"))
{
var oldValue = course.getProperty(metadataName + "_remote").getValue().getString();
if (mapping[oldValue] != null)
{
course.setProperty(metadataName + "_remote", mapping[oldValue]);
needSave = true;
}
}
if (needSave)
{
course.save();
count++;
}
}
println(count + " courses has been modified");
// Correspondance {"ancienne valeur", "nouvelle valeur"}
var mapping = {
'premierSemestre': 'automne',
'secondSemestre': 'printemps',
'premierEtSecondSemestre': 'touslesans'
}
// Nom de la métadonnée à modifier
var metadataName = "ametys:teachingTerm";
var query = session.getWorkspace().getQueryManager().createQuery("//element(*, ametys:defaultContent)[@ametys-internal:contentType = 'org.ametys.plugins.odf.Content.course']", javax.jcr.query.Query.XPATH);
var nodes = query.execute().getNodes();
var count = 0;
while (nodes.hasNext())
{
var course = nodes.next();
var needSave = false;
if (course.hasProperty(metadataName))
{
var oldValue = course.getProperty(metadataName).getValue().getString();
if (mapping[oldValue] != null)
{
course.setProperty(metadataName, mapping[oldValue]);
needSave = true;
}
}
if (course.hasProperty(metadataName + "_remote"))
{
var oldValue = course.getProperty(metadataName + "_remote").getValue().getString();
if (mapping[oldValue] != null)
{
course.setProperty(metadataName + "_remote", mapping[oldValue]);
needSave = true;
}
}
if (needSave)
{
course.save();
count++;
}
}
println(count + " courses has been modified");