Fixes RDF export of subobjects

Partial integration of the patch https://gerrit.wikimedia.org/r/#/c/70047/4
from Dbeeson
Going through the code, its mostly the same with additional handling for subobjects and with some refactoring.
All we can do is add tests to this.