本文整理汇总了Java中org.apache.olingo.odata2.jpa.processor.api.exception.ODataJPARuntimeException类的典型用法代码示例。如果您正苦于以下问题:Java ODataJPARuntimeException类的具体用法?Java ODataJPARuntimeException怎么用?Java ODataJPARuntimeException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ODataJPARuntimeException类属于org.apache.olingo.odata2.jpa.processor.api.exception包,在下文中一共展示了ODataJPARuntimeException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parseURISegmentWithCustomOptions
import org.apache.olingo.odata2.jpa.processor.api.exception.ODataJPARuntimeException; //导入依赖的package包/类
public final UriInfo parseURISegmentWithCustomOptions(final int segmentFromIndex, final int segmentToIndex,
final Map<String, String> options) 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, options);
} catch (ODataException e) {
throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL.addContent(e.getMessage()), e);
}
return uriInfo;
}
示例2: parseLink
import org.apache.olingo.odata2.jpa.processor.api.exception.ODataJPARuntimeException; //导入依赖的package包/类
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;
}
示例3: parseLinkSegments
import org.apache.olingo.odata2.jpa.processor.api.exception.ODataJPARuntimeException; //导入依赖的package包/类
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;
}
示例4: getPropertyName
import org.apache.olingo.odata2.jpa.processor.api.exception.ODataJPARuntimeException; //导入依赖的package包/类
private static String getPropertyName(final CommonExpression whereExpression) throws EdmException,
ODataJPARuntimeException {
EdmTyped edmProperty = ((PropertyExpression) whereExpression).getEdmProperty();
EdmMapping mapping;
if (edmProperty instanceof EdmNavigationProperty) {
EdmNavigationProperty edmNavigationProperty = (EdmNavigationProperty) edmProperty;
mapping = edmNavigationProperty.getMapping();
} else if(edmProperty instanceof EdmProperty) {
EdmProperty property = (EdmProperty) edmProperty;
mapping = property.getMapping();
} else {
throw ODataJPARuntimeException.throwException(ODataJPARuntimeException.GENERAL, null);
}
return mapping != null ? mapping.getInternalName() : edmProperty.getName();
}
示例5: createJPQLQuery
import org.apache.olingo.odata2.jpa.processor.api.exception.ODataJPARuntimeException; //导入依赖的package包/类
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);
jpqlQuery.append(ODataExpressionParser
.parseKeyPredicates(context.getKeyPredicates(), context.getJPAEntityAlias()));
}
return jpqlQuery.toString();
}
示例6: firstBuild
import org.apache.olingo.odata2.jpa.processor.api.exception.ODataJPARuntimeException; //导入依赖的package包/类
private void firstBuild() throws ODataJPAModelException, ODataJPARuntimeException {
firstBuild = false;
if (principalRoleView == null && dependentRoleView == null) {
principalRoleView =
new JPAEdmReferentialConstraintRole(RoleType.PRINCIPAL, entityTypeView, propertyView, associationView);
principalRoleView.getBuilder().build();
dependentRoleView =
new JPAEdmReferentialConstraintRole(RoleType.DEPENDENT, entityTypeView, propertyView, associationView);
dependentRoleView.getBuilder().build();
if (referentialConstraint == null) {
referentialConstraint = new ReferentialConstraint();
}
}
}
示例7: buildSimpleProperty
import org.apache.olingo.odata2.jpa.processor.api.exception.ODataJPARuntimeException; //导入依赖的package包/类
private SimpleProperty buildSimpleProperty(final Attribute<?, ?> jpaAttribute, final SimpleProperty simpleProperty,
final JoinColumn joinColumn)
throws ODataJPAModelException, ODataJPARuntimeException {
boolean isForeignKey = joinColumn != null;
JPAEdmNameBuilder.build(JPAEdmProperty.this, isBuildModeComplexType, skipDefaultNaming, isForeignKey);
EdmSimpleTypeKind simpleTypeKind = JPATypeConverter
.convertToEdmSimpleType(jpaAttribute
.getJavaType(), jpaAttribute);
simpleProperty.setType(simpleTypeKind);
Facets facets = JPAEdmFacets.createAndSet(jpaAttribute, simpleProperty);
if(isForeignKey) {
facets.setNullable(joinColumn.nullable());
}
return simpleProperty;
}
示例8: addForeignKey
import org.apache.olingo.odata2.jpa.processor.api.exception.ODataJPARuntimeException; //导入依赖的package包/类
private void addForeignKey(final Attribute<?, ?> jpaAttribute) throws ODataJPAModelException,
ODataJPARuntimeException {
AnnotatedElement annotatedElement = (AnnotatedElement) jpaAttribute.getJavaMember();
joinColumnNames = null;
if (annotatedElement == null) {
return;
}
JoinColumn joinColumn = annotatedElement.getAnnotation(JoinColumn.class);
if (joinColumn == null) {
JoinColumns joinColumns = annotatedElement.getAnnotation(JoinColumns.class);
if (joinColumns != null) {
for (JoinColumn jc : joinColumns.value()) {
buildForeignKey(jc, jpaAttribute);
}
}
} else {
buildForeignKey(joinColumn, jpaAttribute);
}
}
示例9: process
import org.apache.olingo.odata2.jpa.processor.api.exception.ODataJPARuntimeException; //导入依赖的package包/类
@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;
}
示例10: normalizeInlineEntries
import org.apache.olingo.odata2.jpa.processor.api.exception.ODataJPARuntimeException; //导入依赖的package包/类
private void normalizeInlineEntries(final Map<String, Object> oDataEntryProperties) throws ODataJPARuntimeException {
List<ODataEntry> entries = null;
try {
for (String navigationPropertyName : oDataEntityType.getNavigationPropertyNames()) {
Object inline = oDataEntryProperties.get(navigationPropertyName);
if (inline instanceof ODataFeed) {
entries = ((ODataFeed) inline).getEntries();
} else if (inline instanceof ODataEntry) {
entries = new ArrayList<ODataEntry>();
entries.add((ODataEntry) inline);
}
if (entries != null) {
oDataEntryProperties.put(navigationPropertyName, entries);
entries = null;
}
}
} catch (EdmException e) {
throw ODataJPARuntimeException
.throwException(ODataJPARuntimeException.GENERAL
.addContent(e.getMessage()), e);
}
}
示例11: build
import org.apache.olingo.odata2.jpa.processor.api.exception.ODataJPARuntimeException; //导入依赖的package包/类
public Query build(GetEntitySetCountUriInfo uriInfo) throws ODataJPARuntimeException {
Query query = null;
try {
ODataJPAQueryExtensionEntityListener listener = getODataJPAQueryEntityListener((UriInfo) uriInfo);
if (listener != null) {
query = listener.getQuery(uriInfo, em);
}
if (query == null) {
query = buildQuery((UriInfo) uriInfo, UriInfoType.GetEntitySetCount);
}
} catch (Exception e) {
throw ODataJPARuntimeException.throwException(
ODataJPARuntimeException.ERROR_JPQL_QUERY_CREATE, e);
}
return query;
}
示例12: testBuildSimpleQuery
import org.apache.olingo.odata2.jpa.processor.api.exception.ODataJPARuntimeException; //导入依赖的package包/类
/**
* Test method for {@link org.apache.olingo.odata2.processor.jpa.jpql.JPQLSelectSingleStatementBuilder#build)}.
* @throws EdmException
* @throws ODataJPARuntimeException
*/
@Test
public void testBuildSimpleQuery() throws EdmException, ODataJPARuntimeException {
EdmSimpleType edmType = EdmSimpleTypeKind.Int32.getEdmSimpleTypeInstance();
JPQLSelectSingleContext JPQLSelectSingleContextImpl = createSelectContext(edmType);
JPQLSelectSingleStatementBuilder = new JPQLSelectSingleStatementBuilder(JPQLSelectSingleContextImpl);
String query = JPQLSelectSingleStatementBuilder.build().toString();
query = query.substring(0, query.indexOf("?"));
Map<String, Map<Integer, Object>> positionalParameters =
ODataParameterizedWhereExpressionUtil.getParameterizedQueryMap();
for (Entry<String, Map<Integer, Object>> param : positionalParameters.entrySet()) {
for (Entry<Integer, Object> postionalParam : param.getValue().entrySet()) {
query += postionalParam.getValue();
}
}
assertEquals("SELECT E1 FROM SalesOrderHeader E1 WHERE E1.Field1 = 1", query);
}
示例13: testBuild
import org.apache.olingo.odata2.jpa.processor.api.exception.ODataJPARuntimeException; //导入依赖的package包/类
@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");
}
}
示例14: initializeODataJPAContext
import org.apache.olingo.odata2.jpa.processor.api.exception.ODataJPARuntimeException; //导入依赖的package包/类
@Override
public ODataJPAContext initializeODataJPAContext()
throws ODataJPARuntimeException {
ODataJPAContext oDataJPAContext = this.getODataJPAContext();
try {
EntityManagerFactory emf = JpaEntityManagerFactory.getEntityManagerFactory();
oDataJPAContext.setEntityManagerFactory(emf);
oDataJPAContext.setPersistenceUnitName(PERSISTENCE_UNIT_NAME);
return oDataJPAContext;
} catch (Exception e) {
throw new RuntimeException(e);
}
}
示例15: initializeODataJPAContext
import org.apache.olingo.odata2.jpa.processor.api.exception.ODataJPARuntimeException; //导入依赖的package包/类
public ODataJPAContext initializeODataJPAContext() throws ODataJPARuntimeException {
ODataJPAContext oDataJPAContext = getODataJPAContext();
EntityManagerFactory factory = (EntityManagerFactory) SpringContextsUtil.getBean(ENTITY_MANAGER_FACTORY_ID);
oDataJPAContext.setEntityManagerFactory(factory);
oDataJPAContext.setPersistenceUnitName(DEFAULT_ENTITY_UNIT_NAME);
oDataJPAContext.setJPAEdmExtension(new JPAEdmExtension());
ODataContextUtil.setODataContext(oDataJPAContext.getODataContext());
return oDataJPAContext;
}