Package cross.reputation.model

Examples of cross.reputation.model.MetricMapping


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


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

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

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

TOP

Related Classes of cross.reputation.model.MetricMapping

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.