org.apache.olingo.odata2.api.uri.info.GetEntitySetUriInfo Java Examples

The following examples show how to use org.apache.olingo.odata2.api.uri.info.GetEntitySetUriInfo. 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: JPAProcessorImplTest.java    From olingo-odata2 with Apache License 2.0 6 votes vote down vote up
private GetEntitySetUriInfo getEntitySetUriInfo() {

    UriInfo objUriInfo = EasyMock.createMock(UriInfo.class);
    EasyMock.expect(objUriInfo.getStartEntitySet()).andStubReturn(getLocalEdmEntitySet());
    EasyMock.expect(objUriInfo.getTargetEntitySet()).andStubReturn(getLocalEdmEntitySet());
    EasyMock.expect(objUriInfo.getSelect()).andStubReturn(null);
    EasyMock.expect(objUriInfo.getOrderBy()).andStubReturn(getOrderByExpression());
    EasyMock.expect(objUriInfo.getTop()).andStubReturn(getTop());
    EasyMock.expect(objUriInfo.getSkip()).andStubReturn(getSkip());
    EasyMock.expect(objUriInfo.getSkipToken()).andReturn("5");
    EasyMock.expect(objUriInfo.getInlineCount()).andStubReturn(getInlineCount());
    EasyMock.expect(objUriInfo.getFilter()).andStubReturn(getFilter());
    EasyMock.expect(objUriInfo.getFunctionImport()).andStubReturn(null);
    EasyMock.expect(objUriInfo.getCustomQueryOptions()).andStubReturn(null);
    EasyMock.expect(objUriInfo.getNavigationSegments()).andStubReturn(new ArrayList<NavigationSegment>());
    EasyMock.replay(objUriInfo);
    return objUriInfo;
  }
 
Example #2
Source File: AcceptHeaderTypeTest.java    From olingo-odata2 with Apache License 2.0 6 votes vote down vote up
private HttpResponse testGetRequest(final String uriExtension, final String acceptHeader,
    final HttpStatusCodes expectedStatus, final String expectedContentType)
    throws ClientProtocolException, IOException, ODataException {
  // prepare
  ODataResponse expectedResponse = ODataResponse.contentHeader(expectedContentType).entity("Test passed.").build();
  when(processor.readMetadata(any(GetMetadataUriInfo.class), any(String.class))).thenReturn(expectedResponse);
  when(processor.readEntity(any(GetEntityUriInfo.class), any(String.class))).thenReturn(expectedResponse);
  when(processor.readEntitySet(any(GetEntitySetUriInfo.class), any(String.class))).thenReturn(expectedResponse);

  HttpGet getRequest = new HttpGet(URI.create(getEndpoint().toString() + uriExtension));
  getRequest.setHeader(HttpHeaders.ACCEPT, acceptHeader);

  // execute
  HttpResponse response = getHttpClient().execute(getRequest);

  // validate
  assertEquals(expectedStatus.getStatusCode(), response.getStatusLine().getStatusCode());
  Header[] contentTypeHeaders = response.getHeaders("Content-Type");
  assertEquals("Found more then one content type header in response.", 1, contentTypeHeaders.length);
  assertEquals("Received content type does not match expected.", expectedContentType, contentTypeHeaders[0]
      .getValue());
  assertEquals("Received status code does not match expected.", expectedStatus.getStatusCode(), response
      .getStatusLine().getStatusCode());
  //
  return response;
}
 
Example #3
Source File: ODataJPAResponseBuilderDefault.java    From olingo-odata2 with Apache License 2.0 6 votes vote down vote up
private static Integer getInlineCountForNonFilterQueryEntitySet(final List<Map<String, Object>> edmEntityList,
    final GetEntitySetUriInfo resultsView) {
  // when $skip and/or $top is present with $inlinecount, first get the total count
  Integer count = null;
  if (resultsView.getInlineCount() == InlineCount.ALLPAGES) {
    count = edmEntityList.size();
    if (resultsView.getCustomQueryOptions() != null) {
      String countValue = resultsView.getCustomQueryOptions().get(COUNT);
      if (countValue != null && isNumeric(countValue)) {
        count = Integer.parseInt(countValue);
        resultsView.getCustomQueryOptions().remove(COUNT);
        if (resultsView.getCustomQueryOptions().size() == 0) {
          ((UriInfoImpl) resultsView).setCustomQueryOptions(null);
        }
      }
    }
  }// Inlinecount of None is handled by default - null
  return count;
}
 
