org.apache.olingo.odata2.jpa.processor.api.exception.ODataJPARuntimeException Java Examples

The following examples show how to use org.apache.olingo.odata2.jpa.processor.api.exception.ODataJPARuntimeException. 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: ODataJPAResponseBuilderDefault.java    From olingo-odata2 with Apache License 2.0 6 votes vote down vote up
private static EntityProviderWriteProperties getEntityProviderProperties(final ODataJPAContext odataJPAContext,
    final GetEntityUriInfo resultsView) throws ODataJPARuntimeException {
  ODataEntityProviderPropertiesBuilder entityFeedPropertiesBuilder = null;
  ExpandSelectTreeNode expandSelectTree = null;
  try {
    entityFeedPropertiesBuilder =
        EntityProviderWriteProperties.serviceRoot(odataJPAContext.getODataContext().getPathInfo().getServiceRoot());
    expandSelectTree = UriParser.createExpandSelectTree(resultsView.getSelect(), resultsView.getExpand());
    entityFeedPropertiesBuilder.expandSelectTree(expandSelectTree);
    entityFeedPropertiesBuilder.callbacks(JPAExpandCallBack.getCallbacks(odataJPAContext.getODataContext()
        .getPathInfo().getServiceRoot(), expandSelectTree, resultsView.getExpand()));
  } catch (ODataException e) {
    throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.INNER_EXCEPTION, e);
  }

  return entityFeedPropertiesBuilder.build();
}
 
Example #2
Source File: EspmServiceFactory.java    From cloud-espm-v2 with Apache License 2.0 6 votes vote down vote up
@Override
public ODataJPAContext initializeODataJPAContext()
		throws ODataJPARuntimeException {
	ODataJPAContext oDataJPAContext = this.getODataJPAContext();
	EntityManagerFactory emf;
	try {
		emf = JpaEntityManagerFactory.getEntityManagerFactory();
		oDataJPAContext.setEntityManagerFactory(emf);
		oDataJPAContext.setPersistenceUnitName(PERSISTENCE_UNIT_NAME);
		oDataJPAContext.setJPAEdmExtension(new EspmProcessingExtension());
		oDataJPAContext.setJPAEdmMappingModel("EspmEdmMapping.xml");
		return oDataJPAContext;
	} catch (Exception e) {
		throw new ODataRuntimeException(e);
	}

}
 
Example #3
Source File: ODataEntityParser.java    From olingo-odata2 with Apache License 2.0 6 votes vote down vote up
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 #4
Source File: JPAQueryBuilder.java    From olingo-odata2 with Apache License 2.0 6 votes vote down vote up
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 #5
Source File: JPQLJoinStatementBuilderTest.java    From olingo-odata2 with Apache License 2.0 6 votes vote down vote up
@Test
public void testBuild() throws Exception {
  setUp(getJoinClauseList());
  JPQLJoinStatementBuilder jpqlJoinStatementBuilder = new JPQLJoinStatementBuilder(context);
  try {
    JPQLStatement jpqlStatement = jpqlJoinStatementBuilder.build();
    assertEquals(
        "SELECT mat FROM SOHeader soh JOIN soh.soItem soi JOIN soi.material mat WHERE soh.buyerId = 2 AND "
            +
            "soh.createdBy = 'Peter' AND soi.shId = soh.soId AND mat.id = 'abc' "
            +
            "ORDER BY mat.buyerId asc , mat.city desc",
            jpqlStatement.toString());
  } catch (ODataJPARuntimeException e) {
    fail("Should not have come here");
  }

}
 
