GeoPubby  Version 0.1.0.0
Configuration Class Reference

The server's configuration. More...

Inheritance diagram for Configuration:
Collaboration diagram for Configuration:

Public Member Functions

 Configuration (Resource configuration)
 
DataSource getDataSource ()
 A composite DataSource representing the merge of all datasets. More...
 
List< DatasetgetDatasets ()
 The conf:dataset blocks. More...
 
HypermediaControls getControls (String relativeRequestURI, boolean isRelativeToPubbyRoot)
 
PrefixMapping getPrefixes ()
 
Collection< Property > getLabelProperties ()
 
Collection< Property > getGeoProperties ()
 
Collection< Property > getCrsProperties ()
 
Collection< Property > getTypeProperties ()
 
Collection< Property > getCommentProperties ()
 
Collection< Property > getImageProperties ()
 
String getDefaultLanguage ()
 
String getIndexIRI ()
 The "home" resource. More...
 
String getProjectLink ()
 
String getProjectName ()
 
String getWebApplicationBaseURI ()
 
String getWebResourcePrefix ()
 
boolean showLabels ()
 
VocabularyStore getVocabularyStore ()
 
Set< String > getBrowsableNamespaces ()
 Gets all values of conf:browsableNamespace declared on the configuration resource. More...
 
boolean isBrowsable (String iri)
 
Resource getSelf ()
 
Model getModel ()
 
boolean hasType (Resource class_)
 
boolean hasProperty (Property p)
 
Resource getResource (Property p)
 
Set< Resource > getResources (Property p)
 
Set< Property > getProperties (Property p)
 
String getIRI (Property p)
 
String getIRI (Property p, String defaultValue)
 
String getRequiredIRI (Property p)
 
Set< String > getIRIs (Property p)
 
String getString (Property p)
 
String getString (Property p, String defaultValue)
 
Set< String > getStrings (Property p)
 
boolean getBoolean (Property p, boolean defaultValue)
 
void requireExactlyOneOf (Property... properties)
 

Static Public Member Functions

static Configuration create (Model model)
 

Private Member Functions

DataSource buildDataSource ()
 
void assertHasOneValue (Property p)
 
void assertResourceValue (Property p)
 
void assertResourceValue (Statement stmt)
 
void assertIRIValue (Property p)
 
void assertIRIValue (Statement stmt)
 
void assertLiteralValue (Property p)
 
void assertLiteralValue (Statement stmt)
 
void assertString (Statement stmt)
 
String pretty (RDFNode node)
 
String pretty (Statement stmt)
 
void raiseMissingProperty (Property p)
 
void raiseUnexpectedDatatype (String expectedDatatype, Statement stmt)
 

Private Attributes

final PrefixMapping prefixes
 
final String webBase
 
final Collection< Property > labelProperties
 
final Collection< Property > typeProperties
 
final Collection< Property > geoProperties
 
final Collection< Property > crsProperties
 
final Collection< Property > commentProperties
 
final Collection< Property > imageProperties
 
final ArrayList< Datasetdatasets = new ArrayList<Dataset>()
 
final VocabularyStore vocabularyStore = new VocabularyStore()
 
final DataSource dataSource
 
final String indexIRI
 
final Set< String > allBrowsableNamespaces = new HashSet<String>()
 
final Resource resource
 

Detailed Description

The server's configuration.

Constructor & Destructor Documentation

◆ Configuration()

