本文整理汇总了Java中org.apache.olingo.server.api.uri.UriResourceEntitySet.getKeyPredicates方法的典型用法代码示例。如果您正苦于以下问题:Java UriResourceEntitySet.getKeyPredicates方法的具体用法?Java UriResourceEntitySet.getKeyPredicates怎么用?Java UriResourceEntitySet.getKeyPredicates使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.olingo.server.api.uri.UriResourceEntitySet
的用法示例。
在下文中一共展示了UriResourceEntitySet.getKeyPredicates方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: deleteEntity
import org.apache.olingo.server.api.uri.UriResourceEntitySet; //导入方法依赖的package包/类
public static void deleteEntity(RdfEdmProvider rdfEdmProvider, UriInfo uriInfo) throws OData2SparqlException {
SparqlStatement sparqlStatement = null;
// 1. Retrieve the entity set which belongs to the requested entity
List<UriResource> resourcePaths = uriInfo.getUriResourceParts();
// Note: only in our example we can assume that the first segment is the EntitySet
UriResourceEntitySet uriResourceEntitySet = (UriResourceEntitySet) resourcePaths.get(0);
EdmEntitySet edmEntitySet = uriResourceEntitySet.getEntitySet();
RdfEntityType entityType = rdfEdmProvider.getRdfEntityTypefromEdmEntitySet(edmEntitySet);
// 2. delete the data in backend
List<UriParameter> keyPredicates = uriResourceEntitySet.getKeyPredicates();
SparqlCreateUpdateDeleteBuilder sparqlCreateUpdateDeleteBuilder = new SparqlCreateUpdateDeleteBuilder(
rdfEdmProvider);
try {
sparqlStatement = sparqlCreateUpdateDeleteBuilder.generateDeleteEntity(entityType, keyPredicates);
} catch (Exception e) {
log.error(e.getMessage());
throw new OData2SparqlException(e.getMessage());
}
sparqlStatement.executeDelete(rdfEdmProvider);
}
示例2: updateEntity
import org.apache.olingo.server.api.uri.UriResourceEntitySet; //导入方法依赖的package包/类
public static void updateEntity(RdfEdmProvider rdfEdmProvider, UriInfo uriInfo, Entity requestEntity,
HttpMethod httpMethod) throws OData2SparqlException {
SparqlStatement sparqlStatement = null;
// 1. Retrieve the entity set which belongs to the requested entity
List<UriResource> resourcePaths = uriInfo.getUriResourceParts();
// Note: only in our example we can assume that the first segment is the EntitySet
UriResourceEntitySet uriResourceEntitySet = (UriResourceEntitySet) resourcePaths.get(0);
EdmEntitySet edmEntitySet = uriResourceEntitySet.getEntitySet();
//EdmEntityType edmEntityType = edmEntitySet.getEntityType();
RdfEntityType entityType = rdfEdmProvider.getRdfEntityTypefromEdmEntitySet(edmEntitySet);
List<UriParameter> keyPredicates = uriResourceEntitySet.getKeyPredicates();
// Note that this updateEntity()-method is invoked for both PUT or PATCH operations
SparqlCreateUpdateDeleteBuilder sparqlCreateUpdateDeleteBuilder = new SparqlCreateUpdateDeleteBuilder(
rdfEdmProvider);
try {
sparqlStatement = sparqlCreateUpdateDeleteBuilder.generateUpdateEntity(entityType, keyPredicates,
requestEntity);
} catch (Exception e) {
log.error(e.getMessage());
throw new OData2SparqlException(e.getMessage());
}
sparqlStatement.executeDelete(rdfEdmProvider);
}
示例3: updatePrimitiveValue
import org.apache.olingo.server.api.uri.UriResourceEntitySet; //导入方法依赖的package包/类
public static void updatePrimitiveValue(RdfEdmProvider rdfEdmProvider, UriInfo uriInfo, Object entry)
throws OData2SparqlException {
SparqlStatement sparqlStatement = null;
// 1. Retrieve the entity set which belongs to the requested entity
List<UriResource> resourcePaths = uriInfo.getUriResourceParts();
// Note: only in our example we can assume that the first segment is the EntitySet
UriResourceEntitySet uriResourceEntitySet = (UriResourceEntitySet) resourcePaths.get(0);
EdmEntitySet edmEntitySet = uriResourceEntitySet.getEntitySet();
RdfEntityType entityType = rdfEdmProvider.getRdfEntityTypefromEdmEntitySet(edmEntitySet);
List<UriParameter> keyPredicates = uriResourceEntitySet.getKeyPredicates();
UriResourcePrimitiveProperty uriResourcePrimitiveProperty = (UriResourcePrimitiveProperty) resourcePaths.get(1);
EdmProperty edmProperty = uriResourcePrimitiveProperty.getProperty();
SparqlCreateUpdateDeleteBuilder sparqlCreateUpdateDeleteBuilder = new SparqlCreateUpdateDeleteBuilder(
rdfEdmProvider);
try {
sparqlStatement = sparqlCreateUpdateDeleteBuilder.generateUpdateEntitySimplePropertyValue(entityType,
keyPredicates, edmProperty.getName(), entry);
} catch (Exception e) {
log.error(e.getMessage());
throw new OData2SparqlException(e.getMessage());
}
sparqlStatement.executeUpdate(rdfEdmProvider);
}
示例4: deleteEntityReference
import org.apache.olingo.server.api.uri.UriResourceEntitySet; //导入方法依赖的package包/类
public static void deleteEntityReference(RdfEdmProvider rdfEdmProvider, UriInfo uriInfo) throws OData2SparqlException {
SparqlStatement sparqlStatement = null;
// 1. Retrieve the entity set which belongs to the requested entity
List<UriResource> resourcePaths = uriInfo.getUriResourceParts();
// Note: only in our example we can assume that the first segment is the EntitySet
UriResourceEntitySet uriResourceEntitySet = (UriResourceEntitySet) resourcePaths.get(0);
EdmEntitySet edmEntitySet = uriResourceEntitySet.getEntitySet();
RdfEntityType entityType = rdfEdmProvider.getRdfEntityTypefromEdmEntitySet(edmEntitySet);
List<UriParameter> entityKeyPredicates = uriResourceEntitySet.getKeyPredicates();
UriResourceNavigation uriResourceNavigation = (UriResourceNavigation) resourcePaths.get(1);
RdfAssociation navigationProperty = entityType
.findNavigationProperty(uriResourceNavigation.getProperty().getName());
List<UriParameter> navigationKeyPredicates = uriResourceNavigation.getKeyPredicates();
SparqlCreateUpdateDeleteBuilder sparqlCreateUpdateDeleteBuilder = new SparqlCreateUpdateDeleteBuilder(
rdfEdmProvider);
try {
sparqlStatement = sparqlCreateUpdateDeleteBuilder.generateDeleteLinkQuery( entityType, entityKeyPredicates,navigationProperty,navigationKeyPredicates);
} catch (Exception e) {
log.error(e.getMessage());
throw new OData2SparqlException(e.getMessage());
}
sparqlStatement.executeInsert(rdfEdmProvider);
}
示例5: visit
import org.apache.olingo.server.api.uri.UriResourceEntitySet; //导入方法依赖的package包/类
@Override
public void visit(UriResourceEntitySet info) {
this.edmEntitySet = info.getEntitySet();
this.edmEntityTable = findTable(edmEntitySet, this.metadata);
this.edmEntityTableGroup = new GroupSymbol("g0", this.edmEntityTable.getFullName()); //$NON-NLS-1$
this.fromClause = new UnaryFromClause(this.edmEntityTableGroup);
// URL is like /entitySet(key)s
if (info.getKeyPredicates() != null && !info.getKeyPredicates().isEmpty()) {
List<UriParameter> keys = info.getKeyPredicates();
try {
this.criteria = buildEntityKeyCriteria(this.edmEntityTable, this.edmEntityTableGroup, keys);
} catch (TeiidException e) {
this.exceptions.add(e);
}
}
}
示例6: deleteEntity
import org.apache.olingo.server.api.uri.UriResourceEntitySet; //导入方法依赖的package包/类
public void deleteEntity(ODataRequest request, ODataResponse response, UriInfo uriInfo)
throws ODataApplicationException {
// 1. Retrieve the entity set which belongs to the requested entity
List<UriResource> resourcePaths = uriInfo.getUriResourceParts();
// Note: only in our example we can assume that the first segment is the EntitySet
UriResourceEntitySet uriResourceEntitySet = (UriResourceEntitySet) resourcePaths.get(0);
EdmEntitySet edmEntitySet = uriResourceEntitySet.getEntitySet();
// 2. delete the data in backend
List<UriParameter> keyPredicates = uriResourceEntitySet.getKeyPredicates();
storage.deleteEntityData(edmEntitySet, keyPredicates);
//3. configure the response object
response.setStatusCode(HttpStatusCode.NO_CONTENT.getStatusCode());
}
示例7: updateEntity
import org.apache.olingo.server.api.uri.UriResourceEntitySet; //导入方法依赖的package包/类
public void updateEntity(ODataRequest request, ODataResponse response, UriInfo uriInfo,
ContentType requestFormat, ContentType responseFormat)
throws ODataApplicationException, DeserializerException, SerializerException {
// 1. Retrieve the entity set which belongs to the requested entity
List<UriResource> resourcePaths = uriInfo.getUriResourceParts();
// Note: only in our example we can assume that the first segment is the EntitySet
UriResourceEntitySet uriResourceEntitySet = (UriResourceEntitySet) resourcePaths.get(0);
EdmEntitySet edmEntitySet = uriResourceEntitySet.getEntitySet();
EdmEntityType edmEntityType = edmEntitySet.getEntityType();
// 2. update the data in backend
// 2.1. retrieve the payload from the PUT request for the entity to be updated
InputStream requestInputStream = request.getBody();
ODataDeserializer deserializer = odata.createDeserializer(requestFormat);
DeserializerResult result = deserializer.entity(requestInputStream, edmEntityType);
Entity requestEntity = result.getEntity();
// 2.2 do the modification in backend
List<UriParameter> keyPredicates = uriResourceEntitySet.getKeyPredicates();
// Note that this updateEntity()-method is invoked for both PUT or PATCH operations
HttpMethod httpMethod = request.getMethod();
storage.updateEntityData(edmEntitySet, keyPredicates, requestEntity, httpMethod);
//3. configure the response object
response.setStatusCode(HttpStatusCode.NO_CONTENT.getStatusCode());
}
示例8: updateEntity
import org.apache.olingo.server.api.uri.UriResourceEntitySet; //导入方法依赖的package包/类
public void updateEntity(ODataRequest request, ODataResponse response, UriInfo uriInfo,
ContentType requestFormat, ContentType responseFormat)
throws ODataApplicationException, DeserializerException, SerializerException {
// 1. Retrieve the entity set which belongs to the requested entity
List<UriResource> resourcePaths = uriInfo.getUriResourceParts();
// Note: only in our example we can assume that the first segment is the EntitySet
UriResourceEntitySet uriResourceEntitySet = (UriResourceEntitySet) resourcePaths.get(0);
EdmEntitySet edmEntitySet = uriResourceEntitySet.getEntitySet();
EdmEntityType edmEntityType = edmEntitySet.getEntityType();
// 2. update the data in backend
// 2.1. retrieve the payload from the PUT request for the entity to be updated
InputStream requestInputStream = request.getBody();
ODataDeserializer deserializer = this.odata.createDeserializer(requestFormat);
DeserializerResult result = deserializer.entity(requestInputStream, edmEntityType);
Entity requestEntity = result.getEntity();
// 2.2 do the modification in backend
List<UriParameter> keyPredicates = uriResourceEntitySet.getKeyPredicates();
// Note that this updateEntity()-method is invoked for both PUT or PATCH operations
HttpMethod httpMethod = request.getMethod();
storage.updateEntityData(edmEntitySet, keyPredicates, requestEntity, httpMethod);
//3. configure the response object
response.setStatusCode(HttpStatusCode.NO_CONTENT.getStatusCode());
}
示例9: deleteEntity
import org.apache.olingo.server.api.uri.UriResourceEntitySet; //导入方法依赖的package包/类
public void deleteEntity(ODataRequest request, ODataResponse response, UriInfo uriInfo)
throws ODataApplicationException {
// 1. Retrieve the entity set which belongs to the requested entity
List<UriResource> resourcePaths = uriInfo.getUriResourceParts();
// Note: only in our example we can assume that the first segment is the EntitySet
UriResourceEntitySet uriResourceEntitySet = (UriResourceEntitySet) resourcePaths.get(0);
EdmEntitySet edmEntitySet = uriResourceEntitySet.getEntitySet();
// 2. delete the data in backend
List<UriParameter> keyPredicates = uriResourceEntitySet.getKeyPredicates();
storage.deleteEntityData(edmEntitySet, keyPredicates);
// 3. configure the response object
response.setStatusCode(HttpStatusCode.NO_CONTENT.getStatusCode());
}
示例10: readEntity
import org.apache.olingo.server.api.uri.UriResourceEntitySet; //导入方法依赖的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());
}
示例11: deletePrimitiveValue
import org.apache.olingo.server.api.uri.UriResourceEntitySet; //导入方法依赖的package包/类
public static void deletePrimitiveValue(RdfEdmProvider rdfEdmProvider, UriInfo uriInfo)
throws OData2SparqlException {
SparqlStatement sparqlStatement = null;
// 1. Retrieve the entity set which belongs to the requested entity
List<UriResource> resourcePaths = uriInfo.getUriResourceParts();
// Note: only in our example we can assume that the first segment is the EntitySet
UriResourceEntitySet uriResourceEntitySet = (UriResourceEntitySet) resourcePaths.get(0);
EdmEntitySet edmEntitySet = uriResourceEntitySet.getEntitySet();
RdfEntityType entityType = rdfEdmProvider.getRdfEntityTypefromEdmEntitySet(edmEntitySet);
List<UriParameter> keyPredicates = uriResourceEntitySet.getKeyPredicates();
UriResourcePrimitiveProperty uriResourcePrimitiveProperty = (UriResourcePrimitiveProperty) resourcePaths.get(1);
EdmProperty edmProperty = uriResourcePrimitiveProperty.getProperty();
SparqlCreateUpdateDeleteBuilder sparqlCreateUpdateDeleteBuilder = new SparqlCreateUpdateDeleteBuilder(
rdfEdmProvider);
try {
sparqlStatement = sparqlCreateUpdateDeleteBuilder.generateDeleteEntitySimplePropertyValue(entityType,
keyPredicates, edmProperty.getName());
} catch (Exception e) {
log.error(e.getMessage());
throw new OData2SparqlException(e.getMessage());
}
sparqlStatement.executeDelete(rdfEdmProvider);
}
示例12: writeEntityReference
import org.apache.olingo.server.api.uri.UriResourceEntitySet; //导入方法依赖的package包/类
public static void writeEntityReference(RdfEdmProvider rdfEdmProvider, UriInfo uriInfo,
List<URI> requestEntityReferences) throws OData2SparqlException {
SparqlStatement sparqlStatement = null;
// 1. Retrieve the entity set which belongs to the requested entity
List<UriResource> resourcePaths = uriInfo.getUriResourceParts();
// Note: only in our example we can assume that the first segment is the EntitySet
UriResourceEntitySet uriResourceEntitySet = (UriResourceEntitySet) resourcePaths.get(0);
EdmEntitySet edmEntitySet = uriResourceEntitySet.getEntitySet();
RdfEntityType entityType = rdfEdmProvider.getRdfEntityTypefromEdmEntitySet(edmEntitySet);
List<UriParameter> keyPredicates = uriResourceEntitySet.getKeyPredicates();
UriResourceNavigation uriResourceNavigation = (UriResourceNavigation) resourcePaths.get(1);
RdfAssociation navigationProperty = entityType
.findNavigationProperty(uriResourceNavigation.getProperty().getName());
SparqlCreateUpdateDeleteBuilder sparqlCreateUpdateDeleteBuilder = new SparqlCreateUpdateDeleteBuilder(
rdfEdmProvider);
try {
sparqlStatement = sparqlCreateUpdateDeleteBuilder.generateInsertLinkQuery( entityType, keyPredicates,navigationProperty,
requestEntityReferences);
} catch (Exception e) {
log.error(e.getMessage());
throw new OData2SparqlException(e.getMessage());
}
sparqlStatement.executeInsert(rdfEdmProvider);
}
示例13: updateEntityReference
import org.apache.olingo.server.api.uri.UriResourceEntitySet; //导入方法依赖的package包/类
public static void updateEntityReference(RdfEdmProvider rdfEdmProvider, UriInfo uriInfo,
List<URI> requestEntityReferences) throws OData2SparqlException {
SparqlStatement sparqlStatement = null;
// 1. Retrieve the entity set which belongs to the requested entity
List<UriResource> resourcePaths = uriInfo.getUriResourceParts();
// Note: only in our example we can assume that the first segment is the EntitySet
UriResourceEntitySet uriResourceEntitySet = (UriResourceEntitySet) resourcePaths.get(0);
EdmEntitySet edmEntitySet = uriResourceEntitySet.getEntitySet();
RdfEntityType entityType = rdfEdmProvider.getRdfEntityTypefromEdmEntitySet(edmEntitySet);
List<UriParameter> keyPredicates = uriResourceEntitySet.getKeyPredicates();
UriResourceNavigation uriResourceNavigation = (UriResourceNavigation) resourcePaths.get(1);
RdfAssociation navigationProperty = entityType
.findNavigationProperty(uriResourceNavigation.getProperty().getName());
List<UriParameter> navigationKeyPredicates = uriResourceNavigation.getKeyPredicates();
SparqlCreateUpdateDeleteBuilder sparqlCreateUpdateDeleteBuilder = new SparqlCreateUpdateDeleteBuilder(
rdfEdmProvider);
try {
sparqlStatement = sparqlCreateUpdateDeleteBuilder.generateUpdateLinkQuery( entityType, keyPredicates,navigationProperty,navigationKeyPredicates,
requestEntityReferences);
} catch (Exception e) {
log.error(e.getMessage());
throw new OData2SparqlException(e.getMessage());
}
sparqlStatement.executeInsert(rdfEdmProvider);
}
示例14: visit
import org.apache.olingo.server.api.uri.UriResourceEntitySet; //导入方法依赖的package包/类
@Override
public void visit(UriResourceEntitySet info) {
this.entitySet = info.getEntitySet().getName();
if (info.getKeyPredicates() != null && info.getKeyPredicates().size() > 0) {
this.navPath = buildEntityKey(info.getKeyPredicates());
this.singleEntity = true;
}
}
示例15: readEntity
import org.apache.olingo.server.api.uri.UriResourceEntitySet; //导入方法依赖的package包/类
public void readEntity(ODataRequest request, ODataResponse response, UriInfo uriInfo, ContentType responseFormat)
throws ODataApplicationException, SerializerException {
// 1. retrieve the Entity Type
List<UriResource> resourcePaths = uriInfo.getUriResourceParts();
// Note: only in our example we can assume that the first segment is the EntitySet
UriResourceEntitySet uriResourceEntitySet = (UriResourceEntitySet) resourcePaths.get(0);
EdmEntitySet edmEntitySet = uriResourceEntitySet.getEntitySet();
// 2. retrieve the data from backend
List<UriParameter> keyPredicates = uriResourceEntitySet.getKeyPredicates();
Entity entity = storage.readEntityData(edmEntitySet, keyPredicates);
// 3. serialize
EdmEntityType entityType = edmEntitySet.getEntityType();
ContextURL contextUrl = ContextURL.with().entitySet(edmEntitySet).suffix(ContextURL.Suffix.ENTITY).build();
// expand and select currently not supported
EntitySerializerOptions options = EntitySerializerOptions.with().contextURL(contextUrl).build();
ODataSerializer serializer = this.odata.createSerializer(responseFormat);
SerializerResult serializerResult = serializer.entity(serviceMetadata, entityType, entity, options);
InputStream entityStream = serializerResult.getContent();
//4. configure the response object
response.setContent(entityStream);
response.setStatusCode(HttpStatusCode.OK.getStatusCode());
response.setHeader(HttpHeader.CONTENT_TYPE, responseFormat.toContentTypeString());
}