Example #4
Source File: JPATombstoneCallBackTest.java    From olingo-odata2 with Apache License 2.0 6 votes vote down vote up
@Test
public void Test() {

  EdmEntitySet edmEntitySet = EasyMock.createMock(EdmEntitySet.class);
  try {
    EasyMock.expect(edmEntitySet.getName()).andReturn("SalesOrder");
    EasyMock.replay(edmEntitySet);
  } catch (EdmException e) {
    fail("Not Expected");
  }
  GetEntitySetUriInfo resultsView = EasyMock.createMock(GetEntitySetUriInfo.class);
  EasyMock.expect(resultsView.getTargetEntitySet()).andReturn(edmEntitySet);
  EasyMock.replay(resultsView);
  JPATombstoneCallBack tombStoneCallBack = new JPATombstoneCallBack("/sample/", resultsView, "1");

  TombstoneCallbackResult result = tombStoneCallBack.getTombstoneCallbackResult();
  assertEquals("/sample/SalesOrder?!deltatoken=1", result.getDeltaLink());
}
 
Example #5
Source File: JPAProcessorImpl.java    From olingo-odata2 with Apache License 2.0 6 votes vote down vote up
private List<Object> handlePaging(final List<Object> result, final GetEntitySetUriInfo uriParserResultView) {
  if (result == null) {
    return null;
  }
  JPAPageBuilder pageBuilder = new JPAPageBuilder();
  pageBuilder.pageSize(oDataJPAContext.getPageSize())
      .entities(result)
      .skipToken(uriParserResultView.getSkipToken());

  // $top/$skip with $inlinecount case handled in response builder to avoid multiple DB call
  if (uriParserResultView.getSkip() != null) {
    pageBuilder.skip(uriParserResultView.getSkip().intValue());
  }

  if (uriParserResultView.getTop() != null) {
    pageBuilder.top(uriParserResultView.getTop().intValue());
  }

  JPAPage page = pageBuilder.build();
  oDataJPAContext.setPaging(page);

  return page.getPagedEntities();
}
 
Example #6
Source File: JPAProcessorImpl.java    From olingo-odata2 with Apache License 2.0 6 votes vote down vote up
private List<Object> handlePaging(final Query query, final GetEntitySetUriInfo uriParserResultView) {

    JPAPageBuilder pageBuilder = new JPAPageBuilder();
    pageBuilder.pageSize(oDataJPAContext.getPageSize())
        .query(query)
        .skipToken(uriParserResultView.getSkipToken());

    // $top/$skip with $inlinecount case handled in response builder to avoid multiple DB call
    if (uriParserResultView.getSkip() != null) {
      pageBuilder.skip(uriParserResultView.getSkip().intValue());
    }

    if (uriParserResultView.getTop() != null) {
      pageBuilder.top(uriParserResultView.getTop().intValue());
    }

    JPAPage page = pageBuilder.build();
    oDataJPAContext.setPaging(page);

    return page.getPagedEntities();

  }
 