Configuration ( Resource  configuration)
59  {
60  super(configuration);
61  webBase = getRequiredIRI(CONF.webBase);
62 
63  // Create datasets from conf:dataset
64  for (Resource r: getResources(CONF.dataset)) {
65  Dataset ds = new Dataset(r, this);
66  datasets.add(ds);
67  allBrowsableNamespaces.addAll(ds.getBrowsableNamespaces());
68  }
71 
72  // Create datasets from conf:loadVocabularyFromURL
73  for (String sourceURL: getIRIs(CONF.loadVocabulary)) {
74  Model m = ModelFactory.createDefaultModel();
75  Resource dummyDataset = m.createResource();
76  dummyDataset.addProperty(CONF.loadRDF, m.createResource(sourceURL));
77  dummyDataset.addProperty(RDF.type, CONF.AnnotationProvider);
78  datasets.add(new Dataset(dummyDataset, this));
79  }
80 
81  labelProperties = getProperties(CONF.labelProperty);
82  if (labelProperties.isEmpty()) {
83  labelProperties.add(RDFS.label);
84  labelProperties.add(DC.title);
85  labelProperties.add(DCTerms.title);
86  labelProperties.add(FOAF.name);
87  }
88 
89  typeProperties = getProperties(CONF.typeProperty);
90  if (typeProperties.isEmpty()) {
91  typeProperties.add(RDF.type);
92  }
93 
94  geoProperties = getProperties(CONF.geoProperty);
95  if (geoProperties.isEmpty()) {
96  geoProperties.add(GEO.HASGEOMETRY);
97  }
98 
99  crsProperties = getProperties(CONF.crsProperty);
100  if (crsProperties.isEmpty()) {
101  crsProperties.add(GEO.EPSG);
102  }
103 
104  commentProperties = getProperties(CONF.commentProperty);
105  if (commentProperties.isEmpty()) {
106  commentProperties.add(RDFS.comment);
107  commentProperties.add(DC.description);
108  commentProperties.add(DCTerms.description);
109  }
110  imageProperties = getProperties(CONF.imageProperty);
111  if (imageProperties.isEmpty()) {
112  imageProperties.add(FOAF.depiction);
113  imageProperties.add(CONF.wdImage);
114  }
115 
116  prefixes = new PrefixMappingImpl();
117  if (hasProperty(CONF.usePrefixesFrom)) {
118  for (String iri: getIRIs(CONF.usePrefixesFrom)) {
119  prefixes.setNsPrefixes(FileManager.get().loadModel(iri));
120  }
121  } else {
122  prefixes.setNsPrefixes(getModel());
123  }
124  if (prefixes.getNsURIPrefix(CONF.NS) != null) {
125  prefixes.removeNsPrefix(prefixes.getNsURIPrefix(CONF.NS));
126  }
127  // If no prefix is defined for the RDF and XSD namespaces, set them,
128  // unless that would overwrite something. This is the namespaces that
129  // have syntactic sugar in Turtle.
130  ModelUtil.addNSIfUndefined(prefixes, "rdf", RDF.getURI());
131  ModelUtil.addNSIfUndefined(prefixes, "xsd", XSD.getURI());
132  ModelUtil.addNSIfUndefined(prefixes, "rdfs", RDFS.getURI());
133  ModelUtil.addNSIfUndefined(prefixes, "owl", "http://www.w3.org/2002/07/owl#");
134  ModelUtil.addNSIfUndefined(prefixes, "pubby", webBase);
135  System.out.println("Building datasource");
137 
138  // Vocabulary data source contains our normal data sources plus
139  // the configuration model, so that we can read labels etc from
140  // the configuration file
141  DataSource vocabularyDataSource = new MergeDataSource(
142  new ModelDataSource(getModel()), getDataSource());
143  vocabularyStore.setDataSource(vocabularyDataSource);
145  // Sanity check to spot typical configuration problem
146  if (dataSource.getIndex().isEmpty()) {
147  throw new ConfigurationException("The index is empty. " +
148  "Try adding conf:datasetBase to your datasets, " +
149  "check any conf:datasetURIPatterns, " +
150  "and check that all data sources actually contain data.");
151  }
152  System.out.println("Datasource index: "+dataSource.getLabelIndex());
153  String resourceBase = getWebApplicationBaseURI() + getWebResourcePrefix();
154  if (hasProperty(CONF.indexResource)) {
155  indexIRI = getIRI(CONF.indexResource);
156  // Sanity check to spot typical configuration problem
157  if (dataSource.describeResource(indexIRI).isEmpty()) {
158  throw new ConfigurationException(
159  "conf:indexResource <" + indexIRI +
160  "> not found in data sets. " +
161  "Try disabling the conf:indexResource to get " +
162  "a list of found resources.");
163  }
164  } else {
165  indexIRI = resourceBase;
166  }
167  }
final Set< String > allBrowsableNamespaces
Definition: Configuration.java:57
final DataSource dataSource
Definition: Configuration.java:55
final Collection< Property > typeProperties
Definition: Configuration.java:48
final Collection< Property > labelProperties
Definition: Configuration.java:47
final ArrayList< Dataset > datasets
Definition: Configuration.java:53
final String indexIRI
Definition: Configuration.java:56
final String webBase
Definition: Configuration.java:46
final Collection< Property > geoProperties
Definition: Configuration.java:49
final PrefixMapping prefixes
Definition: Configuration.java:45
String getWebResourcePrefix()
Definition: Configuration.java:273
final Collection< Property > commentProperties
Definition: Configuration.java:51
final Collection< Property > crsProperties
Definition: Configuration.java:50
final Collection< Property > imageProperties
Definition: Configuration.java:52
Set< String > getBrowsableNamespaces()
Gets all values of conf:browsableNamespace declared on the configuration resource.
Definition: Configuration.java:292
DataSource getDataSource()
A composite DataSource representing the merge of all datasets.
Definition: Configuration.java:192
final VocabularyStore vocabularyStore
Definition: Configuration.java:54
DataSource buildDataSource()
Definition: Configuration.java:169
String getWebApplicationBaseURI()
Definition: Configuration.java:269
String getDefaultLanguage()
Definition: Configuration.java:249
String getIRI(Property p)
Definition: ResourceReader.java:71
Set< String > getIRIs(Property p)
Definition: ResourceReader.java:89
String getRequiredIRI(Property p)
Definition: ResourceReader.java:82
Set< Property > getProperties(Property p)
Definition: ResourceReader.java:63
Set< Resource > getResources(Property p)
Definition: ResourceReader.java:52
boolean hasProperty(Property p)
Definition: ResourceReader.java:41
Model getModel()
Definition: ResourceReader.java:33
Model describeResource(String absoluteIRI)
Returns a subgraph of the data source describing one resource.
de.fuberlin.wiwiss.pubby.util.AutocompleteEngine< SearchRecord > getLabelIndex()
List< Resource > getIndex()
A list of IRI resources described in this data source.
void setDataSource(DataSource dataSource)
Needs to be set before the instance is used! This is to allow creation of the store before the datase...
Definition: VocabularyStore.java:39
void setDefaultLanguage(String defaultLanguage)
Definition: VocabularyStore.java:43

