Package cross.reputation.model

Examples of cross.reputation.model.ImportationUnit


            "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());         
        }
View Full Code Here


            "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());         
        }
View Full Code Here

    }
  }
 
  public ImportationUnit getImportationUnit(Model model,
      Resource resource) throws Exception {
    ImportationUnit impUni = (ImportationUnit) getResourceFromCache(
        resource, ImportationUnit.class);
    if(impUni != null) {     
      return impUni;
    }
    impUni = new ImportationUnit();
    impUni.setResource(resource);
    addResourceInstanceToCache(resource, impUni);
    Property importedCommunity = ResourceFactory.createProperty(
        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

        System.out.println("The database contains subjects" +
            " of type ImportationUnit:");
        while (iters.hasNext()) {
            Resource resource = iters.nextResource();
            System.out.println("  " + resource.getLocalName());
            ImportationUnit impUniInstance =
              getImportationUnit(model,resource);           
            System.out.println(impUniInstance.toString("     "));
        }
    } else {
        System.out.println("No simple String riNamespace+" +
            "ImportationUnit were found in the database");
    }
View Full Code Here

TOP

Related Classes of cross.reputation.model.ImportationUnit

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.