Fix sparql generation for linked data.

Nested references no longer seem to work, either for referencing return
values or in filters.  So build predicate statements whenever there is
a relationship between types.

Change-Id: Id9015047764d36ed3854bf4a785fb6b5bcba639b
Reviewed-by: Robin Burchell <robin+qt@viroteck.net>
Exclude query results located on removed media.

Only include results whose tracker:available property is true, or if
query is for an aggregate type then only include results which aggregate
data from a item with a true tracker:available property.

Change-Id: Iaf7487fb33fa0f7bdc0537ba3240fa4cb2c93a44
Reviewed-by: Robin Burchell <robin+qt@viroteck.net>