本文整理汇总了Java中org.apache.olingo.odata2.api.processor.ODataContext.startRuntimeMeasurement方法的典型用法代码示例。如果您正苦于以下问题:Java ODataContext.startRuntimeMeasurement方法的具体用法?Java ODataContext.startRuntimeMeasurement怎么用?Java ODataContext.startRuntimeMeasurement使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.olingo.odata2.api.processor.ODataContext
的用法示例。
在下文中一共展示了ODataContext.startRuntimeMeasurement方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: updateEntityMedia
import org.apache.olingo.odata2.api.processor.ODataContext; //导入方法依赖的package包/类
@Override
public ODataResponse updateEntityMedia(final PutMergePatchUriInfo uriInfo, final InputStream content,
final String requestContentType, final String contentType) throws ODataException {
final Object data = retrieveData(
uriInfo.getStartEntitySet(),
uriInfo.getKeyPredicates(),
uriInfo.getFunctionImport(),
mapFunctionParameters(uriInfo.getFunctionImportParameters()),
uriInfo.getNavigationSegments()).getFirst();
if (!appliesFilter(data, uriInfo.getFilter())) {
throw new ODataNotFoundException(ODataNotFoundException.ENTITY);
}
ODataContext context = getContext();
final int timingHandle = context.startRuntimeMeasurement("EntityProvider", "readBinary");
final byte[] value = EntityProvider.readBinary(content);
context.stopRuntimeMeasurement(timingHandle);
final EdmEntitySet entitySet = uriInfo.getTargetEntitySet();
dataSource.writeBinaryData(entitySet, data, new BinaryData(value, requestContentType));
return ODataResponse.newBuilder().eTag(constructETag(entitySet, data)).build();
}
示例2: writeEntry
import org.apache.olingo.odata2.api.processor.ODataContext; //导入方法依赖的package包/类
private <T> ODataResponse writeEntry(final EdmEntitySet entitySet, final ExpandSelectTreeNode expandSelectTree,
final T data, final String contentType) throws ODataException {
final EdmEntityType entityType = entitySet.getEntityType();
final Map<String, Object> values = getStructuralTypeValueMap(data, entityType);
ODataContext context = getContext();
EntityProviderWriteProperties writeProperties = EntityProviderWriteProperties
.serviceRoot(context.getPathInfo().getServiceRoot())
.expandSelectTree(expandSelectTree)
.callbacks(getCallbacks(data, entityType))
.build();
final int timingHandle = context.startRuntimeMeasurement("EntityProvider", "writeEntry");
final ODataResponse response = EntityProvider.writeEntry(contentType, entitySet, values, writeProperties);
context.stopRuntimeMeasurement(timingHandle);
return response;
}
示例3: parseEntry
import org.apache.olingo.odata2.api.processor.ODataContext; //导入方法依赖的package包/类
private ODataEntry parseEntry(final EdmEntitySet entitySet, final InputStream content,
final String requestContentType, final EntityProviderReadProperties properties) throws ODataBadRequestException {
ODataContext context = getContext();
final int timingHandle = context.startRuntimeMeasurement("EntityConsumer", "readEntry");
ODataEntry entryValues;
try {
entryValues = EntityProvider.readEntry(requestContentType, entitySet, content, properties);
} catch (final EntityProviderException e) {
throw new ODataBadRequestException(ODataBadRequestException.BODY, e);
}
context.stopRuntimeMeasurement(timingHandle);
return entryValues;
}
示例4: parseLinkUri
import org.apache.olingo.odata2.api.processor.ODataContext; //导入方法依赖的package包/类
private Map<String, Object> parseLinkUri(final EdmEntitySet targetEntitySet, final String uriString)
throws EdmException {
ODataContext context = getContext();
final int timingHandle = context.startRuntimeMeasurement("UriParser", "getKeyPredicatesFromEntityLink");
List<KeyPredicate> key = null;
try {
key = UriParser.getKeyPredicatesFromEntityLink(targetEntitySet, uriString,
context.getPathInfo().getServiceRoot());
} catch (ODataException e) {
// We don't understand the link target. This could also be seen as an error.
}
context.stopRuntimeMeasurement(timingHandle);
return key == null ? null : mapKey(key);
}
示例5: updateEntityMedia
import org.apache.olingo.odata2.api.processor.ODataContext; //导入方法依赖的package包/类
@Override
public ODataResponse updateEntityMedia(final PutMergePatchUriInfo uriInfo, final InputStream content,
final String requestContentType, final String contentType) throws ODataException {
final Object data = retrieveData(
uriInfo.getStartEntitySet(),
uriInfo.getKeyPredicates(),
uriInfo.getFunctionImport(),
mapFunctionParameters(uriInfo.getFunctionImportParameters()),
uriInfo.getNavigationSegments());
if (!appliesFilter(data, uriInfo.getFilter())) {
throw new ODataNotFoundException(ODataNotFoundException.ENTITY);
}
ODataContext context = getContext();
final int timingHandle = context.startRuntimeMeasurement("EntityProvider", "readBinary");
final byte[] value = EntityProvider.readBinary(content);
context.stopRuntimeMeasurement(timingHandle);
final EdmEntitySet entitySet = uriInfo.getTargetEntitySet();
dataSource.writeBinaryData(entitySet, data, new BinaryData(value, requestContentType));
return ODataResponse.newBuilder().eTag(constructETag(entitySet, data)).build();
}
示例6: getStructuralTypeTypeMap
import org.apache.olingo.odata2.api.processor.ODataContext; //导入方法依赖的package包/类
private <T> Map<String, Object> getStructuralTypeTypeMap(final T data, final EdmStructuralType type)
throws ODataException {
ODataContext context = getContext();
final int timingHandle = context.startRuntimeMeasurement(getClass().getSimpleName(), "getStructuralTypeTypeMap");
Map<String, Object> typeMap = new HashMap<String, Object>();
for (final String propertyName : type.getPropertyNames()) {
final EdmProperty property = (EdmProperty) type.getProperty(propertyName);
if (property.isSimple()) {
typeMap.put(propertyName, valueAccess.getPropertyType(data, property));
} else {
typeMap.put(propertyName, getStructuralTypeTypeMap(valueAccess.getPropertyValue(data, property),
(EdmStructuralType) property.getType()));
}
}
context.stopRuntimeMeasurement(timingHandle);
return typeMap;
}
示例7: readEntityLink
import org.apache.olingo.odata2.api.processor.ODataContext; //导入方法依赖的package包/类
@Override
public ODataResponse readEntityLink(final GetEntityLinkUriInfo uriInfo, final String contentType)
throws ODataException {
final Object data = retrieveData(
uriInfo.getStartEntitySet(),
uriInfo.getKeyPredicates(),
uriInfo.getFunctionImport(),
mapFunctionParameters(uriInfo.getFunctionImportParameters()),
uriInfo.getNavigationSegments()).getFirst();
// if (!appliesFilter(data, uriInfo.getFilter()))
if (data == null) {
throw new ODataNotFoundException(ODataNotFoundException.ENTITY);
}
final EdmEntitySet entitySet = uriInfo.getTargetEntitySet();
Map<String, Object> values = new HashMap<>();
for (final EdmProperty property : entitySet.getEntityType().getKeyProperties()) {
values.put(property.getName(), valueAccess.getPropertyValue(data, property));
}
ODataContext context = getContext();
final EntityProviderWriteProperties entryProperties = EntityProviderWriteProperties
.serviceRoot(context.getPathInfo().getServiceRoot())
.build();
final int timingHandle = context.startRuntimeMeasurement("EntityProvider", "writeLink");
final ODataResponse response = EntityProvider.writeLink(contentType, entitySet, values, entryProperties);
context.stopRuntimeMeasurement(timingHandle);
return ODataResponse.fromResponse(response).build();
}
示例8: readEntityComplexProperty
import org.apache.olingo.odata2.api.processor.ODataContext; //导入方法依赖的package包/类
@Override
public ODataResponse readEntityComplexProperty(final GetComplexPropertyUriInfo uriInfo, final String contentType)
throws ODataException {
Object data = retrieveData(
uriInfo.getStartEntitySet(),
uriInfo.getKeyPredicates(),
uriInfo.getFunctionImport(),
mapFunctionParameters(uriInfo.getFunctionImportParameters()),
uriInfo.getNavigationSegments()).getFirst();
// if (!appliesFilter(data, uriInfo.getFilter()))
if (data == null) {
throw new ODataNotFoundException(ODataNotFoundException.ENTITY);
}
final List<EdmProperty> propertyPath = uriInfo.getPropertyPath();
final EdmProperty property = propertyPath.get(propertyPath.size() - 1);
final Object value = property.isSimple() ?
property.getMapping() == null || property.getMapping().getMediaResourceMimeTypeKey() == null ?
getPropertyValue(data, propertyPath) : getSimpleTypeValueMap(data, propertyPath) :
getStructuralTypeValueMap(getPropertyValue(data, propertyPath), (EdmStructuralType) property.getType());
ODataContext context = getContext();
final int timingHandle = context.startRuntimeMeasurement("EntityProvider", "writeProperty");
final ODataResponse response = EntityProvider.writeProperty(contentType, property, value);
context.stopRuntimeMeasurement(timingHandle);
return ODataResponse.fromResponse(response).eTag(constructETag(uriInfo.getTargetEntitySet(), data)).build();
}
示例9: updateEntitySimplePropertyValue
import org.apache.olingo.odata2.api.processor.ODataContext; //导入方法依赖的package包/类
@Override
public ODataResponse updateEntitySimplePropertyValue(final PutMergePatchUriInfo uriInfo, final InputStream content,
final String requestContentType, final String contentType) throws ODataException {
Object data = retrieveData(
uriInfo.getStartEntitySet(),
uriInfo.getKeyPredicates(),
uriInfo.getFunctionImport(),
mapFunctionParameters(uriInfo.getFunctionImportParameters()),
uriInfo.getNavigationSegments()).getFirst();
if (!appliesFilter(data, uriInfo.getFilter())) {
throw new ODataNotFoundException(ODataNotFoundException.ENTITY);
}
final List<EdmProperty> propertyPath = uriInfo.getPropertyPath();
final EdmProperty property = propertyPath.get(propertyPath.size() - 1);
data = getPropertyValue(data, propertyPath.subList(0, propertyPath.size() - 1));
ODataContext context = getContext();
int timingHandle = context.startRuntimeMeasurement("EntityConsumer", "readPropertyValue");
Object value;
try {
value = EntityProvider.readPropertyValue(property, content);
} catch (final EntityProviderException e) {
throw new ODataBadRequestException(ODataBadRequestException.BODY, e);
}
context.stopRuntimeMeasurement(timingHandle);
valueAccess.setPropertyValue(data, property, value);
valueAccess.setMappingValue(data, property.getMapping(), requestContentType);
return ODataResponse.newBuilder().eTag(constructETag(uriInfo.getTargetEntitySet(), data)).build();
}
示例10: parseLink
import org.apache.olingo.odata2.api.processor.ODataContext; //导入方法依赖的package包/类
private Map<String, Object> parseLink(final EdmEntitySet entitySet, final InputStream content,
final String contentType) throws ODataException {
ODataContext context = getContext();
final int timingHandle = context.startRuntimeMeasurement("EntityProvider", "readLink");
final String uriString = EntityProvider.readLink(contentType, entitySet, content);
context.stopRuntimeMeasurement(timingHandle);
final Map<String, Object> targetKeys = parseLinkUri(entitySet, uriString);
if (targetKeys == null) {
throw new ODataBadRequestException(ODataBadRequestException.BODY);
}
return targetKeys;
}
示例11: appliesFilter
import org.apache.olingo.odata2.api.processor.ODataContext; //导入方法依赖的package包/类
private <T> boolean appliesFilter(final T data, final FilterExpression filter) throws ODataException {
ODataContext context = getContext();
final int timingHandle = context.startRuntimeMeasurement(getClass().getSimpleName(), "appliesFilter");
try {
return data != null && (filter == null || evaluateExpression(data, filter.getExpression()).equals("true"));
} catch (final RuntimeException e) {
return false;
} finally {
context.stopRuntimeMeasurement(timingHandle);
}
}
示例12: getStructuralTypeValueMap
import org.apache.olingo.odata2.api.processor.ODataContext; //导入方法依赖的package包/类
private <T> Map<String, Object> getStructuralTypeValueMap(final T data, final EdmStructuralType type)
throws ODataException {
ODataContext context = getContext();
final int timingHandle = context.startRuntimeMeasurement(getClass().getSimpleName(), "getStructuralTypeValueMap");
Map<String, Object> valueMap = new HashMap<>();
EdmMapping mapping = type.getMapping();
if (mapping != null) {
handleMimeType(data, mapping, valueMap);
}
for (final String propertyName : type.getPropertyNames()) {
final EdmProperty property = (EdmProperty) type.getProperty(propertyName);
final Object value = valueAccess.getPropertyValue(data, property);
if (property.isSimple()) {
if (property.getMapping() == null || property.getMapping().getMediaResourceMimeTypeKey() == null) {
valueMap.put(propertyName, value);
} else {
// TODO: enable MIME type mapping outside the current subtree
valueMap.put(propertyName, getSimpleTypeValueMap(data, Collections.singletonList(property)));
}
} else {
valueMap.put(propertyName, getStructuralTypeValueMap(value, (EdmStructuralType) property.getType()));
}
}
context.stopRuntimeMeasurement(timingHandle);
return valueMap;
}
示例13: setStructuralTypeValuesFromMap
import org.apache.olingo.odata2.api.processor.ODataContext; //导入方法依赖的package包/类
private <T> void setStructuralTypeValuesFromMap(final T data, final EdmStructuralType type,
final Map<String, Object> valueMap, final boolean merge) throws ODataException {
if (data == null) {
throw new ODataException("Unable to set structural type values to NULL data.");
}
ODataContext context = getContext();
final int timingHandle =
context.startRuntimeMeasurement(getClass().getSimpleName(), "setStructuralTypeValuesFromMap");
for (final String propertyName : type.getPropertyNames()) {
final EdmProperty property = (EdmProperty) type.getProperty(propertyName);
if (type instanceof EdmEntityType && ((EdmEntityType) type).getKeyProperties().contains(property)) {
Object v = valueAccess.getPropertyValue(data, property);
if (v != null) {
continue;
}
}
if (!merge || valueMap != null && valueMap.containsKey(propertyName)) {
final Object value = valueMap == null ? null : valueMap.get(propertyName);
if (property.isSimple()) {
valueAccess.setPropertyValue(data, property, value);
} else {
@SuppressWarnings("unchecked")
final Map<String, Object> values = (Map<String, Object>) value;
Object complexData = valueAccess.getPropertyValue(data, property);
if (complexData == null) {
Class<?> complexClass = valueAccess.getPropertyType(data, property);
complexData = createInstance(complexClass);
valueAccess.setPropertyValue(data, property, complexData);
}
setStructuralTypeValuesFromMap(complexData,
(EdmStructuralType) property.getType(), values, merge);
}
}
}
context.stopRuntimeMeasurement(timingHandle);
}
示例14: executeFunctionImport
import org.apache.olingo.odata2.api.processor.ODataContext; //导入方法依赖的package包/类
@Override
public ODataResponse executeFunctionImport(final GetFunctionImportUriInfo uriInfo, final String contentType)
throws ODataException {
final EdmFunctionImport functionImport = uriInfo.getFunctionImport();
final EdmType type = functionImport.getReturnType().getType();
final Object data = dataSource.readData(
functionImport,
mapFunctionParameters(uriInfo.getFunctionImportParameters()),
null);
if (data == null) {
throw new ODataNotFoundException(ODataHttpException.COMMON);
}
Object value;
if (type.getKind() == EdmTypeKind.SIMPLE) {
value = type == EdmSimpleTypeKind.Binary.getEdmSimpleTypeInstance() ?
((BinaryData) data).getData() : data;
} else if (functionImport.getReturnType().getMultiplicity() == EdmMultiplicity.MANY) {
List<Map<String, Object>> values = new ArrayList<Map<String, Object>>();
for (final Object typeData : (List<?>) data) {
values.add(getStructuralTypeValueMap(typeData, (EdmStructuralType) type));
}
value = values;
} else {
value = getStructuralTypeValueMap(data, (EdmStructuralType) type);
}
ODataContext context = getContext();
final EntityProviderWriteProperties entryProperties = EntityProviderWriteProperties
.serviceRoot(context.getPathInfo().getServiceRoot()).build();
final int timingHandle = context.startRuntimeMeasurement("EntityProvider", "writeFunctionImport");
final ODataResponse response =
EntityProvider.writeFunctionImport(contentType, functionImport, value, entryProperties);
context.stopRuntimeMeasurement(timingHandle);
return ODataResponse.fromResponse(response).build();
}
示例15: readEntityLink
import org.apache.olingo.odata2.api.processor.ODataContext; //导入方法依赖的package包/类
@Override
public ODataResponse readEntityLink(final GetEntityLinkUriInfo uriInfo, final String contentType)
throws ODataException {
final Object data = retrieveData(
uriInfo.getStartEntitySet(),
uriInfo.getKeyPredicates(),
uriInfo.getFunctionImport(),
mapFunctionParameters(uriInfo.getFunctionImportParameters()),
uriInfo.getNavigationSegments());
if (data == null) {
throw new ODataNotFoundException(ODataNotFoundException.ENTITY);
}
final EdmEntitySet entitySet = uriInfo.getTargetEntitySet();
Map<String, Object> values = new HashMap<String, Object>();
for (final EdmProperty property : entitySet.getEntityType().getKeyProperties()) {
values.put(property.getName(), valueAccess.getPropertyValue(data, property));
}
ODataContext context = getContext();
final EntityProviderWriteProperties entryProperties = EntityProviderWriteProperties
.serviceRoot(context.getPathInfo().getServiceRoot())
.build();
final int timingHandle = context.startRuntimeMeasurement("EntityProvider", "writeLink");
final ODataResponse response = EntityProvider.writeLink(contentType, entitySet, values, entryProperties);
context.stopRuntimeMeasurement(timingHandle);
return ODataResponse.fromResponse(response).build();
}