本文整理汇总了Java中org.apache.olingo.commons.api.data.Entity类的典型用法代码示例。如果您正苦于以下问题:Java Entity类的具体用法?Java Entity怎么用?Java Entity使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Entity类属于org.apache.olingo.commons.api.data包,在下文中一共展示了Entity类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: createEndpointUri
import org.apache.olingo.commons.api.data.Entity; //导入依赖的package包/类
@Override
public String createEndpointUri(final String scheme, final Map<String, String> options) throws URISyntaxException {
// set serviceUri on delegate component
Olingo4Component delegate = getCamelContext().getComponent(scheme, Olingo4Component.class);
Olingo4Configuration configuration = new Olingo4Configuration();
configuration.setServiceUri(this.serviceUri);
delegate.setConfiguration(configuration);
setAfterProducer( exchange -> {
if (!exchange.isFailed()) {
ClientEntity clientEntity = exchange.getIn().getBody(ClientEntity.class);
if (clientEntity != null) {
// convert client entity to JSON
final StringWriter writer = new StringWriter();
final Entity entity = odataClient.getBinder().getEntity(clientEntity);
final ODataSerializer serializer = odataClient.getSerializer(APPLICATION_JSON);
serializer.write(writer, entity);
exchange.getIn().setBody(writer.toString());
}
}
// TODO handle failure on missing resource 404
});
return super.createEndpointUri(scheme, options);
}
开发者ID:syndesisio,项目名称:syndesis,代码行数:27,代码来源:AbstractODataConnector.java
示例2: setFromEntity
import org.apache.olingo.commons.api.data.Entity; //导入依赖的package包/类
protected void setFromEntity(Entity entity, boolean overrideWithNull) {
List<Property> sourceProperties = entity.getProperties();
if (proxy.properties == null || proxy.propertyAccessors == null) {
getProperties();
}
if (overrideWithNull) {
proxy.properties.forEach(prop -> {
if (!sourceProperties.contains(prop)) {
proxy.propertyAccessors.get(prop.getName()).set(this, null);
}
});
}
sourceProperties.forEach(prop -> proxy.propertyAccessors.get(prop.getName()).set(this, prop.getValue()));
// we need new values in the cache after the next call
proxy.properties = null;
}
开发者ID:mat3e,项目名称:olingo-jpa,代码行数:21,代码来源:JpaOlingoEntity.java
示例3: test_JpaOlingoEntity_patch_updatesAllFieldsButID
import org.apache.olingo.commons.api.data.Entity; //导入依赖的package包/类
@Test
public void test_JpaOlingoEntity_patch_updatesAllFieldsButID() {
// GIVEN
final String NEW_NAME = "NewName";
Entity entityToSet = new Entity().addProperty(new Property(null, NAME_FIELD, ValueType.PRIMITIVE, NEW_NAME))
.addProperty(new Property(null, ID_FIELD, ValueType.PRIMITIVE, "WRONG!!111"));
TestEntity SUT = new TestEntity();
// WHEN
SUT.patch(entityToSet);
// THEN
assertThat(SUT.getName()).isEqualTo(NEW_NAME);
assertThat(SUT.getID()).isEqualTo(ID_VALUE);
}
开发者ID:mat3e,项目名称:olingo-jpa,代码行数:19,代码来源:JpaOlingoEntityTest.java
示例4: list
import org.apache.olingo.commons.api.data.Entity; //导入依赖的package包/类
/**
* Reads multiple instances of an Entity Type.
*
* @param entitySet
* Entity Set to read from
* @param uriInfo
* contains filter, order by and paging arguments
* @return entities
* @throws ODataApplicationException
* if error occurred handling filter option
*/
public EntityCollection list(EdmEntitySet entitySet, UriInfo uriInfo)
throws ODataApplicationException {
SearchRequestBuilder searchRequest = elasticsearchTemplate.getClient()
.prepareSearch(toIndexName(entitySet))
.setTypes(toTypeName(entitySet))
.setQuery(toQueryBuilder(uriInfo.getFilterOption()));
configureSorting(uriInfo, searchRequest);
configurePaging(uriInfo, searchRequest);
SearchResponse response = searchRequest.execute().actionGet();
EntityCollection entityCollection = new EntityCollection();
List<Entity> entities = entityCollection.getEntities();
response.getHits().forEach(hit -> {
Entity entity = toEntity(entitySet, hit.getId(), hit.getSource());
entities.add(entity);
});
return entityCollection;
}
开发者ID:pukkaone,项目名称:odata-spring-boot-starter,代码行数:34,代码来源:EntityRepository.java
示例5: writeEntity
import org.apache.olingo.commons.api.data.Entity; //导入依赖的package包/类
public static Entity writeEntity(RdfEdmProvider rdfEdmProvider, UriInfo uriInfo, Entity requestEntity)
throws OData2SparqlException, ODataApplicationException {
SparqlStatement sparqlStatement = null;
EdmEntitySet edmEntitySet = Util.getEdmEntitySet(uriInfo);
RdfEntityType entityType = rdfEdmProvider.getRdfEntityTypefromEdmEntitySet(edmEntitySet);
SparqlCreateUpdateDeleteBuilder sparqlCreateUpdateDeleteBuilder = new SparqlCreateUpdateDeleteBuilder(
rdfEdmProvider);
try {
sparqlStatement = sparqlCreateUpdateDeleteBuilder.generateInsertEntity(entityType, requestEntity);
} catch (Exception e) {
log.error(e.getMessage());
throw new OData2SparqlException(e.getMessage());
}
sparqlStatement.executeInsert(rdfEdmProvider);
return requestEntity;
}
开发者ID:peterjohnlawrence,项目名称:com.inova8.odata2sparql.v4,代码行数:17,代码来源:SparqlBaseCommand.java
示例6: updateEntity
import org.apache.olingo.commons.api.data.Entity; //导入依赖的package包/类
public static void updateEntity(RdfEdmProvider rdfEdmProvider, UriInfo uriInfo, Entity requestEntity,
HttpMethod httpMethod) throws OData2SparqlException {
SparqlStatement sparqlStatement = null;
// 1. Retrieve the entity set which belongs to the requested entity
List<UriResource> resourcePaths = uriInfo.getUriResourceParts();
// Note: only in our example we can assume that the first segment is the EntitySet
UriResourceEntitySet uriResourceEntitySet = (UriResourceEntitySet) resourcePaths.get(0);
EdmEntitySet edmEntitySet = uriResourceEntitySet.getEntitySet();
//EdmEntityType edmEntityType = edmEntitySet.getEntityType();
RdfEntityType entityType = rdfEdmProvider.getRdfEntityTypefromEdmEntitySet(edmEntitySet);
List<UriParameter> keyPredicates = uriResourceEntitySet.getKeyPredicates();
// Note that this updateEntity()-method is invoked for both PUT or PATCH operations
SparqlCreateUpdateDeleteBuilder sparqlCreateUpdateDeleteBuilder = new SparqlCreateUpdateDeleteBuilder(
rdfEdmProvider);
try {
sparqlStatement = sparqlCreateUpdateDeleteBuilder.generateUpdateEntity(entityType, keyPredicates,
requestEntity);
} catch (Exception e) {
log.error(e.getMessage());
throw new OData2SparqlException(e.getMessage());
}
sparqlStatement.executeDelete(rdfEdmProvider);
}
开发者ID:peterjohnlawrence,项目名称:com.inova8.odata2sparql.v4,代码行数:26,代码来源:SparqlBaseCommand.java
示例7: insertValuesReplace
import org.apache.olingo.commons.api.data.Entity; //导入依赖的package包/类
private String insertValuesReplace(String group, RdfEntityType entityType, Entity entry) {
String insertReplace = group;
for (Property prop : entry.getProperties()) {
if (prop.getValue() != null) {
RdfProperty property = entityType.findProperty(prop.getName());
if (property.getIsKey()) {
insertReplace = insertReplace.replaceAll("\\?" + property.getVarName() + "\\b",
"<" + prop.getValue().toString() + ">");
} else {
insertReplace = insertReplace.replaceAll("\\?" + property.getVarName() + "\\b",
"\"" + prop.getValue().toString() + "\"");
}
}
}
//Replace any unmatched variables with UNDEF
insertReplace = insertReplace.replaceAll("\\?\\S+", "UNDEF");
return insertReplace;
}
开发者ID:peterjohnlawrence,项目名称:com.inova8.odata2sparql.v4,代码行数:19,代码来源:SparqlCreateUpdateDeleteBuilder.java
示例8: generateUpdatePropertyValues
import org.apache.olingo.commons.api.data.Entity; //导入依赖的package包/类
private StringBuilder generateUpdatePropertyValues(RdfEntityType entityType, String entityKey, Entity entry) {
StringBuilder updatePropertyValues = new StringBuilder("VALUES( ?" + entityType.entityTypeName + "_p){");
StringBuilder properties = new StringBuilder();
boolean first = true;
for (Property prop : entry.getProperties()) {
if (prop.getValue() != null) {
if (!first) {
properties.append(" ;\n");
} else {
first = false;
}
RdfProperty property = entityType.findProperty(prop.getName());
if (property.getIsKey()) {
entityKey = prop.getValue().toString();
} else {
updatePropertyValues.append("(<" + property.propertyNode.getIRI() + ">) ");
}
}
}
return updatePropertyValues.append("}.");
}
开发者ID:peterjohnlawrence,项目名称:com.inova8.odata2sparql.v4,代码行数:22,代码来源:SparqlCreateUpdateDeleteBuilder.java
示例9: parse
import org.apache.olingo.commons.api.data.Entity; //导入依赖的package包/类
@Override
public InstanceData<EdmEntityType, Entity> parse(SearchResponse response,
ElasticEdmEntitySet entitySet) throws ODataApplicationException {
ElasticEdmEntityType entityType = entitySet.getEntityType();
Iterator<SearchHit> hits = response.getHits().iterator();
if (hits.hasNext()) {
SearchHit firstHit = hits.next();
Map<String, Object> source = firstHit.getSource();
Entity entity = new Entity();
entity.setId(ProcessorUtils.createId(entityType.getName(), firstHit.getId()));
entity.addProperty(
createProperty(ElasticConstants.ID_FIELD_NAME, firstHit.getId(), entityType));
for (Map.Entry<String, Object> entry : source.entrySet()) {
ElasticEdmProperty edmProperty = entityType.findPropertyByEField(entry.getKey());
entity.addProperty(
createProperty(edmProperty.getName(), entry.getValue(), entityType));
}
return new InstanceData<>(entityType, entity);
} else {
throw new ODataApplicationException("No data found", HttpStatus.SC_NOT_FOUND,
Locale.ROOT);
}
}
开发者ID:Hevelian,项目名称:hevelian-olastic,代码行数:26,代码来源:EntityParser.java
示例10: parse
import org.apache.olingo.commons.api.data.Entity; //导入依赖的package包/类
@Override
public InstanceData<EdmEntityType, AbstractEntityCollection> parse(SearchResponse response,
ElasticEdmEntitySet entitySet) {
ElasticEdmEntityType entityType = entitySet.getEntityType();
Entity entity = new Entity();
Aggregations aggs = response.getAggregations();
if (aggs != null) {
aggs.asList().stream().filter(SingleValue.class::isInstance)
.map(SingleValue.class::cast)
.map(aggr -> createProperty(aggr.getName(), aggr.value(), entityType))
.forEach(entity::addProperty);
}
addCountIfNeeded(entity, response.getHits().getTotalHits());
EntityCollection entities = new EntityCollection();
entities.getEntities().add(entity);
return new InstanceData<>(entityType, entities);
}
开发者ID:Hevelian,项目名称:hevelian-olastic,代码行数:18,代码来源:MetricsAggregationsParser.java
示例11: subList
import org.apache.olingo.commons.api.data.Entity; //导入依赖的package包/类
/**
* This is custom pagination, because Elasticsearch doesn't support this.
* Method to get sublist from parent list with top and skip parameter. We
* need to check whether top and skip are in parent list size or not, and
* then calculate from and to indexes.
*
* @param entities
* entities to paginate
* @return new sublist
*/
private List<Entity> subList(List<Entity> entities) {
if (entities.isEmpty()) {
return entities;
}
int top = pagination.getTop();
int skip = pagination.getSkip();
int fromIndex;
int toIndex;
int max = skip + top;
int actualSize = entities.size();
if (max <= actualSize) {
fromIndex = skip;
toIndex = top + skip;
} else {
fromIndex = skip > actualSize ? actualSize : skip;
toIndex = actualSize;
}
return entities.subList(fromIndex, toIndex);
}
开发者ID:Hevelian,项目名称:hevelian-olastic,代码行数:30,代码来源:BucketsAggregationsParser.java
示例12: parse
import org.apache.olingo.commons.api.data.Entity; //导入依赖的package包/类
@Override
public InstanceData<EdmEntityType, AbstractEntityCollection> parse(SearchResponse response,
ElasticEdmEntitySet entitySet) {
ElasticEdmEntityType entityType = entitySet.getEntityType();
EntityCollection entities = new EntityCollection();
for (SearchHit hit : response.getHits()) {
Map<String, Object> source = hit.getSource();
Entity entity = new Entity();
entity.setId(ProcessorUtils.createId(entityType.getName(), hit.getId()));
entity.addProperty(
createProperty(ElasticConstants.ID_FIELD_NAME, hit.getId(), entityType));
for (Map.Entry<String, Object> entry : source.entrySet()) {
ElasticEdmProperty edmProperty = entityType.findPropertyByEField(entry.getKey());
entity.addProperty(
createProperty(edmProperty.getName(), entry.getValue(), entityType));
}
entities.getEntities().add(entity);
}
if (isCount()) {
entities.setCount((int) response.getHits().getTotalHits());
}
return new InstanceData<>(entityType, entities);
}
开发者ID:Hevelian,项目名称:hevelian-olastic,代码行数:26,代码来源:EntityCollectionParser.java
示例13: deleteLinksTo
import org.apache.olingo.commons.api.data.Entity; //导入依赖的package包/类
public void deleteLinksTo(final Entity to) throws DataProviderException {
for (final String entitySetName : data.keySet()) {
for (final Entity entity : data.get(entitySetName).getEntities()) {
for (Iterator<Link> linkIterator = entity.getNavigationLinks().iterator(); linkIterator
.hasNext();) {
final Link link = linkIterator.next();
if (to.equals(link.getInlineEntity())) {
linkIterator.remove();
} else if (link.getInlineEntitySet() != null) {
for (Iterator<Entity> iterator =
link.getInlineEntitySet().getEntities().iterator(); iterator.hasNext();) {
if (to.equals(iterator.next())) {
iterator.remove();
}
}
if (link.getInlineEntitySet().getEntities().isEmpty()) {
linkIterator.remove();
}
}
}
}
}
}
开发者ID:RedHelixOrg,项目名称:RedHelix-1,代码行数:24,代码来源:DataProvider.java
示例14: create
import org.apache.olingo.commons.api.data.Entity; //导入依赖的package包/类
public Entity create(final EdmEntitySet edmEntitySet) throws DataProviderException {
final EdmEntityType edmEntityType = edmEntitySet.getEntityType();
EntityCollection entitySet = readAll(edmEntitySet);
final List<Entity> entities = entitySet.getEntities();
final Map<String, Object> newKey = findFreeComposedKey(entities, edmEntitySet.getEntityType());
Entity newEntity = new Entity();
newEntity.setType(edmEntityType.getFullQualifiedName().getFullQualifiedNameAsString());
for (final String keyName : edmEntityType.getKeyPredicateNames()) {
newEntity.addProperty(DataCreator.createPrimitive(keyName, newKey.get(keyName)));
}
createProperties(edmEntityType, newEntity.getProperties());
try {
newEntity
.setId(URI.create(odata.createUriHelper().buildCanonicalURL(edmEntitySet, newEntity)));
} catch (final SerializerException e) {
throw new DataProviderException("Unable to set entity ID!", e);
}
entities.add(newEntity);
return newEntity;
}
开发者ID:RedHelixOrg,项目名称:RedHelix-1,代码行数:23,代码来源:DataProvider.java
示例15: handleDeleteSingleNavigationProperties
import org.apache.olingo.commons.api.data.Entity; //导入依赖的package包/类
private void handleDeleteSingleNavigationProperties(final EdmEntitySet edmEntitySet,
final Entity entity, final Entity changedEntity) throws DataProviderException {
final EdmEntityType entityType = edmEntitySet.getEntityType();
final List<String> navigationPropertyNames = entityType.getNavigationPropertyNames();
for (final String navPropertyName : navigationPropertyNames) {
final Link navigationLink = changedEntity.getNavigationLink(navPropertyName);
final EdmNavigationProperty navigationProperty =
entityType.getNavigationProperty(navPropertyName);
if (!navigationProperty.isCollection() && navigationLink != null
&& navigationLink.getInlineEntity() == null) {
// Check if partner is available
if (navigationProperty.getPartner() != null
&& entity.getNavigationLink(navPropertyName) != null) {
Entity partnerEntity = entity.getNavigationLink(navPropertyName).getInlineEntity();
removeLink(navigationProperty.getPartner(), partnerEntity);
}
// Remove link
removeLink(navigationProperty, entity);
}
}
}
开发者ID:RedHelixOrg,项目名称:RedHelix-1,代码行数:25,代码来源:DataProvider.java
示例16: getEntityByReference
import org.apache.olingo.commons.api.data.Entity; //导入依赖的package包/类
protected Entity getEntityByReference(final String entityId, final String rawServiceRoot)
throws DataProviderException {
try {
final UriResourceEntitySet uriResource =
odata.createUriHelper().parseEntityId(edm, entityId, rawServiceRoot);
final Entity targetEntity = read(uriResource.getEntitySet(), uriResource.getKeyPredicates());
if (targetEntity != null) {
return targetEntity;
} else {
throw new DataProviderException("Entity not found", HttpStatusCode.NOT_FOUND);
}
} catch (DeserializerException e) {
throw new DataProviderException("Invalid entity-id", HttpStatusCode.BAD_REQUEST);
}
}
开发者ID:RedHelixOrg,项目名称:RedHelix-1,代码行数:17,代码来源:DataProvider.java
示例17: createAllPrimEntity
import org.apache.olingo.commons.api.data.Entity; //导入依赖的package包/类
private static Entity createAllPrimEntity(final Short key, final String val,
final Calendar date) {
return new Entity().addProperty(DataCreator.createPrimitive("PropertyInt16", key))
.addProperty(DataCreator.createPrimitive("PropertyString", val))
.addProperty(DataCreator.createPrimitive("PropertyBoolean", false))
.addProperty(DataCreator.createPrimitive("PropertyByte", null))
.addProperty(DataCreator.createPrimitive("PropertySByte", null))
.addProperty(DataCreator.createPrimitive("PropertyInt32", null))
.addProperty(DataCreator.createPrimitive("PropertyInt64", null))
.addProperty(DataCreator.createPrimitive("PropertySingle", null))
.addProperty(DataCreator.createPrimitive("PropertyDouble", null))
.addProperty(DataCreator.createPrimitive("PropertyDecimal", null))
.addProperty(DataCreator.createPrimitive("PropertyBinary", null))
.addProperty(DataCreator.createPrimitive("PropertyDate", date))
.addProperty(DataCreator.createPrimitive("PropertyDateTimeOffset", null))
.addProperty(DataCreator.createPrimitive("PropertyDuration", null))
.addProperty(DataCreator.createPrimitive("PropertyGuid", null))
.addProperty(DataCreator.createPrimitive("PropertyTimeOfDay", null));
}
开发者ID:RedHelixOrg,项目名称:RedHelix-1,代码行数:20,代码来源:ActionData.java
示例18: createETKeyNavEntity
import org.apache.olingo.commons.api.data.Entity; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private static Entity createETKeyNavEntity(final Short number) {
return new Entity().addProperty(DataCreator.createPrimitive("PropertyInt16", number))
.addProperty(DataCreator.createPrimitive("PropertyString",
"UARTCollETKeyNavParam int16 value: " + number))
.addProperty(DataCreator.createComplex("PropertyCompNav",
DataCreator.createPrimitive("PropertyInt16", (short) 0)))
.addProperty(createKeyNavAllPrimComplexValue("PropertyCompAllPrim"))
.addProperty(DataCreator.createComplex("PropertyCompTwoPrim",
DataCreator.createPrimitive("PropertyInt16", (short) 0),
DataCreator.createPrimitive("PropertyString", "")))
.addProperty(DataCreator.createPrimitiveCollection("CollPropertyString"))
.addProperty(DataCreator.createPrimitiveCollection("CollPropertyInt16"))
.addProperty(DataCreator.createComplexCollection("CollPropertyComp"))
.addProperty(DataCreator.createComplex("PropertyCompCompNav",
DataCreator.createPrimitive("PropertyString", ""), DataCreator.createComplex(
"PropertyCompNav", DataCreator.createPrimitive("PropertyInt16", (short) 0))));
}
开发者ID:RedHelixOrg,项目名称:RedHelix-1,代码行数:19,代码来源:ActionData.java
示例19: createESBase
import org.apache.olingo.commons.api.data.Entity; //导入依赖的package包/类
private EntityCollection createESBase(final Edm edm, final OData odata) {
final EntityCollection entityCollection = new EntityCollection();
entityCollection.getEntities()
.add(new Entity().addProperty(createPrimitive("PropertyInt16", (short) 111))
.addProperty(createPrimitive("PropertyString", "TEST A"))
.addProperty(createPrimitive("AdditionalPropertyString_5", "TEST A 0815")));
entityCollection.getEntities()
.add(new Entity().addProperty(createPrimitive("PropertyInt16", (short) 222))
.addProperty(createPrimitive("PropertyString", "TEST B"))
.addProperty(createPrimitive("AdditionalPropertyString_5", "TEST C 0815")));
entityCollection.getEntities()
.add(new Entity().addProperty(createPrimitive("PropertyInt16", (short) 333))
.addProperty(createPrimitive("PropertyString", "TEST C"))
.addProperty(createPrimitive("AdditionalPropertyString_5", "TEST E 0815")));
setEntityType(entityCollection, edm.getEntityType(EntityTypeProvider.nameETBase));
createEntityId(edm, odata, "ESBase", entityCollection);
return entityCollection;
}
开发者ID:RedHelixOrg,项目名称:RedHelix-1,代码行数:21,代码来源:DataCreator.java
示例20: createESTwoBase
import org.apache.olingo.commons.api.data.Entity; //导入依赖的package包/类
private EntityCollection createESTwoBase(final Edm edm, final OData odata) {
final EntityCollection entityCollection = new EntityCollection();
entityCollection.getEntities()
.add(new Entity().addProperty(createPrimitive("PropertyInt16", (short) 111))
.addProperty(createPrimitive("PropertyString", "TEST A"))
.addProperty(createPrimitive("AdditionalPropertyString_5", "TEST A 0815"))
.addProperty(createPrimitive("AdditionalPropertyString_6", "TEST B 0815")));
entityCollection.getEntities()
.add(new Entity().addProperty(createPrimitive("PropertyInt16", (short) 222))
.addProperty(createPrimitive("PropertyString", "TEST B"))
.addProperty(createPrimitive("AdditionalPropertyString_5", "TEST C 0815"))
.addProperty(createPrimitive("AdditionalPropertyString_6", "TEST D 0815")));
entityCollection.getEntities()
.add(new Entity().addProperty(createPrimitive("PropertyInt16", (short) 333))
.addProperty(createPrimitive("PropertyString", "TEST C"))
.addProperty(createPrimitive("AdditionalPropertyString_5", "TEST E 0815"))
.addProperty(createPrimitive("AdditionalPropertyString_6", "TEST F 0815")));
setEntityType(entityCollection, edm.getEntityType(EntityTypeProvider.nameETTwoBase));
createEntityId(edm, odata, "ESTwoBase", entityCollection);
return entityCollection;
}
开发者ID:RedHelixOrg,项目名称:RedHelix-1,代码行数:24,代码来源:DataCreator.java
注:本文中的org.apache.olingo.commons.api.data.Entity类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论