Package org.corrib.s3b.mbb.db.rdf

Examples of org.corrib.s3b.mbb.db.rdf.GraphStatistics


        ex.printStackTrace();
      }
     
    }else {
      Graph g = repo.getGraph();
      GraphStatistics gstats = GraphStatistics.get(g);
      StatementIterator it;
      int[] reg = new int[3];
     
      for(ValueStats propst : filterProps.values()) {
        it = g.getStatements(null, propst.getProperty(), null);
        reg[0] = 0;
        reg[1] = 0;
        reg[2] = 0;
       
        while(it.hasNext()) {
          Statement s = it.next();
          Value v;
         
          if(propst.isInverted())
            v = s.getObject();
          else
            v = s.getSubject();
         
          if(v instanceof Literal)
            continue;
         
          if(v instanceof BNode)
            reg[2]++;
          else if(gstats.getResults().contains(v))
            reg[0]++;
          else
            reg[1]++;
        }// ---- while
       
View Full Code Here


    }else {
      String[] asparams = new String[7];
      BrowseSimilarService similarService = new BrowseSimilarService();
      ServiceChain newchain = null;
      LocalRepository simrepo;
      GraphStatistics graphstats;
      ValueStats aisize;
     
      try {
         newchain = (ServiceChain)this.callBean.getChain().clone();
         newchain.getServices().add(similarService);
      } catch (CloneNotSupportedException e) {
        e.printStackTrace();
      }
     
      similarService.setCallBean(this.getCallBean());
      similarService.setRequestParams(null);
      similarService.setUser(this.user);
 
      asparams[1] = "";//"!");
      asparams[2]= "";//"-");
      asparams[6]= "*";
     
     
      if(newchain != null)
        for(String property : results.keySet()) {
          String prop = property;
          String ns = null;
          String name = property;
         
          if(property.startsWith("-")) {
            asparams[2] =  MBBService.INVERSE;
            prop = property.substring(1);
            name = prop;
          }
         
          if(prop.indexOf(':')>0) {
            ns = prop.substring(0, prop.indexOf(':'));
            name = prop.substring(prop.indexOf(':')+1);
          }
         
          asparams[0]= this.params.get(0)+"/browse/"+property+"/*";
          asparams[3]= prop;
          asparams[4]= ns;
          asparams[5]= name;
         
          similarService.setUri(asparams[0]);
          similarService.setParams(Arrays.asList(asparams));
 
          simrepo = similarService.execute(repo);
          graphstats = GraphStatistics.get(simrepo.getGraph());
          graphstats.process(asparams[0], true, true, true);
         
          aisize = results.get(property);
          aisize.setCountWithResults(graphstats.getResults().size());
          aisize.setCountWithResources(graphstats.getResources().size());
          aisize.setCountWithBnodes(graphstats.getBnodes().size());
        }

      String _uri = this.getCallBean().getCall();
      _uri = _uri.substring(0, _uri.indexOf("/stats"));
      Repository.logger.info("Put stats to cache: "+_uri);
View Full Code Here

    }else {
      String[] asprops = new String[6];
      BrowseRelatedService browseService = new BrowseRelatedService();
      ServiceChain newchain = null;
      LocalRepository simrepo;
      GraphStatistics graphstats;
      ValueStats aisize;
     
      try {
         newchain = (ServiceChain)this.callBean.getChain().clone();
         newchain.getServices().add(browseService);
      } catch (CloneNotSupportedException e) {
        e.printStackTrace();
      }
     
      browseService.setCallBean(this.getCallBean());
      browseService.setRequestParams(null);
      browseService.setUser(this.user);
 
      asprops[1]="";//"!");
      asprops[2]="";//"-");
     
     
      if(newchain != null)
        for(String property : results.keySet()) {
          String prop = property;
          String ns = null;
          String name = property;
         
          if(property.startsWith("-")) {
            asprops[2]=MBBService.INVERSE;
            prop = property.substring(1);
            name = prop;
          }
         
          if(prop.indexOf(':')>0) {
            ns = prop.substring(0, prop.indexOf(':'));
            name = prop.substring(prop.indexOf(':')+1);
          }
         
          asprops[0]=this.params.get(0)+"/browse/"+property+"$";
          asprops[3]=prop;
          asprops[4]=ns;
          asprops[5]=name;
 
          browseService.setParams(Arrays.asList(asprops));
          browseService.setUri(asprops[0]);
 
          simrepo = browseService.execute(repo);
          graphstats = GraphStatistics.get(simrepo.getGraph());
          graphstats.process(asprops[0], true, true, true);
         
          aisize = results.get(property);
          aisize.setCountWithResults(graphstats.getResults().size());
          aisize.setCountWithResources(graphstats.getResources().size());
          aisize.setCountWithBnodes(graphstats.getBnodes().size());
        }

      String _uri = this.getCallBean().getCall();
      _uri = _uri.substring(0, _uri.indexOf("/stats"));
      Repository.logger.info("Put stats to cache: "+_uri);
View Full Code Here

      }
      if(prop.length() > 4)
        prop = prop.substring(0, prop.length()-4);

      String lit;
      GraphStatistics gstats;
      Value[] ares;
      RDFQuery query = (inverse)?RDFQuery.RDFQ_STATS_GETRES_BY_VALUE_INV:RDFQuery.RDFQ_STATS_GETRES_BY_VALUE;
     
      for(ValueStats value : result.values()) {
        lit = "\""+value.getLiteral().getLabel()+"\"";
        if(value.getLiteral().getLanguage() != null)
          lit += "@"+value.getLiteral().getLanguage();
        else if(value.getLiteral().getDatatype() != null)
          lit += "^^<"+value.getLiteral().getDatatype()+">";
       
        try {
          ares = SesameWrapper.performVectorQuery(repo, query, prop, lit);
          SesameWrapper.loadResources(ares, repo, lr.getGraph());
         
          gstats = GraphStatistics.get(lr.getGraph());
          gstats.forceProcess(null, true, true, true);
         
          value.setCountWithBnodes(gstats.getBnodes().size());
          value.setCountWithResources(gstats.getResources().size());
          value.setCountWithResults(gstats.getResults().size());
         
          lr.clear(new StdOutAdminListener());
        }catch(Exception ex) {
          Repository.logger.warning("Something wrong has happend: "+ex);
        }
View Full Code Here

    }else {
      BrowseSimilarService similarService = new BrowseSimilarService();
      String[] asparams = new String[7];
      ServiceChain newchain = null;
      LocalRepository simrepo;
      GraphStatistics graphstats;
      String[] aprop = (aproperty != null && aproperty.length > 0)?PredefinedProperty.shortenURI(aproperty[0]):null; //XXX this is a nasty quick hack - to be corrected later
     
      try {
         newchain = (ServiceChain)this.callBean.getChain().clone();
         newchain.getServices().add(similarService);
      } catch (CloneNotSupportedException e) {
        e.printStackTrace();
      }
     
      similarService.setCallBean(this.getCallBean());
      similarService.setRequestParams(null);
      similarService.setUser(this.user);
 
      asparams[1]= "";//"!";
      asparams[2]= (inverse)?"-":"";//"-";
      asparams[3]= (aprop != null)?aprop[3]:"*";
      asparams[4]= (aprop != null && aprop[1]!=null)?aprop[1]:"";
      asparams[5]= (aprop != null && aprop[2]!=null)?aprop[2]:((aprop != null)?aprop[0]:"");
     
     
      if(newchain != null)
        for(ValueStats value : results.values()) {
          String lit = value.getLiteral().getLabel();
         
          if(lit.indexOf(' ') > 0)
            lit = "\""+lit.replaceAll(" ", "%20")+"\"";
         
          asparams[0] = this.params.get(0)+"/similar/"+((inverse)?"-":"")+asparams[3]+"/"+lit;
          asparams[6]= lit;
 
          similarService.setParams(Arrays.asList(asparams));
          similarService.setUri(asparams[0]);
         
          simrepo = similarService.execute(repo);
          graphstats = GraphStatistics.get(simrepo.getGraph());
          graphstats.process(asparams[0], true, true, true);
         
          value.setCountWithResults(graphstats.getResults().size());
          value.setCountWithResources(graphstats.getResources().size());
          value.setCountWithBnodes(graphstats.getBnodes().size());
        }
    }//--- check if full processing allowed   
   
    return results;
  }   
View Full Code Here

   * This method enriches results returned from this servlet with easier processable information
   * @param request
   * @param repos
   */
  protected void postprocessResults(HttpServletRequest request, LocalRepository repos) {
    GraphStatistics gstats = null;
    try {
      gstats = GraphStatistics.get(repos.getGraph());
    } catch (AccessDeniedException e) {
      e.printStackTrace();
    }finally {
      if(gstats != null) {
        request.setAttribute("sresults", gstats.getResults());
        request.setAttribute("sresources", gstats.getResources());
        request.setAttribute("sbnodes", gstats.getBnodes());
        request.setAttribute("mtriples", gstats.getTriples());
        request.setAttribute("mlabels", gstats.getLabels());
        request.setAttribute("triplescount", gstats.getCount());
        request.setAttribute("stypes", gstats.getTypes());
      }
    }
   
   
  }
View Full Code Here

TOP

Related Classes of org.corrib.s3b.mbb.db.rdf.GraphStatistics

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.