org.apache.stanbol.entityhub.servicesapi.yard.Yard.store()方法的使用及代码示例

x33g5p2x  于2022-02-05 转载在 其他  
字(11.4k)|赞(0)|评价(0)|浏览(102)

本文整理了Java中org.apache.stanbol.entityhub.servicesapi.yard.Yard.store()方法的一些代码示例,展示了Yard.store()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Yard.store()方法的具体详情如下:
包路径:org.apache.stanbol.entityhub.servicesapi.yard.Yard
类名称:Yard
方法名:store

Yard.store介绍

[英]Stores all the parsed representation in a single chunk in the Yard. This can improve performance, because it does not require multiple commits.
null values are ignored and added as null in the returned Iterable. Otherwise same as #store(Representation).
[中]将所有解析后的表示存储在院子里的单个块中。这可以提高性能,因为它不需要多次提交。
null值被忽略,并作为null添加到返回的Iterable中。否则与#存储(表示)相同。

代码示例

代码示例来源: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

@Override
public Iterable<Representation> store(Iterable<Representation> representations) throws IllegalArgumentException, YardException {
  return yard.store(representations);
}

代码示例来源:origin: apache/stanbol

@Override
public Representation store(Representation representation) throws IllegalArgumentException, YardException {
  return yard.store(applyCacheMappings(yard, representation));
}

代码示例来源:origin: org.apache.stanbol/org.apache.stanbol.entityhub.core

@Override
public Representation store(Representation representation) throws IllegalArgumentException, YardException {
  return yard.store(applyCacheMappings(yard, representation));
}

代码示例来源:origin: org.apache.stanbol/org.apache.stanbol.entityhub.core

/**
 * Stores both the Representation and the Metadata of the parsed Entity to the
 * parsed yard.<p>
 * This Method also updated the modification date of the Metadata.
 * @param entity the stored entity
 * @throws YardException
 */
private void storeEntity(Entity entity) throws YardException{
  if(entity != null){
    entityhubYard.store(entity.getRepresentation());
    entity.getMetadata().set(NamespaceEnum.dcTerms+"modified", new Date());
    entityhubYard.store(entity.getMetadata());
  }
}

代码示例来源:origin: apache/stanbol

/**
 * Stores both the Representation and the Metadata of the parsed Entity to the
 * parsed yard.<p>
 * This Method also updated the modification date of the Metadata.
 * @param entity the stored entity
 * @throws YardException
 */
private void storeEntity(Entity entity) throws YardException{
  if(entity != null){
    entityhubYard.store(entity.getRepresentation());
    entity.getMetadata().set(NamespaceEnum.dcTerms+"modified", new Date());
    entityhubYard.store(entity.getMetadata());
  }
}

代码示例来源:origin: apache/stanbol

@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: 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

@Test(expected = IllegalArgumentException.class)
public void testStoreRepresentationWithNull() throws YardException {
  getYard().store((Representation) null);
}

代码示例来源:origin: apache/stanbol

@Test(expected = IllegalArgumentException.class)
public void testStoreRepresentationsWithNull() throws YardException {
  getYard().store((Iterable<Representation>) null);
}

代码示例来源:origin: apache/stanbol

@Test
public void testStoreRepresentationsWithNullElement() throws YardException {
  String testId = "urn:yard.test.testStoreRepresentationsWithNullElement:representation.id";
  Yard yard = getYard();
  Representation test = create(testId, false);
  Iterable<Representation> added = yard.store(Arrays.asList(test, null));
  // now test that only the valid representation was added and the null
  // value was ignored
  assertNotNull(added);
  Iterator<Representation> addedIt = added.iterator();
  assertTrue(addedIt.hasNext());
  assertEquals(test, addedIt.next());
  assertFalse(addedIt.hasNext());
}

代码示例来源:origin: apache/stanbol

@Test
public void testStoreRepresentation() throws YardException {
  // NOTE: this does not test if the updated view of the representation is
  // stored, but only that the store method works for representations
  // that are already in the Yard AND representations that are not yet
  // present within the yard
  String testId = "urn:yard.test.testStoreRepresentation:representation.id1";
  String testId2 = "urn:yard.test.testStoreRepresentation:representation.id2";
  Yard yard = getYard();
  Representation test = create(testId, false);
  Representation added = yard.store(test); // this adds the representation
  assertEquals(test, added);
  Representation test2 = create(testId2, true); // this creates and adds the representation
  // now test that the representation can also be updated
  added = yard.store(test2);
  assertEquals(test2, added);
}

代码示例来源: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

