semanticwfs  Version 0.1.0.0
DCATFormatter Class Reference

Formats metadata according to the GeoDCAT format. More...

Inheritance diagram for DCATFormatter:
Collaboration diagram for DCATFormatter:

Public Member Functions

String formatter (String collectionid, String collectioncall, String collectionurl, JSONObject workingobj, String format) throws XMLStreamException
 
String formatHeader ()
 
String formatFooter ()
 

Static Public Member Functions

static ResultMetadataFormatter getFormatter (String formatString)
 

Public Attributes

Integer lastQueriedElemCount =0
 
String mimeType ="text/plain"
 
String exposedType ="application/vnd.geo+json"
 
XMLStreamWriter xmlwriter
 

Static Public Attributes

static Map< String, ResultMetadataFormatterresultMap =new TreeMap<String, ResultMetadataFormatter>()
 

Static Package Functions

 [static initializer]
 

Package Attributes

GMDFormatter formatter =new GMDFormatter()
 GMDFormatter to produce the initial GMD XML. More...
 

Detailed Description

Formats metadata according to the GeoDCAT format.

This class takes metadata formatted in the GMD standard and uses an XSLT stylesheet to convert the results to GeoDCAT.

Member Function Documentation

◆ [static initializer]()

[static initializer]
staticpackageinherited

◆ formatFooter()

String formatFooter ( )
inherited
56  {
57  return "";
58  }

◆ formatHeader()

String formatHeader ( )
inherited
52  {
53  return "";
54  }

◆ formatter()

String formatter ( String  collectionid,
String  collectioncall,
String  collectionurl,
JSONObject  workingobj,
String  format 
) throws XMLStreamException

Reimplemented from ResultMetadataFormatter.

31  {
32  String gmd=formatter.formatter(collectionid, collectioncall, collectionurl, workingobj,format);
33  String gmdrdf;
34  try {
35  gmdrdf = XSLTTransformer.gmdToGeoDCAT(gmd);
36  if(format.contains("html")) {
37  this.mimeType=MediaType.TEXT_HTML;
38  return XSLTTransformer.GeoDCATToHTML(gmdrdf);
39  }
40  OntModel model = ModelFactory.createOntologyModel();
41  model.read(IOUtils.toInputStream(gmdrdf, "UTF-8"), null, "RDF/XML");
42  OutputStream output = new OutputStream() {
43  private StringBuilder string = new StringBuilder();
44 
45  @Override
46  public void write(int b) throws IOException {
47  this.string.append((char) b );
48  }
49 
50  //Netbeans IDE automatically overrides this toString()
51  public String toString() {
52  return this.string.toString();
53  }
54  };
55  if(format.contains("n3")) {
56  this.mimeType="text/n3";
57  model.write(output,"N3");
58  return output.toString();
59  }
60  if(format.contains("jsonld")) {
61  this.mimeType="application/ld+json";
62  model.write(output,"JSON-LD");
63  return output.toString();
64  }
65  if(format.contains("ttl")) {
66  this.mimeType="text/ttl";
67  model.write(output,"TTL");
68  return output.toString();
69  }
70  if(format.contains("ntriples")) {
71  this.mimeType="application/n-triples";
72  model.write(output,"NTRIPLES");
73  return output.toString();
74  }
75  this.mimeType=MediaType.APPLICATION_XML;
76  return gmdrdf;
77  } catch (TransformerException e) {
78  // TODO Auto-generated catch block
79  e.printStackTrace();
80  return "";
81  }
82  }
GMDFormatter formatter
GMDFormatter to produce the initial GMD XML.
Definition: DCATFormatter.java:27
String formatter(String collectionid, String collectioncall, String collectionurl, JSONObject workingobj, String format)
Definition: GMDFormatter.java:28
String mimeType
Definition: ResultMetadataFormatter.java:17

References DCATFormatter.formatter, GMDFormatter.formatter(), XSLTTransformer.GeoDCATToHTML(), XSLTTransformer.gmdToGeoDCAT(), and ResultMetadataFormatter.mimeType.

◆ getFormatter()

static ResultMetadataFormatter getFormatter ( String  formatString)
staticinherited
23  {
24  formatString=formatString.toLowerCase();
25  if(resultMap.containsKey(formatString)) {
26  return resultMap.get(formatString);
27  }
28  formatString=formatString.replace("+","");
29  if(formatString.contains("dcat")) {
30  return resultMap.get("geodcat");
31  }
32  return resultMap.get("gmd");
33  }
static Map< String, ResultMetadataFormatter > resultMap
Definition: ResultMetadataFormatter.java:13

Referenced by WebService.getCollectionMetadata().

Member Data Documentation

◆ exposedType

String exposedType ="application/vnd.geo+json"
inherited

◆ formatter

GMDFormatter formatter =new GMDFormatter()
package

GMDFormatter to produce the initial GMD XML.

Referenced by DCATFormatter.formatter().

◆ lastQueriedElemCount

Integer lastQueriedElemCount =0
inherited

◆ mimeType

String mimeType ="text/plain"
inherited

◆ resultMap

Map<String,ResultMetadataFormatter> resultMap =new TreeMap<String, ResultMetadataFormatter>()
staticinherited

◆ xmlwriter

XMLStreamWriter xmlwriter
inherited

Referenced by GMDFormatter.formatter().