本文整理汇总了Java中org.apache.olingo.commons.api.data.ValueType类的典型用法代码示例。如果您正苦于以下问题:Java ValueType类的具体用法?Java ValueType怎么用?Java ValueType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ValueType类属于org.apache.olingo.commons.api.data包,在下文中一共展示了ValueType类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: test_JpaOlingoEntity_patch_updatesAllFieldsButID
import org.apache.olingo.commons.api.data.ValueType; //导入依赖的package包/类
@Test
public void test_JpaOlingoEntity_patch_updatesAllFieldsButID() {
// GIVEN
final String NEW_NAME = "NewName";
Entity entityToSet = new Entity().addProperty(new Property(null, NAME_FIELD, ValueType.PRIMITIVE, NEW_NAME))
.addProperty(new Property(null, ID_FIELD, ValueType.PRIMITIVE, "WRONG!!111"));
TestEntity SUT = new TestEntity();
// WHEN
SUT.patch(entityToSet);
// THEN
assertThat(SUT.getName()).isEqualTo(NEW_NAME);
assertThat(SUT.getID()).isEqualTo(ID_VALUE);
}
开发者ID:mat3e,项目名称:olingo-jpa,代码行数:19,代码来源:JpaOlingoEntityTest.java
示例2: createPropertyList
import org.apache.olingo.commons.api.data.ValueType; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private Property createPropertyList(String name, List<Object> valueObject,
EdmStructuredType structuredType) {
ValueType valueType;
EdmElement property = structuredType.getProperty(name);
EdmTypeKind propertyKind = property.getType().getKind();
if (propertyKind == EdmTypeKind.COMPLEX) {
valueType = ValueType.COLLECTION_COMPLEX;
} else {
valueType = ValueType.COLLECTION_PRIMITIVE;
}
List<Object> properties = new ArrayList<>();
for (Object value : valueObject) {
if (value instanceof Map) {
properties.add(createComplexValue((Map<String, Object>) value, property));
} else {
properties.add(value);
}
}
return new Property(null, name, valueType, properties);
}
开发者ID:Hevelian,项目名称:hevelian-olastic,代码行数:22,代码来源:PropertyCreator.java
示例3: createComplexValue
import org.apache.olingo.commons.api.data.ValueType; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private ComplexValue createComplexValue(Map<String, Object> complexObject,
EdmElement edmElement) {
ComplexValue complexValue = new ComplexValue();
for (Map.Entry<String, Object> entry : complexObject.entrySet()) {
Object value = entry.getValue();
if (value instanceof List) {
ElasticEdmComplexType complexType = (ElasticEdmComplexType) edmElement.getType();
EdmElement complexProperty = complexType.getProperty(entry.getKey());
complexProperty = complexProperty == null
? complexType.getPropertyByNestedName(entry.getKey()) : complexProperty;
complexValue.getValue().add(createPropertyList(complexProperty.getName(),
(List<Object>) value, complexType));
} else {
complexValue.getValue().add(
new Property(null, entry.getKey(), ValueType.PRIMITIVE, entry.getValue()));
}
}
return complexValue;
}
开发者ID:Hevelian,项目名称:hevelian-olastic,代码行数:21,代码来源:PropertyCreator.java
示例4: createProperty_DateFieldsAndNullValue_PropertyWithNullValueCreated
import org.apache.olingo.commons.api.data.ValueType; //导入依赖的package包/类
@Test
public void createProperty_DateFieldsAndNullValue_PropertyWithNullValueCreated() {
doReturn(getTypedProperty(EdmDateTimeOffset.getInstance())).when(entityType)
.getProperty(DATE_OF_BIRTH_PROPERTY);
Property property = creator.createProperty(DATE_OF_BIRTH_PROPERTY, null, entityType);
assertEquals(DATE_OF_BIRTH_PROPERTY, property.getName());
assertEquals(ValueType.PRIMITIVE, property.getValueType());
assertNull(property.getValue());
doReturn(getTypedProperty(EdmDate.getInstance())).when(entityType)
.getProperty(DATE_OF_BIRTH_PROPERTY);
property = creator.createProperty(DATE_OF_BIRTH_PROPERTY, null, entityType);
assertEquals(DATE_OF_BIRTH_PROPERTY, property.getName());
assertEquals(ValueType.PRIMITIVE, property.getValueType());
assertNull(property.getValue());
}
开发者ID:Hevelian,项目名称:hevelian-olastic,代码行数:17,代码来源:PropertyCreatorTest.java
示例5: createProperty_DateTimeOffsetFieldAndDateAsString_PropertyWithCalendarCreated
import org.apache.olingo.commons.api.data.ValueType; //导入依赖的package包/类
@Test
public void createProperty_DateTimeOffsetFieldAndDateAsString_PropertyWithCalendarCreated() {
doReturn(getTypedProperty(EdmDateTimeOffset.getInstance())).when(entityType)
.getProperty(DATE_OF_BIRTH_PROPERTY);
Property property = creator.createProperty(DATE_OF_BIRTH_PROPERTY,
"1982-05-24T10:25:15.777Z", entityType);
assertEquals(DATE_OF_BIRTH_PROPERTY, property.getName());
assertEquals(ValueType.PRIMITIVE, property.getValueType());
Object calendar = property.getValue();
assertTrue(calendar instanceof GregorianCalendar);
assertEquealsToCalendar(1982, 4, 24, 10, 25, 15, 777, (GregorianCalendar) calendar);
// Case where date less than 1582 year
property = creator.createProperty(DATE_OF_BIRTH_PROPERTY, "1420-07-09T16:55:01.102Z",
entityType);
calendar = property.getValue();
assertTrue(calendar instanceof GregorianCalendar);
assertEquealsToCalendar(1420, 6, 9, 16, 55, 1, 102, (GregorianCalendar) calendar);
}
开发者ID:Hevelian,项目名称:hevelian-olastic,代码行数:20,代码来源:PropertyCreatorTest.java
示例6: createProperty_DateFieldAndDateAsString_PropertyWithCalendarCreated
import org.apache.olingo.commons.api.data.ValueType; //导入依赖的package包/类
@Test
public void createProperty_DateFieldAndDateAsString_PropertyWithCalendarCreated() {
doReturn(getTypedProperty(EdmDate.getInstance())).when(entityType)
.getProperty(DATE_OF_BIRTH_PROPERTY);
Property property = creator.createProperty(DATE_OF_BIRTH_PROPERTY,
"1992-06-24T00:00:00.000Z", entityType);
assertEquals(DATE_OF_BIRTH_PROPERTY, property.getName());
assertEquals(ValueType.PRIMITIVE, property.getValueType());
Object calendar = property.getValue();
assertTrue(calendar instanceof GregorianCalendar);
assertEquealsToCalendar(1992, 5, 24, 0, 0, 0, 0, (GregorianCalendar) calendar);
// Case where date less than 1582 year
property = creator.createProperty(DATE_OF_BIRTH_PROPERTY, "1256-05-01T00:00:00.000Z",
entityType);
calendar = property.getValue();
assertTrue(calendar instanceof GregorianCalendar);
assertEquealsToCalendar(1256, 4, 1, 0, 0, 0, 0, (GregorianCalendar) calendar);
}
开发者ID:Hevelian,项目名称:hevelian-olastic,代码行数:20,代码来源:PropertyCreatorTest.java
示例7: createProperty_DateTimeOffsetFieldAndDateAsTimestamp_PropertyWithCalendarCreated
import org.apache.olingo.commons.api.data.ValueType; //导入依赖的package包/类
@Test
public void createProperty_DateTimeOffsetFieldAndDateAsTimestamp_PropertyWithCalendarCreated() {
doReturn(getTypedProperty(EdmDateTimeOffset.getInstance())).when(entityType)
.getProperty(DATE_OF_BIRTH_PROPERTY);
Property property = creator.createProperty(DATE_OF_BIRTH_PROPERTY, 1064231665584L,
entityType);
assertEquals(DATE_OF_BIRTH_PROPERTY, property.getName());
assertEquals(ValueType.PRIMITIVE, property.getValueType());
Object calendar = property.getValue();
assertTrue(calendar instanceof GregorianCalendar);
assertEquealsToCalendar(2003, 8, 22, 11, 54, 25, 584, (GregorianCalendar) calendar);
// Case where date less than 1582 year
property = creator.createProperty(DATE_OF_BIRTH_PROPERTY, -19064231665584L, entityType);
calendar = property.getValue();
assertTrue(calendar instanceof GregorianCalendar);
assertEquealsToCalendar(1365, 10, 17, 4, 5, 34, 416, (GregorianCalendar) calendar);
}
开发者ID:Hevelian,项目名称:hevelian-olastic,代码行数:19,代码来源:PropertyCreatorTest.java
示例8: createProperty_DateTimeFieldAndDateAsTimestamp_PropertyWithCalendarCreated
import org.apache.olingo.commons.api.data.ValueType; //导入依赖的package包/类
@Test
public void createProperty_DateTimeFieldAndDateAsTimestamp_PropertyWithCalendarCreated() {
doReturn(getTypedProperty(EdmDateTimeOffset.getInstance())).when(entityType)
.getProperty(DATE_OF_BIRTH_PROPERTY);
Property property = creator.createProperty(DATE_OF_BIRTH_PROPERTY, 683596800000L,
entityType);
assertEquals(DATE_OF_BIRTH_PROPERTY, property.getName());
assertEquals(ValueType.PRIMITIVE, property.getValueType());
Object calendar = property.getValue();
assertTrue(calendar instanceof GregorianCalendar);
assertEquealsToCalendar(1991, 7, 31, 0, 0, 0, 0, (GregorianCalendar) calendar);
// Case where date less than 1582 year
property = creator.createProperty(DATE_OF_BIRTH_PROPERTY, -27377049600000L, entityType);
calendar = property.getValue();
assertTrue(calendar instanceof GregorianCalendar);
assertEquealsToCalendar(1102, 5, 17, 0, 0, 0, 0, (GregorianCalendar) calendar);
}
开发者ID:Hevelian,项目名称:hevelian-olastic,代码行数:19,代码来源:PropertyCreatorTest.java
示例9: complexCollectionAction
import org.apache.olingo.commons.api.data.ValueType; //导入依赖的package包/类
protected static Property complexCollectionAction(final String name,
final Map<String, Parameter> parameters) throws DataProviderException {
if ("UARTCollCTTwoPrimParam".equals(name)) {
List<ComplexValue> complexCollection = new ArrayList<ComplexValue>();
complexCollection.add(createCTTwoPrimComplexProperty((short) 16, "Test123").asComplex());
complexCollection.add(createCTTwoPrimComplexProperty((short) 17, "Test456").asComplex());
complexCollection.add(createCTTwoPrimComplexProperty((short) 18, "Test678").asComplex());
Parameter paramInt16 = parameters.get("ParameterInt16");
if (paramInt16 != null) {
Short number = (Short) paramInt16.asPrimitive();
if (number < 0) {
complexCollection.clear();
} else if (number >= 0 && number < complexCollection.size()) {
complexCollection = complexCollection.subList(0, number);
}
Property complexCollProperty = new Property();
complexCollProperty.setValue(ValueType.COLLECTION_COMPLEX, complexCollection);
return complexCollProperty;
}
}
throw new DataProviderException("Action " + name + " is not yet implemented.");
}
开发者ID:RedHelixOrg,项目名称:RedHelix-1,代码行数:24,代码来源:ActionData.java
示例10: getStoredPI
import org.apache.olingo.commons.api.data.ValueType; //导入依赖的package包/类
@GET
@Path("/StoredPIs(1000)")
public Response getStoredPI(@Context final UriInfo uriInfo) {
final Entity entity = new Entity();
entity.setType("Microsoft.Test.OData.Services.ODataWCFService.StoredPI");
final Property id = new Property();
id.setType("Edm.Int32");
id.setName("StoredPIID");
id.setValue(ValueType.PRIMITIVE, 1000);
entity.getProperties().add(id);
final Link edit = new Link();
edit.setHref(uriInfo.getRequestUri().toASCIIString());
edit.setRel("edit");
edit.setTitle("StoredPI");
entity.setEditLink(edit);
final ByteArrayOutputStream content = new ByteArrayOutputStream();
final OutputStreamWriter writer = new OutputStreamWriter(content, Constants.ENCODING);
try {
jsonSerializer.write(writer, new ResWrap<Entity>((URI) null, null, entity));
return xml.createResponse(new ByteArrayInputStream(content.toByteArray()), null, Accept.JSON_FULLMETA);
} catch (Exception e) {
LOG.error("While creating StoredPI", e);
return xml.createFaultResponse(Accept.JSON_FULLMETA.toString(), e);
}
}
开发者ID:apache,项目名称:olingo-odata4,代码行数:27,代码来源:Services.java
示例11: primitiveCollectionBoundAction
import org.apache.olingo.commons.api.data.ValueType; //导入依赖的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
示例12: complexCollectionAction
import org.apache.olingo.commons.api.data.ValueType; //导入依赖的package包/类
protected static Property complexCollectionAction(final String name, final Map<String, Parameter> parameters)
throws DataProviderException {
if ("UARTCollCTTwoPrimParam".equals(name)) {
List<ComplexValue> complexCollection = new ArrayList<ComplexValue>();
final Parameter paramInt16 = parameters.get("ParameterInt16");
final Short number = paramInt16 == null || paramInt16.isNull() ? 0 : (Short) paramInt16.asPrimitive();
if (number >= 1) {
complexCollection.add(createCTTwoPrimComplexProperty(null, (short) 16, "Test123").asComplex());
}
if (number >= 2) {
complexCollection.add(createCTTwoPrimComplexProperty(null, (short) 17, "Test456").asComplex());
}
if (number >= 3) {
complexCollection.add(createCTTwoPrimComplexProperty(null, (short) 18, "Test678").asComplex());
}
return new Property(null, name, ValueType.COLLECTION_COMPLEX, complexCollection);
}
throw new DataProviderException("Action " + name + " is not yet implemented.",
HttpStatusCode.NOT_IMPLEMENTED);
}
开发者ID:apache,项目名称:olingo-odata4,代码行数:21,代码来源:ActionData.java
示例13: actionUARTCollStringTwoParam
import org.apache.olingo.commons.api.data.ValueType; //导入依赖的package包/类
@Test
public void actionUARTCollStringTwoParam() throws Exception {
Map<String, Parameter> parameters = new HashMap<String, Parameter>();
Parameter paramInt16 = new Parameter();
paramInt16.setName("ParameterInt16");
paramInt16.setValue(ValueType.PRIMITIVE, new Short((short) 3));
parameters.put("ParameterInt16", paramInt16);
Parameter paramDuration = new Parameter();
paramDuration.setName("ParameterDuration");
paramDuration.setValue(ValueType.PRIMITIVE, new BigDecimal(2));
parameters.put("ParameterDuration", paramDuration);
Property result = ActionData.primitiveCollectionAction("UARTCollStringTwoParam", parameters, oData);
assertNotNull(result);
assertEquals(3, result.asCollection().size());
}
开发者ID:apache,项目名称:olingo-odata4,代码行数:18,代码来源:ActionDataProviderTest.java
示例14: actionUARTCTTwoPrimParam
import org.apache.olingo.commons.api.data.ValueType; //导入依赖的package包/类
@Test
public void actionUARTCTTwoPrimParam() throws Exception {
Parameter paramInt16 = new Parameter();
paramInt16.setName("ParameterInt16");
paramInt16.setValue(ValueType.PRIMITIVE, new Short((short) 3));
final Map<String, Parameter> parameters = Collections.singletonMap("ParameterInt16", paramInt16);
Property result = ActionData.complexAction("UARTCTTwoPrimParam", parameters);
assertNotNull(result);
ComplexValue value = result.asComplex();
assertEquals((short) 3, value.getValue().get(0).asPrimitive());
result = ActionData.complexAction("UARTCTTwoPrimParam", Collections.<String, Parameter> emptyMap());
assertNotNull(result);
value = result.asComplex();
assertEquals((short) 32767, value.getValue().get(0).asPrimitive());
}
开发者ID:apache,项目名称:olingo-odata4,代码行数:18,代码来源:ActionDataProviderTest.java
示例15: entityCollectionIEEE754Compatible
import org.apache.olingo.commons.api.data.ValueType; //导入依赖的package包/类
@Test
public void entityCollectionIEEE754Compatible() throws Exception {
EntityCollection entityCollection = new EntityCollection();
entityCollection.getEntities().add(new Entity()
.addProperty(new Property(null, "Property1", ValueType.PRIMITIVE, Long.MIN_VALUE))
.addProperty(new Property(null, "Property2", ValueType.PRIMITIVE, BigDecimal.valueOf(Long.MAX_VALUE, 10)))
.addProperty(new Property("Edm.Byte", "Property3", ValueType.PRIMITIVE, 20)));
entityCollection.setCount(3);
Assert.assertEquals(
"{\"@odata.context\":\"$metadata#EntitySet(Property1,Property2,Property3)\","
+ "\"@odata.count\":\"3\","
+ "\"value\":[{\"@odata.id\":null,"
+ "\"[email protected]\":\"#Int64\",\"Property1\":\"-9223372036854775808\","
+ "\"[email protected]\":\"#Decimal\",\"Property2\":\"922337203.6854775807\","
+ "\"[email protected]\":\"#Byte\",\"Property3\":20}]}",
serialize(
oData.createEdmAssistedSerializer(
ContentType.create(ContentType.JSON, ContentType.PARAMETER_IEEE754_COMPATIBLE, "true")),
metadata, null, entityCollection, null));
}
开发者ID:apache,项目名称:olingo-odata4,代码行数:21,代码来源:EdmAssistedJsonSerializerTest.java
示例16: entityCollectionWithComplexProperty
import org.apache.olingo.commons.api.data.ValueType; //导入依赖的package包/类
@Test
public void entityCollectionWithComplexProperty() throws Exception {
Entity entity = new Entity();
entity.setId(null);
entity.addProperty(new Property(null, "Property1", ValueType.PRIMITIVE, 1L));
ComplexValue complexValue = new ComplexValue();
complexValue.getValue().add(new Property(null, "Inner1", ValueType.PRIMITIVE,
BigDecimal.TEN.scaleByPowerOfTen(-5)));
Calendar time = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
time.clear();
time.set(Calendar.HOUR_OF_DAY, 13);
time.set(Calendar.SECOND, 59);
time.set(Calendar.MILLISECOND, 999);
complexValue.getValue().add(new Property("Edm.TimeOfDay", "Inner2", ValueType.PRIMITIVE, time));
entity.addProperty(new Property("Namespace.ComplexType", "Property2", ValueType.COMPLEX, complexValue));
EntityCollection entityCollection = new EntityCollection();
entityCollection.getEntities().add(entity);
Assert.assertEquals("{\"@odata.context\":\"$metadata#EntitySet(Property1,Property2)\","
+ "\"value\":[{\"@odata.id\":null,"
+ "\"[email protected]\":\"#Int64\",\"Property1\":1,"
+ "\"Property2\":{\"@odata.type\":\"#Namespace.ComplexType\","
+ "\"[email protected]\":\"#Decimal\",\"Inner1\":0.00010,"
+ "\"[email protected]\":\"#TimeOfDay\",\"Inner2\":\"13:00:59.999\"}}]}",
serialize(serializer, metadata, null, entityCollection, null));
}
开发者ID:apache,项目名称:olingo-odata4,代码行数:26,代码来源:EdmAssistedJsonSerializerTest.java
示例17: entityCollectionWithComplexCollection
import org.apache.olingo.commons.api.data.ValueType; //导入依赖的package包/类
@Test
public void entityCollectionWithComplexCollection() throws Exception {
final EdmEntitySet entitySet = entityContainer.getEntitySet("ESMixPrimCollComp");
ComplexValue complexValue1 = new ComplexValue();
complexValue1.getValue().add(new Property(null, "PropertyInt16", ValueType.PRIMITIVE, 1));
complexValue1.getValue().add(new Property(null, "PropertyString", ValueType.PRIMITIVE, "one"));
ComplexValue complexValue2 = new ComplexValue();
complexValue2.getValue().add(new Property(null, "PropertyInt16", ValueType.PRIMITIVE, 2));
complexValue2.getValue().add(new Property(null, "PropertyString", ValueType.PRIMITIVE, "two"));
ComplexValue complexValue3 = new ComplexValue();
complexValue3.getValue().add(new Property(null, "PropertyInt16", ValueType.PRIMITIVE, 3));
complexValue3.getValue().add(new Property(null, "PropertyString", ValueType.PRIMITIVE, "three"));
EntityCollection entityCollection = new EntityCollection();
entityCollection.getEntities().add(new Entity()
.addProperty(new Property(null, "CollPropertyComp", ValueType.COLLECTION_COMPLEX,
Arrays.asList(complexValue1, complexValue2, complexValue3))));
Assert.assertEquals("{\"@odata.context\":\"$metadata#ESMixPrimCollComp(CollPropertyComp)\","
+ "\"value\":[{\"@odata.id\":null,"
+ "\"CollPropertyComp\":["
+ "{\"PropertyInt16\":1,\"PropertyString\":\"one\"},"
+ "{\"PropertyInt16\":2,\"PropertyString\":\"two\"},"
+ "{\"PropertyInt16\":3,\"PropertyString\":\"three\"}]}]}",
serialize(serializer, metadata, entitySet, entityCollection, "CollPropertyComp"));
}
开发者ID:apache,项目名称:olingo-odata4,代码行数:25,代码来源:EdmAssistedJsonSerializerTest.java
示例18: expand
import org.apache.olingo.commons.api.data.ValueType; //导入依赖的package包/类
@Test
public void expand() throws Exception {
final Entity relatedEntity1 = new Entity().addProperty(new Property(null, "Related1", ValueType.PRIMITIVE, 1.5));
final Entity relatedEntity2 = new Entity().addProperty(new Property(null, "Related1", ValueType.PRIMITIVE, 2.75));
EntityCollection target = new EntityCollection();
target.getEntities().add(relatedEntity1);
target.getEntities().add(relatedEntity2);
Link link = new Link();
link.setTitle("NavigationProperty");
link.setInlineEntitySet(target);
Entity entity = new Entity();
entity.setId(null);
entity.addProperty(new Property(null, "Property1", ValueType.PRIMITIVE, (short) 1));
entity.getNavigationLinks().add(link);
EntityCollection entityCollection = new EntityCollection();
entityCollection.getEntities().add(entity);
Assert.assertEquals("{\"@odata.context\":\"$metadata#EntitySet(Property1,NavigationProperty(Related1))\","
+ "\"value\":[{\"@odata.id\":null,"
+ "\"[email protected]\":\"#Int16\",\"Property1\":1,"
+ "\"NavigationProperty\":["
+ "{\"@odata.id\":null,\"[email protected]\":\"#Double\",\"Related1\":1.5},"
+ "{\"@odata.id\":null,\"[email protected]\":\"#Double\",\"Related1\":2.75}]}]}",
serialize(serializer, metadata, null, entityCollection, "Property1,NavigationProperty(Related1)"));
}
开发者ID:apache,项目名称:olingo-odata4,代码行数:25,代码来源:EdmAssistedJsonSerializerTest.java
示例19: expandWithEdm
import org.apache.olingo.commons.api.data.ValueType; //导入依赖的package包/类
@Test
public void expandWithEdm() throws Exception {
final EdmEntitySet entitySet = entityContainer.getEntitySet("ESTwoPrim");
Entity entity = new Entity()
.addProperty(new Property(null, "PropertyInt16", ValueType.PRIMITIVE, (short) 42))
.addProperty(new Property(null, "PropertyString", ValueType.PRIMITIVE, "test"));
final Entity target = new Entity()
.addProperty(new Property(null, "PropertyInt16", ValueType.PRIMITIVE, (short) 2))
.addProperty(new Property(null, "PropertyByte", ValueType.PRIMITIVE, 3L));
Link link = new Link();
link.setTitle("NavPropertyETAllPrimOne");
link.setInlineEntity(target);
entity.getNavigationLinks().add(link);
EntityCollection entityCollection = new EntityCollection();
entityCollection.getEntities().add(entity);
Assert.assertEquals("{\"@odata.context\":\"$metadata#ESTwoPrim\",\"value\":[{\"@odata.id\":null,"
+ "\"PropertyInt16\":42,\"PropertyString\":\"test\","
+ "\"NavPropertyETAllPrimOne\":{\"@odata.id\":null,\"PropertyInt16\":2,\"PropertyByte\":3}}]}",
serialize(serializer, metadata, entitySet, entityCollection, null));
}
开发者ID:apache,项目名称:olingo-odata4,代码行数:21,代码来源:EdmAssistedJsonSerializerTest.java
示例20: createProduct
import org.apache.olingo.commons.api.data.ValueType; //导入依赖的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
注:本文中的org.apache.olingo.commons.api.data.ValueType类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论