use of org.apache.stanbol.entityhub.yard.sesame.SesameYardConfig in project stanbol by apache.
the class SesameYardTest method initYard.
@BeforeClass
public static final void initYard() throws RepositoryException {
SesameYardConfig config = new SesameYardConfig("testYardId");
config.setName("Sesame Yard Test");
config.setDescription("The Sesame Yard instance used to execute the Unit Tests defined for the Yard Interface");
repo = new SailRepository(new MemoryStore());
repo.initialize();
yard = new SesameYard(repo, config);
}
use of org.apache.stanbol.entityhub.yard.sesame.SesameYardConfig in project stanbol by apache.
the class SesameContextTest method initYard.
@BeforeClass
public static final void initYard() throws RepositoryException {
repo.initialize();
// create the graphs in Clerezza
// init the ClerezzaYards for the created Clerezza graphs
SesameYardConfig yard1config = new SesameYardConfig("context 1 yard");
yard1config.setName("Yard over context 1");
yard1config.setContextEnabled(true);
yard1config.setContexts(new String[] { CONTEXT1.stringValue() });
yard1 = new SesameYard(repo, yard1config);
SesameYardConfig yard2config = new SesameYardConfig("context 2 yard");
yard2config.setName("Yard over context 2");
yard2config.setContextEnabled(true);
yard2config.setContexts(new String[] { CONTEXT2.stringValue() });
yard2 = new SesameYard(repo, yard2config);
SesameYardConfig unionYardConfig = new SesameYardConfig("union yard");
unionYardConfig.setName("Union Yard");
unionYard = new SesameYard(repo, unionYardConfig);
yards = Arrays.asList(yard1, yard2, unionYard);
// add the test data (to the Repository to also test pre-existing data)
RepositoryConnection con = repo.getConnection();
con.begin();
URI entity1 = sesameFactory.createURI("http://www.test.org/entity1");
con.add(entity1, rdfType, skosConcept, CONTEXT1);
con.add(entity1, skosPrefLabel, sesameFactory.createLiteral("test context one", EN), CONTEXT1);
con.add(entity1, skosPrefLabel, sesameFactory.createLiteral("Test Context Eins", DE), CONTEXT1);
expectedEntities.put(entity1, Arrays.asList(yard1, unionYard));
URI entity2 = sesameFactory.createURI("http://www.test.org/entity2");
con.add(entity2, rdfType, skosConcept, CONTEXT2);
con.add(entity2, skosPrefLabel, sesameFactory.createLiteral("test context two", EN), CONTEXT2);
con.add(entity2, skosPrefLabel, sesameFactory.createLiteral("Test Context Zwei", DE), CONTEXT2);
expectedEntities.put(entity2, Arrays.asList(yard2, unionYard));
con.commit();
con.close();
}
use of org.apache.stanbol.entityhub.yard.sesame.SesameYardConfig in project stanbol by apache.
the class SesameYardComponent method activate.
/**
* Register a service tracker for the KiWiRepositoryService; once it is there, register a new SesameYard.
*
* @param context
* @throws ConfigurationException
* @throws RepositoryException
*/
@Activate
protected final void activate(ComponentContext context) throws ConfigurationException, RepositoryException {
@SuppressWarnings("unchecked") Dictionary<String, Object> config = context.getProperties();
this.config = config;
this.bundleContext = context.getBundleContext();
repoId = (String) config.get(REPOSITORY_ID);
if (repoId != null && repoId.trim().isEmpty()) {
repoId = null;
}
log.info(" - repository ID: {}", repoId);
String filterStr;
if (repoId != null) {
filterStr = String.format("(&(objectClass=%s)(%s=%s))", Repository.class.getName(), REPOSITORY_ID, repoId);
} else {
filterStr = String.format("(&(objectClass=%s))", Repository.class.getName());
}
Filter filter;
try {
log.info(" - service Filter: {}", filterStr);
filter = bundleContext.createFilter(filterStr);
} catch (InvalidSyntaxException e) {
throw new ConfigurationException(REPOSITORY_ID, "Unable to build Service " + "Filter with parsed Repository ID '" + repoId + "' (filter: '" + filterStr + "')", e);
}
yardConfig = new SesameYardConfig(config);
// check context is set
Object value = config.get(SesameYard.CONTEXT_ENABLED);
if (value == null || value.toString().trim().isEmpty()) {
// not set ... set default to TRUE
yardConfig.setContextEnabled(true);
} else if (!yardConfig.isContextEnabled()) {
// want to allow)!
throw new ConfigurationException(SesameYard.CONTEXT_ENABLED, "Sesame Contexts MUST BE enabled for the Kiwi TripleStore Yard");
}
repositoryTracker = new ServiceTracker(bundleContext, filter, this);
log.info(" ... start tracking for Sesame Repositories");
repositoryTracker.open();
}
Aggregations