analyseWriter/src/MEPTL/rechercherUnNodeStudent.java

839 lines
46 KiB
Java
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package MEPTL;
import java.util.ArrayList;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.swing.JOptionPane;
import cXML.Run;
import cXML.node;
import evaluer.evaluation;
/**
*
* @author pablo rodriguez
*
*/
public class rechercherUnNodeStudent {
/**
* Recherche en cascade des nodes en fonction de leur contenu.</br>
* Elargie sa recherche dans les nodes parents.</br>
* Permet de rechercher par l'index, le contenu ou le nom des objets.</br></br>
* @param nameNode : nom du node
* @param nodSujet : nod sujet
* @param nod0Student : node étudiant contenant le node nod1Student. Si pas trouvé dans le node nod1Student
* @param nod1Student : node étudiant contenant le node nod2Student. Si pas trouvé dans le node Nod2Student.
* @param nod2Student : node étudiant de niveau le plus haut. La recherche commence par ce node.
* @param a : Run cXML
* @return : le node recherché
*/
public static node rechercheLeNodeEnCascade(String nameNode, node nodSujet,node nod0Student, node nod1Student, node nod2Student, Run a ) {
node nodStudent =null;
//************************************************************************************************
//** Recherche le node par le contenu exact du node en intégrant les contenus des nodes enfants **
//** Le contenu exact supprime dans le texte les espaces au début et à la fin et ignore la case **
//************************************************************************************************
if(nodSujet.getAttributs().get("recherche_contenu_exact")!=null){
if(nodSujet.getAttributs().get("recherche_contenu_exact").contentEquals("true")) {
nodStudent = findNodeParContenuEXACT(nameNode, nodSujet, nod0Student, nod1Student, nod2Student, a);
return nodStudent;
}
}
//************************************************************************************************
//** Recherche le node par le contenu ayant la distance Levenshtein la plus proche de 1 **
//************************************************************************************************
if(nodSujet.getAttributs().get("recherche_contenu_plus_proche_voisin")!=null && nodSujet.retourneLesContenusEnfants("").length()>2){
if(nodSujet.getAttributs().get("recherche_contenu_plus_proche_voisin").equals("true")){
nodStudent = findNodeParContenuPlusProcheVoisin(nameNode, nodSujet, nod0Student, nod1Student, nod2Student, a);
return nodStudent;
}
}
//***********************************
//** Recherche le node par l'index **
//***********************************
if(nodSujet.getAttributs().get("recherche_index")!=null){
if(nodSujet.getAttributs().get("recherche_index").equals("true")) {
nodStudent = findNodeParIndex(nameNode, nodSujet, nod0Student, nod1Student, nod2Student, a);
return nodStudent;
}
}
//***********************************************************************************************************************
//** Recherche les nodes text:p, text:h, text:span, text:list, text:note, text:tab **
//** text:line-break, text:note, text:tab, text:index-body, text:index-title, text:index-title-template **
//** text:table-of-content par le contenu textuel **
//** Si le node possède un node text:user-defined alors utilise la méthode findLeNodeTextpParDesNodesEnfantsSpecifique **
//***********************************************************************************************************************
if(nodSujet.getNomElt().contains("text:")) {
Pattern p = Pattern.compile("^text:p$|^text:h$|^text:span$|^text:list|^text:line-break$|^text:note$|^text:tab$|"
+ "^text:index-body$|^text:index-title$|^text:index-title-template^$|^text:table-of-content$"); //le node qui peuvent rechercher par le contenu textuel
Matcher m = p.matcher(nameNode);
if(m.find()) {
nodStudent = findNodeByContenuTextuel(nameNode, nodSujet, nod0Student, nod1Student, nod2Student, a);
if(nameNode.equals("text:line-break")) return nodStudent;
if(nodSujet.getAttributs().get("isDoublon")!=null) if(nodSujet.getAttributs().get("isDoublon").equals("true")) return nodStudent;
if(nodStudent!=null) return nodStudent;
}
}
//*****************************************************************
//** Recherche le node text:p par les différents contenu du node **
//*****************************************************************
if(nameNode.equals("text:p")||nameNode.equals("text:h")||nameNode.equals("text:list-item")||nameNode.equals("text:list")
||nameNode.equals("text:span")||nameNode.equals("text:line-break")) {
nodStudent = findLeNodeTextpParDesNodesEnfantsSpecifique(nameNode, nodSujet,nod0Student, nod1Student, nod2Student, a );
}
//********************************************************************************
//** Recherche le node draw:frame par draw:name ou recherche_anchor-page-number **
//********************************************************************************
if(nameNode.equals("draw:frame")) {
nodStudent = findDrawFrame(nameNode, nodSujet, nod0Student, nod1Student, nod2Student, a);
}
//************************************************
//** Recherche le node text:date par text:fixed **
//************************************************
if(nameNode.equals("text:date")) {
nodStudent = findTextDate(nameNode, nodSujet, nod0Student, nod1Student, nod2Student, a);
}
//**********************************************
//** Recherche le node text:xxx par text:name **
//**********************************************
if(nameNode.equals("text:section") || nameNode.equals("text:user-defined") || nameNode.equals("text:table-of-content")) {
nodStudent = findByTextName(nameNode, nodSujet, nod0Student, nod1Student, nod2Student, a);
}
//******************************************************************
//** Recherche le node text:database-display par text:column-name **
//******************************************************************
if(nameNode.equals("text:database-display")) {
nodStudent = findDataBase(nameNode, nodSujet, nod0Student, nod1Student, nod2Student, a);
}
//**************************************************
//** Recherche le node table:table par table:name **
//**************************************************
if(nameNode.equals("table:table")) {
nodStudent = findTable(nameNode, nodSujet, nod0Student, nod1Student, nod2Student, a);
}
//*************************************************************************
//** Recherche le node text:h par le contenu avec tolérance de caractère **
//*************************************************************************
if(nameNode.equals("text:h")) {
nodStudent = findByContentWithTolerance(nameNode, nodSujet, nod0Student, nod1Student, nod2Student, a);
}
//*******************************************************
//** Recherche le node par l'index même si pas demandé **
//*******************************************************
if(nameNode.equals("table:table-row") || nameNode.equals("table:table-cell") || nameNode.equals("text:tab") || nameNode.equals("text:span")) {
nodStudent = findByIndexEvenIsFalse(nameNode, nodSujet, nod0Student, nod1Student, nod2Student, a);
}
//****************************************************************
//** Recherche le node text:conditional-text par text:condition **
//****************************************************************
if(nameNode.equals("text:conditional-text") ) {
nodStudent = findTextConditional(nameNode, nodSujet, nod0Student, nod1Student, nod2Student, a);
}
//***************************************************************
//** Recherche le node table:table-column par table:style-name **
//***************************************************************
if(nameNode.equals("table:table-column")) {
nodStudent = findTableByStyleName(nameNode, nodSujet, nod0Student, nod1Student, nod2Student, a);
}
//*********************************************
//** Recherche le node par le contenu simple **
//*********************************************
if(nameNode.equals("text:tab") || nameNode.equals("style:graphic-properties")) {
nodStudent = findByContentZero(nameNode, nodSujet, nod0Student, nod1Student, nod2Student, a);
}
//*************************************************************
//** Recherche le node style:tab-stop par son style:position **
//*************************************************************
if(nameNode.equals("style:tab-stop")) {
nodStudent = findBystylePosition(nameNode, nodSujet, nod0Student, nod1Student, nod2Student, a);
return nodStudent;
}
//***********************************
//** Recherche le node par son nom **
//***********************************
if(nameNode.equals("text:editing-cycles")) {
nodStudent = findByNameNode(nameNode, nodSujet, nod0Student, nod1Student, nod2Student, a);
return nodStudent;
}
//***********************************************
//** Recherche le node par son nom **
//** sauf pour draw:frame **
//***********************************************
if(nodStudent==null) {
nodStudent = findByNameNode(nameNode, nodSujet, nod0Student, nod1Student, nod2Student, a);
}
//*********************************************
//** Recherche le node par le contenu simple **
//*********************************************
if(nodStudent==null){
nodStudent = findByContentZero(nameNode, nodSujet, nod0Student, nod1Student, nod2Student, a);
}
return nodStudent;
}
/**
* Recherche par le contenu exact du node. Englobe les contenus des nodes enfants.</br>
* Le contenu exact supprime dans le texte les espaces au début et à la fin et ignore la case.</br>
* @param nameNode
* @param nodSujet
* @param nod0Student
* @param nod1Student
* @param nod2Student
* @param a
* @return
*/
private static node findNodeParContenuEXACT(String nameNode, node nodSujet,node nod0Student, node nod1Student, node nod2Student, Run a ) {
node nodStudent = null;
if(nodSujet.getAttributs().get("recherche_contenu_exact")!=null) {
if(nodSujet.getAttributs().get("recherche_contenu_exact").equals("true")) {
if(!nodSujet.retourneLesContenusEnfants("").isEmpty()) {
String valueAttribut = evaluation.withoutCodeAndPointPourRechercheContenuExact(nodSujet.retourneLesContenusEnfants(""));
if(nod2Student!=null) if(nodStudent==null) nodStudent = a.retourneFirstNodeByFindContentExact(nod2Student.getNodes(), valueAttribut, nodSujet.getNomElt());
if(nod1Student!=null) if(nodStudent==null) nodStudent = a.retourneFirstNodeByFindContentExact(nod1Student.getNodes(), valueAttribut, nodSujet.getNomElt());
if(nod0Student!=null) if(nodStudent==null) nodStudent = a.retourneFirstNodeByFindContentExact(nod0Student.getNodes(), valueAttribut, nodSujet.getNomElt());
}
}
}
return nodStudent;
}
/**
* Retourne le node Student en recherchant par le contenu textuel.</br>
* @param nameNode
* @param nodSujet
* @param nod0Student
* @param nod1Student
* @param nod2Student
* @param a
* @return
*/
private static node findNodeByContenuTextuel(String nameNode, node nodSujet,node nod0Student, node nod1Student, node nod2Student, Run a) {
node nodStudent = null;
String valueAttribut = evaluation.withoutCodeAndPointPourRechercheContenuExact(nodSujet.retourneLesContenusEnfants(""));
ArrayList<node> tousLesfreres = new ArrayList<node>();
if(nodSujet.getAttributs().get("isDoublon")==null) {
//méthode texte rigoureusement exact
if(nod2Student!=null) if(nodStudent==null) nodStudent = a.retourneFirstNameNodeByFindContentExactly(nod2Student.getNodes(), valueAttribut, nameNode);
if(nod2Student!=null) if(nodStudent==null) {
tousLesfreres = nod2Student.retourneTousLesFreres(); //Retourne tous les frère d'une même page
for(int i = 0 ; i < tousLesfreres.size();i++) {
if(nodStudent==null) {
if(tousLesfreres.get(i)!=null) nodStudent = a.retourneFirstNameNodeByFindContentExactly(tousLesfreres.get(i).getNodes(), valueAttribut, nameNode);
}
}
}
if(nodStudent!=null) return nodStudent;
//méthode par le calcul de la distance de levenshtein
Run.setStockLaDerniereValeurSim(0.1);
if(nod2Student!=null) if(nodStudent==null) {
node stockNodeTrouveMeilleurVoisin = null;
for(int i = 0 ; i < tousLesfreres.size();i++) {
if(tousLesfreres.get(i)!=null) {
nodStudent = a.retourneLeNodeByContentPlusProche(tousLesfreres.get(i).getNodes(), valueAttribut, nameNode,null);
if(nodStudent!=null) {
stockNodeTrouveMeilleurVoisin = nodStudent;
}
}
}
if(stockNodeTrouveMeilleurVoisin!=null) nodStudent=stockNodeTrouveMeilleurVoisin;
}
}else {
//Recherche le doublon
if(nod2Student!=null) if(nodStudent==null) nodStudent = a.retourneLeNodeDoublonStudent(nod2Student.getNodes(), valueAttribut, nameNode, nodSujet);
}
return nodStudent;
}
/**
* Recherche par le contenu par le plus proche voisin. Englobe les contenus des nodes enfants.</br>
* La distance maximale est déterminé par la valeur de sim.</br>
* @param nameNode
* @param nodSujet
* @param nod0Student
* @param nod1Student
* @param nod2Student
* @param a
* @return
*/
@SuppressWarnings("unused")
private static node findNodeParContenuPlusProcheVoisinSim(String nameNode, node nodSujet,node nod0Student, node nod1Student, node nod2Student, Run a , double sim) {
node nodStudent = null;
if(!nodSujet.retourneLesContenusEnfants("").isEmpty()) {
Run.setStockLaDerniereValeurSim(sim);
String valueAttribut = evaluation.withoutCodeAndPointPourRechercheContenuExact(nodSujet.retourneLesContenusEnfants(""));
if(nod2Student!=null) if(nodStudent==null) nodStudent = a.retourneLeNodeByContentPlusProche(nod2Student.getNodes(), valueAttribut, nodSujet.getNomElt(),null);
if(nod1Student!=null) if(nodStudent==null) nodStudent = a.retourneLeNodeByContentPlusProche(nod1Student.getNodes(), valueAttribut, nodSujet.getNomElt(),null);
if(nod0Student!=null) if(nodStudent==null) nodStudent = a.retourneLeNodeByContentPlusProche(nod0Student.getNodes(), valueAttribut, nodSujet.getNomElt(),null);
}
return nodStudent;
}
/**
* Recherche par le contenu par le plus proche voisin. Englobe les contenus des nodes enfants.</br>
* @param nameNode
* @param nodSujet
* @param nod0Student
* @param nod1Student
* @param nod2Student
* @param a
* @return
*/
private static node findNodeParContenuPlusProcheVoisin(String nameNode, node nodSujet,node nod0Student, node nod1Student, node nod2Student, Run a ) {
node nodStudent = null;
if(nodSujet.getAttributs().get("recherche_contenu_plus_proche_voisin").equals("true")) {
cXML.Run.setStockLaDerniereValeurSim(commandes.analyse_tolerance_text);
if(!nodSujet.retourneLesContenusEnfants("").isEmpty()) {
String valueAttribut = evaluation.withoutCodeAndPointPourRechercheContenuExact(nodSujet.retourneLesContenusEnfants(""));
if(nod2Student!=null) if(nodStudent==null) nodStudent = a.retourneLeNodeByContentPlusProche(nod2Student.getNodes(), valueAttribut, nodSujet.getNomElt(),null);
if(nod1Student!=null) if(nodStudent==null) nodStudent = a.retourneLeNodeByContentPlusProche(nod1Student.getNodes(), valueAttribut, nodSujet.getNomElt(),null);
if(nod0Student!=null) if(nodStudent==null) nodStudent = a.retourneLeNodeByContentPlusProche(nod0Student.getNodes(), valueAttribut, nodSujet.getNomElt(),null);
}
}
return nodStudent;
}
/**
* Recherche par l'attribut index.</br>
* @param nameNode
* @param nodSujet
* @param nod0Student
* @param nod1Student
* @param nod2Student
* @param a
* @return
*/
private static node findNodeParIndex(String nameNode, node nodSujet,node nod0Student, node nod1Student, node nod2Student, Run a ) {
node nodStudent = null;
if(nodSujet.getAttributs().get("recherche_index").equals("true")) {
String valueAttribut = nodSujet.getAttributs().get("index");
if(nod2Student!=null) if(nodStudent==null) nodStudent = a.retourneFirstNodeByNameAttributValue(nod2Student.getNodes(), nodSujet.getNomElt(),"index",valueAttribut);
if(nod1Student!=null) if(nodStudent==null) nodStudent = a.retourneFirstNodeByNameAttributValue(nod1Student.getNodes(), nodSujet.getNomElt(),"index",valueAttribut);
if(nod0Student!=null) if(nodStudent==null) nodStudent = a.retourneFirstNodeByNameAttributValue(nod0Student.getNodes(), nodSujet.getNomElt(),"index",valueAttribut);
}
return nodStudent;
}
/**
* Recherche Le node text:p par les différents contenu du node.</br>
* @param nameNode
* @param nodSujet
* @param nod0Student
* @param nod1Student
* @param nod2Student
* @param a
* @return
*/
private static node findLeNodeTextpParDesNodesEnfantsSpecifique(String nameNode, node nodSujet,node nod0Student, node nod1Student, node nod2Student, Run a ) {
node nodStudent =null;
if(!nodSujet.getNodes().isEmpty()) return null;
String nameNodeSujet = nodSujet.getNomElt();
if(nodSujet.getNodes().size()>0) {
for(int i = 0; i < nodSujet.getNodes().size() ; i++) {
if(nodSujet.getNodes().get(i)!=null) {
node nodEnfantSujet = nodSujet.getNodes().get(i);
String nameNodeEnfantSujet = nodEnfantSujet.getNomElt();
if(nameNodeEnfantSujet.equals("text:user-defined")) {
String valueAttribut = evaluation.withoutCodeAndPoint(nodSujet.retourneFirstEnfantsByName("text:user-defined").getAttributs().get("text:name"));
if(nod2Student!=null) if(nodStudent==null) nodStudent = nod2Student.retourneFirstNodeByNameContainsNodeByNameAndAttributValue(nameNodeSujet,"text:user-defined", "text:name", valueAttribut);
if(nod1Student!=null) if(nodStudent==null) nodStudent = nod1Student.retourneFirstNodeByNameContainsNodeByNameAndAttributValue(nameNodeSujet,"text:user-defined", "text:name", valueAttribut);
if(nod0Student!=null) if(nodStudent==null) nodStudent = nod0Student.retourneFirstNodeByNameContainsNodeByNameAndAttributValue(nameNodeSujet,"text:user-defined", "text:name", valueAttribut);
}
if(nameNodeEnfantSujet.equals("text:conditional-text")) {
String valueAttribut = evaluation.withoutCodeAndPoint(nodSujet.retourneFirstEnfantsByName("text:conditional-text").getAttributs().get("text:condition"));
if(nod2Student!=null) if(nodStudent==null) nodStudent = nod2Student.retourneFirstNodeByNameContainsNodeByNameAndAttributValue(nameNodeSujet,"text:conditional-text", "text:condition", valueAttribut);
if(nod1Student!=null) if(nodStudent==null) nodStudent = nod1Student.retourneFirstNodeByNameContainsNodeByNameAndAttributValue(nameNodeSujet,"text:conditional-text", "text:condition", valueAttribut);
if(nod0Student!=null) if(nodStudent==null) nodStudent = nod0Student.retourneFirstNodeByNameContainsNodeByNameAndAttributValue(nameNodeSujet,"text:conditional-text", "text:condition", valueAttribut);
}
if(nameNodeEnfantSujet.equals("text:database-display")) {
String valueAttribut = evaluation.withoutCodeAndPoint(nodSujet.retourneFirstEnfantsByName("text:database-display").getAttributs().get("text:column-name"));
if(nod2Student!=null) if(nodStudent==null) nodStudent = nod2Student.retourneFirstNodeByNameContainsNodeByNameAndAttributValue(nameNodeSujet,"text:database-display", "text:column-name", valueAttribut);
if(nod1Student!=null) if(nodStudent==null) nodStudent = nod1Student.retourneFirstNodeByNameContainsNodeByNameAndAttributValue(nameNodeSujet,"text:database-display", "text:column-name", valueAttribut);
if(nod0Student!=null) if(nodStudent==null) nodStudent = nod0Student.retourneFirstNodeByNameContainsNodeByNameAndAttributValue(nameNodeSujet,"text:database-display", "text:column-name", valueAttribut);
}
if(nameNodeEnfantSujet.equals("text:date")) {
String valueAttribut = evaluation.withoutCodeAndPoint(nodSujet.retourneFirstEnfantsByName("text:date").getAttributs().get("text:fixed"));
if(nod2Student!=null) if(nodStudent==null) nodStudent = nod2Student.retourneFirstNodeByNameContainsNodeByNameAndAttributValue(nameNodeSujet,"text:date", "text:fixed", valueAttribut);
if(nod1Student!=null) if(nodStudent==null) nodStudent = nod1Student.retourneFirstNodeByNameContainsNodeByNameAndAttributValue(nameNodeSujet,"text:date", "text:fixed", valueAttribut);
if(nod0Student!=null) if(nodStudent==null) nodStudent = nod0Student.retourneFirstNodeByNameContainsNodeByNameAndAttributValue(nameNodeSujet,"text:date", "text:fixed", valueAttribut);
}
if(nameNodeEnfantSujet.equals("text:subject")) {
if(nod2Student!=null) if(nodStudent==null) nodStudent = nod2Student.retourneFirstEnfantsByNameNode1ContainNameNode2(nameNodeSujet,"text:subject");
if(nod1Student!=null) if(nodStudent==null) nodStudent = nod1Student.retourneFirstEnfantsByNameNode1ContainNameNode2(nameNodeSujet,"text:subject");
if(nod0Student!=null) if(nodStudent==null) nodStudent = nod0Student.retourneFirstEnfantsByNameNode1ContainNameNode2(nameNodeSujet,"text:subject");
}
if(nameNodeEnfantSujet.equals("text:title")) {
if(nod2Student!=null) if(nodStudent==null) nodStudent = nod2Student.retourneFirstEnfantsByNameNode1ContainNameNode2(nameNodeSujet,"text:title");
if(nod1Student!=null) if(nodStudent==null) nodStudent = nod1Student.retourneFirstEnfantsByNameNode1ContainNameNode2(nameNodeSujet,"text:title");
if(nod0Student!=null) if(nodStudent==null) nodStudent = nod0Student.retourneFirstEnfantsByNameNode1ContainNameNode2(nameNodeSujet,"text:title");
}
if(nameNodeEnfantSujet.equals("text:initial-creator")) {
if(nod2Student!=null) if(nodStudent==null) nodStudent = nod2Student.retourneFirstEnfantsByNameNode1ContainNameNode2(nameNodeSujet,"text:initial-creator");
if(nod1Student!=null) if(nodStudent==null) nodStudent = nod1Student.retourneFirstEnfantsByNameNode1ContainNameNode2(nameNodeSujet,"text:initial-creator");
if(nod0Student!=null) if(nodStudent==null) nodStudent = nod0Student.retourneFirstEnfantsByNameNode1ContainNameNode2(nameNodeSujet,"text:initial-creator");
}
if(nameNodeEnfantSujet.equals("text:creator")) {
if(nod2Student!=null) if(nodStudent==null) nodStudent = nod2Student.retourneFirstEnfantsByNameNode1ContainNameNode2(nameNodeSujet,"text:creator");
if(nod1Student!=null) if(nodStudent==null) nodStudent = nod1Student.retourneFirstEnfantsByNameNode1ContainNameNode2(nameNodeSujet,"text:creator");
if(nod0Student!=null) if(nodStudent==null) nodStudent = nod0Student.retourneFirstEnfantsByNameNode1ContainNameNode2(nameNodeSujet,"text:creator");
}
if(nameNodeEnfantSujet.equals("text:note")) {
node nodeTexteNoteSujet = nodSujet.retourneFirstEnfantsByName("text:note");
node nodeTexteNoteStudent = null;
if(nod2Student!=null) if(nodStudent==null) nodStudent = nod2Student.retourneFirstEnfantsByNameNode1ContainNameNode2(nameNodeSujet,"text:note");
if(nodStudent!=null) {
nodeTexteNoteStudent = nodStudent.retourneFirstEnfantsByName("text:note");
if(nodeTexteNoteSujet.retourneLesContenusEnfants("").equals(nodeTexteNoteStudent.retourneLesContenusEnfants(""))) return nodStudent;
}
if(nod1Student!=null) if(nodStudent==null) nodStudent = nod1Student.retourneFirstEnfantsByNameNode1ContainNameNode2(nameNodeSujet,"text:note");
if(nod2Student!=null) if(nodStudent==null) nodStudent = nod2Student.retourneFirstEnfantsByNameNode1ContainNameNode2(nameNodeSujet,"text:note");
if(nodStudent!=null) {
nodeTexteNoteStudent = nodStudent.retourneFirstEnfantsByName("text:note");
if(nodeTexteNoteSujet.retourneLesContenusEnfants("").equals(nodeTexteNoteStudent.retourneLesContenusEnfants(""))) return nodStudent;
}
if(nod0Student!=null) if(nodStudent==null) nodStudent = nod0Student.retourneFirstEnfantsByNameNode1ContainNameNode2(nameNodeSujet,"text:note");
if(nod2Student!=null) if(nodStudent==null) nodStudent = nod2Student.retourneFirstEnfantsByNameNode1ContainNameNode2(nameNodeSujet,"text:note");
if(nodStudent!=null) {
nodeTexteNoteStudent = nodStudent.retourneFirstEnfantsByName("text:note");
if(nodeTexteNoteSujet.retourneLesContenusEnfants("").equals(nodeTexteNoteStudent.retourneLesContenusEnfants(""))) return nodStudent;
}
}
if(nodStudent!=null) return nodStudent;
}
}
}
// //si le node "text:p" contient un "text:user-defined" alors le recherche par le "text:name" de ce node "text:user-defined"
// if(nodSujet.containElementByName("text:user-defined")) {
// String valueAttribut = evaluation.withoutCodeAndPoint(nodSujet.retourneFirstEnfantsByName("text:user-defined").getAttributs().get("text:name"));
// if(nod2Student!=null) if(nodStudent==null) nodStudent = nod2Student.retourneFirstNodeByNameContainsNodeByNameAndAttributValue("text:p","text:user-defined", "text:name", valueAttribut);
// if(nod1Student!=null) if(nodStudent==null) nodStudent = nod1Student.retourneFirstNodeByNameContainsNodeByNameAndAttributValue("text:p","text:user-defined", "text:name", valueAttribut);
// if(nod0Student!=null) if(nodStudent==null) nodStudent = nod0Student.retourneFirstNodeByNameContainsNodeByNameAndAttributValue("text:p","text:user-defined", "text:name", valueAttribut);
// }
// //si le node "text:p" contient un "text:conditional-text" alors le recherche par le "text:condition" de ce node "text:conditional-text"
// if(nodSujet.containElementByName("text:conditional-text")) {
// String valueAttribut = evaluation.withoutCodeAndPoint(nodSujet.retourneFirstEnfantsByName("text:conditional-text").getAttributs().get("text:condition"));
// if(nod2Student!=null) if(nodStudent==null) nodStudent = nod2Student.retourneFirstNodeByNameContainsNodeByNameAndAttributValue("text:p","text:conditional-text", "text:condition", valueAttribut);
// if(nod1Student!=null) if(nodStudent==null) nodStudent = nod1Student.retourneFirstNodeByNameContainsNodeByNameAndAttributValue("text:p","text:conditional-text", "text:condition", valueAttribut);
// if(nod0Student!=null) if(nodStudent==null) nodStudent = nod0Student.retourneFirstNodeByNameContainsNodeByNameAndAttributValue("text:p","text:conditional-text", "text:condition", valueAttribut);
// }
// //si le node "text:p" contient un "text:database-display" alors le recherche par le "text:column-name" de ce node "text:database-display"
// if(nodSujet.containElementByName("text:database-display")) {
// String valueAttribut = evaluation.withoutCodeAndPoint(nodSujet.retourneFirstEnfantsByName("text:database-display").getAttributs().get("text:column-name"));
// if(nod2Student!=null) if(nodStudent==null) nodStudent = nod2Student.retourneFirstNodeByNameContainsNodeByNameAndAttributValue("text:p","text:database-display", "text:column-name", valueAttribut);
// if(nod1Student!=null) if(nodStudent==null) nodStudent = nod1Student.retourneFirstNodeByNameContainsNodeByNameAndAttributValue("text:p","text:database-display", "text:column-name", valueAttribut);
// if(nod0Student!=null) if(nodStudent==null) nodStudent = nod0Student.retourneFirstNodeByNameContainsNodeByNameAndAttributValue("text:p","text:database-display", "text:column-name", valueAttribut);
// }
// //si le node "text:p" contient un "text:date" alors le recherche par le "text:fixed" de ce node "text:date"
// if(nodSujet.containElementByName("text:date")) {
// String valueAttribut = evaluation.withoutCodeAndPoint(nodSujet.retourneFirstEnfantsByName("text:date").getAttributs().get("text:fixed"));
// if(nod2Student!=null) if(nodStudent==null) nodStudent = nod2Student.retourneFirstNodeByNameContainsNodeByNameAndAttributValue("text:p","text:date", "text:fixed", valueAttribut);
// if(nod1Student!=null) if(nodStudent==null) nodStudent = nod1Student.retourneFirstNodeByNameContainsNodeByNameAndAttributValue("text:p","text:date", "text:fixed", valueAttribut);
// if(nod0Student!=null) if(nodStudent==null) nodStudent = nod0Student.retourneFirstNodeByNameContainsNodeByNameAndAttributValue("text:p","text:date", "text:fixed", valueAttribut);
// }
// if(nodSujet.containElementByName("text:subject")) {
// if(nod2Student!=null) if(nodStudent==null) nodStudent = nod2Student.retourneFirstEnfantsByNameNode1ContainNameNode2("text:p","text:subject");
// if(nod1Student!=null) if(nodStudent==null) nodStudent = nod1Student.retourneFirstEnfantsByNameNode1ContainNameNode2("text:p","text:subject");
// if(nod0Student!=null) if(nodStudent==null) nodStudent = nod0Student.retourneFirstEnfantsByNameNode1ContainNameNode2("text:p","text:subject");
// }
// if(nodSujet.containElementByName("text:title")) {
// if(nod2Student!=null) if(nodStudent==null) nodStudent = nod2Student.retourneFirstEnfantsByNameNode1ContainNameNode2("text:p","text:title");
// if(nod1Student!=null) if(nodStudent==null) nodStudent = nod1Student.retourneFirstEnfantsByNameNode1ContainNameNode2("text:p","text:title");
// if(nod0Student!=null) if(nodStudent==null) nodStudent = nod0Student.retourneFirstEnfantsByNameNode1ContainNameNode2("text:p","text:title");
// }
// if(nodSujet.containElementByName("text:initial-creator")) {
// if(nod2Student!=null) if(nodStudent==null) nodStudent = nod2Student.retourneFirstEnfantsByNameNode1ContainNameNode2("text:p","text:initial-creator");
// if(nod1Student!=null) if(nodStudent==null) nodStudent = nod1Student.retourneFirstEnfantsByNameNode1ContainNameNode2("text:p","text:initial-creator");
// if(nod0Student!=null) if(nodStudent==null) nodStudent = nod0Student.retourneFirstEnfantsByNameNode1ContainNameNode2("text:p","text:initial-creator");
// }
// if(nodSujet.containElementByName("text:creator")) {
// if(nod2Student!=null) if(nodStudent==null) nodStudent = nod2Student.retourneFirstEnfantsByNameNode1ContainNameNode2("text:p","text:creator");
// if(nod1Student!=null) if(nodStudent==null) nodStudent = nod1Student.retourneFirstEnfantsByNameNode1ContainNameNode2("text:p","text:creator");
// if(nod0Student!=null) if(nodStudent==null) nodStudent = nod0Student.retourneFirstEnfantsByNameNode1ContainNameNode2("text:p","text:creator");
// }
//** Recherche par contenu
if(!nodSujet.getContenu().isEmpty()) {
String valueAttribut = evaluation.withoutCodeAndPointPourRechercheContenuExact(nodSujet.getContenu().get(0));
if(nod2Student!=null) if(nodStudent==null) nodStudent = a.retourneFirstNodeByFindContentExact(nod2Student.getNodes(), valueAttribut, nodSujet.getNomElt());
if(nod1Student!=null) if(nodStudent==null) nodStudent = a.retourneFirstNodeByFindContentExact(nod1Student.getNodes(), valueAttribut, nodSujet.getNomElt());
if(nod0Student!=null) if(nodStudent==null) nodStudent = a.retourneFirstNodeByFindContentExact(nod0Student.getNodes(), valueAttribut, nodSujet.getNomElt());
}
//** Recherche le node par index uniquement même si pas demandé. Si trouve pas retourne un null.
if(nodSujet.getAttributs().get("index")!=null){
String valueAttribut = nodSujet.getAttributs().get("index");
if(nod2Student!=null) if(nodStudent==null) nodStudent = a.retourneFirstNodeByNameAttributValue(nod2Student.getNodes(), nodSujet.getNomElt(),"index",valueAttribut);
if(nod1Student!=null) if(nodStudent==null) nodStudent = a.retourneFirstNodeByNameAttributValue(nod1Student.getNodes(), nodSujet.getNomElt(),"index",valueAttribut);
if(nod0Student!=null) if(nodStudent==null) nodStudent = a.retourneFirstNodeByNameAttributValue(nod0Student.getNodes(), nodSujet.getNomElt(),"index",valueAttribut);
}
return nodStudent;
}
/**
* Recherche Le node draw:frame par l'attribut draw:name ou recherche_anchor-apge-number.</br>
* @param nameNode
* @param nodSujet
* @param nod0Student
* @param nod1Student
* @param nod2Student
* @param a
* @return
*/
private static node findDrawFrame(String nameNode, node nodSujet,node nod0Student, node nod1Student, node nod2Student, Run a) {
node nodStudent = null;
String nameDraw = evaluation.withoutCodeAndPointPourRechercheContenuExact(nodSujet.getAttributs().get("draw:name"));
//recherche par le nom de l'objet draw:name par défaut
if(nod2Student!=null) nodStudent = a.retourneFirstNodeByNameAttributValueNetTexte(nod2Student, nameNode, "draw:name", nameDraw);
if(nod1Student!=null) if(nodStudent==null) nodStudent = a.retourneFirstNodeByNameAttributValueNetTexte(nod1Student, nameNode, "draw:name", nameDraw);
if(nod0Student!=null) if(nodStudent==null) nodStudent = a.retourneFirstNodeByNameAttributValueNetTexte(nod0Student, nameNode, "draw:name", nameDraw);
if(nodStudent!=null) return nodStudent;
if(nodSujet.getAttributs().get("recherche_anchor-page-number")!=null) if(nodSujet.getAttributs().get("recherche_anchor-page-number").equalsIgnoreCase("true")) {
String AncragePage = evaluation.withoutCodeAndPointPourRechercheContenuExact(nodSujet.getAttributs().get("text:anchor-page-number"));
if(nod2Student!=null) nodStudent = a.retourneFirstNodeByNameAttributValue(nod2Student, nameNode, "text:anchor-page-number", AncragePage);
if(nod1Student!=null) if(nodStudent==null) nodStudent = a.retourneFirstNodeByNameAttributValue(nod1Student, nameNode, "text:anchor-page-number", AncragePage);
if(nod0Student!=null) if(nodStudent==null) nodStudent = a.retourneFirstNodeByNameAttributValue(nod0Student, nameNode, "text:anchor-page-number", AncragePage);
}
return nodStudent;
}
/**
*
* @param nameNode
* @param nodSujet
* @param nod0Student
* @param nod1Student
* @param nod2Student
* @param a
* @return
*/
private static node findTextConditional(String nameNode, node nodSujet,node nod0Student, node nod1Student, node nod2Student, Run a) {
node nodStudent = null;
String valueAttribut = evaluation.withoutCodeAndPoint(nodSujet.getAttributs().get("text:condition"));
if(nod2Student!=null) nodStudent = a.retourneFirstNodeByNameAttributValue(nod2Student, nameNode, "text:condition", valueAttribut);
if(nod1Student!=null) if(nodStudent==null) nodStudent = a.retourneFirstNodeByNameAttributValue(nod1Student, nameNode, "text:condition", valueAttribut);
if(nod0Student!=null) if(nodStudent==null) nodStudent = a.retourneFirstNodeByNameAttributValue(nod0Student, nameNode, "text:condition", valueAttribut);
return nodStudent;
}
/**
* Recherche Le node text:section par l'attribut text:name;</br>
* @param nameNode
* @param nodSujet
* @param nod0Student
* @param nod1Student
* @param nod2Student
* @param a
* @return
*/
private static node findByTextName(String nameNode, node nodSujet,node nod0Student, node nod1Student, node nod2Student, Run a) {
node nodStudent = null;
if(nod2Student!=null) nodStudent = a.retourneFirstNodeByNameAttributValue(nod2Student, nameNode, "text:name", evaluation.withoutCodeAndPoint(nodSujet.getAttributs().get("text:name")));
if(nod1Student!=null) if(nodStudent==null) nodStudent = a.retourneFirstNodeByNameAttributValue(nod1Student, nameNode, "text:name", evaluation.withoutCodeAndPoint(nodSujet.getAttributs().get("text:name")));
if(nod0Student!=null) if(nodStudent==null) nodStudent = a.retourneFirstNodeByNameAttributValue(nod0Student, nameNode, "text:name", evaluation.withoutCodeAndPoint(nodSujet.getAttributs().get("text:name")));
return nodStudent;
}
/**
*
* @param nameNode
* @param nodSujet
* @param nod0Student
* @param nod1Student
* @param nod2Student
* @param a
* @return
*/
private static node findTextDate(String nameNode, node nodSujet,node nod0Student, node nod1Student, node nod2Student, Run a) {
node nodStudent = null;
String valueAttribut = evaluation.withoutCodeAndPoint(nodSujet.getAttributs().get("text:fixed"));
if(nod2Student!=null) nodStudent = a.retourneFirstNodeByNameAttributValue(nod2Student, nameNode, "text:fixed", valueAttribut);
if(nod1Student!=null) if(nodStudent==null) nodStudent = a.retourneFirstNodeByNameAttributValue(nod1Student, nameNode, "text:fixed", valueAttribut);
if(nod0Student!=null) if(nodStudent==null) nodStudent = a.retourneFirstNodeByNameAttributValue(nod0Student, nameNode, "text:fixed", valueAttribut);
return nodStudent;
}
/**
* Recherche le node par son nom.<br>
* Retourne le premier node qui correspond au nom du node.<br>
* Sauf pour les nodes (draw:frame, ...)
* @param nameNode
* @param nodSujet
* @param nod0Student
* @param nod1Student
* @param nod2Student
* @param a
* @return
*/
private static node findByNameNode(String nameNode, node nodSujet,node nod0Student, node nod1Student, node nod2Student, Run a) {
node nodStudent = null;
if(nodSujet.getNomElt().equals("draw:frame")) return null;
if(nod2Student!=null) if(nod2Student.retourneEnfantsByNameExist(nameNode)) nodStudent = nod2Student.retourneFirstEnfantsByName(nameNode);
if(nod1Student!=null) if(nodStudent==null) if(nod1Student.retourneEnfantsByNameExist(nameNode)) nodStudent = nod1Student.retourneFirstEnfantsByName(nameNode);
if(nod0Student!=null) if(nodStudent==null) if(nod0Student.retourneEnfantsByNameExist(nameNode)) nodStudent = nod0Student.retourneFirstEnfantsByName(nameNode);
return nodStudent;
}
/**
* Recherche le node text:database-display par text:column-name.</br>
* @param nameNode
* @param nodSujet
* @param nod0Student
* @param nod1Student
* @param nod2Student
* @param a
* @return
*/
private static node findDataBase(String nameNode, node nodSujet,node nod0Student, node nod1Student, node nod2Student, Run a) {
node nodStudent = null;
String valueAttribut = evaluation.withoutCodeAndPoint(nodSujet.getAttributs().get("text:column-name"));
if(nod2Student!=null) nodStudent = a.retourneFirstNodeByNameAttributValue(nod2Student, nameNode, "text:column-name", valueAttribut);
if(nod1Student!=null) if(nodStudent==null) nodStudent = a.retourneFirstNodeByNameAttributValue(nod1Student, nameNode, "text:column-name", valueAttribut);
if(nod0Student!=null) if(nodStudent==null) nodStudent = a.retourneFirstNodeByNameAttributValue(nod0Student, nameNode, "text:column-name", valueAttribut);
return nodStudent;
}
/**
* Recherche le node par le contenu simple get(0).</br>
* Le nom du node doit contenir "text" ou "style:" pour qu'il soit pris en compte.<br>
* @param nameNode
* @param nodSujet
* @param nod0Student
* @param nod1Student
* @param nod2Student
* @param a
* @return
*/
private static node findByContentZero(String nameNode, node nodSujet,node nod0Student, node nod1Student, node nod2Student, Run a) {
node nodStudent = null;
if(nodSujet.getNomElt().contains("text")||nodSujet.getNomElt().contains("style:")) {
if(!nodSujet.getContenu().isEmpty()) {
if(nod2Student!=null) nodStudent = a.retourneFirstNodeByNameContent(nod2Student, nameNode, nodSujet.getContenu().get(0));
if(nod1Student!=null) if(nodStudent==null) nodStudent = a.retourneFirstNodeByNameContent(nod1Student, nameNode, nodSujet.getContenu().get(0));
if(nod0Student!=null) if(nodStudent==null) nodStudent = a.retourneFirstNodeByNameContent(nod0Student, nameNode, nodSujet.getContenu().get(0));
}
}
return nodStudent;
}
/**
* Recherche le node style:position pour les stops de tabulation.</br>
* @param nameNode
* @param nodSujet
* @param nod0Student
* @param nod1Student
* @param nod2Student
* @param a
* @return
*/
private static node findBystylePosition(String nameNode, node nodSujet,node nod0Student, node nod1Student, node nod2Student, Run a) {
double tolerance = 0.05;
String valueAttribut = evaluation.withoutCodeAndPoint(nodSujet.getAttributs().get("style:position"));
if(!valueAttribut.contains("¦")&&!valueAttribut.contains("|")&&!valueAttribut.contains("")&&!valueAttribut.contains("")
&&!valueAttribut.contains("")&&!valueAttribut.contains("×")&&!valueAttribut.contains("")&&!valueAttribut.contains("¢")) {
if(!valueAttribut.contains("")) {
Pattern p3 = Pattern.compile("^[0-9]{0,}\\.[0-9]{0,}|^[0-9]{0,}");
Matcher m3 = p3.matcher(valueAttribut);
if(m3.find()) {
valueAttribut = (valueAttribut.substring(m3.start(), m3.end()));
}else {
JOptionPane.showMessageDialog(null, "Le fichier d'analyse possède une erreur dans la valeur du tab-stop."
+"\r\nLa valeur est " + valueAttribut+
"\r\nProblème de pattern.","Erreur",JOptionPane.ERROR_MESSAGE);
}
}else {
tolerance = (evaluation.TraitementIntervaleRetourneValeurMaximale(valueAttribut) - evaluation.TraitementIntervaleRetourneValeurMinimale(valueAttribut))/2;
valueAttribut = String.valueOf(evaluation.TraitementIntervaleRetourneValeurMaximale(valueAttribut) - tolerance);
}
}else {
JOptionPane.showMessageDialog(null, "Le fichier d'analyse possède une erreur dans la valeur du tab-stop."
+"\r\nLa valeur est " + valueAttribut,"Erreur",JOptionPane.ERROR_MESSAGE);
}
double ValeurSujet = 0.0;
try {
ValeurSujet = Double.valueOf(valueAttribut);
}catch (Exception e) {
JOptionPane.showMessageDialog(null, "Le fichier d'analyse possède une erreur dans la valeur du tab-stop."
+"\r\nLa valeur est " + valueAttribut+
"\r\nImpossible de convertir la valeur en type Double.", "Erreur",JOptionPane.ERROR_MESSAGE);
}
if(nod2Student!=null) {
ArrayList<node> A = nod2Student.retourneTousLesNodesDeCeNiveauQuiOnAttribut(nameNode, "");
for(int i = 0 ; i < A.size() ; i++) {
String valueAttributStudent = A.get(i).getAttributs().get("style:position");
Pattern p3 = Pattern.compile("^[0-9]{0,}\\.[0-9]{0,}|^[0-9]{0,}");
Matcher m3 = p3.matcher(valueAttributStudent);
double ValeurStudent = 0.0;
if(m3.find()) {
valueAttributStudent = (valueAttributStudent.substring(m3.start(), m3.end()));
}else {
JOptionPane.showMessageDialog(null, "Le fichier de l'étudiant possède une erreur dans la valeur du tab-stop."
+"\r\nLa valeur est " + valueAttribut+
"\r\nProblème de pattern.","Erreur",JOptionPane.ERROR_MESSAGE);
}
ValeurStudent = Double.valueOf(valueAttributStudent);
if((ValeurStudent>ValeurSujet-tolerance)&&(ValeurStudent<ValeurSujet+tolerance)) return A.get(i);
}
}
return null;
}
/**
* Rechercher le node table:table par table:name.</br>
* @param nameNode
* @param nodSujet
* @param nod0Student
* @param nod1Student
* @param nod2Student
* @param a
* @return
*/
private static node findTable(String nameNode, node nodSujet,node nod0Student, node nod1Student, node nod2Student, Run a) {
node nodStudent = null;
if(nod2Student!=null) nodStudent = a.retourneFirstNodeByNameAttributValue(nod2Student, nameNode, "table:name", evaluation.withoutCodeAndPointPourRechercheContenuExact(nodSujet.getAttributs().get("table:name")));
if(nod1Student!=null) if(nodStudent==null) nodStudent = a.retourneFirstNodeByNameAttributValue(nod1Student, nameNode, "table:name", evaluation.withoutCodeAndPointPourRechercheContenuExact(nodSujet.getAttributs().get("table:name")));
if(nod0Student!=null) if(nodStudent==null) nodStudent = a.retourneFirstNodeByNameAttributValue(nod0Student, nameNode, "table:name", evaluation.withoutCodeAndPointPourRechercheContenuExact(nodSujet.getAttributs().get("table:name")));
return nodStudent;
}
/**
* Recherche le node par son contenu avec une tolérance de carcatère.</br>
* @param nameNode
* @param nodSujet
* @param nod0Student
* @param nod1Student
* @param nod2Student
* @param a
* @return
*/
private static node findByContentWithTolerance(String nameNode, node nodSujet,node nod0Student, node nod1Student, node nod2Student, Run a) {
node nodStudent = null;
String contenuSujet = nodSujet.retourneLesContenusEnfants("");
if(nod2Student!=null) nodStudent = a.retourneFirstNodeByFindContent2(nod2Student.getNodes(), contenuSujet,commandes.tolerance_characters,commandes.tolerance_text);
if(nod1Student!=null) if(nodStudent==null) nodStudent = a.retourneFirstNodeByFindContent2(nod1Student.getNodes(), contenuSujet,commandes.tolerance_characters,commandes.tolerance_text);
if(nod0Student!=null) if(nodStudent==null) nodStudent = a.retourneFirstNodeByFindContent2(nod0Student.getNodes(), contenuSujet,commandes.tolerance_characters,commandes.tolerance_text);
return nodStudent;
}
/**
* Rechreche le node par son index même si pas demandé.</br>
* @param nameNode
* @param nodSujet
* @param nod0Student
* @param nod1Student
* @param nod2Student
* @param a
* @return
*/
private static node findByIndexEvenIsFalse(String nameNode, node nodSujet,node nod0Student, node nod1Student, node nod2Student, Run a) {
node nodStudent = null;
if(nodSujet.getAttributs().get("index")!=null){
if(nod2Student!=null) nodStudent = a.retourneFirstNodeByNameAttributValue(nod2Student, nameNode, "index", nodSujet.getAttributs().get("index"));
if(nod1Student!=null) if(nodStudent==null) nodStudent = a.retourneFirstNodeByNameAttributValue(nod1Student, nameNode, "index", nodSujet.getAttributs().get("index"));
if(nod0Student!=null) if(nodStudent==null) nodStudent = a.retourneFirstNodeByNameAttributValue(nod0Student, nameNode, "index", nodSujet.getAttributs().get("index"));
}
return nodStudent;
}
/**
* Recherche le node par table:style-name.</br>
* @param nameNode
* @param nodSujet
* @param nod0Student
* @param nod1Student
* @param nod2Student
* @param a
* @return
*/
private static node findTableByStyleName(String nameNode, node nodSujet,node nod0Student, node nod1Student, node nod2Student, Run a) {
node nodStudent = null;
if(nod2Student!=null) nodStudent = a.retourneFirstNodeByNameAttributValue(nod2Student, nameNode, "table:style-name", nodSujet.getAttributs().get("table:style-name"));
if(nod1Student!=null) if(nodStudent==null) nodStudent = a.retourneFirstNodeByNameAttributValue(nod1Student, nameNode, "table:style-name", nodSujet.getAttributs().get("table:style-name"));
if(nod0Student!=null) if(nodStudent==null) nodStudent = a.retourneFirstNodeByNameAttributValue(nod0Student, nameNode, "table:style-name", nodSujet.getAttributs().get("table:style-name"));
return nodStudent;
}
}