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

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


  public static EdmNavigationProperty mockEdmNavigationProperty(final String navigationPropertyName,
      final EdmMultiplicity multiplicity) throws EdmException {

    EdmEntityType edmEntityType = mockEdmEntityType(JPARelatedTypeMock.ENTITY_NAME, false);

    EdmNavigationProperty navigationProperty = EasyMock.createMock(EdmNavigationProperty.class);
    EasyMock.expect(navigationProperty.getType()).andReturn(edmEntityType).anyTimes();
    EasyMock.expect(navigationProperty.getMultiplicity()).andReturn(multiplicity);
    EasyMock.expect(navigationProperty.getMapping()).andReturn(
        (EdmMapping) mockEdmMapping(null, null, navigationPropertyName)).anyTimes();
    EasyMock.expect(navigationProperty.getToRole()).andReturn("TO");
    EasyMock.expect(navigationProperty.getRelationship()).andReturn(mockEdmAssociation(navigationPropertyName));
    if (multiplicity.equals(EdmMultiplicity.ONE)) {
      EasyMock.expect(navigationProperty.getName()).andReturn(JPATypeMock.NAVIGATION_PROPERTY_X).anyTimes();
    }

    EasyMock.replay(navigationProperty);

    return navigationProperty;
View Full Code Here


  private static EdmNavigationProperty createNavigationProperty(final String name, final EdmMultiplicity multiplicity,
      final EdmEntitySet entitySet, final EdmEntitySet targetEntitySet) throws EdmException {
    EdmType navigationType = mock(EdmType.class);
    when(navigationType.getKind()).thenReturn(EdmTypeKind.ENTITY);

    EdmNavigationProperty navigationProperty = mock(EdmNavigationProperty.class);
    when(navigationProperty.getName()).thenReturn(name);
    when(navigationProperty.getType()).thenReturn(navigationType);
    when(navigationProperty.getMultiplicity()).thenReturn(multiplicity);

    when(entitySet.getEntityType().getProperty(name)).thenReturn(navigationProperty);
    when(entitySet.getRelatedEntitySet(navigationProperty)).thenReturn(targetEntitySet);

    return navigationProperty;
View Full Code Here

  private void writeExpandedNavigationProperty(final Writer writer, final EntityInfoAggregator entityInfo,
      final Map<String, Object> data,
      final EdmEntityType type, final String navigationPropertyName) throws EdmException, EntityProviderException,
      IOException {
    final EdmNavigationProperty navigationProperty = (EdmNavigationProperty) type.getProperty(navigationPropertyName);
    final boolean isFeed = navigationProperty.getMultiplicity() == EdmMultiplicity.MANY;
    final EdmEntitySet entitySet = entityInfo.getEntitySet();
    final EdmEntitySet inlineEntitySet = entitySet.getRelatedEntitySet(navigationProperty);

    WriteCallbackContext context = isFeed ? new WriteFeedCallbackContext() : new WriteEntryCallbackContext();
    context.setSourceEntitySet(entitySet);
View Full Code Here

  public void setUp() throws Exception {
    entitySetUriInfo = EasyMock.createMock(GetEntitySetUriInfo.class);
    EdmEntitySet edmEntitySet = EasyMock.createMock(EdmEntitySet.class);
    EdmEntityType edmEntityType = EasyMock.createMock(EdmEntityType.class);
    List<NavigationSegment> navigationSegments = new ArrayList<NavigationSegment>();
    final EdmNavigationProperty navigationProperty = createNavigationProperty("a");
    final EdmNavigationProperty navigationProperty1 = createNavigationProperty("b");
    final List<KeyPredicate> keyPredicates = createKeyPredicates();
    NavigationSegment navigationSegment = new NavigationSegment() {

      @Override
      public EdmNavigationProperty getNavigationProperty() {
View Full Code Here

    assertEquals("s_Itema", joinClauses.get(1).getEntityRelationShip());
    assertEquals("R1", joinClauses.get(1).getEntityRelationShipAlias());
  }

  private EdmNavigationProperty createNavigationProperty(final String z) throws EdmException {
    EdmNavigationProperty navigationProperty = EasyMock.createMock(EdmNavigationProperty.class);
    EdmAssociation association = EasyMock.createMock(EdmAssociation.class);
    EdmAssociationEnd associationEnd = EasyMock.createMock(EdmAssociationEnd.class);
    EasyMock.expect(navigationProperty.getFromRole()).andStubReturn("roleA" + z);
    EasyMock.expect(navigationProperty.getToRole()).andStubReturn("roleB" + z);
    EasyMock.expect(navigationProperty.getName()).andStubReturn("navP" + z);
    EasyMock.expect(navigationProperty.getName()).andStubReturn("navP" + z);
    EasyMock.expect(navigationProperty.getMultiplicity()).andStubReturn(EdmMultiplicity.ONE);
    EdmEntityType edmEntityType = EasyMock.createMock(EdmEntityType.class);
    EdmMapping edmMapping = EasyMock.createMock(EdmMapping.class);
    EasyMock.expect(edmMapping.getInternalName()).andStubReturn("sItem" + z);
    EasyMock.expect(edmEntityType.getMapping()).andStubReturn(edmMapping);
    EasyMock.expect(edmEntityType.getName()).andStubReturn("soItem" + z);
    EasyMock.expect(associationEnd.getEntityType()).andStubReturn(edmEntityType);
    EasyMock.expect(association.getEnd("roleA" + z)).andStubReturn(associationEnd);
    EasyMock.expect(navigationProperty.getRelationship()).andStubReturn(association);
    EdmMapping edmMapping1 = EasyMock.createMock(EdmMapping.class);
    EasyMock.expect(edmMapping1.getInternalName()).andStubReturn("s_Item" + z);
    EasyMock.expect(navigationProperty.getMapping()).andStubReturn(edmMapping1);
    EasyMock.replay(edmMapping, edmMapping1, edmEntityType, associationEnd, association, navigationProperty);
    return navigationProperty;
  }
View Full Code Here

      handlePropertyPath((EdmProperty) property);
      break;

    case ENTITY: // navigation properties point to entities
      final EdmNavigationProperty navigationProperty = (EdmNavigationProperty) property;
      if (keyPredicateName != null || emptyParentheses != null) {
        if (navigationProperty.getMultiplicity() != EdmMultiplicity.MANY) {
          throw new UriSyntaxException(UriSyntaxException.INVALIDSEGMENT.addContent(currentPathSegment));
        }
      }

      addNavigationSegment(keyPredicateName, navigationProperty);

      boolean many = false;
      if (navigationProperty.getMultiplicity() == EdmMultiplicity.MANY) {
        many = keyPredicateName == null;
      }

      if (pathSegments.isEmpty()) {
        if (many) {
View Full Code Here

        final EdmTyped property = fromEntitySet.getEntityType().getProperty(expandPropertyName);
        if (property == null) {
          throw new UriNotMatchingException(UriNotMatchingException.PROPERTYNOTFOUND.addContent(expandPropertyName));
        }
        if (property.getType().getKind() == EdmTypeKind.ENTITY) {
          final EdmNavigationProperty navigationProperty = (EdmNavigationProperty) property;
          fromEntitySet = fromEntitySet.getRelatedEntitySet(navigationProperty);
          NavigationPropertySegmentImpl propertySegment = new NavigationPropertySegmentImpl();
          propertySegment.setNavigationProperty(navigationProperty);
          propertySegment.setTargetEntitySet(fromEntitySet);
          expandNavigationProperties.add(propertySegment);
View Full Code Here

          selectItem.setProperty((EdmProperty) property);
          exit = true;
          break;

        case ENTITY: // navigation properties point to entities
          final EdmNavigationProperty navigationProperty = (EdmNavigationProperty) property;
          final EdmEntitySet targetEntitySet = fromEntitySet.getRelatedEntitySet(navigationProperty);

          NavigationPropertySegmentImpl navigationPropertySegment = new NavigationPropertySegmentImpl();
          navigationPropertySegment.setNavigationProperty(navigationProperty);
          navigationPropertySegment.setTargetEntitySet(targetEntitySet);
View Full Code Here

    EdmEntitySet entitySet = MockFacade.getMockEdm().getDefaultEntityContainer().getEntitySet("Employees");
    // modify edm for test case (change multiplicity to ZERO_TO_ONE)
    EdmType navigationType = mock(EdmType.class);
    when(navigationType.getKind()).thenReturn(EdmTypeKind.ENTITY);

    EdmNavigationProperty navigationProperty = mock(EdmNavigationProperty.class);
    when(navigationProperty.getName()).thenReturn("ne_Team");
    when(navigationProperty.getType()).thenReturn(navigationType);
    when(navigationProperty.getMultiplicity()).thenReturn(EdmMultiplicity.ZERO_TO_ONE);

    when(entitySet.getEntityType().getProperty("ne_Team")).thenReturn(navigationProperty);
    EdmEntitySet targetEntitySet = MockFacade.getMockEdm().getDefaultEntityContainer().getEntitySet("Teams");
    when(entitySet.getRelatedEntitySet(navigationProperty)).thenReturn(targetEntitySet);
View Full Code Here

          break;
        case NAVIGATION:
        case ENTITY:
          if (isCreate) {
            structuralType = (EdmStructuralType) edmTyped.getType();
            EdmNavigationProperty navProperty = (EdmNavigationProperty) edmTyped;
            EdmEntitySet edmRelatedEntitySet = oDataEntitySet.getRelatedEntitySet(navProperty);
            List<ODataEntry> relatedEntries = (List<ODataEntry>) oDataEntryProperties.get(propertyName);
            if (relatedJPAEntityMap == null) {
              relatedJPAEntityMap = new HashMap<String, List<Object>>();
            }
            List<Object> relatedJPAEntities = new ArrayList<Object>();
            JPAEntity relatedEntity =
                new JPAEntity((EdmEntityType) structuralType, edmRelatedEntitySet, oDataJPAContext);
            for (ODataEntry oDataEntry : relatedEntries) {
              relatedEntity.setParentJPAEntity(this);
              relatedEntity.create(oDataEntry);
              relatedJPAEntities.add(relatedEntity.getJPAEntity());
            }
            relatedJPAEntityMap.put(navProperty.getName(), relatedJPAEntities);
          }
        default:
          continue;
        }
      }
View Full Code Here

TOP

Related Classes of org.apache.olingo.odata2.api.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.