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

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

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

Yard.create介绍

[英]Creates a new empty representation and stores it in the Yard. The Yard is responsible to assign a valid ID.
[中]创建一个新的空表示并将其存储在院子中。造船厂负责分配一个有效的ID。

代码示例

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

@Override
public Representation create() throws YardException {
  return yard.create();
}

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

@Override
public Representation create(String id) throws IllegalArgumentException, YardException {
  return yard.create(id);
}

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

@Override
public Representation create() throws YardException {
  return yard.create();
}

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

@Override
public Representation create(String id) throws IllegalArgumentException, YardException {
  return yard.create(id);
}

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

/**
 * Lookups (or initialises) the metadata for the entity with the parsed id 
 * @param entityId The id of the entity
 * @param init if the metadata should be initialised of not existing
 * @return the metadata for that Entity or <code>null</code> if not existing
 * and <code>init == false</code>
 * @throws YardException
 */
private Representation lookupMetadata(String entityId, boolean init) throws YardException {
  Representation metadata;
  //TODO: check the asumption that the Metadata always use the
  //      extension ".meta"
  String metaID = entityId+".meta";
  metadata = entityhubYard.getRepresentation(metaID);
  if(metadata == null){
    metadata = entityhubYard.create(metaID);
  }
  return metadata;
}
/**

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

/**
 * Lookups (or initialises) the metadata for the entity with the parsed id 
 * @param entityId The id of the entity
 * @param init if the metadata should be initialised of not existing
 * @return the metadata for that Entity or <code>null</code> if not existing
 * and <code>init == false</code>
 * @throws YardException
 */
private Representation lookupMetadata(String entityId, boolean init) throws YardException {
  Representation metadata;
  //TODO: check the asumption that the Metadata always use the
  //      extension ".meta"
  String metaID = entityId+".meta";
  metadata = entityhubYard.getRepresentation(metaID);
  if(metadata == null){
    metadata = entityhubYard.create(metaID);
  }
  return metadata;
}
/**

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

protected Representation create() throws YardException {
  Representation r = getYard().create();
  representationIds.add(r.getId());
  return r;
}

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

@Test(expected = IllegalArgumentException.class)
public void testCreateWithEmptyString() throws YardException {
  getYard().create("");// throws an IllegalArgumentException
}

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

@Test
public void testDefaultCreate() throws YardException {
  Yard yard = getYard();
  Representation test = yard.create();
  assertNotNull(test);
  Representation test2 = yard.create();
  assertNotNull(test2);
  assertNotSame(test, test2);
  assertFalse("Two Representation created with create() MUST NOT be equals", test.equals(test2));
}

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

@Test
public void testCreateWithNull() throws YardException {
  Yard yard = getYard();
  Representation test = yard.create(null);
  assertNotNull("Parsing NULL to create(String) MUST create a valid Representation", test);
  representationIds.add(test.getId()); // add id to cleanup list
  Representation test2 = yard.create(null);
  assertNotNull("Parsing NULL to create(String) MUST create a valid Representation", test2);
  representationIds.add(test2.getId()); // add id to cleanup list
  assertNotSame(test, test2);
  assertFalse("Two Representation created with create(null) MUST NOT be equals", test.equals(test2));
}

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

@Test(expected = IllegalArgumentException.class)
public void testCreateWithExistingId() throws YardException {
  Yard yard = getYard();
  Representation test = create();
  assertNotNull(test);
  yard.create(test.getId()); // throws an IllegalArgumentException
}

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

Representation localRep = entityhubYard.create(constructResourceId(DEFAULT_MANAGED_ENTITY_PREFIX));
Entity localEntity = loadEntity(localRep);
importEntity(remoteEntity, site, localEntity, valueFactory);
Representation entityMappingRepresentation = entityhubYard.create(
  constructResourceId(DEFAULT_MAPPING_PREFIX));
Entity entityMappingEntity = loadEntity(entityMappingRepresentation);

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

Representation localRep = entityhubYard.create(constructResourceId(DEFAULT_MANAGED_ENTITY_PREFIX));
Entity localEntity = loadEntity(localRep);
importEntity(remoteEntity, site, localEntity, valueFactory);
Representation entityMappingRepresentation = entityhubYard.create(
  constructResourceId(DEFAULT_MAPPING_PREFIX));
Entity entityMappingEntity = loadEntity(entityMappingRepresentation);

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

/**
 * Tests that {@link Representation} IDs that are not stored by the yard are ignored by the multiple
 * remove method
 * 
 * @throws YardException
 */
@Test
public void testRemoveRepresentationsWithNonStoredValue() 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.stored";
  String id2 = "urn:yard.test.testRemoveRepresentationsWithNullValue:representation.notStored";
  Yard yard = getYard();
  Representation test = yard.create(id); // create and add
  assertTrue(yard.isRepresentation(test.getId()));
  yard.remove(Arrays.asList(test.getId(), id2));
  assertFalse(yard.isRepresentation(test.getId()));
  assertFalse(yard.isRepresentation(id2));
}

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

/**
 * Tests that multiple Representations are removed.
 * 
 * @throws YardException
 */
@Test
public void testRemoveRepresentations() 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.id1";
  String id2 = "urn:yard.test.testRemoveRepresentationsWithNullValue:representation.id2";
  String field = "urn:the.field:used.for.this.Test";
  String testValue = "This is a test";
  Yard yard = getYard();
  // use both ways to add the two Representations (should make no differences,
  // but one never can know ...
  Representation test1 = yard.create(id); // create and add
  Representation test2 = yard.getValueFactory().createRepresentation(id2); // create
  test2.add(field, testValue); // add value
  yard.store(test2);// store
  assertTrue(yard.isRepresentation(test1.getId())); // test if stored
  assertTrue(yard.isRepresentation(test2.getId()));
  yard.remove(Arrays.asList(test1.getId(), test2.getId())); // remove
  assertFalse(yard.isRepresentation(test1.getId())); // test if removed
  assertFalse(yard.isRepresentation(test2.getId()));
}
/**

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

Representation test1 = yard.create(id); // create and add

相关文章