Cette page répertorie les scripts de migration nécessaires suite aux modifications effectuées sur les champs énumérées (répertoire WEB-INF/param/odf).

  1. Type de diplôme (degree.xml)
  2. Niveau d'étude (level.xml)
  3. Nature de la formation (program_type.xml)
  4. Forme d'enseignement (teaching_activity.xml)
  5. Plage horaire (time_slot.xml)
  6. Période de l'année (teaching_term.xml)
  7. Méthode d'enseignement (formofteaching_method.xml)

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)

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

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

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

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

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

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

Méthode d'enseignement (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");
Retour en haut