References ModelUtil.addNSIfUndefined(), Configuration.allBrowsableNamespaces, CONF.AnnotationProvider, Configuration.buildDataSource(), Configuration.commentProperties, CONF.commentProperty, Configuration.crsProperties, CONF.crsProperty, CONF.dataset, Configuration.datasets, Configuration.dataSource, DataSource.describeResource(), GEO.EPSG, Configuration.geoProperties, CONF.geoProperty, Configuration.getBrowsableNamespaces(), Dataset.getBrowsableNamespaces(), Configuration.getDataSource(), Configuration.getDefaultLanguage(), DataSource.getIndex(), ResourceReader.getIRI(), ResourceReader.getIRIs(), DataSource.getLabelIndex(), ResourceReader.getModel(), ResourceReader.getProperties(), ResourceReader.getRequiredIRI(), ResourceReader.getResources(), Configuration.getWebApplicationBaseURI(), Configuration.getWebResourcePrefix(), GEO.HASGEOMETRY, ResourceReader.hasProperty(), Configuration.imageProperties, CONF.imageProperty, Configuration.indexIRI, CONF.indexResource, Configuration.labelProperties, CONF.labelProperty, CONF.loadRDF, CONF.loadVocabulary, CONF.NS, Configuration.prefixes, VocabularyStore.setDataSource(), VocabularyStore.setDefaultLanguage(), Configuration.typeProperties, CONF.typeProperty, CONF.usePrefixesFrom, Configuration.vocabularyStore, CONF.wdImage, Configuration.webBase, and CONF.webBase.

