Premier commit - Inclusion dans le projet git

This commit is contained in:
Mysaa 2021-05-24 15:57:42 +02:00
commit 2c0b74a366
10 changed files with 288 additions and 0 deletions

16
.gitignore vendored Normal file
View File

@ -0,0 +1,16 @@
bin/
.settings
gradlew
gradlew.bat
gradle/
.gradle/
*.toc
*.log
*.aux
*.synctex.gz
*.test.xml
test.ods
build
.classpath
.project

38
build.gradle Normal file
View File

@ -0,0 +1,38 @@
/*
* This file was generated by the Gradle 'init' task.
*
* This generated file contains a sample Java Library project to get you started.
* For more details take a look at the Java Libraries chapter in the Gradle
* user guide available at https://docs.gradle.org/4.10.2/userguide/java_library_plugin.html
*/
plugins {
// Apply the java-library plugin to add support for Java Library
id 'java-library'
}
dependencies {
// This dependency is exported to consumers, that is to say found on their compile classpath.
api 'org.apache.commons:commons-math3:3.6.1'
// This dependency is used internally, and not exposed to consumers on their own compile classpath.
implementation 'com.google.guava:guava:23.0'
// Use JUnit test framework
testImplementation 'junit:junit:4.12'
// https://mvnrepository.com/artifact/mysql/mysql-connector-java
compile group: 'mysql', name: 'mysql-connector-java', version: '8.0.13'
// https://mvnrepository.com/artifact/org.jopendocument/jOpenDocument
compile group: 'org.jopendocument', name: 'jOpenDocument', version: '1.3'
}
// In this section you declare where to find the dependencies of your project
repositories {
// Use jcenter for resolving your dependencies.
// You can declare any Maven/Ivy/file repository here.
jcenter()
}

10
settings.gradle Normal file
View File

@ -0,0 +1,10 @@
/*
* This file was generated by the Gradle 'init' task.
*
* The settings file is used to specify which projects to include in your build.
*
* Detailed information about configuring a multi-project build in Gradle can be found
* in the user guide at https://docs.gradle.org/4.10.2/userguide/multi_project_builds.html
*/
rootProject.name = 'Kholloscopinator'

View File

@ -0,0 +1,15 @@
package com.bernard.kholle;
import java.io.File;
import com.bernard.kholle.process.KholloscopeProcessor;
public class KholloMain {
public static void main(String[] args) {
System.out.println("Wiouw");
System.out.println(new File(".").getAbsolutePath());
KholloscopeProcessor.khollize(new File("./kholloscope2018_1.ods"));
}
}

View File

@ -0,0 +1,7 @@
package com.bernard.kholle.model;
public class Eleve {
String nom;
String prenom;
int[] groups;// 1(ALL) , 7(INFO2) ,...
}

View File

@ -0,0 +1,12 @@
package com.bernard.kholle.model;
public class Horaire {
String day;//Lun, Mar, Mer ...
String hour;//12-13,13-14,15-16, ...
byte[] place;// 1(S1), 2(S2)
byte[] tags;// 1(M , midi), 2(S, soir)
String[] profs;// LEVAUX, PRINCIAUX, LAMARTINE, ...
int[] groups;// 1(ALL) , 7(INFO2) ,...
}

View File

@ -0,0 +1,8 @@
package com.bernard.kholle.model;
public class KGroup {
Eleve[] élèves;
int[] constrains;// 1(ALL) , 7(INFO2) ,...
}

View File

@ -0,0 +1,61 @@
package com.bernard.kholle.model;
public class Kholle {
String tag,hour;
String semaine;
String prof;
int kGroup;
String salle;
public Kholle(String tag, String hour, String semaine, String prof, int kGroup, String salle) {
super();
this.tag = tag;
this.hour = hour;
this.semaine = semaine;
this.prof = prof;
this.kGroup = kGroup;
this.salle = salle;
}
@Override
public String toString() {
return "Kholle [tag=" + tag + ", hour=" + hour + ", semaine=" + semaine + ", prof=" + prof + ", kGroup="
+ kGroup + ", salle=" + salle + "]";
}
public String getTag() {
return tag;
}
public String getHour() {
return hour;
}
public String getSemaine() {
return semaine;
}
public String getProf() {
return prof;
}
public int getkGroup() {
return kGroup;
}
public String getSalle() {
return salle;
}
}

View File

@ -0,0 +1,19 @@
package com.bernard.kholle.process;
import java.util.Map;
import com.bernard.kholle.model.Eleve;
import com.bernard.kholle.model.Horaire;
import com.bernard.kholle.model.Kholle;
public class KholloMaker {
public static final Kholle[] findBestKholloscope(Eleve[] eleves, Horaire[] horaires, Map<String,String> profs /* {PRINCIAUX,Math},{BOUSSAGEON,Physique}*/) {
return null;
}
}

View File

@ -0,0 +1,102 @@
package com.bernard.kholle.process;
import java.io.File;
import java.io.IOException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import org.jopendocument.dom.spreadsheet.Sheet;
import org.jopendocument.dom.spreadsheet.SpreadSheet;
import com.bernard.kholle.model.Kholle;
public class KholloscopeProcessor {
public static List<Kholle> khollize(File f){
List<Kholle> kholles = new ArrayList<>();
try {
SpreadSheet sheet = SpreadSheet.createFromFile(f);
Sheet khollesSheet = sheet.getFirstSheet();
parseCell(4, 19, 7, 21, khollesSheet, kholles);
parseCell(4, 19, 23, 35, khollesSheet, kholles);
parseCell(4, 19, 37, 46, khollesSheet, kholles);
System.out.println(kholles);
System.out.println(kholles.size());
} catch (IOException e) {
e.printStackTrace();
}
return kholles;
}
public static void parseCell(int x0,int x1,int y0,int y1,Sheet khollesSheet,List<Kholle> kholles) {
for(int i = y0;i<y1;i++) {
String prof = khollesSheet.getImmutableCellAt(0, i).getTextValue();//A voir pour les cell jointes
String time = khollesSheet.getImmutableCellAt(2, i).getTextValue();//A voir pour les cell jointes
String salle = khollesSheet.getImmutableCellAt(3, i).getTextValue();//A voir pour les cell jointes
for(int j = x0;j<x1;j++) {
String groupe = khollesSheet.getImmutableCellAt(j, i).getTextValue();
try {
int kGroup = Integer.parseInt(groupe);
kholles.add(new Kholle(time.split(" ")[0], time.split(" ")[1], khollesSheet.getImmutableCellAt(j, 2).getTextValue(), prof, kGroup, salle));
}catch(NumberFormatException e) {
}
}
}
}
public static List<String> sqlize(List<Kholle> kholles,Connection c){
List<String> statements = new ArrayList<>();
final String STATEMENT = "INSERT INTO kholles (ID,tag,hour,semaine,prof,kGroup,salle) VALUES (NULL,?,?,?,?,?,?)";
for(Kholle k : kholles) {
try {
PreparedStatement st = c.prepareStatement(STATEMENT);
st.setString(1, k.getTag());
st.setString(2, k.getHour());
st.setString(3, k.getSemaine());
st.setString(4, k.getProf());
st.setInt(5, k.getkGroup());
st.setString(6, k.getSalle());
try {
Class<?> stmt1 = st.getClass();
java.lang.reflect.Field mem = stmt1.getField("sql");
String value = (String)mem.get(st);
System.out.println(value);
} catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException e) {
e.printStackTrace();
}
st.execute();
} catch (SQLException e) {
e.printStackTrace();
}
}
return statements;
}
}