本文整理汇总了Java中org.apache.olingo.server.api.ODataApplicationException类的典型用法代码示例。如果您正苦于以下问题:Java ODataApplicationException类的具体用法?Java ODataApplicationException怎么用?Java ODataApplicationException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ODataApplicationException类属于org.apache.olingo.server.api包,在下文中一共展示了ODataApplicationException类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: executeRequest
import org.apache.olingo.server.api.ODataApplicationException; //导入依赖的package包/类
/**
* Execute query request with filter and aggregations.
*
* @param query
* search query
* @return ES search response
* @throws ODataApplicationException
* if any error appeared during executing request
*/
public SearchResponse executeRequest(SearchQuery query) throws ODataApplicationException {
Pagination pagination = query.getPagination();
SearchRequestBuilder requestBuilder = client.prepareSearch(query.getIndex())
.setTypes(query.getTypes()).setQuery(query.getQueryBuilder());
if (pagination != null) {
List<Sort> orderBy = pagination.getOrderBy();
for (Sort sort : orderBy) {
FieldSortBuilder sortQuery = SortBuilders.fieldSort(sort.getProperty())
.order(SortOrder.valueOf(sort.getDirection().toString()));
requestBuilder.addSort(sortQuery);
}
requestBuilder.setSize(pagination.getTop()).setFrom(pagination.getSkip());
}
Set<String> fields = query.getFields();
if (fields != null && !fields.isEmpty()) {
requestBuilder.setFetchSource(fields.toArray(new String[fields.size()]), null);
}
return executeRequest(requestBuilder);
}
开发者ID:Hevelian,项目名称:hevelian-olastic,代码行数:29,代码来源:ESClient.java
示例2: list
import org.apache.olingo.server.api.ODataApplicationException; //导入依赖的package包/类
/**
* Reads multiple instances of an Entity Type.
*
* @param entitySet
* Entity Set to read from
* @param uriInfo
* contains filter, order by and paging arguments
* @return entities
* @throws ODataApplicationException
* if error occurred handling filter option
*/
public EntityCollection list(EdmEntitySet entitySet, UriInfo uriInfo)
throws ODataApplicationException {
SearchRequestBuilder searchRequest = elasticsearchTemplate.getClient()
.prepareSearch(toIndexName(entitySet))
.setTypes(toTypeName(entitySet))
.setQuery(toQueryBuilder(uriInfo.getFilterOption()));
configureSorting(uriInfo, searchRequest);
configurePaging(uriInfo, searchRequest);
SearchResponse response = searchRequest.execute().actionGet();
EntityCollection entityCollection = new EntityCollection();
List<Entity> entities = entityCollection.getEntities();
response.getHits().forEach(hit -> {
Entity entity = toEntity(entitySet, hit.getId(), hit.getSource());
entities.add(entity);
});
return entityCollection;
}
开发者ID:pukkaone,项目名称:odata-spring-boot-starter,代码行数:34,代码来源:EntityRepository.java
示例3: updateReference
import org.apache.olingo.server.api.ODataApplicationException; //导入依赖的package包/类
@Override
public void updateReference(ODataRequest request, ODataResponse response, UriInfo uriInfo,
ContentType requestFormat) throws ODataApplicationException, ODataLibraryException {
// 1. Retrieve the entity type from the URI
// EdmEntitySet edmEntitySet = Util.getEdmEntitySet(uriInfo);
// EdmEntityType edmEntityType = edmEntitySet.getEntityType();
// 2. create the data in backend
// 2.1. retrieve the payload from the POST request for the entity to create and deserialize it
InputStream requestInputStream = request.getBody();
ODataDeserializer deserializer = this.odata.createDeserializer(requestFormat);
DeserializerResult result = deserializer.entityReferences(requestInputStream);
List<URI> requestEntityReferences = result.getEntityReferences();
// 2.2 do the creation in backend,
try {
SparqlBaseCommand.updateEntityReference(rdfEdmProvider, uriInfo, requestEntityReferences);
} catch (EdmException | OData2SparqlException e) {
throw new ODataApplicationException(e.getMessage(), HttpStatusCode.NO_CONTENT.getStatusCode(),
Locale.ENGLISH);
}
// 3. serialize the response
response.setStatusCode(HttpStatusCode.NO_CONTENT.getStatusCode());
}
开发者ID:peterjohnlawrence,项目名称:com.inova8.odata2sparql.v4,代码行数:25,代码来源:SparqlReferenceProcessor.java
示例4: deleteReference
import org.apache.olingo.server.api.ODataApplicationException; //导入依赖的package包/类
@Override
public void deleteReference(ODataRequest request, ODataResponse response, UriInfo uriInfo)
throws ODataApplicationException, ODataLibraryException {
// 1. Retrieve the entity type from the URI
// EdmEntitySet edmEntitySet = Util.getEdmEntitySet(uriInfo);
// EdmEntityType edmEntityType = edmEntitySet.getEntityType();
try {
SparqlBaseCommand.deleteEntityReference(rdfEdmProvider, uriInfo);
} catch (EdmException | OData2SparqlException e) {
throw new ODataApplicationException(e.getMessage(), HttpStatusCode.NO_CONTENT.getStatusCode(),
Locale.ENGLISH);
}
// 3. serialize the response
response.setStatusCode(HttpStatusCode.NO_CONTENT.getStatusCode());
}
开发者ID:peterjohnlawrence,项目名称:com.inova8.odata2sparql.v4,代码行数:17,代码来源:SparqlReferenceProcessor.java
示例5: readReferenceCollection
import org.apache.olingo.server.api.ODataApplicationException; //导入依赖的package包/类
static public EntityCollection readReferenceCollection(RdfEdmProvider rdfEdmProvider, UriInfo uriInfo,
UriType uriType) throws OData2SparqlException, EdmException, ODataApplicationException, ExpressionVisitException {
List<UriResource> resourcePaths = uriInfo.getUriResourceParts();
RdfEntityType rdfEntityType = null;
EdmEntitySet edmEntitySet = null;
UriResourceEntitySet uriResourceEntitySet = (UriResourceEntitySet) resourcePaths.get(0);
edmEntitySet = uriResourceEntitySet.getEntitySet();
rdfEntityType = rdfEdmProvider.getRdfEntityTypefromEdmEntitySet(edmEntitySet);
SparqlQueryBuilder sparqlBuilder = new SparqlQueryBuilder(rdfEdmProvider.getRdfModel(),
rdfEdmProvider.getEdmMetadata(), uriInfo, uriType);
//prepareQuery
SparqlStatement sparqlStatement = sparqlBuilder.prepareEntityLinksSparql();
SparqlEntityCollection rdfResults = sparqlStatement.executeConstruct(rdfEdmProvider, rdfEntityType, null, null);
if (rdfResults == null) {
throw new ODataApplicationException("No results", HttpStatusCode.INTERNAL_SERVER_ERROR.getStatusCode(),
Locale.ENGLISH);
} else {
return rdfResults;
}
}
开发者ID:peterjohnlawrence,项目名称:com.inova8.odata2sparql.v4,代码行数:24,代码来源:SparqlBaseCommand.java
示例6: writeEntity
import org.apache.olingo.server.api.ODataApplicationException; //导入依赖的package包/类
public static Entity writeEntity(RdfEdmProvider rdfEdmProvider, UriInfo uriInfo, Entity requestEntity)
throws OData2SparqlException, ODataApplicationException {
SparqlStatement sparqlStatement = null;
EdmEntitySet edmEntitySet = Util.getEdmEntitySet(uriInfo);
RdfEntityType entityType = rdfEdmProvider.getRdfEntityTypefromEdmEntitySet(edmEntitySet);
SparqlCreateUpdateDeleteBuilder sparqlCreateUpdateDeleteBuilder = new SparqlCreateUpdateDeleteBuilder(
rdfEdmProvider);
try {
sparqlStatement = sparqlCreateUpdateDeleteBuilder.generateInsertEntity(entityType, requestEntity);
} catch (Exception e) {
log.error(e.getMessage());
throw new OData2SparqlException(e.getMessage());
}
sparqlStatement.executeInsert(rdfEdmProvider);
return requestEntity;
}
开发者ID:peterjohnlawrence,项目名称:com.inova8.odata2sparql.v4,代码行数:17,代码来源:SparqlBaseCommand.java
示例7: read
import org.apache.olingo.server.api.ODataApplicationException; //导入依赖的package包/类
/**
* Method is a template to provide behavior for all read processors.
*/
@Override
public void read(ODataRequest request, ODataResponse response, UriInfo uriInfo,
ContentType responseFormat) throws ODataApplicationException, ODataLibraryException {
this.request = request;
ESRequest searchRequest = createRequest(uriInfo);
ElasticEdmEntitySet entitySet = searchRequest.getEntitySet();
SearchResponse searchResponse = searchRequest.execute();
InstanceData<T, V> data = parseResponse(searchResponse, entitySet);
ODataSerializer serializer = odata.createSerializer(responseFormat);
SerializerResult serializerResult = serialize(serializer, data, entitySet, uriInfo);
response.setContent(serializerResult.getContent());
response.setStatusCode(HttpStatusCode.OK.getStatusCode());
response.setHeader(HttpHeader.CONTENT_TYPE, responseFormat.toContentTypeString());
}
开发者ID:Hevelian,项目名称:hevelian-olastic,代码行数:19,代码来源:AbstractESReadProcessor.java
示例8: visitMethodCall
import org.apache.olingo.server.api.ODataApplicationException; //导入依赖的package包/类
@Override
public ExpressionMember visitMethodCall(MethodKind methodCall,
List<ExpressionMember> parameters)
throws ExpressionVisitException, ODataApplicationException {
switch (methodCall) {
case CONTAINS:
return parameters.get(0).contains(parameters.get(1));
case STARTSWITH:
return parameters.get(0).startsWith(parameters.get(1));
case ENDSWITH:
return parameters.get(0).endsWith(parameters.get(1));
case DATE:
return parameters.get(0).date();
default:
return throwNotImplemented(
String.format("Method call %s is not implemented", methodCall));
}
}
开发者ID:Hevelian,项目名称:hevelian-olastic,代码行数:19,代码来源:ElasticSearchExpressionVisitor.java
示例9: getEqQuery
import org.apache.olingo.server.api.ODataApplicationException; //导入依赖的package包/类
/**
* Gets query for equals and not equals operations.
*
* @param expressionMember
* member with value
* @return appropriate query
* @throws ODataApplicationException
* if any error occurred during creating query
*/
protected QueryBuilder getEqQuery(ExpressionMember expressionMember)
throws ODataApplicationException {
Object value = ((LiteralMember) expressionMember).getValue();
if (getField().equals(ID_FIELD_NAME)) {
if (value == null) {
throw new ODataApplicationException("Id value can not be null",
HttpStatusCode.BAD_REQUEST.getStatusCode(), Locale.ROOT);
}
return idsQuery().addIds(value.toString());
} else {
String fieldName = addKeywordIfNeeded(getField(), getAnnotations());
if (value == null) {
return boolQuery().mustNot(existsQuery(fieldName));
} else {
return termQuery(fieldName, value);
}
}
}
开发者ID:Hevelian,项目名称:hevelian-olastic,代码行数:28,代码来源:AnnotatedMember.java
示例10: visitLiteral
import org.apache.olingo.server.api.ODataApplicationException; //导入依赖的package包/类
@Override
public Object visitLiteral(Literal literal) throws ExpressionVisitException, ODataApplicationException {
String literalAsString = literal.getText();
if(literal.getType() instanceof EdmString) {
String stringLiteral = "";
if (literal.getText().length() > 2) {
stringLiteral = literalAsString.substring(1, literalAsString.length() - 1);
}
return stringLiteral;
}
else {
try {
return Integer.parseInt(literalAsString);
} catch (NumberFormatException e) {
throw new ODataApplicationException("Only Edm.Int32 and Edm.String literals are implemented", HttpStatusCode.NOT_IMPLEMENTED.getStatusCode(), Locale.ENGLISH);
}
}
}
开发者ID:sbcd90,项目名称:olingo-jersey,代码行数:19,代码来源:FilterExpressionVisitor.java
示例11: readEntity
import org.apache.olingo.server.api.ODataApplicationException; //导入依赖的package包/类
@Override
public void readEntity(
ODataRequest request,
ODataResponse response,
UriInfo uriInfo,
ContentType responseFormat) throws ODataApplicationException, ODataLibraryException {
// First path segment is Entity Set.
List<UriResource> resourceParts = uriInfo.getUriResourceParts();
UriResourceEntitySet uriResourceEntitySet = (UriResourceEntitySet) resourceParts.get(0);
EdmEntitySet entitySet = uriResourceEntitySet.getEntitySet();
List<UriParameter> keyPredicates = uriResourceEntitySet.getKeyPredicates();
// Retrieve entity from backend.
Entity entity = entityRepository.read(entitySet, keyPredicates);
// Serialize to response format.
ContextURL contextUrl = ContextURL.with()
.entitySet(entitySet)
.suffix(ContextURL.Suffix.ENTITY)
.build();
EntitySerializerOptions options = EntitySerializerOptions.with()
.contextURL(contextUrl)
.build();
ODataSerializer serializer = odata.createSerializer(responseFormat);
SerializerResult serializerResult = serializer.entity(
serviceMetadata, entitySet.getEntityType(), entity, options);
// Set response attributes.
response.setContent(serializerResult.getContent());
response.setStatusCode(HttpStatusCode.OK.getStatusCode());
response.setHeader(HttpHeader.CONTENT_TYPE, responseFormat.toContentTypeString());
}
开发者ID:pukkaone,项目名称:odata-spring-boot-starter,代码行数:34,代码来源:ElasticsearchEntityProcessor.java
示例12: createEntity
import org.apache.olingo.server.api.ODataApplicationException; //导入依赖的package包/类
@Override
public void createEntity(
ODataRequest request,
ODataResponse response,
UriInfo uriInfo,
ContentType requestFormat,
ContentType responseFormat) throws ODataApplicationException, ODataLibraryException {
throw new NotImplementedException("createEntity not implemented");
}
开发者ID:pukkaone,项目名称:odata-spring-boot-starter,代码行数:11,代码来源:ElasticsearchEntityProcessor.java
示例13: updateEntity
import org.apache.olingo.server.api.ODataApplicationException; //导入依赖的package包/类
@Override
public void updateEntity(
ODataRequest request,
ODataResponse response,
UriInfo uriInfo,
ContentType requestFormat,
ContentType responseFormat) throws ODataApplicationException, ODataLibraryException {
throw new NotImplementedException("updateEntity not implemented");
}
开发者ID:pukkaone,项目名称:odata-spring-boot-starter,代码行数:11,代码来源:ElasticsearchEntityProcessor.java
示例14: deleteEntity
import org.apache.olingo.server.api.ODataApplicationException; //导入依赖的package包/类
@Override
public void deleteEntity(
ODataRequest request,
ODataResponse response,
UriInfo uriInfo) throws ODataApplicationException, ODataLibraryException {
throw new NotImplementedException("deleteEntity not implemented");
}
开发者ID:pukkaone,项目名称:odata-spring-boot-starter,代码行数:9,代码来源:ElasticsearchEntityProcessor.java
示例15: visitBinaryOperator
import org.apache.olingo.server.api.ODataApplicationException; //导入依赖的package包/类
@Override
public Object visitBinaryOperator(
BinaryOperatorKind operator,
Object left,
Object right) throws ExpressionVisitException, ODataApplicationException {
switch (operator) {
case AND:
return and((QueryBuilder) left, (QueryBuilder) right);
case EQ:
return eq((String) left, right);
case GE:
return ge((String) left, right);
case GT:
return gt((String) left, right);
case LE:
return le((String) left, right);
case LT:
return lt((String) left, right);
case NE:
return ne((String) left, right);
case OR:
return or((QueryBuilder) left, (QueryBuilder) right);
default:
throw new NotImplementedException("Binary operator " + operator + " not implemented");
}
}
开发者ID:pukkaone,项目名称:odata-spring-boot-starter,代码行数:28,代码来源:ElasticsearchExpressionVisitor.java
示例16: visitUnaryOperator
import org.apache.olingo.server.api.ODataApplicationException; //导入依赖的package包/类
@Override
public Object visitUnaryOperator(
UnaryOperatorKind operator,
Object operand) throws ExpressionVisitException, ODataApplicationException {
switch (operator) {
case NOT:
return not((QueryBuilder) operand);
default:
throw new NotImplementedException("Unary operator " + operator + " not implemented");
}
}
开发者ID:pukkaone,项目名称:odata-spring-boot-starter,代码行数:13,代码来源:ElasticsearchExpressionVisitor.java
示例17: visitMethodCall
import org.apache.olingo.server.api.ODataApplicationException; //导入依赖的package包/类
@Override
public Object visitMethodCall(
MethodKind method,
List<Object> parameters) throws ExpressionVisitException, ODataApplicationException {
switch (method) {
case CONTAINS:
return contains((String) parameters.get(0), (String) parameters.get(1));
case STARTSWITH:
return startsWith((String) parameters.get(0), (String) parameters.get(1));
default:
throw new NotImplementedException("Method " + method + " not implemented");
}
}
开发者ID:pukkaone,项目名称:odata-spring-boot-starter,代码行数:15,代码来源:ElasticsearchExpressionVisitor.java
示例18: visitLambdaExpression
import org.apache.olingo.server.api.ODataApplicationException; //导入依赖的package包/类
@Override
public Object visitLambdaExpression(
String lambdaFunction,
String lambdaVariable,
Expression expression) throws ExpressionVisitException, ODataApplicationException {
throw new NotImplementedException("visitLambdaExpression not implemented");
}
开发者ID:pukkaone,项目名称:odata-spring-boot-starter,代码行数:9,代码来源:ElasticsearchExpressionVisitor.java
示例19: visitLiteral
import org.apache.olingo.server.api.ODataApplicationException; //导入依赖的package包/类
@Override
public Object visitLiteral(Literal literal)
throws ExpressionVisitException, ODataApplicationException {
String value = literal.getText();
if (literal.getType() instanceof EdmString) {
value = LiteralUtils.unquote(value);
}
return value;
}
开发者ID:pukkaone,项目名称:odata-spring-boot-starter,代码行数:12,代码来源:ElasticsearchExpressionVisitor.java
示例20: visitEnum
import org.apache.olingo.server.api.ODataApplicationException; //导入依赖的package包/类
@Override
public Object visitEnum(
EdmEnumType type,
List<String> enumValues) throws ExpressionVisitException, ODataApplicationException {
throw new NotImplementedException("visitEnum not implemented");
}
开发者ID:pukkaone,项目名称:odata-spring-boot-starter,代码行数:8,代码来源:ElasticsearchExpressionVisitor.java
注:本文中的org.apache.olingo.server.api.ODataApplicationException类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论