GeoPubby  Version 0.1.0.0
IndexDataSource Class Reference

A DataSource that wraps another data source and adds an index of the resources in that data source. More...

Inheritance diagram for IndexDataSource:
Collaboration diagram for IndexDataSource:

Public Member Functions

 IndexDataSource (String indexIRI, DataSource wrapped)
 
boolean canDescribe (String absoluteIRI)
 Indicates whether this data source may have some information about a given IRI. More...
 
Model describeResource (String iri)
 Returns a subgraph of the data source describing one resource. More...
 
Model describeResource (String iri, String language)
 Returns a subgraph of the data source describing one resource. More...
 
Map< Property, Integer > getHighIndegreeProperties (String resourceIRI)
 If describeResource(String) omits properties of high indegree, then those properties must be returned here with the count of arcs. More...
 
Map< Property, Integer > getHighOutdegreeProperties (String resourceIRI)
 If describeResource(String) omits properties of high outdegree, then those properties must be returned here with the count of arcs. More...
 
Model listPropertyValues (String resourceIRI, Property property, boolean isInverse)
 Describe the index resource, and extract all the statements that have our property and the right subject/object. More...
 
List< Resource > getIndex ()
 A list of IRI resources described in this data source. More...
 
de.fuberlin.wiwiss.pubby.util.AutocompleteEngine< SearchRecordgetLabelIndex ()
 

Public Attributes

final DataSource wrapped
 

Static Public Attributes

static final int MAX_INDEX_SIZE = 1000000
 

Private Attributes

final String indexIRI
 

Static Private Attributes

static final String SIOC_NS = "http://rdfs.org/sioc/ns#"
 
static final Property siocContainerOf
 

Detailed Description

A DataSource that wraps another data source and adds an index of the resources in that data source.

Constructor & Destructor Documentation

◆ IndexDataSource()

IndexDataSource ( String  indexIRI,
DataSource  wrapped 
)
25  {
26  this.indexIRI = indexIRI;
27  this.wrapped = wrapped;
28  }
final String indexIRI
Definition: IndexDataSource.java:22
final DataSource wrapped
Definition: IndexDataSource.java:23

References IndexDataSource.indexIRI, and IndexDataSource.wrapped.

Member Function Documentation

◆ canDescribe()

boolean canDescribe ( String  absoluteIRI)

Indicates whether this data source may have some information about a given IRI.

If this is false, a client should not bother to call describeResource(String). This method is to allow for optimizations and should respond very fast.

It is also used by the UI to decide whether a click on a resource should go to a Pubby page (if true) or out to the Web (if false).

Parameters
absoluteIRIThe IRI of a resource to be described
Returns
true if this data source might have something about it

Implements DataSource.

31  {
32  return indexIRI.equals(absoluteIRI) || wrapped.canDescribe(absoluteIRI);
33  }
boolean canDescribe(String absoluteIRI)
Indicates whether this data source may have some information about a given IRI.

References DataSource.canDescribe(), IndexDataSource.indexIRI, and IndexDataSource.wrapped.

◆ describeResource() [1/2]

Model describeResource ( String  absoluteIRI)

Returns a subgraph of the data source describing one resource.

This should include both incoming and outgoing triples. However, it should exclude outgoing arcs where the property is a high-outdegree property, and it should exclude incoming arcs where the property is a high-indegree property. If labels for other resources are included in the result, then they will be used.

Parameters
absoluteIRIThe IRI of the resource to be described
Returns
A subgraph of the data source describing the resource.

Implements DataSource.

36  {
37  if (!indexIRI.equals(iri)) return wrapped.describeResource(iri);
38  Model result = ModelFactory.createDefaultModel();
39  result.setNsPrefix("sioc", SIOC_NS);
40  result.setNsPrefix("rdfs", RDFS.getURI());
41  Resource index = result.createResource(indexIRI);
42  // TODO: Get label from the vocabulary store, and make it i18nable
43  index.addProperty(RDFS.label, "Index of Resources", "en");
44  for (Resource r: wrapped.getIndex()) {
45  index.addProperty(siocContainerOf, r);
46  }
47  return result;
48  }
Model describeResource(String absoluteIRI)
Returns a subgraph of the data source describing one resource.
List< Resource > getIndex()
A list of IRI resources described in this data source.
static final String SIOC_NS
Definition: IndexDataSource.java:65
static final Property siocContainerOf
Definition: IndexDataSource.java:66

References DataSource.describeResource(), DataSource.getIndex(), IndexDataSource.indexIRI, IndexDataSource.SIOC_NS, IndexDataSource.siocContainerOf, and IndexDataSource.wrapped.

Referenced by IndexDataSource.listPropertyValues().

◆ describeResource() [2/2]

Model describeResource ( String  absoluteIRI,
String  language 
)

Returns a subgraph of the data source describing one resource.

This should include both incoming and outgoing triples. However, it should exclude outgoing arcs where the property is a high-outdegree property, and it should exclude incoming arcs where the property is a high-indegree property. If labels for other resources are included in the result, then they will be used.

