Search in sources :

Example 1 with VipCoreHttpClient

use of dk.dbc.openagency.http.VipCoreHttpClient in project solr-document-store by DBCDK.

the class DocProducerIT method setUp.

@Before
public void setUp() throws Exception {
    try {
        pg.clearTables("bibliographicSolrKeys", "bibliographictobibliographic", "holdingsitemssolrkeys", "holdingstobibliographic");
        try (Connection connection = dataSource.getConnection();
            Statement stmt = connection.createStatement()) {
            stmt.executeUpdate("INSERT INTO openagencycache (agencyid, librarytype, partofbibdk, partofdanbib, authcreatecommonrecord, fetched, valid) VALUES(300000, 'FBSSchool', False, False, False, NOW(), True);");
            stmt.executeUpdate("INSERT INTO openagencycache (agencyid, librarytype, partofbibdk, partofdanbib, authcreatecommonrecord, fetched, valid) VALUES(300010, 'FBSSchool', False, False, False, NOW(), True);");
            stmt.executeUpdate("INSERT INTO openagencycache (agencyid, librarytype, partofbibdk, partofdanbib, authcreatecommonrecord, fetched, valid) VALUES(300101, 'FBSSchool', False, False, False, NOW(), True);");
            stmt.executeUpdate("INSERT INTO openagencycache (agencyid, librarytype, partofbibdk, partofdanbib, authcreatecommonrecord, fetched, valid) VALUES(300102, 'FBSSchool', False, False, False, NOW(), True);");
            stmt.executeUpdate("INSERT INTO openagencycache (agencyid, librarytype, partofbibdk, partofdanbib, authcreatecommonrecord, fetched, valid) VALUES(300103, 'FBSSchool', False, False, False, NOW(), True);");
        }
    } catch (SQLException ex) {
        log.trace("Exception: {}", ex.getMessage());
    }
    for (SolrCollection collection : config.getSolrCollections()) {
        SolrClient solrClient = collection.getSolrClient();
        solrClient.deleteByQuery("*:*");
        solrClient.commit();
    }
    docProducer = new DocProducer();
    docProducer.config = config;
    docProducer.libraryRuleProvider = new LibraryRuleProviderBean() {

        @Override
        public VipCoreLibraryRule libraryRulesFor(String agencyId) {
            switch(agencyId) {
                case "300000":
                case "300101":
                case "300102":
                case "300103":
                case "300104":
                case "777777":
                    return new VipCoreLibraryRuleMockResponse(true, true, false, true, false, true);
                default:
                    throw new IllegalArgumentException("Don't know library rules for: " + agencyId);
            }
        }
    };
    docProducer.persistentWorkIdProvider = new PersistentWorkIdProviderBean() {

        @Override
        public String persistentWorkIdFor(String corepoWorkId) {
            return "xxx";
        }
    };
    ProfileProviderBean profileProviderBean = new ProfileProviderBean();
    profileProviderBean.config = config;
    profileProviderBean.vipCoreHttpClient = new VipCoreHttpClient();
    docProducer.profileProvider = profileProviderBean;
    docProducer.init();
}
Also used : SQLException(java.sql.SQLException) Statement(java.sql.Statement) Connection(java.sql.Connection) VipCoreLibraryRule(dk.dbc.solrdocstore.updater.businesslogic.VipCoreLibraryRule) SolrClient(org.apache.solr.client.solrj.SolrClient) VipCoreHttpClient(dk.dbc.openagency.http.VipCoreHttpClient) Before(org.junit.Before)

Example 2 with VipCoreHttpClient

use of dk.dbc.openagency.http.VipCoreHttpClient in project solr-document-store by DBCDK.

the class WorkerIT method setUp.