Referenced by Configuration.create().

Member Function Documentation

◆ assertHasOneValue()

void assertHasOneValue ( Property  p)
privateinherited
170  {
171  StmtIterator it = resource.listProperties(p);
172  if (!it.hasNext()) {
173  throw new ConfigurationException("Missing property " + pretty(p) +
174  " on resource " + pretty(resource));
175  }
176  it.next();
177  if (it.hasNext()) {
178  throw new ConfigurationException("Too many values for property " +
179  pretty(p) + " on resource " + pretty(resource));
180  }
181  }
String pretty(RDFNode node)
Definition: ResourceReader.java:235
final Resource resource
Definition: ResourceReader.java:23

References ResourceReader.pretty(), and ResourceReader.resource.

Referenced by ResourceReader.getBoolean(), ResourceReader.getIRI(), ResourceReader.getResource(), and ResourceReader.getString().

◆ assertIRIValue() [1/2]

void assertIRIValue ( Property  p)
privateinherited
194  {
195  assertIRIValue(resource.getProperty(p));
196  }
void assertIRIValue(Property p)
Definition: ResourceReader.java:194

References ResourceReader.resource.

Referenced by ResourceReader.getIRI(), and ResourceReader.getIRIs().

◆ assertIRIValue() [2/2]

void assertIRIValue ( Statement  stmt)
privateinherited
198  {
199  if (stmt.getObject().isLiteral()) {
200  throw new ConfigurationException(
201  "Expected IRI object, found literal: " + pretty(stmt));
202  }
203  if (stmt.getObject().isAnon()) {
204  throw new ConfigurationException(
205  "Expected IRI object, found blank node: " + pretty(stmt));
206  }
207  }

References ResourceReader.pretty().

◆ assertLiteralValue() [1/2]

void assertLiteralValue ( Property  p)
privateinherited
209  {
210  assertLiteralValue(resource.getProperty(p));
211  }
void assertLiteralValue(Property p)
Definition: ResourceReader.java:209

References ResourceReader.resource.

Referenced by ResourceReader.assertString(), and ResourceReader.getBoolean().

◆ assertLiteralValue() [2/2]

void assertLiteralValue ( Statement  stmt)
privateinherited
213  {
214  if (stmt.getObject().isURIResource()) {
215  throw new ConfigurationException(
216  "Expected literal object, found IRI: " + pretty(stmt));
217  }
218  if (stmt.getObject().isAnon()) {
219  throw new ConfigurationException(
220  "Expected literal object, found blank node: " + pretty(stmt));
221  }
222  }

References ResourceReader.pretty().

◆ assertResourceValue() [1/2]

void assertResourceValue ( Property  p)
privateinherited
183  {
184  assertResourceValue(resource.getProperty(p));
185  }
void assertResourceValue(Property p)
Definition: ResourceReader.java:183

References ResourceReader.resource.

Referenced by ResourceReader.getResource(), and ResourceReader.getResources().

◆ assertResourceValue() [2/2]

void assertResourceValue ( Statement  stmt)
privateinherited
187  {
188  if (stmt.getObject().isLiteral()) {
189  throw new ConfigurationException(
190  "Expected resource object, found literal: " + pretty(stmt));
191  }
192  }

References ResourceReader.pretty().

◆ assertString()

void assertString ( Statement  stmt)
privateinherited
224  {
225  assertLiteralValue(stmt);
226  Literal value = stmt.getLiteral();
227  if (value.getDatatypeURI() == null ||
228  XSD.xstring.getURI().equals(value.getDatatypeURI()) ||
229  (RDF.getURI() + "langString").equals(value.getDatatypeURI())) {
230  return;
231  }
232  raiseUnexpectedDatatype("string", stmt);
233  }
void raiseUnexpectedDatatype(String expectedDatatype, Statement stmt)
Definition: ResourceReader.java:257

References ResourceReader.assertLiteralValue(), and ResourceReader.raiseUnexpectedDatatype().

Referenced by ResourceReader.getString(), and ResourceReader.getStrings().

