Java Code Examples for org.apache.olingo.server.api.OData#createUriHelper()

The following examples show how to use org.apache.olingo.server.api.OData#createUriHelper() . 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: DataRequest.java    From olingo-odata4 with Apache License 2.0 6 votes vote down vote up
@Override
public ContextURL getContextURL(OData odata) throws SerializerException {
  final UriHelper helper = odata.createUriHelper();
  EdmProperty edmProperty = getUriResourceProperty().getProperty();

  ContextURL.Builder builder =
      ContextURL.with().entitySetOrSingletonOrType(getTargetEntitySet(getEntitySet(), getNavigations()));
  builder.keyPath(helper.buildContextURLKeyPredicate(getUriResourceEntitySet()
      .getKeyPredicates()));
  String navPath = buildNavPath(helper, getEntitySet().getEntityType(), getNavigations(), true);
  if (navPath != null && !navPath.isEmpty()) {
    builder.navOrPropertyPath(navPath+"/"+edmProperty.getName());
  } else {
    builder.navOrPropertyPath(edmProperty.getName());
  }
  setServiceRoot(builder, getODataRequest());      
  if (isPropertyComplex()) {
    EdmComplexType complexType = ((UriResourceComplexProperty) uriResourceProperty).getComplexType();
    String select = helper.buildContextURLSelectList(complexType, getUriInfo().getExpandOption(),
        getUriInfo().getSelectOption());
    builder.selectList(select);
  }
  return builder.build();
}
 
Example 2
Source File: DataCreator.java    From olingo-odata4 with Apache License 2.0 5 votes vote down vote up
private void createEntityId(final Edm edm, final OData odata,
    final String entitySetName, final EntityCollection entities) {
  final EdmEntitySet entitySet = edm.getEntityContainer().getEntitySet(entitySetName);
  final UriHelper helper = odata.createUriHelper();
  for (Entity entity : entities.getEntities()) {
    try {
      entity.setId(URI.create(helper.buildCanonicalURL(entitySet, entity)));
    } catch (final SerializerException e) {
      entity.setId(null);
    }
  }
}
 
Example 3
Source File: DataRequest.java    From olingo-odata4 with Apache License 2.0 5 votes vote down vote up
@Override
public ContextURL getContextURL(OData odata) throws SerializerException {
  // EntitySet based return
  final UriHelper helper = odata.createUriHelper();
  ContextURL.Builder builder = buildEntitySetContextURL(helper, getEntitySet(),
      getKeyPredicates(), getUriInfo(), getNavigations(), isCollection(), false, getODataRequest());
  return builder.build();
}
 
Example 4
Source File: DataRequest.java    From olingo-odata4 with Apache License 2.0 5 votes vote down vote up
@Override
public ContextURL getContextURL(OData odata) throws SerializerException {
  final UriHelper helper = odata.createUriHelper();
  ContextURL.Builder builder = buildEntitySetContextURL(helper,
      uriResourceSingleton.getSingleton(), null, getUriInfo(), getNavigations(), isCollection(), true, 
      getODataRequest());
  return builder.build();
}