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();
}
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");
}
}
Aggregations