◆ buildDataSource()

DataSource buildDataSource ( )
private
169  {
170  List<DataSource> sources = new ArrayList<DataSource>(datasets.size());
171  for (Dataset dataset: datasets) {
172  sources.add(dataset.getDataSource());
173  }
174  DataSource result = new MergeDataSource(sources, prefixes);
175  // If we don't have an indexResource, and there is no resource
176  // at the home URL in any of the datasets, then add an
177  // index builder. It will be responsible for handling the
178  // homepage/index resource.
179  // TODO: Shouldn't we make the index data source available even if there
180  // is an indexResource?
182  if (!hasProperty(CONF.indexResource) &&
183  result.describeResource(indexIRI).isEmpty()) {
184  result = new IndexDataSource(indexIRI, result);
185  }
186  return result;
187  }

References Configuration.datasets, DataSource.describeResource(), Configuration.getWebResourcePrefix(), ResourceReader.hasProperty(), Configuration.indexIRI, CONF.indexResource, Configuration.prefixes, and Configuration.webBase.

Referenced by Configuration.Configuration().

◆ create()

static Configuration create ( Model  model)
static
36  {
37  StmtIterator it = model.listStatements(null, RDF.type, CONF.Configuration);
38  if (!it.hasNext()) {
39  throw new IllegalArgumentException(
40  "No resource with type conf:Configuration found in configuration file");
41  }
42  return new Configuration(it.nextStatement().getSubject());
43  }
Configuration(Resource configuration)
Definition: Configuration.java:59

References Configuration.Configuration(), and CONF.Configuration.

Referenced by ServletContextInitializer.initConfiguration(), and Reloader.run().

◆ getBoolean()

boolean getBoolean ( Property  p,
boolean  defaultValue 
)
inherited
124  {
125  if (!resource.hasProperty(p)) {
126  return defaultValue;
127  }
130  Literal value = resource.getProperty(p).getLiteral();
131  if (XSD.xboolean.getURI().equals(value.getDatatypeURI())) {
132  return value.getBoolean();
133  }
134  if (value.getDatatypeURI() == null || XSD.xstring.getURI().equals(value.getDatatypeURI())) {
135  if ("true".equals(value.getString().toLowerCase())
136  || "false".equals(value.getString().toLowerCase())) {
137  return "true".equals(value.getString().toLowerCase());
138  }
139  }
140  raiseUnexpectedDatatype("xsd:boolean", resource.getProperty(p));
141  return false;
142  }
void assertHasOneValue(Property p)
Definition: ResourceReader.java:170

References ResourceReader.assertHasOneValue(), ResourceReader.assertLiteralValue(), ResourceReader.raiseUnexpectedDatatype(), and ResourceReader.resource.

Referenced by Dataset.addSameAsStatements(), Configuration.showLabels(), Dataset.supportsIRIs(), and Dataset.supportsSPARQL11().

◆ getBrowsableNamespaces()

Set<String> getBrowsableNamespaces ( )

Gets all values of conf:browsableNamespace declared on the configuration resource.

Does not include values declared on specific datasets.

Returns
Namespace IRIs of browsable namespaces
292  {
293  return getIRIs(CONF.browsableNamespace);
294  }

References CONF.browsableNamespace, and ResourceReader.getIRIs().

Referenced by Dataset.buildDataSource(), and Configuration.Configuration().

◆ getCommentProperties()

Collection<Property> getCommentProperties ( )
241  {
242  return commentProperties;
243  }

References Configuration.commentProperties.

Referenced by ResourceDescription.getComment().

◆ getControls()

HypermediaControls getControls ( String  relativeRequestURI,
boolean  isRelativeToPubbyRoot 
)
Parameters
relativeRequestURIURI relative to the Pubby root (conf:webBase)
isRelativeToPubbyRootIf true, the IRI is relative to the Pubby root (conf:webBase); otherwise, the IRI is relative to some non-resource namespace such as /page/. The distinction matters if conf:webResourcePrefix is set.
211  {
212  String relativeIRI = IRIEncoder.toIRI(relativeRequestURI);
213  if (isRelativeToPubbyRoot) {
214  if (!relativeIRI.startsWith(getWebResourcePrefix())) return null;
215  } else {
216  relativeIRI = relativeIRI.substring(getWebResourcePrefix().length());
217  }
218  return HypermediaControls.createFromPubbyPath(relativeIRI, this);
219  }