Example #7
Source File: JPAQueryBuilder.java    From olingo-odata2 with Apache License 2.0 6 votes vote down vote up
public JPAQueryInfo build(GetEntitySetUriInfo uriInfo) throws ODataJPARuntimeException {
  JPAQueryInfo queryInfo = new JPAQueryInfo();
  Query query = null;
  try {
    ODataJPATombstoneEntityListener listener = getODataJPATombstoneEntityListener((UriInfo) uriInfo);
    if (listener != null) {
      query = listener.getQuery(uriInfo, em);
      JPQLContext jpqlContext = JPQLContext.getJPQLContext();
      query = getParameterizedQueryForListeners(jpqlContext, query);
    }
    if (query == null) {
      query = buildQuery((UriInfo) uriInfo, UriInfoType.GetEntitySet);
    } else {
      queryInfo.setTombstoneQuery(true);
    }
  } catch (Exception e) {
    throw ODataJPARuntimeException.throwException(
        ODataJPARuntimeException.ERROR_JPQL_QUERY_CREATE, e);
  } finally {
    JPQLContext.removeJPQLContext();
    ODataExpressionParser.removePositionalParametersThreadLocal();
  }
  queryInfo.setQuery(query);
  return queryInfo;
}
 
Example #8
Source File: MapProcessor.java    From olingo-odata2 with Apache License 2.0 6 votes vote down vote up
@Override
public ODataResponse readEntitySet(final GetEntitySetUriInfo uriInfo, final String contentType)
    throws ODataException {
  final EntityProviderWriteProperties properties =
      EntityProviderWriteProperties.serviceRoot(getContext().getPathInfo().getServiceRoot()).build();

  final List<Map<String, Object>> values = new ArrayList<Map<String, Object>>();

  for (final HashMap<String, String> record : records) {
    final HashMap<String, Object> data = new HashMap<String, Object>();

    for (final String pName : uriInfo.getTargetEntitySet().getEntityType().getPropertyNames()) {
      final EdmProperty property = (EdmProperty) uriInfo.getTargetEntitySet().getEntityType().getProperty(pName);
      final String mappedPropertyName = (String) property.getMapping().getObject();
      data.put(pName, record.get(mappedPropertyName));
    }

    values.add(data);
  }

  final ODataResponse response =
      EntityProvider.writeFeed(contentType, uriInfo.getTargetEntitySet(), values, properties);

  return response;
}
 
Example #9
Source File: ODataJPAResponseBuilderTest.java    From olingo-odata2 with Apache License 2.0 5 votes vote down vote up
private GetEntitySetUriInfo mockEntitySetUriInfoForExpand() {

    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
    NavigationPropertySegment navigationPropertySegment = EasyMock.createMock(NavigationPropertySegment.class);
    EasyMock.expect(navigationPropertySegment.getNavigationProperty()).andStubReturn(navigationProperty);
    EasyMock.expect(navigationPropertySegment.getTargetEntitySet()).andStubReturn(getTargetEntitySetForExpand());
    EasyMock.replay(navigationPropertySegment);
    navigationPropertyList.add(navigationPropertySegment);
    expandList.add(navigationPropertyList);
    // Mocking EntityUriInfo
    UriInfoImpl entitySetUriInfo = EasyMock.createMock(UriInfoImpl.class);
    EasyMock.expect(entitySetUriInfo.getSelect()).andStubReturn(selectItemList);
    EasyMock.expect(entitySetUriInfo.getExpand()).andStubReturn(expandList);
    EasyMock.expect(entitySetUriInfo.getInlineCount()).andStubReturn(InlineCount.ALLPAGES);
    EasyMock.expect(entitySetUriInfo.getSkip()).andStubReturn(new Integer(1));
    EasyMock.expect(entitySetUriInfo.getTop()).andStubReturn(new Integer(2));
    Map<String, String> customQuery = new HashMap<String, String>();
    customQuery.put("count", "5");
    entitySetUriInfo.setCustomQueryOptions(null);
    EasyMock.expectLastCall().times(1);
    EasyMock.expect(entitySetUriInfo.getCustomQueryOptions()).andStubReturn(customQuery );
    EasyMock.replay(entitySetUriInfo);
    return entitySetUriInfo;
  }
 
