Created
December 21, 2011 22:06
-
-
Save jimklo/1507943 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// a library for resource_data validation | |
exports.init = function (newDoc, oldDoc, userCtx, secObj) { | |
var a = {}; | |
a.is_resource_data = function() { | |
return newDoc.doc_type === "resource_data_distributable" && newDoc.resource_data && newDoc.resource_locator; | |
}; | |
a.has_dct_conformsTo = function() { | |
try { | |
var nsdl = eval(newDoc.resource_data); | |
var dct = new Namespace("http://purl.org/dc/terms/"); | |
var stds = nsdl..dct::conformsTo | |
if (stds.length > 0) { | |
return true; | |
} | |
} catch (error) { | |
log("error:"+error); | |
return false; | |
} | |
}; | |
a.is_lr_paradata = function() { | |
try { | |
if (newDoc.resource_data_type === "paradata" && newDoc.payload_schema) { | |
for(var i=0; i<newDoc.payload_schema.length; i++) { | |
if (newDoc.payload_schema[i] === "LR Paradata 1.0") { | |
log("We have Paradata!"); | |
return true; | |
} | |
} | |
} | |
return false; | |
} catch (error) { | |
return false; | |
} | |
}; | |
a.has_oer_commons_rubric = function() { | |
try { | |
} catch (error) { | |
return false; | |
} | |
}; | |
return a; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function (newDoc, oldDoc, userCtx, secObj) { | |
try { | |
var v = require("lib/validate").init(newDoc, oldDoc, userCtx, secObj); | |
var a = require("lib/alignment").init(newDoc, oldDoc, userCtx, secObj); | |
log("validating for alignment."); | |
if (a.is_resource_data()) { | |
if (a.has_dct_conformsTo()) { | |
log(newDoc._id +" is good resource for alignment."); | |
return true; | |
} | |
if (a.is_lr_paradata()) { | |
log(newDoc._id + " is a valid paradata resource."); | |
return true; | |
} | |
} | |
} catch (error) { | |
log("ERROR: "+ error); | |
throw { "error": error }; | |
} | |
log(newDoc._id + " is NOT being replicated."); | |
throw v.forbidden(newDoc._id + " does not contain common core standards alignment metadata or paradata."); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment