Java Code Examples for org.apache.olingo.odata2.api.edm.provider.NavigationProperty#setToRole()

The following examples show how to use org.apache.olingo.odata2.api.edm.provider.NavigationProperty#setToRole() . 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: AnnotationEdmProvider.java    From olingo-odata2 with Apache License 2.0 5 votes vote down vote up
private NavigationProperty createNavigationProperty(final String namespace, Field field,
                                                    AnnotationHelper.AnnotatedNavInfo navInfo) {
  NavigationProperty navProp = new NavigationProperty();
  navProp.setName(ANNOTATION_HELPER.getPropertyName(field));
  String fromRole = navInfo.getFromRoleName();
  navProp.setFromRole(fromRole);
  navProp.setToRole(navInfo.getToRoleName());

  String relationshipName = navInfo.getRelationshipName();
  navProp.setRelationship(new FullQualifiedName(namespace, relationshipName));

  return navProp;
}
 
Example 2
Source File: XmlMetadataConsumer.java    From olingo-odata2 with Apache License 2.0 5 votes vote down vote up
private NavigationProperty readNavigationProperty(final XMLStreamReader reader) throws XMLStreamException,
    EntityProviderException {
  reader.require(XMLStreamConstants.START_ELEMENT, edmNamespace, XmlMetadataConstants.EDM_NAVIGATION_PROPERTY);

  NavigationProperty navProperty = new NavigationProperty();
  List<AnnotationElement> annotationElements = new ArrayList<AnnotationElement>();
  navProperty.setName(reader.getAttributeValue(null, XmlMetadataConstants.EDM_NAME));
  String relationship = reader.getAttributeValue(null, XmlMetadataConstants.EDM_NAVIGATION_RELATIONSHIP);
  if (relationship != null) {
    FullQualifiedName fqName = extractFQName(relationship);
    navProperty.setRelationship(fqName);

  } else {
    throw new EntityProviderException(EntityProviderException.MISSING_ATTRIBUTE
        .addContent(XmlMetadataConstants.EDM_NAVIGATION_RELATIONSHIP).addContent(
            XmlMetadataConstants.EDM_NAVIGATION_PROPERTY));
  }

  navProperty.setFromRole(reader.getAttributeValue(null, XmlMetadataConstants.EDM_NAVIGATION_FROM_ROLE));
  navProperty.setToRole(reader.getAttributeValue(null, XmlMetadataConstants.EDM_NAVIGATION_TO_ROLE));
  navProperty.setAnnotationAttributes(readAnnotationAttribute(reader));
  while (reader.hasNext() && !(reader.isEndElement() && edmNamespace.equals(reader.getNamespaceURI())
      && XmlMetadataConstants.EDM_NAVIGATION_PROPERTY.equals(reader.getLocalName()))) {
    reader.next();
    if (reader.isStartElement()) {
      extractNamespaces(reader);
      annotationElements.add(readAnnotationElement(reader));
    }
  }
  if (!annotationElements.isEmpty()) {
    navProperty.setAnnotationElements(annotationElements);
  }
  navProperties.add(navProperty);
  return navProperty;
}