Example #10
Source File: MyODataSingleProcessor.java    From wildfly-camel with Apache License 2.0 5 votes vote down vote up
@Override
public ODataResponse readEntitySet(GetEntitySetUriInfo uriInfo, String contentType) throws ODataException {

    EdmEntitySet entitySet;

    if (uriInfo.getNavigationSegments().size() == 0) {
        entitySet = uriInfo.getStartEntitySet();

        if (ENTITY_SET_NAME_CARS.equals(entitySet.getName())) {
            return EntityProvider.writeFeed(contentType, entitySet, dataStore.getCars(), EntityProviderWriteProperties.serviceRoot(getContext().getPathInfo().getServiceRoot()).build());
        } else if (ENTITY_SET_NAME_MANUFACTURERS.equals(entitySet.getName())) {
            return EntityProvider.writeFeed(contentType, entitySet, dataStore.getManufacturers(), EntityProviderWriteProperties.serviceRoot(getContext().getPathInfo().getServiceRoot()).build());
        }

        throw new ODataNotFoundException(ODataNotFoundException.ENTITY);

    } else if (uriInfo.getNavigationSegments().size() == 1) {
        //navigation first level, simplified example for illustration purposes only
        entitySet = uriInfo.getTargetEntitySet();

        if (ENTITY_SET_NAME_CARS.equals(entitySet.getName())) {
            int manufacturerKey = getKeyValue(uriInfo.getKeyPredicates().get(0));

            List<Map<String, Object>> cars = new ArrayList<>();
            cars.addAll(dataStore.getCarsFor(manufacturerKey));

            return EntityProvider.writeFeed(contentType, entitySet, cars, EntityProviderWriteProperties.serviceRoot(getContext().getPathInfo().getServiceRoot()).build());
        }

        throw new ODataNotFoundException(ODataNotFoundException.ENTITY);
    }

    throw new ODataNotImplementedException();
}
 
Example #11
Source File: CarODataSingleProcessor.java    From olingo-odata2 with Apache License 2.0 5 votes vote down vote up
@Override
public ODataResponse readEntitySet(final GetEntitySetUriInfo uriInfo, final String contentType) 
    throws ODataException {

  EdmEntitySet entitySet;

  if (uriInfo.getNavigationSegments().size() == 0) {
    entitySet = uriInfo.getStartEntitySet();

    if (ENTITY_SET_NAME_CARS.equals(entitySet.getName())) {
      return EntityProvider.writeFeed(contentType, entitySet, dataStore.getCars(),
          EntityProviderWriteProperties.serviceRoot(getContext().getPathInfo().getServiceRoot()).build());
    } else if (ENTITY_SET_NAME_MANUFACTURERS.equals(entitySet.getName())) {
      return EntityProvider.writeFeed(contentType, entitySet, dataStore.getManufacturers(),
          EntityProviderWriteProperties.serviceRoot(getContext().getPathInfo().getServiceRoot()).build());
    }

    throw new ODataNotFoundException(ODataNotFoundException.ENTITY);

  } else if (uriInfo.getNavigationSegments().size() == 1) {
    // navigation first level, simplified example for illustration purposes only
    entitySet = uriInfo.getTargetEntitySet();

    if (ENTITY_SET_NAME_CARS.equals(entitySet.getName())) {
      int manufacturerKey = getKeyValue(uriInfo.getKeyPredicates().get(0));

      List<Map<String, Object>> cars = new ArrayList<Map<String, Object>>();
      cars.addAll(dataStore.getCarsFor(manufacturerKey));

      return EntityProvider.writeFeed(contentType, entitySet, cars, EntityProviderWriteProperties.serviceRoot(
          getContext().getPathInfo().getServiceRoot()).build());
    }

    throw new ODataNotFoundException(ODataNotFoundException.ENTITY);
  }

  throw new ODataNotImplementedException();
}
 
Example #12
Source File: AcceptHeaderTypeTest.java    From olingo-odata2 with Apache License 2.0 5 votes vote down vote up
@Override
protected ODataSingleProcessor createProcessor() throws ODataException {
  String contentType = "application/atom+xml";
  ODataResponse response =
      ODataResponse.status(HttpStatusCodes.OK).contentHeader(contentType).entity("Test passed.").build();
  when(processor.readEntity(any(GetEntityUriInfo.class), any(String.class))).thenReturn(response);
  when(processor.readEntitySet(any(GetEntitySetUriInfo.class), any(String.class))).thenReturn(response);

  return processor;
}
 
