Examples of MetricTransformer


Examples of cross.reputation.model.MetricTransformer

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

Examples of cross.reputation.model.MetricTransformer

        riNamespace + "MetricTransformer");
    ResIterator iters = model.listSubjectsWithProperty(
        RDF.type,metricTransformer);
    while (iters.hasNext()) {
      Resource resource = iters.nextResource();
      MetricTransformer tranformerIns = getMetricTransformer(model,resource,null);
      if(!validate || ValidateModel.validateMetricTransformer(tranformerIns)) {
        transformers.add(tranformerIns);
      } else {
        ModelException.sendMessage(ModelException.WARNING,"entity(" +
            "resource:"+tranformerIns.getResource()+") dicarted");
      }     
    }
    return transformers;
  }
View Full Code Here

Examples of cross.reputation.model.MetricTransformer

 
  @SuppressWarnings("unchecked")
  public MetricTransformer getMetricTransformer(
      Model model, Resource resource,
      Class<? extends MetricTransformer> type) throws Exception {
    MetricTransformer metTra = (MetricTransformer)
      getResourceFromCache(resource, MetricTransformer.class);
    if(metTra != null) {     
      return metTra;
    }
    if(type == null) {
      StmtIterator stmtI1 = model.listStatements(resource, RDF.type, (RDFNode)null);
      Map<Resource,Method> childrenType = new HashMap<Resource,Method>();
      List<Class<? extends MetricTransformer>> subclasses =
        NumericTransformer.listSubclasses();
      while(!subclasses.isEmpty()) {
        Class<?> subclass = subclasses.get(0);
        try {
          Method method = subclass.getMethod("listSubclasses");
          List<Class<? extends MetricTransformer>> subsubclasses =
            (List<Class<? extends MetricTransformer>>) method.invoke(null);
          subclasses.addAll(subsubclasses);
        } catch (Exception e) {         
        }
        childrenType.put(ResourceFactory.createResource(
            riNamespace + subclass.getSimpleName()),
            this.getClass().getMethod("get"+subclass.getSimpleName(),
                Model.class, Resource.class));
        subclasses.remove(0);
      }
      while(stmtI1.hasNext()) {
        Statement typeStatement = stmtI1.nextStatement();
        for(Resource resourceType : childrenType.keySet()) {
          if(typeStatement.getObject().asResource().getURI().equals(
              resourceType.getURI())) {
            return (MetricTransformer) childrenType.get(
                resourceType).invoke(this, model, resource);
          }
        }               
      }
      if(type == null) {
        if(!ModelException.throwException(ModelException.METRICTRANSFORMER,
            "Resource "+resource+" cannot be defined" +
            " as a direct instance of MetricTransformer. You must not use" +
            " abstract subclasses")) {
          return null;
        }   
      }
    } else {
     
    }
    MetricTransformerInstances instances =
      getMetricTransformer(model,resource);
    try {
      Constructor<?> constructor = type.getConstructor(Metric.class,
        Metric.class, List.class);
      metTra = (MetricTransformer) constructor.newInstance(
          instances.sourceMetric,
          instances.destinationMetric,
          instances.correlationBetweenMetrics);
      metTra.setResource(resource);
      addResourceInstanceToCache(resource, metTra);
      metTra.setDescription(instances.description);
      metTra.setIdentifier(instances.identifier);
    } catch(Exception e) {
      throw new Exception("System Bug: Not constructor with args: (Metric, " +
          "Metric, List) exist for type:"+type);
    }
    return metTra;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.