Premier commit - Inclusion dans le projet git
This commit is contained in:
@@ -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"));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.bernard.kholle.model;
|
||||
|
||||
public class Eleve {
|
||||
String nom;
|
||||
String prenom;
|
||||
int[] groups;// 1(ALL) , 7(INFO2) ,...
|
||||
}
|
||||
@@ -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) ,...
|
||||
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package com.bernard.kholle.model;
|
||||
|
||||
public class KGroup {
|
||||
|
||||
Eleve[] élèves;
|
||||
int[] constrains;// 1(ALL) , 7(INFO2) ,...
|
||||
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user