Example #13
Source File: InvalidDataInScenarioTest.java    From olingo-odata2 with Apache License 2.0 5 votes vote down vote up
@Override
public ODataResponse readEntitySet(GetEntitySetUriInfo uriInfo, String contentType) throws ODataException {
  if ("Employees".equals(uriInfo.getTargetEntitySet().getName())) {
    ODataContext context = getContext();
    EntityProviderWriteProperties writeProperties =
        EntityProviderWriteProperties.serviceRoot(context.getPathInfo().getServiceRoot()).build();
    List<Map<String, Object>> data = new ArrayList<Map<String, Object>>();
    data.add(new HashMap<String, Object>());
    return EntityProvider.writeFeed(contentType, uriInfo.getTargetEntitySet(), data, writeProperties);
  } else {
    throw new ODataApplicationException("Wrong testcall", Locale.getDefault(), HttpStatusCodes.NOT_IMPLEMENTED);
  }
}
 
Example #14
Source File: AtomFeedSerializerTest.java    From olingo-odata2 with Apache License 2.0 5 votes vote down vote up
@Before
public void before() throws Exception {
  initializeRoomData(1);

  view = mock(GetEntitySetUriInfo.class);

  EdmEntitySet set = MockFacade.getMockEdm().getDefaultEntityContainer().getEntitySet("Rooms");
  when(view.getTargetEntitySet()).thenReturn(set);
}
 
Example #15
Source File: CustomODataJPAProcessor.java    From olingo-odata2 with Apache License 2.0 5 votes vote down vote up
@Override
public ODataResponse readEntitySet(final GetEntitySetUriInfo uriParserResultView, final String contentType)
    throws ODataException {

  int readCount = READ_COUNT.incrementAndGet();
  LOG.log(Level.INFO, "Start read access number '" + readCount + "' for '" +
      uriParserResultView.getTargetEntitySet().getName() + "'.");
  long start = System.currentTimeMillis();
  List<Object> jpaEntities = jpaProcessor.process(uriParserResultView);
  ODataResponse oDataResponse = responseBuilder.build(uriParserResultView, jpaEntities, contentType);
  long duration = System.currentTimeMillis() - start;
  LOG.log(Level.INFO, "Finished read access number '" + readCount + "' after '" + duration + "'ms.");

  return oDataResponse;
}
 
Example #16
Source File: JPAQueryBuilderTest.java    From olingo-odata2 with Apache License 2.0 5 votes vote down vote up
@Test
public void buildQueryWithKeyNavSegmentAndFilter() {
  EdmMapping mapping = (EdmMapping) mockMapping();
  try {
    assertNotNull(builder.build((GetEntitySetUriInfo) mockURIInfoWithKeyNavSegAndFilter(mapping)));
  } catch (ODataException e) {
    fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
  }
}
 
Example #17
Source File: JPAQueryBuilderTest.java    From olingo-odata2 with Apache License 2.0 5 votes vote down vote up
@Test
public void buildQueryGetEntitySetTestWithNormalizationWithtoUpper() {
  EdmMapping mapping = (EdmMapping) mockNormalizedMapping();
  try {
    assertNotNull(builder.build((GetEntitySetUriInfo) 
        mockURIInfoForEntitySetWithBinaryFilterExpression(mapping, "toUpper")));
  } catch (ODataException e) {
    fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
  }
}
 
Example #18
Source File: ODataJPAResponseBuilderTest.java    From olingo-odata2 with Apache License 2.0 5 votes vote down vote up
private GetEntitySetUriInfo getResultsViewWithNullSelects() {
  GetEntitySetUriInfo objGetEntitySetUriInfo = EasyMock.createMock(GetEntitySetUriInfo.class);
  EasyMock.expect(objGetEntitySetUriInfo.getInlineCount()).andStubReturn(getLocalInlineCount());
  EasyMock.expect(objGetEntitySetUriInfo.getTargetEntitySet()).andStubReturn(getLocalTargetEntitySet());
  EasyMock.expect(objGetEntitySetUriInfo.getSelect()).andStubReturn(null);
  EasyMock.expect(objGetEntitySetUriInfo.getExpand()).andStubReturn(null);
  EasyMock.expect(objGetEntitySetUriInfo.getSkip()).andStubReturn(new Integer(1));

  EasyMock.replay(objGetEntitySetUriInfo);
  return objGetEntitySetUriInfo;
}
 
