本文整理汇总了Java中org.apache.olingo.commons.api.data.Property类的典型用法代码示例。如果您正苦于以下问题:Java Property类的具体用法?Java Property怎么用?Java Property使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Property类属于org.apache.olingo.commons.api.data包,在下文中一共展示了Property类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getProperties
import org.apache.olingo.commons.api.data.Property; //导入依赖的package包/类
@Override
public List<Property> getProperties() {
if (proxy.properties == null) {
proxy.properties = new ArrayList<>();
proxy.propertyAccessors = new HashMap<>();
for (Field f : getAccessibleFields()) {
ODataProperty annotation = f.getAnnotation(ODataProperty.class);
if (annotation != null) {
String name = annotation.name();
RealAccessors<JpaOlingoEntity> accessors = new RealAccessors<>(this, f);
proxy.properties.add(new Property(null, name, annotation.valueType(), accessors.get(this)));
proxy.propertyAccessors.put(name, accessors);
}
}
}
return proxy.properties;
}
开发者ID:mat3e,项目名称:olingo-jpa,代码行数:18,代码来源:JpaOlingoEntity.java
示例2: setFromEntity
import org.apache.olingo.commons.api.data.Property; //导入依赖的package包/类
protected void setFromEntity(Entity entity, boolean overrideWithNull) {
List<Property> sourceProperties = entity.getProperties();
if (proxy.properties == null || proxy.propertyAccessors == null) {
getProperties();
}
if (overrideWithNull) {
proxy.properties.forEach(prop -> {
if (!sourceProperties.contains(prop)) {
proxy.propertyAccessors.get(prop.getName()).set(this, null);
}
});
}
sourceProperties.forEach(prop -> proxy.propertyAccessors.get(prop.getName()).set(this, prop.getValue()));
// we need new values in the cache after the next call
proxy.properties = null;
}
开发者ID:mat3e,项目名称:olingo-jpa,代码行数:21,代码来源:JpaOlingoEntity.java
示例3: test_JpaOlingoEntity_patch_updatesAllFieldsButID
import org.apache.olingo.commons.api.data.Property; //导入依赖的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
示例4: writePropertyValue
import org.apache.olingo.commons.api.data.Property; //导入依赖的package包/类
private void writePropertyValue(ODataResponse response, Property property) throws ODataApplicationException {
if (property == null) {
throw new ODataApplicationException("No property found", HttpStatusCode.NOT_FOUND.getStatusCode(),
Locale.ENGLISH);
} else {
if (property.getValue() == null) {
response.setStatusCode(HttpStatusCode.NO_CONTENT.getStatusCode());
} else {
String value = String.valueOf(property.getValue());
ByteArrayInputStream serializerContent = new ByteArrayInputStream(value.getBytes());//Charset.forName("UTF-8")));
response.setContent(serializerContent);
response.setStatusCode(HttpStatusCode.OK.getStatusCode());
response.setHeader(HttpHeader.CONTENT_TYPE, ContentType.TEXT_PLAIN.toContentTypeString());
}
}
}
开发者ID:peterjohnlawrence,项目名称:com.inova8.odata2sparql.v4,代码行数:17,代码来源:SparqlPrimitiveValueProcessor.java
示例5: getId
import org.apache.olingo.commons.api.data.Property; //导入依赖的package包/类
@Override
public URI getId() {
try {
if(this.getEntityType().isOperation()){
String id=rdfEntityType.getEDMEntitySetName() + "(";
boolean first = true;
for( RdfPrimaryKey keyProperty: rdfEntityType.getPrimaryKeys())
{
if(!first)id=id+",";
Property propertyValue = this.getProperty(keyProperty.getPrimaryKeyName());
id= id + propertyValue.getName()+"='"+ propertyValue.getValue().toString().replace(RdfConstants.QNAME_SEPARATOR, RdfConstants.QNAME_SEPARATOR_ENCODED )+ "'";
first=false;
}
id=id + ")";
return new URI(id);
}else{
return new URI(rdfEntityType.getEDMEntitySetName() + "('" + subject.replace(RdfConstants.QNAME_SEPARATOR, RdfConstants.QNAME_SEPARATOR_ENCODED ) + "')");
}
} catch (URISyntaxException e) {
throw new ODataRuntimeException("Unable to create id for entity: " + rdfEntityType.getEDMEntitySetName(), e);
}
}
开发者ID:peterjohnlawrence,项目名称:com.inova8.odata2sparql.v4,代码行数:24,代码来源:SparqlEntity.java
示例6: insertValuesReplace
import org.apache.olingo.commons.api.data.Property; //导入依赖的package包/类
private String insertValuesReplace(String group, RdfEntityType entityType, Entity entry) {
String insertReplace = group;
for (Property prop : entry.getProperties()) {
if (prop.getValue() != null) {
RdfProperty property = entityType.findProperty(prop.getName());
if (property.getIsKey()) {
insertReplace = insertReplace.replaceAll("\\?" + property.getVarName() + "\\b",
"<" + prop.getValue().toString() + ">");
} else {
insertReplace = insertReplace.replaceAll("\\?" + property.getVarName() + "\\b",
"\"" + prop.getValue().toString() + "\"");
}
}
}
//Replace any unmatched variables with UNDEF
insertReplace = insertReplace.replaceAll("\\?\\S+", "UNDEF");
return insertReplace;
}
开发者ID:peterjohnlawrence,项目名称:com.inova8.odata2sparql.v4,代码行数:19,代码来源:SparqlCreateUpdateDeleteBuilder.java
示例7: generateUpdatePropertyValues
import org.apache.olingo.commons.api.data.Property; //导入依赖的package包/类
private StringBuilder generateUpdatePropertyValues(RdfEntityType entityType, String entityKey, Entity entry) {
StringBuilder updatePropertyValues = new StringBuilder("VALUES( ?" + entityType.entityTypeName + "_p){");
StringBuilder properties = new StringBuilder();
boolean first = true;
for (Property prop : entry.getProperties()) {
if (prop.getValue() != null) {
if (!first) {
properties.append(" ;\n");
} else {
first = false;
}
RdfProperty property = entityType.findProperty(prop.getName());
if (property.getIsKey()) {
entityKey = prop.getValue().toString();
} else {
updatePropertyValues.append("(<" + property.propertyNode.getIRI() + ">) ");
}
}
}
return updatePropertyValues.append("}.");
}
开发者ID:peterjohnlawrence,项目名称:com.inova8.odata2sparql.v4,代码行数:22,代码来源:SparqlCreateUpdateDeleteBuilder.java
示例8: createPropertyList
import org.apache.olingo.commons.api.data.Property; //导入依赖的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
示例9: createComplexValue
import org.apache.olingo.commons.api.data.Property; //导入依赖的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
示例10: serialize
import org.apache.olingo.commons.api.data.Property; //导入依赖的package包/类
@Override
protected SerializerResult serialize(ODataSerializer serializer,
InstanceData<EdmPrimitiveType, Property> data, ElasticEdmEntitySet entitySet,
UriInfo uriInfo) throws SerializerException {
List<UriResource> resourceParts = uriInfo.getUriResourceParts();
UriResourceProperty uriProperty = (UriResourceProperty) resourceParts
.get(resourceParts.size() - 1);
ElasticEdmProperty edmProperty = (ElasticEdmProperty) uriProperty.getProperty();
String propertyName = edmProperty.getName();
return serializer.primitive(serviceMetadata, data.getType(), data.getValue(),
PrimitiveSerializerOptions.with()
.contextURL(createContextUrl(entitySet, true, null, null, propertyName))
.scale(edmProperty.getScale()).nullable(edmProperty.isNullable())
.precision(edmProperty.getPrecision()).maxLength(edmProperty.getMaxLength())
.unicode(edmProperty.isUnicode()).build());
}
开发者ID:Hevelian,项目名称:hevelian-olastic,代码行数:17,代码来源:PrimitiveProcessorImpl.java
示例11: parse
import org.apache.olingo.commons.api.data.Property; //导入依赖的package包/类
@Override
public InstanceData<EdmPrimitiveType, Property> parse(SearchResponse response,
ElasticEdmEntitySet entitySet) {
ElasticEdmEntityType entityType = entitySet.getEntityType();
SearchHit firstHit = response.getHits().getAt(0);
ElasticEdmProperty edmProperty;
Property property;
Map<String, Object> source = firstHit.getSource();
if (source.isEmpty()) {
edmProperty = entityType.findPropertyByEField(ElasticConstants.ID_FIELD_NAME);
property = createProperty(edmProperty.getName(), firstHit.getId(), entityType);
} else {
Entry<String, Object> entry = source.entrySet().iterator().next();
edmProperty = entityType.findPropertyByEField(entry.getKey());
property = createProperty(edmProperty.getName(), entry.getValue(), entityType);
}
return new InstanceData<>((EdmPrimitiveType) edmProperty.getType(), property);
}
开发者ID:Hevelian,项目名称:hevelian-olastic,代码行数:21,代码来源:PrimitiveParser.java
示例12: writeProperties
import org.apache.olingo.commons.api.data.Property; //导入依赖的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
示例13: writePrimitive
import org.apache.olingo.commons.api.data.Property; //导入依赖的package包/类
/**
* Writes primitive property into json.
*
* @param type
* the EDM type
* @param property
* property instance
* @param options
* options for the serializer
* @param json
* json generator
* @throws EdmPrimitiveTypeException
* if any error occurred
* @throws IOException
* if any error occurred
* @throws SerializerException
* if any error occurred
*/
private void writePrimitive(EdmPrimitiveType type, Property property,
PrimitiveSerializerOptions options, JsonGenerator json)
throws EdmPrimitiveTypeException, IOException, SerializerException {
Boolean isNullable = options == null ? null : options.isNullable();
Integer maxLength = options == null ? null : options.getMaxLength();
Integer precision = options == null ? null : options.getPrecision();
Integer scale = options == null ? null : options.getScale();
Boolean isUnicode = options == null ? null : options.isUnicode();
if (property.isPrimitive()) {
writePrimitiveValue(property.getName(), type, property.asPrimitive(), isNullable,
maxLength, precision, scale, isUnicode, json);
} else if (property.isGeospatial()) {
throw new SerializerException("Property type not yet supported!",
SerializerException.MessageKeys.UNSUPPORTED_PROPERTY_TYPE, property.getName());
} else if (property.isEnum()) {
writePrimitiveValue(property.getName(), type, property.asEnum(), isNullable, maxLength,
precision, scale, isUnicode, json);
} else {
throw new SerializerException("Inconsistent property type!",
SerializerException.MessageKeys.INCONSISTENT_PROPERTY_TYPE, property.getName());
}
}
开发者ID:Hevelian,项目名称:hevelian-olastic,代码行数:41,代码来源:ElasticODataJsonSerializer.java
示例14: writeProperties
import org.apache.olingo.commons.api.data.Property; //导入依赖的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
示例15: createProperty_DateFieldsAndNullValue_PropertyWithNullValueCreated
import org.apache.olingo.commons.api.data.Property; //导入依赖的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
示例16: createProperty_DateTimeOffsetFieldAndDateAsString_PropertyWithCalendarCreated
import org.apache.olingo.commons.api.data.Property; //导入依赖的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
示例17: createProperty_DateFieldAndDateAsString_PropertyWithCalendarCreated
import org.apache.olingo.commons.api.data.Property; //导入依赖的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
示例18: createProperty_DateTimeOffsetFieldAndDateAsTimestamp_PropertyWithCalendarCreated
import org.apache.olingo.commons.api.data.Property; //导入依赖的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
示例19: createProperty_DateTimeFieldAndDateAsTimestamp_PropertyWithCalendarCreated
import org.apache.olingo.commons.api.data.Property; //导入依赖的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
示例20: validatePropertyValue
import org.apache.olingo.commons.api.data.Property; //导入依赖的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
注:本文中的org.apache.olingo.commons.api.data.Property类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论