@Test public void testOrderByCollectionOrderByCountAsc() throws IOException, ODataException { final JPAEntityType jpaEntity = getHelper().getJPAEntityType(CollectionDeep.class); final From<?, ?> target = cb.createQuery().from(getHelper().getEntityType(CollectionDeep.class)); cut = new JPAOrderByBuilder(jpaEntity, target, cb, groups); final List<UriResource> pathParts = createOrderByClause(Boolean.FALSE); final UriResourceProperty firstLevelPart = mock(UriResourceComplexProperty.class); final UriResourceProperty secondLevelPart = mock(UriResourceComplexProperty.class); final UriResourceProperty commentPart = mock(UriResourceProperty.class); final UriResourceCount countPart = mock(UriResourceCount.class); when(commentPart.isCollection()).thenReturn(Boolean.TRUE); pathParts.add(firstLevelPart); pathParts.add(secondLevelPart); pathParts.add(commentPart); pathParts.add(countPart); createComplexEdmProperty(firstLevelPart, "FirstLevel"); createComplexEdmProperty(secondLevelPart, "SecondLevel"); createPrimitiveEdmProperty(commentPart, "Comment"); joinTables.put("FirstLevel/SecondLevel/Comment", cb.createQuery().from(getHelper().getEntityType(BusinessPartnerRole.class))); final List<Order> act = cut.createOrderByList(joinTables, uriResource); assertEquals(1, act.size()); assertTrue(act.get(0).isAscending()); assertEquals("COUNT", ((FunctionExpressionImpl<?>) act.get(0).getExpression()).getOperation()); }
@Nonnull List<Order> createOrderByList(@Nonnull final Map<String, From<?, ?>> joinTables, @Nonnull final UriInfoResource uriResource) throws ODataApplicationException { final List<Order> result = new ArrayList<>(); try { if (uriResource.getOrderByOption() != null) { addOrderByFromUriResource(joinTables, result, uriResource.getOrderByOption()); } if (uriResource.getTopOption() != null || uriResource.getSkipOption() != null) { addOrderByPrimaryKey(result); } } catch (final ODataJPAModelException e) { throw new ODataJPAQueryException(e, BAD_REQUEST); } return result; }
JPAOrderByBuilder { @Nonnull List<Order> createOrderByList(@Nonnull final Map<String, From<?, ?>> joinTables, @Nonnull final UriInfoResource uriResource) throws ODataApplicationException { final List<Order> result = new ArrayList<>(); try { if (uriResource.getOrderByOption() != null) { addOrderByFromUriResource(joinTables, result, uriResource.getOrderByOption()); } if (uriResource.getTopOption() != null || uriResource.getSkipOption() != null) { addOrderByPrimaryKey(result); } } catch (final ODataJPAModelException e) { throw new ODataJPAQueryException(e, BAD_REQUEST); } return result; } }
JPAOrderByBuilder { @Nonnull List<Order> createOrderByList(@Nonnull final Map<String, From<?, ?>> joinTables, @Nonnull final UriInfoResource uriResource) throws ODataApplicationException { final List<Order> result = new ArrayList<>(); try { if (uriResource.getOrderByOption() != null) { addOrderByFromUriResource(joinTables, result, uriResource.getOrderByOption()); } if (uriResource.getTopOption() != null || uriResource.getSkipOption() != null) { addOrderByPrimaryKey(result); } } catch (final ODataJPAModelException e) { throw new ODataJPAQueryException(e, BAD_REQUEST); } return result; } JPAOrderByBuilder(final JPAEntityType jpaEntity, final From<?, ?> target, final CriteriaBuilder cb,
      final List<String> groups); }
JPAOrderByBuilder { @Nonnull List<Order> createOrderByList(@Nonnull final Map<String, From<?, ?>> joinTables, @Nonnull final UriInfoResource uriResource) throws ODataApplicationException { final List<Order> result = new ArrayList<>(); try { if (uriResource.getOrderByOption() != null) { addOrderByFromUriResource(joinTables, result, uriResource.getOrderByOption()); } if (uriResource.getTopOption() != null || uriResource.getSkipOption() != null) { addOrderByPrimaryKey(result); } } catch (final ODataJPAModelException e) { throw new ODataJPAQueryException(e, BAD_REQUEST); } return result; } JPAOrderByBuilder(final JPAEntityType jpaEntity, final From<?, ?> target, final CriteriaBuilder cb,
      final List<String> groups);  }
JPAOrderByBuilder { @Nonnull List<Order> createOrderByList(@Nonnull final Map<String, From<?, ?>> joinTables, @Nonnull final UriInfoResource uriResource) throws ODataApplicationException { final List<Order> result = new ArrayList<>(); try { if (uriResource.getOrderByOption() != null) { addOrderByFromUriResource(joinTables, result, uriResource.getOrderByOption()); } if (uriResource.getTopOption() != null || uriResource.getSkipOption() != null) { addOrderByPrimaryKey(result); } } catch (final ODataJPAModelException e) { throw new ODataJPAQueryException(e, BAD_REQUEST); } return result; } JPAOrderByBuilder(final JPAEntityType jpaEntity, final From<?, ?> target, final CriteriaBuilder cb,
      final List<String> groups);   }