export.js
/**
 * Verify, modify and save tracker package
 */
Verify, modify and save tracker package
Verify modify and save tracker package
function processTracker() {
	var success = true;
	console.log("\n2. Validating exported metadata");
	if (debug) {
		fs.writeFileSync('.\\debug.json', JSON.stringify(metaData));
	}
	removeProperties();
	removeNameFromPTEA();
	removeNameFromTETA();
	clearMapZoom();
	clearMapViews();
	configureSharing();
	configureOwnership();
	clearUserGroups();
	setDefaultUid();
	clearOrgunitAssignment();
	removeDuplicateObjects();
	if (!validateDataElementReference()) success = false;
	if (!validateProgramIndicatorReference()) success = false;
	if (!validateGroupReferences()) success = false;
	if (!validateFavoriteOrgunits()) success = false;
	if (!validateFavoriteDataItems()) success = false;
	if (!validateFavoriteDataDimension()) success = false;
	if (!validationDataSetSections()) success = false;
	if (currentExport.hasOwnProperty("_customFuncs")) {
		for (var customFunc of currentExport._customFuncs) {
			var func = new Function("metaData", customFunc);
			func(metaData);
		}
	}
	if (success) {
		console.log("✔ Validation passed");
		saveTracker();
	}
	else {
		console.log("");
		var schema = {
			properties: {
				continue: {
					description: "Validation failed. Continue anyway? (yes/no)",
					required: true,
					type: "string",
					default: "no",
				}
			}
		};
		if(args.ignoreerrors)
		{
			saveTracker();
		} else {
			prompt.get(schema, function (err, result) {
				if (result.continue == "yes") saveTracker();
				else cancelCurrentExport();
			});
		}
	}
}
function processTracker ( ) { var success = true ; console . log ( "\n2. Validating exported metadata" ) ; if ( debug ) { fs . writeFileSync ( '.\\debug.json' , JSON . stringify ( metaData ) ) ; } removeProperties ( ) ; removeNameFromPTEA ( ) ; removeNameFromTETA ( ) ; clearMapZoom ( ) ; clearMapViews ( ) ; configureSharing ( ) ; configureOwnership ( ) ; clearUserGroups ( ) ; setDefaultUid ( ) ; clearOrgunitAssignment ( ) ; removeDuplicateObjects ( ) ; if ( ! validateDataElementReference ( ) ) success = false ; if ( ! validateProgramIndicatorReference ( ) ) success = false ; if ( ! validateGroupReferences ( ) ) success = false ; if ( ! validateFavoriteOrgunits ( ) ) success = false ; if ( ! validateFavoriteDataItems ( ) ) success = false ; if ( ! validateFavoriteDataDimension ( ) ) success = false ; if ( ! validationDataSetSections ( ) ) success = false ; if ( currentExport . hasOwnProperty ( "_customFuncs" ) ) { for ( var customFunc of currentExport . _customFuncs ) { var func = new Function ( "metaData" , customFunc ) ; func ( metaData ) ; } } if ( success ) { console . log ( "✔ Validation passed"); saveTracker ( ) ; } else { console . log ( "" ) ; var schema = { properties : { continue : { description : "Validation failed. Continue anyway? (yes/no)" , required : true , type : "string" , default : "no" , } } } ; if ( args . ignoreerrors ) { saveTracker ( ) ; } else { prompt . get ( schema , function ( err , result ) { if ( result . continue == "yes" ) saveTracker ( ) ; else cancelCurrentExport ( ) ; } ) ; } } }
Verify, modify and save tracker package
Verify modify and save tracker package
//Debug: dump metadata before processing //Remove undesired properties from objects //Reset/remove lat/long/zoom on maps //Configure sharing and metadata ownership //Remove users from user groups //Make sure the "default defaults" are used //Make sure we don't include orgunit assigment in datasets or users //Remove duplicate programStageDataElements //Verify that all data elements referred in indicators, validation rules, //predictors are included //Verify that all program indicators referred to in indicators and predictors are included //Remove invalid references to data elements or indicators from groups //Verify that there are no data elements or indicators without groups //Verify that favourites only use relative orgunits //Verify that favourites only use indicators //Verify that no unsupported data dimensions are used //Verify that data sets with section include all data elements /** CUSTOM MODIFICATIONS */