本文整理了Java中org.apache.stanbol.entityhub.servicesapi.yard.Yard
类的一些代码示例,展示了Yard
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Yard
类的具体详情如下:
包路径:org.apache.stanbol.entityhub.servicesapi.yard.Yard
类名称:Yard
[英]The Yard represents a local cache for Representations of the Entities and Symbols managed by a referenced site.
Referenced Sites need to provide the configuration if there representations should be cached locally. This is done by using one of the defined CacheStrategy.
The Idea is not to have one big Yard that caches all the representations, but to provide the possibility to use different caches. This means, that each Site can have its own Yard instance. However several Sites might also use the same Yard.
The YardManager is an singleton services that manages the different Yard instances and provides an central point of access for the Entityhuband the SiteManager.
This should also allow for implementing Yards that are based on
Side note: The name yard was chosen as name because in farming "yard" refers to a piece of enclosed land for farm animals or other agricultural purpose and the storage component of the entityhub does the same thing for Entities.
[中]庭院代表一个本地缓存,用于表示被引用站点管理的实体和符号。
如果应该在本地缓存表示,则引用的站点需要提供配置。这是通过使用一种已定义的缓存策略来实现的。
我们的想法不是要有一个大院子来缓存所有的表示,而是提供使用不同缓存的可能性。这意味着,每个站点都可以有自己的庭院实例。然而,几个场地也可能使用同一个场地。
YardManager是一个单例服务,它管理不同的Yard实例,并为EntityHub和SiteManager提供一个中心访问点。
这也应该允许实现基于
*由引用站点的转储生成的索引
*所指站点使用的软件的本地安装
*等等。。。
TODO:框架需要提供一个特殊的场地来存储符号和实体映射信息。该场地目前被称为Entityhub场地。我们还需要一个特殊的API来处理这个院子吗?仍然可以提供一个“默认”实现,该实现基于一个提供正常庭院服务的组件来实现该接口。
旁注:之所以选择“庭院”作为名称,是因为在农业中,“庭院”指的是一块用于农场动物或其他农业用途的封闭土地,entityhub的存储组件对实体也有同样的作用。
代码示例来源:origin: org.apache.stanbol/org.apache.stanbol.entityhub.core
@Override
public void removeAll() throws YardException {
//ensure that the baseConfig (if present) is not deleted by this
//operation
Representation baseConfig = yard.getRepresentation(Cache.BASE_CONFIGURATION_URI);
yard.removeAll();
if(baseConfig != null){
yard.store(baseConfig);
}
}
代码示例来源:origin: apache/stanbol
@Override
protected ValueFactory getValueFactory() {
return yard.getValueFactory();
}
@Override
代码示例来源:origin: apache/stanbol
@Override
public final QueryResultList<String> findEntityReferences(FieldQuery query) throws YardException{
return entityhubYard.findReferences(query);
}
@Override
代码示例来源:origin: org.apache.stanbol/org.apache.stanbol.entityhub.core
/**
* Stores the current configuration used for caching documents back to the
* {@link Yard}. This configuration is present in the {@link #additionalMapper}).
* If this field is <code>null</code> than any existing configuration is
* removed form the index.
* @throws YardException on any error while changing the configuration in the
* yard.
* @throws IllegalArgumentException if <code>null</code> is parsed as {@link Yard}.
*/
protected static void storeAdditionalMappingsConfiguration(Yard yard,FieldMapper additionalMapper) throws YardException,IllegalArgumentException {
if(yard == null){
throw new IllegalArgumentException("The parsed Yard MUST NOT be NULL!");
}
if(additionalMapper == null){
yard.remove(Cache.ADDITIONAL_CONFIGURATION_URI);
} else {
Representation config = yard.getValueFactory().createRepresentation(Cache.ADDITIONAL_CONFIGURATION_URI);
writeFieldConfig(config,additionalMapper);
yard.store(config);
}
}
/**
代码示例来源:origin: apache/stanbol
Representation test1 = yard.create(id); // create and add
yard.store(test1);// store
Representation test2 = yard.getValueFactory().createRepresentation(id2); // create
yard.store(test2);// store
assertTrue(yard.isRepresentation(test1.getId())); // test if stored
assertTrue(yard.isRepresentation(test2.getId()));
yard.removeAll(); // remove
assertFalse(yard.isRepresentation(test1.getId())); // test if removed
assertFalse(yard.isRepresentation(test2.getId()));
yard.store(test1);// store
assertTrue(yard.isRepresentation(test1.getId())); // test if stored
yard.removeAll(); // remove
assertFalse(yard.isRepresentation(test1.getId()));
代码示例来源:origin: apache/stanbol
@Test
public void testFindTextWildcards(){
//init the test data
FieldQueryTestData data = getFieldQueryTestData();
//prefix search with *
FieldQuery query = getYard().getQueryFactory().createFieldQuery();
String wildcard = data.textValue1.getText();
wildcard = wildcard.substring(0, wildcard.length()-1) + "*";
query.setConstraint(data.textField, new TextConstraint(wildcard,PatternType.wildcard,false, "en"));
query.addSelectedField(data.refField);
query.addSelectedField(data.textField);
validateQueryResults(query, getYard().find(query),
Arrays.asList(data.r1en.getId(), data.r2en.getId()),
Arrays.asList(data.refField, data.textField));
//wildcard with ?
query = getYard().getQueryFactory().createFieldQuery();
//selects r1en and r2en
wildcard = data.textValue1.getText();
wildcard = wildcard.substring(0, wildcard.length()-1) + "?";
query.setConstraint(data.textField, new TextConstraint(wildcard,PatternType.wildcard,false, "de"));
query.addSelectedField(data.refField);
query.addSelectedField(data.textField);
validateQueryResults(query, getYard().find(query),
Arrays.asList(data.r1de.getId(), data.r2de.getId()),
Arrays.asList(data.refField, data.textField));
}
代码示例来源:origin: apache/stanbol
@Override
protected Representation getRepresentation(String id) throws EntityhubException {
return yard.getRepresentation(id);
}
@Override
代码示例来源:origin: org.apache.stanbol/org.apache.stanbol.entityhub.core
@Override
public Iterable<Representation> store(Iterable<Representation> representations) throws IllegalArgumentException, YardException {
return yard.store(representations);
}
代码示例来源:origin: apache/stanbol
/**
* Stores the parsed representation to the Yard and also applies the
* configured {@link #getFieldMapper() FieldMappings}.
* @param The representation to store
*/
@Override
public void store(Representation representation) throws ManagedSiteException {
try {
Yard yard = getYard();
fieldMapper.applyMappings(representation, representation, yard.getValueFactory());
yard.store(representation);
} catch (YardException e) {
throw new ManagedSiteException(e.getMessage(), e);
}
}
/**
代码示例来源:origin: org.apache.stanbol/org.apache.stanbol.entityhub.core
@Override
public QueryResultList<Representation> findRepresentation(FieldQuery query) throws YardException, IllegalArgumentException {
return yard.findRepresentation(query);
}
代码示例来源:origin: apache/stanbol
@Override
public String getId() {
return yard.getId();
}
代码示例来源:origin: apache/stanbol
private void deleteEntities(Collection<String> ids) throws YardException {
FieldQuery fieldQuery = getQueryFactory().createFieldQuery();
Collection<String> toDelete = new HashSet<String>(ids);
for(String id : ids){
if(id != null && !id.isEmpty()){
fieldQuery.setConstraint(RdfResourceEnum.aboutRepresentation.getUri(), new ReferenceConstraint(id));
for(Iterator<String> it = entityhubYard.findReferences(fieldQuery).iterator();it.hasNext();){
toDelete.add(it.next());
}
}
}
if(!toDelete.isEmpty()){
entityhubYard.remove(toDelete);
}
}
代码示例来源:origin: apache/stanbol
protected Representation create(String id, boolean store) throws YardException {
Representation r;
if (store) {
r = getYard().create(id);
} else if (id != null && !id.isEmpty()) {
r = getYard().getValueFactory().createRepresentation(id);
} else {
throw new IllegalArgumentException("If store is FALSE the id MUST NOT be NULL nor EMPTY!");
}
representationIds.add(r.getId());
return r;
}
代码示例来源:origin: apache/stanbol
@Override
protected FieldQuery createQuery() {
return yard.getQueryFactory().createFieldQuery();
}
@Override
代码示例来源:origin: apache/stanbol
/**
* Same as {@link #testFindText()} but using
* {@link Yard#findRepresentation(FieldQuery)} to execute the queries
*/
@Test
public void testFindRepresentationText(){
//init the test data
FieldQueryTestData data = getFieldQueryTestData();
//query for all languages and value1
FieldQuery query = getYard().getQueryFactory().createFieldQuery();
query.setConstraint(data.textField, new TextConstraint(data.textValue1.getText()));
validateQueryResults(query, getYard().findRepresentation(query),
Arrays.asList( data.r1.getId(), data.r1en.getId(), data.r1de.getId()),
Arrays.asList(data.textField, data.refField, data.intField));
//same for value2
query = getYard().getQueryFactory().createFieldQuery();
query.setConstraint(data.textField, new TextConstraint(data.textValue2.getText()));
validateQueryResults(query, getYard().findRepresentation(query),
Arrays.asList( data.r2.getId(), data.r2en.getId(), data.r2de.getId()),
Arrays.asList(data.textField, data.refField, data.intField));
}
/**
代码示例来源:origin: apache/stanbol
/**
* Tests if <code>null</code> values within the Iterable are ignored and do not cause an Exception
*
* @throws YardException
*/
@Test
public void testRemoveRepresentationsWithNullValue() throws YardException {
// NOTE: This test needs not to use the create(..) method, because we
// remove the created representation form the store anyway as part of the
// test
String id = "urn:yard.test.testRemoveRepresentationsWithNullValue:representation.id";
Yard yard = getYard();
Representation test = yard.create(id); // create and add
assertTrue(yard.isRepresentation(test.getId()));
yard.remove(Arrays.asList(test.getId(), null));
assertFalse(yard.isRepresentation(test.getId()));
}
代码示例来源:origin: apache/stanbol
/**
* Same as {@link #testFindText()} but using
* {@link Yard#findReferences(FieldQuery)} to execute the queries
*/
@Test
public void testFindReferencesText(){
//init the test data
FieldQueryTestData data = getFieldQueryTestData();
//query for all languages and value1
FieldQuery query = getYard().getQueryFactory().createFieldQuery();
query.setConstraint(data.textField, new TextConstraint(data.textValue1.getText()));
validateQueryResults(query, getYard().findReferences(query),
Arrays.asList(data.r1.getId(), data.r1en.getId(), data.r1de.getId()));
//same for value2
query = getYard().getQueryFactory().createFieldQuery();
query.setConstraint(data.textField, new TextConstraint(data.textValue2.getText()));
validateQueryResults(query, getYard().findReferences(query),
Arrays.asList( data.r2.getId(), data.r2en.getId(), data.r2de.getId()));
}
代码示例来源:origin: org.apache.stanbol/org.apache.stanbol.entityhub.core
@Override
public void remove(Iterable<String> ids) throws IllegalArgumentException, YardException {
yard.remove(ids);
}
@Override
代码示例来源:origin: org.apache.stanbol/org.apache.stanbol.entityhub.indexing.core
for(Representation r : yard.store(reps)){
QueueItem<Representation> old = toStore.remove(r.getId());
String.format(errorMsg,entry.getItem().getId(),yard.getId()),
yardException);
代码示例来源:origin: org.apache.stanbol/org.apache.stanbol.entityhub.core
@Override
public final QueryResultList<Representation> find(FieldQuery query) throws YardException{
return entityhubYard.find(query);
}
@Override
内容来源于网络,如有侵权,请联系作者删除!