Package cross.reputation.model

Examples of cross.reputation.model.ReputationValue


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


            "hasValue property of ReputationObject resource:"+
            resource.getURI()+" is not a resource")) {
          return null;
        }
      } else {
        ReputationValue repVal = (ReputationValue) getResourceFromCache(
            statement.getObject().asResource(), ReputationValue.class);
        if(repVal == null) {
          repVal = getReputationValue(model,
              statement.getObject().asResource());         
        }
View Full Code Here

    }
    return repEva;
 
 
  public ReputationValue getReputationValue(Model model, Resource resource) throws Exception {
    ReputationValue repVal = (ReputationValue) getResourceFromCache(
        resource, ReputationValue.class);
    if(repVal == null) {
      repVal = new ReputationValue();
      repVal.setResource(resource);
      addResourceInstanceToCache(resource,repVal);
    } else {
      return repVal;
    }
    // Specific Attributes and Properties of ReputationValue 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.REPUTATIONVALUE,
            "collectionIdentifier property of resource:"+
            resource.getURI()+" is not a literal")) {
          return null;
        }
      } else {
        repVal.setCollectionIdentifier(statement.getObject(
            ).asLiteral().getString());
      }
    }
    // timeStamp //
    Property homePage = ResourceFactory.createProperty(
        riNamespace + "timeStamp");
    stmtI1 = model.listStatements(resource,
        homePage, (RDFNode)null);
    while(stmtI1.hasNext()) {
      Statement statement = stmtI1.nextStatement();
      // validate timeStamp property //
      if(!statement.getObject().isLiteral()) {         
        if(!ModelException.throwException(ModelException.REPUTATIONVALUE,
            "timeStamp property of resource:"+
            resource.getURI()+" is not a literal")) {
          return null;
        }
      } else {
        DateFormat dt = DateFormat.getDateTimeInstance();
        repVal.setTimeStamp(dt.parse(statement.getObject(
            ).asLiteral().getString()));
      }
    }
    // expirationTime //
    Property expirationTime = ResourceFactory.createProperty(
        riNamespace + "expirationTime");
    stmtI1 = model.listStatements(resource,
        expirationTime, (RDFNode)null);
    while(stmtI1.hasNext()) {
      Statement statement = stmtI1.nextStatement();
      // validate expirationTime property //
      if(!statement.getObject().isLiteral()) {         
        if(!ModelException.throwException(ModelException.REPUTATIONVALUE,
            "expirationTime property of resource:"+
            resource.getURI()+" is not a literal")) {
          return null;
        }
      } else {
        DateFormat dt = DateFormat.getDateTimeInstance();
        repVal.setExpirationTime(dt.parse(statement.getObject(
            ).asLiteral().getString()));
      }
    }
    // obtainedBy //
    Property obtainedBy = ResourceFactory.createProperty(
        riNamespace + "obtainedBy");   
    stmtI1 = model.listStatements(resource,
        obtainedBy, (RDFNode)null);
    while(stmtI1.hasNext()) {
      Statement statement = stmtI1.nextStatement();
      // validate obtainedBy property //
      if(!statement.getObject().isResource()) {         
        if(!ModelException.throwException(ModelException.REPUTATIONVALUE,
            "obtainedBy property of 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);         
        }
        repVal.setObtainedBy(repAlg);
      }
    }
    // owner //
    Property owner = ResourceFactory.createProperty(
        riNamespace + "owner");   
    stmtI1 = model.listStatements(resource,
        owner, (RDFNode)null);
    while(stmtI1.hasNext()) {
      Statement statement = stmtI1.nextStatement();
      // validate owner property //
      if(!statement.getObject().isResource()) {         
        if(!ModelException.throwException(ModelException.REPUTATIONVALUE,
            "owner property of 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);         
        }
        repVal.setOwner(entity);
      }
    }
    // hasEvaluation //
    Property hasEvaluation = ResourceFactory.createProperty(
        riNamespace + "hasEvaluation");   
    stmtI1 = model.listStatements(resource,
        hasEvaluation, (RDFNode)null);
    while(stmtI1.hasNext()) {
      Statement statement = stmtI1.nextStatement();
      // validate hasEvaluation property //
      if(!statement.getObject().isResource()) {         
        if(!ModelException.throwException(ModelException.REPUTATIONVALUE,
            "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());         
        }
        repVal.addHasEvaluations(repEva);
      }
    }
    return repVal;
  }
View Full Code Here

            resource.getURI()+" is not a resource")) {
          repAlg = null;
          return;
        }
      } else {
        ReputationValue reputationValue = (ReputationValue) getResourceFromCache(
            statement.getObject().asResource(),ReputationValue.class);
        if(reputationValue == null) {
          reputationValue = getReputationValue(model,
              statement.getObject().asResource());       
        }
        repAlg.addReputationSources(reputationValue);         
      }
    }
    Property reputationResult = ResourceFactory.
        createProperty(riNamespace + "reputationResult");
    /* reputationResult */
    stmtI1 = model.listStatements(resource,
        reputationResult, (RDFNode)null);
    while(stmtI1.hasNext()) {
      Statement statement = stmtI1.nextStatement();
      /* validate reputationResult property */
      if(!statement.getObject().isResource()) {         
        if(!ModelException.throwException(ModelException.REPUTATIONALGORITHM,
            "reputationResult property of ReputationAlgorithm resource:"+
            resource.getURI()+" is not a resource")) {
          repAlg = null;
          return;
        }
      } else {
        ReputationValue reputationValue = (ReputationValue) getResourceFromCache(
            statement.getObject().asResource(),ReputationValue.class);
        if(reputationValue == null) {
          reputationValue = getReputationValue(model,
              statement.getObject().asResource());       
        }
View Full Code Here

          "usesMetric property");
      return null;
    }
    List<ReputationValue> repVals = new ArrayList<ReputationValue>();
    for(Metric metric : repAlg.getUsesMetrics()) {
      ReputationValue repVal = new ReputationValue();
      repVal.setOwner(entity);
      repVal.setObtainedBy(repAlg);
      repVal.setTimeStamp(timestamp);
      String collectionId = repAlg.getResource()+timestamp.toString();
      repVal.setCollectionIdentifier(collectionId);
      List<Object> values = new ArrayList<Object>();
      for(ImportationUnit impUnit : reputationOfEntities.keySet()) {
        //Metric importedMetric = impUnit.getImportedMetric();
        for(ReputationAlgorithmImplementation importationRepAlg :
            reputationOfEntities.get(impUnit).keySet()) {
View Full Code Here

                +"(resource:"+repAlg.getResource()+") in importation procedement" +
                " of the comunity(resource:"+community.getResource()+")");
          } catch (Exception e) {}
          continue;
        }
        ReputationValue repVal = new ReputationValue();
        repVal.setOwner(entity);
        repVal.setObtainedBy(repAlg);
        repVal.setTimeStamp(timestamp);
        String collectionId = repAlg.getResource()+timestamp.toString();
        repVal.setCollectionIdentifier(collectionId);
        for(Metric exportedMetric : reputationOfEntities.get(
            impUnit).get(repAlg).keySet()) {
          List<Object> values = reputationOfEntities.get(
              impUnit).get(repAlg).get(exportedMetric);
          addValuesToRepEvalInsideRepVal(repAlg,repVal,exportedMetric,entity,
              collectionId,values);                 
        }
        if(repVal.getHasEvaluations() == null || repVal.getHasEvaluations().isEmpty()) {
          continue;
        }
        reputationValues.add(repVal);       
      }
    }
View Full Code Here

TOP

Related Classes of cross.reputation.model.ReputationValue

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.