public class RDF4JR2RMLMappingManager extends R2RMLMappingManagerImpl {

    private static RDF4JR2RMLMappingManager INSTANCE = new RDF4JR2RMLMappingManager(new RDF4J());

    private RDF4JR2RMLMappingManager(RDF4J rdf) {
        super(rdf);
    }

    public Collection<TriplesMap> importMappings(Model model) throws InvalidR2RMLMappingException {
        return importMappings(((RDF4J) getRDF()).asGraph(model));
    }

    @Override
    public RDF4JGraph exportMappings(Collection<TriplesMap> maps) {
        return (RDF4JGraph) super.exportMappings(maps);
    }

    public static RDF4JR2RMLMappingManager getInstance(){
        return INSTANCE;
    }
} public class SQLBaseTableOrViewImpl extends LogicalTableImpl implements SQLBaseTableOrView {

	String table;

	public SQLBaseTableOrViewImpl(RDF c, String tableName) {
		super(c);

		setTableName(tableName);

        setNode(getRDF().createBlankNode());
	}

	@Override
	public void setTableName(String tableName) {
		if (tableName != null) {
			table = tableName;
		} else {
			throw new NullPointerException("A SQLBaseTableOrView must have a table name.");
		}
	}

	@Override
	public String getTableName() {
		return table;
	}

	@Override
	public String getSQLQuery() {
		return "SELECT * FROM " + table;
	}

	@Override
	public Set<Triple> serialize() {
		Set<Triple> stmtSet = new HashSet<Triple>();

        stmtSet.add(getRDF().createTriple(node, getRDF().createIRI("http://www.w3.org/1999/02/22-rdf-syntax-ns#type"), getRDF().createIRI(R2RMLVocabulary.TYPE_BASE_TABLE_OR_VIEW)));

        stmtSet.add(getRDF().createTriple(node, getRDF().createIRI(R2RMLVocabulary.PROP_TABLE_NAME),
                getRDF().createLiteral(getTableName())));

		return stmtSet;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((node == null) ? 0 : node.hashCode());
		result = prime * result + ((table == null) ? 0 : table.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;

		if (obj == null)
			return false;

		if (!(obj instanceof SQLBaseTableOrViewImpl))
			return false;

		SQLBaseTableOrViewImpl other = (SQLBaseTableOrViewImpl) obj;
		if (node == null) {
			if (other.node != null) {
				return false;
			}
		} else if (!node.equals(other.node)) {
			return false;
		}

		if (table == null) {
			if (other.table != null) {
				return false;
			}
		} else if (!table.equals(other.table)) {
			return false;
		}

		return true;
	}

	@Override
	public String toString() {
		return "SQLBaseTableOrViewImpl [table=" + table + ", node=" + node + "]";
	}

}
 @W3C_R2RML_Recommendation(R2RMLVocabulary.TYPE_LOGICAL_TABLE)
public interface LogicalTable extends MappingComponent {

	/**
	 * Returns the effective SQL query of this LogicalTable. The effective SQL
	 * query of a R2RMLView is it's own SQL query. For a SQLBaseTableOrView it's
	 * "SELECT * FROM {table}".
	 * 
	 * @return The effective SQL query of this LogicalTable.
	 */
    @W3C_R2RML_Recommendation(R2RMLVocabulary.PROP_SQL_QUERY)
	public String getSQLQuery();

}
 @W3C_R2RML_Recommendation(R2RMLVocabulary.TYPE_OBJECT_MAP)
public interface ObjectMap extends TermMap {

    /**
     * {@inheritDoc}
     *
     * The possible values for the term type are:<br>
     * - rr:IRI<br>
     * - rr:BlankNode<br>
     * - rr:Literal
     *
     */
    @W3C_R2RML_Recommendation(R2RMLVocabulary.PROP_TERM_TYPE)
    @Override
    void setTermType(IRI typeIRI);

    /**
	 * Set the language tag of this ObjectMap if the term type is set to
	 * rr:Literal. If the ObjectMap is data typed, the data type will be
	 * removed.
	 * 
	 * @param lang
	 *            The language tag to be set. Must be a valid language tag.
	 * @throws IllegalStateException
	 *             If the term type of this ObjectMap is not rr:Literal.
	 */
    @W3C_R2RML_Recommendation(R2RMLVocabulary.PROP_LANGUAGE)
    public void setLanguageTag(String lang);

	/**
	 * Set the data type for this ObjectMap. A ObjectMap can have either zero or
	 * one data types. The ObjectMap can only be data typed if the term type is
	 * rr:Literal. If the ObjectMap has a language tag, the language tag will be
	 * removed. The datatypeURI parameter must be an instance of the library's
	 * resource class.
	 * 
	 * @param datatypeURI
	 *            The data type IRI to be set.
	 * @throws IllegalStateException
	 *             If the term type of this ObjectMap is not rr:Literal.
	 */
    @W3C_R2RML_Recommendation(R2RMLVocabulary.PROP_DATATYPE)
	public void setDatatype(IRI datatypeURI);

	/**
	 * Get the language tag for this ObjectMap. It will return null if the
	 * ObjectMap doesn't have a language tag.
	 * 
	 * @return The language tag of this ObjectMap.
	 */
    @W3C_R2RML_Recommendation(R2RMLVocabulary.PROP_LANGUAGE)
	public String getLanguageTag();

	/**
	 * Get the data type for this ObjectMap. It will return null if the
	 * ObjectMap is not data typed.
	 *
	 * @return The data type of this ObjectMap.
	 */
    @W3C_R2RML_Recommendation(R2RMLVocabulary.PROP_DATATYPE)
    public IRI getDatatype();

	/**
	 * Remove the data type associated with this ObjectMap. The ObjectMap will
	 * no longer be data typed.
	 */
    @W3C_R2RML_Recommendation(R2RMLVocabulary.PROP_DATATYPE)
	public void removeDatatype();

	/**
	 * Removes the language tag from this ObjectMap if there is one.
	 */
    @W3C_R2RML_Recommendation(R2RMLVocabulary.PROP_LANGUAGE)
	public void removeLanguageTag();

}
 @W3C_R2RML_Recommendation(R2RMLVocabulary.TYPE_PREDICATE_MAP)
public interface PredicateMap extends TermMap {

}
 @W3C_R2RML_Recommendation(R2RMLVocabulary.TYPE_PREDICATE_OBJECT_MAP)
public interface PredicateObjectMap extends MappingComponent {

	/**
	 * Adds a PredicateMap to this PredicateObjectMap. The PredicateMap will be
	 * added to the end of the PredicateMap list. A PredicateObjectMap must have
	 * one or more PredicateMaps.
	 * 
	 * @param pm
	 *            The PredicateMap that will be added.
	 */
	@W3C_R2RML_Recommendation(R2RMLVocabulary.PROP_PREDICATE_MAP)
	public void addPredicateMap(PredicateMap pm);

	/**
	 * Adds an ObjectMap to this PredicateObjectMap. The ObjectMap will be added
	 * to the end of the ObjectMap list. A PredicateObjectMap must have at least
	 * one ObjectMap or RefObjectMap.
	 * 
	 * @param om
	 *            The ObjectMap that will be added.
	 */
    @W3C_R2RML_Recommendation(R2RMLVocabulary.PROP_OBJECT_MAP)
	public void addObjectMap(ObjectMap om);

	/**
	 * Adds an RefObjectMap to this PredicateObjectMap. The RefObjectMap will be
	 * added to the end of the RefObjectMap list. A PredicateObjectMap must have
	 * at least one ObjectMap or RefObjectMap.
	 * 
	 * @param rom
	 *            The RefObjectMap that will be added.
	 */
	@W3C_R2RML_Recommendation(R2RMLVocabulary.PROP_OBJECT_MAP)
	public void addRefObjectMap(RefObjectMap rom);

	/**
	 * Adds a GraphMap to this PredicateObjectMap. A PredicateObjectMap can have
	 * zero or more GraphMaps. The GraphMap will be added to the end of the
	 * GraphMap list.
	 * 
	 * @param gm
	 *            The GraphMap that will be added.
	 */
    @W3C_R2RML_Recommendation(R2RMLVocabulary.PROP_GRAPH_MAP)
	public void addGraphMap(GraphMap gm);

	/**
	 * Adds a list of GraphMaps to this PredicateObjectMap. A PredicateObjectMap
	 * can have zero or more GraphMaps. The GraphMaps will be added to the end
	 * of the GraphMap list.
	 * 
	 * @param gms
	 *            The list of GraphMaps that will be added.
	 */
    @W3C_R2RML_Recommendation(R2RMLVocabulary.PROP_GRAPH_MAP)
    public void addGraphMaps(List<GraphMap> gms);

	/**
	 * Get the GraphMap located at the given index.
	 * 
	 * @param index
	 *            The index of the GraphMap.
	 * @return The GraphMap located at the given index.
	 * @throws IndexOutOfBoundsException
	 *             If the given index is out of range.
	 */
    @W3C_R2RML_Recommendation(R2RMLVocabulary.PROP_GRAPH_MAP)
	public GraphMap getGraphMap(int index);

	/**
	 * Get the RefObjectMap located at the given index.
	 * 
	 * @param index
	 *            The index of the RefObjectMap.
	 * @return The RefObjectMap located at the given index.
	 * @throws IndexOutOfBoundsException
	 *             If the given index is out of range.
	 */
    @W3C_R2RML_Recommendation(R2RMLVocabulary.PROP_OBJECT_MAP)
    public RefObjectMap getRefObjectMap(int index);

	/**
	 * Get the ObjectMap located at the given index.
	 * 
	 * @param index
	 *            The index of the ObjectMap.
	 * @return The ObjectMap located at the given index.
	 * @throws IndexOutOfBoundsException
	 *             If the given index is out of range.
	 */
    @W3C_R2RML_Recommendation(R2RMLVocabulary.PROP_OBJECT_MAP)
    public ObjectMap getObjectMap(int index);

	/**
	 * Get the PredicateMap located at the given index.
	 * 
	 * @param index
	 *            The index of the PredicateMap.
	 * @return The PredicateMap located at the given index.
	 * @throws IndexOutOfBoundsException
	 *             If the given index is out of range.
	 */
    @W3C_R2RML_Recommendation(R2RMLVocabulary.PROP_PREDICATE_MAP)
    public PredicateMap getPredicateMap(int index);

	/**
	 * Returns an unmodifiable view of the list of GraphMaps that have been
	 * added to this PredicateObjectMap.
	 * 
	 * @return An unmodifiable list of GraphMaps.
	 */
    @W3C_R2RML_Recommendation(R2RMLVocabulary.PROP_GRAPH_MAP)
	public List<GraphMap> getGraphMaps();

	/**
	 * Returns an unmodifiable view of the list of RefObjectMaps that have been
	 * added to this PredicateObjectMap.
	 * 
	 * @return An unmodifiable list of RefObjectMaps.
	 */
    @W3C_R2RML_Recommendation(R2RMLVocabulary.PROP_OBJECT_MAP)
	public List<RefObjectMap> getRefObjectMaps();

	/**
	 * Returns an unmodifiable view of the list of ObjectMaps that have been
	 * added to this PredicateObjectMap.
	 * 
	 * @return An unmodifiable list of ObjectMaps.
	 */
    @W3C_R2RML_Recommendation(R2RMLVocabulary.PROP_OBJECT_MAP)
    public List<ObjectMap> getObjectMaps();

	/**
	 * Returns an unmodifiable view of the list of PredicateMaps that have been
	 * added to this PredicateObjectMap.
	 * 
	 * @return An unmodifiable list of PredicateMaps.
	 */
    @W3C_R2RML_Recommendation(R2RMLVocabulary.PROP_PREDICATE_MAP)
    public List<PredicateMap> getPredicateMaps();

	/**
	 * Remove the GraphMap given by the parameter, from the PredicateObjectMap.
	 * The subsequent GraphMaps in the list will be shifted left.
	 * 
	 * @param gm
	 *            The GraphMap to be removed.
	 */
    @W3C_R2RML_Recommendation(R2RMLVocabulary.PROP_GRAPH_MAP)
    public void removeGraphMap(GraphMap gm);

	/**
	 * Remove the RefObjectMap, given by the parameter, from the
	 * PredicateObjectMap. The subsequent RefObjectMaps in the list will be
	 * shifted left.
	 * 
	 * @param rom
	 *            The RefObjectMap to be removed.
	 * @throws IllegalStateException
	 *             If removing the RefObjectMap would cause the
	 *             PredicateObjectMap to contain no RefObjectMaps or ObjectMaps.
	 */
    @W3C_R2RML_Recommendation(R2RMLVocabulary.PROP_OBJECT_MAP)
	public void removeRefObjectMap(RefObjectMap rom);

	/**
	 * Remove the ObjectMap, given by the parameter, from the
	 * PredicateObjectMap. The subsequent ObjectMaps in the list will be shifted
	 * left.
	 * 
	 * @param om
	 *            The ObjectMap to be removed.
	 * @throws IllegalStateException
	 *             If removing the RefObjectMap would cause the
	 *             PredicateObjectMap to contain no RefObjectMaps or ObjectMaps.
	 */
    @W3C_R2RML_Recommendation(R2RMLVocabulary.PROP_OBJECT_MAP)
	public void removeObjectMap(ObjectMap om);

	/**
	 * Remove the PredicateMap, given by the parameter, from the
	 * PredicateObjectMap. The subsequent PredicateMaps in the list will be
	 * shifted left.
	 * 
	 * @param pm
	 *            The PredicateMap to be removed.
	 * @throws IllegalStateException
	 *             If removing the RefObjectMap would cause the
	 *             PredicateObjectMap to contain no PredicateMaps.
	 */
    @W3C_R2RML_Recommendation(R2RMLVocabulary.PROP_OBJECT_MAP)
	public void removePredicateMap(PredicateMap pm);

}
 @W3C_R2RML_Recommendation(R2RMLVocabulary.TYPE_SUBJECT_MAP)
public interface SubjectMap extends TermMap {

    /**
     * Adds a class to the SubjectMap. The class URI will be added to the end of
     * the class list. A SubjectMap can have zero or more classes. The classURI
     * parameter must be an instance of the library's resource class.
     *
     * @param classURI The class URI that will be added.
     */
    @W3C_R2RML_Recommendation(R2RMLVocabulary.PROP_CLASS)
    public void addClass(IRI classURI);

    /**
     * Adds a GraphMap to this SubjectMap. The GraphMap will be added to the end
     * of the GraphMap list. A SubjectMap can have zero or more GraphMaps.
     *
     * @param gm The GraphMap that will be added.
     */
    @W3C_R2RML_Recommendation(R2RMLVocabulary.PROP_GRAPH_MAP)
    public void addGraphMap(GraphMap gm);

    /**
     * Adds a list of GraphMaps to this SubjectMap. A SubjectMap can have zero
     * or more GraphMaps. The GraphMaps will be added to the end of the GraphMap
     * list.
     *
     * @param gms The list of GraphMaps that will be added.
     */
    @W3C_R2RML_Recommendation(R2RMLVocabulary.PROP_GRAPH_MAP)
    public void addGraphMap(List<GraphMap> gms);

    /**
     * {@inheritDoc}
     *
     * The possible values for the term type are
     * (http://www.w3.org/TR/r2rml/#dfn-term-type>):<br>
     * - rr:IRI<br>
     * - rr:BlankNode
     */
    @Override
    public void setTermType(IRI typeIRI);

    /**
     * Get the class URI located at the given index.
     *
     * @param index The index of the class URI.
     * @return The class URI located at the given index.
     * @throws IndexOutOfBoundsException If the given index is out of range.
     */
    @W3C_R2RML_Recommendation(R2RMLVocabulary.PROP_CLASS)
    public IRI getClass(int index);

    /**
     * Get the GraphMap located at the given index.
     *
     * @param index The index of the GraphMap.
     * @return The GraphMap located at the given index.
     * @throws IndexOutOfBoundsException If the given index is out of range.
     */
    @W3C_R2RML_Recommendation(R2RMLVocabulary.PROP_GRAPH_MAP)
    public GraphMap getGraphMap(int index);

    /**
     * Returns an unmodifiable view of the list of classes that have been added
     * to this SubjectMap.
     *
     * @return An unmodifiable list of classes.
     */
    @W3C_R2RML_Recommendation(R2RMLVocabulary.PROP_CLASS)
    public List<IRI> getClasses();

    /**
     * Returns an unmodifiable view of the list of GraphMaps that have been
     * added to this SubjectMap.
     *
     * @return An unmodifiable list of GraphMaps.
     */
    @W3C_R2RML_Recommendation(R2RMLVocabulary.PROP_GRAPH_MAP)
    public List<GraphMap> getGraphMaps();

    /**
     * Remove the class given by the parameter, from the SubjectMap. The
     * subsequent class URIs in the list will be shifted left. The classURI
     * parameter must be an instance of the library's resource class.
     *
     * @param classURI The class that will be removed.
     */
    @W3C_R2RML_Recommendation(R2RMLVocabulary.PROP_CLASS)
    public void removeClass(IRI classURI);

    /**
     * Remove the GraphMap given by the parameter, from the SubjectMap. The
     * subsequent GraphMaps in the list will be shifted left.
     *
     * @param gm The GraphMap to be removed.
     */
    @W3C_R2RML_Recommendation(R2RMLVocabulary.PROP_GRAPH_MAP)
    public void removeGraphMap(GraphMap gm);

}
 public interface Template {

	/**
	 * Gets the string segment at the given index.
	 * 
	 * @param segIndex
	 *            The index of the string segment.
	 * @return The string segment at the given index.
	 */
	String getStringSegment(int segIndex);

    /**
     * Gets the string segments
     * @return The string segments
     */
    List<String> getStringSegments();

    String getTemplateStringWithoutColumnNames();

    /**
	 * Set the string segment on the given index. Any previously set segments on
	 * this index will be removed. Adding a new string segment (that don't
	 * overwrite older ones), must be done by adding it with an index one higher
	 * that the previously highest index.
	 * 
	 * @param segIndex
	 *            The index where the string segment will be set.
	 * @param segment
	 *            The string segment to insert.
	 * @throws IndexOutOfBoundsException
	 *             If the index is larger than the previously highest index plus
	 *             one.
	 */
	void addStringSegment(int segIndex, String segment);

	/**
	 * Gets the column name at the given index.
	 * 
	 * @param colIndex
	 *            The index of the column name.
	 * @return The column name at the given index.
	 */
	String getColumnName(int colIndex);

	/**
	 * Returns an unmodifiable view of all the column names in this template.
	 * 
	 * @return An unmodifiable view of all column names.
	 */
	List<String> getColumnNames();

	/**
	 * Set the column name on the given index. Any previously set column names
	 * on this index will be removed. Adding new column name (that don't
	 * overwrite older ones), must be done by adding it with an index one higher
	 * that the previously highest index.
	 * 
	 * @param colIndex
	 *            The index where the column name will be set.
	 * @param columnName
	 *            The column name to insert.
	 * @throws IndexOutOfBoundsException
	 *             If the index is larger than the previously highest index plus
	 *             one.
	 */
	void addColumnName(int colIndex, String columnName);
}
 @W3C_R2RML_Recommendation(R2RMLVocabulary.TYPE_TRIPLES_MAP)
public interface TriplesMap extends MappingComponent {

	/**
	 * Set the LogicalTable of this TriplesMap. A TriplesMap must have exactly
	 * one LogicalTable.
	 * 
	 * @param lt
	 *            The LogicalTable that will be added.
	 */
	@W3C_R2RML_Recommendation(R2RMLVocabulary.PROP_LOGICAL_TABLE)
	public void setLogicalTable(LogicalTable lt);

	/**
	 * Set the SubjectMap of this TriplesMap. A TriplesMap must have exactly one
	 * SubjectMap.
	 * 
	 * @param sm
	 *            The SubjectMap that will be added.
	 */
    @W3C_R2RML_Recommendation(R2RMLVocabulary.PROP_SUBJECT_MAP)
	public void setSubjectMap(SubjectMap sm);

	/**
	 * Adds a PredicateObjectMap to this TriplesMap. The PredicateObjectMap will
	 * be added to the end of the PredicateObjectMap list. A TriplesMap can have
	 * any number of PredicateObjectMaps.
	 * 
	 * @param pom
	 *            The PredicateObjectMap that will be added.
	 */
    @W3C_R2RML_Recommendation(R2RMLVocabulary.PROP_PREDICATE_OBJECT_MAP)
	public void addPredicateObjectMap(PredicateObjectMap pom);
	
	/**
	 * Adds a collection of PredicateObjectMaps to this TriplesMap. The PredicateObjectMap will
	 * be added to the end of the PredicateObjectMap list. A TriplesMap can have
	 * any number of PredicateObjectMaps.
	 * 
	 * @param poms
	 *            The PredicateObjectMaps that will be added.
	 */
    @W3C_R2RML_Recommendation(R2RMLVocabulary.PROP_PREDICATE_OBJECT_MAP)
	public void addPredicateObjectMaps(Collection<PredicateObjectMap> poms);

	/**
	 * Get the LogicalTable associated with this TriplesMap.
	 * 
	 * @return The LogicalTable of this TriplesMap.
	 */
    @W3C_R2RML_Recommendation(R2RMLVocabulary.PROP_LOGICAL_TABLE)
	public LogicalTable getLogicalTable();

	/**
	 * Get the SubjectMap associated with this TriplesMap.
	 * 
	 * @return The SubjectMap of this TriplesMap.
	 */
    @W3C_R2RML_Recommendation(R2RMLVocabulary.PROP_SUBJECT_MAP)
	public SubjectMap getSubjectMap();

	/**
	 * Get the PredicateObjectMap located at the given index.
	 * 
	 * @param index
	 *            The index of the PredicateObjectMap.
	 * @return The PredicateObjectMap located at the given index.
	 * @throws IndexOutOfBoundsException
	 *             If the given index is out of range.
	 */
    @W3C_R2RML_Recommendation(R2RMLVocabulary.PROP_PREDICATE_OBJECT_MAP)
	public PredicateObjectMap getPredicateObjectMap(int index);

	/**
	 * Returns an unmodifiable view of the list of PredicateObjectMaps that have
	 * been added to this TriplesMap.
	 * 
	 * @return An unmodifiable list of PredicateObjectMaps.
	 */
    @W3C_R2RML_Recommendation(R2RMLVocabulary.PROP_PREDICATE_OBJECT_MAP)
	public List<PredicateObjectMap> getPredicateObjectMaps();

	/**
	 * Remove the PredicateObjectMap given by the parameter, from the
	 * TriplesMap. The subsequent PredicateObjectMaps in the list will be
	 * shifted left.
	 * 
	 * @param pom
	 *            The PredicateObjectMap to be removed.
	 */
    @W3C_R2RML_Recommendation(R2RMLVocabulary.PROP_PREDICATE_OBJECT_MAP)
	public void removePredicateObjectMap(PredicateObjectMap pom);

	

}
 public class R2RMLVocabulary {

    // the R2RML namespace
    public static final String NAMESPACE = "http://www.w3.org/ns/r2rml#";

    // R2RML types
    public static final String TYPE_BASE_TABLE_OR_VIEW = NAMESPACE + "BaseTableOrView";
    public static final String TYPE_GRAPH_MAP = NAMESPACE + "GraphMap";
    public static final String TYPE_JOIN = NAMESPACE + "Join";
    public static final String TYPE_LOGICAL_TABLE = NAMESPACE + "LogicalTable";
    public static final String TYPE_OBJECT_MAP = NAMESPACE + "ObjectMap";
    public static final String TYPE_PREDICATE_MAP = NAMESPACE + "PredicateMap";
    public static final String TYPE_PREDICATE_OBJECT_MAP = NAMESPACE + "PredicateObjectMap";
    public static final String TYPE_R2RML_VIEW = NAMESPACE + "R2RMLView";
    public static final String TYPE_REF_OBJECT_MAP = NAMESPACE + "RefObjectMap";
    public static final String TYPE_SUBJECT_MAP = NAMESPACE + "SubjectMap";
    public static final String TYPE_TERM_MAP = NAMESPACE + "TermMap";
    public static final String TYPE_TRIPLES_MAP = NAMESPACE + "TriplesMap";

    // R2RML properties
    public static final String PROP_CHILD = NAMESPACE + "child";
    public static final String PROP_CLASS = NAMESPACE + "class";
    public static final String PROP_COLUMN = NAMESPACE + "column";
    public static final String PROP_DATATYPE = NAMESPACE + "datatype";
    public static final String PROP_CONSTANT = NAMESPACE + "constant";
    public static final String PROP_GRAPH = NAMESPACE + "graph";
    public static final String PROP_GRAPH_MAP = NAMESPACE + "graphMap";
    public static final String PROP_INVERSE_EXPRESSION = NAMESPACE + "inverseExpression";
    public static final String PROP_JOIN_CONDITION = NAMESPACE + "joinCondition";
    public static final String PROP_LANGUAGE = NAMESPACE + "language";
    public static final String PROP_LOGICAL_TABLE = NAMESPACE + "logicalTable";
    public static final String PROP_OBJECT = NAMESPACE + "object";
    public static final String PROP_OBJECT_MAP = NAMESPACE + "objectMap";
    public static final String PROP_PARENT = NAMESPACE + "parent";
    public static final String PROP_PARENT_TRIPLES_MAP = NAMESPACE + "parentTriplesMap";
    public static final String PROP_PREDICATE = NAMESPACE + "predicate";
    public static final String PROP_PREDICATE_MAP = NAMESPACE + "predicateMap";
    public static final String PROP_PREDICATE_OBJECT_MAP = NAMESPACE + "predicateObjectMap";
    public static final String PROP_SQL_QUERY = NAMESPACE + "sqlQuery";
    public static final String PROP_SQL_VERSION = NAMESPACE + "sqlVersion";
    public static final String PROP_SUBJECT = NAMESPACE + "subject";
    public static final String PROP_SUBJECT_MAP = NAMESPACE + "subjectMap";
    public static final String PROP_TABLE_NAME = NAMESPACE + "tableName";
    public static final String PROP_TEMPLATE = NAMESPACE + "template";
    public static final String PROP_TERM_TYPE = NAMESPACE + "termType";

    // R2RML other terms
    public static final String TERM_DEFAULT_GRAPH = NAMESPACE + "defaultGraph";
    public static final String TERM_SQL_2008 = NAMESPACE + "SQL2008";
    public static final String TERM_IRI = NAMESPACE + "IRI";
    public static final String TERM_BLANK_NODE = NAMESPACE + "BlankNode";
    public static final String TERM_LITERAL = NAMESPACE + "Literal";

}

import java.io.InputStream;
import java.util.Collection;
import java.util.Iterator;
import eu.optique.r2rml.api.binding.rdf4j.RDF4JR2RMLMappingManager;
import eu.optique.r2rml.api.model.impl.SQLBaseTableOrViewImpl;
import org.apache.commons.rdf.api.IRI;
import org.apache.commons.rdf.rdf4j.RDF4J;
import org.junit.Assert;
import org.junit.Test;
import org.eclipse.rdf4j.model.Model;
import org.eclipse.rdf4j.model.ValueFactory;
import org.eclipse.rdf4j.model.impl.LinkedHashModel;
import org.eclipse.rdf4j.model.impl.ValueFactoryImpl;
import org.eclipse.rdf4j.rio.RDFFormat;
import org.eclipse.rdf4j.rio.RDFParser;
import org.eclipse.rdf4j.rio.Rio;
import org.eclipse.rdf4j.rio.helpers.StatementCollector;
import eu.optique.r2rml.api.model.LogicalTable;
import eu.optique.r2rml.api.model.ObjectMap;
import eu.optique.r2rml.api.model.PredicateMap;
import eu.optique.r2rml.api.model.PredicateObjectMap;
import eu.optique.r2rml.api.model.SubjectMap;
import eu.optique.r2rml.api.model.Template;
import eu.optique.r2rml.api.model.TriplesMap;
import eu.optique.r2rml.api.model.R2RMLVocabulary;

/*******************************************************************************
 * Copyright 2013, the Optique Consortium
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *   http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * 
 * This first version of the R2RML API was developed jointly at the University of Oslo, 
 * the University of Bolzano, La Sapienza University of Rome, and fluid Operations AG, 
 * as part of the Optique project, www.optique-project.eu
 ******************************************************************************/
package rdf4jTest;




/**
 * JUnit Test Cases
 * 
 * @author Riccardo Mancini
 */
public class TermType_Test {
	
	@Test
	public void test() throws Exception{
		
		ValueFactory myFactory = ValueFactoryImpl.getInstance();

		RDF4J rdf4J = new RDF4J();

		InputStream fis = getClass().getResourceAsStream("../mappingFiles/test7.ttl");

        RDF4JR2RMLMappingManager mm = RDF4JR2RMLMappingManager.getInstance();
		
		// Read the file into a model.
		RDFParser rdfParser = Rio.createParser(RDFFormat.TURTLE);
		Model m = new LinkedHashModel();
		rdfParser.setRDFHandler(new StatementCollector(m));
		rdfParser.parse(fis, "testMapping");
		
		Collection<TriplesMap> coll = mm.importMappings(m);
		
		Assert.assertTrue(coll.size()==1);
		
		Iterator<TriplesMap> it=coll.iterator();
		while(it.hasNext()){
			TriplesMap current=it.next();

			SubjectMap s=current.getSubjectMap();
			Template t=s.getTemplate();
			Assert.assertTrue(t.getColumnName(0).contains("ID"));
			
			LogicalTable table=current.getLogicalTable();
			
			
			if(table instanceof SQLBaseTableOrViewImpl){
				SQLBaseTableOrViewImpl ta= (SQLBaseTableOrViewImpl) table;
				Assert.assertTrue(ta.getTableName().contains("Student"));
			}else{
				Assert.assertTrue(false);
			}
			
			
			
			Iterator<PredicateObjectMap> pomit=current.getPredicateObjectMaps().iterator();
			while(pomit.hasNext()){
				PredicateObjectMap pom=pomit.next();
				
				Iterator<PredicateMap> pmit=pom.getPredicateMaps().iterator();
				while(pmit.hasNext()){
					PredicateMap p=pmit.next();
					boolean first=p.getConstant().toString().contains("name");
					
					Assert.assertTrue(first);
					
				}
				
				Iterator<ObjectMap> omit=pom.getObjectMaps().iterator();
				while(omit.hasNext()){
					ObjectMap o=omit.next();
					
					Assert.assertEquals("\"FirstName\"", o.getTemplate().getColumnName(0));
					Assert.assertEquals("\"LastName\"", o.getTemplate().getColumnName(1));
					
					IRI u=o.getTermType();

					Assert.assertEquals(u, rdf4J.asRDFTerm(myFactory.createIRI(R2RMLVocabulary.TERM_LITERAL)));
