Search in sources :

Example 76 with HikariDataSource

use of com.zaxxer.hikari.HikariDataSource in project opentheso by miledrousset.

the class QueriesPostgresTest method modifyIdToNumeric.

@org.junit.Test
public void modifyIdToNumeric() {
    HikariDataSource conn = openConnexionPool();
    ConceptHelper conceptHelper = new ConceptHelper();
    boolean status = conceptHelper.setIdConceptToNumeric(conn, "1", "Tz6caNb7Jg");
    conn.close();
    System.out.println("");
}
Also used : HikariDataSource(com.zaxxer.hikari.HikariDataSource)

Example 77 with HikariDataSource

use of com.zaxxer.hikari.HikariDataSource in project opentheso by miledrousset.

the class TestExportTabulate method openConnexionPool.

private HikariDataSource openConnexionPool() {
    HikariConfig config = new HikariConfig();
    config.setMinimumIdle(1);
    config.setMaximumPoolSize(1000);
    // config.setJdbc4ConnectionTest(false);
    config.setConnectionTestQuery("SELECT 1");
    config.setDataSourceClassName("org.postgresql.ds.PGSimpleDataSource");
    /*   config.addDataSourceProperty("user", "opentheso");
         config.addDataSourceProperty("password", "opentheso");
         config.addDataSourceProperty("databaseName", "OTW");
         */
    config.addDataSourceProperty("user", "pactols");
    config.addDataSourceProperty("password", "frantiq2014");
    config.addDataSourceProperty("databaseName", "pactols");
    // config.addDataSourceProperty("serverName", "localhost");
    config.addDataSourceProperty("portNumber", "5432");
    config.addDataSourceProperty("serverName", "opentheso.mom.fr");
    // config.addDataSourceProperty("serverName", "193.48.137.88");
    HikariDataSource poolConnexion1 = new HikariDataSource(config);
    return poolConnexion1;
}
Also used : HikariDataSource(com.zaxxer.hikari.HikariDataSource) HikariConfig(com.zaxxer.hikari.HikariConfig)

Example 78 with HikariDataSource

use of com.zaxxer.hikari.HikariDataSource in project opentheso by miledrousset.

the class TestGetSiteMap method openConnexionPool.

private HikariDataSource openConnexionPool() {
    HikariConfig config = new HikariConfig();
    config.setMinimumIdle(1);
    config.setMaximumPoolSize(1000);
    config.setConnectionTestQuery("SELECT 1");
    config.setDataSourceClassName("org.postgresql.ds.PGSimpleDataSource");
    /*    config.addDataSourceProperty("user", "opentheso");
         config.addDataSourceProperty("password", "opentheso");
         config.addDataSourceProperty("databaseName", "OTW");
         */
    config.addDataSourceProperty("user", "pactols");
    config.addDataSourceProperty("password", "pactols");
    config.addDataSourceProperty("databaseName", "pactols");
    // config.addDataSourceProperty("serverName", "localhost");
    config.addDataSourceProperty("portNumber", "5433");
    config.addDataSourceProperty("serverName", "localhost");
    // config.addDataSourceProperty("serverName", "193.48.137.88");
    HikariDataSource poolConnexion1 = new HikariDataSource(config);
    return poolConnexion1;
}
Also used : HikariDataSource(com.zaxxer.hikari.HikariDataSource) HikariConfig(com.zaxxer.hikari.HikariConfig)

Example 79 with HikariDataSource

use of com.zaxxer.hikari.HikariDataSource in project opentheso by miledrousset.

the class TestGetSiteMap method testExportAllDatas.

/**
 * Test of Get datas for SiteMap.
 */
@org.junit.Test
public void testExportAllDatas() {
    HikariDataSource conn = openConnexionPool();
    ConceptHelper conceptHelper = new ConceptHelper();
    ArrayList<NodeConceptArkId> nodeConceptArkIds = conceptHelper.getAllConceptArkIdOfThesaurus(conn, "TH_1");
    // ArrayList<String> allIds = conceptHelper.getAllIdConceptOfThesaurus(conn, "TH_1");
    String url;
    Date actuelle = new Date();
    // * Definition du format utilise pour les dates
    DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
    // * Donne la date au format "aaaa-mm-jj"
    String dat = dateFormat.format(actuelle);
    StringBuilder siteMap = new StringBuilder();
    siteMap.append("<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">\n");
    for (NodeConceptArkId nodeConceptArkId : nodeConceptArkIds) {
        // http://ark.frantiq.fr/ark:/26678/pcrtoBSSWiOt51
        // c'est l'URL qu'il faut composer.
        siteMap.append("  <url>\n");
        siteMap.append("    <loc>");
        // siteMap.append("http://pactols.frantiq.fr/opentheso/?idc=");
        // if(nodeConceptArkId.getIdArk() == null || nodeConceptArkId.getIdArk().isEmpty()){
        siteMap.append("http://pactols.frantiq.fr/opentheso/?idc=");
        siteMap.append(nodeConceptArkId.getIdConcept());
        siteMap.append("&amp;idt=TH_1");
        /*   } else {
                siteMap.append("http://ark.frantiq.fr/ark:/");
                siteMap.append(nodeConceptArkId.getIdArk());
            }*/
        // siteMap.append(url);
        siteMap.append("</loc>\n");
        if (dat != null) {
            siteMap.append("    <lastmod>");
            siteMap.append(dat);
            siteMap.append("</lastmod>\n");
            siteMap.append("    <changefreq>");
            siteMap.append("monthly");
            siteMap.append("</changefreq>\n");
            siteMap.append("    <priority>0.9</priority>\n");
        }
        siteMap.append("  </url>\n");
    }
    /*    for (String allId : allIds) { 
            // http://pactols.frantiq.fr/opentheso/?idc=13412&idt=TH_1
            // c'est l'URL qu'il faut composer.
            
            url = conceptHelper.getIdArkOfConcept(conn, allId, "TH_1");
          //  date = conceptHelper.getModifiedDateOfConcept(conn, allId, "TH_1");

            siteMap.append("  <url>\n");
            siteMap.append("    <loc>");
            siteMap.append("http://ark.frantiq.fr/ark:/");
        //    siteMap.append("http://pactols.frantiq.fr/opentheso/?idc=");
            
            
            siteMap.append(allId);
            siteMap.append("&amp;idt=TH_1");
         //   siteMap.append(url);
            siteMap.append("</loc>\n");
            
            if(dat != null) {
                siteMap.append("    <lastmod>");
                siteMap.append(dat);
                siteMap.append("</lastmod>\n");
            }
            siteMap.append("  </url>\n");
        }
        */
    siteMap.append("</urlset>");
    System.out.println(siteMap.toString());
    conn.close();
}
Also used : HikariDataSource(com.zaxxer.hikari.HikariDataSource) SimpleDateFormat(java.text.SimpleDateFormat) DateFormat(java.text.DateFormat) NodeConceptArkId(mom.trd.opentheso.bdd.helper.nodes.NodeConceptArkId) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date)

