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


          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

      for (String navigationPropertyName : oDataEntityType.getNavigationPropertyNames()) {
        List<String> links = entryMetadata.getAssociationUris(navigationPropertyName);
        if (links.isEmpty()) {
          continue;
        } else {
          EdmNavigationProperty navProperty =
              (EdmNavigationProperty) oDataEntityType.getProperty(navigationPropertyName);
          if (relatedJPAEntityMap != null && relatedJPAEntityMap.containsKey(navigationPropertyName)) {
            JPALink.linkJPAEntities(relatedJPAEntityMap.get(navigationPropertyName), jpaEntity,
                navProperty);
          } else if (parentJPAEntity != null
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

    List<SelectItem> selectItemList = new ArrayList<SelectItem>();
    List<ArrayList<NavigationPropertySegment>> expandList = new ArrayList<ArrayList<NavigationPropertySegment>>();
    ArrayList<NavigationPropertySegment> navigationPropertyList = new ArrayList<NavigationPropertySegment>();
    // Mocking the navigation property
    EdmNavigationProperty navigationProperty = EasyMock.createMock(EdmNavigationProperty.class);
    try {
      EasyMock.expect(navigationProperty.getName()).andStubReturn("SalesOrderItemDetails");
    } catch (EdmException e) {
      fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
    }
    EasyMock.replay(navigationProperty);
    // Mocking the navigation property segments and adding to expand list
View Full Code Here

    List<SelectItem> selectItemList = new ArrayList<SelectItem>();
    List<ArrayList<NavigationPropertySegment>> expandList = new ArrayList<ArrayList<NavigationPropertySegment>>();
    ArrayList<NavigationPropertySegment> navigationPropertyList = new ArrayList<NavigationPropertySegment>();
    // Mocking the navigation property
    EdmNavigationProperty navigationProperty = EasyMock.createMock(EdmNavigationProperty.class);
    try {
      EasyMock.expect(navigationProperty.getName()).andStubReturn("SalesOrderItemDetails");
    } catch (EdmException e) {
      fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
    }
    EasyMock.replay(navigationProperty);
    // Mocking the navigation property segments and adding to expand list
View Full Code Here

    EasyMock.replay(entitySet);
    return entitySet;
  }

  private NavigationPropertySegment getNavigationPropertySegment(final String navPropertyName) {
    EdmNavigationProperty navigationProperty = EasyMock.createMock(EdmNavigationProperty.class);
    try {
      EasyMock.expect(navigationProperty.getName()).andStubReturn(navPropertyName);
    } catch (EdmException e) {
      fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
    }
    EasyMock.replay(navigationProperty);
    NavigationPropertySegment navPropertySegment = EasyMock.createMock(NavigationPropertySegment.class);
View Full Code Here

  public void testGetNextNavigationProperty() {
    JPAExpandCallBack callBack = getJPAExpandCallBackObject();
    List<ArrayList<NavigationPropertySegment>> expandList = EdmMockUtil.getExpandList();
    ArrayList<NavigationPropertySegment> expands = expandList.get(0);
    expands.add(EdmMockUtil.mockThirdNavigationPropertySegment());
    EdmNavigationProperty result = null;
    try {
      Field field = callBack.getClass().getDeclaredField("expandList");
      field.setAccessible(true);
      field.set(callBack, expandList);
      Class<?>[] formalParams = { EdmEntityType.class, EdmNavigationProperty.class };
      Object[] actualParams = { EdmMockUtil.mockSourceEdmEntityType(), EdmMockUtil.mockNavigationProperty() };
      Method method = callBack.getClass().getDeclaredMethod("getNextNavigationProperty", formalParams);
      method.setAccessible(true);
      result = (EdmNavigationProperty) method.invoke(callBack, actualParams);
      assertEquals("MaterialDetails", result.getName());

    } catch (SecurityException e) {
      fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
    } catch (NoSuchFieldException e) {
      fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
View Full Code Here

        } else {
          throw new EntityProviderException(EntityProviderException.ILLEGAL_ARGUMENT.addContent(uri));
        }
        reader.endObject();
      } else {
        EdmNavigationProperty navigationProperty =
            (EdmNavigationProperty) eia.getEntityType().getProperty(navigationPropertyName);
        EdmEntitySet inlineEntitySet = eia.getEntitySet().getRelatedEntitySet(navigationProperty);
        EntityInfoAggregator inlineEia = EntityInfoAggregator.create(inlineEntitySet);
        EntityProviderReadProperties inlineReadProperties;
        OnReadInlineContent callback = readProperties.getCallback();
        try {
          if (callback == null) {
            inlineReadProperties =
                EntityProviderReadProperties.init()
                    .mergeSemantic(readProperties.getMergeSemantic())
                    .isValidatingFacets(readProperties.isValidatingFacets())
                    .build();

          } else {
            inlineReadProperties = callback.receiveReadProperties(readProperties, navigationProperty);
          }

          if (navigationProperty.getMultiplicity() == EdmMultiplicity.MANY) {
            JsonFeedConsumer inlineConsumer = new JsonFeedConsumer(reader, inlineEia, inlineReadProperties);
            ODataFeed feed = inlineConsumer.readStartedInlineFeed(name);
            updateExpandSelectTree(navigationPropertyName, feed);
            if (callback == null) {
              properties.put(navigationPropertyName, feed);
              resultEntry.setContainsInlineEntry(true);
            } else {
              ReadFeedResult result = new ReadFeedResult(inlineReadProperties, navigationProperty, feed);
              callback.handleReadFeed(result);
            }
          } else {
            JsonEntryConsumer inlineConsumer = new JsonEntryConsumer(reader, inlineEia, inlineReadProperties);
            ODataEntry entry = inlineConsumer.readInlineEntry(name);
            updateExpandSelectTree(navigationPropertyName, entry);
            if (callback == null) {
              properties.put(navigationPropertyName, entry);
              resultEntry.setContainsInlineEntry(true);
            } else {
              ReadEntryResult result = new ReadEntryResult(inlineReadProperties, navigationProperty, entry);
              callback.handleReadEntry(result);
            }
          }

        } catch (ODataApplicationException e) {
          throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass()
              .getSimpleName()), e);
        }
      }
      reader.endObject();
    } else if (peek == JsonToken.NULL) {
      reader.nextNull();
    } else {
      final EdmNavigationProperty navigationProperty =
          (EdmNavigationProperty) eia.getEntityType().getProperty(navigationPropertyName);
      final EdmEntitySet inlineEntitySet = eia.getEntitySet().getRelatedEntitySet(navigationProperty);
      final EntityInfoAggregator inlineInfo = EntityInfoAggregator.create(inlineEntitySet);
      OnReadInlineContent callback = readProperties.getCallback();
      EntityProviderReadProperties inlineReadProperties;
View Full Code Here

  private <T> void createInlinedEntities(final EdmEntitySet entitySet, final T data, final ODataEntry entryValues)
      throws ODataException {
    final EdmEntityType entityType = entitySet.getEntityType();
    for (final String navigationPropertyName : entityType.getNavigationPropertyNames()) {

      final EdmNavigationProperty navigationProperty =
          (EdmNavigationProperty) entityType.getProperty(navigationPropertyName);
      final EdmEntitySet relatedEntitySet = entitySet.getRelatedEntitySet(navigationProperty);
      final EdmEntityType relatedEntityType = relatedEntitySet.getEntityType();

      final Object relatedValue = entryValues.getProperties().get(navigationPropertyName);
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.