本文整理了Java中org.apache.stanbol.entityhub.servicesapi.model.Entity
类的一些代码示例,展示了Entity
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Entity
类的具体详情如下:
包路径:org.apache.stanbol.entityhub.servicesapi.model.Entity
类名称:Entity
[英]A Sign links three things together
代码示例来源:origin: org.apache.stanbol/org.apache.stanbol.entityhub.core
/**
* Getter for the value of the {@link #SOURCE} property of the parsed
* Entity.
* @param entity the entity
* @return the value or <code>null</code> if not present.
*/
public static String getSourceId(Entity entity) {
Object id = entity.getRepresentation().getFirst(SOURCE);
return id != null?id.toString():null;
}
/**
代码示例来源:origin: apache/stanbol
public Suggestion(Entity entity) {
this.entity = entity;
this.entityUri = new IRI(entity.getId());
this.site = entity.getSite();
}
代码示例来源: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: org.apache.stanbol/org.apache.stanbol.entityhub.core
@Override
public boolean equals(Object o) {
return o instanceof Entity &&
representation.equals(((Entity)o).getRepresentation()) &&
site.equals(((Entity)o).getSite()) &&
metadata.equals(((Entity)o).getMetadata());
}
代码示例来源:origin: apache/stanbol
/**
* @param entity
* @return
* @throws JSONException
*/
private JSONObject convertEntityToJSON(Entity entity) throws JSONException {
JSONObject jSign;
jSign = new JSONObject();
jSign.put("id", entity.getId());
jSign.put("site", entity.getSite());
// Representation rep = sign.getRepresentation();
jSign.put("representation", toJSON(entity.getRepresentation()));
jSign.put("metadata", toJSON(entity.getMetadata()));
return jSign;
}
代码示例来源:origin: apache/stanbol
annotationsToRelate.add(entitySuggestions.getKey().getEntity());
for (Suggestion suggestion : entitySuggestions.getValue()) {
log.debug("Add Suggestion {} for {}", suggestion.getEntity().getId(),
entitySuggestions.getKey());
EnhancementRDFUtils.writeEntityAnnotation(this, literalFactory, graph, ci.getUri(),
entityData.put(suggestion.getEntity().getId(), suggestion.getEntity()
.getRepresentation());
代码示例来源:origin: org.apache.stanbol/org.apache.stanbol.entityhub.core
@Override
public final Entity delete(String id) throws EntityhubException, IllegalArgumentException {
if(id == null || id.isEmpty()){
throw new IllegalArgumentException("The parsed id MUST NOT be NULL nor emtpty!");
}
Entity entity = loadEntity(id);
if(entity != null){
log.debug("delete Entity {} as requested by the parsed id {}",entity.getId(),id);
//we need to remove all mappings for this Entity
deleteMappingsbyTarget(entity.getId());
deleteEntity(entity);
} else {
log.debug("Unable to delete Entity for id {}, because no Entity for this id is" +
"managed by the Entityhub",id);
}
return entity;
}
@Override
代码示例来源:origin: apache/stanbol
/**
* Adds the Triples that represent the Sign to the parsed graph. Note that
* this method does not add triples for the representation. However it adds
* the triple (sign,singRepresentation,representation)
*
* @param graph the graph to add the triples
* @param sign the sign
*/
private void addEntityTriplesToGraph(Model graph, Entity sign) {
URI id = sesameFactory.createURI(sign.getId());
URI metaId = sesameFactory.createURI(sign.getMetadata().getId());
//add the FOAF triples between metadata and content
graph.add(id, FOAF_PRIMARY_TOPIC_OF, metaId);
graph.add(metaId, FOAF_PRIMARY_TOPIC, metaId);
graph.add(metaId, RDF_TYPE, FOAF_DOCUMENT);
//add the site to the metadata
//TODO: this should be the HTTP URI and not the id of the referenced site
Literal siteName = sesameFactory.createLiteral(sign.getSite());
graph.add(metaId, EH_SIGN_SITE, siteName);
}
代码示例来源:origin: org.apache.stanbol/org.apache.stanbol.entityhub.core
/**
* Setter for the modified date (replaces existing values)
* @param date the new date
*/
public void setModified(Date date) {
if(date != null){
wrappedEntity.getMetadata().set(NamespaceEnum.dcTerms+"modified", date);
}
}
/**
代码示例来源:origin: apache/stanbol
String nameField,
String lang) {
Representation rep = suggestion.getEntity().getRepresentation();
if(suggestion.getEntity().getSite() != null){
graph.add(new TripleImpl(entityAnnotation,
new IRI(RdfResourceEnum.site.getUri()),
new PlainLiteralImpl(suggestion.getEntity().getSite())));
代码示例来源:origin: apache/stanbol
Entity guess = guesses.next();
Float score =
guess.getRepresentation().getFirst(RdfResourceEnum.resultScore.getUri(), Float.class);
if (score == null) {
log.warn("Missing Score for Entityhub Query Result {}!", guess.getId());
continue;
maxScore = score;
IRI uri = new IRI(guess.getId());
Suggestion suggestion = savedEntity.getSuggestion(uri);
if (suggestion == null) {
log.info(" - not found {}", guess.getId());
continue;
代码示例来源:origin: apache/stanbol
@Override
public boolean equals(Object o) {
return o instanceof Entity &&
representation.equals(((Entity)o).getRepresentation()) &&
site.equals(((Entity)o).getSite()) &&
metadata.equals(((Entity)o).getMetadata());
}
代码示例来源:origin: apache/stanbol
@Override
public final Entity delete(String id) throws EntityhubException, IllegalArgumentException {
if(id == null || id.isEmpty()){
throw new IllegalArgumentException("The parsed id MUST NOT be NULL nor emtpty!");
}
Entity entity = loadEntity(id);
if(entity != null){
log.debug("delete Entity {} as requested by the parsed id {}",entity.getId(),id);
//we need to remove all mappings for this Entity
deleteMappingsbyTarget(entity.getId());
deleteEntity(entity);
} else {
log.debug("Unable to delete Entity for id {}, because no Entity for this id is" +
"managed by the Entityhub",id);
}
return entity;
}
@Override
代码示例来源:origin: apache/stanbol
/**
* Adds the Triples that represent the Sign to the parsed graph. Note that
* this method does not add triples for the representation. However it adds
* the triple (sign,singRepresentation,representation)
*
* @param graph the graph to add the triples
* @param sign the sign
*/
private void addEntityTriplesToGraph(Graph graph, Entity sign) {
IRI id = new IRI(sign.getId());
IRI metaId = new IRI(sign.getMetadata().getId());
//add the FOAF triples between metadata and content
graph.add(new TripleImpl(id, FOAF_PRIMARY_TOPIC_OF, metaId));
graph.add(new TripleImpl(metaId, FOAF_PRIMARY_TOPIC, metaId));
graph.add(new TripleImpl(metaId, RDF.type, FOAF_DOCUMENT));
//add the site to the metadata
//TODO: this should be the HTTP URI and not the id of the referenced site
Literal siteName = literalFactory.createTypedLiteral(sign.getSite());
graph.add(new TripleImpl(metaId, SIGN_SITE, siteName));
}
代码示例来源:origin: org.apache.stanbol/org.apache.stanbol.entityhub.core
/**
* Removes a link to the creator
* @param reference the creator
*/
public final void removeCreatorLink(String reference) {
wrappedEntity.getMetadata().removeReference(NamespaceEnum.dcTerms+"creator", reference);
}
代码示例来源:origin: org.apache.stanbol/org.apache.stanbol.entityhub.core
/**
* Setter for the expire date for this representation.
* @param date the date or <code>null</code> if this representation does not
* expire
*/
public final void setExpires(Date date) {
wrappedEntity.getRepresentation().set(EXPIRES, date);
}
代码示例来源: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
Representation rep = match.getEntity().getRepresentation();
Float score = rep.getFirst(RdfResourceEnum.resultScore.getUri(), Float.class);
if (maxScore == null) {
log.debug("No value of {} for Entity {}!", nameField, match.getEntity().getId());
代码示例来源:origin: apache/stanbol
try {
Entity entity = entityhub.store(representation);
updated.put(entity.getId(), entity);
}catch (EntityhubException e) {
log.error(String.format("Exception while storing Entity %s" +
ResponseBuilder rb = Response.created(uriInfo.getAbsolutePathBuilder()
.queryParam("id", "{entityId}")
.build(entity.getId()));
代码示例来源:origin: org.apache.stanbol/org.apache.stanbol.entityhub.core
/**
* Adds an attribution to the metadata of the entity
* @param text the attribution
* @param lang the language of the attribution (optional)
*/
public final void addAttributionText(String text,String lang){
if(text != null && !text.isEmpty()){
wrappedEntity.getMetadata().addNaturalText(NamespaceEnum.cc+"attributionName", text,lang);
wrappedEntity.getMetadata().addReference(NamespaceEnum.rdf+"type", NamespaceEnum.cc+"Work");
}
}
/**
内容来源于网络,如有侵权,请联系作者删除!