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

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


    } catch (AccessDeniedException e) {
      Repository.logger.warning(e.toString());
    }
   
   
    RDFQuery rdfquery;
//    String pparam;
    String restparam;
    String using;
   
    //this is the type of browse when you match values
    rdfquery  = (isInverse)?RDFQuery.RDFQ_BROWSE_LISTVALUES_PROPERTY_INVERSE:RDFQuery.RDFQ_BROWSE_LISTVALUES_PROPERTY;

   
    if(uriprop) {
      using = "";
//      pparam = "prop";//(isNegation)?"prop":"<"+sFullProperty+">";
      restparam = (isNegation)?"NOT (":"(";
      if(asFullProperty != null)
      for(String s : asFullProperty){
        restparam += "prop = <"+s+"> OR ";
      }
      if(restparam.length() > 4)
        restparam = restparam.substring(0, restparam.length()-4);
      restparam += ")";
//      restparam = (isNegation)?"NOT prop = <"+sFullProperty+">":"TRUE";
    }else {
//      String property = this.pproperty.getURI(sPropertyName);
//      pparam = "prop";//(sPropertyNS == null)?"<"+property+">":"prop";
      restparam = "TRUE";
      if(!"*".equals(sPropertyNS))
        restparam += ((!isNegation)?" AND (":" AND (NOT ")+"namespace(prop) = property:";
      //namespace(prop) = property: AND localName(prop) LIKE "*digitaltype*" //IGNORE CASE
      if(!"*".equals(sPropertyName) && !"*".equals(sPropertyNS))
        restparam += (!isNegation)?" AND ":" OR ";
      if(!"*".equals(sPropertyName))
        restparam += ((!isNegation)?"":"NOT")+" localName(prop)=\""+sPropertyName+"\"";
      if(!"*".equals(sPropertyNS))
        restparam += ") ";
 
      using = (!"*".equals(sPropertyNS))?" USING NAMESPACE mbb = <http://s3b.corrib.org/mbb#>"+RDFQuery.RDFQ_ADD_NAMESPACE.toString(this.pnamespace.getURI(sPropertyNS)):"";
    }
   
    String valueQueryPart = rdfquery.toString(/*pparam, */restparam);
         valueQueryPart += using;
    //no need for predefined properties
    Repository.logger.info(valueQueryPart);
    Value[] avUris = SesameWrapper.performVectorQuery(inGraph, QueryLanguage.SERQL, valueQueryPart);

View Full Code Here


    String props = "(%1$s)";
         props += (!isNegation)?" AND":" OR NOT";
         props += " prop=<"+sPropertyURI+">";
       
    //we need it only when namespace defined
    RDFQuery rdfquery = (isInverse)?RDFQuery.RDFQ_INVERS_FILTER:RDFQuery.RDFQ_FILTER;
    String queryPart = rdfquery.toString("prop",//just prop
                             props);//we only need to filter values
    String query = new ValueFilter(sValues).process(queryPart, this.isIgnoreCase());
        query += " USING NAMESPACE mbb = <http://s3b.corrib.org/mbb#>";

    Repository.logger.info("URIPropertyFilterService: "+query);
View Full Code Here

    if(restparam.length() > 4)
      restparam = restparam.substring(0, restparam.length()-4);
    restparam += ")  AND (%1$s)";
   
    // --- =========== non inverse scenario ===================== ---
    RDFQuery rdfquery = (isInverse)?RDFQuery.RDFQ_INVERS_FILTER:RDFQuery.RDFQ_FILTER;
    String queryPart = rdfquery.toString(pparam,//we know the full URI of the property
                                restparam);//we only need to filter values
    String query = new ValueFilter(sValues).process(queryPart, this.isIgnoreCase());
    //no need for predefined properties

    Repository.logger.info(query);
