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

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


    }
   
    private void createRelationsFromProperties(Iterator iterator, HashMap relationsMap) {
        Relation relation;
        for(;iterator.hasNext();){
          Statement statement = (Statement) iterator.next();
          if(statement.getObject().canAs(Individual.class)){
            if(relationsMap.containsKey(statement.getPredicate().getURI())){
              relation = (Relation) relationsMap.get(statement.getPredicate().getURI());
            }else{
              relation = factory.createRelation();                
              relation = createRelationFromInstance(statement.getPredicate().getURI(),
                  TypeHierarchy.SUBCLASS,
                  statement.getPredicate().getLocalName(),
                  statement.getPredicate().getLocalName());
            }

            addRelation(relation,
                OntologyHelper.createConceptDescription((Individual) statement.getObject().as(Individual.class)),relationsMap);
          }else{
            logger.debug("Discarding instance concept "+statement.getObject()+" conversion to Individual is not possible because is "+statement.getObject().getClass());
          }
        }      
       
    }
View Full Code Here


  }


  public Object visitBlank(Resource r, AnonId id) {
        for(StmtIterator iterator = r.listProperties(); iterator.hasNext();){
            Statement stmt = iterator.nextStatement();
            stmt.getObject().visitWith(this);
        }       
        return null;
     }