Example #6
Source File: ODataExpressionParser.java    From olingo-odata2 with Apache License 2.0 6 votes vote down vote up
public static String parseKeyPropertiesToJPAOrderByExpression(
    final List<EdmProperty> edmPropertylist, final String tableAlias) throws ODataJPARuntimeException {
  String propertyName = null;
  String orderExpression = "";
  if (edmPropertylist == null) {
    return orderExpression;
  }
  for (EdmProperty edmProperty : edmPropertylist) {
    try {
      EdmMapping mapping = edmProperty.getMapping();
      if (mapping != null && mapping.getInternalName() != null) {
        propertyName = mapping.getInternalName();// For embedded/complex keys
      } else {
        propertyName = edmProperty.getName();
      }
    } catch (EdmException e) {
      throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e);
    }
    orderExpression += tableAlias + JPQLStatement.DELIMITER.PERIOD + propertyName + " , ";
  }
  return normalizeOrderByExpression(orderExpression);
}
 
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: ODataJPAResponseBuilderDefault.java    From olingo-odata2 with Apache License 2.0 5 votes vote down vote up
private static EntityProviderWriteProperties getEntityProviderPropertiesforPost(
    final ODataJPAContext odataJPAContext) throws ODataJPARuntimeException {
  ODataEntityProviderPropertiesBuilder entityFeedPropertiesBuilder = null;
  try {
    entityFeedPropertiesBuilder =
        EntityProviderWriteProperties.serviceRoot(odataJPAContext.getODataContext().getPathInfo().getServiceRoot());
  } catch (ODataException e) {
    throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.INNER_EXCEPTION, e);
  }

  return entityFeedPropertiesBuilder.build();
}
 
Example #9
Source File: ODataJPAResponseBuilderTest.java    From olingo-odata2 with Apache License 2.0 5 votes vote down vote up
@Test
public void testBuildGetCount() {
  ODataResponse objODataResponse = null;
  try {
    objODataResponse = responseBuilder.build(1);
  } catch (ODataJPARuntimeException e) {
    fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
  }
  assertNotNull(objODataResponse);
}
 
Example #10
Source File: ODataJPAResponseBuilderDefault.java    From olingo-odata2 with Apache License 2.0 5 votes vote down vote up
@Override
public ODataResponse build(final GetEntityLinkUriInfo resultsView, final Object jpaEntity,
    final String contentType) throws ODataNotFoundException,
    ODataJPARuntimeException {

  if (jpaEntity == null) {
    throw new ODataNotFoundException(ODataNotFoundException.ENTITY);
  }
  EdmEntityType edmEntityType = null;
  ODataResponse odataResponse = null;

  try {

    EdmEntitySet entitySet = resultsView.getTargetEntitySet();
    edmEntityType = entitySet.getEntityType();
    Map<String, Object> edmPropertyValueMap = null;

    JPAEntityParser jpaResultParser = new JPAEntityParser();
    edmPropertyValueMap = jpaResultParser.parse2EdmPropertyValueMap(jpaEntity, edmEntityType.getKeyProperties());

    EntityProviderWriteProperties entryProperties =
        EntityProviderWriteProperties.serviceRoot(oDataJPAContext.getODataContext().getPathInfo().getServiceRoot())
            .build();

    ODataResponse response = EntityProvider.writeLink(contentType, entitySet, edmPropertyValueMap, entryProperties);

    odataResponse = ODataResponse.fromResponse(response).build();

  } catch (ODataException e) {
    throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.INNER_EXCEPTION, e);

  }

  return odataResponse;
}
 
Example #11
Source File: OnDBWriteContent.java    From olingo-odata2 with Apache License 2.0 5 votes vote down vote up
@Override
public Clob getJPAClob(final char[] characterData) throws ODataJPARuntimeException {
  try {
    return new JDBCClob(new String(characterData));
  } catch (SQLException e) {
    ODataJPARuntimeException.throwException(ODataJPARuntimeException.INNER_EXCEPTION, e);
  }
  return null;
}
 
Example #12
Source File: ODataJPAResponseBuilderDefault.java    From olingo-odata2 with Apache License 2.0 5 votes vote down vote up
@Override
public ODataResponse build(final PutMergePatchUriInfo putUriInfo, final Object updatedObject)
    throws ODataJPARuntimeException, ODataNotFoundException {
  if (updatedObject == null) {
    throw new ODataNotFoundException(ODataNotFoundException.ENTITY);
  }
  return ODataResponse.status(HttpStatusCodes.NO_CONTENT).build();
}
 
