I am in the middle of rewriting the whole code to be both Drupal and Views 3.x friendly.
A version 1.2 is going to be released within next weeks that will support every oData endpoint.

Use the development version at your own risk.

Remaining tasks are:

  • Improve admin UI
  • Refactor Parser (remove old parser)
  • Create Unit tests
  • Integrate complex fields, contextual filters and add tests for them
  • Support Relationships between Entities

Comments

sfcamil’s picture

First of all, nice to see you again and sorry for my English ;) and remember that I'm not an programmer.
Just some modifications made by me probably a good idea to start :

odata_handler_field_date.inc

- Sometimes $values->{$this->real_field} can be null
- Probably the version of my OData server (java-jpa-hibernate-oracle) sends me the date on other format? deleted double intval(intval

      if (isset($values->{$this->real_field})) {
          //  sfc changed formula to calculate the date
            $values->{$this->real_field} = (drupal_substr($values->{$this->real_field}, 6))/1000;
$ret = parent::render($values);
return $ret;
      }
      return null;
  }//
}

odata_handler_field_numeric.inc

- Copied from Views module function render($values) and modified like this. I have problems with long (oid) returned by my server.

//sfc: eliminate $remainder = abs($value) - intval(abs($value)); from default views handler. convert from float to int
	function render($values) {
		$value = $this -> get_value($values);
		$value = number_format($value, $this -> options['precision'], $this -> options['decimal'], $this -> options['separator']);

		// Check to see if hiding should happen before adding prefix and suffix.
		if ($this -> options['hide_empty'] && empty($value) && ($value !== 0 || $this -> options['empty_zero'])) {
			return '';
		}

		// Should we format as a plural.
		if (!empty($this -> options['format_plural'])) {
			$value = format_plural($value, $this -> options['format_plural_singular'], $this -> options['format_plural_plural']);
		}

data_plugin_query_odata.inc

- function query - initial was: function query($view, $get_count = FALSE) it's not like views3 . changed to function query($get_count = FALSE) and get view from:
$view = views_get_current_view();
- see that odata have a protocol to query conditional like substringof, endswith, startswith but here we missing the “eq true” at the end of condition (OData proto)
Added this to alter the query:

….
else {
                            $operator = '+or+';
                            if ($operator_needed)
                                $query .= $generaloperator;
                            $query .= '(';
                        }//if

                        // sfc: changed: $query  to add ) eq true if is condition
                        $uriConv = array(
                            'substringof',
                            'endswith',
                            'startswith'
                        );
                        foreach ($value as $key => $val) {
                            foreach ($uriConv as $keyConv => $valConv) {
                                if (strpos($val, $valConv)) {
                                    $value[$key] = $value[$key] . urlencode(' eq true');
                                }
                            }
                        }

                        $query .= implode($operator, $value);
                        $query .= ')';

- for me the results is in $reply['results'] not in $reply

//sfc
        if (isset($reply['results'])) {
            foreach ($reply['results'] as $key => $values) {
                //if (isset($values['__metadata']))unset($values['__metadata']);
                $rows[$key] = $values;
            }
        }

- later in the same function a do this, but I don’t remember why:

        if ($this -> pager -> use_pager()) {
            $view -> total_rows = $this -> pager -> get_total_items();
        } else {
            $view -> total_rows = $count -> data;
        }

        // sfc
        if (!empty($this -> limit) || !empty($this -> offset)) {
            $views_result = array_slice($views_result, $this -> offset, $this -> limit, TRUE);

odata_metadata.inc

- function odata_xml2array2 eliminate m: from OData response. Probably not the right solution but it’s ok for me.

   // sfc: eliminate m: from odata response. SimpleXMLElement don't like it.
    $text_xml = preg_replace('/m:/', '', $text_xml);

    $all_obj = new SimpleXMLElement($text_xml);
apanag’s picture

Hi there,

Just a quick heads up: I just finished rewriting the admin UI to be based on ctools multiform wizard instead of the ugly old code there. Next in my todo list is editing and rewriting the XML Parser (which hopefully will resolve your bug in #2124769: Namespace prefix m for IsDefaultEntityContainer).

After that I am going to see your suggestions. Really appreciate your feedback :-) Unfortunately Views code is in progress yet, so some features are missing.

PS. If your odata endpoint is a public one, can you type it here to run some additional tests?

Thank you!

apanag’s picture

Issue summary: View changes
sfcamil’s picture

Hi,
My endpoint it’s not public but I can give you a possibility to test but not here. I don’t know if Drupal have the possibility to send private message if not you have another possibility to send you a private message? (facebook, twitter ...)

Thanks !

apanag’s picture

Hi all,

hopefully tomorrow I will update the development version. There is a new custom oData parser, that will provide a class to handle odata objects and will be enhanced during future development As said earlier, the admin UI is completely rewritten, and the whole schema is saved in the db to avoid extra unnecessary requests. I guess some Ajax magic can be included there, but something like that goes later in the list.

Next thing is to implement the complex entities and to start writing some unit tests.

@sfcamil: Please use the contact form, in my Drupal profile.

apanag’s picture

Issue summary: View changes
apanag’s picture

Issue summary: View changes

I just pushed some commits that correct all the errors mentioned here.
Also there are some tests mostly for the oData admin UI for now.

Next is integration of complex fields and contextual filters.

:-)

apanag’s picture

Issue summary: View changes

Hi all,

The latest development code supports complex fields and contextual filters. Next in the todo list is to fully test them in order to prevent any bugs.
If anyone is willing to play with that code and report any bugs he/she might encounter, that would be great.

In the meantime I will create write SimpleTests for the Views UI.

PS. Requests for further development are more than welcome.
:-D

apanag’s picture

Issue summary: View changes
brooke_heaton’s picture

Does the module support ODATA API Token authentication? I have not been able to get this to work with tokens. Further information here: https://stage.fra.dot.gov/MasterWebService/PublicAPI/v1/Develop/QuickSta...

wub’s picture

What is the current status of this project? It seems like there hasn't been any activity in quite a while.

apanag’s picture

That's true @wub. All my active projects on the oData framework have been replaced and had to allocate my time to other tasks.