本文整理汇总了Java中org.apache.olingo.commons.api.edm.EdmEntityType类的典型用法代码示例。如果您正苦于以下问题:Java EdmEntityType类的具体用法?Java EdmEntityType怎么用?Java EdmEntityType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
EdmEntityType类属于org.apache.olingo.commons.api.edm包,在下文中一共展示了EdmEntityType类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: parse
import org.apache.olingo.commons.api.edm.EdmEntityType; //导入依赖的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
示例2: parse
import org.apache.olingo.commons.api.edm.EdmEntityType; //导入依赖的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
示例3: parse
import org.apache.olingo.commons.api.edm.EdmEntityType; //导入依赖的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
示例4: create
import org.apache.olingo.commons.api.edm.EdmEntityType; //导入依赖的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
示例5: handleDeleteSingleNavigationProperties
import org.apache.olingo.commons.api.edm.EdmEntityType; //导入依赖的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
示例6: getContextUrl
import org.apache.olingo.commons.api.edm.EdmEntityType; //导入依赖的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
示例7: createEntity
import org.apache.olingo.commons.api.edm.EdmEntityType; //导入依赖的package包/类
private Entity createEntity(EdmEntitySet edmEntitySet, EdmEntityType edmEntityType, Entity entity,
List<Entity> entityList, final String rawServiceUri) throws ODataApplicationException {
// 1.) Create the entity
final Entity newEntity = new Entity();
newEntity.setType(entity.getType());
// Create the new key of the entity
int newId = 1;
while (entityIdExists(newId, entityList)) {
newId++;
}
// Add all provided properties
newEntity.getProperties().addAll(entity.getProperties());
// Add the key property
newEntity.getProperties().add(new Property(null, "ID", ValueType.PRIMITIVE, newId));
newEntity.setId(createId(newEntity, "ID"));
// --> Implement Deep Insert handling here <--
entityList.add(newEntity);
return newEntity;
}
开发者ID:apache,项目名称:olingo-odata4,代码行数:27,代码来源:Storage.java
示例8: serializeEntity
import org.apache.olingo.commons.api.edm.EdmEntityType; //导入依赖的package包/类
private SerializerResult serializeEntity(final ODataRequest request, final Entity entity,
final EdmEntitySet edmEntitySet, final EdmEntityType edmEntityType,
final ContentType requestedFormat,
final ExpandOption expand, final SelectOption select, final boolean isContNav)
throws ODataLibraryException {
ContextURL contextUrl = isODataMetadataNone(requestedFormat) ? null :
getContextUrl(request.getRawODataPath(), edmEntitySet, edmEntityType, true, expand, null,isContNav);
return odata.createSerializer(requestedFormat, request.getHeaders(HttpHeader.ODATA_VERSION)).entity(
serviceMetadata,
edmEntityType,
entity,
EntitySerializerOptions.with()
.contextURL(contextUrl)
.expand(expand).select(select)
.build());
}
开发者ID:apache,项目名称:olingo-odata4,代码行数:18,代码来源:TechnicalEntityProcessor.java
示例9: writeReadEntitySet
import org.apache.olingo.commons.api.edm.EdmEntityType; //导入依赖的package包/类
public void writeReadEntitySet(EdmEntityType entityType, EntityCollection entitySet)
throws SerializerException {
assert (!isClosed());
if (entitySet == null) {
writeNotFound(true);
return;
}
if (ContentTypeHelper.isODataMetadataFull(this.responseContentType)) {
buildOperations(entityType, entitySet);
}
// write the whole collection to response
this.response.setContent(this.serializer.entityCollection(metadata, entityType, entitySet, this.options)
.getContent());
writeOK(responseContentType);
close();
}
开发者ID:apache,项目名称:olingo-odata4,代码行数:20,代码来源:EntitySetResponse.java
示例10: recordWithEntityTypeAndPropValues
import org.apache.olingo.commons.api.edm.EdmEntityType; //导入依赖的package包/类
@Test
public void recordWithEntityTypeAndPropValues() {
CsdlRecord csdlRecord = new CsdlRecord();
csdlRecord.setType("ns.et");
Edm mock = mock(Edm.class);
when(mock.getEntityType(new FullQualifiedName("ns", "et"))).thenReturn(mock(EdmEntityType.class));
List<CsdlPropertyValue> propertyValues = new ArrayList<CsdlPropertyValue>();
propertyValues.add(new CsdlPropertyValue());
csdlRecord.setPropertyValues(propertyValues);
List<CsdlAnnotation> csdlAnnotations = new ArrayList<CsdlAnnotation>();
csdlAnnotations.add(new CsdlAnnotation().setTerm("ns.term"));
csdlRecord.setAnnotations(csdlAnnotations);
EdmExpression record = AbstractEdmExpression.getExpression(mock, csdlRecord);
EdmDynamicExpression dynExp = assertDynamic(record);
EdmRecord asRecord = dynExp.asRecord();
assertNotNull(asRecord.getPropertyValues());
assertEquals(1, asRecord.getPropertyValues().size());
assertNotNull(asRecord.getType());
assertTrue(asRecord.getType() instanceof EdmEntityType);
assertNotNull(asRecord.getAnnotations());
assertEquals(1, asRecord.getAnnotations().size());
}
开发者ID:apache,项目名称:olingo-odata4,代码行数:27,代码来源:EdmRecordImplTest.java
示例11: findEntity
import org.apache.olingo.commons.api.edm.EdmEntityType; //导入依赖的package包/类
public static Entity findEntity(EdmEntityType edmEntityType, EntityCollection entitySet,
List<UriParameter> keyParams) {
List<Entity> entityList = entitySet.getEntities();
// loop over all entities in order to find that one that matches
// all keys in request e.g. contacts(ContactID=1, CompanyID=1)
for (Entity entity : entityList) {
boolean foundEntity = entityMatchesAllKeys(edmEntityType, entity, keyParams);
if (foundEntity) {
return entity;
}
}
return null;
}
开发者ID:apache,项目名称:olingo-odata4,代码行数:17,代码来源:Util.java
示例12: updateEntity
import org.apache.olingo.commons.api.edm.EdmEntityType; //导入依赖的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
示例13: aliasForPropertyInComplexPropertyTwoLevels
import org.apache.olingo.commons.api.edm.EdmEntityType; //导入依赖的package包/类
@Test
public void aliasForPropertyInComplexPropertyTwoLevels() {
CsdlPropertyRef providerRef = new CsdlPropertyRef().setName("comp/comp2/Id").setAlias("alias");
EdmEntityType etMock = mock(EdmEntityType.class);
EdmProperty keyPropertyMock = mock(EdmProperty.class);
EdmProperty compMock = mock(EdmProperty.class);
EdmComplexType compTypeMock = mock(EdmComplexType.class);
EdmProperty comp2Mock = mock(EdmProperty.class);
EdmComplexType comp2TypeMock = mock(EdmComplexType.class);
when(comp2TypeMock.getStructuralProperty("Id")).thenReturn(keyPropertyMock);
when(comp2Mock.getType()).thenReturn(comp2TypeMock);
when(compTypeMock.getStructuralProperty("comp2")).thenReturn(comp2Mock);
when(compMock.getType()).thenReturn(compTypeMock);
when(etMock.getStructuralProperty("comp")).thenReturn(compMock);
EdmKeyPropertyRef ref = new EdmKeyPropertyRefImpl(etMock, providerRef);
EdmProperty property = ref.getProperty();
assertNotNull(property);
assertTrue(property == keyPropertyMock);
}
开发者ID:apache,项目名称:olingo-odata4,代码行数:21,代码来源:EdmKeyPropertyRefImplTest.java
示例14: createProduct
import org.apache.olingo.commons.api.edm.EdmEntityType; //导入依赖的package包/类
private Entity createProduct(EdmEntityType edmEntityType, Entity entity) {
// the ID of the newly created product entity is generated automatically
int newId = 1;
while (productIdExists(newId)) {
newId++;
}
Property idProperty = entity.getProperty("ID");
if (idProperty != null) {
idProperty.setValue(ValueType.PRIMITIVE, Integer.valueOf(newId));
} else {
// as of OData v4 spec, the key property can be omitted from the POST request body
entity.getProperties().add(new Property(null, "ID", ValueType.PRIMITIVE, newId));
}
entity.setId(createId("Products", newId));
this.productList.add(entity);
return entity;
}
开发者ID:apache,项目名称:olingo-odata4,代码行数:22,代码来源:Storage.java
示例15: writeEntitySet
import org.apache.olingo.commons.api.edm.EdmEntityType; //导入依赖的package包/类
protected void writeEntitySet(final ServiceMetadata metadata, final EdmEntityType entityType,
final Delta entitySet, final EntityCollectionSerializerOptions options,
final JsonGenerator json) throws IOException,
SerializerException {
json.writeStartArray();
for (final Entity entity : entitySet.getEntities()) {
writeAddedUpdatedEntity(metadata, entityType, entity, options.getExpand(),
options.getSelect(), options.getContextURL(), false, options.getContextURL()
.getEntitySetOrSingletonOrType(), json);
}
for (final DeletedEntity deletedEntity : entitySet.getDeletedEntities()) {
writeDeletedEntity(deletedEntity, options, json);
}
for (final DeltaLink addedLink : entitySet.getAddedLinks()) {
writeLink(addedLink, options, json, true);
}
for (final DeltaLink deletedLink : entitySet.getDeletedLinks()) {
writeLink(deletedLink, options, json, false);
}
json.writeEndArray();
}
开发者ID:apache,项目名称:olingo-odata4,代码行数:22,代码来源:JsonDeltaSerializer.java
示例16: keyValuePair
import org.apache.olingo.commons.api.edm.EdmEntityType; //导入依赖的package包/类
private static UriParameter keyValuePair(UriTokenizer tokenizer,
final String keyPredicateName, final EdmEntityType edmEntityType,
final Edm edm, final EdmType referringType, final Map<String, AliasQueryOption> aliases)
throws UriParserException, UriValidationException {
final EdmKeyPropertyRef keyPropertyRef = edmEntityType.getKeyPropertyRef(keyPredicateName);
final EdmProperty edmProperty = keyPropertyRef == null ? null : keyPropertyRef.getProperty();
if (edmProperty == null) {
throw new UriValidationException(keyPredicateName + " is not a valid key property name.",
UriValidationException.MessageKeys.INVALID_KEY_PROPERTY, keyPredicateName);
}
ParserHelper.requireNext(tokenizer, TokenKind.EQ);
if (tokenizer.next(TokenKind.COMMA) || tokenizer.next(TokenKind.CLOSE) || tokenizer.next(TokenKind.EOF)) {
throw new UriParserSyntaxException("Key value expected.", UriParserSyntaxException.MessageKeys.SYNTAX);
}
if (nextPrimitiveTypeValue(tokenizer, (EdmPrimitiveType) edmProperty.getType(), edmProperty.isNullable())) {
return createUriParameter(edmProperty, keyPredicateName, tokenizer.getText(), edm, referringType, aliases);
} else {
throw new UriParserSemanticException(keyPredicateName + " has not a valid key value.",
UriParserSemanticException.MessageKeys.INVALID_KEY_VALUE, keyPredicateName);
}
}
开发者ID:apache,项目名称:olingo-odata4,代码行数:22,代码来源:ParserHelper.java
示例17: getProduct
import org.apache.olingo.commons.api.edm.EdmEntityType; //导入依赖的package包/类
private Entity getProduct(EdmEntityType edmEntityType, List<UriParameter> keyParams)
throws ODataApplicationException {
// the list of entities at runtime
EntityCollection entitySet = getProducts();
/* generic approach to find the requested entity */
Entity requestedEntity = Util.findEntity(edmEntityType, entitySet, keyParams);
if (requestedEntity == null) {
// this variable is null if our data doesn't contain an entity for the requested key
// Throw suitable exception
throw new ODataApplicationException("Entity for requested key doesn't exist",
HttpStatusCode.NOT_FOUND.getStatusCode(), Locale.ENGLISH);
}
return requestedEntity;
}
开发者ID:apache,项目名称:olingo-odata4,代码行数:19,代码来源:Storage.java
示例18: entity
import org.apache.olingo.commons.api.edm.EdmEntityType; //导入依赖的package包/类
@Override
public DeserializerResult entity(final InputStream stream, final EdmEntityType edmEntityType)
throws DeserializerException {
try {
final ObjectNode tree = parseJsonTree(stream);
final ExpandTreeBuilder expandBuilder = ExpandTreeBuilderImpl.create();
EdmEntityType derivedEdmEntityType = (EdmEntityType) getDerivedType(edmEntityType, tree);
return DeserializerResultImpl.with().entity(consumeEntityNode(derivedEdmEntityType, tree, expandBuilder))
.expandOption(expandBuilder.build())
.build();
} catch (final IOException e) {
throw wrapParseException(e);
}
}
开发者ID:apache,项目名称:olingo-odata4,代码行数:17,代码来源:ODataJsonDeserializer.java
示例19: keyPropertyGuidStartsWithNumber
import org.apache.olingo.commons.api.edm.EdmEntityType; //导入依赖的package包/类
@Test
public void keyPropertyGuidStartsWithNumber() throws Exception {
final String entitySetName = "ESGuid";
final String keyPropertyName = "a";
EdmProperty keyProperty = Mockito.mock(EdmProperty.class);
Mockito.when(keyProperty.getType())
.thenReturn(OData.newInstance().createPrimitiveTypeInstance(EdmPrimitiveTypeKind.Guid));
EdmKeyPropertyRef keyPropertyRef = Mockito.mock(EdmKeyPropertyRef.class);
Mockito.when(keyPropertyRef.getName()).thenReturn(keyPropertyName);
Mockito.when(keyPropertyRef.getProperty()).thenReturn(keyProperty);
EdmEntityType entityType = Mockito.mock(EdmEntityType.class);
Mockito.when(entityType.getKeyPredicateNames()).thenReturn(Collections.singletonList(keyPropertyName));
Mockito.when(entityType.getKeyPropertyRefs()).thenReturn(Collections.singletonList(keyPropertyRef));
Mockito.when(entityType.getPropertyNames()).thenReturn(Collections.singletonList(keyPropertyName));
Mockito.when(entityType.getProperty(keyPropertyName)).thenReturn(keyProperty);
EdmEntitySet entitySet = Mockito.mock(EdmEntitySet.class);
Mockito.when(entitySet.getName()).thenReturn(entitySetName);
Mockito.when(entitySet.getEntityType()).thenReturn(entityType);
EdmEntityContainer container = Mockito.mock(EdmEntityContainer.class);
Mockito.when(container.getEntitySet(entitySetName)).thenReturn(entitySet);
Edm mockedEdm = Mockito.mock(Edm.class);
Mockito.when(mockedEdm.getEntityContainer()).thenReturn(container);
new TestUriValidator().setEdm(mockedEdm)
.run("ESGuid", "$filter=a eq 889e3e73-af9f-4cd4-b330-db93c25ff3c7");
}
开发者ID:apache,项目名称:olingo-odata4,代码行数:26,代码来源:ParserTest.java
示例20: fetchNavigationProperty
import org.apache.olingo.commons.api.edm.EdmEntityType; //导入依赖的package包/类
/**
* Fetch the correct navigation property from the remaining path
* @param remainingPath
* @param strNavProperty
* @param sourceTypeHavingNavProp
* @return EdmNavigationProperty
*/
private EdmNavigationProperty fetchNavigationProperty(String remainingPath,
String strNavProperty, EdmStructuredType sourceTypeHavingNavProp) {
String[] paths = remainingPath.split("/");
for (String path : paths) {
FullQualifiedName fqName = null;
if (sourceTypeHavingNavProp instanceof EdmComplexType) {
fqName = ((EdmComplexType)sourceTypeHavingNavProp).getProperty(path).getType().getFullQualifiedName();
} else if (sourceTypeHavingNavProp instanceof EdmEntityType) {
fqName = ((EdmEntityType)sourceTypeHavingNavProp).getProperty(path).getType().getFullQualifiedName();
}
if (fqName != null) {
String namespace = aliasNamespaceMap.get(fqName.getNamespace());
fqName = namespace != null ? new FullQualifiedName(namespace, fqName.getName()) : fqName;
}
sourceTypeHavingNavProp = edmEntityTypesMap.containsKey(fqName) ?
edmEntityTypesMap.get(fqName) :
edmComplexTypesMap.get(fqName);
}
return sourceTypeHavingNavProp.getNavigationProperty(strNavProperty);
}
开发者ID:apache,项目名称:olingo-odata4,代码行数:29,代码来源:EdmTypeValidator.java
注:本文中的org.apache.olingo.commons.api.edm.EdmEntityType类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论