Example #13
Source File: JPAEntityParserTest.java    From olingo-odata2 with Apache License 2.0 5 votes vote down vote up
@Test
public void testForNullJPAEntity() {
  JPAEntityParser resultParser = new JPAEntityParser();
  EdmStructuralType structuralType = EasyMock.createMock(EdmStructuralType.class);
  Object map;
  try {
    map = resultParser.parse2EdmPropertyValueMap(null, structuralType);
    assertNull(map);
  } catch (ODataJPARuntimeException e) {
    fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage() + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
  }
}
 
Example #14
Source File: JPQLSelectSingleStatementBuilder.java    From olingo-odata2 with Apache License 2.0 5 votes vote down vote up
private String createJPQLQuery() throws ODataJPARuntimeException {

    StringBuilder jpqlQuery = new StringBuilder();
    String tableAlias = context.getJPAEntityAlias();
    String fromClause = context.getJPAEntityName() + JPQLStatement.DELIMITER.SPACE + tableAlias;

    jpqlQuery.append(JPQLStatement.KEYWORD.SELECT).append(JPQLStatement.DELIMITER.SPACE);
    jpqlQuery.append(context.getSelectExpression()).append(JPQLStatement.DELIMITER.SPACE);
    jpqlQuery.append(JPQLStatement.KEYWORD.FROM).append(JPQLStatement.DELIMITER.SPACE);
    jpqlQuery.append(fromClause);

    if (context.getKeyPredicates() != null && !context.getKeyPredicates().isEmpty()) {
      jpqlQuery.append(JPQLStatement.DELIMITER.SPACE);
      jpqlQuery.append(JPQLStatement.KEYWORD.WHERE).append(JPQLStatement.DELIMITER.SPACE);
      String keyString = ODataExpressionParser
          .parseKeyPredicates(context.getKeyPredicates(), context.getJPAEntityAlias());
      Map<String, Map<Integer, Object>> parameterizedExpressionMap = 
          new HashMap<String, Map<Integer,Object>>();
      if (keyString != null) { 
        parameterizedExpressionMap.put(keyString, 
            ODataExpressionParser.getPositionalParametersThreadLocal());
        ((JPQLSelectSingleContext)this.context).setParameterizedQueryMap(parameterizedExpressionMap);
      }
      jpqlQuery.append(keyString);
    }

    return jpqlQuery.toString();

  }
 
Example #15
Source File: JPQLSelectStatementBuilder.java    From olingo-odata2 with Apache License 2.0 5 votes vote down vote up
private String createJPQLQuery() throws ODataJPARuntimeException {

    StringBuilder jpqlQuery = new StringBuilder();
    String tableAlias = context.getJPAEntityAlias();
    String fromClause = context.getJPAEntityName() + JPQLStatement.DELIMITER.SPACE + tableAlias;

    jpqlQuery.append(JPQLStatement.KEYWORD.SELECT).append(JPQLStatement.DELIMITER.SPACE);
    if (context.getType().equals(JPQLContextType.SELECT_COUNT)) { // $COUNT
      jpqlQuery.append(JPQLStatement.KEYWORD.COUNT).append(JPQLStatement.DELIMITER.SPACE);
      jpqlQuery.append(JPQLStatement.DELIMITER.PARENTHESIS_LEFT).append(JPQLStatement.DELIMITER.SPACE);
      jpqlQuery.append(context.getSelectExpression()).append(JPQLStatement.DELIMITER.SPACE);
      jpqlQuery.append(JPQLStatement.DELIMITER.PARENTHESIS_RIGHT).append(JPQLStatement.DELIMITER.SPACE);
    } else {// Normal
      jpqlQuery.append(context.getSelectExpression()).append(JPQLStatement.DELIMITER.SPACE);
    }

    jpqlQuery.append(JPQLStatement.KEYWORD.FROM).append(JPQLStatement.DELIMITER.SPACE);
    jpqlQuery.append(fromClause);

    if (context.getWhereExpression() != null) {
      jpqlQuery.append(JPQLStatement.DELIMITER.SPACE);
      jpqlQuery.append(JPQLStatement.KEYWORD.WHERE).append(JPQLStatement.DELIMITER.SPACE);
      jpqlQuery.append(context.getWhereExpression());
    }

    if (context.getOrderByCollection() != null && context.getOrderByCollection().length() > 0) {

      StringBuilder orderByBuilder = new StringBuilder();
      orderByBuilder.append(context.getOrderByCollection());
      jpqlQuery.append(JPQLStatement.DELIMITER.SPACE);
      jpqlQuery.append(JPQLStatement.KEYWORD.ORDERBY).append(JPQLStatement.DELIMITER.SPACE);
      jpqlQuery.append(orderByBuilder);
    }

    return jpqlQuery.toString();

  }
 
