Package cross.reputation.model

Examples of cross.reputation.model.Community


        new ArrayList<CommunityMetricToImport>();   
    for(String communityId : GlobalModel.getCommunities().keySet()) {
      if(communityId == community.getName()) {
        continue;
      }
      Community sourceCommunity = GlobalModel.getCommunities().get(communityId);
      for(Metric sourceMetric : sourceCommunity.getMetrics()) {
        communityMetricsToImport.addAll(buildCommunityMetricToImportToAllMetrics(
            sourceCommunity, community, sourceMetric));
      }
    }
    //printMetricsFromCommunity(communityMetricsToImport);
View Full Code Here


    for(Entity entity : GlobalModel.getEntities().values()) {
      Map<Community,EntityIdentifier> usuario = entity.getIdentificatorInCommunities();
      //In this form of iteration, we dont search accounts in the new accounts found or
      //  accounts updated that have already been iterated
      for(Object object : usuario.keySet().toArray()) {
        Community community = (Community) object;
        Set<String> accounts = new HashSet<String>();       
        String userName = usuario.get(community).getName();
        //System.out.println(userName+":"+community);
        String url = usuario.get(community).getUrl();
        try {
          if(url != null) {
            accounts.add(url);
            accounts.addAll(Scrapper.MoreUserAccountsByURL(url));
          } else {
            accounts.addAll(Scrapper.UserAccounts(userName,
                community.getDomainName(),true));
          }
         
        } catch (Exception e) {
          System.out.println("Error to get more accounts for entity:"+
            entity.getUniqueIdentificator()+" with comunnity: "+community.getName()
            +(url==null?" and user:"+userName:" and url:"+url));
          e.printStackTrace();
        }
        if(accounts != null) {
          SetAccountsInEntity(entity, userName, accounts);
View Full Code Here

    }   
  }
 
  static private void SetAccountsInEntity(Entity entity, String userName, Collection<String> accounts) {
    for(String accountName : accounts) {
      Community community = getCommunityByAccountName(accountName);
      if(community == null)
        continue;
      EntityIdentifier id = entity.getIdentificatorInCommunities().get(community);
      if(id == null) {
        System.out.println("New account:"+entity.getUniqueIdentificator()+","+
            community.getName()+","+userName+","+accountName);
        entity.addIdentificatorInCommunities(community,
          new EntityIdentifier(userName, accountName));
      } else if(id.getUrl() == null) {
        System.out.println("Update account:"+entity.getUniqueIdentificator()+","+
            community.getName()+","+userName+","+accountName);
        id.setUrl(accountName);
      }
    }
  }
View Full Code Here

    for(Entity entity : GlobalModel.getEntities().values()) {
      Map<Community,EntityIdentifier> usuario = entity.getIdentificatorInCommunities();
      //In this form of iteration, we dont search accounts in the new accounts found or
      //  accounts updated that have already been iterated
      for(Object object : usuario.keySet().toArray()) {
        Community community = (Community) object;
        Set<String> accounts = new HashSet<String>();       
        String userName = usuario.get(community).getName();
        //System.out.println(userName+":"+community);
        String url = usuario.get(community).getUrl();
        try {
          if(url != null) {
            accounts.add(url);
            Set<String> userAccounts = Scrapper.MoreUserAccountsByURL(url);
            if(userAccounts != null) {
              accounts.addAll(userAccounts);
            }
          } else {
            List<String> userAccounts = Scrapper.UserAccounts(userName,
                community.getDomainName(), true);
            if(userAccounts != null) {
              accounts.addAll(userAccounts);
            }
          }         
        } catch (Exception e) {
          e.printStackTrace();
          ModelException.throwException(ModelException.GET_MORE_ACCOUNTS,
            "Error to get more accounts for entity:"+
            entity.getUniqueIdentificator()+" with community: "+
            community.getName()+" and user:"+userName+" from"+url);         
        }
        if(accounts != null) {
          SetAccountsInEntity(entity, userName, accounts);
        }
      }     
View Full Code Here

  }
 
  static private void SetAccountsInEntity(Entity entity,
      String userName, Collection<String> accounts) throws Exception {
    for(String accountName : accounts) {
      Community community = getCommunityByAccountName(accountName);
      if(community == null)
        continue;
      EntityIdentifier id = entity.getIdentificatorInCommunities().get(community);
      if(id == null) {
        ModelException.sendMessage(ModelException.INFO,
            "New account:"+entity.getUniqueIdentificator()+","+
            community.getName()+","+userName+","+accountName);
        entity.addIdentificatorInCommunities(community,
          new EntityIdentifier(userName, accountName));
      } else if(id.getUrl() == null) {
        ModelException.sendMessage(ModelException.INFO,"Update account:"
            +entity.getUniqueIdentificator()+","+
            community.getName()+","+userName+","+accountName);
        id.setUrl(accountName);
      }
    }
  }
View Full Code Here

    */
  }
 
  public Map<String, Entity> importOverEntitiesToCommunity(String communityName,
      Set<String> entityNames) throws Exception {
    Community community = GlobalModel.getCommunities().get(communityName);
    if(community == null) {
      ModelException.sendMessage(ModelException.ERROR, "Community to import" +
          " is not set in the parsed semantic model");
      return null;
    }
    if(community.getReputationModel() == null) {
      ModelException.sendMessage(ModelException.ERROR, "ReputationModel from " +
          "Community(resource:"+community.getResource()+") must be set to" +
          " import reputations");
      return null;
    }
    //Find importationUnit
    Map<ReputationImporterBehaviour, Set<ImportationUnit>> importationUnits =
        findImportationUnits(community.getReputationModel());
    //TODO: ver que existe al menos un importationUnit in todo el MAP!!
    //Set<MetricMapping> metricMappings = findMetricMappings(
    //    community.getReputationModel());
    Map<String, Entity> entities = new HashMap<String, Entity>();
    for(String entityName : entityNames) {
View Full Code Here

 
  public void importOverEntitiesToCommunity(
      URI commmunityURI, Set<String> entityNames) throws Exception {
    Resource communityResource = ResourceFactory.createResource(
        commmunityURI.toString());
    Community community = (Community) reputationParser.getResourceFromCache(
        communityResource, Community.class);
    if(community == null) {
      community = reputationParser.getCommunity(
          reputationParser.getModel(), communityResource);
    }
View Full Code Here

   
    //Set All Model
    ConfigureModel.buildCrossReputationGlobalModel();
   
    //Set the destination community to import the other community reputations
    Community destinationCommunity = GlobalModel.getCommunities().get("semanticWiki");
   
    //Set user accounts from file generated by the mediawiki python bot
    /*try {
      setUserAccountsFromJSON(lastFileName);
      //setUserAccountsFromFile(lastFileName);
    } catch (IOException e) {
      System.out.println("Error: ioexception at reading file:"+lastFileName
          +"\n "+e.getMessage());
      return;
    } catch (JSONException e) {
          System.out.println("The file could have a not JSON format.");
          e.printStackTrace();
          return;
    }*/
   
    //Set user accounts from Foaf RDF file
    FoafParser foaf = new FoafParser();
    //foaf.foafAgent("dir/foafSample.rdf");
    foaf.foafAgent("http://localhost/foafSample2.rdf");
   
    //Add all entities configured to all metrics in the destination community
    for(Entity entity : GlobalModel.getEntities().values()) {
      destinationCommunity.addEntityToAllMetrics(entity);
    }   
   
    //Set that all rest communities and theirs metrics are valid to the importation
    List<CommunityMetricToImport> metricsToImport = ConfigureModel.
      buildMetricsFromAllCommunitiesToAllMetrics(destinationCommunity);
View Full Code Here

TOP

Related Classes of cross.reputation.model.Community

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.