View Full Code Here

        return null;
     }

     public Object visitURI(Resource r, String uri) {
        for(StmtIterator iterator = r.listProperties(); iterator.hasNext();){
            Statement stmt = iterator.nextStatement();
            this.applyStatement(stmt,this.conceptTO);
//            Resource  subject   = stmt.getSubject();   
//            Property  predicate = stmt.getPredicate();
//            RDFNode   object    = stmt.getObject();    
//            subject.visitWith(this);
View Full Code Here

    /**
     * @param resource
     * @return
     */
    public static String getPublicName(Resource resource) {
        Statement labelProp = resource.getProperty(RDFS.label);
        if (labelProp != null && labelProp.getString().length() > 0) {
            return labelProp.getString();
        } else {
            return (resource.getURI()!=null?prefixesFor(resource).shortForm(resource.getURI()):"Not available");
        }
    }
View Full Code Here

    /**
     * @param resource
     * @return
     */
    public static String getDescription(Resource resource) {
        Statement commentProp = resource.getProperty(RDFS.comment);
        if (commentProp != null) {
            return commentProp.getString();
        } else {
            return (resource.getURI()!=null?prefixesFor(resource).shortForm(resource.getURI()):"Not available");
        }
    }
View Full Code Here

    Property identifier = ResourceFactory.createProperty(
        riNamespace + "identifier");
    StmtIterator stmtI1 = model.listStatements(resource,
        identifier, (RDFNode)null);
    while(stmtI1.hasNext()) {
      Statement statement = stmtI1.nextStatement();
      // validate identifier property //
      if(!statement.getObject().isLiteral()) {         
        if(!ModelException.throwException(ModelException.COMMUNITY,
            "identifier property of resource:"+
            resource.getURI()+" is not a literal")) {
          return null;
        }
      } else {
        community.setName(statement.getObject().asLiteral().getString());
      }
    }
    // homePage //
    Property homePage = ResourceFactory.createProperty(
        riNamespace + "homePage");
    stmtI1 = model.listStatements(resource,
        homePage, (RDFNode)null);
    while(stmtI1.hasNext()) {
      Statement statement = stmtI1.nextStatement();
      // validate homePage property //
      if(!statement.getObject().isLiteral()) {         
        if(!ModelException.throwException(ModelException.COMMUNITY,
            "homePage property of resource:"+
            resource.getURI()+" is not a literal")) {
          return null;
        }
      } else {
        community.setDomainName(statement.getObject().asLiteral().getString());
      }
    }
    // hasCategory //
    Property mapsMetric = ResourceFactory.createProperty(
        riNamespace + "hasCategory");   
    stmtI1 = model.listStatements(resource,
        mapsMetric, (RDFNode)null);
    while(stmtI1.hasNext()) {
      Statement statement = stmtI1.nextStatement();
      // validate hasCategory property //
      if(!statement.getObject().isResource()) {         
        if(!ModelException.throwException(ModelException.COMMUNITY,
            "hasCategory property of resource:"+
            resource.getURI()+" is not a resource")) {
          return null;
        }
      } else {
        Category category = (Category) getResourceFromCache(
            statement.getObject().asResource(), Category.class);
        if(category == null) {
          category = getCategory(model,
              statement.getObject().asResource());         
        }
        community.addCategory(category);
      }
    }
    // hasReputationModel //
    Property hasReputationModel = ResourceFactory.createProperty(
        riNamespace + "hasReputationModel");   
    stmtI1 = model.listStatements(resource,
        hasReputationModel, (RDFNode)null);
    while(stmtI1.hasNext()) {
      Statement statement = stmtI1.nextStatement();
      // validate hasReputationModel property //
      if(!statement.getObject().isResource()) {         
        if(!ModelException.throwException(ModelException.COMMUNITY,
            "hasReputationModel property of Community resource:"+
            resource.getURI()+" is not a resource")) {
          return null;
        }
      } else {
        ReputationAlgorithmImplementation repAlg = (ReputationAlgorithmImplementation)
          getResourceFromCache(statement.getObject().asResource(),
          ReputationAlgorithmImplementation.class);
        if(repAlg == null) {
          repAlg = getReputationAlgorithm(model,
              statement.getObject().asResource(),null);         
        }
        community.setReputationModel(repAlg);
      }
    }
    // hasEntity //
    Property hasEntity = ResourceFactory.createProperty(
        riNamespace + "hasEntity");   
    stmtI1 = model.listStatements(resource,
        hasEntity, (RDFNode)null);
    while(stmtI1.hasNext()) {
      Statement statement = stmtI1.nextStatement();
      // validate hasEntity property //
      if(!statement.getObject().isResource()) {         
        if(!ModelException.throwException(ModelException.COMMUNITY,
            "hasEntity property of Community resource:"+
            resource.getURI()+" is not a resource")) {
          return null;
        }
      } else {
        Entity entity = (Entity) getResourceFromCache(
            statement.getObject().asResource(), Entity.class);
        if(entity == null) {
          entity = getEntity(model,
              statement.getObject().asResource(),null);         
        }
        community.addEntity(entity);
      }
    }
    return community;
View Full Code Here

        riNamespace + "mapsMetric");
    /* mapsMetric */
    StmtIterator stmtI1 = model.listStatements(resource,
        mapsMetric, (RDFNode)null);
    while(stmtI1.hasNext()) {
      Statement statement = stmtI1.nextStatement();
      /* validate mapsMetric property */
      if(!statement.getObject().isResource()) {         
        if(!ModelException.throwException(ModelException.REPUTATIONIMPORTER,
            "mapsMetric property of ReputationAlgorithm resource:"+
            resource.getURI()+" is not a resource")) {
          return null;
        }
      } else {
        MetricMapping metMap = (MetricMapping) getResourceFromCache(
            statement.getObject().asResource(), MetricMapping.class);
        if(metMap == null) {
          metMap = getMetricMapping(model,
              statement.getObject().asResource());         
        }
        repImpBeh.addMapsMetrics(metMap);
      }
    }
    Property importsFrom = ResourceFactory.createProperty(
        riNamespace + "importsFrom");
    /* importsFrom */
    stmtI1 = model.listStatements(resource,
        importsFrom, (RDFNode)null);
    while(stmtI1.hasNext()) {
      Statement statement = stmtI1.nextStatement();
      /* validate importsFrom property */
      if(!statement.getObject().isResource()) {         
        if(!ModelException.throwException(ModelException.REPUTATIONALGORITHM,
            "importsFrom property of ReputationAlgorithm resource:"+
            resource.getURI()+" is not a resource")) {
          return null;
        }
      } else {
        ImportationUnit impUni = (ImportationUnit) getResourceFromCache(
            statement.getObject().asResource(), ImportationUnit.class);
        if(impUni == null) {
          impUni = getImportationUnit(model,
              statement.getObject().asResource());         
        }
        repImpBeh.addImportsFrom(impUni);
      }
    } 
    return repImp;
View Full Code Here

        riNamespace + "mapsMetric");
    /* mapsMetric */
    StmtIterator stmtI1 = model.listStatements(resource,
        mapsMetric, (RDFNode)null);
    while(stmtI1.hasNext()) {
      Statement statement = stmtI1.nextStatement();
      /* validate mapsMetric property */
      if(!statement.getObject().isResource()) {         
        if(!ModelException.throwException(ModelException.REPUTATIONIMPORTER,
            "mapsMetric property of ReputationImporter resource:"+
            resource.getURI()+" is not a resource")) {
          return null;
        }
      } else {
        MetricMapping metMap = (MetricMapping) getResourceFromCache(
            statement.getObject().asResource(),MetricMapping.class);
        if(metMap == null) {
          metMap = getMetricMapping(model,
              statement.getObject().asResource());         
        }
        behaviour.addMapsMetrics(metMap);       
      }
    }
    Property importsFrom = ResourceFactory.createProperty(
        riNamespace + "importsFrom");
    /* importsFrom */
    stmtI1 = model.listStatements(resource,
        importsFrom, (RDFNode)null);
    while(stmtI1.hasNext()) {
      Statement statement = stmtI1.nextStatement();
      /* validate importsFrom property */
      if(!statement.getObject().isResource()) {         
        if(!ModelException.throwException(ModelException.REPUTATIONIMPORTER,
            "importsFrom property of ReputationImporter resource:"+
            resource.getURI()+" is not a resource")) {
          return null;
        }
      } else {
        ImportationUnit impUni = (ImportationUnit) getResourceFromCache(
            statement.getObject().asResource(),ImportationUnit.class);
        if(impUni == null) {
          impUni = getImportationUnit(model,
              statement.getObject().asResource());         
        }
        behaviour.addImportsFrom(impUni);
      }
    }
    return behaviour;