Example #16
Source File: ODataJPAServiceFactoryMock.java    From olingo-odata2 with Apache License 2.0 5 votes vote down vote up
@Override
public ODataJPAContext initializeODataJPAContext() throws ODataJPARuntimeException {
  ODataJPAContext oDataJPAContext = null;
  oDataJPAContext = ODataJPAContextMock.mockODataJPAContext(context);
  setOnWriteJPAContent(new OnJPAWriteContentMock());
  return oDataJPAContext;
}
 
Example #17
Source File: ODataEntityParserTest.java    From olingo-odata2 with Apache License 2.0 5 votes vote down vote up
@Test
public void testParseURISegmentInvalidEntityType() {
  try {
    parser = new ODataEntityParser(mock("JPATypeMockInvalid(2)"));
    parser.parseURISegment(0, 1);
    fail("Exception Expected");
  } catch (ODataJPARuntimeException e) {
    assertEquals(true, true);
  }
}
 
Example #18
Source File: JPAFunctionContext.java    From olingo-odata2 with Apache License 2.0 5 votes vote down vote up
private JPAFunction generateJPAFunction() throws EdmException, NoSuchMethodException, SecurityException,
    ODataJPAModelException, ODataJPARuntimeException {

  Class<?>[] parameterTypes = getParameterTypes();
  Method method = getMethod(parameterTypes);
  Type returnType = getReturnType();
  Object[] args = getArguments();

  return new JPAFunction(method, parameterTypes, returnType, args);
}
 
Example #19
Source File: ODataJPAResponseBuilderDefault.java    From olingo-odata2 with Apache License 2.0 5 votes vote down vote up
private static List<EdmProperty> getEdmProperties(final EdmStructuralType structuralType)
    throws ODataJPARuntimeException {
  List<EdmProperty> edmProperties = new ArrayList<EdmProperty>();
  try {
    for (String propertyName : structuralType.getPropertyNames()) {
      edmProperties.add((EdmProperty) structuralType.getProperty(propertyName));
    }
  } catch (EdmException e) {
    throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.INNER_EXCEPTION, e);
  }
  return edmProperties;
}
 
Example #20
Source File: JPAQueryBuilder.java    From olingo-odata2 with Apache License 2.0 5 votes vote down vote up
private Query buildQuery(UriInfo uriParserResultView, UriInfoType type)
    throws EdmException,
    ODataJPAModelException, ODataJPARuntimeException {

  JPQLContextType contextType = determineJPQLContextType(uriParserResultView, type);
  JPQLContext jpqlContext = buildJPQLContext(contextType, uriParserResultView);
  JPQLStatement jpqlStatement = JPQLStatement.createBuilder(jpqlContext).build();
  
  Query query = em.createQuery(normalizeMembers(em, jpqlStatement.toString()));
  getParameterizedQuery(contextType, jpqlContext, jpqlStatement, query);
  return query;
}
 
