Package com.hp.hpl.jena.rdf.model

Examples of com.hp.hpl.jena.rdf.model.Statement$Util


    Property identifier = ResourceFactory.createProperty(
        riNamespace + "identifier");   
    StmtIterator stmtI1 = model.listStatements(resource,
        identifier, (RDFNode)null);
    while(stmtI1.hasNext()) {
      Statement statement = stmtI1.nextStatement();
      // validate identificator property //
      if(!statement.getObject().isLiteral()) {         
        if(!ModelException.throwException(ModelException.METRIC,
            "identificator property of Metric resource:"+
            resource.getURI()+" is not a literal")) {
          return null;
        }
      } else {
        metric.setIdentifier(statement.getObject().asLiteral().getString());
      }
    }
    Property description = ResourceFactory.createProperty(
        dcNamespace + "description");
    // description //
    stmtI1 = model.listStatements(resource,
        description, (RDFNode)null);
    while(stmtI1.hasNext()) {
      Statement statement = stmtI1.nextStatement();
      // validate description property //
      if(!statement.getObject().isLiteral()) {         
        if(!ModelException.throwException(ModelException.METRIC,
            "description property of Metric resource:"+
            resource.getURI()+" is not a literal")) {
          return null;
        }
      } else {
        metric.setDescription(statement.getObject().asLiteral().getString());
      }
    }
    Property hasScale = ResourceFactory.createProperty(
        riNamespace + "hasScale");
    // hasScale //
    stmtI1 = model.listStatements(resource,
        hasScale, (RDFNode)null);
    while(stmtI1.hasNext()) {
      Statement statement = stmtI1.nextStatement();
      // validate hasScale property //
      if(!statement.getObject().isResource()) {         
        if(!ModelException.throwException(ModelException.METRIC,
            "hasScale property of Metric resource:"+
            resource.getURI()+" is not a resource")) {
          return null;
        }
      } else {
        Scale scale = (Scale) getResourceFromCache(
            statement.getObject().asResource(),Scale.class);
        if(scale == null) {
          scale = getScale(model,statement.getObject().asResource(),null);         
        }
        metric.setScale(scale);
      }
    }
    Property hasDimension = ResourceFactory.createProperty(
        riNamespace + "hasDimension");
    // hasDimension //
    stmtI1 = model.listStatements(resource,
        hasDimension, (RDFNode)null);
    while(stmtI1.hasNext()) {
      Statement statement = stmtI1.nextStatement();
      // validate hasDimension property //
      if(!statement.getObject().isResource()) {         
        if(!ModelException.throwException(ModelException.METRIC,
            "hasDimension property of Metric resource:"+
            resource.getURI()+" is not a resource")) {
          return null;
        }
      } else {
        Dimension dimension = (Dimension) getResourceFromCache(
            statement.getObject().asResource(),Dimension.class);
        if(dimension == null) {
          dimension = getDimension(model,
              statement.getObject().asResource());         
        }
        metric.setDimension(dimension);
      }
    }
    return metric;
View Full Code Here


        riNamespace + "allowValue");
    // allowValue //
    StmtIterator stmtI1 = model.listStatements(resource,
        allowValue, (RDFNode)null);
    while(stmtI1.hasNext()) {
      Statement statement = stmtI1.nextStatement();
      // validate allowValue property //
      if(!statement.getObject().isLiteral()) {         
        if(!ModelException.throwException(ModelException.SCALE,
            "allowValue property of CategoricScale resource:"+
            resource.getURI()+" is not a literal")) {
          return null;
        }
      } else {
        categoricScale.addCategories(statement.getObject().asLiteral().getString());
      }
    }   
    return categoricScale;
  }
View Full Code Here

    Property minimum = ResourceFactory.createProperty(
        riNamespace + "minimum");
    StmtIterator stmtI1 = model.listStatements(resource,
        minimum, (RDFNode)null);
    while(stmtI1.hasNext()) {
      Statement statement = stmtI1.nextStatement();
      // validate minimum property //
      if(!statement.getObject().isLiteral()) {         
        if(!ModelException.throwException(ModelException.NUMERIC_SCALE,
            "minimum property of NumericScale resource:"+
            resource.getURI()+" is not a literal")) {
          return null;
        }
      } else {
        numericScale.setMinimum(statement.getObject().asLiteral().getDouble());
      }
    }
    Property maximum = ResourceFactory.createProperty(
        riNamespace + "maximum");
    // maximum //
    stmtI1 = model.listStatements(resource,
        maximum, (RDFNode)null);
    while(stmtI1.hasNext()) {
      Statement statement = stmtI1.nextStatement();
      /* validate maximum property */
      if(!statement.getObject().isLiteral()) {         
        if(!ModelException.throwException(ModelException.NUMERIC_SCALE,
            "maximum property of NumericScale resource:"+
            resource.getURI()+" is not a literal")) {
          return null;
        }
      } else {
        numericScale.setMaximum(statement.getObject().asLiteral().getDouble());
      }
    }
    Property step = ResourceFactory.createProperty(
        riNamespace + "step");
    // step //
    stmtI1 = model.listStatements(resource,
        step, (RDFNode)null);
    while(stmtI1.hasNext()) {
      Statement statement = stmtI1.nextStatement();
      // validate step property //
      if(!statement.getObject().isLiteral()) {         
        if(!ModelException.throwException(ModelException.NUMERIC_SCALE,
            "step property of NumericScale resource:"+
            resource.getURI()+" is not a literal")){
          return null;
        }
      } else {
        numericScale.setStep(statement.getObject().asLiteral().getDouble());
      }
    }
    return numericScale;
  }
