235 lines
10 KiB
Java
235 lines
10 KiB
Java
package AnalyseCalc;
|
|
|
|
import java.io.BufferedWriter;
|
|
import java.io.IOException;
|
|
import java.nio.charset.StandardCharsets;
|
|
import java.nio.file.Files;
|
|
import java.nio.file.Path;
|
|
import java.nio.file.Paths;
|
|
import java.util.HashMap;
|
|
|
|
import nodeAC.nodeAC;
|
|
|
|
public class AnalyseHisto {
|
|
|
|
private HashMap<nodeAC,String> Correspondance = new HashMap<nodeAC,String>();
|
|
private HashMap<nodeAC,Integer> CorrespondancesTotal = new HashMap<nodeAC,Integer>();
|
|
private HashMap<nodeAC,String> CorrespondancesDate = new HashMap<nodeAC,String>();
|
|
private HashMap<nodeAC,String> CopyDate = new HashMap<nodeAC,String>();
|
|
private HashMap<nodeAC,Integer> NbrModificationDate = new HashMap<nodeAC,Integer>();
|
|
private HashMap<nodeAC,String> CorrespondancesCopier = new HashMap<nodeAC,String>();
|
|
|
|
public AnalyseHisto() {
|
|
|
|
}
|
|
|
|
|
|
|
|
// public AnalyseHisto(Run a, Boolean createBaseHisto, Classeur2 Sujet) throws IOException {
|
|
//
|
|
// // create base historique
|
|
// String EnsembleHistoriqueDesClasseurAnalyse="";
|
|
// ArrayList<nodeAC> LesHistorique = new ArrayList<nodeAC>();
|
|
//
|
|
// for(int i=0;i<a.getEC().getListeHistoriqueTableur().size();i++) {
|
|
// EnsembleHistoriqueDesClasseurAnalyse = EnsembleHistoriqueDesClasseurAnalyse + a.getEC().getListeHistoriqueTableur().get(i) + "\n\n";
|
|
// nodeAC n = a.XMLContent2(a.getEC().getListeHistoriqueTableur().get(i)).get(0);
|
|
// LesHistorique.add(n);
|
|
// }
|
|
// createBaseHistorique(a.getPatch(),EnsembleHistoriqueDesClasseurAnalyse);
|
|
//
|
|
// // initialisation du compteur de correspondance pour chaque fichier
|
|
// for(int i=0;i < LesHistorique.size();i++) {
|
|
// if(LesHistorique.get(i).getAttributs().get("name")!=null) {
|
|
// Correspondance.put(LesHistorique.get(i), "");
|
|
// CorrespondancesTotal.put(LesHistorique.get(i), 0);
|
|
// CorrespondancesDate.put(LesHistorique.get(i), "");
|
|
// CopyDate.put(LesHistorique.get(i), "");
|
|
// NbrModificationDate.put(LesHistorique.get(i), 0);
|
|
// CorrespondancesCopier.put(LesHistorique.get(i), "");
|
|
// }
|
|
// }
|
|
//
|
|
//
|
|
//
|
|
// LocalDateTime datetime1 = LocalDateTime.of(2017, 1, 14, 10, 34);
|
|
// LocalDateTime datetime2 = datetime1.plusDays(120);
|
|
//
|
|
//
|
|
//
|
|
//
|
|
//
|
|
//
|
|
// // analyse des historiques
|
|
// for(int j=0;j<LesHistorique.size();j++) {
|
|
//
|
|
// String nameStudent1 = LesHistorique.get(j).getAttributs().get("name");
|
|
// ArrayList<nodeAC> HistoStudent1 = a.XMLName(LesHistorique.get(j).getNodes(),"table:cell-content-change");
|
|
// String laDatePrecedent1 = "?";
|
|
// String laDatePrecedent2 = "?";
|
|
//
|
|
//
|
|
//
|
|
// //test
|
|
// ZonedDateTime zonedDateTime = null;
|
|
//
|
|
//
|
|
// int NbrCopy = 0 ;
|
|
// int NbrModif = 0 ;
|
|
// long L1 = 0 ;
|
|
// long L2 = 0 ;
|
|
//
|
|
// String copierKey1 = "";
|
|
// String copierKey2 = "";
|
|
// String messageDepart ="";
|
|
// String UneDateStudent1precedente ="";
|
|
// boolean messageDeaprtMis = false;
|
|
//
|
|
// String Idprecedent = "";
|
|
// for(int i1 = 0 ; i1 < HistoStudent1.size(); i1++) {
|
|
// String Id = HistoStudent1.get(i1).getAttributs().get("table:id");
|
|
//
|
|
// String UneDateStudent1 = a.XMLFirstName(HistoStudent1.get(i1),"dc:date").getContenu();
|
|
// datetime1 = LocalDateTime.parse(UneDateStudent1);
|
|
// zonedDateTime = ZonedDateTime.of(datetime1, ZoneId.systemDefault());
|
|
// L1 = zonedDateTime.toInstant().toEpochMilli();
|
|
//
|
|
// nodeAC celladdress = a.XMLFirstName(HistoStudent1.get(i1),"table:cell-address");
|
|
// String refStudent1 = "table:column=\"" + celladdress.getAttributs().get("table:column")+ "\" "
|
|
// + "table:row=\"" + celladdress.getAttributs().get("table:row")+ "\" "
|
|
// + "table:table=\"" + celladdress.getAttributs().get("table:table") + "\" ";
|
|
//
|
|
//
|
|
// // nombre de modification et nombre de cellule modifiées simultanément
|
|
// if(L1 < L2 ) {
|
|
// NbrCopy++;
|
|
//
|
|
// for(Entry<String,String> key :Sujet.Modif.getModif().entrySet()) {
|
|
// if(key.getValue().contains(refStudent1)) {
|
|
// if(copierKey1.isEmpty()) { copierKey1 = key.getKey();} else {copierKey2 = key.getKey();}
|
|
// }
|
|
// }
|
|
//
|
|
// if(!copierKey1.isEmpty() && copierKey1.equals(copierKey2) && !messageDepart.isEmpty()) {
|
|
// if( Sujet.Modif.getMessage().get(refStudent1)!=null && messageDeaprtMis) {
|
|
// CorrespondancesCopier.put(LesHistorique.get(j), CorrespondancesCopier.get(LesHistorique.get(j)) + " [( " + UneDateStudent1precedente + " ≈ " + UneDateStudent1 +" ) ( " + Idprecedent + " et " + Id + " ) " + Sujet.Modif.getMessage().get(refStudent1) + "]" );
|
|
// }
|
|
// if( Sujet.Modif.getMessage().get(refStudent1)!=null && !messageDeaprtMis) {
|
|
// CorrespondancesCopier.put(LesHistorique.get(j), CorrespondancesCopier.get(LesHistorique.get(j)) + " [( " + UneDateStudent1precedente + " ≈ " + UneDateStudent1 +" ) ( " + Idprecedent + " et " + Id + " ) " + messageDepart+ " "+ Sujet.Modif.getMessage().get(refStudent1) + "]" );
|
|
// messageDeaprtMis=true;
|
|
// }
|
|
// }
|
|
//
|
|
// }else {
|
|
// CopyDate.put(LesHistorique.get(j), CopyDate.get(LesHistorique.get(j)) + " " + NbrCopy );
|
|
// NbrCopy = 0 ;
|
|
// NbrModif++;
|
|
// copierKey1 = "";
|
|
// copierKey2 = "";
|
|
// messageDeaprtMis = false;
|
|
// messageDepart="";
|
|
// UneDateStudent1precedente="";
|
|
//
|
|
//
|
|
//
|
|
//
|
|
// }
|
|
//
|
|
// for(Entry<String,String> key :Sujet.Modif.getModif().entrySet()) {
|
|
// if(key.getValue().contains(refStudent1)) {
|
|
// copierKey1 = key.getKey();
|
|
// messageDepart = Sujet.Modif.getMessage().get(refStudent1);
|
|
// Idprecedent = Id;
|
|
// UneDateStudent1precedente = UneDateStudent1;
|
|
// }
|
|
// }
|
|
//
|
|
//
|
|
//
|
|
//
|
|
// L2 = L1 + 500; // ajoute 0.5 seconde intervalle de temps entre deux modifications manuelles
|
|
//
|
|
// NbrModificationDate.put(LesHistorique.get(j), NbrModif);
|
|
//
|
|
// System.out.println( j + "/" + LesHistorique.size() + " " + i1 + "/" +HistoStudent1.size() + " "+nameStudent1 + " date = " + UneDateStudent1 );
|
|
//
|
|
// for(int k = j+1 ; k < LesHistorique.size(); k++) {
|
|
//
|
|
// String nameStudent2 = LesHistorique.get(k).getAttributs().get("name");
|
|
// String HistoDateStudent2 = a.RetourTousLesDesNodes(a.XMLName(LesHistorique.get(k).getNodes(),"dc:date"));
|
|
//
|
|
// // Première boucle de recherche, directement les dates
|
|
// if(HistoDateStudent2.contains(UneDateStudent1)) {
|
|
//
|
|
// // Trouve une date de student1 qui correspond à une date de student2
|
|
// // Recherche le Node du student2
|
|
// ArrayList<nodeAC> HistoStudent2 = a.XMLName(LesHistorique.get(k).getNodes(),"table:cell-content-change");
|
|
// for(int k1 = 0 ; k1 < HistoStudent2.size(); k1++) {
|
|
// String UneDateStudent2 = a.XMLFirstName(HistoStudent2.get(k1), "dc:date").getContenu();
|
|
//
|
|
// if(UneDateStudent2.equals(UneDateStudent1)){
|
|
// //trouve le nodeAC de student2
|
|
// nodeAC address2 = a.XMLFirstName(HistoStudent2.get(k1), "table:cell-address");
|
|
// String RefStudent2 = "col=" + address2.getAttributs().get("table:column") + " row=" + address2.getAttributs().get("table:row") + " feuil=" + address2.getAttributs().get("table:table");
|
|
//
|
|
// nodeAC address1 = a.XMLFirstName(HistoStudent1.get(i1), "table:cell-address");
|
|
// String RefStudent1 = "col=" + address1.getAttributs().get("table:column") + " row=" + address1.getAttributs().get("table:row") + " feuil=" + address1.getAttributs().get("table:table");
|
|
//
|
|
// if(RefStudent2.equals(RefStudent1)){
|
|
// // Correspondance total
|
|
// Correspondance.put(LesHistorique.get(j), Correspondance.get(LesHistorique.get(j)) + " (" +nameStudent1 +"=" + nameStudent2+") ");
|
|
// CorrespondancesTotal.put(LesHistorique.get(j) , CorrespondancesTotal.get(LesHistorique.get(j))+1);
|
|
// CorrespondancesDate.put(LesHistorique.get(j), CorrespondancesDate.get(LesHistorique.get(j))+ " (date=" + UneDateStudent1 + " " + RefStudent1 + ") ");
|
|
//
|
|
// Correspondance.put(LesHistorique.get(k), Correspondance.get(LesHistorique.get(k)) + " (" +nameStudent1 +"=" + nameStudent2+") ");
|
|
// CorrespondancesTotal.put(LesHistorique.get(k) , CorrespondancesTotal.get(LesHistorique.get(k))+1);
|
|
// CorrespondancesDate.put(LesHistorique.get(k), CorrespondancesDate.get(LesHistorique.get(k))+ " (date=" + UneDateStudent1 + " " + RefStudent1 + ") ");
|
|
// }
|
|
//
|
|
//
|
|
// }
|
|
//
|
|
// }
|
|
//
|
|
// }
|
|
//
|
|
//
|
|
// }
|
|
//
|
|
// }
|
|
//
|
|
//
|
|
// System.out.println("\t\t"+nameStudent1 + " fin.");
|
|
// }
|
|
//
|
|
//
|
|
// System.getProperty("file.encoding","UTF-8");
|
|
// Path outputFilePath = Paths.get(a.getPatch() + "/" +"CorrespondanceHistorique.csv");
|
|
// BufferedWriter fichier = Files.newBufferedWriter(outputFilePath, StandardCharsets.UTF_8);
|
|
// fichier.write("name;mise en jeu etudiant ; nombre de correspondance ; reference correspondance ; nombre de cellules simultanement modifiee ; nombre de modification ; copier et coller interdit ; pénalité");
|
|
// for (Entry<nodeAC, String> j : Correspondance.entrySet()) {
|
|
// fichier.newLine();
|
|
// fichier.write(j.getKey().getAttributs().get("name") + ";" + j.getValue() + ";"+ CorrespondancesTotal.get(j.getKey()) + ";"+ CorrespondancesDate.get(j.getKey()) + ";" + CopyDate.get(j.getKey()) + ";" + NbrModificationDate.get(j.getKey()) + ";" + CorrespondancesCopier.get(j.getKey()));
|
|
// }
|
|
// fichier.close();
|
|
//
|
|
// System.out.println("\tFin de l'analyse de l'historique");
|
|
// }
|
|
|
|
|
|
public static void createBaseHistorique(String patch, String EnsembleHistoriqueDesClasseurAnalyse ) throws IOException {
|
|
System.getProperty("file.encoding","UTF-8");
|
|
|
|
Path outputFilePath = Paths.get(patch + "/baseHistorique.xml");
|
|
BufferedWriter fichier = Files.newBufferedWriter(outputFilePath, StandardCharsets.UTF_8);
|
|
|
|
fichier.write(EnsembleHistoriqueDesClasseurAnalyse);
|
|
fichier.close();
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|