本文整理汇总了Java中org.apache.olingo.commons.api.edm.EdmProperty类的典型用法代码示例。如果您正苦于以下问题:Java EdmProperty类的具体用法?Java EdmProperty怎么用?Java EdmProperty使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
EdmProperty类属于org.apache.olingo.commons.api.edm包,在下文中一共展示了EdmProperty类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: toSort
import org.apache.olingo.commons.api.edm.EdmProperty; //导入依赖的package包/类
/**
* Converts {@link OrderByItem} to {@link Sort} needed for
* {@link Pagination}.
*
* @param orderByItem
* order by item
* @return sort instance, or null in case order by item wasn't specific type
*/
protected Sort toSort(OrderByItem orderByItem) {
Expression expression = orderByItem.getExpression();
if (expression instanceof Member) {
UriInfoResource resourcePath = ((Member) expression).getResourcePath();
UriResource uriResource = resourcePath.getUriResourceParts().get(0);
if (uriResource instanceof UriResourcePrimitiveProperty) {
EdmProperty edmProperty = ((UriResourcePrimitiveProperty) uriResource)
.getProperty();
String property = edmProperty.getName();
if (edmProperty instanceof ElasticEdmProperty) {
ElasticEdmProperty entityTypeProperty = (ElasticEdmProperty) edmProperty;
property = addKeywordIfNeeded(entityTypeProperty.getEField(),
entityTypeProperty.getAnnotations());
}
return new Sort(property,
orderByItem.isDescending() ? Sort.Direction.DESC : Sort.Direction.ASC);
}
}
return null;
}
开发者ID:Hevelian,项目名称:hevelian-olastic,代码行数:29,代码来源:RequestCreator.java
示例2: updatePrimitiveValue
import org.apache.olingo.commons.api.edm.EdmProperty; //导入依赖的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
示例3: writeProperties
import org.apache.olingo.commons.api.edm.EdmProperty; //导入依赖的package包/类
@Override
protected void writeProperties(ServiceMetadata metadata, EdmStructuredType type,
List<Property> properties, SelectOption select, JsonGenerator json)
throws IOException, SerializerException {
boolean all = ExpandSelectHelper.isAll(select);
Set<String> selected = all ? new HashSet<>()
: ExpandSelectHelper.getSelectedPropertyNames(select.getSelectItems());
for (Property property : properties) {
String propertyName = property.getName();
if (all || selected.contains(propertyName)) {
EdmProperty edmProperty = type.getStructuralProperty(propertyName);
if (edmProperty == null) {
edmProperty = new EdmPropertyImpl(metadata.getEdm(), new CsdlProperty()
.setType(getPropertyType(property.getValue())).setName(propertyName));
}
Set<List<String>> selectedPaths = all || edmProperty.isPrimitive() ? null
: ExpandSelectHelper.getSelectedPaths(select.getSelectItems(),
propertyName);
writeProperty(metadata, edmProperty, property, selectedPaths, json);
}
}
}
开发者ID:Hevelian,项目名称:hevelian-olastic,代码行数:23,代码来源:ElasticODataJsonSerializer.java
示例4: writeProperties
import org.apache.olingo.commons.api.edm.EdmProperty; //导入依赖的package包/类
@Override
protected void writeProperties(ServiceMetadata metadata, EdmStructuredType type,
List<Property> properties, SelectOption select, String xml10InvalidCharReplacement,
XMLStreamWriter writer) throws XMLStreamException, SerializerException {
boolean all = ExpandSelectHelper.isAll(select);
Set<String> selected = all ? new HashSet<>()
: ExpandSelectHelper.getSelectedPropertyNames(select.getSelectItems());
for (Property property : properties) {
String propertyName = property.getName();
if (all || selected.contains(propertyName)) {
EdmProperty edmProperty = type.getStructuralProperty(propertyName);
if (edmProperty == null) {
edmProperty = new EdmPropertyImpl(metadata.getEdm(), new CsdlProperty()
.setType(getPropertyType(property.getValue())).setName(propertyName));
}
Set<List<String>> selectedPaths = all || edmProperty.isPrimitive() ? null
: ExpandSelectHelper.getSelectedPaths(select.getSelectItems(),
propertyName);
writeProperty(metadata, edmProperty, property, selectedPaths,
xml10InvalidCharReplacement, writer);
}
}
}
开发者ID:Hevelian,项目名称:hevelian-olastic,代码行数:24,代码来源:ElasticODataXmlSerializer.java
示例5: validatePropertyValue
import org.apache.olingo.commons.api.edm.EdmProperty; //导入依赖的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
示例6: createProperty
import org.apache.olingo.commons.api.edm.EdmProperty; //导入依赖的package包/类
private Property createProperty(final EdmProperty edmProperty, final String propertyName)
throws DataProviderException {
Property newProperty;
if (edmProperty.isPrimitive()) {
newProperty = edmProperty.isCollection() ? DataCreator.createPrimitiveCollection(propertyName)
: DataCreator.createPrimitive(propertyName, null);
} else if (edmProperty.isCollection()) {
@SuppressWarnings("unchecked")
Property newProperty2 = DataCreator.createComplexCollection(propertyName);
newProperty = newProperty2;
} else {
newProperty = DataCreator.createComplex(propertyName);
createProperties((EdmComplexType) edmProperty.getType(), newProperty.asComplex().getValue());
}
return newProperty;
}
开发者ID:RedHelixOrg,项目名称:RedHelix-1,代码行数:19,代码来源:DataProvider.java
示例7: createComplexValue
import org.apache.olingo.commons.api.edm.EdmProperty; //导入依赖的package包/类
private ComplexValue createComplexValue(final EdmProperty edmProperty,
final ComplexValue complexValue, final boolean patch) throws DataProviderException {
final ComplexValue result = new ComplexValue();
final EdmComplexType edmType = (EdmComplexType) edmProperty.getType();
final List<Property> givenProperties = complexValue.getValue();
// Create ALL properties, even if no value is given. Check if null is allowed
for (final String propertyName : edmType.getPropertyNames()) {
final EdmProperty innerEdmProperty = (EdmProperty) edmType.getProperty(propertyName);
final Property currentProperty = findProperty(propertyName, givenProperties);
final Property newProperty = createProperty(innerEdmProperty, propertyName);
result.getValue().add(newProperty);
if (currentProperty != null) {
updateProperty(innerEdmProperty, newProperty, currentProperty, patch);
} else if (innerEdmProperty.isNullable()) {
// Check complex properties ... may be null is not allowed
if (edmProperty.getType().getKind() == EdmTypeKind.COMPLEX) {
updateProperty(innerEdmProperty, newProperty, null, patch);
}
}
}
return result;
}
开发者ID:RedHelixOrg,项目名称:RedHelix-1,代码行数:26,代码来源:DataProvider.java
示例8: validateProperties
import org.apache.olingo.commons.api.edm.EdmProperty; //导入依赖的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
示例9: writeProperties
import org.apache.olingo.commons.api.edm.EdmProperty; //导入依赖的package包/类
protected void writeProperties(final ServiceMetadata metadata, final EdmStructuredType type,
final List<Property> properties,
final SelectOption select, final JsonGenerator json)
throws IOException, SerializerException {
final boolean all = ExpandSelectHelper.isAll(select);
final Set<String> selected = all ? new HashSet<String>() : ExpandSelectHelper.getSelectedPropertyNames(select
.getSelectItems());
for (final String propertyName : type.getPropertyNames()) {
if (all || selected.contains(propertyName)) {
final EdmProperty edmProperty = type.getStructuralProperty(propertyName);
final Property property = findProperty(propertyName, properties);
final Set<List<String>> selectedPaths = all || edmProperty.isPrimitive() ? null : ExpandSelectHelper
.getSelectedPaths(select.getSelectItems(), propertyName);
writeProperty(metadata, edmProperty, property, selectedPaths, json);
}
}
}
开发者ID:apache,项目名称:olingo-odata4,代码行数:18,代码来源:JsonDeltaSerializer.java
示例10: keyBehaviour
import org.apache.olingo.commons.api.edm.EdmProperty; //导入依赖的package包/类
@Test
public void keyBehaviour() {
List<String> keyPredicateNames = baseType.getKeyPredicateNames();
assertEquals(1, keyPredicateNames.size());
assertEquals("Id", keyPredicateNames.get(0));
EdmKeyPropertyRef keyPropertyRef = baseType.getKeyPropertyRef("Id");
assertNotNull(keyPropertyRef);
assertEquals("Id", keyPropertyRef.getName());
assertNull(keyPropertyRef.getAlias());
EdmProperty keyProperty = keyPropertyRef.getProperty();
assertNotNull(keyProperty);
assertEquals(baseType.getProperty("Id"), keyProperty);
List<EdmKeyPropertyRef> keyPropertyRefs = baseType.getKeyPropertyRefs();
assertNotNull(keyPropertyRefs);
assertEquals(1, keyPropertyRefs.size());
assertEquals("Id", keyPropertyRefs.get(0).getName());
}
开发者ID:apache,项目名称:olingo-odata4,代码行数:21,代码来源:EdmEntityTypeImplTest.java
示例11: aliasForPropertyInComplexPropertyOneLevel
import org.apache.olingo.commons.api.edm.EdmProperty; //导入依赖的package包/类
@Test
public void aliasForPropertyInComplexPropertyOneLevel() {
CsdlPropertyRef providerRef = new CsdlPropertyRef().setName("comp/Id").setAlias("alias");
EdmEntityType etMock = mock(EdmEntityType.class);
EdmProperty keyPropertyMock = mock(EdmProperty.class);
EdmProperty compMock = mock(EdmProperty.class);
EdmComplexType compTypeMock = mock(EdmComplexType.class);
when(compTypeMock.getStructuralProperty("Id")).thenReturn(keyPropertyMock);
when(compMock.getType()).thenReturn(compTypeMock);
when(etMock.getStructuralProperty("comp")).thenReturn(compMock);
EdmKeyPropertyRef ref = new EdmKeyPropertyRefImpl(etMock, providerRef);
assertEquals("alias", ref.getAlias());
EdmProperty property = ref.getProperty();
assertNotNull(property);
assertTrue(property == keyPropertyMock);
}
开发者ID:apache,项目名称:olingo-odata4,代码行数:18,代码来源:EdmKeyPropertyRefImplTest.java
示例12: upsertStreamProperty
import org.apache.olingo.commons.api.edm.EdmProperty; //导入依赖的package包/类
@Override
public void upsertStreamProperty(DataRequest request, String entityETag, InputStream streamContent,
NoContentResponse response) throws ODataLibraryException, ODataApplicationException {
final EdmEntitySet edmEntitySet = request.getEntitySet();
List<UriParameter> keys = request.getKeyPredicates();
Entity entity = this.dataModel.getEntity(edmEntitySet.getName(), keys);
EdmProperty property = request.getUriResourceProperty().getProperty();
if (streamContent == null) {
boolean deleted = this.dataModel.deleteStream(entity, property);
if (deleted) {
response.writeNoContent();
} else {
response.writeNotFound();
}
} else {
boolean updated = this.dataModel.updateStream(entity, property, streamContent);
if (updated) {
response.writeNoContent();
} else {
response.writeServerError(true);
}
}
}
开发者ID:apache,项目名称:olingo-odata4,代码行数:26,代码来源:TripPinHandler.java
示例13: getTypeReturnsComplexType
import org.apache.olingo.commons.api.edm.EdmProperty; //导入依赖的package包/类
@Test
public void getTypeReturnsComplexType() throws Exception {
CsdlEdmProvider provider = mock(CsdlEdmProvider.class);
EdmProviderImpl edm = new EdmProviderImpl(provider);
final FullQualifiedName complexTypeName = new FullQualifiedName("ns", "complex");
CsdlComplexType complexTypeProvider = new CsdlComplexType();
when(provider.getComplexType(complexTypeName)).thenReturn(complexTypeProvider);
CsdlProperty propertyProvider = new CsdlProperty();
propertyProvider.setType(complexTypeName);
final EdmProperty property = new EdmPropertyImpl(edm, propertyProvider);
assertFalse(property.isCollection());
assertFalse(property.isPrimitive());
final EdmType type = property.getType();
assertEquals(EdmTypeKind.COMPLEX, type.getKind());
assertEquals("ns", type.getNamespace());
assertEquals("complex", type.getName());
}
开发者ID:apache,项目名称:olingo-odata4,代码行数:18,代码来源:EdmPropertyImplTest.java
示例14: getTypeReturnsEnumType
import org.apache.olingo.commons.api.edm.EdmProperty; //导入依赖的package包/类
@Test
public void getTypeReturnsEnumType() throws Exception {
CsdlEdmProvider provider = mock(CsdlEdmProvider.class);
EdmProviderImpl edm = new EdmProviderImpl(provider);
final FullQualifiedName enumTypeName = new FullQualifiedName("ns", "enum");
CsdlEnumType enumTypeProvider = new CsdlEnumType();
when(provider.getEnumType(enumTypeName)).thenReturn(enumTypeProvider);
CsdlProperty propertyProvider = new CsdlProperty();
propertyProvider.setType(enumTypeName);
final EdmProperty property = new EdmPropertyImpl(edm, propertyProvider);
assertFalse(property.isCollection());
assertFalse(property.isPrimitive());
final EdmType type = property.getType();
assertEquals(EdmTypeKind.ENUM, type.getKind());
assertEquals("ns", type.getNamespace());
assertEquals("enum", type.getName());
}
开发者ID:apache,项目名称:olingo-odata4,代码行数:18,代码来源:EdmPropertyImplTest.java
示例15: parsePathSegment
import org.apache.olingo.commons.api.edm.EdmProperty; //导入依赖的package包/类
private UriResource parsePathSegment(final EdmElement property) throws UriParserException {
if (property == null
|| !(property.getType().getKind() == EdmTypeKind.COMPLEX
|| property instanceof EdmNavigationProperty)) {
// Could be a customAggregate or $count.
return null;
}
if (tokenizer.next(TokenKind.SLASH)) {
final EdmStructuredType typeCast = ParserHelper.parseTypeCast(tokenizer, edm,
(EdmStructuredType) property.getType());
if (typeCast != null) {
ParserHelper.requireNext(tokenizer, TokenKind.SLASH);
}
return property.getType().getKind() == EdmTypeKind.COMPLEX ?
new UriResourceComplexPropertyImpl((EdmProperty) property).setTypeFilter(typeCast) :
new UriResourceNavigationPropertyImpl((EdmNavigationProperty) property).setCollectionTypeFilter(typeCast);
} else {
return null;
}
}
开发者ID:apache,项目名称:olingo-odata4,代码行数:21,代码来源:ApplyParser.java
示例16: facets
import org.apache.olingo.commons.api.edm.EdmProperty; //导入依赖的package包/类
@Test
public void facets() {
EdmProviderImpl edm = new EdmProviderImpl(mock(CsdlEdmProvider.class));
CsdlProperty propertyProvider = new CsdlProperty();
propertyProvider.setType(EdmPrimitiveTypeKind.String.getFullQualifiedName());
propertyProvider.setPrecision(42);
propertyProvider.setScale(12);
propertyProvider.setMaxLength(128);
propertyProvider.setUnicode(true);
propertyProvider.setNullable(false);
propertyProvider.setDefaultValue("x");
final EdmProperty property = new EdmPropertyImpl(edm, propertyProvider);
assertTrue(property.isPrimitive());
assertNull(property.getMapping());
assertNull(property.getMimeType());
assertEquals(Integer.valueOf(42), property.getPrecision());
assertEquals(Integer.valueOf(12), property.getScale());
assertEquals(Integer.valueOf(128), property.getMaxLength());
assertTrue(property.isUnicode());
assertFalse(property.isNullable());
assertEquals("x", property.getDefaultValue());
assertNull(property.getSrid());
}
开发者ID:apache,项目名称:olingo-odata4,代码行数:24,代码来源:EdmPropertyImplTest.java
示例17: initialMappingMustBeNull
import org.apache.olingo.commons.api.edm.EdmProperty; //导入依赖的package包/类
@Test
public void initialMappingMustBeNull() {
CsdlProperty property = new CsdlProperty().setType(EdmPrimitiveTypeKind.DateTimeOffset.getFullQualifiedName());
EdmProperty edmProperty = new EdmPropertyImpl(null, property);
assertNull(edmProperty.getMapping());
CsdlParameter parameter = new CsdlParameter().setType(EdmPrimitiveTypeKind.DateTimeOffset.getFullQualifiedName());
EdmParameter edmParameter = new EdmParameterImpl(null, parameter);
assertNull(edmParameter.getMapping());
CsdlEntitySet es = new CsdlEntitySet().setName("test");
EdmEntitySet edmES = new EdmEntitySetImpl(null, null, es);
assertNull(edmES.getMapping());
CsdlSingleton si = new CsdlSingleton().setName("test");
EdmSingleton edmSi = new EdmSingletonImpl(null, null, si);
assertNull(edmSi.getMapping());
}
开发者ID:apache,项目名称:olingo-odata4,代码行数:19,代码来源:EdmMappingTest.java
示例18: readPrimitiveValueInString
import org.apache.olingo.commons.api.edm.EdmProperty; //导入依赖的package包/类
/**
* This method returns the object which is the value of the property.
*
* @param edmProperty EdmProperty
* @param value String value
* @return Object
* @throws ODataApplicationException
*/
private String readPrimitiveValueInString(EdmProperty edmProperty, Object value) throws ODataApplicationException {
if (value == null) {
return null;
}
try {
EdmPrimitiveType edmPrimitiveType = (EdmPrimitiveType) edmProperty.getType();
return edmPrimitiveType.valueToString(value, edmProperty.isNullable(), edmProperty.getMaxLength(),
edmProperty.getPrecision(), edmProperty.getScale(),
edmProperty.isUnicode());
} catch (EdmPrimitiveTypeException e) {
throw new ODataApplicationException("Invalid value: " + value + " for property: " + edmProperty.getName(),
HttpStatusCode.INTERNAL_SERVER_ERROR.getStatusCode(),
Locale.getDefault());
}
}
开发者ID:wso2,项目名称:carbon-data,代码行数:24,代码来源:ODataAdapter.java
示例19: uriResourceComplexPropertyImpl
import org.apache.olingo.commons.api.edm.EdmProperty; //导入依赖的package包/类
@Test
public void uriResourceComplexPropertyImpl() {
EdmEntityType entityType = edm.getEntityType(EntityTypeProvider.nameETKeyNav);
EdmProperty property = (EdmProperty) entityType.getProperty("PropertyCompNav");
UriResourceComplexPropertyImpl impl = new UriResourceComplexPropertyImpl(property);
assertEquals(UriResourceKind.complexProperty, impl.getKind());
assertEquals(property, impl.getProperty());
assertEquals(property.getName(), impl.toString());
assertFalse(impl.isCollection());
assertEquals(property.getType(), impl.getType());
assertEquals(property.getType(), impl.getComplexType());
impl.getComplexType();
EdmComplexType complexTypeImplType = edm.getComplexType(ComplexTypeProvider.nameCTBasePrimCompNav);
impl.setTypeFilter(complexTypeImplType);
assertEquals(complexTypeImplType, impl.getTypeFilter());
assertEquals(complexTypeImplType, impl.getComplexTypeFilter());
impl.getComplexTypeFilter();
}
开发者ID:apache,项目名称:olingo-odata4,代码行数:22,代码来源:UriResourceImplTest.java
示例20: primitivePropertyWithMetadataFull
import org.apache.olingo.commons.api.edm.EdmProperty; //导入依赖的package包/类
@Test
public void primitivePropertyWithMetadataFull() 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(serializerFullMetadata
.primitive(metadata, (EdmPrimitiveType) edmProperty.getType(), property,
PrimitiveSerializerOptions.with()
.contextURL(ContextURL.with().entitySet(edmEntitySet)
.keyPath("32767")
.navOrPropertyPath(edmProperty.getName()).build())
.build())
.getContent());
Assert.assertEquals(
"{\"@odata.context\":\"$metadata#ESAllPrim(32767)/PropertyString\","
+ "\"@odata.metadataEtag\":\"W/\\\"metadataETag\\\"\","
+ "\"value\":\"First Resource - positive values\"}",
resultString);
}
开发者ID:apache,项目名称:olingo-odata4,代码行数:23,代码来源:ODataJsonSerializerTest.java
注:本文中的org.apache.olingo.commons.api.edm.EdmProperty类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论