diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..56ea4d8 --- /dev/null +++ b/.gitignore @@ -0,0 +1,24 @@ + +proyecto/java_microservice/build/classes/Carreras.class +proyecto/java_microservice/build/classes/Estudiante.class +proyecto/java_microservice/build/classes/EstudianteAddEvaluation.class +proyecto/java_microservice/build/classes/EstudianteAddPlan.class +proyecto/java_microservice/build/classes/Estudiantes/impl/CourseInscriptionImpl.class +proyecto/java_microservice/build/classes/Estudiantes/impl/EstudiantesFactoryImpl.class +proyecto/java_microservice/build/classes/Estudiantes/impl/EstudiantesPackageImpl.class +proyecto/java_microservice/build/classes/Estudiantes/impl/PlanInscriptionImpl.class +proyecto/java_microservice/build/classes/Estudiantes/impl/RootImpl.class +proyecto/java_microservice/build/classes/Estudiantes/impl/StudentEvaluationImpl.class +proyecto/java_microservice/build/classes/Estudiantes/impl/StudentImpl.class +*.class +proyecto/java_microservice/build/classes/EvalPlan.class +proyecto/java_microservice/build/classes/Evaluations.class +proyecto/java_microservice/build/classes/EvalUC.class +proyecto/java_microservice/build/classes/Facultad.class +proyecto/java_microservice/build/classes/modelSingleton.class +proyecto/java_microservice/build/classes/Plan.class +proyecto/java_microservice/build/classes/PlanUcs.class +proyecto/java_microservice/build/classes/Subjects.class +proyecto/java_microservice/build/classes/UnidadCurricular.class +*.class +lab3/org.eclipse.acceleo.SoaML2JavaWS/bin/org/eclipse/acceleo/SoaML2JavaWS/GenerateJavaWSfromSoaML.class diff --git a/lab3/org.eclipse.acceleo.SoaML2JavaWS/bin/.gitignore b/lab3/org.eclipse.acceleo.SoaML2JavaWS/bin/.gitignore index cf1db2e..3df2884 100644 --- a/lab3/org.eclipse.acceleo.SoaML2JavaWS/bin/.gitignore +++ b/lab3/org.eclipse.acceleo.SoaML2JavaWS/bin/.gitignore @@ -1 +1,2 @@ /org/ +/modelo/ diff --git a/proyecto/front/js/seePlan.js b/proyecto/front/js/seePlan.js index a6b5859..c405445 100644 --- a/proyecto/front/js/seePlan.js +++ b/proyecto/front/js/seePlan.js @@ -13,6 +13,38 @@ function consultarPlan() { var nodos_final = []; var aristas = []; + function processSomeOfGraph(reqFather, aristas, materias, nodos_0){ + for (let j = 1; j < (reqFather).length; j++) { + let a = reqFather[j]; + let b = Object.keys(a); + let req = b[0]; + if (req === "Coursed") { + let source_index = findKeyByValue(nodos_0, a['Coursed']); + let dest_index = findKeyByValue(nodos_0, materias); + let aaa = { + from: source_index, + to: dest_index, + color: "#0000FF", + arrows: "to", + dashes: true + }; + aristas.push(aaa); + } else if (req === "Exam") { + let source_index = findKeyByValue(nodos_0, a['Exam']); + let dest_index = findKeyByValue(nodos_0, materias); + let aaa = { + from: source_index, + to: dest_index, + color: "#0000FF", + arrows: "to" + }; + aristas.push(aaa); + } else if (req === "SomeOf") { + processSomeOfGraph(a['SomeOf'], aristas, materias, nodos_0); + } + } + } + fetch(url) .then(response => response.json()) .then(materias => { @@ -26,11 +58,12 @@ function consultarPlan() { for (let i = 0; i < materias.length; i++) { let apiUrl = `https://tmde-api.fapret.com:8443/curricula_microservice/Faculty/ucs?faculty=${faculty}&curricularUnit=` + materias[i]; fetch(apiUrl) - .then(response => { + .then(async response => { if (!response.ok) { throw new Error('No se pudo obtener la respuesta de la API'); } - return response.json(); // Parsear la respuesta JSON + return response.json(); + //return await response.json(); // Parsear la respuesta JSON }) .then(async data => { const result = await getMaxRequirementLevel(facultyName, materias[i]); @@ -49,33 +82,7 @@ function consultarPlan() { if (data.Requirement && (data.Requirement).length > 0) { //todo: si es un someof, tengo que ver cuales de las N se cumple, y mostrar solo las aristas de ella. por ejemplo, tprog y sus 2 vias de cursado if (Object.keys(data.Requirement[0])[0] === "SomeOf") { - for (let j = 1; j < (data.Requirement[0]['SomeOf']).length; j++) { - let a = data.Requirement[0]['SomeOf'][j]; - let b = Object.keys(a); - let req = b[0]; - if (req === "Coursed") { - let source_index = findKeyByValue(nodos_0, a['Coursed']); - let dest_index = findKeyByValue(nodos_0, materias[i]); - let aaa = { - from: source_index, - to: dest_index, - color: "#0000FF", - arrows: "to", - dashes: true - }; - aristas.push(aaa); - } else if (req === "Exam") { - let source_index = findKeyByValue(nodos_0, a['Exam']); - let dest_index = findKeyByValue(nodos_0, materias[i]); - let aaa = { - from: source_index, - to: dest_index, - color: "#0000FF", - arrows: "to" - }; - aristas.push(aaa); - } - } + processSomeOfGraph(data.Requirement[0]['SomeOf'], aristas, materias[i], nodos_0); } else { let a = data.Requirement[0]; let b = Object.keys(a); diff --git a/proyecto/front/js/selectLib.js b/proyecto/front/js/selectLib.js index 28eb0d1..8815a39 100644 --- a/proyecto/front/js/selectLib.js +++ b/proyecto/front/js/selectLib.js @@ -121,6 +121,21 @@ function findKeyByValue(obj, value) { return null; // Return null if the value is not found } +async function processSomeOf(someOfArray, req_values, facultyName) { + for (let j = 0; j < someOfArray.length; j++) { + const subReq = someOfArray[j]; + + if (subReq.Exam) { + req_values.push(await getMaxRequirementLevel(facultyName, subReq.Exam)); + } else if (subReq.Coursed) { + req_values.push(await getMaxRequirementLevel(facultyName, subReq.Coursed)); + } else if (subReq.SomeOf) { + // Recursive call for nested SomeOf + await processSomeOf(subReq.SomeOf, req_values, facultyName); + } + } +} + async function getMaxRequirementLevel(facultyName, cu_id) { let apiUrl = `https://tmde-api.fapret.com:8443/curricula_microservice/Faculty/ucs?faculty=${facultyName}&curricularUnit=${cu_id}`; @@ -139,27 +154,15 @@ async function getMaxRequirementLevel(facultyName, cu_id) { for (let i = 0; i < data['Requirement'].length; i++) { const subRequirement = data['Requirement'][i]; - if (subRequirement.Exam) { req_values.push(await getMaxRequirementLevel(facultyName, subRequirement.Exam)); } else if (subRequirement.Coursed) { req_values.push(await getMaxRequirementLevel(facultyName, subRequirement.Coursed)); - } - else if (subRequirement.SomeOf) { - for (let j = 0; j < subRequirement.SomeOf.length; j++) { - if (subRequirement.SomeOf[j].Exam) - req_values.push(await getMaxRequirementLevel(facultyName, subRequirement.SomeOf[j].Exam)); - else if (subRequirement.SomeOf[j].Coursed) - req_values.push(await getMaxRequirementLevel(facultyName, subRequirement.SomeOf[j].Coursed)); - - } + } else if (subRequirement.SomeOf) { + await processSomeOf(subRequirement.SomeOf, req_values, facultyName); } } - let base = 1; - //if (data['Id'] === "P4" || data['Id'] === "LOGICA" || data["Id"] === "METNUM" || data["Id"] === "FBD" || data["Id"] === "PROLOG" || data["Id"] === "PROGFUN" || data["Id"] === "IIO") - //base = 2; - - return base + Math.max(...req_values); + return req_values.length > 0 ? 1 + Math.max(...req_values) : 0; } catch (error) { console.error(error); return 0; diff --git a/proyecto/front/js/viewTrajectory.js b/proyecto/front/js/viewTrajectory.js index 10b6c5a..cdae240 100644 --- a/proyecto/front/js/viewTrajectory.js +++ b/proyecto/front/js/viewTrajectory.js @@ -29,6 +29,38 @@ function mostrar_trayectoria() { }; + function processSomeOfGraph(reqFather, aristas, materias, nodos_0){ + for (let j = 1; j < reqFather.length; j++) { + let a = reqFather[j]; + let b = Object.keys(a); + let req = b[0]; + if (req === "Coursed") { + let source_index = findKeyByValue(nodos_0, a['Coursed']); + let dest_index = findKeyByValue(nodos_0, materias); + let aaa = { + from: source_index, + to: dest_index, + color: "#0000FF", + arrows: "to", + dashes: true + }; + aristas.push(aaa); + } else if (req === "Exam") { + let source_index = findKeyByValue(nodos_0, a['Exam']); + let dest_index = findKeyByValue(nodos_0, materias); + let aaa = { + from: source_index, + to: dest_index, + color: "#0000FF", + arrows: "to" + }; + aristas.push(aaa); + } else if (req === "SomeOf") { + processSomeOfGraph(a['SomeOf'], aristas, materias, nodos_0); + } + } + } + fetch(url, options) .then(response => response.json()) .then(materias => { @@ -55,33 +87,7 @@ function mostrar_trayectoria() { //PENDIENTE: si es un someof, tengo que ver cuales de las N se cumple, //y mostrar solo las aristas de ella. por ejemplo, tprog y sus 2 vias de cursado if (Object.keys(data.Requirement[0])[0] === "SomeOf") { - for (let j = 1; j < (data.Requirement[0]['SomeOf']).length; j++) { - let a = data.Requirement[0]['SomeOf'][j]; - let b = Object.keys(a); - let req = b[0]; - if (req === "Coursed") { - let source_index = findKeyByValue(nodos_0, a['Coursed']); - let dest_index = findKeyByValue(nodos_0, materias[i]); - let aaa = { - from: source_index, - to: dest_index, - color: "#0000FF", - arrows: "to", - dashes: true - }; - aristas.push(aaa); - } else if (req === "Exam") { - let source_index = findKeyByValue(nodos_0, a['Exam']); - let dest_index = findKeyByValue(nodos_0, materias[i]); - let aaa = { - from: source_index, - to: dest_index, - color: "#0000FF", - arrows: "to" - }; - aristas.push(aaa); - } - } + processSomeOfGraph(data.Requirement[0]['SomeOf'], aristas, materias[i], nodos_0); } else { let a = data.Requirement[0]; @@ -222,6 +228,21 @@ function mostrar_trayectoria() { }) } +async function processSomeOf(someOfArray, req_values, facultyName) { + for (let j = 0; j < someOfArray.length; j++) { + const subReq = someOfArray[j]; + + if (subReq.Exam) { + req_values.push(await getMaxRequirementLevel(facultyName, subReq.Exam)); + } else if (subReq.Coursed) { + req_values.push(await getMaxRequirementLevel(facultyName, subReq.Coursed)); + } else if (subReq.SomeOf) { + // Recursive call for nested SomeOf + await processSomeOf(subReq.SomeOf, req_values, facultyName); + } + } + } + async function getMaxRequirementLevel(facultyName, cu_id) { let apiUrl = `https://tmde-api.fapret.com:8443/curricula_microservice/Faculty/ucs?faculty=${facultyName}&curricularUnit=${cu_id}`; @@ -234,38 +255,24 @@ async function getMaxRequirementLevel(facultyName, cu_id) { const data = await response.json(); - if (data['Requirement'].length === 0) - if (data['Id'] === "P1") // porque P1 se dicta en el segundo semestre - return 1; - else - return 0; - else { - const req_values = []; - - for (let i = 0; i < data['Requirement'].length; i++) { - const subRequirement = data['Requirement'][i]; + if (!data['Requirement'] || data['Requirement'].length === 0) + return 0; + const req_values = []; - if (subRequirement.Exam) { - req_values.push(await getMaxRequirementLevel(facultyName, subRequirement.Exam)); - } else if (subRequirement.Coursed) { - req_values.push(await getMaxRequirementLevel(facultyName, subRequirement.Coursed)); - } - else if (subRequirement.SomeOf) { - for (let j = 0; j < subRequirement.SomeOf.length; j++) { - if (subRequirement.SomeOf[j].Exam) - req_values.push(await getMaxRequirementLevel(facultyName, subRequirement.SomeOf[j].Exam)); - else if (subRequirement.SomeOf[j].Coursed) - req_values.push(await getMaxRequirementLevel(facultyName, subRequirement.SomeOf[j].Coursed)); + for (let i = 0; i < data['Requirement'].length; i++) { + const subRequirement = data['Requirement'][i]; - } - } + if (subRequirement.Exam) { + req_values.push(await getMaxRequirementLevel(facultyName, subRequirement.Exam)); + } else if (subRequirement.Coursed) { + req_values.push(await getMaxRequirementLevel(facultyName, subRequirement.Coursed)); + } + else if (subRequirement.SomeOf) { + await processSomeOf(subRequirement.SomeOf, req_values, facultyName); } - let base = 1; - if (data['Id'] === "P4" || data['Id'] === "LOGICA" || data["Id"] === "METNUM" || data["Id"] === "FBD" || data["Id"] === "PROLOG" || data["Id"] === "PROGFUN" || data["Id"] === "IIO") - base = 2; - - return base + Math.max(...req_values); } + + return req_values.length > 0 ? 1 + Math.max(...req_values) : 0; } catch (error) { console.error(error); return 0; diff --git a/proyecto/java_microservice/src/main/java/UnidadCurricular.java b/proyecto/java_microservice/src/main/java/UnidadCurricular.java index 9bcdb5b..923a17f 100644 --- a/proyecto/java_microservice/src/main/java/UnidadCurricular.java +++ b/proyecto/java_microservice/src/main/java/UnidadCurricular.java @@ -32,7 +32,7 @@ public UnidadCurricular() { private String getRequeriment(Requirement requerimiento) { if(requerimiento instanceof NOT) { NOT req = (NOT) requerimiento; - return "{ \"NOT\": \"" + getRequeriment(req.getRequirement()) + "\"}"; + return "{ \"NOT\": " + getRequeriment(req.getRequirement()) + "}"; } if(requerimiento instanceof Coursed) { Coursed req = (Coursed) requerimiento;