Examples of CollectingSystemBehaviour


Examples of cross.reputation.model.CollectingSystemBehaviour

      getResourceFromCache(resource, ReputationAlgorithmImplementation.class);
    if(colSys != null) {     
      return colSys;
    }
    colSys = getCollectingAlgorithm(model, resource, CollectingSystemBehaviour.class);
    CollectingSystemBehaviour colSysBeh = null;
    for(ReputationBehaviour behaviour : colSys.getBehaviours()) {
      if(behaviour instanceof CollectingAlgorithmBehaviour) {
        for(ReputationBehaviour subBehaviour : behaviour.getBehaviours()) {
          if(subBehaviour instanceof CollectingSystemBehaviour) {
            colSysBeh = (CollectingSystemBehaviour) subBehaviour;
          }
        }
      }
    }

    // Specific Attributes and Properties of CollectingSystem Class //
   
    // uriFormat //
    Property uriFormat = ResourceFactory.createProperty(
        riNamespace + "uriFormat");   
    StmtIterator stmtI1 = model.listStatements(resource,
        uriFormat, (RDFNode)null);
    while(stmtI1.hasNext()) {
      Statement statement = stmtI1.nextStatement();
      /* validate uriFormat property */
      if(!statement.getObject().isLiteral()) {         
        if(!ModelException.throwException(ModelException.COLLECTINGSYSTEM,
            "uriFormat property of CollectingSystem resource:"+
            resource.getURI()+" is not a literal")) {
          return null;
        }
      } else {
        colSysBeh.setUriFormat(new URI(
            statement.getObject().asLiteral().getString()));
      }
    }   
    return colSys;
  }
View Full Code Here

Examples of cross.reputation.model.CollectingSystemBehaviour

    return colSys;
  }
 
  public ReputationBehaviour getCollectingSystemBehaviour(Model model,
      Resource resource, Class<? extends ReputationBehaviour> type) throws Exception {
    CollectingSystemBehaviour behaviour = (CollectingSystemBehaviour)
      getResourceFromCache(resource, CollectingSystemBehaviour.class);
    if(behaviour != null) {     
      return behaviour;
    }
    behaviour = new CollectingSystemBehaviour();
    addResourceInstanceToCache(resource, behaviour);
   
    // Specific Attributes and Properties of CollectingAlgorithm Class //
    // uriFormat //
    Property uriFormat = ResourceFactory.createProperty(
        riNamespace + "uriFormat");
    StmtIterator stmtI1 = model.listStatements(resource,
        uriFormat, (RDFNode)null);
    while(stmtI1.hasNext()) {
      Statement statement = stmtI1.nextStatement();
      /* validate uriFormat property */
      if(!statement.getObject().isLiteral()) {         
        if(!ModelException.throwException(ModelException.COLLECTINGSYSTEM,
            "uriFormat property of CollectingSystem resource:"+
            resource.getURI()+" is not a literal")) {
          return null;
        }
      } else {
        behaviour.setUriFormat(new URI(
            statement.getObject().asLiteral().getString()));
      }
    }
    return behaviour;
  }
View Full Code Here

Examples of cross.reputation.model.CollectingSystemBehaviour

      for(int i = 0; i < sortedObjectList.size(); i++) {
        extractReputationFromEntity(repImp, sortedObjectList.get(i),importationUnit,
          entity, algorithmsImpl, reputations);       
      }
    } else if(systems.getObject() instanceof CollectingSystemBehaviour) {
      CollectingSystemBehaviour system = (CollectingSystemBehaviour)systems.getObject();
      //It was checked before
      /*for(Community community : entity.getIdentificatorInCommunities().keySet()) {
        if(community != importationUnit.getImportedCommunity()) {
          continue;
        }
      }*/
      try {
        Map<Metric,List<Object>> reputation = null;
        if(system.getRoot().getObjectClass() != null) {
          String className = system.getRoot().getObjectClass();
          Class classImpl = Class.forName(className);
          //Erase previous objects that are instances of the class of this new object
          for(int i = 0; i < algorithmsImpl.size(); i++) {
            Object algorithmObj = algorithmsImpl.get(i);
            if(!classImpl.isInstance(algorithmObj)) {
              continue;
            }
            ModelException.sendMessage(ModelException.WARNING,
              "Previous object(class:"+algorithmObj.getClass()+" was instance" +
              " of the class of a new object(class"+classImpl+")");
            algorithmsImpl.remove(i);
            i--;                       
          }
          algorithmsImpl.add(classImpl.newInstance());
        }       
        if(system.getRoot().getAlgorithmPath() != null) {
          reputation = executeAlgorithm(algorithmsImpl,repImp, importationUnit,system,
              entity, system.getRoot().getAlgorithmPath());
        } else {
          reputation = ExtractReputationByDefaultMethods(
              repImp, importationUnit, system, entity);         
        }
        //Add new imported Reputation to stored imported Reputation
        if(reputation != null && reputation.size() > 0) {
          if(reputations.containsKey(system.getRoot())) {
            ModelException.sendMessage(ModelException.ERROR,
              "CollectingSystem(resource:"+system.getRoot().getResource()+
              ") already exists in previous imported reputation from the same"
              +"ImportationUnit(res:"+importationUnit.getResource()+"in the"
              +"same ReputationImporter(res:"+repImp.getRoot().getResource()+")");
            for(Metric metric : reputation.keySet()) {
              if(reputations.get(system.getRoot()).containsKey(metric)) {
                reputations.get(system.getRoot()).get(metric).addAll(
                    reputation.get(metric));
              } else {
                reputations.get(system.getRoot()).put(metric,reputation.get(metric));
              }
            }
          } else {
            reputations.put(system.getRoot(), reputation);
          }         
        }       
      } catch(MalformedURLException e) {
        ModelException.throwException(ModelException.EXTRACT_REPUTATION_URL,
            e.getMessage()+"("+e.getClass()+")");
View Full Code Here

Examples of cross.reputation.model.CollectingSystemBehaviour

          behaviour.getBehaviours()) {
        if(!CollectingSystemBehaviour.class.isInstance(
            behaviourInside)) {
          continue;
        }
        CollectingSystemBehaviour collectingSystem =
            (CollectingSystemBehaviour)behaviourInside;
        if(!filterColletingSystem(collectingSystem, repAlg)) {
          continue;
        }
        //Because there are not collectingSystems inside, we put directly the collectingSystem
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.