/**
 * 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

/**
 * Stores the baseMappings to the {@link Yard}. This may cause unexpected
 * behaviour for subsequest calls of the stored configuration does not
 * correspond with the actual data stored within the cache.<p>
 * Typically this is only used at the start or end of the creation of a
 * full Cache ({@link CacheStrategy#all}) of an referenced site (entity source).<p>
 * Note also that if the {@link #baseMapper} is <code>null</code> this
 * method removes any existing configuration from the yard.
 * @throws YardException an any error while storing the config to the yard.
 * @throws IllegalArgumentException if <code>null</code> is parsed as {@link Yard}.
 */
public static void storeBaseMappingsConfiguration(Yard yard,FieldMapper baseMapper) throws YardException,IllegalArgumentException {
  if(yard == null){
    throw new IllegalArgumentException("The parsed Yard MUST NOT be NULL!");
  }
  if(baseMapper == null){
    yard.remove(Cache.BASE_CONFIGURATION_URI);
  } else {
    Representation config = yard.getValueFactory().createRepresentation(Cache.BASE_CONFIGURATION_URI);
    writeFieldConfig(config,baseMapper);
    yard.store(config);
  }
}
/**

代码示例来源:origin: org.apache.stanbol/org.apache.stanbol.entityhub.core

/**
 * Stores the baseMappings to the {@link Yard}. This may cause unexpected
 * behaviour for subsequest calls of the stored configuration does not
 * correspond with the actual data stored within the cache.<p>
 * Typically this is only used at the start or end of the creation of a
 * full Cache ({@link CacheStrategy#all}) of an referenced site (entity source).<p>
 * Note also that if the {@link #baseMapper} is <code>null</code> this
 * method removes any existing configuration from the yard.
 * @throws YardException an any error while storing the config to the yard.
 * @throws IllegalArgumentException if <code>null</code> is parsed as {@link Yard}.
 */
public static void storeBaseMappingsConfiguration(Yard yard,FieldMapper baseMapper) throws YardException,IllegalArgumentException {
  if(yard == null){
    throw new IllegalArgumentException("The parsed Yard MUST NOT be NULL!");
  }
  if(baseMapper == null){
    yard.remove(Cache.BASE_CONFIGURATION_URI);
  } else {
    Representation config = yard.getValueFactory().createRepresentation(Cache.BASE_CONFIGURATION_URI);
    writeFieldConfig(config,baseMapper);
    yard.store(config);
  }
}
/**

代码示例来源:origin: apache/stanbol

Yard yard = getYard();
final ValueFactory vf = yard.getValueFactory();
yard.store(new Iterable<Representation>() {                
  @Override
  public Iterator<Representation> iterator() {

代码示例来源:origin: apache/stanbol

@Test
public void testStoreRepresentations() throws YardException {
  // NOTE: this does not test if the updated view of the representation is
  // stored, but only that the store method works for representations
  // that are already in the Yard AND representations that are not yet
  // present within the yard
  String testId = "urn:yard.test.testStoreRepresentations:representation.id1";
  String testId2 = "urn:yard.test.testStoreRepresentations:representation.id2";
  String field = "urn:the.field:used.for.this.Test";
  Yard yard = getYard();
  Representation test = create(testId, false);
  Representation test2 = create(testId2, true); // this creates and adds the representation
  // now add both and mix Representations that are already present in the yard
  // with an other that is not yet present in the yard
  // change the representations to be sure to force an update even if the
  // implementation checks for changes before updating a representation
  test2.add(field, "test value 2");
  Iterable<Representation> addedIterable = yard.store(Arrays.asList(test, test2));
  assertNotNull(addedIterable);
  Collection<Representation> added = asCollection(addedIterable.iterator());
  // test that both the parsed Representations where stored (updated & created)
  assertTrue(added.remove(test));
  assertTrue(added.remove(test2));
  assertTrue(added.isEmpty());
}

代码示例来源: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: apache/stanbol

@Test
public void testIsRepresentation() throws YardException {
  String id = "urn:yard.test.testIsRepresentation:representation.id";
  Yard yard = getYard();
  // Representations created via the yard need to be created (as empty
  // representation within the yard
  Representation test = create();
  assertTrue(yard.isRepresentation(test.getId()));
  // Representations created via the ValueFactory MUST NOT be added to the
  // Yard
  Representation test2 = create(id, false);
  assertFalse(yard.isRepresentation(test2.getId()));
  // now store test2 and test again
  yard.store(test2);
  assertTrue(yard.isRepresentation(test2.getId()));
  // now remove test and test again
  yard.remove(test.getId());
  assertFalse(yard.isRepresentation(test.getId()));
  yard.remove(test2.getId());
  assertFalse(yard.isRepresentation(test2.getId()));
}

相关文章