Package cross.reputation.model

Examples of cross.reputation.model.ReputationEvaluation


            "hasEvaluation property of Entity resource:"+
            resource.getURI()+" is not a resource")) {
          return null;
        }
      } else {
        ReputationEvaluation repEva = (ReputationEvaluation) getResourceFromCache(
            statement.getObject().asResource(), ReputationEvaluation.class);
        if(repEva == null) {
          repEva = getReputationEvaluation(model,
              statement.getObject().asResource());         
        }
View Full Code Here


    return repObj;
  }
 
  public ReputationEvaluation getReputationEvaluation(Model model,
      Resource resource) throws Exception {
    ReputationEvaluation repEva = (ReputationEvaluation) getResourceFromCache(
        resource, ReputationEvaluation.class);
    if(repEva == null) {
      repEva = new ReputationEvaluation();
      repEva.setResource(resource);
      addResourceInstanceToCache(resource,repEva);
    } else {
      return repEva;
    }
    // Specific Attributes and Properties of ReputationEvaluation Class //
    // collectionIdentifier //
    Property identifier = ResourceFactory.createProperty(
        riNamespace + "collectionIdentifier");
    StmtIterator stmtI1 = model.listStatements(resource,
        identifier, (RDFNode)null);
    while(stmtI1.hasNext()) {
      Statement statement = stmtI1.nextStatement();
      // validate collectionIdentifier property //
      if(!statement.getObject().isLiteral()) {         
        if(!ModelException.throwException(ModelException.REPUTATIONEVALUATION,
            "collectionIdentifier property of ReputationEvaluation resource:"+
            resource.getURI()+" is not a literal")) {
          return null;
        }
      } else {
        repEva.setCollectionIdentifier(statement.getObject(
            ).asLiteral().getString());
      }
    }
    // target //
    Property target = ResourceFactory.createProperty(
        riNamespace + "target");   
    stmtI1 = model.listStatements(resource,
        target, (RDFNode)null);
    while(stmtI1.hasNext()) {
      Statement statement = stmtI1.nextStatement();
      // validate target property //
      if(!statement.getObject().isResource()) {         
        if(!ModelException.throwException(ModelException.REPUTATIONEVALUATION,
            "target property of ReputationEvaluation resource:"+
            resource.getURI()+" is not a resource")) {
          return null;
        }
      } else {
        Entity targetImp = (Entity) getResourceFromCache(
            statement.getObject().asResource(), Entity.class);
        if(targetImp == null) {
          targetImp = getEntity(model,statement.getObject().asResource(),null);         
        }
        repEva.setTarget(targetImp);
      }
    }
    // hasMetric //
    Property hasMetric = ResourceFactory.createProperty(
        riNamespace + "hasMetric");   
    stmtI1 = model.listStatements(resource,
        hasMetric, (RDFNode)null);
    while(stmtI1.hasNext()) {
      Statement statement = stmtI1.nextStatement();
      // validate hasMetric property //
      if(!statement.getObject().isResource()) {         
        if(!ModelException.throwException(ModelException.REPUTATIONEVALUATION,
            "hasMetric property of ReputationEvaluation 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());         
        }
        repEva.setHasMetric(metric);
      }
    }
    return repEva;
 
View Full Code Here

            "hasEvaluation property of resource:"+
            resource.getURI()+" is not a resource")) {
          return null;
        }
      } else {
        ReputationEvaluation repEva = (ReputationEvaluation) getResourceFromCache(
            statement.getObject().asResource(), ReputationEvaluation.class);
        if(repEva == null) {
          repEva = getReputationEvaluation(model,
              statement.getObject().asResource());         
        }
View Full Code Here

        totalReputation = values.get(0);
      }
      if(totalReputation == null) {
        return false;
      }
      ReputationEvaluation repEval = new ReputationEvaluation();
      repEval.setHasMetric(exportedMetric);
      repEval.setTarget(entity);
      repEval.setCollectionIdentifier(collectionId);
      repEval.setValue(totalReputation);
      repVal.addHasEvaluations(repEval);
    } else {
      for(Object singleValue : values) {
        if(singleValue == null) {
          continue;
        }
        ReputationEvaluation repEval = new ReputationEvaluation();
        repEval.setHasMetric(exportedMetric);
        repEval.setTarget(entity);
        repEval.setCollectionIdentifier(collectionId);
        repEval.setValue(singleValue);
        repVal.addHasEvaluations(repEval);
      }                     
    }
    return true;
  }
View Full Code Here

TOP

Related Classes of cross.reputation.model.ReputationEvaluation

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.