References HypermediaControls.createFromPubbyPath(), Configuration.getWebResourcePrefix(), and IRIEncoder.toIRI().

Referenced by DataURLServlet.doGet(), ValuesBaseServlet.doGet(), WebURIServlet.doGet(), PageURLServlet.doGet(), and MappedResource.MappedResource().

◆ getCrsProperties()

Collection<Property> getCrsProperties ( )
233  {
234  return crsProperties;
235  }

References Configuration.crsProperties.

Referenced by GeoBrowserServlet.doGet().

◆ getDatasets()

List<Dataset> getDatasets ( )

◆ getDataSource()

DataSource getDataSource ( )

A composite DataSource representing the merge of all datasets.

192  {
193  return dataSource;
194  }

References Configuration.dataSource.

Referenced by Configuration.Configuration(), ValuesDataURLServlet.doGet(), ValuesURLServlet.doGet(), SearchServlet.doGet(), and HypermediaControls.getResourceDescription().

◆ getDefaultLanguage()

String getDefaultLanguage ( )
249  {
250  return getString(CONF.defaultLanguage, "en");
251  }
String getString(Property p)
Definition: ResourceReader.java:100

References CONF.defaultLanguage, and ResourceReader.getString().

Referenced by Configuration.Configuration(), ResourceDescription.getComment(), ResourceDescription.getLabel(), and ResourceDescription.toTitleCase().

◆ getGeoProperties()

Collection<Property> getGeoProperties ( )
229  {
230  return geoProperties;
231  }

References Configuration.geoProperties.

Referenced by GeoBrowserServlet.doGet().

◆ getImageProperties()

Collection<Property> getImageProperties ( )
245  {
246  return imageProperties;
247  }

References Configuration.imageProperties.

Referenced by ResourceDescription.getImageURL().

◆ getIndexIRI()

String getIndexIRI ( )

The "home" resource.

If its IRI is not the web server base, then the web server will redirect there.

257  {
258  return indexIRI;
259  }

References Configuration.indexIRI.

Referenced by RootServlet.doGet().

◆ getIRI() [1/2]

◆ getIRI() [2/2]

String getIRI ( Property  p,
String  defaultValue 
)
inherited
75  {
76  if (!resource.hasProperty(p)) return defaultValue;
78  assertIRIValue(p);
79  return resource.getProperty(p).getResource().getURI();
80  }

References ResourceReader.assertHasOneValue(), ResourceReader.assertIRIValue(), and ResourceReader.resource.

◆ getIRIs()

Set<String> getIRIs ( Property  p)
inherited
89  {
90  Set<String> result = new HashSet<String>();
91  StmtIterator it = resource.listProperties(p);
92  while (it.hasNext()) {
93  Statement stmt = it.next();
94  assertIRIValue(stmt);
95  result.add(stmt.getResource().getURI());
96  }
97  return result;
98  }

References ResourceReader.assertIRIValue(), and ResourceReader.resource.

Referenced by Dataset.buildDataSource(), Configuration.Configuration(), Configuration.getBrowsableNamespaces(), and Dataset.getBrowsableNamespaces().

◆ getLabelProperties()

Collection<Property> getLabelProperties ( )
225  {
226  return labelProperties;
227  }

References Configuration.labelProperties.

Referenced by GeoBrowserServlet.doGet(), and ResourceDescription.getLabel().

◆ getModel()

◆ getPrefixes()

PrefixMapping getPrefixes ( )

◆ getProjectLink()

String getProjectLink ( )
261  {
262  return getIRI(CONF.projectHomepage);
263  }

References ResourceReader.getIRI(), and CONF.projectHomepage.

Referenced by ValuesURLServlet.doGet(), GeoBrowserServlet.doGet(), PageURLServlet.doGet(), and BaseServlet.send404().

