本文整理汇总了Java中org.apache.olingo.odata2.api.ep.EntityProvider.writePropertyValue方法的典型用法代码示例。如果您正苦于以下问题:Java EntityProvider.writePropertyValue方法的具体用法?Java EntityProvider.writePropertyValue怎么用?Java EntityProvider.writePropertyValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.olingo.odata2.api.ep.EntityProvider
的用法示例。
在下文中一共展示了EntityProvider.writePropertyValue方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: readEntitySimplePropertyValue
import org.apache.olingo.odata2.api.ep.EntityProvider; //导入方法依赖的package包/类
@Override
public ODataResponse readEntitySimplePropertyValue(final GetSimplePropertyUriInfo uriInfo, final String contentType)
throws ODataException {
final List<EdmProperty> propertyPath = uriInfo.getPropertyPath();
final EdmProperty property = propertyPath.get(propertyPath.size() - 1);
final String mappedKeyName =
(String) uriInfo.getTargetEntitySet().getEntityType().getKeyProperties().get(0).getMapping().getObject();
final String keyValue = uriInfo.getKeyPredicates().get(0).getLiteral();
final int index = indexOf(mappedKeyName, keyValue);
if ((index < 0) || (index > records.size())) {
throw new ODataNotFoundException(ODataNotFoundException.ENTITY.addContent(keyValue));
}
final HashMap<String, String> record = records.get(index);
final String mappedPropertyName = (String) property.getMapping().getObject();
final Object value = record.get(mappedPropertyName);
final ODataResponse response = EntityProvider.writePropertyValue(property, value);
return response;
}
示例2: readEntitySimplePropertyValue
import org.apache.olingo.odata2.api.ep.EntityProvider; //导入方法依赖的package包/类
@Override
public ODataResponse readEntitySimplePropertyValue(GetSimplePropertyUriInfo uri_info, String content_type)
throws ODataException
{
try
{
Object value = readPropertyValue(uri_info);
EdmProperty target = uri_info.getPropertyPath().get(uri_info.getPropertyPath().size() - 1);
if (target.getName().equals("Metalink")) // Metalink/$value
{
return ODataResponse
.fromResponse(
EntityProvider.writeBinary(MetalinkBuilder.CONTENT_TYPE,
value.toString().getBytes("UTF-8")))
.header("Content-Disposition",
"inline; filename=product" + MetalinkBuilder.FILE_EXTENSION)
.build();
}
else
{
return EntityProvider.writePropertyValue(target, value);
}
}
catch (UnsupportedEncodingException e)
{
throw new ExpectedException(e.getMessage());
}
}
示例3: writeContent
import org.apache.olingo.odata2.api.ep.EntityProvider; //导入方法依赖的package包/类
private ODataResponse writeContent(Edm edm, UriInfoWithType uriInfo, Object content)
throws ODataApplicationException, EdmException, EntityProviderException, URISyntaxException, IOException {
String responseContentType = getContentType();
ODataResponse response;
switch (uriInfo.getUriType()) {
case URI4:
case URI5:
// simple property
final List<EdmProperty> simplePropertyPath = uriInfo.getPropertyPath();
final EdmProperty simpleProperty = simplePropertyPath.get(simplePropertyPath.size() - 1);
responseContentType = simpleProperty.getMimeType();
if (uriInfo.isValue()) {
response = EntityProvider.writePropertyValue(simpleProperty, content);
responseContentType = TEXT_PLAIN_WITH_CS_UTF_8.toString();
} else {
response = EntityProvider.writeProperty(getContentType(), simpleProperty, content);
}
break;
case URI3:
// complex property
final List<EdmProperty> complexPropertyPath = uriInfo.getPropertyPath();
final EdmProperty complexProperty = complexPropertyPath.get(complexPropertyPath.size() - 1);
response = EntityProvider.writeProperty(responseContentType, complexProperty, content);
break;
case URI7A:
// $links with 0..1 cardinality property
final EdmEntitySet targetLinkEntitySet = uriInfo.getTargetEntitySet();
EntityProviderWriteProperties linkProperties =
EntityProviderWriteProperties.serviceRoot(new URI(serviceUri + SEPARATOR)).build();
@SuppressWarnings("unchecked")
final Map<String, Object> linkMap = (Map<String, Object>) content;
response = EntityProvider.writeLink(responseContentType, targetLinkEntitySet, linkMap, linkProperties);
break;
case URI7B:
// $links with * cardinality property
final EdmEntitySet targetLinksEntitySet = uriInfo.getTargetEntitySet();
EntityProviderWriteProperties linksProperties =
EntityProviderWriteProperties.serviceRoot(new URI(serviceUri + SEPARATOR)).build();
@SuppressWarnings("unchecked")
final List<Map<String, Object>> linksMap = (List<Map<String, Object>>) content;
response = EntityProvider.writeLinks(responseContentType, targetLinksEntitySet, linksMap, linksProperties);
break;
case URI1:
case URI2:
case URI6A:
case URI6B:
// Entity
final EdmEntitySet targetEntitySet = uriInfo.getTargetEntitySet();
EntityProviderWriteProperties properties =
EntityProviderWriteProperties.serviceRoot(new URI(serviceUri + SEPARATOR)).build();
@SuppressWarnings("unchecked")
final Map<String, Object> objectMap = (Map<String, Object>) content;
response = EntityProvider.writeEntry(responseContentType, targetEntitySet, objectMap, properties);
break;
case URI9:
// $batch
@SuppressWarnings("unchecked")
final List<Olingo2BatchRequest> batchParts = (List<Olingo2BatchRequest>) content;
response = parseBatchRequest(edm, batchParts);
break;
default:
// notify exception and return!!!
throw new ODataApplicationException("Unsupported resource type " + uriInfo.getTargetType(),
Locale.ENGLISH);
}
return response.getContentHeader() != null ? response
: ODataResponse.fromResponse(response).contentHeader(responseContentType).build();
}