Package cross.reputation.model

Examples of cross.reputation.model.Entity$GroupEntity


    }
    return onlAcc;
  }
 
  public Entity getFoafAgent(Model model, Resource resource) throws Exception {
    Entity entity = getEntity(model, resource, Entity.class);
    // Specific Attributes and Properties of Foaf:Agent Class //
    // name //
    Property name = ResourceFactory.createProperty(
        foafNamespace + "name");
    StmtIterator stmtI1 = model.listStatements(resource,
        name, (RDFNode)null);
    while(stmtI1.hasNext()) {
      Statement statement = stmtI1.nextStatement();
      // validate name property //
      if(!statement.getObject().isLiteral()) {         
        if(!ModelException.throwException(ModelException.FOAFAGENT,
            "name property of resource foaf:Agent:"+
            resource.getURI()+" is not a literal")) {
          return null;
        }
      } else {
        entity.setUniqueIdentificator(statement.getObject(
            ).asLiteral().getString());
      }
    }
    return entity;
  }
View Full Code Here


        riNamespace + "Entity");
    ResIterator iters = model.listSubjectsWithProperty(
        RDF.type,entity);
    while (iters.hasNext()) {
      Resource resource = iters.nextResource();
      Entity entityIns = getEntity(model,resource,null);
      if(!validate || ValidateModel.validateEntity(entityIns)) {
        entities.add(entityIns);
      } else {
        ModelException.sendMessage(ModelException.WARNING,"entity(" +
            "resource:"+entityIns.getResource()+") dicarted");
      }     
    }
    return entities;
  }
View Full Code Here

  }
 
  public Entity getEntity(Model model, Resource resource, Class<?> clazz)
      throws Exception {
    //Or Entity.class or clazz.class
    Entity entity = (Entity) getResourceFromCache(resource, Entity.class);
    if(entity != null) {
      return entity;
    }
    if(clazz == null) {
      StmtIterator stmtI1 = model.listStatements(resource, RDF.type, (RDFNode)null);           
      while(stmtI1.hasNext()) {
        Statement typeStatement = stmtI1.nextStatement();
        for(Resource resourceType : foafAgentClasses) {
          if(typeStatement.getObject().asResource().getURI().equals(
              resourceType.getURI())) {
            return getFoafAgent(model, resource);
          }
        }               
      }
      //The default option:Entity class
      entity = new Entity();
      entity.setResource(resource);
      addResourceInstanceToCache(resource,entity);
    } else {   
      entity = (Entity) clazz.newInstance(); //new Entity();
      entity.setResource(resource);
      addResourceInstanceToCache(resource,entity);
    }   
   
    // Specific Attributes and Properties of Entity Class //
    // identifier //
    Property identifier = ResourceFactory.createProperty(
        riNamespace + "identifier");
    StmtIterator stmtI1 = model.listStatements(resource,
        identifier, (RDFNode)null);
    while(stmtI1.hasNext()) {
      Statement statement = stmtI1.nextStatement();
      // validate identifier property //
      if(!statement.getObject().isLiteral()) {         
        if(!ModelException.throwException(ModelException.ENTITY,
            "identifier property of Entity resource:"+
            resource.getURI()+" is not a literal")) {
          return null;
        }
      } else {
        entity.setUniqueIdentificator(statement.getObject(
            ).asLiteral().getString());
      }
    }
    // hasReputation //
    Property hasReputation = ResourceFactory.createProperty(
        riNamespace + "hasMetric");   
    stmtI1 = model.listStatements(resource,
        hasReputation, (RDFNode)null);
    while(stmtI1.hasNext()) {
      Statement statement = stmtI1.nextStatement();
      // validate hasReputation property //
      if(!statement.getObject().isResource()) {         
        if(!ModelException.throwException(ModelException.ENTITY,
            "hasReputation property of Entity resource:"+
            resource.getURI()+" is not a resource")) {
          return null;
        }
      } else {
        ReputationObject repObj = (ReputationObject) getResourceFromCache(
            statement.getObject().asResource(), ReputationObject.class);
        if(repObj == null) {
          repObj = getReputationObject(model,
              statement.getObject().asResource());         
        }
        entity.addHasReputation(repObj);
      }
    }
    // hasValue //
    Property hasValue = ResourceFactory.createProperty(
        riNamespace + "hasValue");   
    stmtI1 = model.listStatements(resource,
        hasValue, (RDFNode)null);
    while(stmtI1.hasNext()) {
      Statement statement = stmtI1.nextStatement();
      // validate hasValue property //
      if(!statement.getObject().isResource()) {         
        if(!ModelException.throwException(ModelException.ENTITY,
            "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());         
        }
        entity.addHasValue(repVal);
      }
    }
    // 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.ENTITY,
            "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());         
        }
        entity.addHasEvaluation(repEva);
      }
    }
    // foafAccount //
    Property foafAccount = ResourceFactory.createProperty(
        foafNamespace + "account");   
    stmtI1 = model.listStatements(resource,
        foafAccount, (RDFNode)null);
    while(stmtI1.hasNext()) {
      Statement statement = stmtI1.nextStatement();
      // validate foafAccount property //
      if(!statement.getObject().isResource()) {         
        if(!ModelException.throwException(ModelException.ENTITY,
            "foafAccount property of Entity resource:"+
            resource.getURI()+" is not a resource")) {
          return null;
        }
      } else {
        entity.addOnlineAccount(getFoafOnlineAccount(model,
            statement.getObject().asResource()));
      }
    }
    // foafHoldsAccount //
    Property foafHoldsAccount = ResourceFactory.createProperty(
        foafNamespace + "holdsAccount");   
    stmtI1 = model.listStatements(resource,
        foafHoldsAccount, (RDFNode)null);
    while(stmtI1.hasNext()) {
      Statement statement = stmtI1.nextStatement();
      // validate foafHoldsAccount property //
      if(!statement.getObject().isResource()) {         
        if(!ModelException.throwException(ModelException.ENTITY,
            "foafHoldsAccount property of Entity resource:"+
            resource.getURI()+" is not a resource")) {
          return null;
        }
      } else {
        entity.addOnlineAccount(getFoafOnlineAccount(model,
            statement.getObject().asResource()));
      }
    }   
    return entity;
  }