◆ getProjectName()

String getProjectName ( )

◆ getProperties()

Set<Property> getProperties ( Property  p)
inherited
63  {
64  Set<Property> result = new HashSet<Property>();
65  for (Resource r: getResources(p)) {
66  result.add(r.as(Property.class));
67  }
68  return result;
69  }

References ResourceReader.getResources().

Referenced by Configuration.Configuration().

◆ getRequiredIRI()

String getRequiredIRI ( Property  p)
inherited
82  {
83  if (!resource.hasProperty(p)) {
85  }
86  return getIRI(p);
87  }
void raiseMissingProperty(Property p)
Definition: ResourceReader.java:252

References ResourceReader.getIRI(), ResourceReader.raiseMissingProperty(), and ResourceReader.resource.

Referenced by Configuration.Configuration().

◆ getResource()

Resource getResource ( Property  p)
inherited
45  {
46  if (!resource.hasProperty(p)) return null;
49  return resource.getProperty(p).getResource();
50  }

References ResourceReader.assertHasOneValue(), ResourceReader.assertResourceValue(), and ResourceReader.resource.

Referenced by MetadataConfiguration.MetadataConfiguration().

◆ getResources()

Set<Resource> getResources ( Property  p)
inherited
52  {
53  Set<Resource> result = new HashSet<Resource>();
54  StmtIterator it = resource.listProperties(p);
55  while (it.hasNext()) {
56  Statement stmt = it.next();
57  assertResourceValue(stmt);
58  result.add(stmt.getResource());
59  }
60  return result;
61  }

References ResourceReader.assertResourceValue(), and ResourceReader.resource.

Referenced by Configuration.Configuration(), and ResourceReader.getProperties().

◆ getSelf()

Resource getSelf ( )
inherited
29  {
30  return resource;
31  }

References ResourceReader.resource.

Referenced by MetadataConfiguration.parsePlaceholder().

◆ getString() [1/2]

String getString ( Property  p)
inherited

◆ getString() [2/2]

String getString ( Property  p,
String  defaultValue 
)
inherited
104  {
105  if (!resource.hasProperty(p)) {
106  return defaultValue;
107  }
109  assertString(resource.getProperty(p));
110  return resource.getProperty(p).getString();
111  }
void assertString(Statement stmt)
Definition: ResourceReader.java:224

References ResourceReader.assertHasOneValue(), ResourceReader.assertString(), and ResourceReader.resource.

◆ getStrings()

Set<String> getStrings ( Property  p)
inherited
113  {
114  Set<String> result = new HashSet<String>();
115  StmtIterator it = resource.listProperties(p);
116  while (it.hasNext()) {
117  Statement stmt = it.next();
118  assertString(stmt);
119  result.add(stmt.getString());
120  }
121  return result;
122  }

References ResourceReader.assertString(), and ResourceReader.resource.

Referenced by Dataset.buildDataSource().

◆ getTypeProperties()

Collection<Property> getTypeProperties ( )
237  {
238  return typeProperties;
239  }

References Configuration.typeProperties.

Referenced by GeoBrowserServlet.doGet().

◆ getVocabularyStore()

◆ getWebApplicationBaseURI()

◆ getWebResourcePrefix()

◆ hasProperty()

boolean hasProperty ( Property  p)
inherited
41  {
42  return resource.hasProperty(p);
43  }

References ResourceReader.resource.

Referenced by Configuration.buildDataSource(), Dataset.buildDataSource(), and Configuration.Configuration().

◆ hasType()

boolean hasType ( Resource  class_)
inherited
37  {
38  return resource.hasProperty(RDF.type, class_);
39  }

References ResourceReader.resource.

Referenced by Dataset.buildDataSource().

◆ isBrowsable()

boolean isBrowsable ( String  iri)
296  {
297  for (String namespace: allBrowsableNamespaces) {
298  if (iri.startsWith(namespace)) return true;
299  }
300  return false;
301  }

References Configuration.allBrowsableNamespaces.

