当前位置: 首页>>代码示例>>Java>>正文


Java Entity.getProperties方法代码示例

本文整理汇总了Java中org.apache.olingo.commons.api.data.Entity.getProperties方法的典型用法代码示例。如果您正苦于以下问题:Java Entity.getProperties方法的具体用法?Java Entity.getProperties怎么用?Java Entity.getProperties使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.olingo.commons.api.data.Entity的用法示例。


在下文中一共展示了Entity.getProperties方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setFromEntity

import org.apache.olingo.commons.api.data.Entity; //导入方法依赖的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

示例2: insertValuesReplace

import org.apache.olingo.commons.api.data.Entity; //导入方法依赖的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

示例3: generateUpdatePropertyValues

import org.apache.olingo.commons.api.data.Entity; //导入方法依赖的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

示例4: derivedEntityETTwoPrim

import org.apache.olingo.commons.api.data.Entity; //导入方法依赖的package包/类
@Test
public void derivedEntityETTwoPrim() throws Exception {
  String entityString =
      "{\"@odata.type\":\"#olingo.odata.test1.ETBase\","+
          "\"PropertyInt16\":32767," +
          "\"PropertyString\":\"First Resource - positive values\"," +
          "\"AdditionalPropertyString_5\":\"Additional\"}";
  final Entity entity = deserialize(entityString, "ETTwoPrim");
  assertNotNull(entity);
  assertEquals("olingo.odata.test1.ETBase", entity.getType());
  List<Property> properties = entity.getProperties();
  assertNotNull(properties);
  assertEquals(3, properties.size());
  assertEquals(new Short((short) 32767), entity.getProperty("PropertyInt16").getValue());
  assertEquals("First Resource - positive values", entity.getProperty("PropertyString").getValue());
  assertNotNull(entity.getProperty("AdditionalPropertyString_5").getValue());
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:18,代码来源:ODataJsonDeserializerEntityTest.java

示例5: cloneEntityCollection

import org.apache.olingo.commons.api.data.Entity; //导入方法依赖的package包/类
private List<Entity> cloneEntityCollection(final List<Entity> entities) {
  final List<Entity> clonedEntities = new ArrayList<Entity>();
  
  for(final Entity entity : entities) {
    final Entity clonedEntity = new Entity();
    
    clonedEntity.setId(entity.getId());
    for(final Property property : entity.getProperties()) {
      clonedEntity.addProperty(new Property(property.getType(), 
                                            property.getName(), 
                                            property.getValueType(), 
                                            property.getValue()));
    }
     
    clonedEntities.add(clonedEntity);
  }
  
  return clonedEntities;
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:20,代码来源:Storage.java

示例6: odataControlInformationIsIgnoredForRequests

import org.apache.olingo.commons.api.data.Entity; //导入方法依赖的package包/类
@Test
public void odataControlInformationIsIgnoredForRequests() throws Exception {
  String entityString =
      "{"
          + "\"@odata.context\":\"http://localhost:8080\","
          + "\"@odata.metadataEtag\":\"metadataEtag\","
          + "\"@odata.id\":\"value\","
          + "\"@odata.editLink\":\"value\","
          + "\"@odata.readLink\":\"value\","
          + "\"@odata.etag\":\"value\","
          + "\"@odata.mediaEtag\":\"value\","
          + "\"@odata.mediaReadLink\":\"value\","
          + "\"@odata.mediaEditLink\":\"value\","
          + "\"PropertyInt16\":32767,"
          + "\"PropertyString\":\"First Resource - positive values\""
          + "}";
  final Entity entity = deserialize(entityString, "ETAllPrim");
  assertNotNull(entity);
  List<Property> properties = entity.getProperties();
  assertNotNull(properties);
  assertEquals(2, properties.size());
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:23,代码来源:ODataJsonDeserializerEntityTest.java

示例7: emptyEntity

import org.apache.olingo.commons.api.data.Entity; //导入方法依赖的package包/类
@Test
public void emptyEntity() throws Exception {
  final String entityString = "{}";
  final Entity entity = deserialize(entityString, "ETAllPrim");
  assertNotNull(entity);
  List<Property> properties = entity.getProperties();
  assertNotNull(properties);
  assertEquals(0, properties.size());
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:10,代码来源:ODataJsonDeserializerEntityTest.java

示例8: simpleEntityETAllPrimNoTAllPropertiesPresent

import org.apache.olingo.commons.api.data.Entity; //导入方法依赖的package包/类
@Test
public void simpleEntityETAllPrimNoTAllPropertiesPresent() throws Exception {
  String entityString =
      "{\"PropertyInt16\":32767," +
          "\"PropertyString\":\"First Resource - positive values\"" +
          "}";
  final Entity entity = deserialize(entityString, "ETAllPrim");
  assertNotNull(entity);
  List<Property> properties = entity.getProperties();
  assertNotNull(properties);
  assertEquals(2, properties.size());
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:13,代码来源:ODataJsonDeserializerEntityTest.java

示例9: simpleEntityETCompAllPrim

import org.apache.olingo.commons.api.data.Entity; //导入方法依赖的package包/类
@Test
public void simpleEntityETCompAllPrim() throws Exception {
  String entityString = "{\"PropertyInt16\":32767," +
      "\"PropertyComp\":{" +
      "\"PropertyString\":\"First Resource - first\"," +
      "\"PropertyBinary\":\"ASNFZ4mrze8=\"," +
      "\"PropertyBoolean\":true," +
      "\"PropertyByte\":255," +
      "\"PropertyDate\":\"2012-10-03\"," +
      "\"PropertyDateTimeOffset\":\"2012-10-03T07:16:23.1234567Z\"," +
      "\"PropertyDecimal\":34.27," +
      "\"PropertySingle\":1.79E20," +
      "\"PropertyDouble\":-1.79E19," +
      "\"PropertyDuration\":\"PT6S\"," +
      "\"PropertyGuid\":\"01234567-89ab-cdef-0123-456789abcdef\"," +
      "\"PropertyInt16\":32767," +
      "\"PropertyInt32\":2147483647," +
      "\"PropertyInt64\":9223372036854775807," +
      "\"PropertySByte\":127," +
      "\"PropertyTimeOfDay\":\"01:00:01\"}}";
  final Entity entity = deserialize(entityString, "ETCompAllPrim");
  assertNotNull(entity);
  List<Property> properties = entity.getProperties();
  assertNotNull(properties);
  assertEquals(2, properties.size());

  assertEquals(new Short((short) 32767), entity.getProperty("PropertyInt16").getValue());

  assertNotNull(entity.getProperty("PropertyComp"));
  assertNotNull(entity.getProperty("PropertyComp") instanceof List);
  List<Property> complexProperties = entity.getProperty("PropertyComp").asComplex().getValue();
  assertEquals(16, complexProperties.size());
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:34,代码来源:ODataJsonDeserializerEntityTest.java

示例10: simpleEntityETMixPrimCollComp

import org.apache.olingo.commons.api.data.Entity; //导入方法依赖的package包/类
@Test
public void simpleEntityETMixPrimCollComp() throws Exception {
  final String entityString = "{"
      + "\"PropertyInt16\":32767,"
      + "\"CollPropertyString\":"
      + "[\"[email protected]\",\"[email protected]\",\"[email protected]\"],"
      + "\"PropertyComp\":{\"PropertyInt16\":111,\"PropertyString\":\"TEST A\"},"
      + "\"CollPropertyComp\":["
      + "{\"PropertyInt16\":123,\"PropertyString\":\"TEST 1\"},"
      + "{\"PropertyInt16\":456,\"PropertyString\":\"TEST 2\"},"
      + "{\"PropertyInt16\":789,\"PropertyString\":\"TEST 3\"}]}";
  final Entity entity = deserialize(entityString, "ETMixPrimCollComp");
  assertNotNull(entity);
  List<Property> properties = entity.getProperties();
  assertNotNull(properties);
  assertEquals(4, properties.size());

  Property property = entity.getProperty("CollPropertyComp");
  assertEquals(ValueType.COLLECTION_COMPLEX, property.getValueType());

  assertTrue(property.getValue() instanceof List);
  List<? extends Object> asCollection = property.asCollection();
  assertEquals(3, asCollection.size());

  for (Object arrayElement : asCollection) {
    assertTrue(arrayElement instanceof ComplexValue);
    List<Property> castedArrayElement = ((ComplexValue) arrayElement).getValue();
    assertEquals(2, castedArrayElement.size());
  }
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:31,代码来源:ODataJsonDeserializerEntityTest.java

示例11: deriveEntityETMixPrimCollComp

import org.apache.olingo.commons.api.data.Entity; //导入方法依赖的package包/类
@Test
public void deriveEntityETMixPrimCollComp() throws Exception {
  final String entityString = "{"
      + "\"PropertyInt16\":32767,"
      + "\"CollPropertyString\":"
      + "[\"[email protected]\",\"[email protected]\",\"[email protected]\"],"
      + "\"PropertyComp\":{\"@odata.type\": \"#olingo.odata.test1.CTBase\","
      + "\"PropertyInt16\":111,\"PropertyString\":\"TEST A\",\"AdditionalPropString\":\"Additional\"},"
      + "\"CollPropertyComp\":["
      + "{\"@odata.type\": \"#olingo.odata.test1.CTBase\",\n"
      + "\"PropertyInt16\":123,\"PropertyString\":\"TEST 1\",\"AdditionalPropString\":\"Additional\"},"
      + "{\"PropertyInt16\":456,\"PropertyString\":\"TEST 2\"},"
      + "{\"PropertyInt16\":789,\"PropertyString\":\"TEST 3\"}]}";
  final Entity entity = deserialize(entityString, "ETMixPrimCollComp");
  assertNotNull(entity);
  List<Property> properties = entity.getProperties();
  assertNotNull(properties);
  assertEquals(4, properties.size());
  Property prop = entity.getProperty("PropertyComp");
  ComplexValue asComp = prop.asComplex();
  assertEquals(3,asComp.getValue().size());
  assertEquals("olingo.odata.test1.CTBase",prop.getType());
  Property property = entity.getProperty("CollPropertyComp");
  assertEquals(ValueType.COLLECTION_COMPLEX, property.getValueType());

  assertTrue(property.getValue() instanceof List);
  List<? extends Object> asCollection = property.asCollection();
  assertEquals(3, asCollection.size());
  assertEquals(3,((ComplexValue)asCollection.get(0)).getValue().size());
  assertEquals(2,((ComplexValue)asCollection.get(1)).getValue().size());
  assertEquals(2,((ComplexValue)asCollection.get(2)).getValue().size());
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:33,代码来源:ODataJsonDeserializerEntityTest.java

示例12: deriveEntityESAllPrimDeepInsert

import org.apache.olingo.commons.api.data.Entity; //导入方法依赖的package包/类
@Test
public void deriveEntityESAllPrimDeepInsert() throws Exception {
  final String entityString =  "{\"PropertyInt16\": 32767,"
      + "\"PropertyString\": \"First Resource - positive values\","
      + "\"PropertyBoolean\": true,"
      + "\"PropertyByte\": 255,"
      + "\"PropertySByte\": 127,"
      + "\"PropertyInt32\": 2147483647,"
      + "\"PropertyInt64\": 9223372036854775807,"
      + "\"PropertyDecimal\": 34,"
      + "\"PropertyBinary\": \"ASNFZ4mrze8=\","
      + "\"PropertyDate\": \"2012-12-03\","
      + "\"PropertyDateTimeOffset\": \"2012-12-03T07:16:23Z\","
      + "\"PropertyDuration\": \"PT6S\","
      + "\"PropertyGuid\": \"01234567-89ab-cdef-0123-456789abcdef\","
      + "\"PropertyTimeOfDay\": \"03:26:05\","
      + "\"NavPropertyETTwoPrimMany\": [{\"@odata.type\": \"#olingo.odata.test1.ETBase\","
      + "\"PropertyInt16\": -365,\"PropertyString\": \"Test String2\","
      + "\"AdditionalPropertyString_5\": \"Test String2\"},"
      + "{\"PropertyInt16\": -365,\"PropertyString\": \"Test String2\"}],"
      + "\"NavPropertyETTwoPrimOne\":"
      + "{\"@odata.type\": \"#olingo.odata.test1.ETBase\",\"PropertyInt16\": 32767,"
      + "\"PropertyString\": \"Test String4\","
      + "\"AdditionalPropertyString_5\": \"Test String2\"}}";
  final Entity entity = deserialize(entityString, "ETAllPrim");
  assertNotNull(entity);
  List<Property> properties = entity.getProperties();
  assertNotNull(properties);
  assertEquals(14, properties.size());
  List<Link> navProperties = entity.getNavigationLinks();
  assertNotNull(navProperties);
  assertEquals(2, navProperties.size());
  assertNotNull(navProperties.get(1).getInlineEntitySet()
      .getEntities().get(0).getProperty("AdditionalPropertyString_5"));
  assertNotNull(navProperties.get(0).getInlineEntity().getProperty("AdditionalPropertyString_5"));
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:37,代码来源:ODataJsonDeserializerEntityTest.java

示例13: eTMixPrimCollCompMissingPropertyInComplexType

import org.apache.olingo.commons.api.data.Entity; //导入方法依赖的package包/类
@Test
public void eTMixPrimCollCompMissingPropertyInComplexType() throws Exception {
  final String entityString = "{"
      + "\"PropertyComp\":{\"PropertyInt16\":111},"
      + "\"CollPropertyComp\":["
      + "{\"PropertyInt16\":123},"
      + "{\"PropertyInt16\":456},"
      + "{\"PropertyInt16\":789}]}";
  final Entity entity = deserialize(entityString, "ETMixPrimCollComp");
  assertNotNull(entity);
  List<Property> properties = entity.getProperties();
  assertNotNull(properties);
  assertEquals(2, properties.size());

  Property complexProperty = entity.getProperty("PropertyComp");
  assertEquals(ValueType.COMPLEX, complexProperty.getValueType());
  List<Property> complexPropertyValues = complexProperty.asComplex().getValue();
  assertEquals(1, complexPropertyValues.size());

  Property property = entity.getProperty("CollPropertyComp");
  assertEquals(ValueType.COLLECTION_COMPLEX, property.getValueType());

  assertTrue(property.getValue() instanceof List);
  List<? extends Object> asCollection = property.asCollection();
  assertEquals(3, asCollection.size());

  for (Object arrayElement : asCollection) {
    assertTrue(arrayElement instanceof ComplexValue);
    List<Property> castedArrayElement = ((ComplexValue) arrayElement).getValue();
    assertEquals(1, castedArrayElement.size());
  }
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:33,代码来源:ODataJsonDeserializerEntityTest.java

示例14: mappingTest

import org.apache.olingo.commons.api.data.Entity; //导入方法依赖的package包/类
@Test
public void mappingTest() throws Exception {
  EdmEntityType entityType = mock(EdmEntityType.class);
  when(entityType.getFullQualifiedName()).thenReturn(new FullQualifiedName("namespace", "name"));
  List<String> propertyNames = new ArrayList<String>();
  propertyNames.add("PropertyDate");
  propertyNames.add("PropertyDateTimeOffset");
  when(entityType.getPropertyNames()).thenReturn(propertyNames);
  CsdlMapping mapping = new CsdlMapping().setMappedJavaClass(Date.class);

  EdmProperty propertyDate = mock(EdmProperty.class);
  when(propertyDate.getName()).thenReturn("PropertyDate");
  when(propertyDate.getMapping()).thenReturn(mapping);
  when(propertyDate.getType()).thenReturn(odata.createPrimitiveTypeInstance(EdmPrimitiveTypeKind.Date));
  when(entityType.getProperty("PropertyDate")).thenReturn(propertyDate);

  EdmProperty propertyDateTimeOffset = mock(EdmProperty.class);
  when(propertyDateTimeOffset.getName()).thenReturn("PropertyDateTimeOffset");
  when(propertyDateTimeOffset.getMapping()).thenReturn(mapping);
  when(propertyDateTimeOffset.getType()).thenReturn(
      odata.createPrimitiveTypeInstance(EdmPrimitiveTypeKind.DateTimeOffset));
  when(entityType.getProperty("PropertyDateTimeOffset")).thenReturn(propertyDateTimeOffset);

  String entityString =
      "{\"PropertyDate\":\"2012-12-03\","
          + "\"PropertyDateTimeOffset\":\"2012-12-03T07:16:23Z\"}";
  InputStream stream = new ByteArrayInputStream(entityString.getBytes());
  ODataDeserializer deserializer = odata.createDeserializer(ContentType.JSON, metadata);
  Entity entity = deserializer.entity(stream, entityType).getEntity();
  assertNotNull(entity);
  List<Property> properties = entity.getProperties();
  assertNotNull(properties);
  assertEquals(2, properties.size());

  assertNotNull(entity.getProperty("PropertyDate").getValue());
  assertEquals(Date.class, entity.getProperty("PropertyDate").getValue().getClass());
  assertNotNull(entity.getProperty("PropertyDateTimeOffset").getValue());
  assertEquals(Date.class, entity.getProperty("PropertyDateTimeOffset").getValue().getClass());
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:40,代码来源:ODataJsonDeserializerEntityTest.java

示例15: esAllPrim

import org.apache.olingo.commons.api.data.Entity; //导入方法依赖的package包/类
@Test
public void esAllPrim() throws Exception {
  final EntityCollection entitySet = deserialize(getFileAsStream("ESAllPrim.json"), "ETAllPrim");
  assertNotNull(entitySet);
  assertEquals(3, entitySet.getEntities().size());

  // Check first entity
  Entity entity = entitySet.getEntities().get(0);
  List<Property> properties = entity.getProperties();
  assertNotNull(properties);
  assertEquals(16, properties.size());

  assertEquals(new Short((short) 32767), entity.getProperty("PropertyInt16").getValue());
  assertEquals("First Resource - positive values", entity.getProperty("PropertyString").getValue());
  assertEquals(new Boolean(true), entity.getProperty("PropertyBoolean").getValue());
  assertEquals(new Short((short) 255), entity.getProperty("PropertyByte").getValue());
  assertEquals(new Byte((byte) 127), entity.getProperty("PropertySByte").getValue());
  assertEquals(new Integer(2147483647), entity.getProperty("PropertyInt32").getValue());
  assertEquals(new Long(9223372036854775807l), entity.getProperty("PropertyInt64").getValue());
  assertEquals(new Float(1.79E20), entity.getProperty("PropertySingle").getValue());
  assertEquals(new Double(-1.79E19), entity.getProperty("PropertyDouble").getValue());
  assertEquals(new BigDecimal(34), entity.getProperty("PropertyDecimal").getValue());
  assertNotNull(entity.getProperty("PropertyBinary").getValue());
  assertNotNull(entity.getProperty("PropertyDate").getValue());
  assertNotNull(entity.getProperty("PropertyDateTimeOffset").getValue());
  assertNotNull(entity.getProperty("PropertyDuration").getValue());
  assertNotNull(entity.getProperty("PropertyGuid").getValue());
  assertNotNull(entity.getProperty("PropertyTimeOfDay").getValue());
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:30,代码来源:ODataDeserializerEntityCollectionTest.java


注:本文中的org.apache.olingo.commons.api.data.Entity.getProperties方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。