Parameters
absoluteIRIThe IRI of the resource to be described
Returns
A subgraph of the data source describing the resource.

Implements DataSource.

51  {
52  if (!indexIRI.equals(iri)) return wrapped.describeResource(iri);
53  Model result = ModelFactory.createDefaultModel();
54  result.setNsPrefix("sioc", SIOC_NS);
55  result.setNsPrefix("rdfs", RDFS.getURI());
56  Resource index = result.createResource(indexIRI);
57  // TODO: Get label from the vocabulary store, and make it i18nable
58  index.addProperty(RDFS.label, "Index of Resources", language);
59  for (Resource r: wrapped.getIndex()) {
60  index.addProperty(siocContainerOf, r);
61  }
62  return result;
63  }

References DataSource.describeResource(), DataSource.getIndex(), IndexDataSource.indexIRI, IndexDataSource.SIOC_NS, IndexDataSource.siocContainerOf, and IndexDataSource.wrapped.

◆ getHighIndegreeProperties()

Map<Property, Integer> getHighIndegreeProperties ( String  resourceIRI)

If describeResource(String) omits properties of high indegree, then those properties must be returned here with the count of arcs.

If high-indegree properties are not omitted, or the resource doesn't have any, then an empty map or null may be returned. Entries with value 0 will be ignored.

Parameters
resourceIRIThe IRI of the resource to be described
Returns
A map containing high-indegree properties with number of arcs for the resource

Implements DataSource.

70  {
71  return wrapped.getHighIndegreeProperties(resourceIRI);
72  }
Map< Property, Integer > getHighIndegreeProperties(String resourceIRI)
If describeResource(String) omits properties of high indegree, then those properties must be returned...

References DataSource.getHighIndegreeProperties(), and IndexDataSource.wrapped.

◆ getHighOutdegreeProperties()

Map<Property, Integer> getHighOutdegreeProperties ( String  resourceIRI)

If describeResource(String) omits properties of high outdegree, then those properties must be returned here with the count of arcs.

If high-outdegree properties are not omitted, or the resource doesn't have any, then an empty map or null may be returned. Entries with value 0 will be ignored.

Parameters
resourceIRIThe IRI of the resource to be described
Returns
A map containing high-outdegree properties with number of arcs for the resource

Implements DataSource.

75  {
76  return wrapped.getHighOutdegreeProperties(resourceIRI);
77  }
Map< Property, Integer > getHighOutdegreeProperties(String resourceIRI)
If describeResource(String) omits properties of high outdegree, then those properties must be returne...

References DataSource.getHighOutdegreeProperties(), and IndexDataSource.wrapped.

◆ getIndex()

List<Resource> getIndex ( )

A list of IRI resources described in this data source.

Ordering is implementation-defined. Usually a reasonable limit should be applied to the number of resources returned.

Implements DataSource.

102  {
103  // We could add the indexIRI as an additional resource here, but we
104  // don't want it to show up in the list of resources generated in
105  // describeResource(), and we don't want it turn an otherwise
106  // empty dataset into a non-empty one.
107  return wrapped.getIndex();
108  }

References DataSource.getIndex(), and IndexDataSource.wrapped.

◆ getLabelIndex()

Implements DataSource.

111  {
112  System.out.println("IndexDataSource: GetLabelIndex()");
113  return wrapped.getLabelIndex();
114  }
de.fuberlin.wiwiss.pubby.util.AutocompleteEngine< SearchRecord > getLabelIndex()

References DataSource.getLabelIndex(), and IndexDataSource.wrapped.

◆ listPropertyValues()

Model listPropertyValues ( String  resourceIRI,
Property  property,
boolean  isInverse 
)

Describe the index resource, and extract all the statements that have our property and the right subject/object.

Implements DataSource.

85  {
86  if (!indexIRI.equals(resourceIRI)) {
87  return wrapped.listPropertyValues(resourceIRI, property, isInverse);
88  }
89  Model all = describeResource(resourceIRI);
90  Resource r = all.getResource(resourceIRI);
91  StmtIterator it = isInverse
92  ? all.listStatements(null, property, r)
93  : all.listStatements(r, property, (RDFNode) null);
94  Model result = ModelFactory.createDefaultModel();
95  while (it.hasNext()) {
96  result.add(it.next());
97  }
98  return result;
99  }
Model listPropertyValues(String resourceIRI, Property property, boolean isInverse)
Returns a subgraph of the data source.
Model describeResource(String iri)
Returns a subgraph of the data source describing one resource.
Definition: IndexDataSource.java:36

References IndexDataSource.describeResource(), IndexDataSource.indexIRI, DataSource.listPropertyValues(), and IndexDataSource.wrapped.

Member Data Documentation

◆ indexIRI

◆ MAX_INDEX_SIZE

◆ SIOC_NS

final String SIOC_NS = "http://rdfs.org/sioc/ns#"
staticprivate

◆ siocContainerOf

final Property siocContainerOf
staticprivate
Initial value:
=
ResourceFactory.createProperty(SIOC_NS + "container_of")

Referenced by IndexDataSource.describeResource().

◆ wrapped