本文整理汇总了Java中org.apache.olingo.commons.api.edm.EdmEntitySet类的典型用法代码示例。如果您正苦于以下问题:Java EdmEntitySet类的具体用法?Java EdmEntitySet怎么用?Java EdmEntitySet使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
EdmEntitySet类属于org.apache.olingo.commons.api.edm包,在下文中一共展示了EdmEntitySet类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: list
import org.apache.olingo.commons.api.edm.EdmEntitySet; //导入依赖的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
示例2: readReferenceCollection
import org.apache.olingo.commons.api.edm.EdmEntitySet; //导入依赖的package包/类
static public EntityCollection readReferenceCollection(RdfEdmProvider rdfEdmProvider, UriInfo uriInfo,
UriType uriType) throws OData2SparqlException, EdmException, ODataApplicationException, ExpressionVisitException {
List<UriResource> resourcePaths = uriInfo.getUriResourceParts();
RdfEntityType rdfEntityType = null;
EdmEntitySet edmEntitySet = null;
UriResourceEntitySet uriResourceEntitySet = (UriResourceEntitySet) resourcePaths.get(0);
edmEntitySet = uriResourceEntitySet.getEntitySet();
rdfEntityType = rdfEdmProvider.getRdfEntityTypefromEdmEntitySet(edmEntitySet);
SparqlQueryBuilder sparqlBuilder = new SparqlQueryBuilder(rdfEdmProvider.getRdfModel(),
rdfEdmProvider.getEdmMetadata(), uriInfo, uriType);
//prepareQuery
SparqlStatement sparqlStatement = sparqlBuilder.prepareEntityLinksSparql();
SparqlEntityCollection rdfResults = sparqlStatement.executeConstruct(rdfEdmProvider, rdfEntityType, null, null);
if (rdfResults == null) {
throw new ODataApplicationException("No results", HttpStatusCode.INTERNAL_SERVER_ERROR.getStatusCode(),
Locale.ENGLISH);
} else {
return rdfResults;
}
}
开发者ID:peterjohnlawrence,项目名称:com.inova8.odata2sparql.v4,代码行数:24,代码来源:SparqlBaseCommand.java
示例3: writeEntity
import org.apache.olingo.commons.api.edm.EdmEntitySet; //导入依赖的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
示例4: deleteEntity
import org.apache.olingo.commons.api.edm.EdmEntitySet; //导入依赖的package包/类
public static void deleteEntity(RdfEdmProvider rdfEdmProvider, UriInfo uriInfo) 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();
RdfEntityType entityType = rdfEdmProvider.getRdfEntityTypefromEdmEntitySet(edmEntitySet);
// 2. delete the data in backend
List<UriParameter> keyPredicates = uriResourceEntitySet.getKeyPredicates();
SparqlCreateUpdateDeleteBuilder sparqlCreateUpdateDeleteBuilder = new SparqlCreateUpdateDeleteBuilder(
rdfEdmProvider);
try {
sparqlStatement = sparqlCreateUpdateDeleteBuilder.generateDeleteEntity(entityType, keyPredicates);
} catch (Exception e) {
log.error(e.getMessage());
throw new OData2SparqlException(e.getMessage());
}
sparqlStatement.executeDelete(rdfEdmProvider);
}
开发者ID:peterjohnlawrence,项目名称:com.inova8.odata2sparql.v4,代码行数:22,代码来源:SparqlBaseCommand.java
示例5: updateEntity
import org.apache.olingo.commons.api.edm.EdmEntitySet; //导入依赖的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
示例6: updatePrimitiveValue
import org.apache.olingo.commons.api.edm.EdmEntitySet; //导入依赖的package包/类
public static void updatePrimitiveValue(RdfEdmProvider rdfEdmProvider, UriInfo uriInfo, Object entry)
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();
RdfEntityType entityType = rdfEdmProvider.getRdfEntityTypefromEdmEntitySet(edmEntitySet);
List<UriParameter> keyPredicates = uriResourceEntitySet.getKeyPredicates();
UriResourcePrimitiveProperty uriResourcePrimitiveProperty = (UriResourcePrimitiveProperty) resourcePaths.get(1);
EdmProperty edmProperty = uriResourcePrimitiveProperty.getProperty();
SparqlCreateUpdateDeleteBuilder sparqlCreateUpdateDeleteBuilder = new SparqlCreateUpdateDeleteBuilder(
rdfEdmProvider);
try {
sparqlStatement = sparqlCreateUpdateDeleteBuilder.generateUpdateEntitySimplePropertyValue(entityType,
keyPredicates, edmProperty.getName(), entry);
} catch (Exception e) {
log.error(e.getMessage());
throw new OData2SparqlException(e.getMessage());
}
sparqlStatement.executeUpdate(rdfEdmProvider);
}
开发者ID:peterjohnlawrence,项目名称:com.inova8.odata2sparql.v4,代码行数:27,代码来源:SparqlBaseCommand.java
示例7: deleteEntityReference
import org.apache.olingo.commons.api.edm.EdmEntitySet; //导入依赖的package包/类
public static void deleteEntityReference(RdfEdmProvider rdfEdmProvider, UriInfo uriInfo) 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();
RdfEntityType entityType = rdfEdmProvider.getRdfEntityTypefromEdmEntitySet(edmEntitySet);
List<UriParameter> entityKeyPredicates = uriResourceEntitySet.getKeyPredicates();
UriResourceNavigation uriResourceNavigation = (UriResourceNavigation) resourcePaths.get(1);
RdfAssociation navigationProperty = entityType
.findNavigationProperty(uriResourceNavigation.getProperty().getName());
List<UriParameter> navigationKeyPredicates = uriResourceNavigation.getKeyPredicates();
SparqlCreateUpdateDeleteBuilder sparqlCreateUpdateDeleteBuilder = new SparqlCreateUpdateDeleteBuilder(
rdfEdmProvider);
try {
sparqlStatement = sparqlCreateUpdateDeleteBuilder.generateDeleteLinkQuery( entityType, entityKeyPredicates,navigationProperty,navigationKeyPredicates);
} catch (Exception e) {
log.error(e.getMessage());
throw new OData2SparqlException(e.getMessage());
}
sparqlStatement.executeInsert(rdfEdmProvider);
}
开发者ID:peterjohnlawrence,项目名称:com.inova8.odata2sparql.v4,代码行数:26,代码来源:SparqlBaseCommand.java
示例8: getData
import org.apache.olingo.commons.api.edm.EdmEntitySet; //导入依赖的package包/类
/**
* Helper method for providing some sample data.
*
* @param edmEntitySet
* for which the data is requested
* @return data of requested entity set
*/
private EntitySet getData(UriInfo uriInfo) {
List<UriResource> resourcePaths = uriInfo.getUriResourceParts();
UriResourceEntitySet uriResourceEntitySet = (UriResourceEntitySet) resourcePaths
.get(0); // in our example, the first segment is the EntitySet
EdmEntitySet edmEntitySet = uriResourceEntitySet.getEntitySet();
EntitySet entitySet = null;
Map<String, EntityProvider> entityProviders = ctx
.getBeansOfType(EntityProvider.class);
for (String entity : entityProviders.keySet()) {
EntityProvider entityProvider = entityProviders.get(entity);
if (entityProvider
.getEntityType().getName()
.equals(edmEntitySet.getEntityType().getName())) {
entitySet = entityProvider.getEntitySet(uriInfo);
break;
}
}
return entitySet;
}
开发者ID:rohitghatol,项目名称:spring-boot-Olingo-oData,代码行数:31,代码来源:GenericEntityCollectionProcessor.java
示例9: create
import org.apache.olingo.commons.api.edm.EdmEntitySet; //导入依赖的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
示例10: handleDeleteSingleNavigationProperties
import org.apache.olingo.commons.api.edm.EdmEntitySet; //导入依赖的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
示例11: getContextUrl
import org.apache.olingo.commons.api.edm.EdmEntitySet; //导入依赖的package包/类
private static ContextURL getContextUrl(final EdmEntitySet entitySet,
final EdmEntityType entityType,
final boolean isSingleEntity)
throws ODataLibraryException
{
ContextURL.Builder builder = ContextURL.with();
builder = (entitySet == null)
? isSingleEntity
? builder.type(entityType)
: builder.asCollection().type(entityType)
: builder.entitySet(entitySet);
builder = builder.suffix((isSingleEntity && (entitySet != null))
? ContextURL.Suffix.ENTITY
: null);
return builder.build();
}
开发者ID:RedHelixOrg,项目名称:RedHelix-1,代码行数:19,代码来源:RedHxDiscoveryProcessor.java
示例12: deleteEntity
import org.apache.olingo.commons.api.edm.EdmEntitySet; //导入依赖的package包/类
public void deleteEntity(ODataRequest request, ODataResponse response, UriInfo uriInfo)
throws ODataApplicationException {
// 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();
// 2. delete the data in backend
List<UriParameter> keyPredicates = uriResourceEntitySet.getKeyPredicates();
storage.deleteEntityData(edmEntitySet, keyPredicates);
//3. configure the response object
response.setStatusCode(HttpStatusCode.NO_CONTENT.getStatusCode());
}
开发者ID:apache,项目名称:olingo-odata4,代码行数:17,代码来源:DemoEntityProcessor.java
示例13: primitiveCollectionPropertyIEEE754CompatibleDecimal
import org.apache.olingo.commons.api.edm.EdmEntitySet; //导入依赖的package包/类
@Test
public void primitiveCollectionPropertyIEEE754CompatibleDecimal() throws Exception {
final EdmEntitySet edmEntitySet = entityContainer.getEntitySet("ESCollAllPrim");
final EdmProperty edmProperty = (EdmProperty) edmEntitySet.getEntityType().getProperty("CollPropertyDecimal");
final Property property = data.readAll(edmEntitySet).getEntities().get(0).getProperty(edmProperty.getName());
final String resultString = IOUtils.toString(serializerIEEECompatible
.primitiveCollection(metadata, (EdmPrimitiveType) edmProperty.getType(), property,
PrimitiveSerializerOptions.with()
.contextURL(ContextURL.with()
.entitySet(edmEntitySet).keyPath("1").navOrPropertyPath(edmProperty.getName()).build())
.build()).getContent());
Assert.assertEquals("{"
+ "\"@context\":\"$metadata#ESCollAllPrim(1)/CollPropertyDecimal\","
+ "\"@metadataEtag\":\"W/\\\"metadataETag\\\"\","
+ "\"value\":[\"12\",\"-2\",\"1234\"]}",
resultString);
}
开发者ID:apache,项目名称:olingo-odata4,代码行数:19,代码来源:ODataJsonSerializerv01Test.java
示例14: primitiveCollectionBoundAction
import org.apache.olingo.commons.api.edm.EdmEntitySet; //导入依赖的package包/类
protected static Property primitiveCollectionBoundAction(final String name, final Map<String, Parameter> parameters,
final Map<String, EntityCollection> data,
EdmEntitySet edmEntitySet, List<UriParameter> keyList, final OData oData) throws DataProviderException {
List<Object> collectionValues = new ArrayList<Object>();
if ("BAETTwoPrimRTCollString".equals(name)) {
EdmPrimitiveType strType = oData.createPrimitiveTypeInstance(EdmPrimitiveTypeKind.String);
try {
String strValue1 = strType.valueToString("ABC", false, 100, null, null, false);
collectionValues.add(strValue1);
String strValue2 = strType.valueToString("XYZ", false, 100, null, null, false);
collectionValues.add(strValue2);
} catch (EdmPrimitiveTypeException e) {
throw new DataProviderException("EdmPrimitiveTypeException", HttpStatusCode.BAD_REQUEST, e);
}
return new Property(null, name, ValueType.COLLECTION_PRIMITIVE, collectionValues);
}
throw new DataProviderException("Action " + name + " is not yet implemented.",
HttpStatusCode.NOT_IMPLEMENTED);
}
开发者ID:apache,项目名称:olingo-odata4,代码行数:20,代码来源:ActionData.java
示例15: buildRelativeFiveNavigation
import org.apache.olingo.commons.api.edm.EdmEntitySet; //导入依赖的package包/类
@Test
public void buildRelativeFiveNavigation() throws Exception {
final EdmEntitySet entitySet = entityContainer.getEntitySet("ESTwoPrim");
String odataPath = "ESAllPrim(32767)/NavPropertyETTwoPrimOne/NavPropertyETAllPrimOne/" +
"NavPropertyETTwoPrimOne/NavPropertyETAllPrimOne/NavPropertyETTwoPrimOne";
ContextURL contextURL = ContextURL.with()
.oDataPath("/" + odataPath)
.entitySet(entitySet).suffix(ContextURL.Suffix.ENTITY).build();
assertEquals("../../../../../$metadata#ESTwoPrim/$entity", ContextURLBuilder.create(contextURL).toASCIIString());
// removed leading '/'
contextURL = ContextURL.with()
.oDataPath(odataPath)
.entitySet(entitySet).suffix(ContextURL.Suffix.ENTITY).build();
assertEquals("../../../../../$metadata#ESTwoPrim/$entity", ContextURLBuilder.create(contextURL).toASCIIString());
}
开发者ID:apache,项目名称:olingo-odata4,代码行数:17,代码来源:ContextURLHelperTest.java
示例16: primitiveProperty
import org.apache.olingo.commons.api.edm.EdmEntitySet; //导入依赖的package包/类
@Test
public void primitiveProperty() throws Exception {
final EdmEntitySet edmEntitySet = entityContainer.getEntitySet("ESAllPrim");
final EdmProperty edmProperty = (EdmProperty) edmEntitySet.getEntityType().getProperty("PropertyString");
final Property property = data.readAll(edmEntitySet).getEntities().get(0).getProperty(edmProperty.getName());
final String resultString = IOUtils.toString(serializer
.primitive(metadata, (EdmPrimitiveType) edmProperty.getType(), property,
PrimitiveSerializerOptions.with()
.contextURL(ContextURL.with()
.entitySet(edmEntitySet).keyPath("32767").navOrPropertyPath(edmProperty.getName())
.build())
.build()).getContent());
Assert.assertEquals("{"
+ "\"@context\":\"$metadata#ESAllPrim(32767)/PropertyString\","
+ "\"@metadataEtag\":\"W/\\\"metadataETag\\\"\","
+ "\"value\":\"First Resource - positive values\"}",
resultString);
}
开发者ID:apache,项目名称:olingo-odata4,代码行数:19,代码来源:ODataJsonSerializerv01Test.java
示例17: updateEntity
import org.apache.olingo.commons.api.edm.EdmEntitySet; //导入依赖的package包/类
public void updateEntity(ODataRequest request, ODataResponse response, UriInfo uriInfo,
ContentType requestFormat, ContentType responseFormat)
throws ODataApplicationException, DeserializerException, SerializerException {
// 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();
// 2. update the data in backend
// 2.1. retrieve the payload from the PUT request for the entity to be updated
InputStream requestInputStream = request.getBody();
ODataDeserializer deserializer = odata.createDeserializer(requestFormat);
DeserializerResult result = deserializer.entity(requestInputStream, edmEntityType);
Entity requestEntity = result.getEntity();
// 2.2 do the modification in backend
List<UriParameter> keyPredicates = uriResourceEntitySet.getKeyPredicates();
// Note that this updateEntity()-method is invoked for both PUT or PATCH operations
HttpMethod httpMethod = request.getMethod();
storage.updateEntityData(edmEntitySet, keyPredicates, requestEntity, httpMethod);
//3. configure the response object
response.setStatusCode(HttpStatusCode.NO_CONTENT.getStatusCode());
}
开发者ID:apache,项目名称:olingo-odata4,代码行数:27,代码来源:DemoEntityProcessor.java
示例18: testDeltaForStream
import org.apache.olingo.commons.api.edm.EdmEntitySet; //导入依赖的package包/类
@Test
public void testDeltaForStream() throws Exception {
final EdmEntitySet edmEntitySet = entityContainer.getEntitySet("ESWithStream");
Delta delta = new Delta();
List<DeltaLink> addedLinks = new ArrayList<DeltaLink>();
DeltaLink link1 = new DeltaLink();
link1.setRelationship("NavPropertyETAllPrimOne");
link1.setSource(new URI("ESDelta(100)"));
link1.setTarget(new URI("ESAllPrim(0)"));
addedLinks.add(link1 );
delta.getAddedLinks().addAll(addedLinks );
InputStream stream = ser.entityCollection(metadata, edmEntitySet.getEntityType(), delta ,
EntityCollectionSerializerOptions.with()
.contextURL(ContextURL.with().entitySet(edmEntitySet).build())
.build()).getContent();
String jsonString = IOUtils.toString(stream);
final String expectedResult = "{"
+ "\"@context\":\"$metadata#ESWithStream/$delta\","
+ "\"value\":[{\"@context\":\"#ESWithStream/$link\","
+ "\"source\":\"ESDelta(100)\",\"relationship\":"
+ "\"NavPropertyETAllPrimOne\",\"target\":\"ESAllPrim(0)\"}]"
+ "}";
Assert.assertNotNull(jsonString);
Assert.assertEquals(expectedResult, jsonString);
}
开发者ID:apache,项目名称:olingo-odata4,代码行数:26,代码来源:JsonDeltaSerializerWithNavigationsTest.java
示例19: expandSelect
import org.apache.olingo.commons.api.edm.EdmEntitySet; //导入依赖的package包/类
@Test
public void expandSelect() throws Exception {
final EdmEntitySet edmEntitySet = entityContainer.getEntitySet("ESTwoPrim");
final EdmEntityType entityType = edmEntitySet.getEntityType();
final Entity entity = data.readAll(edmEntitySet).getEntities().get(3);
final SelectOption select = ExpandSelectMock.mockSelectOption(Collections.singletonList(
ExpandSelectMock.mockSelectItem(entityContainer.getEntitySet("ESAllPrim"), "PropertyDate")));
ExpandItem expandItem = ExpandSelectMock.mockExpandItem(edmEntitySet, "NavPropertyETAllPrimOne");
Mockito.when(expandItem.getSelectOption()).thenReturn(select);
final ExpandOption expand = ExpandSelectMock.mockExpandOption(Collections.singletonList(expandItem));
final String resultString = IOUtils.toString(serializer
.entity(metadata, entityType, entity,
EntitySerializerOptions.with()
.contextURL(ContextURL.with().entitySet(edmEntitySet)
.selectList(helper.buildContextURLSelectList(entityType, expand, select))
.suffix(Suffix.ENTITY).build())
.expand(expand)
.build()).getContent());
Assert.assertEquals("{"
+ "\"@context\":\"$metadata#ESTwoPrim(NavPropertyETAllPrimOne(PropertyDate))/$entity\","
+ "\"@metadataEtag\":\"W/\\\"metadataETag\\\"\","
+ "\"PropertyInt16\":32767,\"PropertyString\":\"Test String4\","
+ "\"NavPropertyETAllPrimOne\":{\"@id\":\"ESAllPrim(32767)\",\"PropertyDate\":\"2012-12-03\"}}",
resultString);
}
开发者ID:apache,项目名称:olingo-odata4,代码行数:26,代码来源:ODataJsonSerializerv01Test.java
示例20: serializeDeltaPayloads
import org.apache.olingo.commons.api.edm.EdmEntitySet; //导入依赖的package包/类
private SerializerResult serializeDeltaPayloads(final ODataRequest request, final Delta delta,
final EdmEntitySet edmEntitySet, final EdmEntityType edmEntityType,
final ContentType requestedFormat, final ExpandOption expand, final SelectOption select,
final CountOption countOption, String id) throws ODataLibraryException {
return odata.createEdmDeltaSerializer(requestedFormat, request.getHeaders(HttpHeader.ODATA_VERSION))
.entityCollection(serviceMetadata,
edmEntityType, delta,
EntityCollectionSerializerOptions.with()
.contextURL(isODataMetadataNone(requestedFormat) ? null :
getContextUrl(request.getRawODataPath(), edmEntitySet, edmEntityType, false, expand, select, false))
.count(countOption)
.expand(expand).select(select)
.id(id)
.build());
}
开发者ID:apache,项目名称:olingo-odata4,代码行数:18,代码来源:TechnicalEntityProcessor.java
注:本文中的org.apache.olingo.commons.api.edm.EdmEntitySet类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论