Referenced by HypermediaControls.createFromIRI().

◆ pretty() [1/2]

String pretty ( RDFNode  node)
privateinherited
235  {
236  if (node.isAnon()) return "[]";
237  if (node.isURIResource()) {
238  Resource r = node.asResource();
239  if (getModel().qnameFor(r.getURI()) == null) {
240  return "<" + r.getURI() + ">";
241  }
242  return getModel().qnameFor(r.getURI());
243  }
244  return PrintUtil.print(node);
245  }

References ResourceReader.getModel().

Referenced by ResourceReader.assertHasOneValue(), ResourceReader.assertIRIValue(), ResourceReader.assertLiteralValue(), ResourceReader.assertResourceValue(), ResourceReader.pretty(), ResourceReader.raiseMissingProperty(), ResourceReader.raiseUnexpectedDatatype(), and ResourceReader.requireExactlyOneOf().

◆ pretty() [2/2]

String pretty ( Statement  stmt)
privateinherited
247  {
248  return pretty(stmt.getSubject()) + " " + pretty(stmt.getPredicate())
249  + " " + pretty(stmt.getObject()) + ".";
250  }

References ResourceReader.pretty().

◆ raiseMissingProperty()

void raiseMissingProperty ( Property  p)
privateinherited
252  {
253  throw new ConfigurationException("Missing property " +
254  pretty(p) + " on resource " + pretty(resource));
255  }

References ResourceReader.pretty(), and ResourceReader.resource.

Referenced by ResourceReader.getRequiredIRI().

◆ raiseUnexpectedDatatype()

void raiseUnexpectedDatatype ( String  expectedDatatype,
Statement  stmt 
)
privateinherited
257  {
258  throw new ConfigurationException(
259  "Expected " + expectedDatatype +
260  " object, found other datatype: " +
261  pretty(stmt));
262  }

References ResourceReader.pretty().

Referenced by ResourceReader.assertString(), and ResourceReader.getBoolean().

◆ requireExactlyOneOf()

void requireExactlyOneOf ( Property...  properties)
inherited
144  {
145  Property found = null;
146  boolean first = true;
147  StringBuilder s = new StringBuilder();
148  for (Property p: properties) {
149  if (resource.hasProperty(p)) {
150  if (found == null) {
151  found = p;
152  } else {
153  throw new ConfigurationException("Can't have both " +
154  pretty(found) + " and " + pretty(p) +
155  " on resource " + pretty(resource));
156  }
157  }
158  if (!first) {
159  s.append(", ");
160  }
161  s.append(pretty(p));
162  first = false;
163  }
164  if (found == null) {
165  throw new ConfigurationException("One of " + s.toString() +
166  " required on resource " + pretty(resource));
167  }
168  }

References ResourceReader.pretty(), and ResourceReader.resource.

Referenced by Dataset.buildDataSource().

◆ showLabels()

boolean showLabels ( )
277  {
278  return getBoolean(CONF.showLabels, true);
279  }
boolean getBoolean(Property p, boolean defaultValue)
Definition: ResourceReader.java:124

References ResourceReader.getBoolean(), and CONF.showLabels.

Referenced by ValuesURLServlet.doGet(), and PageURLServlet.doGet().

Member Data Documentation

◆ allBrowsableNamespaces

final Set<String> allBrowsableNamespaces = new HashSet<String>()
private

◆ commentProperties

final Collection<Property> commentProperties
private

◆ crsProperties

final Collection<Property> crsProperties
private

◆ datasets

final ArrayList<Dataset> datasets = new ArrayList<Dataset>()
private

◆ dataSource

final DataSource dataSource
private

◆ geoProperties

final Collection<Property> geoProperties
private

◆ imageProperties

final Collection<Property> imageProperties
private

◆ indexIRI

◆ labelProperties

final Collection<Property> labelProperties
private

◆ prefixes

final PrefixMapping prefixes
private

◆ resource

◆ typeProperties

final Collection<Property> typeProperties
private

◆ vocabularyStore

final VocabularyStore vocabularyStore = new VocabularyStore()
private

◆ webBase