use of mom.trd.opentheso.core.exports.privatesdatas.tables.Table in project opentheso by miledrousset.
the class TestExportPrivatesDatas method testWriteUsersIntoXML1.
@Test
public void testWriteUsersIntoXML1() {
HikariDataSource conn = openConnexionPool();
ExportPrivatesDatas exportPrivatesDatas = new ExportPrivatesDatas();
ArrayList<Table> usersList = exportPrivatesDatas.getDatasOfTable(conn, "alignement_type");
// ArrayList <Proposition> listPropo = exportPrivatesDatas.getProposition(conn);
// ArrayList <Concept_Candidat> listConceptC = exportPrivatesDatas.getconceptCandidat(conn);
// ArrayList <Term_Candidat> listTermC = exportPrivatesDatas.getTermeCandidat(conn);
// ArrayList <Concept_orphan> list_userRol = exportPrivatesDatas.getConceptOrphelin(conn);
// ArrayList <Concept_Fusion> list_userRol = exportPrivatesDatas.getconceptFusion(conn);
// ArrayList <Images> list_userRol = exportPrivatesDatas.getImages(conn);
// ArrayList <Preferences> list_userRol = exportPrivatesDatas.getPreferences(conn);
// ArrayList <Concept_Group_Historique> list_userRol = exportPrivatesDatas.getConceptGroupHist(conn);
// ArrayList <Concept_Group_Label_Historique> list_userRol = exportPrivatesDatas.getconceptGroupLabelH(conn);
// ArrayList <Concept_Historique> list_userRol = exportPrivatesDatas.getConceptHistorique(conn);
// ArrayList <Hierarchical_Relationship_Historique> list_userRol = exportPrivatesDatas.getHierarchicalRelationshipH(conn);
// ArrayList <Non_Preferred_Term> list_userRol = exportPrivatesDatas.getNonPreferredTerm(conn);
// ArrayList <Note_Historique> list_userRol = exportPrivatesDatas.getNoteHistorique(conn);
// ArrayList <Term_Historique> list_userRol = exportPrivatesDatas.getTermHistorique(conn);
conn.close();
writeHead();
startTable("users");
for (Table user : usersList) {
startLine();
for (LineOfData lineOfData : user.getLineOfDatas()) {
writeLine(lineOfData.getColomne(), lineOfData.getValue());
}
endLine();
}
endTable("users");
System.out.println(xml);
}
use of mom.trd.opentheso.core.exports.privatesdatas.tables.Table in project opentheso by miledrousset.
the class testcreationconexionBD method avoirContent.
@Test
public void avoirContent(HikariDataSource ds) {
String sCadena = "";
String retorno = "";
Statement stmt;
Connection conn;
File fichier = new File("C:\\Users\\antonio.perez\\Documents\\NetBeansProjects\\opentheso\\src\\main\\resources\\install\\opentheso_dist_4.0.9.sql");
if (fichier.exists()) {
try {
BufferedReader bf = new BufferedReader(new FileReader(fichier));
while ((sCadena = bf.readLine()) != null) {
retorno += sCadena;
}
} catch (FileNotFoundException fnfe) {
} catch (IOException ioe) {
}
try {
Connection connection = ds.getConnection();
stmt = connection.createStatement();
try {
// récupération des noms des colonnes de la table
String query = "create Database prueba with owner opentheso";
System.out.println(query);
stmt.executeUpdate(query);
} finally {
stmt.close();
connection.close();
}
} catch (SQLException ex) {
Logger.getLogger(Table.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
use of mom.trd.opentheso.core.exports.privatesdatas.tables.Table in project opentheso by miledrousset.
the class testimportxml method ouvreFichier.
// TODO add test methods here.
// The methods must be annotated with annotation @Test. For example:
//
@Test
public void ouvreFichier() {
HikariDataSource conn = openConnexionPool();
SAXBuilder builder = new SAXBuilder();
ArrayList<Table> toutTables = new ArrayList<>();
ArrayList<LineOfData> lineOfDatas = new ArrayList<>();
File xmlFile = new File("C:/Users/antonio.perez/Desktop/testbon.xml");
try {
// Se crea el documento a traves del archivo
Document document = (Document) builder.build(xmlFile);
// Se obtiene la raiz 'tables'
Element rootNode = document.getRootElement();
// Se obtiene la lista de hijos de la raiz 'tables'
// ici on a toutes les tables (les enfants de la racine)
List list = rootNode.getChildren("table");
// Se recorre la lista de hijos de 'tables'
for (int i = 0; i < list.size(); i++) {
// Se obtiene el elemento 'tabla'
// ici on a la première table
Element tabla = (Element) list.get(i);
// Se obtiene el atributo 'nombre' que esta en el tag 'tabla'
// ici on a le nom de la table
String nombreTabla = tabla.getAttributeValue("nom");
System.out.println("Nom de la table : " + nombreTabla);
// Se obtiene la lista de hijos del tag 'tabla'
// ici c'est la liste des lignes de la table
List lista_campos = tabla.getChildren();
// ici on découpe la liste des lignes
for (int j = 0; j < lista_campos.size(); j++) {
// Se obtiene el elemento 'campo'
// ici on a une ligne de la table
Element campo = (Element) lista_campos.get(j);
// System.out.println("nouvelle ligne table "+ nombreTabla);
for (Element colonne : campo.getChildren()) {
LineOfData lineOfData = new LineOfData();
// System.out.println("Nom de la colonne = " + colonne.getName());
// System.out.println("valeur de la colonne = " + colonne.getText());
lineOfData.setColomne(colonne.getName());
lineOfData.setValue(colonne.getText());
lineOfDatas.add(lineOfData);
}
insertLine(conn, lineOfDatas, nombreTabla);
lineOfDatas.clear();
}
// / mettre à jour la table dans la BDD
}
} catch (IOException io) {
System.out.println(io.getMessage());
} catch (JDOMException jdomex) {
System.out.println(jdomex.getMessage());
}
}
use of mom.trd.opentheso.core.exports.privatesdatas.tables.Table in project opentheso by miledrousset.
the class testimportxml method insertLine.
private void insertLine(HikariDataSource ds, ArrayList<LineOfData> table, String nomtable) {
Statement stmt;
String nomcolun = "";
String values = "";
boolean first = true;
for (LineOfData lineOfData : table) {
if (!first) {
nomcolun += ",";
values += ",";
}
nomcolun += lineOfData.getColomne();
if (lineOfData.getValue() == null)
values += "";
else
values += "'" + lineOfData.getValue() + "'";
first = false;
}
values += ");";
System.out.println(nomcolun);
System.out.println(values);
try {
Connection connection = ds.getConnection();
stmt = connection.createStatement();
try {
System.out.println(nomtable);
// récupération des noms des colonnes de la table
String query = "INSERT INTO " + nomtable + " ( " + nomcolun + ") VALUES (" + values;
System.out.println(query);
stmt.executeUpdate(query);
} finally {
stmt.close();
connection.close();
}
} catch (SQLException ex) {
Logger.getLogger(Table.class.getName()).log(Level.SEVERE, null, ex);
}
}
use of mom.trd.opentheso.core.exports.privatesdatas.tables.Table in project opentheso by miledrousset.
the class testoublie method vide.
private void vide(HikariDataSource ds, String email) throws SQLException {
String nouvellePass = "";
Statement stmt;
ResultSet resultSet;
try {
Connection conn = ds.getConnection();
stmt = conn.createStatement();
try {
String query = "Select username from users where mail ='" + email + "'";
resultSet = stmt.executeQuery(query);
if (resultSet != null) {
nouvellePass = MD5Password.getEncodedPassword(genererNouvellePass());
String queryAjoute = "alter table users add motpasstemp varchar(100)";
stmt.executeQuery(queryAjoute);
}
} finally {
stmt.close();
conn.close();
insertNP(ds, nouvellePass, email);
}
} catch (SQLException ex) {
Logger.getLogger(Table.class.getName()).log(Level.SEVERE, null, ex);
}
}
Aggregations