本文整理汇总了Java中org.apache.olingo.commons.api.data.ValueType类的典型用法代码示例。如果您正苦于以下问题:Java ValueType类的具体用法?Java ValueType怎么用?Java ValueType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ValueType类属于org.apache.olingo.commons.api.data包,在下文中一共展示了ValueType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
示例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);
}
示例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;
}
示例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());
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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.");
}
示例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);
}
}
示例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);
}
示例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);
}
示例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());
}
示例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());
}
示例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));
}