本文整理汇总了Java中org.apache.olingo.commons.api.edm.EdmBindingTarget类的典型用法代码示例。如果您正苦于以下问题:Java EdmBindingTarget类的具体用法?Java EdmBindingTarget怎么用?Java EdmBindingTarget使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
EdmBindingTarget类属于org.apache.olingo.commons.api.edm包,在下文中一共展示了EdmBindingTarget类的40个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getNavigationTargetEntitySet
点赞 3
import org.apache.olingo.commons.api.edm.EdmBindingTarget; //导入依赖的package包/类
/**
* Gets related binding target by resource navigation property name.
*
* @param entitySet
* parent entity set
* @param resourceNavigation
* resource navigation property
* @return found binding target
* @throws ODataApplicationException
* if any error occurred
*/
protected ElasticEdmEntitySet getNavigationTargetEntitySet(ElasticEdmEntitySet entitySet,
UriResourceNavigation resourceNavigation) throws ODataApplicationException {
ElasticEdmEntitySet navigationTargetEntitySet = null;
EdmBindingTarget edmBindingTarget = entitySet
.getRelatedBindingTarget(resourceNavigation.getProperty().getName());
if (edmBindingTarget == null) {
throwNotImplemented();
}
if (edmBindingTarget instanceof ElasticEdmEntitySet) {
navigationTargetEntitySet = (ElasticEdmEntitySet) edmBindingTarget;
} else {
throwNotImplemented();
}
return navigationTargetEntitySet;
}
开发者ID:Hevelian,
项目名称:hevelian-olastic,
代码行数:27,
代码来源:RequestCreator.java
示例2: validatePropertyValue
点赞 3
import org.apache.olingo.commons.api.edm.EdmBindingTarget; //导入依赖的package包/类
private void validatePropertyValue(final Property property, final EdmProperty edmProperty,
final EdmBindingTarget edmBindingTarget, final List<String> path)
throws DataProviderException {
final ArrayList<String> newPath = new ArrayList<String>(path);
newPath.add(edmProperty.getName());
if (edmProperty.isCollection()) {
if (edmProperty.getType() instanceof EdmComplexType && property != null) {
for (final Object value : property.asCollection()) {
validateComplexValue((ComplexValue) value, edmBindingTarget,
(EdmComplexType) edmProperty.getType(), newPath);
}
}
} else if (edmProperty.getType() instanceof EdmComplexType) {
validateComplexValue((property == null) ? null : property.asComplex(), edmBindingTarget,
(EdmComplexType) edmProperty.getType(), newPath);
}
}
开发者ID:RedHelixOrg,
项目名称:RedHelix-1,
代码行数:20,
代码来源:RequestValidator.java
示例3: validateProperties
点赞 3
import org.apache.olingo.commons.api.edm.EdmBindingTarget; //导入依赖的package包/类
private void validateProperties(final List<Property> properties, final EdmBindingTarget edmBindingTarget,
final EdmStructuredType edmType, final List<String> keyPredicateNames, final List<String> path)
throws DataProviderException {
for (final String propertyName : edmType.getPropertyNames()) {
final EdmProperty edmProperty = (EdmProperty) edmType.getProperty(propertyName);
// Ignore key properties, they are set automatically
if (!keyPredicateNames.contains(propertyName)) {
final Property property = getProperty(properties, propertyName);
// Check if all "not nullable" properties are set
if (!edmProperty.isNullable()) {
if ((property != null && property.isNull()) // Update,insert; Property is explicit set to null
|| (isInsert && property == null) // Insert; Property not provided
|| (!isInsert && !isPatch && property == null)) { // Insert(Put); Property not provided
throw new DataProviderException("Property " + propertyName + " must not be null",
HttpStatusCode.BAD_REQUEST);
}
}
// Validate property value
validatePropertyValue(property, edmProperty, edmBindingTarget, path);
}
}
}
开发者ID:apache,
项目名称:olingo-odata4,
代码行数:27,
代码来源:RequestValidator.java
示例4: validatePropertyValue
点赞 3
import org.apache.olingo.commons.api.edm.EdmBindingTarget; //导入依赖的package包/类
private void validatePropertyValue(final Property property, final EdmProperty edmProperty,
final EdmBindingTarget edmBindingTarget, final List<String> path) throws DataProviderException {
final ArrayList<String> newPath = new ArrayList<String>(path);
newPath.add(edmProperty.getName());
if (edmProperty.isCollection()) {
if (edmProperty.getType() instanceof EdmComplexType && property != null) {
for (final Object value : property.asCollection()) {
validateComplexValue((ComplexValue) value,
edmBindingTarget,
(EdmComplexType) edmProperty.getType(),
newPath);
}
}
} else if (edmProperty.getType() instanceof EdmComplexType) {
validateComplexValue((property == null) ? null : property.asComplex(),
edmBindingTarget,
(EdmComplexType) edmProperty.getType(),
newPath);
}
}
开发者ID:apache,
项目名称:olingo-odata4,
代码行数:23,
代码来源:RequestValidator.java
示例5: applyOptionsToEntityCollection
点赞 3
import org.apache.olingo.commons.api.edm.EdmBindingTarget; //导入依赖的package包/类
private void applyOptionsToEntityCollection(final EntityCollection entitySet,
final EdmBindingTarget edmBindingTarget,
final FilterOption filterOption, final OrderByOption orderByOption, final CountOption countOption,
final SkipOption skipOption, final TopOption topOption, final ExpandOption expandOption,
final UriInfoResource uriInfo, final Edm edm)
throws ODataApplicationException {
FilterHandler.applyFilterSystemQuery(filterOption, entitySet, uriInfo, edm);
OrderByHandler.applyOrderByOption(orderByOption, entitySet, uriInfo, edm);
CountHandler.applyCountSystemQueryOption(countOption, entitySet);
SkipHandler.applySkipSystemQueryHandler(skipOption, entitySet);
TopHandler.applyTopSystemQueryOption(topOption, entitySet);
// Apply nested expand system query options to remaining entities
if (expandOption != null) {
for (final Entity entity : entitySet.getEntities()) {
applyExpandOptionToEntity(entity, edmBindingTarget, expandOption, uriInfo, edm);
}
}
}
开发者ID:apache,
项目名称:olingo-odata4,
代码行数:21,
代码来源:ExpandSystemQueryOptionHandler.java
示例6: mustValidate
点赞 3
import org.apache.olingo.commons.api.edm.EdmBindingTarget; //导入依赖的package包/类
private boolean mustValidate(final String uri, final String entitySetName)
throws UriParserException, UriValidationException, PreconditionException {
final UriInfo uriInfo = new Parser(edm, odata).parseUri(uri, null, null, null);
final List<UriResource> parts = uriInfo.getUriResourceParts();
final boolean isMedia = parts.size() >= 2
&& parts.get(parts.size() - 1) instanceof UriResourceValue
&& parts.get(parts.size() - 2) instanceof UriResourceEntitySet;
CustomETagSupport support = mock(CustomETagSupport.class);
final Answer<Boolean> answer = new Answer<Boolean>() {
public Boolean answer(final InvocationOnMock invocation) throws Throwable {
if (entitySetName != null) {
assertEquals(entitySetName, ((EdmBindingTarget) invocation.getArguments()[0]).getName());
}
return true;
}};
when(support.hasETag(any(EdmBindingTarget.class))).thenAnswer(answer);
when(support.hasMediaETag(any(EdmBindingTarget.class))).thenAnswer(answer);
return new PreconditionsValidator(uriInfo).mustValidatePreconditions(support, isMedia);
}
开发者ID:apache,
项目名称:olingo-odata4,
代码行数:22,
代码来源:PreconditionsValidatorTest.java
示例7: getTargetEntitySet
点赞 3
import org.apache.olingo.commons.api.edm.EdmBindingTarget; //导入依赖的package包/类
static String getTargetEntitySet(EdmBindingTarget root, LinkedList<UriResourceNavigation> navigations) {
EdmEntityType type = root.getEntityType();
EdmBindingTarget targetEntitySet = root;
String targetEntitySetName = root.getName();
String name = null;
for (UriResourceNavigation nav:navigations) {
name = nav.getProperty().getName();
EdmNavigationProperty property = type.getNavigationProperty(name);
if (property.containsTarget()) {
return root.getName();
}
type = nav.getProperty().getType();
for(EdmNavigationPropertyBinding enb:targetEntitySet.getNavigationPropertyBindings()) {
if (enb.getPath().equals(name)) {
targetEntitySetName = enb.getTarget();
} else if (enb.getPath().endsWith("/"+name)) {
targetEntitySetName = enb.getTarget();
}
}
}
return targetEntitySetName;
}
开发者ID:apache,
项目名称:olingo-odata4,
代码行数:24,
代码来源:DataRequest.java
示例8: getNavigationBindingDetails
点赞 3
import org.apache.olingo.commons.api.edm.EdmBindingTarget; //导入依赖的package包/类
private EdmBindingTarget getNavigationBindingDetails(final EdmStructuredType type) {
EdmEntityContainer c = edm.getEntityContainer();
if (c != null) {
for (EdmEntitySet es : c.getEntitySets()) {
if (es.getEntityType().getFullQualifiedName().equals(type.getFullQualifiedName())) {
return es;
}
}
for (EdmSingleton s : c.getSingletons()) {
if (s.getEntityType().getFullQualifiedName().equals(type.getFullQualifiedName())) {
return s;
}
}
}
throw new IllegalStateException("EntitySet for '" + type.getName() + "' not found");
}
开发者ID:apache,
项目名称:olingo-odata4,
代码行数:19,
代码来源:NavPropertyBindingDetails.java
示例9: applyFilterSystemQuery
点赞 3
import org.apache.olingo.commons.api.edm.EdmBindingTarget; //导入依赖的package包/类
/**
* This method applies filter query option to the given entity collection.
*
* @param filterOption Filter option
* @param entitySet Entity collection
* @param edmEntitySet Entity set
* @throws ODataApplicationException
*/
public static void applyFilterSystemQuery(final FilterOption filterOption, final EntityCollection entitySet,
final EdmBindingTarget edmEntitySet) throws ODataApplicationException {
try {
final Iterator<Entity> iter = entitySet.getEntities().iterator();
while (iter.hasNext()) {
final VisitorOperand operand =
filterOption.getExpression().accept(new ExpressionVisitorImpl(iter.next(), edmEntitySet));
final TypedOperand typedOperand = operand.asTypedOperand();
if (typedOperand.is(ODataConstants.primitiveBoolean)) {
if (Boolean.FALSE.equals(typedOperand.getTypedValue(Boolean.class))) {
iter.remove();
}
} else {
throw new ODataApplicationException(
"Invalid filter expression. Filter expressions must return a value of " +
"type Edm.Boolean", HttpStatusCode.BAD_REQUEST.getStatusCode(), Locale.ROOT);
}
}
} catch (ExpressionVisitException e) {
throw new ODataApplicationException("Exception in filter evaluation",
HttpStatusCode.INTERNAL_SERVER_ERROR.getStatusCode(), Locale.ROOT);
}
}
开发者ID:wso2,
项目名称:carbon-data,
代码行数:34,
代码来源:QueryHandler.java
示例10: getRelatedBindingTarget
点赞 2
import org.apache.olingo.commons.api.edm.EdmBindingTarget; //导入依赖的package包/类
/**
* Override because of if child entity type has name which starts with as
* parent entity type name, then wrong entity set is returning.
*/
@Override
public EdmBindingTarget getRelatedBindingTarget(final String path) {
if (path == null) {
return null;
}
EdmBindingTarget bindingTarget = null;
boolean found = false;
for (Iterator<EdmNavigationPropertyBinding> itor = getNavigationPropertyBindings()
.iterator(); itor.hasNext() && !found;) {
EdmNavigationPropertyBinding binding = itor.next();
checkBinding(binding);
// Replace 'startsWith' to 'equals'
if (path.equals(binding.getPath())) {
Target target = new Target(binding.getTarget(), getEntityContainer());
EdmEntityContainer entityContainer = getEntityContainer(
target.getEntityContainer());
try {
bindingTarget = entityContainer.getEntitySet(target.getTargetName());
if (bindingTarget == null) {
throw new EdmException("Cannot find EntitySet " + target.getTargetName());
}
} catch (EdmException e) {
bindingTarget = entityContainer.getSingleton(target.getTargetName());
if (bindingTarget == null) {
throw new EdmException("Cannot find Singleton " + target.getTargetName(),
e);
}
} finally {
found = bindingTarget != null;
}
}
}
return bindingTarget;
}
开发者ID:Hevelian,
项目名称:hevelian-olastic,
代码行数:39,
代码来源:ElasticEdmEntitySet.java
示例11: validate
点赞 2
import org.apache.olingo.commons.api.edm.EdmBindingTarget; //导入依赖的package包/类
public void validate(final EdmBindingTarget edmBindingTarget, final Entity entity)
throws DataProviderException {
final List<String> path = new ArrayList<String>();
validateEntitySetProperties(entity.getProperties(), edmBindingTarget,
edmBindingTarget.getEntityType(), path);
validateNavigationProperties(entity, edmBindingTarget, edmBindingTarget.getEntityType(), path);
}
开发者ID:RedHelixOrg,
项目名称:RedHelix-1,
代码行数:9,
代码来源:RequestValidator.java
示例12: validateNavigationProperties
点赞 2
import org.apache.olingo.commons.api.edm.EdmBindingTarget; //导入依赖的package包/类
private void validateNavigationProperties(final Linked entity,
final EdmBindingTarget edmBindingTarget, final EdmStructuredType edmType,
final List<String> path) throws DataProviderException {
for (final String navPropertyName : edmType.getNavigationPropertyNames()) {
final EdmNavigationProperty edmProperty = edmType.getNavigationProperty(navPropertyName);
if (entity == null && !edmProperty.isNullable()) {
throw new DataProviderException(
"Navigation property " + navPropertyName + " must not be null",
HttpStatusCode.BAD_REQUEST);
} else if (entity != null) {
final Link navigationBinding = entity.getNavigationBinding(navPropertyName);
final Link navigationLink = entity.getNavigationLink(navPropertyName);
final List<String> newPath = new ArrayList<String>(path);
newPath.add(edmProperty.getName());
final EdmBindingTarget target =
edmBindingTarget.getRelatedBindingTarget(buildPath(newPath));
final ValidationResult bindingResult = validateBinding(navigationBinding, edmProperty);
final ValidationResult linkResult =
validateNavigationLink(navigationLink, edmProperty, target);
if ((isInsert && !edmProperty.isNullable()
&& (bindingResult != ValidationResult.FOUND && linkResult != ValidationResult.FOUND))
|| (!(isInsert && isPatch) && !edmProperty.isNullable()
&& linkResult == ValidationResult.EMPTY)) {
throw new DataProviderException(
"Navigation property " + navPropertyName + " must not be null",
HttpStatusCode.BAD_REQUEST);
}
}
}
}
开发者ID:RedHelixOrg,
项目名称:RedHelix-1,
代码行数:33,
代码来源:RequestValidator.java
示例13: validateNavigationLink
点赞 2
import org.apache.olingo.commons.api.edm.EdmBindingTarget; //导入依赖的package包/类
private ValidationResult validateNavigationLink(final Link navigationLink,
final EdmNavigationProperty edmProperty, final EdmBindingTarget edmBindingTarget)
throws DataProviderException {
if (navigationLink == null) {
return ValidationResult.NOT_FOUND;
}
if (edmProperty.isCollection()) {
final EntityCollection inlineEntitySet = navigationLink.getInlineEntitySet();
if (inlineEntitySet != null) {
if (!isInsert && inlineEntitySet.getEntities().size() > 0) {
throw new DataProvider.DataProviderException("Deep update is not allowed",
HttpStatusCode.BAD_REQUEST);
} else {
for (final Entity entity : navigationLink.getInlineEntitySet().getEntities()) {
validate(edmBindingTarget, entity);
}
}
}
} else {
final Entity inlineEntity = navigationLink.getInlineEntity();
if (!isInsert && inlineEntity != null) {
throw new DataProvider.DataProviderException("Deep update is not allowed",
HttpStatusCode.BAD_REQUEST);
} else if (inlineEntity != null) {
validate(edmBindingTarget, navigationLink.getInlineEntity());
}
}
return ValidationResult.FOUND;
}
开发者ID:RedHelixOrg,
项目名称:RedHelix-1,
代码行数:32,
代码来源:RequestValidator.java
示例14: validateProperties
点赞 2
import org.apache.olingo.commons.api.edm.EdmBindingTarget; //导入依赖的package包/类
private void validateProperties(final List<Property> properties,
final EdmBindingTarget edmBindingTarget, final EdmStructuredType edmType,
final List<String> keyPredicateNames, final List<String> path) throws DataProviderException {
for (final String propertyName : edmType.getPropertyNames()) {
final EdmProperty edmProperty = (EdmProperty) edmType.getProperty(propertyName);
// Ignore key properties, they are set automatically
if (!keyPredicateNames.contains(propertyName)) {
final Property property = getProperty(properties, propertyName);
// Check if all "not nullable" properties are set
if (!edmProperty.isNullable()) {
if ((property != null && property.isNull()) // Update,insert; Property is explicit set to
// null
|| (isInsert && property == null) // Insert; Property not provided
|| (!isInsert && !isPatch && property == null)) { // Insert(Put); Property not
// provided
throw new DataProviderException("Property " + propertyName + " must not be null",
HttpStatusCode.BAD_REQUEST);
}
}
// Validate property value
validatePropertyValue(property, edmProperty, edmBindingTarget, path);
}
}
}
开发者ID:RedHelixOrg,
项目名称:RedHelix-1,
代码行数:29,
代码来源:RequestValidator.java
示例15: validateComplexValue
点赞 2
import org.apache.olingo.commons.api.edm.EdmBindingTarget; //导入依赖的package包/类
private void validateComplexValue(final ComplexValue value,
final EdmBindingTarget edmBindingTarget, final EdmComplexType edmType,
final List<String> path) throws DataProviderException {
// The whole complex property can be nullable but nested primitive, navigation properties can be
// not nullable
final List<Property> properties =
(value == null) ? new ArrayList<Property>() : value.getValue();
validateProperties(properties, edmBindingTarget, edmType, new ArrayList<String>(0), path);
validateNavigationProperties(value, edmBindingTarget, edmType, path);
}
开发者ID:RedHelixOrg,
项目名称:RedHelix-1,
代码行数:12,
代码来源:RequestValidator.java
示例16: validate
点赞 2
import org.apache.olingo.commons.api.edm.EdmBindingTarget; //导入依赖的package包/类
public void validate(final EdmBindingTarget edmBindingTarget, final Entity entity)
throws DataProviderException {
final List<String> path = new ArrayList<String>();
validateEntitySetProperties(entity.getProperties(), edmBindingTarget, edmBindingTarget.getEntityType(), path);
validateNavigationProperties(entity, edmBindingTarget, edmBindingTarget.getEntityType(), path);
}
开发者ID:apache,
项目名称:olingo-odata4,
代码行数:8,
代码来源:RequestValidator.java
示例17: validateNavigationProperties
点赞 2
import org.apache.olingo.commons.api.edm.EdmBindingTarget; //导入依赖的package包/类
private void validateNavigationProperties(final Linked entity, final EdmBindingTarget edmBindingTarget,
final EdmStructuredType edmType, final List<String> path) throws DataProviderException {
for (final String navPropertyName : edmType.getNavigationPropertyNames()) {
final EdmNavigationProperty edmProperty = edmType.getNavigationProperty(navPropertyName);
if (entity == null && !edmProperty.isNullable()) {
throw new DataProviderException("Navigation property " + navPropertyName + " must not be null",
HttpStatusCode.BAD_REQUEST);
} else if (entity != null) {
final Link navigationBinding = entity.getNavigationBinding(navPropertyName);
final Link navigationLink = entity.getNavigationLink(navPropertyName);
final List<String> newPath = new ArrayList<String>(path);
newPath.add(edmProperty.getName());
final EdmBindingTarget target = edmBindingTarget.getRelatedBindingTarget(buildPath(newPath));
final ValidationResult bindingResult = validateBinding(navigationBinding, edmProperty);
final ValidationResult linkResult = validateNavigationLink(navigationLink,
edmProperty,
target);
if ((isInsert && !edmProperty.isNullable()
&& (bindingResult != ValidationResult.FOUND
&& linkResult != ValidationResult.FOUND))
|| (!(isInsert && isPatch) && !edmProperty.isNullable() && linkResult == ValidationResult.EMPTY)) {
throw new DataProviderException("Navigation property " + navPropertyName + " must not be null",
HttpStatusCode.BAD_REQUEST);
}
}
}
}
开发者ID:apache,
项目名称:olingo-odata4,
代码行数:30,
代码来源:RequestValidator.java
示例18: validateNavigationLink
点赞 2
import org.apache.olingo.commons.api.edm.EdmBindingTarget; //导入依赖的package包/类
private ValidationResult validateNavigationLink(final Link navigationLink, final EdmNavigationProperty edmProperty,
final EdmBindingTarget edmBindingTarget) throws DataProviderException {
if (navigationLink == null) {
return ValidationResult.NOT_FOUND;
}
if (edmProperty.isCollection()) {
final EntityCollection inlineEntitySet = navigationLink.getInlineEntitySet();
if (inlineEntitySet != null) {
if (!isInsert && inlineEntitySet.getEntities().size() > 0) {
throw new DataProvider.DataProviderException("Deep update is not allowed", HttpStatusCode.BAD_REQUEST);
} else {
for (final Entity entity : navigationLink.getInlineEntitySet().getEntities()) {
validate(edmBindingTarget, entity);
}
}
}
} else {
final Entity inlineEntity = navigationLink.getInlineEntity();
if (!isInsert && inlineEntity != null) {
throw new DataProvider.DataProviderException("Deep update is not allowed", HttpStatusCode.BAD_REQUEST);
} else if (inlineEntity != null) {
validate(edmBindingTarget, navigationLink.getInlineEntity());
}
}
return ValidationResult.FOUND;
}
开发者ID:apache,
项目名称:olingo-odata4,
代码行数:29,
代码来源:RequestValidator.java
示例19: validateComplexValue
点赞 2
import org.apache.olingo.commons.api.edm.EdmBindingTarget; //导入依赖的package包/类
private void validateComplexValue(final ComplexValue value, final EdmBindingTarget edmBindingTarget,
final EdmComplexType edmType, final List<String> path) throws DataProviderException {
// The whole complex property can be nullable but nested primitive, navigation properties can be not nullable
final List<Property> properties = (value == null) ? new ArrayList<Property>() : value.getValue();
validateProperties(properties, edmBindingTarget, edmType, new ArrayList<String>(0), path);
validateNavigationProperties(value, edmBindingTarget, edmType, path);
}
开发者ID:apache,
项目名称:olingo-odata4,
代码行数:9,
代码来源:RequestValidator.java
示例20: transformEntitySetGraphToTree
点赞 2
import org.apache.olingo.commons.api.edm.EdmBindingTarget; //导入依赖的package包/类
public EntityCollection transformEntitySetGraphToTree(final EntityCollection entitySet,
final EdmBindingTarget edmBindingTarget, final ExpandOption expand,
final ExpandItem expandItem) throws ODataApplicationException {
final EntityCollection newEntitySet = newEntitySet(entitySet);
for (final Entity entity : entitySet.getEntities()) {
newEntitySet.getEntities().add(transformEntityGraphToTree(entity, edmBindingTarget, expand, expandItem));
}
if (expandItem != null && expandItem.hasCountPath()) {
newEntitySet.setCount(entitySet.getEntities().size());
}
return newEntitySet;
}
开发者ID:apache,
项目名称:olingo-odata4,
代码行数:15,
代码来源:ExpandSystemQueryOptionHandler.java
示例21: transformEntityGraphToTree
点赞 2
import org.apache.olingo.commons.api.edm.EdmBindingTarget; //导入依赖的package包/类
public Entity transformEntityGraphToTree(final Entity entity, final EdmBindingTarget edmEntitySet,
final ExpandOption expand, final ExpandItem parentExpandItem) throws ODataApplicationException {
final Entity newEntity = newEntity(entity);
if (hasExpandItems(expand)) {
final boolean expandAll = expandAll(expand);
final Set<String> expanded = expandAll ? null : getExpandedPropertyNames(expand.getExpandItems());
final EdmEntityType edmType = edmEntitySet.getEntityType();
for (final Link link : entity.getNavigationLinks()) {
final String propertyName = link.getTitle();
if (expandAll || expanded.contains(propertyName)) {
final EdmNavigationProperty edmNavigationProperty = edmType.getNavigationProperty(propertyName);
final EdmBindingTarget edmBindingTarget = edmEntitySet.getRelatedBindingTarget(propertyName);
final Link newLink = newLink(link);
newEntity.getNavigationLinks().add(newLink);
final ExpandItem expandItem = getInnerExpandItem(expand, propertyName);
if (edmNavigationProperty.isCollection()) {
newLink.setInlineEntitySet(transformEntitySetGraphToTree(link.getInlineEntitySet(),
edmBindingTarget, expandItem.getExpandOption(), expandItem));
} else {
newLink.setInlineEntity(transformEntityGraphToTree(link.getInlineEntity(),
edmBindingTarget,expandItem.getExpandOption(), expandItem));
}
}
}
}
return newEntity;
}
开发者ID:apache,
项目名称:olingo-odata4,
代码行数:32,
代码来源:ExpandSystemQueryOptionHandler.java
示例22: simpleEntityValueValidationNotActiveForMedia
点赞 2
import org.apache.olingo.commons.api.edm.EdmBindingTarget; //导入依赖的package包/类
@Test
public void simpleEntityValueValidationNotActiveForMedia() throws Exception {
final UriInfo uriInfo = new Parser(edm, odata).parseUri("ESMedia(1)/$value", null, null, null);
CustomETagSupport support = mock(CustomETagSupport.class);
when(support.hasETag(any(EdmBindingTarget.class))).thenReturn(true);
when(support.hasMediaETag(any(EdmBindingTarget.class))).thenReturn(false);
assertFalse(new PreconditionsValidator(uriInfo).mustValidatePreconditions(support, true));
}
开发者ID:apache,
项目名称:olingo-odata4,
代码行数:11,
代码来源:PreconditionsValidatorTest.java
示例23: getEntitySetFromFunctionImport
点赞 2
import org.apache.olingo.commons.api.edm.EdmBindingTarget; //导入依赖的package包/类
private EdmBindingTarget getEntitySetFromFunctionImport(final UriResourceFunction uriResourceFunction) {
EdmFunctionImport functionImport = uriResourceFunction.getFunctionImport();
if (functionImport != null && functionImport.getReturnedEntitySet() != null
&& !uriResourceFunction.isCollection()) {
return functionImport.getReturnedEntitySet();
}
return null;
}
开发者ID:apache,
项目名称:olingo-odata4,
代码行数:9,
代码来源:PreconditionsValidator.java
示例24: getEntitySetFromNavigation
点赞 2
import org.apache.olingo.commons.api.edm.EdmBindingTarget; //导入依赖的package包/类
private EdmBindingTarget getEntitySetFromNavigation(final EdmBindingTarget lastFoundEntitySetOrSingleton,
final UriResourceNavigation uriResourceNavigation) {
if (lastFoundEntitySetOrSingleton != null && !uriResourceNavigation.isCollection()) {
EdmNavigationProperty navProp = uriResourceNavigation.getProperty();
return lastFoundEntitySetOrSingleton.getRelatedBindingTarget(navProp.getName());
}
return null;
}
开发者ID:apache,
项目名称:olingo-odata4,
代码行数:9,
代码来源:PreconditionsValidator.java
示例25: appendNavigationPropertyBindings
点赞 2
import org.apache.olingo.commons.api.edm.EdmBindingTarget; //导入依赖的package包/类
private void appendNavigationPropertyBindings(final JsonGenerator json,
final EdmBindingTarget bindingTarget) throws SerializerException, IOException {
if (bindingTarget.getNavigationPropertyBindings() != null &&
bindingTarget.getNavigationPropertyBindings().size() > 0) {
json.writeObjectFieldStart(NAVIGATION_PROPERTY_BINDING);
for (EdmNavigationPropertyBinding binding : bindingTarget.getNavigationPropertyBindings()) {
json.writeStringField(binding.getPath(), binding.getTarget());
}
json.writeEndObject();
}
}
开发者ID:apache,
项目名称:olingo-odata4,
代码行数:12,
代码来源:MetadataDocumentJsonSerializer.java
示例26: appendNavigationPropertyBindings
点赞 2
import org.apache.olingo.commons.api.edm.EdmBindingTarget; //导入依赖的package包/类
private void appendNavigationPropertyBindings(final XMLStreamWriter writer, final EdmBindingTarget bindingTarget)
throws XMLStreamException {
if (bindingTarget.getNavigationPropertyBindings() != null) {
for (EdmNavigationPropertyBinding binding : bindingTarget.getNavigationPropertyBindings()) {
writer.writeEmptyElement(XML_NAVIGATION_PROPERTY_BINDING);
writer.writeAttribute(XML_PATH, binding.getPath());
writer.writeAttribute(XML_TARGET, binding.getTarget());
}
}
}
开发者ID:apache,
项目名称:olingo-odata4,
代码行数:11,
代码来源:MetadataDocumentXmlSerializer.java
示例27: buildEntitySetContextURL
点赞 2
import org.apache.olingo.commons.api.edm.EdmBindingTarget; //导入依赖的package包/类
static ContextURL.Builder buildEntitySetContextURL(UriHelper helper,
EdmBindingTarget edmEntitySet, List<UriParameter> keyPredicates, UriInfo uriInfo,
LinkedList<UriResourceNavigation> navigations, boolean collectionReturn, boolean singleton)
throws SerializerException {
ContextURL.Builder builder =
ContextURL.with().entitySetOrSingletonOrType(getTargetEntitySet(edmEntitySet, navigations));
String select = helper.buildContextURLSelectList(edmEntitySet.getEntityType(),
uriInfo.getExpandOption(), uriInfo.getSelectOption());
if (!singleton) {
builder.suffix(collectionReturn ? null : Suffix.ENTITY);
}
builder.selectList(select);
final UriInfoResource resource = uriInfo.asUriInfoResource();
final List<UriResource> resourceParts = resource.getUriResourceParts();
final List<String> path = getPropertyPath(resourceParts);
String propertyPath = buildPropertyPath(path);
final String navPath = buildNavPath(helper, edmEntitySet.getEntityType(), navigations, collectionReturn);
if (navPath != null && !navPath.isEmpty()) {
if (keyPredicates != null) {
builder.keyPath(helper.buildContextURLKeyPredicate(keyPredicates));
}
if (propertyPath != null) {
propertyPath = navPath+"/"+propertyPath;
} else {
propertyPath = navPath;
}
}
builder.navOrPropertyPath(propertyPath);
return builder;
}
开发者ID:apache,
项目名称:olingo-odata4,
代码行数:34,
代码来源:DataRequest.java
示例28: findEntityType
点赞 2
import org.apache.olingo.commons.api.edm.EdmBindingTarget; //导入依赖的package包/类
private EdmType findEntityType(
final String entitySetOrSingletonOrType, final EdmEntityContainer container) {
EdmType type = null;
final String firstToken = StringUtils.substringBefore(entitySetOrSingletonOrType, "/");
EdmBindingTarget bindingTarget = container.getEntitySet(firstToken);
if (bindingTarget == null) {
bindingTarget = container.getSingleton(firstToken);
}
if (bindingTarget != null) {
type = bindingTarget.getEntityType();
}
if (entitySetOrSingletonOrType.indexOf('/') != -1) {
final String[] splitted = entitySetOrSingletonOrType.split("/");
if (splitted.length > 1) {
for (int i = 1; i < splitted.length && type != null; i++) {
final EdmNavigationProperty navProp = ((EdmStructuredType) type).getNavigationProperty(splitted[i]);
if (navProp == null) {
EdmProperty property = ((EdmStructuredType) type).getStructuralProperty(splitted[i]);
if (property != null) {
type = property.getType();
} else {
type = null;
}
} else {
type = navProp.getType();
}
}
}
}
return type;
}
开发者ID:apache,
项目名称:olingo-odata4,
代码行数:36,
代码来源:ODataBinderImpl.java
示例29: validateEntitySetProperties
点赞 2
import org.apache.olingo.commons.api.edm.EdmBindingTarget; //导入依赖的package包/类
private void validateEntitySetProperties(final List<Property> properties,
final EdmBindingTarget edmBindingTarget, final EdmEntityType edmType, final List<String> path)
throws DataProviderException {
validateProperties(properties, edmBindingTarget, edmType, edmType.getKeyPredicateNames(), path);
}
开发者ID:RedHelixOrg,
项目名称:RedHelix-1,
代码行数:6,
代码来源:RequestValidator.java
示例30: hasETag
点赞 2
import org.apache.olingo.commons.api.edm.EdmBindingTarget; //导入依赖的package包/类
@Override
public boolean hasETag(final EdmBindingTarget entitySetOrSingleton) {
return entitySetOrSingleton.getName().equals("ESCompAllPrim");
}
开发者ID:apache,
项目名称:olingo-odata4,
代码行数:5,
代码来源:ETagSupport.java
示例31: hasMediaETag
点赞 2
import org.apache.olingo.commons.api.edm.EdmBindingTarget; //导入依赖的package包/类
@Override
public boolean hasMediaETag(final EdmBindingTarget entitySetOrSingleton) {
return entitySetOrSingleton.getName().equals("ESMedia");
}
开发者ID:apache,
项目名称:olingo-odata4,
代码行数:5,
代码来源:ETagSupport.java
示例32: validateEntitySetProperties
点赞 2
import org.apache.olingo.commons.api.edm.EdmBindingTarget; //导入依赖的package包/类
private void validateEntitySetProperties(final List<Property> properties, final EdmBindingTarget edmBindingTarget,
final EdmEntityType edmType, final List<String> path) throws DataProviderException {
validateProperties(properties, edmBindingTarget, edmType, edmType.getKeyPredicateNames(), path);
}
开发者ID:apache,
项目名称:olingo-odata4,
代码行数:5,
代码来源:RequestValidator.java
示例33: applyExpandOptionToEntity
点赞 2
import org.apache.olingo.commons.api.edm.EdmBindingTarget; //导入依赖的package包/类
private void applyExpandOptionToEntity(final Entity entity, final EdmBindingTarget edmBindingTarget,
final ExpandOption expandOption, final UriInfoResource uriInfo, final Edm edm) throws ODataApplicationException {
final EdmEntityType entityType = edmBindingTarget.getEntityType();
for (ExpandItem item : expandOption.getExpandItems()) {
if(item.getLevelsOption() != null) {
throw new ODataApplicationException("$levels is not implemented",
HttpStatusCode.NOT_IMPLEMENTED.getStatusCode(), Locale.ROOT);
}
List<EdmNavigationProperty> navigationProperties = new ArrayList<EdmNavigationProperty>();
if(item.isStar()) {
List<EdmNavigationPropertyBinding> bindings = edmBindingTarget.getNavigationPropertyBindings();
for (EdmNavigationPropertyBinding binding : bindings) {
EdmElement property = entityType.getProperty(binding.getPath());
if(property instanceof EdmNavigationProperty) {
navigationProperties.add((EdmNavigationProperty) property);
}
}
} else {
final List<UriResource> uriResourceParts = item.getResourcePath().getUriResourceParts();
if (uriResourceParts.get(0) instanceof UriResourceNavigation) {
navigationProperties.add(((UriResourceNavigation) uriResourceParts.get(0)).getProperty());
}
}
for (EdmNavigationProperty navigationProperty: navigationProperties) {
final String navPropertyName = navigationProperty.getName();
final EdmBindingTarget targetEdmEntitySet = edmBindingTarget.getRelatedBindingTarget(navPropertyName);
final Link link = entity.getNavigationLink(navPropertyName);
if (link != null && entityType.getNavigationProperty(navPropertyName).isCollection()) {
applyOptionsToEntityCollection(link.getInlineEntitySet(),
targetEdmEntitySet,
item.getFilterOption(),
item.getOrderByOption(),
item.getCountOption(),
item.getSkipOption(),
item.getTopOption(),
item.getExpandOption(),
uriInfo, edm);
}
}
}
}
开发者ID:apache,
项目名称:olingo-odata4,
代码行数:47,
代码来源:ExpandSystemQueryOptionHandler.java
示例34: getRelatedBindingTarget
点赞 2
import org.apache.olingo.commons.api.edm.EdmBindingTarget; //导入依赖的package包/类
@Override
public EdmBindingTarget getRelatedBindingTarget(final String path) {
if (path == null) {
return null;
}
EdmBindingTarget bindingTarget = null;
boolean found = false;
for (final Iterator<EdmNavigationPropertyBinding> itor = getNavigationPropertyBindings().iterator(); itor.hasNext()
&& !found;) {
final EdmNavigationPropertyBinding binding = itor.next();
if (binding.getPath() == null || binding.getTarget() == null) {
throw new EdmException("Path or Target in navigation property binding must not be null!");
}
if (path.equals(binding.getPath())) {
final Target edmTarget = new Target(binding.getTarget(), container);
final EdmEntityContainer entityContainer = edm.getEntityContainer(edmTarget.getEntityContainer());
if (entityContainer == null) {
throw new EdmException("Cannot find entity container with name: " + edmTarget.getEntityContainer());
}
try {
bindingTarget = entityContainer.getEntitySet(edmTarget.getTargetName());
if (bindingTarget == null) {
throw new EdmException("Cannot find EntitySet " + edmTarget.getTargetName());
}
} catch (EdmException e) {
// try with singletons ...
bindingTarget = entityContainer.getSingleton(edmTarget.getTargetName());
if (bindingTarget == null) {
throw new EdmException("Cannot find Singleton " + edmTarget.getTargetName(), e);
}
} finally {
found = bindingTarget != null;
}
}
}
return bindingTarget;
}
开发者ID:apache,
项目名称:olingo-odata4,
代码行数:43,
代码来源:AbstractEdmBindingTarget.java
示例35: extractInformation
点赞 2
import org.apache.olingo.commons.api.edm.EdmBindingTarget; //导入依赖的package包/类
private EdmBindingTarget extractInformation(final UriInfo uriInfo) throws PreconditionException {
EdmBindingTarget lastFoundEntitySetOrSingleton = null;
int counter = 0;
for (UriResource uriResourcePart : uriInfo.getUriResourceParts()) {
switch (uriResourcePart.getKind()) {
case function:
lastFoundEntitySetOrSingleton = getEntitySetFromFunctionImport((UriResourceFunction) uriResourcePart);
break;
case singleton:
lastFoundEntitySetOrSingleton = ((UriResourceSingleton) uriResourcePart).getSingleton();
break;
case entitySet:
lastFoundEntitySetOrSingleton = getEntitySet((UriResourceEntitySet) uriResourcePart);
break;
case navigationProperty:
lastFoundEntitySetOrSingleton = getEntitySetFromNavigation(lastFoundEntitySetOrSingleton,
(UriResourceNavigation) uriResourcePart);
break;
case primitiveProperty:
case complexProperty:
break;
case value:
case action:
// This should not be possible since the URI Parser validates this but to be sure we throw an exception.
if (counter != uriInfo.getUriResourceParts().size() - 1) {
throw new PreconditionException("$value or Action must be the last segment in the URI.",
PreconditionException.MessageKeys.INVALID_URI);
}
break;
default:
lastFoundEntitySetOrSingleton = null;
break;
}
if (lastFoundEntitySetOrSingleton == null) {
// Once we loose track of the entity set there is no way to retrieve it.
break;
}
counter++;
}
return lastFoundEntitySetOrSingleton;
}
开发者ID:apache,
项目名称:olingo-odata4,
代码行数:42,
代码来源:PreconditionsValidator.java
示例36: getEntitySet
点赞 2
import org.apache.olingo.commons.api.edm.EdmBindingTarget; //导入依赖的package包/类
private EdmBindingTarget getEntitySet(final UriResourceEntitySet uriResourceEntitySet) {
return uriResourceEntitySet.isCollection() ? null : uriResourceEntitySet.getEntitySet();
}
开发者ID:apache,
项目名称:olingo-odata4,
代码行数:4,
代码来源:PreconditionsValidator.java
示例37: getEntitySet
点赞 2
import org.apache.olingo.commons.api.edm.EdmBindingTarget; //导入依赖的package包/类
public EdmBindingTarget getEntitySet() {
return entitySet;
}
开发者ID:apache,
项目名称:olingo-odata4,
代码行数:4,
代码来源:NavPropertyBindingDetails.java
示例38: applyOrderByOption
点赞 2
import org.apache.olingo.commons.api.edm.EdmBindingTarget; //导入依赖的package包/类
/**
* This method applies order by option query to the given entity collection.
*
* @param orderByOption Order by option
* @param entitySet Entity Set
* @param edmBindingTarget Binding Target
*/
public static void applyOrderByOption(final OrderByOption orderByOption, final EntityCollection entitySet,
final EdmBindingTarget edmBindingTarget) {
Collections.sort(entitySet.getEntities(), new Comparator<Entity>() {
@Override
@SuppressWarnings({ "unchecked", "rawtypes" })
public int compare(final Entity e1, final Entity e2) {
// Evaluate the first order option for both entity
// If and only if the result of the previous order option is equals to 0
// evaluate the next order option until all options are evaluated or they are not equals
int result = 0;
for (int i = 0; i < orderByOption.getOrders().size() && result == 0; i++) {
try {
final OrderByItem item = orderByOption.getOrders().get(i);
final TypedOperand op1 = item.getExpression()
.accept(new ExpressionVisitorImpl(e1, edmBindingTarget))
.asTypedOperand();
final TypedOperand op2 = item.getExpression()
.accept(new ExpressionVisitorImpl(e2, edmBindingTarget))
.asTypedOperand();
if (op1.isNull() || op2.isNull()) {
if (op1.isNull() && op2.isNull()) {
result = 0; // null is equals to null
} else {
result = op1.isNull() ? -1 : 1;
}
} else {
Object o1 = op1.getValue();
Object o2 = op2.getValue();
if (o1.getClass() == o2.getClass() && o1 instanceof Comparable) {
result = ((Comparable) o1).compareTo(o2);
} else {
result = 0;
}
}
result = item.isDescending() ? result * -1 : result;
} catch (ExpressionVisitException | ODataApplicationException e) {
throw new RuntimeException(e);
}
}
return result;
}
});
}
开发者ID:wso2,
项目名称:carbon-data,
代码行数:52,
代码来源:QueryHandler.java
示例39: ExpressionVisitorImpl
点赞 2
import org.apache.olingo.commons.api.edm.EdmBindingTarget; //导入依赖的package包/类
public ExpressionVisitorImpl(final Entity entity, final EdmBindingTarget bindingTarget) {
this.entity = entity;
}
开发者ID:wso2,
项目名称:carbon-data,
代码行数:4,
代码来源:ExpressionVisitorImpl.java
示例40: hasETag
点赞 1
import org.apache.olingo.commons.api.edm.EdmBindingTarget; //导入依赖的package包/类
/**
* This method will be called for update requests which target an entity or a property of an entity.
* If this method returns true and an header is not specified we will return a "Precondition Required" response.
* Validation has to be performed inside the processor methods after the dispatching.
* If this method returns false and an header is specified we will ignore the header.
* @param entitySetOrSingleton
* @return true if the entity set specified needs an if-match/if-none-match header
*/
boolean hasETag(EdmBindingTarget entitySetOrSingleton);
开发者ID:apache,
项目名称:olingo-odata4,
代码行数:10,
代码来源:CustomETagSupport.java