Example #19
Source File: CustomerQueryExtension.java    From olingo-odata2 with Apache License 2.0 5 votes vote down vote up
@Override
public Query getQuery(GetEntitySetUriInfo uriInfo, EntityManager em) throws ODataJPARuntimeException {
  FilterExpression filter = uriInfo.getFilter();
  if(filter != null && filter.getExpressionString().startsWith("name")) {
    throw createApplicationError("Filter on name not allowed.", Locale.ENGLISH);
  }
  return null;
}
 
Example #20
Source File: AtomFeedProducerTest.java    From olingo-odata2 with Apache License 2.0 5 votes vote down vote up
@Before
public void before() throws Exception {
  initializeRoomData(1);

  view = mock(GetEntitySetUriInfo.class);

  EdmEntitySet set = MockFacade.getMockEdm().getDefaultEntityContainer().getEntitySet("Rooms");
  when(view.getTargetEntitySet()).thenReturn(set);
}
 
Example #21
Source File: ODataJPAResponseBuilderTest.java    From olingo-odata2 with Apache License 2.0 5 votes vote down vote up
private GetEntitySetUriInfo getResultsView() {
  GetEntitySetUriInfo objGetEntitySetUriInfo = EasyMock.createMock(GetEntitySetUriInfo.class);
  EasyMock.expect(objGetEntitySetUriInfo.getInlineCount()).andStubReturn(getLocalInlineCount());
  EasyMock.expect(objGetEntitySetUriInfo.getTargetEntitySet()).andStubReturn(getLocalTargetEntitySet());
  EasyMock.expect(objGetEntitySetUriInfo.getSelect()).andStubReturn(getSelectItemList());
  EasyMock.expect(objGetEntitySetUriInfo.getExpand()).andStubReturn(getExpandList());
  EasyMock.expect(objGetEntitySetUriInfo.getSkip()).andStubReturn(new Integer(1));
  EasyMock.replay(objGetEntitySetUriInfo);
  return objGetEntitySetUriInfo;
}
 
Example #22
Source File: ODataJPADefaultProcessor.java    From olingo-odata2 with Apache License 2.0 5 votes vote down vote up
@Override
public ODataResponse readEntitySet(final GetEntitySetUriInfo uriParserResultView, final String contentType)
    throws ODataException {
  ODataResponse oDataResponse = null;
  try {
    oDataJPAContext.setODataContext(getContext());
    List<Object> jpaEntities = jpaProcessor.process(uriParserResultView);
    oDataResponse =
        responseBuilder.build(uriParserResultView, jpaEntities, contentType);
  } finally {
    close();
  }
  return oDataResponse;
}
 
Example #23
Source File: JPAQueryBuilderTest.java    From olingo-odata2 with Apache License 2.0 5 votes vote down vote up
@Test
public void buildQueryWithTopSkipInlineWithListener() {
  try {
    GetEntitySetUriInfo uriInfo = (GetEntitySetUriInfo)mockURIInfoWithTopSkipInlineListener();
    builder.getCount(uriInfo);
  } catch (ODataException e) {
    fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
  }
}
 
Example #24
Source File: JPAQueryBuilderTest.java    From olingo-odata2 with Apache License 2.0 5 votes vote down vote up
@Test
public void buildQueryWithTopSkipInline() {
  EdmMapping mapping = (EdmMapping) mockMapping();
  try {
    GetEntitySetUriInfo uriInfo = (GetEntitySetUriInfo) mockURIInfoWithTopSkipInline(mapping);
    builder.getCount(uriInfo);
    assertNotNull(uriInfo.getCustomQueryOptions().get("count"));
  } catch (ODataException e) {
    fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
  }
}
 