View Full Code Here

        riNamespace + "importedCommunity");
    /* importedCommunity */
    StmtIterator stmtI1 = model.listStatements(resource,
        importedCommunity, (RDFNode)null);
    while(stmtI1.hasNext()) {
      Statement statement = stmtI1.nextStatement();
      /* validate importedCommunity property */
      if(!statement.getObject().isResource()) {         
        if(!ModelException.throwException(ModelException.IMPORTATIONUNIT,
            "importedCommunity property of ImportationUnit resource:"+
            resource.getURI()+" is not a resource")) {
          return null;
        }
      } else {
        Community community = (Community) getResourceFromCache(
            statement.getObject().asResource(), Community.class);
        if(community == null) {
          community = getCommunity(model,
              statement.getObject().asResource());         
        }
        impUni.setImportedCommunity(community);
      }
    }
    Property importedMetric = ResourceFactory.createProperty(
        riNamespace + "importedMetric");
    /* importedMetric */
    stmtI1 = model.listStatements(resource,
        importedMetric, (RDFNode)null);
    while(stmtI1.hasNext()) {
      Statement statement = stmtI1.nextStatement();
      /* validate importedMetric property */
      if(!statement.getObject().isResource()) {         
        if(!ModelException.throwException(ModelException.IMPORTATIONUNIT,
            "importedMetric property of MetricMapping resource:"+
            resource.getURI()+" is not a resource")) {
          return null;
        }
      } else {
        Metric metric = (Metric) getResourceFromCache(
            statement.getObject().asResource(),Metric.class);
        if(metric == null) {
          metric = getMetric(model,
              statement.getObject().asResource());         
        }
        impUni.setImportedMetric(metric);
      }
    }
    Property collectsReputationBy = ResourceFactory.createProperty(
        riNamespace + "collectsReputationBy");
    /* collectsReputationBy */
    stmtI1 = model.listStatements(resource,
        collectsReputationBy, (RDFNode)null);
    while(stmtI1.hasNext()) {
      Statement statement = stmtI1.nextStatement();
      /* validate collectsReputationBy property */
      if(!statement.getObject().isResource()) {         
        if(!ModelException.throwException(ModelException.IMPORTATIONUNIT,
            "collectsReputationBy property of ImportationUnit resource:"+
            resource.getURI()+" is not a resource")) {
          return null;
        }
      } else {
        ReputationAlgorithmImplementation colAlg = (
            ReputationAlgorithmImplementation) getResourceFromCache(
            statement.getObject().asResource(),ReputationAlgorithmImplementation.class);
        if(colAlg == null) {
          colAlg = getReputationAlgorithm(model,
              statement.getObject().asResource(),null);         
        }
        impUni.setCollectsReputationBy(colAlg);
      }
    }
    Property metricTransformation = ResourceFactory.createProperty(
        riNamespace + "metricTransformation");
    /* metricTransformation */
    stmtI1 = model.listStatements(resource,
        metricTransformation, (RDFNode)null);
    while(stmtI1.hasNext()) {
      Statement statement = stmtI1.nextStatement();
      /* validate metricTransformation property */
      if(!statement.getObject().isResource()) {         
        if(!ModelException.throwException(ModelException.IMPORTATIONUNIT,
            "metricTransformation property of ImportationUnit resource:"+
            resource.getURI()+" is not a resource")) {
          return null;
        }
      } else {
        MetricTransformer metTra = (MetricTransformer)
          getResourceFromCache(statement.getObject().asResource(),
              MetricTransformer.class);
        if(metTra == null) {
          metTra = getMetricTransformer(model,
              statement.getObject().asResource(),null);         
        }
        impUni.setMetricTransformation(metTra);
      }
    }
    Property trust = ResourceFactory.createProperty(
        riNamespace + "trust");
    /* trust */
    stmtI1 = model.listStatements(resource,
        trust, (RDFNode)null);
    while(stmtI1.hasNext()) {
      Statement statement = stmtI1.nextStatement();
      /* validate trust property */
      if(!statement.getObject().isResource()) {         
        if(!ModelException.throwException(ModelException.IMPORTATIONUNIT,
            "trust property of importationUnit ImportationUnit resource:"+
            resource.getURI()+" is not a resource")) {
          return null;
        }
      } else {
        TrustBetweenCommunities truBet = (TrustBetweenCommunities)
          getResourceFromCache(statement.getObject().asResource(),
              TrustBetweenCommunities.class);
        if(truBet == null) {
          truBet = getTrustBetweenCommunities(model,
              statement.getObject().asResource(),null);         
        }
        impUni.setTrust(truBet);
      }
    }
    return impUni;
