Package de.fuberlin.wiwiss.d2rq

Examples of de.fuberlin.wiwiss.d2rq.D2RQException


  }

  public void validate() throws D2RQException {
    if (this.refersToClassMap != null) {
      if (!this.refersToClassMap.database().equals(this.belongsToClassMap.database())) {
        throw new D2RQException(toString() +
            " links two d2rq:ClassMaps with different d2rq:dataStorages",
            D2RQException.PROPERTYBRIDGE_CONFLICTING_DATABASES);
      }
      // TODO refersToClassMap cannot be combined w/ value constraints or translation tables
    }
    if (properties.isEmpty() && dynamicPropertyPatterns.isEmpty()) {
      throw new D2RQException(toString() + " needs a d2rq:property or d2rq:dynamicProperty",
          D2RQException.PROPERTYBRIDGE_MISSING_PREDICATESPEC);
    }
    assertHasPrimarySpec(new Property[]{
        D2RQ.uriColumn, D2RQ.uriPattern, D2RQ.bNodeIdColumns,
        D2RQ.column, D2RQ.pattern, D2RQ.sqlExpression, D2RQ.uriSqlExpression, D2RQ.constantValue,
        D2RQ.refersToClassMap
    });
    if (this.datatype != null && this.lang != null) {
      throw new D2RQException(toString() + " has both d2rq:datatype and d2rq:lang",
          D2RQException.PROPERTYBRIDGE_LANG_AND_DATATYPE);
    }
    if (this.datatype != null && this.column == null && this.pattern == null
        && this.sqlExpression == null) {
      throw new D2RQException("d2rq:datatype can only be used with d2rq:column, d2rq:pattern " +
          "or d2rq:sqlExpression at " + this,
          D2RQException.PROPERTYBRIDGE_NONLITERAL_WITH_DATATYPE);
    }
    if (this.lang != null && this.column == null && this.pattern == null) {
      throw new D2RQException("d2rq:lang can only be used with d2rq:column, d2rq:pattern " +
          "or d2rq:sqlExpression at " + this,
          D2RQException.PROPERTYBRIDGE_NONLITERAL_WITH_LANG);
    }
  }
View Full Code Here


 
  protected void assertNotYetDefined(Object object, Property property, int errorCode) {
    if (object == null) {
      return;
    }
    throw new D2RQException("Duplicate " + PrettyPrinter.toString(property) +
        " for " + this, errorCode);
  }
View Full Code Here

 
  protected void assertHasBeenDefined(Object object, Property property, int errorCode) {
    if (object != null) {
      return;
    }
    throw new D2RQException("Missing " + PrettyPrinter.toString(property) +
        " for " + this, errorCode);
  }
View Full Code Here

 
  protected void assertArgumentNotNull(Object object, Property property, int errorCode) {
    if (object != null) {
      return;
    }
    throw new D2RQException("Object for " + PrettyPrinter.toString(property) +
        " not found at " + this, errorCode);
  }
View Full Code Here

    return new TableTranslator(this.translations);
  }

  public void validate() throws D2RQException {
    if (!this.translations.isEmpty() && this.javaClass != null) {
      throw new D2RQException("Can't combine d2rq:translation and d2rq:javaClass on " + this,
          D2RQException.TRANSLATIONTABLE_TRANSLATION_AND_JAVACLASS);
    }
    if (!this.translations.isEmpty() && this.href != null) {
      throw new D2RQException("Can't combine d2rq:translation and d2rq:href on " + this,
          D2RQException.TRANSLATIONTABLE_TRANSLATION_AND_HREF);
    }
    if (this.href != null && this.javaClass != null) {
      throw new D2RQException("Can't combine d2rq:href and d2rq:javaClass on " + this,
          D2RQException.TRANSLATIONTABLE_HREF_AND_JAVACLASS);
    }
  }
View Full Code Here

 
  private Translator instantiateJavaClass() {
    try {
      Class<?> translatorClass = Class.forName(this.javaClass);
      if (!checkTranslatorClassImplementation(translatorClass)) {
        throw new D2RQException("d2rq:javaClass " + this.javaClass + " must implement " + Translator.class.getName());
      }
      if (hasConstructorWithArg(translatorClass)) {
        return invokeConstructorWithArg(translatorClass, resource());
      }
      if (hasConstructorWithoutArg(translatorClass)) {
        return invokeConstructorWithoutArg(translatorClass);
      }
      throw new D2RQException("No suitable public constructor found on d2rq:javaClass " + this.javaClass);
    } catch (ClassNotFoundException e) {
      throw new D2RQException("d2rq:javaClass not on classpath: " + this.javaClass);
    }
  }
View Full Code Here

    assertHasBeenDefined(this.database, D2RQ.dataStorage, D2RQException.CLASSMAP_NO_DATABASE);
    assertHasPrimarySpec(new Property[]{
        D2RQ.uriColumn, D2RQ.uriPattern, D2RQ.uriSqlExpression, D2RQ.bNodeIdColumns, D2RQ.constantValue
    });
    if (this.constantValue != null && this.constantValue.isLiteral()) {
      throw new D2RQException(
          "d2rq:constantValue for class map " + toString() + " must be a URI or blank node",
          D2RQException.CLASSMAP_INVALID_CONSTANTVALUE);
    }
    if (this.uriPattern != null && new Pattern(uriPattern).attributes().size() == 0) {
      this.log.warn(toString() + " has an uriPattern without any column specifications. This usually happens when no primary keys are defined for a table. If the configuration is left as is, all table rows will be mapped to a single instance. " +
View Full Code Here

  public void validate() throws D2RQException {
    assertHasPrimarySpec(new Property[]{
        D2RQ.uriColumn, D2RQ.uriPattern, D2RQ.constantValue
    });
    if (database == null && belongsToClassMap == null) {
      throw new D2RQException(
          "Download map " + toString() + " needs a d2rq:dataStorage (or d2rq:belongsToClassMap)",
          D2RQException.DOWNLOADMAP_NO_DATASTORAGE);
    }
    assertHasBeenDefined(contentDownloadColumn, D2RQ.contentDownloadColumn,
        D2RQException.DOWNLOADMAP_NO_CONTENTCOLUMN);
    if (this.constantValue != null && !this.constantValue.isURIResource()) {
      throw new D2RQException(
          "d2rq:constantValue for download map " + toString() + " must be a URI",
          D2RQException.DOWNLOADMAP_INVALID_CONSTANTVALUE);
    }
    if (this.uriPattern != null && new Pattern(uriPattern).attributes().size() == 0) {
      log.warn(toString() + " has an uriPattern without any column specifications. This usually happens when no primary keys are defined for a table. If the configuration is left as is, all table rows will be mapped to a single instance. " +
View Full Code Here

  public Relation buildRelation() {
    if (!isUnique) {
      for (ProjectionSpec projection: projections) {
        for (Attribute column: projection.requiredAttributes()) {
          if (!database.columnType(column).supportsDistinct()) {
            throw new D2RQException("The datatype of " + column + " (" +
                database.columnType(column) + ") does not support " +
                "SELECT DISTINCT and therefore cannot be used in a " +
                "context where d2rq:containsDuplicates is true.",
                D2RQException.DATATYPE_DOES_NOT_SUPPORT_DISTINCT);
          }
View Full Code Here

    }
    if ("".equals(functionName) || functionName == null) {
      return IDENTITY;
    }
    // Shouldn't happen
    throw new D2RQException("Unrecognized column function '" + functionName + "'");
  }
View Full Code Here

TOP

Related Classes of de.fuberlin.wiwiss.d2rq.D2RQException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.