Example #25
Source File: JPAQueryBuilderTest.java    From olingo-odata2 with Apache License 2.0 5 votes vote down vote up
@Test
public void buildQueryWithTopSkip() {
  EdmMapping mapping = (EdmMapping) mockMapping();
  try {
    assertNotNull(builder.build((GetEntitySetUriInfo) mockURIInfoWithTopSkip(mapping)));
  } catch (ODataException e) {
    fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
  }
}
 
Example #26
Source File: JPAQueryBuilderTest.java    From olingo-odata2 with Apache License 2.0 5 votes vote down vote up
@Test
public void buildQueryGetEntitySetTestWithNormalizationWithSubstringof1() {
  EdmMapping mapping = (EdmMapping) mockNormalizedMapping1();
  try {
    assertNotNull(builder.build((GetEntitySetUriInfo) 
        mockURIInfoForEntitySet(mapping, "substringof_1")));
  } catch (ODataException e) {
    fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
  }
}
 
Example #27
Source File: JPAQueryBuilderTest.java    From olingo-odata2 with Apache License 2.0 5 votes vote down vote up
@Test
public void buildQueryGetEntitySetTestWithNoNormalizationWithtoUpper() {
  EdmMapping mapping = (EdmMapping) mockNormalizedValueMapping();
  try {
    assertNotNull(builder.build((GetEntitySetUriInfo) 
        mockURIInfoForEntitySetWithBinaryFilterExpression(mapping, "toUpper")));
  } catch (ODataException e) {
    fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
  }
}
 
Example #28
Source File: ODataJPAProcessor.java    From lemonaid with MIT License 5 votes vote down vote up
@Override
public ODataResponse readEntitySet(GetEntitySetUriInfo uriParserResultView, final String contentType)
		throws ODataException {
	authorization.check(READ, uriParserResultView);
	ODataResponse oDataResponse = null;
	augmentFilter((UriInfoImpl) uriParserResultView);
	try {
		oDataJPAContext.setODataContext(getContext());
		List<Object> jpaEntities = jpaProcessor.process(uriParserResultView);
           jpaEntities = enrichEntities(uriParserResultView, jpaEntities);
           for(Object jpaEntity : jpaEntities){
               if (jpaEntity instanceof Mentor) {
			    if (!authorization.isMentor() && !authorization.isProjectMember()) {

                   }else{
                       ((Mentor) jpaEntity).setPublicLongitude(((Mentor) jpaEntity).getLongitude());
                       ((Mentor) jpaEntity).setPublicLatitude(((Mentor) jpaEntity).getLatitude());
                   }

               }
           }
		oDataResponse = responseBuilder.build(uriParserResultView, jpaEntities, contentType);
	} finally {
		close();
	}
	return oDataResponse;
}
 
Example #29
Source File: JPAQueryBuilderTest.java    From olingo-odata2 with Apache License 2.0 5 votes vote down vote up
@Test
public void buildQueryGetEntitySetTestWithNoNormalizationWithtoLower() {
  EdmMapping mapping = (EdmMapping) mockNormalizedValueMapping();
  try {
    assertNotNull(builder.build((GetEntitySetUriInfo) 
        mockURIInfoForEntitySetWithBinaryFilterExpression(mapping, "toLower")));
  } catch (ODataException e) {
    fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
  }
}
 
Example #30
Source File: JPAQueryBuilderTest.java    From olingo-odata2 with Apache License 2.0 5 votes vote down vote up
@Test
public void buildQueryGetEntitySetTestWithNormalizationWithtoLower() {
  EdmMapping mapping = (EdmMapping) mockNormalizedMapping();
  try {
    assertNotNull(builder.build((GetEntitySetUriInfo) 
        mockURIInfoForEntitySetWithBinaryFilterExpression(mapping, "toLower")));
  } catch (ODataException e) {
    fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
  }
}