View Full Code Here

      Resource numericScale = ResourceFactory.
          createResource(riNamespace + "NumericScale");
      Resource categoricScale = ResourceFactory.
          createResource(riNamespace + "CategoricScale");
      while(stmtI1.hasNext()) {
        Statement typeStatement = stmtI1.nextStatement();
        if(typeStatement.getObject().asResource().getURI().equals(
            numericScale.getURI())) {
          Scale scale = getNumericScale(model, resource);
          return scale;
        } else if (typeStatement.getObject().asResource().getURI().equals(
            categoricScale.getURI())) {
          Scale scale = getCategoricScale(model, resource);
          return scale;
        }       
      }
      if(type == null) {
        if(!ModelException.throwException(ModelException.SCALE,
            "Impossible to instanciate a generic Scale(resource:"+resource+"" +
            "Please, see the model and assign a specific type.")) {
          return null;
        }
      }
    }   
    Scale scale = (Scale) getResourceFromCache(resource, type);
    if(scale != null) {     
      return scale;
    }   
    scale = type.newInstance();
    scale.setResource(resource);
    addResourceInstanceToCache(resource, scale);   
    // name //
    Property name = ResourceFactory.createProperty(riNamespace + "name");
    StmtIterator stmtI1 = model.listStatements(resource,
        name, (RDFNode)null);
    while(stmtI1.hasNext()) {
      Statement statement = stmtI1.nextStatement();
      // validate name property //
      if(!statement.getObject().isLiteral()) {         
        if(!ModelException.throwException(ModelException.SCALE,
            "name property of scale resource:"+
            resource.getURI()+" is not a literal")) {
          return null;
        }
      } else {
        scale.setName(statement.getObject().asLiteral().getString());
      }
    }
    return scale;
  }
View Full Code Here

    // type //
    Property type = ResourceFactory.createProperty(riNamespace + "type");
    StmtIterator stmtI1 = model.listStatements(resource,
        type, (RDFNode)null);
    while(stmtI1.hasNext()) {
      Statement statement = stmtI1.nextStatement();
      // validate type property //
      if(!statement.getObject().isLiteral()) {         
        if(!ModelException.throwException(ModelException.ENTITYTYPE,
            "type property of EntityType resource:"+
            resource.getURI()+" is not a literal")) {
          return null;
        }
      } else {
        entityType.setType(statement.getObject().asLiteral().getString());
      }
    }
    return entityType;
  }
View Full Code Here

    repAlg.setResource(resource);
    addResourceInstanceToCache(resource, repAlg);
    if(types == null) {     
      StmtIterator stmtI1 = model.listStatements(resource, RDF.type, (RDFNode)null);           
      while(stmtI1.hasNext()) {
        Statement typeStatement = stmtI1.nextStatement();
        for(Resource resourceType : reputationAlgorithmSubclasses.keySet()) {
          if(typeStatement.getObject().asResource().getURI().equals(
              resourceType.getURI())) {
            addBehaviourToReputationAlgorithm(model, resource,
                reputationAlgorithmSubclasses.get(resourceType),repAlg);
          }
        }               
View Full Code Here

        createProperty(riNamespace + "objectClass");
    // objectClass //
    StmtIterator stmtI1 = model.listStatements(resource,
        property, (RDFNode)null);
    while(stmtI1.hasNext()) {
      Statement statement = stmtI1.nextStatement();
      /* validate objectClass property */
      if(!statement.getObject().isLiteral()) {         
        if(ModelException.throwException(ModelException.REPUTATIONALGORITHM,
            "objectClass property of ReputationAlgorithm resource:"+
            resource.getURI()+" is not a literal")) {
          repAlg = null;
          return;
        }
      } else {
        repAlg.setObjectClass(statement.getObject().asLiteral().getString());         
      }
    }
    property = ResourceFactory.
        createProperty(riNamespace + "algorithmPath");
    // algorithmPath //
    stmtI1 = model.listStatements(resource,
        property, (RDFNode)null);
    while(stmtI1.hasNext()) {
      Statement statement = stmtI1.nextStatement();
      /* validate algorithmPath property */
      if(!statement.getObject().isLiteral()) {         
        if(ModelException.throwException(ModelException.REPUTATIONALGORITHM,
            "algorithmPath property of ReputationAlgorithm resource:"+
            resource.getURI()+" is not a literal")) {
          repAlg = null;
          return;
        }
      } else {
        repAlg.setAlgorithmPath(statement.getObject().asLiteral().getString());         
      }
    }
  }
View Full Code Here

    //
    resourceSet
        .getResourceFactoryRegistry()
        .getExtensionToFactoryMap()
        .put(Resource.Factory.Registry.DEFAULT_EXTENSION,
            new _40ResourceFactoryImpl());

    // Register the package to ensure it is available during loading.
    //
    resourceSet.getPackageRegistry().put(_40Package.eNS_URI,
        _40Package.eINSTANCE);
View Full Code Here

    // Register the appropriate resource factory to handle all file
    // extensions.
    //
    resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap()
        .put(Resource.Factory.Registry.DEFAULT_EXTENSION,
            new _40ResourceFactoryImpl());
   
   
    // Register the package to ensure it is available during loading.
    //
    resourceSet.getPackageRegistry().put(_40Package.eNS_URI,
View Full Code Here

    // Register the appropriate resource factory to handle all file
    // extensions.
    //
    resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap()
        .put(Resource.Factory.Registry.DEFAULT_EXTENSION,
            new _40ResourceFactoryImpl());
   
   
    // Register the package to ensure it is available during loading.
    //
    resourceSet.getPackageRegistry().put(_40Package.eNS_URI,
View Full Code Here

TOP

Related Classes of com.hp.hpl.jena.rdf.model.Statement$Util

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.