org.d2rq.mapgen
Class D2RQMappingStyle

java.lang.Object
  extended by org.d2rq.mapgen.D2RQMappingStyle
All Implemented Interfaces:
MappingStyle

public class D2RQMappingStyle
extends Object
implements MappingStyle

Generates an original-style mapping. Unlike the W3C Direct Mapping, this handles N:M link tables, includes label definitions and instance labels, and uses different URI patterns.


Constructor Summary
D2RQMappingStyle(SQLConnection connection, String baseIRI)
           
 
Method Summary
 String getBaseIRI()
           
 Property getColumnProperty(TableName tableName, Identifier column)
          Creates a property for a table column.
 TemplateValueMaker getEntityIRITemplate(TableDef table, Key columns)
          Returns an IRI template to be used to uniquely identify the records in a table.
 TemplateValueMaker getEntityLabelTemplate(TableName tableName, Key columns)
          Creates a best-effort template for human-readable labels for the records in a table, based on a given list of columns.
 List<Identifier> getEntityPseudoKeyColumns(List<ColumnDef> columns)
          Returns a list of columns to be used to form blank node identifiers for the records in a table that has no suitable unique/primary key
 Property getForeignKeyProperty(TableName tableName, ForeignKey fk)
          Creates a property for a foreign key relationship between two tables.
 Resource getGeneratedOntologyResource()
          Creates a resource that represents the ontology that defines all generated classes and properties.
 Property getLinkProperty(TableName linkTable)
          Creates a property for an N:M link table.
 MappingGenerator getMappingGenerator()
           
 PrefixMapping getPrefixes()
          Returns a prefix mapping with convenient prefix declarations for this style of mapping.
 Resource getTableClass(TableName tableName)
          Creates a class for a table.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

D2RQMappingStyle

public D2RQMappingStyle(SQLConnection connection,
                        String baseIRI)
Method Detail

getMappingGenerator

public MappingGenerator getMappingGenerator()
Specified by:
getMappingGenerator in interface MappingStyle
Returns:
A mapping generator that creates a mapping according to this style

getBaseIRI

public String getBaseIRI()
Specified by:
getBaseIRI in interface MappingStyle
Returns:
An absolute IRI that will be used as a base for instance and vocabulary namespaces

getPrefixes

public PrefixMapping getPrefixes()
Description copied from interface: MappingStyle
Returns a prefix mapping with convenient prefix declarations for this style of mapping. This could be mappings for the instance and vocabulary namespace(s) used by the style, and any vocabulary namespaces used.

Specified by:
getPrefixes in interface MappingStyle
Returns:
A prefix mapping

getEntityIRITemplate

public TemplateValueMaker getEntityIRITemplate(TableDef table,
                                               Key columns)
Description copied from interface: MappingStyle
Returns an IRI template to be used to uniquely identify the records in a table. Can be invoked with a null argument to indicate that all records should receive the same IRI. Note: The pattern may produce relative IRIs, assuming the base IRI from MappingStyle.getBaseIRI().

Specified by:
getEntityIRITemplate in interface MappingStyle
Parameters:
table - The table definition
columns - The primary or unique key to be used, or null
Returns:
An IRI template

getEntityPseudoKeyColumns

public List<Identifier> getEntityPseudoKeyColumns(List<ColumnDef> columns)
Description copied from interface: MappingStyle
Returns a list of columns to be used to form blank node identifiers for the records in a table that has no suitable unique/primary key

Specified by:
getEntityPseudoKeyColumns in interface MappingStyle
Parameters:
columns - The column definition
Returns:
A column list

getGeneratedOntologyResource

public Resource getGeneratedOntologyResource()
Description copied from interface: MappingStyle
Creates a resource that represents the ontology that defines all generated classes and properties.

Specified by:
getGeneratedOntologyResource in interface MappingStyle
Returns:
An ontology resource representing the generated terms

getTableClass

public Resource getTableClass(TableName tableName)
Description copied from interface: MappingStyle
Creates a class for a table.

Specified by:
getTableClass in interface MappingStyle
Parameters:
tableName - The table
Returns:
A class resource representing the table

getColumnProperty

public Property getColumnProperty(TableName tableName,
                                  Identifier column)
Description copied from interface: MappingStyle
Creates a property for a table column.

Specified by:
getColumnProperty in interface MappingStyle
Parameters:
tableName - The table
column - A column on the table
Returns:
A property representing the column

getForeignKeyProperty

public Property getForeignKeyProperty(TableName tableName,
                                      ForeignKey fk)
Description copied from interface: MappingStyle
Creates a property for a foreign key relationship between two tables.

Specified by:
getForeignKeyProperty in interface MappingStyle
Parameters:
tableName - The source table
fk - A foreign key defines on the source table
Returns:
A property representing the relationship

getLinkProperty

public Property getLinkProperty(TableName linkTable)
Description copied from interface: MappingStyle
Creates a property for an N:M link table.

Specified by:
getLinkProperty in interface MappingStyle
Parameters:
linkTable - A relationship table
Returns:
A property representing the table

getEntityLabelTemplate

public TemplateValueMaker getEntityLabelTemplate(TableName tableName,
                                                 Key columns)
Description copied from interface: MappingStyle
Creates a best-effort template for human-readable labels for the records in a table, based on a given list of columns.

Specified by:
getEntityLabelTemplate in interface MappingStyle
Parameters:
tableName - The table
columns - A list of columns in the table
Returns:
A template for generating labels for the records