Package org.apache.olingo.odata2.api.annotation.edm

Examples of org.apache.olingo.odata2.api.annotation.edm.EdmNavigationProperty


          EdmKey eti = field.getAnnotation(EdmKey.class);
          if (eti != null) {
            keyProperties.add(createKeyProperty(ep, field));
          }
        }
        EdmNavigationProperty enp = field.getAnnotation(EdmNavigationProperty.class);
        if (enp != null) {
          final NavigationProperty navProperty = createNavigationProperty(namespace, enp, field);
          navProperties.add(navProperty);
          Association association = createAssociation(field, navProperty);
          associations.add(association);
View Full Code Here


      return ANNOTATION_HELPER.extractEntityTypeFqn(baseEntityClass);
    }

    private Association createAssociation(final Field field, final NavigationProperty navProperty) {
      Association association = new Association();
      EdmNavigationProperty navigation = field.getAnnotation(EdmNavigationProperty.class);

      AssociationEnd fromEnd = new AssociationEnd();
      fromEnd.setRole(navProperty.getFromRole());
      String typeName = ANNOTATION_HELPER.extractEntityTypeName(field.getDeclaringClass());
      fromEnd.setType(new FullQualifiedName(namespace, typeName));
View Full Code Here

   * @return
   */
  public String getPropertyNameFromAnnotation(final Field field) {
    EdmProperty property = field.getAnnotation(EdmProperty.class);
    if (property == null) {
      EdmNavigationProperty navProperty = field.getAnnotation(EdmNavigationProperty.class);
      if (navProperty == null) {
        throw new EdmAnnotationException("Given field '" + field
            + "' has no EdmProperty or EdmNavigationProperty annotation.");
      }
      return navProperty.name();
    }
    return property.name();
  }
View Full Code Here

    List<Field> sourceFields = getAnnotatedFields(sourceClass, EdmNavigationProperty.class);
    List<Field> targetFields = getAnnotatedFields(targetClass, EdmNavigationProperty.class);

    // first try via association name to get full navigation information
    for (Field sourceField : sourceFields) {
      final EdmNavigationProperty sourceNav = sourceField.getAnnotation(EdmNavigationProperty.class);
      final String sourceAssociation = extractRelationshipName(sourceNav, sourceField);
      for (Field targetField : targetFields) {
        final EdmNavigationProperty targetNav = targetField.getAnnotation(EdmNavigationProperty.class);
        final String targetAssociation = extractRelationshipName(targetNav, targetField);
        if (sourceAssociation.equals(targetAssociation)) {
          return new AnnotatedNavInfo(sourceField, targetField, sourceNav, targetNav);
        }
      }
    }

    // if nothing was found assume none bi-directinal navigation
    String targetEntityTypeName = extractEntityTypeName(targetClass);
    for (Field sourceField : sourceFields) {
      final EdmNavigationProperty sourceNav = sourceField.getAnnotation(EdmNavigationProperty.class);
      final String navTargetEntityName = extractEntitTypeName(sourceNav, sourceField);

      if (navTargetEntityName.equals(targetEntityTypeName)) {
        return new AnnotatedNavInfo(sourceField, null, sourceNav, null);
      }
View Full Code Here

          EdmKey eti = field.getAnnotation(EdmKey.class);
          if (eti != null) {
            keyProperties.add(createKeyProperty(ep, field));
          }
        }
        EdmNavigationProperty enp = field.getAnnotation(EdmNavigationProperty.class);
        if (enp != null) {
          final NavigationProperty navProperty = createNavigationProperty(namespace, enp, field);
          navProperties.add(navProperty);
          Association association = createAssociation(field, navProperty);
          associations.add(association);
View Full Code Here

      return ANNOTATION_HELPER.extractEntityTypeFqn(baseEntityClass);
    }

    private Association createAssociation(final Field field, final NavigationProperty navProperty) {
      Association association = new Association();
      EdmNavigationProperty navigation = field.getAnnotation(EdmNavigationProperty.class);

      AssociationEnd fromEnd = new AssociationEnd();
      fromEnd.setRole(navProperty.getFromRole());
      String typeName = ANNOTATION_HELPER.extractEntityTypeName(field.getDeclaringClass());
      fromEnd.setType(new FullQualifiedName(namespace, typeName));
View Full Code Here

  }

  @Test
  public void extractEntitTypeNameViaNavigation() throws Exception {
    Field field = NavigationAnnotated.class.getDeclaredField("navigationPropertySimpleEntity");
    EdmNavigationProperty enp = field.getAnnotation(EdmNavigationProperty.class);

    String name = annotationHelper.extractEntitTypeName(enp, SimpleEntity.class);

    Assert.assertEquals("SimpleEntity", name);
  }
View Full Code Here

  }

  @Test
  public void extractEntitTypeNameViaNavigationField() throws Exception {
    Field field = NavigationAnnotated.class.getDeclaredField("navigationPropertyDefault");
    EdmNavigationProperty enp = field.getAnnotation(EdmNavigationProperty.class);

    String name = annotationHelper.extractEntitTypeName(enp, field);

    Assert.assertEquals("SimpleEntity", name);
  }
View Full Code Here

   * @return
   */
  public String getPropertyNameFromAnnotation(final Field field) {
    EdmProperty property = field.getAnnotation(EdmProperty.class);
    if (property == null) {
      EdmNavigationProperty navProperty = field.getAnnotation(EdmNavigationProperty.class);
      if (navProperty == null) {
        throw new EdmAnnotationException("Given field '" + field
            + "' has no EdmProperty or EdmNavigationProperty annotation.");
      }
      return navProperty.name();
    }
    return property.name();
  }
View Full Code Here

    List<Field> sourceFields = getAnnotatedFields(sourceClass, EdmNavigationProperty.class);
    List<Field> targetFields = getAnnotatedFields(targetClass, EdmNavigationProperty.class);

    // first try via association name to get full navigation information
    for (Field sourceField : sourceFields) {
      final EdmNavigationProperty sourceNav = sourceField.getAnnotation(EdmNavigationProperty.class);
      final String sourceAssociation = extractRelationshipName(sourceNav, sourceField);
      for (Field targetField : targetFields) {
        final EdmNavigationProperty targetNav = targetField.getAnnotation(EdmNavigationProperty.class);
        final String targetAssociation = extractRelationshipName(targetNav, targetField);
        if (sourceAssociation.equals(targetAssociation)) {
          return new AnnotatedNavInfo(sourceField, targetField, sourceNav, targetNav);
        }
      }
    }

    // if nothing was found assume none bi-directinal navigation
    String targetEntityTypeName = extractEntityTypeName(targetClass);
    for (Field sourceField : sourceFields) {
      final EdmNavigationProperty sourceNav = sourceField.getAnnotation(EdmNavigationProperty.class);
      final String navTargetEntityName = extractEntitTypeName(sourceNav, sourceField);

      if (navTargetEntityName.equals(targetEntityTypeName)) {
        return new AnnotatedNavInfo(sourceField, null, sourceNav, null);
      }
View Full Code Here

TOP

Related Classes of org.apache.olingo.odata2.api.annotation.edm.EdmNavigationProperty

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.