@Before
public void setUp() throws Exception {
    try {
        pg.clearTables("bibliographicSolrKeys", "bibliographictobibliographic", "holdingsitemssolrkeys", "holdingstobibliographic", "openagencycache");
        try (Connection connection = dataSource.getConnection();
            Statement stmt = connection.createStatement()) {
            stmt.executeUpdate("INSERT INTO openagencycache (agencyid, librarytype, partofbibdk, partofdanbib, authcreatecommonrecord, fetched, valid) VALUES(300000, 'FBSSchool', False, False, False, NOW(), True);");
            stmt.executeUpdate("INSERT INTO openagencycache (agencyid, librarytype, partofbibdk, partofdanbib, authcreatecommonrecord, fetched, valid) VALUES(300010, 'FBSSchool', False, False, False, NOW(), True);");
            stmt.executeUpdate("INSERT INTO openagencycache (agencyid, librarytype, partofbibdk, partofdanbib, authcreatecommonrecord, fetched, valid) VALUES(300101, 'FBSSchool', False, False, False, NOW(), True);");
            stmt.executeUpdate("INSERT INTO openagencycache (agencyid, librarytype, partofbibdk, partofdanbib, authcreatecommonrecord, fetched, valid) VALUES(300102, 'FBSSchool', False, False, False, NOW(), True);");
            stmt.executeUpdate("INSERT INTO openagencycache (agencyid, librarytype, partofbibdk, partofdanbib, authcreatecommonrecord, fetched, valid) VALUES(300103, 'FBSSchool', False, False, False, NOW(), True);");
        }
    } catch (SQLException ex) {
        log.trace("Exception: {}", ex.getMessage());
    }
    for (SolrCollection solrCollection : config.getSolrCollections()) {
        SolrClient solrClient = solrCollection.getSolrClient();
        solrClient.deleteByQuery("*:*");
        solrClient.commit();
    }
    worker = new Worker();
    worker.config = config;
    String solrDocStoreUrl1 = config.getSolrDocStoreUrl();
    System.out.println("solrDocStoreUrl1 = " + solrDocStoreUrl1);
    worker.dataSource = dataSource;
    worker.es = Executors.newCachedThreadPool();
    DocProducer docProducer = worker.docProducer = new DocProducer();
    docProducer.config = config;
    docProducer.libraryRuleProvider = new LibraryRuleProviderBean() {

        @Override
        public VipCoreLibraryRule libraryRulesFor(String agencyId) {
            switch(agencyId) {
                case "300000":
                case "300101":
                case "300102":
                case "300103":
                case "300104":
                case "777777":
                    return new VipCoreLibraryRuleMockResponse(true, true, false, true, false, true);
                default:
                    throw new IllegalArgumentException("Don't know library rules for: " + agencyId);
            }
        }
    };
    docProducer.persistentWorkIdProvider = new PersistentWorkIdProviderBean() {

        @Override
        public String persistentWorkIdFor(String corepoWorkId) {
            return "xxx";
        }
    };
    ProfileProviderBean profileProviderBean = new ProfileProviderBean();
    profileProviderBean.config = config;
    profileProviderBean.vipCoreHttpClient = new VipCoreHttpClient();
    docProducer.profileProvider = profileProviderBean;
    docProducer.init();
    worker.init();
    try (Connection connection = dataSource.getConnection();
        Statement stmt = connection.createStatement()) {
        stmt.executeUpdate("TRUNCATE queue");
        stmt.executeUpdate("TRUNCATE queue_error");
    }
}
Also used : SQLException(java.sql.SQLException) Statement(java.sql.Statement) Connection(java.sql.Connection) VipCoreLibraryRule(dk.dbc.solrdocstore.updater.businesslogic.VipCoreLibraryRule) SolrClient(org.apache.solr.client.solrj.SolrClient) VipCoreHttpClient(dk.dbc.openagency.http.VipCoreHttpClient) Before(org.junit.Before)

Aggregations

VipCoreHttpClient (dk.dbc.openagency.http.VipCoreHttpClient)2 VipCoreLibraryRule (dk.dbc.solrdocstore.updater.businesslogic.VipCoreLibraryRule)2 Connection (java.sql.Connection)2 SQLException (java.sql.SQLException)2 Statement (java.sql.Statement)2 SolrClient (org.apache.solr.client.solrj.SolrClient)2 Before (org.junit.Before)2