View Full Code Here

            "owner property of ReputationObject 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);         
        }
        repObj.setOwner(entity);
View Full Code Here

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

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

            "hasEntity property of Community 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);         
        }
View Full Code Here

              }
              System.out.println("   triple "+statement.getPredicate()+" - "+statement.getObject());
            }
            for(Property property : propertyAccount) {
              StmtIterator stmtI1 = model.listStatements(resource, property, (RDFNode)null);
            Entity entity = new Entity(userName);
              while(stmtI1.hasNext()) {
                Statement statement = stmtI1.nextStatement();             
                System.out.println("   OnlineAccount "+statement.getObject());
                String accountURL = "";
                String accountUserName = "";
                if(statement.getObject().isResource()) {
                  Resource onlineAccount = statement.getObject().asResource();                 
                  NodeIterator nodess = model.listObjectsOfProperty(onlineAccount, RDF.type);
                  while(nodess.hasNext()) {
                    RDFNode node = nodess.nextNode();
                    if(node.isResource()) {
                      System.out.println("      type " + node.asResource().getURI());
                    }
                  }
                  for(Property property2 : propertyAccountName) {
                    StmtIterator stmtI2 = model.listStatements(onlineAccount,
                        property2, (RDFNode)null);
                    Statement statement2 = stmtI2.nextStatement();
                    System.out.println("      AccountName "+statement2.getObject());
                    accountUserName = statement2.getObject().toString();
                  }
                  for(Property property2 : propertyAccountProfile) {
                    StmtIterator stmtI2 = model.listStatements(onlineAccount,
                        property2, (RDFNode)null);
                    if(stmtI2.hasNext()){
                      Statement statement2 = stmtI2.nextStatement();
                      System.out.println("      AccountProfile "+statement2.getObject());
                      accountURL = statement2.getObject().toString();
                    }
                  }
                  if(accountUserName.equalsIgnoreCase("not_exist")) {
                    ReputationWiki.notExistantUser.add(userName);
                    continue;
                  }
                  try{
                    Double value = Double.parseDouble(accountUserName);
                    ReputationWiki.userPredefined.add(new Ent_Eva(new Entity(userName),value));
                    continue;
                   
                  }catch (Exception e) {}
                 
                  String domain = ReputationWiki.findDomain(accountURL);
                if(domain == null) {
                  System.out.println("Error: domain is not known from user:"+
                  entity.getUniqueIdentificator()+" and it is discarted: "+ accountURL);
                  continue;
                }
                if(!accountUserName.equals("")){
                  entity.addIdentificatorInCommunities(GlobalModel.getCommunities().get(domain),
                    new EntityIdentifier(accountUserName,null));
                }
                else{
                  entity.addIdentificatorInCommunities(GlobalModel.getCommunities().get(domain),
                    new EntityIdentifier(entity.getUniqueIdentificator(),accountURL));
                }
                 
                if(!entity.getIdentificatorInCommunities().isEmpty()) {
                  GlobalModel.addEntity(entity);
                }
                }
              }
            }
