Java Code Examples for org.apache.olingo.commons.api.edm.provider.CsdlComplexType#setName()

The following examples show how to use org.apache.olingo.commons.api.edm.provider.CsdlComplexType#setName() . 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: ProductsEdmProvider.java    From syndesis with Apache License 2.0 6 votes vote down vote up
@Override
public CsdlComplexType getComplexType(FullQualifiedName complexTypeName) {
    if (complexTypeName.equals(ET_SPEC_FQN)) {
        CsdlProperty type = new CsdlProperty().setName(SPEC_PRODUCT_TYPE)
            .setType(EdmPrimitiveTypeKind.String.getFullQualifiedName());
        CsdlProperty detail1 = new CsdlProperty().setName(SPEC_DETAIL_1)
            .setType(EdmPrimitiveTypeKind.String.getFullQualifiedName());
        CsdlProperty detail2 = new CsdlProperty().setName(SPEC_DETAIL_2)
            .setType(EdmPrimitiveTypeKind.String.getFullQualifiedName());
        CsdlProperty powerType = new CsdlProperty().setName(SPEC_POWER_TYPE)
            .setType(ET_POWER_TYPE_FQN);
        CsdlComplexType complexType = new CsdlComplexType();
        complexType.setName(ET_SPEC_NAME);
        complexType.setProperties(Arrays.asList(type, detail1, detail2, powerType));
        return complexType;
    }

    return null;
}
 
Example 2
Source File: EdmComplexTypeImplTest.java    From olingo-odata4 with Apache License 2.0 5 votes vote down vote up
@Test(expected = EdmException.class)
public void nonExistingBaseType() throws Exception {
  CsdlEdmProvider provider = mock(CsdlEdmProvider.class);
  EdmProviderImpl edm = new EdmProviderImpl(provider);
  FullQualifiedName typeWithNonexistingBaseTypeName = new FullQualifiedName("namespace", "typeName");
  CsdlComplexType complexTypeForNonexistingBaseType =
      new CsdlComplexType().setBaseType(new FullQualifiedName("wrong", "wrong"));
  complexTypeForNonexistingBaseType.setName("typeName");
  when(provider.getComplexType(typeWithNonexistingBaseTypeName)).thenReturn(complexTypeForNonexistingBaseType);
  EdmComplexTypeImpl instance =
      new EdmComplexTypeImpl(edm, typeWithNonexistingBaseTypeName, complexTypeForNonexistingBaseType);
  instance.getBaseType();
}
 
Example 3
Source File: MetadataParser.java    From olingo-odata4 with Apache License 2.0 5 votes vote down vote up
private void readComplexType(XMLEventReader reader, StartElement element, CsdlSchema schema)
    throws XMLStreamException {
  CsdlComplexType complexType = new CsdlComplexType();
  complexType.setProperties(new ArrayList<CsdlProperty>());
  complexType.setNavigationProperties(new ArrayList<CsdlNavigationProperty>());
  complexType.setName(attr(element, "Name"));
  if (attr(element, "BaseType") != null) {
    complexType.setBaseType(new FullQualifiedName(attr(element, "BaseType")));
  }
  complexType.setAbstract(Boolean.parseBoolean(attr(element, "Abstract")));
  complexType.setOpenType(Boolean.parseBoolean(attr(element, "OpenType")));
  readProperties(reader, complexType);

  schema.getComplexTypes().add(complexType);
}