Example #21
Source File: JPAEntityParser.java    From olingo-odata2 with Apache License 2.0 5 votes vote down vote up
public final List<Map<String, Object>> parse2EdmEntityList(final Collection<Object> jpaEntityList,
    final EdmStructuralType structuralType) throws ODataJPARuntimeException {
  if (jpaEntityList == null || structuralType == null) {
    return null;
  }
  List<EdmProperty> edmProperties = getEdmProperties(structuralType);
  List<Map<String, Object>> edmEntityList = new ArrayList<Map<String, Object>>();
  for (Object jpaEntity : jpaEntityList) {
    edmEntityList.add(parse2EdmPropertyValueMap(jpaEntity, edmProperties));
  }

  return edmEntityList;
}
 
Example #22
Source File: JPAEdmReferentialConstraint.java    From olingo-odata2 with Apache License 2.0 5 votes vote down vote up
@Override
public void build() throws ODataJPAModelException, ODataJPARuntimeException {

  if (firstBuild) {
    firstBuild();
  } else {
    if (exists && !firstBuild && principalRoleView.isConsistent() == false) {
      principalRoleView.getBuilder().build();
    }

    if (exists && !firstBuild && dependentRoleView.isConsistent() == false) {
      dependentRoleView.getBuilder().build();
    }
  }

  if (principalRoleView.isConsistent()) {
    referentialConstraint.setPrincipal(principalRoleView.getEdmReferentialConstraintRole());
  }

  if (dependentRoleView.isConsistent()) {
    referentialConstraint.setDependent(dependentRoleView.getEdmReferentialConstraintRole());
  }

  exists = principalRoleView.isExists() && dependentRoleView.isExists();

  isConsistent = principalRoleView.isConsistent() && dependentRoleView.isConsistent();

}
 
Example #23
Source File: JPQLJoinStatementBuilderTest.java    From olingo-odata2 with Apache License 2.0 5 votes vote down vote up
@Test
public void testJoinClauseListAsEmpty() throws Exception {
  setUp(new ArrayList<JPAJoinClause>());
  JPQLJoinStatementBuilder jpqlJoinStatementBuilder = new JPQLJoinStatementBuilder(context);
  try {
    jpqlJoinStatementBuilder.build();
    fail("Should not have come here");
  } catch (ODataJPARuntimeException e) {
    assertTrue(true);
  }
}
 
Example #24
Source File: JPAEntityParser.java    From olingo-odata2 with Apache License 2.0 5 votes vote down vote up
private List<EdmProperty> getEdmProperties(final EdmStructuralType structuralType) throws ODataJPARuntimeException {
  List<EdmProperty> edmProperties = new ArrayList<EdmProperty>();
  try {
    for (String propertyName : structuralType.getPropertyNames()) {
      edmProperties.add((EdmProperty) structuralType.getProperty(propertyName));
    }
  } catch (EdmException e) {
    throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.INNER_EXCEPTION, e);
  }
  return edmProperties;
}
 
Example #25
Source File: JPAEdmEntityContainer.java    From olingo-odata2 with Apache License 2.0 5 votes vote down vote up
@Override
public void build() throws ODataJPAModelException, ODataJPARuntimeException {

  currentEntityContainer = new EntityContainer();

  if (consistentEntityContainerList == null) {
    currentEntityContainer.setDefaultEntityContainer(true);
    consistentEntityContainerList = new ArrayList<EntityContainer>();
  }

  entitySetView = new JPAEdmEntitySet(schemaView);
  entitySetView.getBuilder().build();
  if (entitySetView.isConsistent()) {
    currentEntityContainer.setEntitySets(entitySetView.getConsistentEdmEntitySetList());
  } else {
    isConsistent = false;
    return;
  }

  if (!schemaView.getJPAEdmAssociationView().isConsistent()) {
    schemaView.getJPAEdmAssociationView().getBuilder().build();
  }

  associationSetView = new JPAEdmAssociationSet(schemaView);
  associationSetView.getBuilder().build();
  if (associationSetView.isConsistent()) {
    currentEntityContainer.setAssociationSets(associationSetView.getConsistentEdmAssociationSetList());
  } else {
    isConsistent = false;
    return;
  }

  JPAEdmNameBuilder.build(JPAEdmEntityContainer.this);
  consistentEntityContainerList.add(currentEntityContainer);
  isConsistent = true;

}
 
