private TemplateResult getRelations(
      DataAccess access, DataTemplate template, Map<String, String> param) throws BaseException {
    DataSource dataSource = getDataSource(access, param.get(Helper.Keys.SourceId));
    if (dataSource.getState() != DataInformation.DataState.READY)
      throw new NotReadyException("The datasource %s is not yet ready.", dataSource.getId());

    String relationId = param.get(Helper.Keys.RelationId);
    String fromId = param.get(Helper.Keys.FromId);
    String toId = param.get(Helper.Keys.ToId);

    if (relationId != null) {
      Relation relation = dataSource.getRelation(relationId);
      return template.transform(relation);
    } else if (fromId != null || toId != null) {
      Relation[] relations = dataSource.getRelations(fromId, toId);
      return template.transform(relations);
    } else {

      Relation[] relations = dataSource.getRelations();
      return template.transform(relations);
    }
  }