org.apache.olingo.odata2.api.uri.UriInfo Java Examples
The following examples show how to use
org.apache.olingo.odata2.api.uri.UriInfo.
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: ODataDebugResponseWrapperTest.java From olingo-odata2 with Apache License 2.0 | 6 votes |
@Test public void server() throws Exception { ODataContext context = mockContext(ODataHttpMethod.GET); HttpServletRequest servletRequest = mock(HttpServletRequest.class); when(servletRequest.getServerPort()).thenReturn(12345); when(context.getParameter(ODataContext.HTTP_SERVLET_REQUEST_OBJECT)).thenReturn(servletRequest); final ODataResponse wrappedResponse = mockResponse(HttpStatusCodes.OK, null, null); ODataResponse response = new ODataDebugResponseWrapper(context, wrappedResponse, mock(UriInfo.class), null, ODataDebugResponseWrapper.ODATA_DEBUG_JSON).wrapResponse(); String entity = StringHelper.inputStreamToString((InputStream) response.getEntity()); assertEquals(EXPECTED.replace("null}}", "null,\"environment\":{\"serverPort\":\"12345\"}}}"), entity); response = new ODataDebugResponseWrapper(context, wrappedResponse, mock(UriInfo.class), null, ODataDebugResponseWrapper.ODATA_DEBUG_HTML).wrapResponse(); entity = StringHelper.inputStreamToString((InputStream) response.getEntity()); assertTrue(entity.contains("<td class=\"name\">serverPort</td><td class=\"value\">12345</td>")); }
Example #2
Source File: JPAQueryBuilderTest.java From olingo-odata2 with Apache License 2.0 | 6 votes |
private List<NavigationSegment> mockNavigationSegments(EdmEntityType edmEntityType, UriInfo uriInfo, EdmEntitySet navEntitySet, EdmEntityType navEntityType) throws EdmException { List<NavigationSegment> navSegments = new ArrayList<NavigationSegment>(); NavigationSegment navSegment = EasyMock.createMock(NavigationSegment.class); EasyMock.expect(navSegment.getEntitySet()).andStubReturn(navEntitySet); EasyMock.expect(navSegment.getKeyPredicates()).andStubReturn(new ArrayList<KeyPredicate>()); EdmNavigationProperty edmNavProperty = EasyMock.createMock(EdmNavigationProperty.class); EasyMock.expect(navSegment.getNavigationProperty()).andStubReturn(edmNavProperty); EasyMock.expect(edmNavProperty.getFromRole()).andStubReturn("Customers"); EasyMock.expect(edmNavProperty.getToRole()).andStubReturn("SalesOrderHeader"); EasyMock.expect(edmNavProperty.getMapping()).andStubReturn((EdmMapping) mockNavEdmMappingForProperty()); EdmAssociation association = EasyMock.createMock(EdmAssociation.class); EasyMock.expect(edmNavProperty.getRelationship()).andStubReturn(association); EdmAssociationEnd associationEnd = EasyMock.createMock(EdmAssociationEnd.class); EasyMock.expect(associationEnd.getEntityType()).andStubReturn(edmEntityType); EasyMock.expect(association.getEnd("Customers")).andStubReturn(associationEnd); navSegments.add(navSegment); EasyMock.expect(uriInfo.getNavigationSegments()).andStubReturn(navSegments); EasyMock.replay(navSegment, edmNavProperty, association, associationEnd); return navSegments; }
Example #3
Source File: ODataClient.java From DataHubSystem with GNU Affero General Public License v3.0 | 6 votes |
/** * Creates a UriInfo from a resource path and query parameters. * The returned object may be one of UriInfo subclasses. * * @param resource_path path to a resource on the OData service. * @param query_parameters OData query parameters, can be {@code null} * * @return an UriInfo instance exposing informations about each segment of * the resource path and the query parameters. * * @throws UriSyntaxException violation of the OData URI construction rules. * @throws UriNotMatchingException URI parsing exception. * @throws EdmException if a problem occurs while reading the EDM. * @throws ODataException encapsulate the OData exceptions described above. */ public UriInfo parseRequest (String resource_path, Map<String, String> query_parameters) throws ODataException { List<PathSegment> path_segments; if (resource_path != null && !resource_path.isEmpty ()) { path_segments = new ArrayList<> (); StringTokenizer st = new StringTokenizer (resource_path, "/"); while (st.hasMoreTokens ()) { path_segments.add(UriParser.createPathSegment(st.nextToken(), null)); } } else path_segments = Collections.emptyList (); if (query_parameters == null) query_parameters = Collections.emptyMap (); return this.uriParser.parse (path_segments, query_parameters); }
Example #4
Source File: EntitySetTest.java From olingo-odata2 with Apache License 2.0 | 6 votes |
private UriInfo mockUriResult(final String entitySetName) throws ODataException, URISyntaxException { EdmEntityType entityType = mock(EdmEntityType.class); when(entityType.getName()).thenReturn(entitySetName); EdmEntityContainer entityContainer = mock(EdmEntityContainer.class); when(entityContainer.isDefaultEntityContainer()).thenReturn(true); EdmEntitySet entitySet = mock(EdmEntitySet.class); when(entitySet.getName()).thenReturn(entitySetName); when(entitySet.getEntityType()).thenReturn(entityType); when(entitySet.getEntityContainer()).thenReturn(entityContainer); UriInfo uriResult = mock(UriInfo.class); when(uriResult.getStartEntitySet()).thenReturn(entitySet); when(uriResult.getTargetEntitySet()).thenReturn(entitySet); when(uriResult.getTop()).thenReturn(null); return uriResult; }
Example #5
Source File: ODataEntityParser.java From olingo-odata2 with Apache License 2.0 | 6 votes |
public final UriInfo parseURISegment(final int segmentFromIndex, final int segmentToIndex) throws ODataJPARuntimeException { UriInfo uriInfo = null; if (segmentFromIndex == segmentToIndex || segmentFromIndex > segmentToIndex || segmentFromIndex < 0) { return uriInfo; } try { edm = getEdm(); List<PathSegment> pathSegments = context.getODataContext().getPathInfo().getODataSegments(); List<PathSegment> subPathSegments = pathSegments.subList(segmentFromIndex, segmentToIndex); uriInfo = UriParser.parse(edm, subPathSegments, Collections.<String, String> emptyMap()); } catch (ODataException e) { throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e); } return uriInfo; }
Example #6
Source File: ODataEntityParser.java From olingo-odata2 with Apache License 2.0 | 6 votes |
public final UriInfo parseLink(final EdmEntitySet entitySet, final InputStream content, final String contentType) throws ODataJPARuntimeException { String uriString = null; UriInfo uri = null; try { uriString = EntityProvider.readLink(contentType, entitySet, content); ODataContext odataContext = context.getODataContext(); final String svcRoot = odataContext.getPathInfo().getServiceRoot().toString(); final String path = uriString.startsWith(svcRoot.toString()) ? uriString.substring(svcRoot.length()) : uriString; final List<PathSegment> pathSegment = getPathSegment(path); edm = getEdm(); uri = UriParser.parse(edm, pathSegment, Collections.<String, String> emptyMap()); } catch (ODataException e) { throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e); } return uri; }
Example #7
Source File: JPAQueryBuilderTest.java From olingo-odata2 with Apache License 2.0 | 6 votes |
@SuppressWarnings("unchecked") private GetEntityUriInfo mockURIInfoWithTopSkip(EdmMapping mapping) throws EdmException { UriInfo uriInfo = EasyMock.createMock(UriInfo.class); List<NavigationSegment> navSegments = new ArrayList<NavigationSegment>(); EasyMock.expect(uriInfo.getNavigationSegments()).andStubReturn(navSegments); EdmEntityType edmEntityType = EasyMock.createMock(EdmEntityType.class); EasyMock.expect(edmEntityType.getMapping()).andStubReturn(mapping); EdmEntitySet edmEntitySet = EasyMock.createMock(EdmEntitySet.class); EasyMock.expect(edmEntitySet.getEntityType()).andStubReturn(edmEntityType); EasyMock.expect(uriInfo.getTargetEntitySet()).andStubReturn(edmEntitySet); List<KeyPredicate> keyPreds = EasyMock.createMock(ArrayList.class); EasyMock.expect(uriInfo.getKeyPredicates()).andStubReturn(keyPreds); EasyMock.expect(uriInfo.getOrderBy()).andStubReturn(null); EasyMock.expect(uriInfo.getTop()).andStubReturn(1); EasyMock.expect(uriInfo.getSkip()).andStubReturn(2); EdmProperty edmProperty = EasyMock.createMock(EdmProperty.class); EasyMock.expect(edmProperty.getMapping()).andStubReturn(mapping); EasyMock.expect(edmEntityType.getKeyProperties()).andStubReturn(Arrays.asList(edmProperty)); EasyMock.expect(uriInfo.getFilter()).andStubReturn(null); EasyMock.replay(edmEntityType, edmEntitySet, uriInfo, keyPreds, edmProperty); return uriInfo; }
Example #8
Source File: AtomFeedProducerTest.java From olingo-odata2 with Apache License 2.0 | 6 votes |
private ExpandSelectTreeNode getSelectExpandTree(final String pathSegment, final String selectString, final String expandString) throws Exception { Edm edm = RuntimeDelegate.createEdm(new EdmTestProvider()); UriParserImpl uriParser = new UriParserImpl(edm); List<PathSegment> pathSegments = new ArrayList<PathSegment>(); pathSegments.add(new ODataPathSegmentImpl(pathSegment, null)); Map<String, String> queryParameters = new HashMap<String, String>(); if (selectString != null) { queryParameters.put("$select", selectString); } if (expandString != null) { queryParameters.put("$expand", expandString); } UriInfo uriInfo = uriParser.parse(pathSegments, queryParameters); ExpandSelectTreeCreator expandSelectTreeCreator = new ExpandSelectTreeCreator(uriInfo.getSelect(), uriInfo.getExpand()); ExpandSelectTreeNode expandSelectTree = expandSelectTreeCreator.create(); assertNotNull(expandSelectTree); return expandSelectTree; }
Example #9
Source File: AtomEntryProducerTest.java From olingo-odata2 with Apache License 2.0 | 6 votes |
private ExpandSelectTreeNode getSelectExpandTree(final String pathSegment, final String selectString, final String expandString) throws Exception { Edm edm = RuntimeDelegate.createEdm(new EdmTestProvider()); UriParserImpl uriParser = new UriParserImpl(edm); List<PathSegment> pathSegments = new ArrayList<PathSegment>(); pathSegments.add(new ODataPathSegmentImpl(pathSegment, null)); Map<String, String> queryParameters = new HashMap<String, String>(); if (selectString != null) { queryParameters.put("$select", selectString); } if (expandString != null) { queryParameters.put("$expand", expandString); } UriInfo uriInfo = uriParser.parse(pathSegments, queryParameters); ExpandSelectTreeCreator expandSelectTreeCreator = new ExpandSelectTreeCreator(uriInfo.getSelect(), uriInfo.getExpand()); ExpandSelectTreeNode expandSelectTree = expandSelectTreeCreator.create(); assertNotNull(expandSelectTree); return expandSelectTree; }
Example #10
Source File: XmlExpandProducerTest.java From olingo-odata2 with Apache License 2.0 | 6 votes |
private ExpandSelectTreeNode getSelectExpandTree(final String pathSegment, final String selectString, final String expandString) throws Exception { Edm edm = RuntimeDelegate.createEdm(new EdmTestProvider()); UriParserImpl uriParser = new UriParserImpl(edm); List<PathSegment> pathSegments = new ArrayList<PathSegment>(); pathSegments.add(new ODataPathSegmentImpl(pathSegment, null)); Map<String, String> queryParameters = new HashMap<String, String>(); if (selectString != null) { queryParameters.put("$select", selectString); } if (expandString != null) { queryParameters.put("$expand", expandString); } UriInfo uriInfo = uriParser.parse(pathSegments, queryParameters); ExpandSelectTreeCreator expandSelectTreeCreator = new ExpandSelectTreeCreator(uriInfo.getSelect(), uriInfo.getExpand()); ExpandSelectTreeNode expandSelectTree = expandSelectTreeCreator.create(); assertNotNull(expandSelectTree); return expandSelectTree; }
Example #11
Source File: UriInfoTest.java From olingo-odata2 with Apache License 2.0 | 6 votes |
/** * Parse the URI part after an OData service root, given as string. * Query parameters can be included. * @param uri the URI part * @return a {@link UriInfoImpl} instance containing the parsed information */ private UriInfoImpl parse(final String uri) throws UriSyntaxException, UriNotMatchingException, EdmException { final String[] path = uri.split("\\?", -1); if (path.length > 2) { throw new UriSyntaxException(UriSyntaxException.URISYNTAX); } final List<PathSegment> pathSegments = getPathSegments(path[0]); Map<String, List<String>> queryParameters; if (path.length == 2) { queryParameters = getQueryParameters(unescape(path[1])); } else { queryParameters = new HashMap<String, List<String>>(); } UriInfo result = ODataClient.newInstance().parseUri(edm, pathSegments, queryParameters); return (UriInfoImpl) result; }
Example #12
Source File: UriInfoTest.java From olingo-odata2 with Apache License 2.0 | 6 votes |
/** * Parse the URI part after an OData service root, given as string. * Query parameters can be included. * @param uri the URI part * @return a {@link UriInfoImpl} instance containing the parsed information */ private UriInfoImpl parse(final String uri) throws UriSyntaxException, UriNotMatchingException, EdmException { final String[] path = uri.split("\\?", -1); if (path.length > 2) { throw new UriSyntaxException(UriSyntaxException.URISYNTAX); } final List<PathSegment> pathSegments = getPathSegments(path[0]); Map<String, String> queryParameters; if (path.length == 2) { queryParameters = getQueryParameters(unescape(path[1])); } else { queryParameters = new HashMap<String, String>(); } UriInfo result = new UriParserImpl(edm).parse(pathSegments, queryParameters); return (UriInfoImpl) result; }
Example #13
Source File: JPAQueryBuilderTest.java From olingo-odata2 with Apache License 2.0 | 6 votes |
private UriInfo mockURIInfoWithListener(boolean isNavigationEnabled) throws EdmException { UriInfo uriInfo = EasyMock.createMock(UriInfo.class); if (isNavigationEnabled) { List<NavigationSegment> navSegments = new ArrayList<NavigationSegment>(); navSegments.add(null); EasyMock.expect(uriInfo.getNavigationSegments()).andStubReturn(navSegments); EasyMock.replay(uriInfo); return uriInfo; } EdmEntityType edmEntityType = EasyMock.createMock(EdmEntityType.class); EasyMock.expect(edmEntityType.getMapping()).andStubReturn((EdmMapping) mockEdmMapping()); EdmEntitySet edmEntitySet = EasyMock.createMock(EdmEntitySet.class); EasyMock.expect(edmEntitySet.getEntityType()).andStubReturn(edmEntityType); EasyMock.expect(uriInfo.getTargetEntitySet()).andStubReturn(edmEntitySet); EasyMock.expect(uriInfo.getNavigationSegments()).andReturn(null); EasyMock.expect(uriInfo.getKeyPredicates()).andStubReturn(null); EasyMock.expect(uriInfo.getStartEntitySet()).andStubReturn(edmEntitySet); EasyMock.expect(uriInfo.getOrderBy()).andStubReturn(null); EasyMock.expect(uriInfo.getFilter()).andStubReturn(null); EasyMock.expect(uriInfo.getTop()).andStubReturn(null); EasyMock.expect(uriInfo.getSkip()).andStubReturn(null); EasyMock.replay(edmEntityType, edmEntitySet, uriInfo); return uriInfo; }
Example #14
Source File: JPALinkTest.java From olingo-odata2 with Apache License 2.0 | 6 votes |
private PostUriInfo mockPostURIInfo(boolean isReverse) throws ODataException, NoSuchMethodException, SecurityException, NoSuchFieldException, IllegalArgumentException, IllegalAccessException { PostUriInfo uriInfo = EasyMock.createMock(UriInfo.class); for (EdmEntitySet edmEntitySet : edm.getEntitySets()) { if (edmEntitySet.getName().equals("Notes")) { EasyMock.expect(uriInfo.getTargetEntitySet()).andReturn(edmEntitySet).anyTimes(); break; } } EasyMock.expect(((UriInfo) uriInfo).isLinks()).andReturn(true); EasyMock.expect(uriInfo.getNavigationSegments()).andReturn(mockNavigationSegments(isReverse)).anyTimes(); EasyMock.replay(uriInfo); return uriInfo; }
Example #15
Source File: XmlSelectProducerTest.java From olingo-odata2 with Apache License 2.0 | 6 votes |
private ExpandSelectTreeNode getSelectExpandTree(final String selectString, final String expandString) throws Exception { Edm edm = RuntimeDelegate.createEdm(new EdmTestProvider()); UriParserImpl uriParser = new UriParserImpl(edm); List<PathSegment> pathSegments = new ArrayList<PathSegment>(); pathSegments.add(new ODataPathSegmentImpl("Employees('1')", null)); Map<String, String> queryParameters = new HashMap<String, String>(); if (selectString != null) { queryParameters.put("$select", selectString); } if (expandString != null) { queryParameters.put("$expand", expandString); } UriInfo uriInfo = uriParser.parse(pathSegments, queryParameters); ExpandSelectTreeCreator expandSelectTreeCreator = new ExpandSelectTreeCreator(uriInfo.getSelect(), uriInfo.getExpand()); ExpandSelectTreeNode expandSelectTree = expandSelectTreeCreator.create(); assertNotNull(expandSelectTree); return expandSelectTree; }
Example #16
Source File: ODataEntityParser.java From olingo-odata2 with Apache License 2.0 | 6 votes |
public UriInfo parseLinkSegments(final List<String> linkSegments, final Map<String, String> options) throws ODataJPARuntimeException { List<PathSegment> pathSegments = new ArrayList<PathSegment>(); for (String link : linkSegments) { List<PathSegment> pathSegment = getPathSegment(link); pathSegments.addAll(pathSegment); } UriInfo uriInfo = null; try { edm = getEdm(); uriInfo = UriParser.parse(edm, pathSegments, options); } catch (ODataException e) { throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e); } return uriInfo; }
Example #17
Source File: JPAProcessorImpl.java From olingo-odata2 with Apache License 2.0 | 6 votes |
@Override public Object process(DeleteUriInfo uriParserResultView, final String contentType) throws ODataJPAModelException, ODataJPARuntimeException { if (uriParserResultView instanceof DeleteUriInfo) { if (((UriInfo) uriParserResultView).isLinks()) { return deleteLink(uriParserResultView); } } Object selectedObject = readEntity(new JPAQueryBuilder(oDataJPAContext).build(uriParserResultView)); if (selectedObject != null) { try{ boolean isLocalTransaction = setTransaction(); em.remove(selectedObject); em.flush(); if (isLocalTransaction) { oDataJPAContext.getODataJPATransaction().commit(); } } catch(PersistenceException e){ em.getTransaction().rollback(); throw ODataJPARuntimeException.throwException( ODataJPARuntimeException.ERROR_JPQL_DELETE_REQUEST, e); } } return selectedObject; }
Example #18
Source File: ODataJPADefaultProcessorTest.java From olingo-odata2 with Apache License 2.0 | 6 votes |
/** * @return */ private UriInfo getLocalUriInfo() { UriInfo objUriInfo = EasyMock.createMock(UriInfo.class); EasyMock.expect(objUriInfo.getStartEntitySet()).andStubReturn(getLocalEdmEntitySet()); List<NavigationSegment> navSegments = new ArrayList<NavigationSegment>(); EasyMock.expect(objUriInfo.getNavigationSegments()).andReturn(navSegments).anyTimes(); 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.getInlineCount()).andStubReturn(getInlineCount()); EasyMock.expect(objUriInfo.getFilter()).andStubReturn(getFilter()); EasyMock.expect(objUriInfo.getFunctionImport()).andStubReturn(null); EasyMock.replay(objUriInfo); return objUriInfo; }
Example #19
Source File: UriParserImpl.java From olingo-odata2 with Apache License 2.0 | 6 votes |
@Override public UriInfo parseAll(final List<PathSegment> pathSegments, final Map<String, List<String>> allQueryParameters) throws UriSyntaxException, UriNotMatchingException, EdmException { this.pathSegments = copyPathSegmentList(pathSegments); systemQueryOptions = new HashMap<SystemQueryOption, String>(); otherQueryParameters = new HashMap<String, String>(); uriResult = new UriInfoImpl(); preparePathSegments(); handleResourcePath(); distributeQueryParameters(allQueryParameters); checkSystemQueryOptionsCompatibility(); handleSystemQueryOptions(); handleOtherQueryParameters(); return uriResult; }
Example #20
Source File: ODataJPADefaultProcessorTest.java From olingo-odata2 with Apache License 2.0 | 6 votes |
private DeleteUriInfo getDeletetUriInfo() { UriInfo objUriInfo = EasyMock.createMock(UriInfo.class); EasyMock.expect(objUriInfo.getStartEntitySet()).andStubReturn(getLocalEdmEntitySet()); List<NavigationSegment> navSegments = new ArrayList<NavigationSegment>(); EasyMock.expect(objUriInfo.getNavigationSegments()).andReturn(navSegments).anyTimes(); 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.getInlineCount()).andStubReturn(getInlineCount()); EasyMock.expect(objUriInfo.getFilter()).andStubReturn(getFilter()); EasyMock.expect(objUriInfo.getKeyPredicates()).andStubReturn(getKeyPredicates()); EasyMock.expect(objUriInfo.isLinks()).andStubReturn(false); EasyMock.replay(objUriInfo); return objUriInfo; }
Example #21
Source File: JPAQueryBuilder.java From olingo-odata2 with Apache License 2.0 | 6 votes |
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 #22
Source File: JPAQueryBuilderTest.java From olingo-odata2 with Apache License 2.0 | 6 votes |
@SuppressWarnings("unchecked") private UriInfo mockURIInfoForEntitySetCount(EdmMapping mapping) throws EdmException { UriInfo uriInfo = EasyMock.createMock(UriInfo.class); List<NavigationSegment> navSegments = new ArrayList<NavigationSegment>(); EasyMock.expect(uriInfo.getNavigationSegments()).andStubReturn(navSegments); EdmEntityType edmEntityType = EasyMock.createMock(EdmEntityType.class); EasyMock.expect(edmEntityType.getMapping()).andStubReturn(mapping); EdmEntitySet edmEntitySet = EasyMock.createMock(EdmEntitySet.class); EasyMock.expect(edmEntitySet.getEntityType()).andStubReturn(edmEntityType); EasyMock.expect(uriInfo.getTargetEntitySet()).andStubReturn(edmEntitySet); List<KeyPredicate> keyPreds =EasyMock.createMock(ArrayList.class); EasyMock.expect(uriInfo.getKeyPredicates()).andStubReturn(keyPreds); OrderByExpression orderbyExpression = mockOrderByExpressions(uriInfo); EasyMock.expect(uriInfo.getTop()).andStubReturn(null); EasyMock.expect(uriInfo.getSkip()).andStubReturn(null); EasyMock.replay(edmEntityType, edmEntitySet, uriInfo, keyPreds,orderbyExpression); return uriInfo; }
Example #23
Source File: JPAQueryBuilder.java From olingo-odata2 with Apache License 2.0 | 6 votes |
public Query build(GetEntityUriInfo uriInfo) throws ODataJPARuntimeException { Query query = null; try { ODataJPAQueryExtensionEntityListener listener = getODataJPAQueryEntityListener((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.GetEntity); } } catch (Exception e) { throw ODataJPARuntimeException.throwException( ODataJPARuntimeException.ERROR_JPQL_QUERY_CREATE, e); } finally { JPQLContext.removeJPQLContext(); ODataExpressionParser.removePositionalParametersThreadLocal(); } return query; }
Example #24
Source File: JPAQueryBuilder.java From olingo-odata2 with Apache License 2.0 | 6 votes |
public Query build(GetEntitySetCountUriInfo uriInfo) throws ODataJPARuntimeException { Query query = null; try { ODataJPAQueryExtensionEntityListener listener = getODataJPAQueryEntityListener((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.GetEntitySetCount); } } catch (Exception e) { throw ODataJPARuntimeException.throwException( ODataJPARuntimeException.ERROR_JPQL_QUERY_CREATE, e); } finally { JPQLContext.removeJPQLContext(); ODataExpressionParser.removePositionalParametersThreadLocal(); } return query; }
Example #25
Source File: JPAQueryBuilder.java From olingo-odata2 with Apache License 2.0 | 6 votes |
public Query build(GetEntityCountUriInfo uriInfo) throws ODataJPARuntimeException { Query query = null; try { ODataJPAQueryExtensionEntityListener listener = getODataJPAQueryEntityListener((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.GetEntityCount); } } catch (Exception e) { throw ODataJPARuntimeException.throwException( ODataJPARuntimeException.ERROR_JPQL_QUERY_CREATE, e); } finally { JPQLContext.removeJPQLContext(); ODataExpressionParser.removePositionalParametersThreadLocal(); } return query; }
Example #26
Source File: JPAQueryBuilder.java From olingo-odata2 with Apache License 2.0 | 6 votes |
public Query build(DeleteUriInfo uriInfo) throws ODataJPARuntimeException { Query query = null; try { ODataJPAQueryExtensionEntityListener listener = getODataJPAQueryEntityListener((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.Delete); } } catch (Exception e) { throw ODataJPARuntimeException.throwException( ODataJPARuntimeException.ERROR_JPQL_QUERY_CREATE, e); } finally { JPQLContext.removeJPQLContext(); ODataExpressionParser.removePositionalParametersThreadLocal(); } return query; }
Example #27
Source File: JPAQueryBuilder.java From olingo-odata2 with Apache License 2.0 | 6 votes |
public Query build(PutMergePatchUriInfo uriInfo) throws ODataJPARuntimeException { Query query = null; try { ODataJPAQueryExtensionEntityListener listener = getODataJPAQueryEntityListener((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.PutMergePatch); } } catch (Exception e) { throw ODataJPARuntimeException.throwException( ODataJPARuntimeException.ERROR_JPQL_QUERY_CREATE, e); } finally { JPQLContext.removeJPQLContext(); ODataExpressionParser.removePositionalParametersThreadLocal(); } return query; }
Example #28
Source File: JPAProcessorImplTest.java From olingo-odata2 with Apache License 2.0 | 6 votes |
private GetEntityLinkUriInfo getEntityLinkUriInfo () { 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.getKeyPredicates()).andReturn(getKeyPredicates()); 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 #29
Source File: JPAQueryBuilder.java From olingo-odata2 with Apache License 2.0 | 6 votes |
public JPQLContextType determineJPQLContextType(UriInfo uriParserResultView, UriInfoType type) { JPQLContextType contextType = null; if (uriParserResultView.getNavigationSegments() != null && !uriParserResultView.getNavigationSegments().isEmpty()) { if (type == UriInfoType.GetEntitySet) { contextType = JPQLContextType.JOIN; } else if (type == UriInfoType.Delete || type == UriInfoType.GetEntity || type == UriInfoType.PutMergePatch) { contextType = JPQLContextType.JOIN_SINGLE; } else if (type == UriInfoType.GetEntitySetCount || type == UriInfoType.GetEntityCount) { contextType = JPQLContextType.JOIN_COUNT; } } else { if (type == UriInfoType.GetEntitySet) { contextType = JPQLContextType.SELECT; } else if (type == UriInfoType.Delete || type == UriInfoType.GetEntity || type == UriInfoType.PutMergePatch) { contextType = JPQLContextType.SELECT_SINGLE; } else if (type == UriInfoType.GetEntitySetCount || type == UriInfoType.GetEntityCount) { contextType = JPQLContextType.SELECT_COUNT; } } return contextType; }
Example #30
Source File: JPAProcessorImplTest.java From olingo-odata2 with Apache License 2.0 | 6 votes |
private DeleteUriInfo getDeletetUriInfo() { 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.getInlineCount()).andStubReturn(getInlineCount()); EasyMock.expect(objUriInfo.getFilter()).andStubReturn(getFilter()); EasyMock.expect(objUriInfo.getKeyPredicates()).andStubReturn(getKeyPredicates()); EasyMock.expect(objUriInfo.isLinks()).andStubReturn(false); EasyMock.expect(objUriInfo.getNavigationSegments()).andStubReturn(new ArrayList<NavigationSegment>()); EasyMock.replay(objUriInfo); return objUriInfo; }