本文整理汇总了Java中org.apache.olingo.commons.api.edm.EdmException类的典型用法代码示例。如果您正苦于以下问题:Java EdmException类的具体用法?Java EdmException怎么用?Java EdmException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
EdmException类属于org.apache.olingo.commons.api.edm包,在下文中一共展示了EdmException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createReference
import org.apache.olingo.commons.api.edm.EdmException; //导入依赖的package包/类
@Override
public void createReference(ODataRequest request, ODataResponse response, UriInfo uriInfo,
ContentType requestFormat) throws ODataApplicationException, ODataLibraryException {
// 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.writeEntityReference(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());
}
示例2: updateReference
import org.apache.olingo.commons.api.edm.EdmException; //导入依赖的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());
}
示例3: deleteReference
import org.apache.olingo.commons.api.edm.EdmException; //导入依赖的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());
}
示例4: readReferenceCollection
import org.apache.olingo.commons.api.edm.EdmException; //导入依赖的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;
}
}
示例5: preprocessOperationQuery
import org.apache.olingo.commons.api.edm.EdmException; //导入依赖的package包/类
private String preprocessOperationQuery(RdfEntityType rdfOperationType) throws EdmException, OData2SparqlException {
List<CustomQueryOption> queryOptions = null;
if (rdfOperationType.isFunctionImport()) {
queryOptions = uriInfo.getCustomQueryOptions();
}
String queryText = rdfOperationType.queryText;
for (Entry<String, com.inova8.odata2sparql.RdfModel.RdfModel.FunctionImportParameter> functionImportParameterEntry : rdfOperationType
.getFunctionImportParameters().entrySet()) {
com.inova8.odata2sparql.RdfModel.RdfModel.FunctionImportParameter functionImportParameter = functionImportParameterEntry
.getValue();
String parameterValue = getQueryOptionText(queryOptions, functionImportParameter.getName());
if (parameterValue != null) {
queryText = queryText.replaceAll("\\?" + functionImportParameter.getName(), parameterValue);
} else {
if (!functionImportParameter.isNullable())
throw new OData2SparqlException(
"FunctionImport cannot be called without values for non-nullable parameters");
}
}
if ((uriType != UriType.URI15) && (uriType != UriType.URI6B)) {
queryText += limitClause();
}
return queryText;
}
示例6: clausesPath_URI1
import org.apache.olingo.commons.api.edm.EdmException; //导入依赖的package包/类
private StringBuilder clausesPath_URI1(String indent) throws EdmException {
StringBuilder clausesPath = new StringBuilder();
if (uriInfo.getUriResourceParts().size() > 1) {
clausesPath.append(clausesPathNavigation(indent, uriInfo.getUriResourceParts(),
((UriResourceEntitySet) uriInfo.getUriResourceParts().get(0)).getKeyPredicates()));
} else {
clausesPath.append(indent).append("?" + rdfEntityType.entityTypeName
+ "_s <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> ?class .\n");
// clausesPath.append(indent).append(
// "?class (<http://www.w3.org/2000/01/rdf-schema#subClassOf>)* <" +
// rdfEntityType.getIRI() + "> .\n");
clausesPath.append(indent).append(valuesSubClassOf(rdfEntityType)).append("}\n");
}
return clausesPath;
}
示例7: clausesPath_URI15
import org.apache.olingo.commons.api.edm.EdmException; //导入依赖的package包/类
private StringBuilder clausesPath_URI15(String indent) throws EdmException, OData2SparqlException {
StringBuilder clausesPath = new StringBuilder();
if (uriInfo.getUriResourceParts().size() > 2) {
clausesPath.append(clausesPathNavigation(indent, uriInfo.getUriResourceParts(),
((UriResourceEntitySet) uriInfo.getUriResourceParts().get(0)).getKeyPredicates()));
} else {
if (rdfTargetEntityType.isOperation()) {
clausesPath.append(indent).append(preprocessOperationQuery(rdfTargetEntityType));
} else {
clausesPath.append(indent).append("?" + rdfEntityType.entityTypeName
+ "_s <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> ?class .\n");
// clausesPath.append(indent).append(
// "?class (<http://www.w3.org/2000/01/rdf-schema#subClassOf>)*
// <"
// + rdfEntityType.getIRI() + "> .\n");
clausesPath.append(indent).append(valuesSubClassOf(rdfEntityType)).append("}\n");
}
}
return clausesPath;
}
示例8: createUnboundAction
import org.apache.olingo.commons.api.edm.EdmException; //导入依赖的package包/类
@Override
protected EdmAction createUnboundAction(final FullQualifiedName actionName) {
try {
List<CsdlAction> actions = actionsMap.get(actionName);
if (actions == null) {
actions = provider.getActions(actionName);
if (actions == null) {
return null;
} else {
actionsMap.put(actionName, actions);
}
}
// Search for first unbound action
for (CsdlAction action : actions) {
if (!action.isBound()) {
return new EdmActionImpl(this, actionName, action);
}
}
return null;
} catch (ODataException e) {
throw new EdmException(e);
}
}
示例9: createUnboundFunctions
import org.apache.olingo.commons.api.edm.EdmException; //导入依赖的package包/类
@Override
protected List<EdmFunction> createUnboundFunctions(final FullQualifiedName functionName) {
List<EdmFunction> result = new ArrayList<EdmFunction>();
try {
List<CsdlFunction> functions = functionsMap.get(functionName);
if (functions == null) {
functions = provider.getFunctions(functionName);
if (functions != null) {
functionsMap.put(functionName, functions);
}
}
if (functions != null) {
for (CsdlFunction function : functions) {
if (!function.isBound()) {
result.add(new EdmFunctionImpl(this, functionName, function));
}
}
}
} catch (ODataException e) {
throw new EdmException(e);
}
return result;
}
示例10: createTerm
import org.apache.olingo.commons.api.edm.EdmException; //导入依赖的package包/类
@Override
protected EdmTerm createTerm(final FullQualifiedName termName) {
try {
CsdlTerm providerTerm = provider.getTerm(termName);
if (providerTerm != null) {
return new EdmTermImpl(this, termName.getNamespace(), providerTerm);
} else if (termSchemaDefinition != null && !termSchemaDefinition.isEmpty()) {
for (CsdlSchema schema : termSchemaDefinition) {
if (schema.getNamespace().equalsIgnoreCase(termName.getNamespace())) {
List<CsdlTerm> terms = schema.getTerms();
for (CsdlTerm term : terms) {
if (term.getName().equals(termName.getName())) {
return new EdmTermImpl(this, termName.getNamespace(), term);
}
}
}
}
}
return null;
} catch (ODataException e) {
throw new EdmException(e);
}
}
示例11: compatibleTo
import org.apache.olingo.commons.api.edm.EdmException; //导入依赖的package包/类
@Override
public boolean compatibleTo(final EdmType targetType) {
EdmStructuredType sourceType = this;
if (targetType == null) {
throw new EdmException("Target type must not be null");
}
while (!sourceType.getName().equals(targetType.getName())
|| !sourceType.getNamespace().equals(targetType.getNamespace())) {
sourceType = sourceType.getBaseType();
if (sourceType == null) {
return false;
}
}
return true;
}
示例12: getUnderlyingType
import org.apache.olingo.commons.api.edm.EdmException; //导入依赖的package包/类
@Override
public EdmPrimitiveType getUnderlyingType() {
if (edmPrimitiveTypeInstance == null) {
try {
if (typeDefinition.getUnderlyingType() == null) {
throw new EdmException("Underlying Type for type definition: "
+ typeName.getFullQualifiedNameAsString() + " must not be null.");
}
edmPrimitiveTypeInstance = EdmPrimitiveTypeFactory.getInstance(
EdmPrimitiveTypeKind.valueOfFQN(typeDefinition.getUnderlyingType()));
} catch (IllegalArgumentException e) {
throw new EdmException("Invalid underlying type: " + typeDefinition.getUnderlyingType(), e);
}
}
return edmPrimitiveTypeInstance;
}
示例13: getExpressionType
import org.apache.olingo.commons.api.edm.EdmException; //导入依赖的package包/类
@Override
public EdmExpressionType getExpressionType() {
switch (csdlExp.getType()) {
case And:
return EdmExpressionType.And;
case Or:
return EdmExpressionType.Or;
case Not:
return EdmExpressionType.Not;
case Eq:
return EdmExpressionType.Eq;
case Ne:
return EdmExpressionType.Ne;
case Gt:
return EdmExpressionType.Gt;
case Ge:
return EdmExpressionType.Ge;
case Lt:
return EdmExpressionType.Lt;
case Le:
return EdmExpressionType.Le;
default:
throw new EdmException("Invalid Expressiontype for logical or comparison expression: " + csdlExp.getType());
}
}
示例14: EdmEnumTypeImpl
import org.apache.olingo.commons.api.edm.EdmException; //导入依赖的package包/类
public EdmEnumTypeImpl(final Edm edm, final FullQualifiedName enumName, final CsdlEnumType enumType) {
super(edm, enumName, EdmTypeKind.ENUM, enumType);
if (enumType.getUnderlyingType() == null) {
underlyingType = EdmPrimitiveTypeFactory.getInstance(EdmPrimitiveTypeKind.Int32);
} else {
final EdmPrimitiveTypeKind underlyingTypeKind = EdmPrimitiveTypeKind.valueOfFQN(enumType.getUnderlyingType());
if (underlyingTypeKind == EdmPrimitiveTypeKind.Byte
|| underlyingTypeKind == EdmPrimitiveTypeKind.SByte
|| underlyingTypeKind == EdmPrimitiveTypeKind.Int16
|| underlyingTypeKind == EdmPrimitiveTypeKind.Int32
|| underlyingTypeKind == EdmPrimitiveTypeKind.Int64) {
underlyingType = EdmPrimitiveTypeFactory.getInstance(underlyingTypeKind);
} else {
throw new EdmException("Not allowed as underlying type: " + underlyingTypeKind);
}
}
this.enumType = enumType;
this.enumName = enumName;
}
示例15: getPartner
import org.apache.olingo.commons.api.edm.EdmException; //导入依赖的package包/类
@Override
public EdmNavigationProperty getPartner() {
if (partnerNavigationProperty == null) {
String partner = navigationProperty.getPartner();
if (partner != null) {
EdmStructuredType type = getType();
EdmNavigationProperty property = null;
final String[] split = partner.split("/");
for (String element : split) {
property = type.getNavigationProperty(element);
if (property == null) {
throw new EdmException("Cannot find navigation property with name: " + element
+ " at type " + type.getName());
}
type = property.getType();
}
partnerNavigationProperty = property;
}
}
return partnerNavigationProperty;
}