GeoPubby  Version 0.1.0.0
ModelDataSource Class Reference

A data source backed by a Jena model. More...

Inheritance diagram for ModelDataSource:
Collaboration diagram for ModelDataSource:

Public Member Functions

 ModelDataSource (Model model)
 
boolean canDescribe (String absoluteIRI)
 Indicates whether this data source may have some information about a given IRI. More...
 
Model describeResource (String resourceURI)
 Returns a subgraph of the data source describing one resource. More...
 
Map< Property, Integer > getHighIndegreeProperties (String resourceURI)
 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 resourceURI)
 If describeResource(String) omits properties of high outdegree, then those properties must be returned here with the count of arcs. More...
 
Model listPropertyValues (String resourceURI, Property property, boolean isInverse)
 Returns a subgraph of the data source. More...
 
List< Resource > getIndex ()
 A list of IRI resources described in this data source. More...
 
de.fuberlin.wiwiss.pubby.util.AutocompleteEngine< SearchRecordgetLabelIndex ()
 
Model describeResource (String absoluteIRI, String language)
 Returns a subgraph of the data source describing one resource. More...
 

Static Public Attributes

static final int MAX_INDEX_SIZE = 1000000
 

Private Attributes

Model model
 
AutocompleteEngine< SearchRecordengine
 

Detailed Description

A data source backed by a Jena model.

Constructor & Destructor Documentation

◆ ModelDataSource()

ModelDataSource ( Model  model)
36  {
37  this.model = model;
38  }
Model model
Definition: ModelDataSource.java:32

References ModelDataSource.model.

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.

41  {
42  return true;
43  }

◆ describeResource() [1/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.

114  {
115  // TODO Auto-generated method stub
116  return null;
117  }

◆ describeResource() [2/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.

46  {
47  Resource r = ResourceFactory.createResource(resourceURI);
48  if (model.contains(r, null, (RDFNode) null) || model.contains(null, null, r)) {
49  return model;
50  }
51  return ModelUtil.EMPTY_MODEL;
52  }

References ModelUtil.EMPTY_MODEL, and ModelDataSource.model.

◆ 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.

55  {
56  return null;
57  }

◆ 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.

60  {
61  return null;
62  }

◆ 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.

71  {
72  List<Resource> result = new ArrayList<Resource>();
73  ResIterator subjects = model.listSubjects();
74  while (subjects.hasNext() && result.size() < DataSource.MAX_INDEX_SIZE) {
75  Resource r = subjects.next();
76  if (r.isAnon()) continue;
77  result.add(r);
78  }
79  NodeIterator objects = model.listObjects();
80  while (objects.hasNext() && result.size() < DataSource.MAX_INDEX_SIZE) {
81  RDFNode o = objects.next();
82  if (!o.isURIResource()) continue;
83  result.add(o.asResource());
84  }
85  return result;
86  }

References DataSource.MAX_INDEX_SIZE, and ModelDataSource.model.

◆ getLabelIndex()

Implements DataSource.

89  {
90  System.out.println("ModelDataSource: Get Label Index!!!!");
91  if(engine==null) {
92  engine=SearchIndexInstance.getInstance();
93  System.out.println("Building Label Index....");
94  List<Resource> result = new ArrayList<Resource>();
95  ResIterator subjects = model.listSubjects();
96  int i=0;
97  while (subjects.hasNext() && result.size() < DataSource.MAX_INDEX_SIZE) {
98  Resource r = subjects.next();
99  if (r.isAnon()) continue;
100  StmtIterator st = r.listProperties(RDFS.label);
101  while(st.hasNext()) {
102  Literal lit=st.next().getObject().asLiteral();
103  String label=lit.getString();
104  engine.add(new SearchRecord(label,r));
105  }
106  i++;
107  }
108  System.out.println("Added "+i+" Labels to Index");
109  }
110  return engine;
111  }
AutocompleteEngine< SearchRecord > engine
Definition: ModelDataSource.java:34

References ModelDataSource.engine, SearchIndexInstance.getInstance(), DataSource.MAX_INDEX_SIZE, and ModelDataSource.model.

◆ listPropertyValues()

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

Returns a subgraph of the data source.

It lists the values of a particular property of a particular resource. Where values are blank nodes, a complete description of these anonymous resources must be included.

Parameters
resourceIRIThe resource to be examined
propertyThe property we're interested in
isInverseAre we interested in outgoing arcs (false) or incoming (true)?
Returns
A subgraph of the data source.

Implements DataSource.

66  {
67  return model;
68  }

References ModelDataSource.model.

Member Data Documentation

◆ engine

◆ MAX_INDEX_SIZE

◆ model