View Full Code Here

    } catch (AccessDeniedException e) {
      Repository.logger.warning(e.toString());
    }
    //otherwise we need to execute the query
   
    RDFQuery rdfquery;
    String pparam;
    String restparam;
    String using;
    String valueQueryPart;
   
    if(!"*".equals(sFullProperty)) {
      //this is the type of browse when you match values
      rdfquery  = (isInverse)?RDFQuery.RDFQ_BROWSE_LISTVALUES_PROPERTY_INVERSE:RDFQuery.RDFQ_BROWSE_LISTVALUES_PROPERTY;
      if(uriprop) {
        using = "";
//        pparam = "prop";//(isNegation)?"prop":"<"+sFullProperty+">";
        restparam = (isNegation)?"NOT (":"(";
        if(asFullProperty != null)
        for(String s : asFullProperty){
          restparam += "prop = <"+s+"> OR ";
        }
        if(restparam.length() > 4)
          restparam = restparam.substring(0, restparam.length()-4);
        restparam += ")";
      }else {
//        String property = this.pproperty.getURI(sPropertyName);
//        pparam = "prop";//(sPropertyNS == null)?"<"+property+">":"prop";
        restparam = "TRUE";
        if(!"*".equals(sPropertyNS))
          restparam += ((!isNegation)?" AND (":" AND (NOT ")+"namespace(prop) = property:";
        //namespace(prop) = property: AND localName(prop) LIKE "*digitaltype*" //IGNORE CASE
        if(!"*".equals(sPropertyName) && !"*".equals(sPropertyNS))
          restparam += (!isNegation)?" AND ":" OR ";
        if(!"*".equals(sPropertyName))
          restparam += ((!isNegation)?"":"NOT")+" localName(prop)=\""+sPropertyName+"\"";
        if(!"*".equals(sPropertyNS))
          restparam += ") ";

        String uprop = this.pnamespace.getURI(sPropertyNS);
        using = (sPropertyNS!=null && !"*".equals(sPropertyNS))?" USING NAMESPACE mbb = <http://s3b.corrib.org/mbb#>"+RDFQuery.RDFQ_ADD_NAMESPACE.toString((uprop==null)?"http://dummy.url/":uprop):"";
      }
     
      pparam = "prop";
     
      valueQueryPart = rdfquery.toString(restparam);

    }else {
      //this is the type of browse when you match properties
      rdfquery  = (isInverse)?RDFQuery.RDFQ_BROWSE_LISTVALUES_VALUE_INVERSE:RDFQuery.RDFQ_BROWSE_LISTVALUES_VALUE;
      pparam = "%1$s";
      restparam = "";
      using = "";
     
      valueQueryPart = rdfquery.toString("%1$s");
    }

    ValueFilter values = new ValueFilter(sValues);
    String valueSelectQuery = values.process(valueQueryPart, this.isIgnoreCase());
         valueSelectQuery += using;
    //no need for predefined properties
    Repository.logger.info(valueSelectQuery);
    Value[] avUris = SesameWrapper.performVectorQuery(inGraph, QueryLanguage.SERQL, valueSelectQuery);
   
    Set<Value> ssubjectUris = new HashSet<Value>();
    RDFQuery subjectRdfQuery;
    if(isInverse)
      subjectRdfQuery = (!"*".equals(sFullProperty))?RDFQuery.RDFQ_BROWSE_FILTEROBJECTS_INVERSE:RDFQuery.RDFQ_BROWSE_FILTEROBJECTS_VALUES_INVERSE;
    else
      subjectRdfQuery = (!"*".equals(sFullProperty))?RDFQuery.RDFQ_BROWSE_FILTEROBJECTS:RDFQuery.RDFQ_BROWSE_FILTEROBJECTS_VALUES;
    String subjectQueryPart;
    Value[] avResults;
   
    for(Value value : avUris) {
      String value_filter;
      if(value instanceof BNode)
        value_filter = "<_:"+value+">";
      else if(value instanceof URI)
        value_filter = "<"+value+">";
      else
        value_filter = "\""+value+"\"";
     
      if(!"*".equals(sFullProperty))
        subjectQueryPart = subjectRdfQuery.toString(pparam, ("".equals(restparam))?"TRUE":restparam,  value_filter);
      else {
        String tmpQ = subjectRdfQuery.toString(value_filter, "%1$s");
        subjectQueryPart = values.process(tmpQ, this.isIgnoreCase());
      }
      subjectQueryPart += using;

      avResults = SesameWrapper.performVectorQuery(Repository.MAIN_REPOSITORY.getLocalRepository(),
View Full Code Here

   */
  protected SortedMap<String, ValueStats> getFilterValues(LocalRepository repo, URI[] property, boolean inverted){
    SortedMap<String, ValueStats> result = new TreeMap<String, ValueStats>();
    String filter = this.getRequestParams().getValueS("filter");
    String param = (filter != null && !"".equals(filter))?" value LIKE \"*"+filter+"*\" IGNORE CASE ":"TRUE";
    RDFQuery rdfq = (inverted)?RDFQuery.RDFQ_STATS_GETVALUES_BY_PROP_INV:RDFQuery.RDFQ_STATS_GETVALUES_BY_PROP;
    String prop = "";
    if(property != null){
      for(URI s : property){
        prop += "prop = <"+s.getURI()+"> OR ";
      }
      if(prop.length() > 4)
        prop = prop.substring(0, prop.length()-4);     
    }
   
    String query = (property==null)?RDFQuery.RDFQ_STATS_GETVALUES.toString(param):rdfq.toString(prop, param);
   
    Value[] values = SesameWrapper.performVectorQuery(repo, QueryLanguage.SERQL, query);
    boolean calltokens = false;
   
    if(values.length > MAX_RESULTS) // --- check if the number of results returned does not exceed given threshold
View Full Code Here

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

      props += ((!isNegation)?"":"NOT")+" localName(prop)=\""+sPropertyName+"\"";
    if(!"*".equals(sPropertyNamespace))
      props += ") ";
       
    //we need it only when namespace defined
    RDFQuery rdfquery = (isInverse)?RDFQuery.RDFQ_INVERS_FILTER:RDFQuery.RDFQ_FILTER;
    String queryPart = rdfquery.toString("prop",//just prop
                             props);//we only need to filter values
    String query = new ValueFilter(sValues).process(queryPart, this.isIgnoreCase());
    if(!"*".equals(sPropertyNamespace))
       query += " USING NAMESPACE mbb = <http://s3b.corrib.org/mbb#>"+RDFQuery.RDFQ_ADD_NAMESPACE.toString(this.pnamespace.getURI(sPropertyNamespace));

View Full Code Here

TOP

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

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.