View Full Code Here

    Entity edukun = GlobalModel.addEntity(new Entity("Edukun"));
    edukun.addIdentificatorInCommunities(GlobalModel.getCommunities().get("ohloh.net"),
        new EntityIdentifier("Gavin Sharp",null));
    edukun.addIdentificatorInCommunities(GlobalModel.getCommunities().get("security.stackexchange.com"),
        new EntityIdentifier("Sairam Kunala",null));*/
    Entity racker = GlobalModel.addEntity(new Entity("Racker"));
    //racker.addIdentificatorInCommunities(GlobalModel.getCommunities().get("ohloh.net"),
    //    new EntityIdentifier("janosch","http://www.ohloh.net/p/linux-omap/contributors/34615288934090"));
    racker.addIdentificatorInCommunities(GlobalModel.getCommunities().get("sla.ckers.org"),
        new EntityIdentifier("rsnake",null));
    GetMoreAccounts();
    return GlobalModel.getEntities().values();
  }
View Full Code Here

    for(String entityName : entityNames) {
      Map<ReputationAlgorithmImplementation,Map<ImportationUnit,
        Map<ReputationAlgorithmImplementation,Map<Metric,List<Object>>>>>
        reputationOfRepAlg = new HashMap<ReputationAlgorithmImplementation,
        Map<ImportationUnit,Map<ReputationAlgorithmImplementation,Map<Metric,List<Object>>>>>();
      Entity entity = GlobalModel.getEntities().get(entityName);     
      Date timestamp = new Date();
      List<ReputationValue> reputationValues = new ArrayList<ReputationValue>();
      for(ReputationImporterBehaviour repImp : importationUnits.keySet()) {
        Map<ImportationUnit,Map<ReputationAlgorithmImplementation,Map<Metric,List<Object>>>>
          reputationOfImportUnits = new HashMap<ImportationUnit,Map<
          ReputationAlgorithmImplementation,Map<Metric,List<Object>>>>();
        for(ImportationUnit importationUnit : importationUnits.get(repImp)) {
          //Find collectingSystem that are inside importationUnit     
          ObjectWithIdentifier systems = findCollectingSystemsFromImportationUnit(
              importationUnit);
          if(systems == null) {
            continue;
          }
          boolean communityMatching = false;
          for(Community communityToImport :
              entity.getIdentificatorInCommunities().keySet()) {
            //Comparison between communities is with pointers (not names)
            if(communityToImport == importationUnit.getImportedCommunity()) {
              communityMatching = true;
              break;
            }
          }
          if(communityMatching) {
            //Import and calculate reputations from all chained collectingSystems
            //inside the importationUnit
            Map<ReputationAlgorithmImplementation,Map<Metric,List<Object>>>
              reputationOfRepAlgs = extractReputationFromEntity(repImp, systems,
              importationUnit, entity,new ArrayList<Object>(),new HashMap<
              ReputationAlgorithmImplementation,Map<Metric,List<Object>>>());
            if(reputationOfRepAlgs != null) {
              reputationOfImportUnits.put(importationUnit, reputationOfRepAlgs);
            }   
          }
        }
        //ReputationImporter algorithm (default: 2 steps):
        //1 - join all reputation values in unique values to reduce reputationEvaluations
        //2 - calculate the final importation values with a simple add of all
        //    reputationEvaluations of each resultMetric of the metricMappings.
        //    The value is a simple add of the importedMetrics giving the weight
        //    according to the specific MetricMapping
        reputationValues.addAll(joinAllImportedReputationsByDefault(
            reputationOfImportUnits,repImp.getMapsMetrics(),
            entity, community, timestamp));       
        List<ReputationValue> repValuesAux = calculateReputationsByDefaultMethod(
            repImp.getRoot(),reputationOfImportUnits,
            repImp.getMapsMetrics(), entity, community, timestamp);
        if(repValuesAux != null) {
          reputationValues.addAll(repValuesAux);
        }       
      }
      if(!reputationValues.isEmpty()) {
        continue;
      }     
      entity.addHasReputation(getReputationObjectWithValues(
          entity,community,reputationValues));   
      entities.put(entity.getUniqueIdentificator(), entity);
     
      //TODO: LOG como variable
      System.out.println("Entity Procesed: unique identificator:"+entity.getUniqueIdentificator());
      System.out.println(entity.toString("     "));     
    }
    return entities;
    //Process collectingSystem with process of subgroups??   
  }
View Full Code Here

TOP

Related Classes of cross.reputation.model.Entity$GroupEntity

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.