View Full Code Here

        riNamespace + "value");
    // value //
    StmtIterator stmtI1 = model.listStatements(resource,
        value, (RDFNode)null);
    while(stmtI1.hasNext()) {
      Statement statement = stmtI1.nextStatement();
      // validate value property //
      if(!statement.getObject().isLiteral()) {         
        if(!ModelException.throwException(ModelException.METRICMAPPING,
            "value property of MetricMapping resource:"+
            resource.getURI()+" is not a literal")) {
          return null;
        }
      } else {
        metMap.setValue(statement.getObject().asLiteral().getDouble());
      }
    }   
    Property importedMetric = ResourceFactory.createProperty(
        riNamespace + "importedMetric");
    // importedMetric //
    stmtI1 = model.listStatements(resource,
        importedMetric, (RDFNode)null);
    while(stmtI1.hasNext()) {
      Statement statement = stmtI1.nextStatement();
      /* validate importedMetric property */
      if(!statement.getObject().isResource()) {         
        if(!ModelException.throwException(ModelException.METRICMAPPING,
            "importedMetric property of MetricMapping resource:"+
            resource.getURI()+" is not a resource")) {
          return null;
        }
      } else {
        Metric metric = (Metric) getResourceFromCache(
            statement.getObject().asResource(),Metric.class);
        if(metric == null) {
          metric = getMetric(model,statement.getObject().asResource());         
        }
        metMap.setImportedMetric(metric);
      }
    }
    Property resultMetric = ResourceFactory.createProperty(
        riNamespace + "resultMetric");
    // resultMetric //
    stmtI1 = model.listStatements(resource,
        resultMetric, (RDFNode)null);
    while(stmtI1.hasNext()) {
      Statement statement = stmtI1.nextStatement();
      // validate resultMetric property //
      if(!statement.getObject().isResource()) {         
        if(!ModelException.throwException(ModelException.METRICMAPPING,
            "resultMetric property of MetricMapping resource:"+
            resource.getURI()+" is not a resource")) {
          return null;
        }
      } else {
        Metric metric = (Metric) getResourceFromCache(
            statement.getObject().asResource(),Metric.class);
        if(metric == null) {
          metric = getMetric(model,statement.getObject().asResource());         
        }
        metMap.setResultMetric(metric);       
      }
    }
    return metMap;
View Full Code Here

TOP

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

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.