This page lists the migration scripts required following modifications to the fields listed ( WEB-INF/param/odf directory).

  1. Type of degree (degree.xml)
  2. Level of education (level.xml)
  3. Type of training (program_type.xml)
  4. Teaching form (teaching_activity.xml)
  5. Time slot (time_slot.xml)
  6. Time of year (teaching_term.xml)
  7. Teaching method (formofteaching_method.xml)

As the lists of possible values and labels for each field are customizable, it's possible that your old values don't correspond exactly to the scripts provided. If necessary, modify the correspondence map at the beginning of script to make your own correspondence.

Type of degree (degree.xml)

// 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");

Level of education (level.xml)

// 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");

Type of training (program_type.xml)

// 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");

Teaching form (teaching_activity.xml)

// 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");

Time slot (time_slot.xml)

// 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");

Time of year (teaching_term.xml)

// 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");

Teaching method (formofteaching_method.xml)

// Correspondance {"ancienne valeur", "nouvelle valeur"}
var mapping = {
	'faceAFace': 'presence',
	'aDistance': 'adistance',
    'presentielEnrichi': 'hybride',
    'presentielAllege': 'hybride',
    'presentielReduit': 'hybride',
    'presentielQuasiInexistant': 'hybride',
    'presentielAmeliore': 'hybride',
    'parCorrespondance': 'adistance',
    'paLeWeb': 'adistance'
 }
// Nom de la métadonnée à modifier
var metadataName = "ametys:teachingMethod";

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");
Back to top