Example 80 with HikariDataSource

use of com.zaxxer.hikari.HikariDataSource in project opentheso by miledrousset.

the class TestImportBranch method TestImportMultiBranchUnderGroup.

/**
 * Test of Tabulate reading.
 */
/*    @org.junit.Test

    public void testImportBranchAfterGroup() {    
        HikariDataSource conn = openConnexionPool();
        
        String idTheso = "";
        String idGroup = "";
        String path = "/Users/Miled/ownCloud_cnrs/Projets/OpenTheso/artefacts/25.xml";
       
        String dateFromat = "yyyy-MM-dd";
        boolean useArk = false;
        String adresseSite = "http://localhost";      
        int idUser = 1;


        
        FileInputStream file = readFile(path); 
        
        SKOSXmlDocument sKOSXmlDocument = readSkosFile(conn,
                file,
                dateFromat,
                useArk,
                adresseSite);
                

        // permet d'importer une branche entière sous un domaine avec l'alignement automatique à la source
        WriteBranchSkosBDD writeBranchSkosBDD = new WriteBranchSkosBDD(conn);
        //idGroup, idThesaurus, sKOSXmlDocument, dateFormat, ark, adressSite, user);
        writeBranchSkosBDD.importBranchAfterGroup(
                idGroup,
                idTheso,
                sKOSXmlDocument, dateFromat, useArk,
                adresseSite, idUser);
    }*/
/**
 * Test of Tabulate reading.
 */
@org.junit.Test
public void TestImportMultiBranchUnderGroup() {
    HikariDataSource conn = openConnexionPool();
    String idTheso = "1";
    String idGroup = "";
    String path = "/Users/Miled/ownCloud_cnrs/GDS_FRANTIQ/Pactols/2016-11-15/Sujets.xml";
    String dateFromat = "yyyy-MM-dd";
    boolean useArk = false;
    String adresseSite = "http://localhost";
    int idUser = 1;
    FileInputStream file = readFile(path);
    SKOSXmlDocument sKOSXmlDocument = readSkosFile(conn, file, dateFromat, useArk, adresseSite);
    // permet d'importer une branche entière avec son domaine en intégrant l'alignement à la source
    WriteBranchSkosBDD writeBranchSkosBDD = new WriteBranchSkosBDD(conn);
    // idGroup, idThesaurus, sKOSXmlDocument, dateFormat, ark, adressSite, user);
    writeBranchSkosBDD.importMultiBranchUnderGroup(idTheso, idGroup, sKOSXmlDocument, dateFromat, useArk, adresseSite, idUser);
}
Also used : HikariDataSource(com.zaxxer.hikari.HikariDataSource) WriteBranchSkosBDD(mom.trd.opentheso.core.imports.old.WriteBranchSkosBDD) SKOSXmlDocument(skos.SKOSXmlDocument) FileInputStream(java.io.FileInputStream)

Aggregations

HikariDataSource (com.zaxxer.hikari.HikariDataSource)185 HikariConfig (com.zaxxer.hikari.HikariConfig)109 Test (org.junit.Test)106 Connection (java.sql.Connection)61 TestElf.newHikariConfig (com.zaxxer.hikari.pool.TestElf.newHikariConfig)57 SQLException (java.sql.SQLException)33 StubConnection (com.zaxxer.hikari.mocks.StubConnection)30 TestElf.newHikariDataSource (com.zaxxer.hikari.pool.TestElf.newHikariDataSource)18 StubDataSource (com.zaxxer.hikari.mocks.StubDataSource)11 MetricRegistry (com.codahale.metrics.MetricRegistry)9 DataSource (javax.sql.DataSource)8 Statement (java.sql.Statement)7 ArrayList (java.util.ArrayList)7 FacesMessage (javax.faces.application.FacesMessage)7 BoneCPDataSource (com.jolbox.bonecp.BoneCPDataSource)6 PoolInitializationException (com.zaxxer.hikari.pool.HikariPool.PoolInitializationException)6 Properties (java.util.Properties)6 ConnexionTest (connexion.ConnexionTest)5 File (java.io.File)5 FileInputStream (java.io.FileInputStream)5