Example #26
Source File: JPQLJoinSelectSingleStatementBuilderTest.java    From olingo-odata2 with Apache License 2.0 5 votes vote down vote up
@Test
public void testJoinClauseListAsEmpty() throws Exception {
  List<JPAJoinClause> joinClauseList = new ArrayList<JPAJoinClause>();
  setUp(joinClauseList);
  JPQLJoinSelectSingleStatementBuilder jpqlJoinSelectsingleStatementBuilder =
      new JPQLJoinSelectSingleStatementBuilder(context);
  try {
    jpqlJoinSelectsingleStatementBuilder.build();
    fail("Should not have come here");
  } catch (ODataJPARuntimeException e) {
    assertTrue(true);
  }
}
 
Example #27
Source File: JPAEntityParser.java    From olingo-odata2 with Apache License 2.0 5 votes vote down vote up
public final HashMap<String, Object> parse2EdmPropertyValueMap(final Object jpaEntity,
    final EdmStructuralType structuralType) throws ODataJPARuntimeException {
  if (jpaEntity == null || structuralType == null) {
    return null;
  }
  return parse2EdmPropertyValueMap(jpaEntity, getEdmProperties(structuralType));
}
 
Example #28
Source File: ODataEntityParserTest.java    From olingo-odata2 with Apache License 2.0 5 votes vote down vote up
@Test
public void testParseBindingLink() {
  try {
    parser = new ODataEntityParser(mock("JPATypeMock(2)"));
    UriInfo uriInfo = parser.parseBindingLink("JPATypeMock(2)", new HashMap<String, String>());
    assertNotNull(uriInfo);
  } catch (ODataJPARuntimeException e) {
    fail(ODataJPATestConstants.EXCEPTION_MSG_PART_1 + e.getMessage()
        + ODataJPATestConstants.EXCEPTION_MSG_PART_2);
  }

}
 
Example #29
Source File: JPQLContext.java    From olingo-odata2 with Apache License 2.0 5 votes vote down vote up
/**
 * the method instantiates an instance of type JPQLContextBuilder.
 * 
 * @param contextType
 * indicates the type of JPQLContextBuilder to instantiate.
 * @param resultsView
 * is the OData request view
 * @return an instance of type
 * {@link org.apache.olingo.odata2.jpa.processor.api.jpql.JPQLContext.JPQLContextBuilder}
 * @throws ODataJPARuntimeException
 */
private static JPQLContextBuilder create(final JPQLContextType contextType, final Object resultsView,
    final boolean withPaging)
    throws ODataJPARuntimeException {
  JPQLContextBuilder contextBuilder =
      ODataJPAFactory.createFactory().getJPQLBuilderFactory().getContextBuilder(contextType);
  if (contextBuilder == null) {
    throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.ERROR_JPQLCTXBLDR_CREATE, null);
  }
  contextBuilder.setResultsView(resultsView);
  contextBuilder.withPaging = withPaging;
  return contextBuilder;
}
 
Example #30
Source File: JPAEntityParser.java    From olingo-odata2 with Apache License 2.0 5 votes vote down vote up
public List<Map<String, Object>> parse2EdmEntityList(final Collection<Object> jpaEntityList,
    final List<EdmProperty> properties)
    throws ODataJPARuntimeException {

  if (jpaEntityList == null) {
    return null;
  }
  List<Map<String, Object>> edmEntityList = new ArrayList<Map<String, Object>>();
  for (Object item : jpaEntityList) {
    edmEntityList.add(parse2EdmPropertyValueMap(item, properties));
  }

  return edmEntityList;
}