![JAR search and dependency download from the Maven repository](/logo.png)
cass.rollup.subprocessor.CredentialCompetencyLocator Maven / Gradle / Ivy
package cass.rollup.subprocessor;
import com.eduworks.ec.array.EcArray;
import com.eduworks.ec.array.EcObject;
import org.cass.competency.EcCompetency;
import org.cass.competency.EcFramework;
import org.cassproject.ebac.repository.EcRepository;
import org.cassproject.schema.general.EcRemoteLinkedData;
import org.credentialengine.*;
import org.schema.CreativeWork;
import org.stjs.javascript.Array;
import org.stjs.javascript.JSCollections;
import org.stjs.javascript.JSObjectAdapter;
import org.stjs.javascript.Map;
import org.stjs.javascript.functions.Callback1;
/**
* Attempts to find all 'required' competencies for a given 'Credential' type (Badge, Certificate, Degree, Credential)
* by traversing the associated required 'ConditionProfile' for 'targetLearningOpportunities' and 'targetAssessments'
*
* @author [email protected]
* @author [email protected]
* @class CredentialCompetencyLocator
* @module org.cassproject
*/
public class CredentialCompetencyLocator {
//private static final String CERTIFICATE_TYPE_SUFFIX = "Certificate";
//private static final String CREDENTIAL_TYPE_SUFFIX = "Credential";
//private static final String BADGE_TYPE_SUFFIX = "Badge";
//private static final String DEGREE_TYPE_SUFFIX = "Degree"; //Doesn't seem to exist...
private static final String ASSESSMENT_PROFILE_TYPE_SUFFIX = "AssessmentProfile";
private static final String LEARNING_OPPORTUNITY_PROFILE_TYPE_SUFFIX = "LearningOpportunityProfile";
private static final String CONDITION_PROFILE_TYPE = "ConditionProfile";
public Array logBuffer;
public String credentialLocator;
public boolean stripId = true;
public EcRepository repo = null;
public Callback1> success;
public Callback1 failure;
private boolean inputValid = false;
private Credential sourceCredential;
private Array competencyList;
private Map competencyMap;
private Array currentTargetList;
private int numberOfTargetsToProcess;
private int numberOfTargetsProcessed;
private Array nextTargetList;
private Map targetsProcessed;
private void log(String s) {
logBuffer.push(s);
}
private void validateInput() {
log("Validating input...");
inputValid = false;
if (failure == null) {
log("Invalid failure callback");
} else if (success == null) {
log("Invalid success callback");
failure.$invoke("success callback required");
} else if (credentialLocator == null || credentialLocator.trim()=="") {
log("Invalid credentialLocator");
failure.$invoke("credentialLocator required");
} else {
inputValid = true;
}
}
private void initLocator() {
log("Initializing parameters...");
competencyList = new Array();
competencyMap = JSCollections.$map();
targetsProcessed = JSCollections.$map();
}
private void logCreativeWorkArray(Array extends CreativeWork> cwa) {
for (int i = 0; i < cwa.$length(); i++) {
log("[" + i + "]: " + cwa.$get(i).name);
}
}
private void logStringArray(Array sa) {
for (int i = 0; i < sa.$length(); i++) {
log("[" + i + "]: " + sa.$get(i));
}
}
private void logCredentialAlignmentArray(Array caoa) {
for (int i = 0; i < caoa.$length(); i++) {
log("[" + i + "]-framework: " + caoa.$get(i).framework);
log("[" + i + "]-targetNode: " + caoa.$get(i).targetNode);
}
}
private ConditionProfile generateConditionProfile(Object o) {
ConditionProfile cp = new ConditionProfile();
cp.copyFrom(o);
return cp;
}
private Array getStringArray(Object o) {
if (o == null) new Array();
Array sa;
if (EcArray.isArray(o)) sa = (Array) o;
else {
sa = new Array();
sa.push((String) o);
}
return sa;
}
private Array getTargetCompetencyList(Object targetCompetencyObject) {
if (targetCompetencyObject == null) return new Array();
Array caoa = new Array();
CredentialAlignmentObject cao;
if (EcArray.isArray(targetCompetencyObject)) {
Array
© 2015 - 2025 Weber Informatics LLC | Privacy Policy