Java Code Examples for org.apache.olingo.odata2.api.ep.EntityProvider#writeProperty()

The following examples show how to use org.apache.olingo.odata2.api.ep.EntityProvider#writeProperty() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Processor.java    From DataHubSystem with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public ODataResponse readEntitySimpleProperty(GetSimplePropertyUriInfo uri_info, String content_type)
      throws ODataException
{
   Object value = readPropertyValue(uri_info);
   EdmProperty target = uri_info.getPropertyPath().get(uri_info.getPropertyPath().size() - 1);
   return EntityProvider.writeProperty(content_type, target, value);
}
 
Example 2
Source File: Processor.java    From DataHubSystem with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public ODataResponse readEntityComplexProperty(GetComplexPropertyUriInfo uri_info, String content_type)
      throws ODataException
{
   EdmProperty target = uri_info.getPropertyPath().get(uri_info.getPropertyPath().size() - 1);
   String entityTarget = uri_info.getTargetEntitySet().getName();
   Map<String, Object> values = Model.getEntitySet(entityTarget).getComplexProperty(uri_info);
   return EntityProvider.writeProperty(content_type, target, values);
}
 
Example 3
Source File: ListsProcessor.java    From olingo-odata2 with Apache License 2.0 5 votes vote down vote up
@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());

  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();
}
 
Example 4
Source File: ListsProcessor.java    From olingo-odata2 with Apache License 2.0 5 votes vote down vote up
@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());

  // 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();
}
 
Example 5
Source File: InvalidDataInScenarioTest.java    From olingo-odata2 with Apache License 2.0 5 votes vote down vote up
@Override
public ODataResponse readEntitySimpleProperty(GetSimplePropertyUriInfo uriInfo, String contentType)
    throws ODataException {
  EdmProperty edmProperty = uriInfo.getPropertyPath().get(0);
  Object value = null;
  if ("EmployeeId".equals(edmProperty.getName())) {
    // must be null for a specific test
    value = null;
  } else if ("TeamId".equals(edmProperty.getName())) {
    value = new Integer(520);
  }

  return EntityProvider.writeProperty(contentType, edmProperty, value);
}