org.apache.olingo.odata2.api.edm.provider.Property Java Examples
The following examples show how to use
org.apache.olingo.odata2.api.edm.provider.Property.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JPAEdmExtension.java From odata-boilerplate with MIT License | 6 votes |
@Override public void extendJPAEdmSchema(JPAEdmSchemaView view) { ResourceBundle i18n = ODataContextUtil.getResourceBundle("i18n"); final Schema edmSchema = view.getEdmSchema(); for (EntityType entityType : edmSchema.getEntityTypes()) { for (Property property : entityType.getProperties()) { String label = null; if (i18n != null) { try { label = i18n.getString(entityType.getName() + "." + property.getName()); } catch (Exception e) {} } List<AnnotationAttribute> annotationAttributeList = new ArrayList<AnnotationAttribute>(); if (label != null) { annotationAttributeList.add(new AnnotationAttribute() .setNamespace(SAP_NAMESPACE) .setPrefix(SAP_PREFIX) .setName(LABEL).setText(label)); } annotationAttributeList.addAll(getSapPropertyAnnotations(entityType, property)); property.setAnnotationAttributes(annotationAttributeList); } } addSmartAnnotations(edmSchema); }
Example #2
Source File: ComplexTypesDescriber.java From cloud-sfsf-benefits-ext with Apache License 2.0 | 6 votes |
@SuppressWarnings("nls") private Property createProperty(Field field) { switch (field.getType().getCanonicalName()) { case "java.lang.String": return createProperty(field.getName(), EdmSimpleTypeKind.String); case "java.lang.Short": case "short": return createProperty(field.getName(), EdmSimpleTypeKind.Int16); case "java.lang.Integer": case "int": return createProperty(field.getName(), EdmSimpleTypeKind.Int32); case "java.lang.Long": case "long": return createProperty(field.getName(), EdmSimpleTypeKind.Int64); case "java.lang.Boolean": case "boolean": return createProperty(field.getName(), EdmSimpleTypeKind.Boolean); case "java.lang.Double": case "double": return createProperty(field.getName(), EdmSimpleTypeKind.Double); default: String errMsg = String.format("Unsupported type [%s} for property [%s]!", field.getType().getCanonicalName(), field.getName()); throw new IllegalArgumentException(errMsg); } }
Example #3
Source File: JPAEdmKey.java From olingo-odata2 with Apache License 2.0 | 6 votes |
public void normalizeComplexKey(final ComplexType complexType, final List<PropertyRef> propertyRefList) { for (Property property : complexType.getProperties()) { try { SimpleProperty simpleProperty = (SimpleProperty) property; Facets facets = (Facets) simpleProperty.getFacets(); if (facets == null) { simpleProperty.setFacets(new Facets().setNullable(false)); } else { facets.setNullable(false); } PropertyRef propertyRef = new PropertyRef(); propertyRef.setName(simpleProperty.getName()); propertyRefList.add(propertyRef); } catch (ClassCastException e) { ComplexProperty complexProperty = (ComplexProperty) property; normalizeComplexKey(complexTypeView.searchEdmComplexType(complexProperty.getType()), propertyRefList); } } }
Example #4
Source File: XmlMetadataConsumerTest.java From olingo-odata2 with Apache License 2.0 | 6 votes |
@Test public void testBaseType() throws XMLStreamException, EntityProviderException { int i = 0; XmlMetadataConsumer parser = new XmlMetadataConsumer(); XMLStreamReader reader = createStreamReader(xmlWithBaseType); DataServices result = parser.readMetadata(reader, true); assertEquals("2.0", result.getDataServiceVersion()); for (Schema schema : result.getSchemas()) { assertEquals(NAMESPACE, schema.getNamespace()); assertEquals(2, schema.getEntityTypes().size()); assertEquals("Employee", schema.getEntityTypes().get(0).getName()); for (PropertyRef propertyRef : schema.getEntityTypes().get(0).getKey().getKeys()) { assertEquals("EmployeeId", propertyRef.getName()); } for (Property property : schema.getEntityTypes().get(0).getProperties()) { assertEquals(propertyNames[i], property.getName()); i++; } } }
Example #5
Source File: AnnotationEdmProviderTest.java From olingo-odata2 with Apache License 2.0 | 6 votes |
@Test public void complexTypeLocation() throws Exception { // validate employee EntityType employee = aep.getEntityType(new FullQualifiedName(ModelSharedConstants.NAMESPACE_1, "Employee")); final List<Property> properties = employee.getProperties(); Property location = null; for (Property property : properties) { if (property.getName().equals("Location")) { location = property; } } assertNotNull(location); assertEquals("Location", location.getName()); // validate location complex type ComplexType locationType = aep.getComplexType( new FullQualifiedName(ModelSharedConstants.NAMESPACE_1, "c_Location")); assertEquals("c_Location", locationType.getName()); assertEquals(2, locationType.getProperties().size()); assertEquals(false, location.getFacets().isNullable()); }
Example #6
Source File: JPAEdmComplexTypeTest.java From olingo-odata2 with Apache License 2.0 | 6 votes |
@Test public void testExpandEdmComplexType() { ComplexType complexType = new ComplexType(); List<Property> properties = new ArrayList<Property>(); JPAEdmMapping mapping1 = new JPAEdmMappingImpl(); mapping1.setJPAColumnName("LINEITEMID"); ((Mapping) mapping1).setInternalName("LineItemKey.LiId"); JPAEdmMapping mapping2 = new JPAEdmMappingImpl(); mapping2.setJPAColumnName("LINEITEMNAME"); ((Mapping) mapping2).setInternalName("LineItemKey.LiName"); properties.add(new SimpleProperty().setName("LIID").setMapping((Mapping) mapping1)); properties.add(new SimpleProperty().setName("LINAME").setMapping((Mapping) mapping2)); complexType.setProperties(properties); List<Property> expandedList = null; try { objComplexType.expandEdmComplexType(complexType, expandedList, "SalesOrderItemKey"); } catch (ClassCastException e) { assertTrue(false); } assertTrue(true); }
Example #7
Source File: AnnotationEdmProviderTest.java From olingo-odata2 with Apache License 2.0 | 6 votes |
@Test public void facetsTest() throws Exception { EntityType employee = aep.getEntityType(new FullQualifiedName(ModelSharedConstants.NAMESPACE_1, "Employee")); assertEquals("Employee", employee.getName()); Property name = getProperty(employee, "EmployeeName"); assertEquals(Integer.valueOf(20), name.getFacets().getMaxLength()); assertNull(name.getFacets().getConcurrencyMode()); assertTrue(name.getFacets().isNullable()); Property id = getProperty(employee, "EmployeeId"); assertFalse(id.getFacets().isNullable()); ComplexType city = aep.getComplexType(new FullQualifiedName(ModelSharedConstants.NAMESPACE_1, "c_City")); Property postalCode = getProperty(city.getProperties(), "PostalCode"); assertEquals(Integer.valueOf(5), postalCode.getFacets().getMaxLength()); EntityType room = aep.getEntityType(new FullQualifiedName(ModelSharedConstants.NAMESPACE_1, "Room")); Property version = getProperty(room, "Version"); assertEquals(Integer.valueOf(0), version.getFacets().getScale()); assertEquals(Integer.valueOf(0), version.getFacets().getPrecision()); assertEquals(EdmConcurrencyMode.Fixed, version.getFacets().getConcurrencyMode()); }
Example #8
Source File: XmlMetadataConsumerTest.java From olingo-odata2 with Apache License 2.0 | 6 votes |
@Test public void stringValueForMaxLegthFacet() throws Exception { XmlMetadataConsumer parser = new XmlMetadataConsumer(); XMLStreamReader reader = createStreamReader(xmlWithStringValueForMaxLengthFacet); DataServices result = parser.readMetadata(reader, true); List<Property> properties = result.getSchemas().get(0).getEntityTypes().get(0).getProperties(); assertEquals(2, properties.size()); Property property = getForName(properties, "Id"); EdmFacets facets = property.getFacets(); assertEquals(new Integer(Integer.MAX_VALUE), facets.getMaxLength()); property = getForName(properties, "Name"); facets = property.getFacets(); assertEquals(new Integer(Integer.MAX_VALUE), facets.getMaxLength()); }
Example #9
Source File: AnnotationEdmProviderTest.java From olingo-odata2 with Apache License 2.0 | 6 votes |
@Test public void entityTypeEmployee() throws Exception { // validate employee EntityType employee = aep.getEntityType(new FullQualifiedName(ModelSharedConstants.NAMESPACE_1, "Employee")); assertEquals("Employee", employee.getName()); final List<PropertyRef> employeeKeys = employee.getKey().getKeys(); assertEquals(1, employeeKeys.size()); assertEquals("EmployeeId", employeeKeys.get(0).getName()); assertEquals(6, employee.getProperties().size()); assertEquals(3, employee.getNavigationProperties().size()); Property name = getProperty(employee, "EmployeeName"); assertEquals(Integer.valueOf(20), name.getFacets().getMaxLength()); for (NavigationProperty navigationProperty : employee.getNavigationProperties()) { if (navigationProperty.getName().equals("ne_Manager")) { validateNavProperty(navigationProperty, "ManagerEmployees", "r_Employees", "r_Manager"); } else if (navigationProperty.getName().equals("ne_Team")) { validateNavProperty(navigationProperty, "TeamEmployees", "r_Employees", "r_Team"); } else if (navigationProperty.getName().equals("ne_Room")) { validateNavProperty(navigationProperty, "r_Employees_2_r_Room", "r_Employees", "r_Room"); } else { fail("Got unexpected navigation property with name '" + navigationProperty.getName() + "'."); } } }
Example #10
Source File: EdmStructuralTypeImplProv.java From olingo-odata2 with Apache License 2.0 | 6 votes |
@Override public List<String> getPropertyNames() throws EdmException { if (edmPropertyNames == null) { final List<String> temp = new ArrayList<String>(); if (edmBaseType != null) { temp.addAll(edmBaseType.getPropertyNames()); } if (structuralType.getProperties() != null) { for (final Property property : structuralType.getProperties()) { temp.add(property.getName()); } } edmPropertyNames = temp; } return edmPropertyNames; }
Example #11
Source File: XmlMetadataConsumer.java From olingo-odata2 with Apache License 2.0 | 5 votes |
private Property readProperty(final XMLStreamReader reader) throws XMLStreamException, EntityProviderException { reader.require(XMLStreamConstants.START_ELEMENT, edmNamespace, XmlMetadataConstants.EDM_PROPERTY); Property property; List<AnnotationElement> annotationElements = new ArrayList<AnnotationElement>(); String type = reader.getAttributeValue(null, XmlMetadataConstants.EDM_TYPE); if (type == null) { throw new EntityProviderException(EntityProviderException.MISSING_ATTRIBUTE .addContent(XmlMetadataConstants.EDM_TYPE).addContent(XmlMetadataConstants.EDM_PROPERTY)); } FullQualifiedName fqName = extractFQName(type); if (EdmSimpleType.EDM_NAMESPACE.equals(fqName.getNamespace())) { property = readSimpleProperty(reader, fqName); } else { property = readComplexProperty(reader, fqName); } property.setFacets(readFacets(reader)); property.setCustomizableFeedMappings(readCustomizableFeedMappings(reader)); property.setMimeType(reader.getAttributeValue(Edm.NAMESPACE_M_2007_08, XmlMetadataConstants.M_MIMETYPE)); property.setAnnotationAttributes(readAnnotationAttribute(reader)); while (reader.hasNext() && !(reader.isEndElement() && edmNamespace.equals(reader.getNamespaceURI()) && XmlMetadataConstants.EDM_PROPERTY.equals(reader.getLocalName()))) { reader.next(); if (reader.isStartElement()) { extractNamespaces(reader); annotationElements.add(readAnnotationElement(reader)); } } if (!annotationElements.isEmpty()) { property.setAnnotationElements(annotationElements); } return property; }
Example #12
Source File: AnnotationEdmProvider.java From olingo-odata2 with Apache License 2.0 | 5 votes |
private Property createProperty(final EdmProperty ep, final Field field) { if (isAnnotatedEntity(field.getType())) { return createComplexProperty(ep, field); } else { return createSimpleProperty(ep, field); } }
Example #13
Source File: BasicEntityProvider.java From olingo-odata2 with Apache License 2.0 | 5 votes |
/** * Calculates the necessary data service version for the metadata serialization * @param schemas * @return DataServiceversion as String */ private String calculateDataServiceVersion(final List<Schema> schemas) { String dataServiceVersion = ODataServiceVersion.V10; if (schemas != null) { for (Schema schema : schemas) { List<EntityType> entityTypes = schema.getEntityTypes(); if (entityTypes != null) { for (EntityType entityType : entityTypes) { List<Property> properties = entityType.getProperties(); if (properties != null) { for (Property property : properties) { if (property.getCustomizableFeedMappings() != null) { if (property.getCustomizableFeedMappings().getFcKeepInContent() != null) { if (!property.getCustomizableFeedMappings().getFcKeepInContent()) { dataServiceVersion = ODataServiceVersion.V20; return dataServiceVersion; } } } } if (entityType.getCustomizableFeedMappings() != null) { if (entityType.getCustomizableFeedMappings().getFcKeepInContent() != null) { if (entityType.getCustomizableFeedMappings().getFcKeepInContent()) { dataServiceVersion = ODataServiceVersion.V20; return dataServiceVersion; } } } } } } } } return dataServiceVersion; }
Example #14
Source File: XmlMetadataProducer.java From olingo-odata2 with Apache License 2.0 | 5 votes |
private static void writeProperties(final Collection<Property> properties, final Map<String, String> predefinedNamespaces, final XMLStreamWriter xmlStreamWriter) throws XMLStreamException { for (Property property : properties) { xmlStreamWriter.writeStartElement(XmlMetadataConstants.EDM_PROPERTY); xmlStreamWriter.writeAttribute(XmlMetadataConstants.EDM_NAME, property.getName()); if (property instanceof SimpleProperty) { xmlStreamWriter.writeAttribute(XmlMetadataConstants.EDM_TYPE, ((SimpleProperty) property).getType() .getFullQualifiedName().toString()); } else if (property instanceof ComplexProperty) { xmlStreamWriter .writeAttribute(XmlMetadataConstants.EDM_TYPE, ((ComplexProperty) property).getType().toString()); } else { throw new ODataRuntimeException(); } writeFacets(xmlStreamWriter, property.getFacets()); if (property.getMimeType() != null) { xmlStreamWriter.writeAttribute(Edm.PREFIX_M, Edm.NAMESPACE_M_2007_08, XmlMetadataConstants.M_MIMETYPE, property .getMimeType()); } writeCustomizableFeedMappings(property.getCustomizableFeedMappings(), xmlStreamWriter); writeAnnotationAttributes(property.getAnnotationAttributes(), predefinedNamespaces, null, xmlStreamWriter); writeDocumentation(property.getDocumentation(), predefinedNamespaces, xmlStreamWriter); writeAnnotationElements(property.getAnnotationElements(), predefinedNamespaces, xmlStreamWriter); xmlStreamWriter.writeEndElement(); } }
Example #15
Source File: JPAEdmComplexType.java From olingo-odata2 with Apache License 2.0 | 5 votes |
@Override public void expandEdmComplexType(final ComplexType complexType, List<Property> expandedList, final String embeddablePropertyName) { if (expandedList == null) { expandedList = new ArrayList<Property>(); } for (Property property : complexType.getProperties()) { try { SimpleProperty newSimpleProperty = new SimpleProperty(); SimpleProperty oldSimpleProperty = (SimpleProperty) property; newSimpleProperty.setAnnotationAttributes(oldSimpleProperty.getAnnotationAttributes()); newSimpleProperty.setAnnotationElements(oldSimpleProperty.getAnnotationElements()); newSimpleProperty.setCustomizableFeedMappings(oldSimpleProperty.getCustomizableFeedMappings()); newSimpleProperty.setDocumentation(oldSimpleProperty.getDocumentation()); newSimpleProperty.setFacets(oldSimpleProperty.getFacets()); newSimpleProperty.setMimeType(oldSimpleProperty.getMimeType()); newSimpleProperty.setName(oldSimpleProperty.getName()); newSimpleProperty.setType(oldSimpleProperty.getType()); JPAEdmMappingImpl newMapping = new JPAEdmMappingImpl(); Mapping mapping = oldSimpleProperty.getMapping(); JPAEdmMapping oldMapping = (JPAEdmMapping) mapping; newMapping.setJPAColumnName(oldMapping.getJPAColumnName()); newMapping.setInternalName(embeddablePropertyName + "." + mapping.getInternalName()); newMapping.setObject(mapping.getObject()); newMapping.setJPAType(oldMapping.getJPAType()); newSimpleProperty.setMapping(newMapping); expandedList.add(newSimpleProperty); } catch (ClassCastException e) { ComplexProperty complexProperty = (ComplexProperty) property; String name = embeddablePropertyName + "." + complexProperty.getMapping().getInternalName(); expandEdmComplexType(searchComplexTypeByName(complexProperty.getName()), expandedList, name); } } }
Example #16
Source File: AnnotationEdmProviderTest.java From olingo-odata2 with Apache License 2.0 | 5 votes |
private Property getProperty(final List<Property> properties, final String name) { for (Property property : properties) { if (name.equals(property.getName())) { return property; } } fail("Requested property with name '" + name + "' not available."); return null; }
Example #17
Source File: AnnotationEdmProvider.java From olingo-odata2 with Apache License 2.0 | 5 votes |
private Property createSimpleProperty(final EdmProperty ep, final Field field) { SimpleProperty sp = new SimpleProperty(); String entityName = ANNOTATION_HELPER.getPropertyName(field); sp.setName(entityName); // EdmType type = ep.type(); if (type == EdmType.NULL) { type = getEdmType(field.getType()); } sp.setType(ANNOTATION_HELPER.mapTypeKind(type)); sp.setFacets(createFacets(ep.facets(), field.getAnnotation(EdmConcurrencyControl.class))); return sp; }
Example #18
Source File: ItemEntitySet.java From DataHubSystem with GNU Affero General Public License v3.0 | 5 votes |
@Override public EntityType getEntityType () { List<Property> properties = new ArrayList<Property> (); properties.add (new SimpleProperty ().setName (ID) .setType (EdmSimpleTypeKind.String) .setFacets (new Facets ().setNullable (false))); properties.add (new SimpleProperty () .setName (NAME) .setType (EdmSimpleTypeKind.String) .setCustomizableFeedMappings ( new CustomizableFeedMappings () .setFcTargetPath (EdmTargetPath.SYNDICATION_TITLE))); properties.add (new SimpleProperty ().setName (CONTENT_TYPE).setType ( EdmSimpleTypeKind.String)); properties.add (new SimpleProperty ().setName (CONTENT_LENGTH).setType ( EdmSimpleTypeKind.Int64)); // Key Key key = new Key ().setKeys (Collections.singletonList (new PropertyRef () .setName (ID))); // TODO (OData v3) setOpenType(true) setAbstract(true) return new EntityType ().setName (ENTITY_NAME).setProperties (properties) .setKey (key); }
Example #19
Source File: XmlMetadataConsumer.java From olingo-odata2 with Apache License 2.0 | 5 votes |
private Property readComplexProperty(final XMLStreamReader reader, final FullQualifiedName fqName) throws XMLStreamException { ComplexProperty property = new ComplexProperty(); property.setName(reader.getAttributeValue(null, XmlMetadataConstants.EDM_NAME)); property.setType(fqName); return property; }
Example #20
Source File: XmlMetadataConsumer.java From olingo-odata2 with Apache License 2.0 | 5 votes |
private Property readSimpleProperty(final XMLStreamReader reader, final FullQualifiedName fqName) throws XMLStreamException { SimpleProperty property = new SimpleProperty(); property.setName(reader.getAttributeValue(null, XmlMetadataConstants.EDM_NAME)); property.setType(EdmSimpleTypeKind.valueOf(fqName.getName())); return property; }
Example #21
Source File: EdmServiceMetadataImplProv.java From olingo-odata2 with Apache License 2.0 | 5 votes |
@Override public String getDataServiceVersion() throws ODataException { if(edmProvider == null){ throw new ODataException(EDM_PROVIDER_EXEPTION); } if (schemas == null) { schemas = edmProvider.getSchemas(); } if (dataServiceVersion == null) { dataServiceVersion = ODataServiceVersion.V10; for (Schema schema : listOrEmptyList(schemas)) { List<EntityType> entityTypes = listOrEmptyList(schema.getEntityTypes()); for (EntityType entityType : entityTypes) { List<Property> properties = listOrEmptyList(entityType.getProperties()); for (Property property : properties) { if (property.getCustomizableFeedMappings() != null) { if (property.getCustomizableFeedMappings().getFcKeepInContent() != null) { if (!property.getCustomizableFeedMappings().getFcKeepInContent()) { dataServiceVersion = ODataServiceVersion.V20; return dataServiceVersion; } } if (entityType.getCustomizableFeedMappings() != null) { if (entityType.getCustomizableFeedMappings().getFcKeepInContent() != null) { if (entityType.getCustomizableFeedMappings().getFcKeepInContent()) { dataServiceVersion = ODataServiceVersion.V20; return dataServiceVersion; } } } } } } } } return dataServiceVersion; }
Example #22
Source File: EdmStructuralTypeImplProv.java From olingo-odata2 with Apache License 2.0 | 5 votes |
private void buildPropertiesInternal() throws EdmException { properties = new HashMap<String, Property>(); if (structuralType.getProperties() != null) { for (final Property property : structuralType.getProperties()) { properties.put(property.getName(), property); } } }
Example #23
Source File: EdmStructuralTypeImplProv.java From olingo-odata2 with Apache License 2.0 | 5 votes |
protected EdmTyped createProperty(final Property property) throws EdmException { if (property instanceof SimpleProperty) { return new EdmSimplePropertyImplProv(edm, (SimpleProperty) property); } else if (property instanceof ComplexProperty) { return new EdmComplexPropertyImplProv(edm, (ComplexProperty) property); } else { throw new EdmException(EdmException.COMMON); } }
Example #24
Source File: XmlMetadataConsumerTest.java From olingo-odata2 with Apache License 2.0 | 5 votes |
private Property getForName(final List<Property> properties, final String propertyName) { for (Property property : properties) { if (property.getName().equals(propertyName)) { return property; } } fail("Should have found property:" + propertyName); return null; }
Example #25
Source File: XmlMetadataConsumerTest.java From olingo-odata2 with Apache License 2.0 | 5 votes |
@Test public void test() throws XMLStreamException, EntityProviderException { int i = 0; XmlMetadataConsumer parser = new XmlMetadataConsumer(); XMLStreamReader reader = createStreamReader(xml); DataServices result = parser.readMetadata(reader, true); assertEquals("2.0", result.getDataServiceVersion()); for (Schema schema : result.getSchemas()) { assertEquals(NAMESPACE, schema.getNamespace()); assertEquals(1, schema.getEntityTypes().size()); assertEquals("Employee", schema.getEntityTypes().get(0).getName()); assertEquals(Boolean.TRUE, schema.getEntityTypes().get(0).isHasStream()); for (PropertyRef propertyRef : schema.getEntityTypes().get(0).getKey().getKeys()) { assertEquals("EmployeeId", propertyRef.getName()); } for (Property property : schema.getEntityTypes().get(0).getProperties()) { assertEquals(propertyNames[i], property.getName()); if ("Location".equals(property.getName())) { ComplexProperty cProperty = (ComplexProperty) property; assertEquals(NAMESPACE, cProperty.getType().getNamespace()); assertEquals("c_Location", cProperty.getType().getName()); } else if ("EmployeeName".equals(property.getName())) { assertNotNull(property.getCustomizableFeedMappings()); assertEquals("SyndicationTitle", property.getCustomizableFeedMappings().getFcTargetPath()); assertNull(property.getCustomizableFeedMappings().getFcContentKind()); } i++; } assertEquals(1, schema.getComplexTypes().size()); assertEquals("c_Location", schema.getComplexTypes().get(0).getName()); } }
Example #26
Source File: XmlMetadataConsumerTest.java From olingo-odata2 with Apache License 2.0 | 5 votes |
@Test public void testOtherEdmNamespace() throws XMLStreamException, EntityProviderException { int i = 0; XmlMetadataConsumer parser = new XmlMetadataConsumer(); XMLStreamReader reader = createStreamReader(xml2); DataServices result = parser.readMetadata(reader, true); assertEquals("2.0", result.getDataServiceVersion()); for (Schema schema : result.getSchemas()) { assertEquals(NAMESPACE, schema.getNamespace()); assertEquals(1, schema.getEntityTypes().size()); assertEquals("Employee", schema.getEntityTypes().get(0).getName()); for (PropertyRef propertyRef : schema.getEntityTypes().get(0).getKey().getKeys()) { assertEquals("EmployeeId", propertyRef.getName()); } for (Property property : schema.getEntityTypes().get(0).getProperties()) { assertEquals(propertyNames[i], property.getName()); if ("Location".equals(property.getName())) { ComplexProperty cProperty = (ComplexProperty) property; assertEquals("c_Location", cProperty.getType().getName()); } else if ("EmployeeName".equals(property.getName())) { assertNotNull(property.getCustomizableFeedMappings()); } i++; } for (AnnotationElement annoElement : schema.getAnnotationElements()) { assertEquals("prefix", annoElement.getPrefix()); assertEquals("namespace", annoElement.getNamespace()); assertEquals("schemaElement", annoElement.getName()); assertEquals("text3", annoElement.getText()); } } }
Example #27
Source File: EdmComplexTypeImplProvTest.java From olingo-odata2 with Apache License 2.0 | 5 votes |
@BeforeClass public static void getEdmEntityContainerImpl() throws Exception { edmProvider = mock(EdmProvider.class); EdmImplProv edmImplProv = new EdmImplProv(edmProvider); ComplexType fooComplexType = new ComplexType().setName("fooComplexType"); List<Property> keyPropertysFoo = new ArrayList<Property>(); keyPropertysFoo.add(new SimpleProperty().setName("Name").setType(EdmSimpleTypeKind.String)); keyPropertysFoo.add(new SimpleProperty().setName("Address").setType(EdmSimpleTypeKind.String)); fooComplexType.setProperties(keyPropertysFoo); edmComplexType = new EdmComplexTypeImplProv(edmImplProv, fooComplexType, "namespace"); FullQualifiedName barBaseTypeName = new FullQualifiedName("namespace", "barBase"); ComplexType barBase = new ComplexType().setName("barBase"); when(edmProvider.getComplexType(barBaseTypeName)).thenReturn(barBase); List<Property> propertysBarBase = new ArrayList<Property>(); propertysBarBase.add(new SimpleProperty().setName("Name").setType(EdmSimpleTypeKind.String)); propertysBarBase.add(new SimpleProperty().setName("Address").setType(EdmSimpleTypeKind.String)); barBase.setProperties(propertysBarBase); ComplexType barComplexType = new ComplexType().setName("barComplexType").setBaseType(barBaseTypeName); edmComplexTypeWithBaseType = new EdmComplexTypeImplProv(edmImplProv, barComplexType, "namespace"); }
Example #28
Source File: CarEdmProvider.java From olingo-odata2 with Apache License 2.0 | 5 votes |
@Override public ComplexType getComplexType(final FullQualifiedName edmFQName) throws ODataException { if (NAMESPACE.equals(edmFQName.getNamespace())) { if (COMPLEX_TYPE.getName().equals(edmFQName.getName())) { List<Property> properties = new ArrayList<Property>(); properties.add(new SimpleProperty().setName("Street").setType(EdmSimpleTypeKind.String)); properties.add(new SimpleProperty().setName("City").setType(EdmSimpleTypeKind.String)); properties.add(new SimpleProperty().setName("ZipCode").setType(EdmSimpleTypeKind.String)); properties.add(new SimpleProperty().setName("Country").setType(EdmSimpleTypeKind.String)); return new ComplexType().setName(COMPLEX_TYPE.getName()).setProperties(properties); } } return null; }
Example #29
Source File: ComplexTypesDescriber.java From cloud-sfsf-benefits-ext with Apache License 2.0 | 5 votes |
private ComplexType describeType(Class<?> odataType, String name) throws SecurityException, IllegalArgumentException, InstantiationException, IllegalAccessException, IntrospectionException, NoSuchFieldException { List<Field> fields = getTypeFields(odataType); List<Property> properties = new ArrayList<>(); for (Field field : fields) { properties.add(createProperty(field)); } ComplexType complexType = new ComplexType(); complexType.setName(name); complexType.setProperties(properties); return complexType; }
Example #30
Source File: MyEdmProvider.java From wildfly-camel with Apache License 2.0 | 5 votes |
@Override public ComplexType getComplexType(FullQualifiedName edmFQName) throws ODataException { if (NAMESPACE.equals(edmFQName.getNamespace())) { if (COMPLEX_TYPE.getName().equals(edmFQName.getName())) { List<Property> properties = new ArrayList<>(); properties.add(new SimpleProperty().setName("Street").setType(EdmSimpleTypeKind.String)); properties.add(new SimpleProperty().setName("City").setType(EdmSimpleTypeKind.String)); properties.add(new SimpleProperty().setName("ZipCode").setType(EdmSimpleTypeKind.String)); properties.add(new SimpleProperty().setName("Country").setType(EdmSimpleTypeKind.String)); return new ComplexType().setName(COMPLEX_TYPE.getName()).setProperties(properties); } } return null; }