Package org.openrdf.model

Examples of org.openrdf.model.URI


    // see if we should try and find a value from the supplied resource's
    // parent.
    if (inherit) {
      visited.add(subject);
      URI inheritanceProperty = getInheritanceProperty();

      if (inheritanceProperty != null) {
        Cursor<? extends Statement> parentStatements = super.getStatements(subject, inheritanceProperty,
            null, true);
View Full Code Here


  private URI getAttributeValueForPermission(URI permission, URI attribute)
    throws StoreException
  {
    Resource match = getPropertyResourceValue(permission, ACL.HAS_MATCH, false, ACL.CONTEXT);
    URI attributeValue = (URI)getPropertyResourceValue(match, attribute, false, ACL.CONTEXT);
    return attributeValue;
  }
View Full Code Here

  private URI getCurrentUser()
    throws StoreException
  {
    Session session = SessionManager.get();
    if (session != null) {
      URI userId = session.getUserId();

      if (userId != null) {
        return userId;
      }
View Full Code Here

      for (URI permission : permissions) {
        // check if all attributes match
        boolean allMatch = true;

        for (Entry<URI, Set<Resource>> entry : attributeValues.entrySet()) {
          URI attribute = entry.getKey();
          Set<Resource> attributeValueList = entry.getValue();

          URI permissionAttributeValue = getAttributeValueForPermission(permission, attribute);
          boolean isMatch = attributeValueList.contains(permissionAttributeValue);

          if (!isMatch) {
            allMatch = false;
            break;
View Full Code Here

  protected void insert(Number id, RdbmsLiteral literal)
    throws SQLException, InterruptedException
  {
    String label = literal.getLabel();
    String language = literal.getLanguage();
    URI datatype = literal.getDatatype();
    if (datatype == null && language == null) {
      table.insertSimple(id, label);
    }
    else if (datatype == null) {
      table.insertLanguage(id, label, language);
    }
    else {
      String dt = datatype.stringValue();
      try {
        if (XMLDatatypeUtil.isNumericDatatype(datatype)) {
          table.insertNumeric(id, label, dt, literal.doubleValue());
        }
        else if (XMLDatatypeUtil.isCalendarDatatype(datatype)) {
View Full Code Here

      }

      // join of the attribute match expressions.
      Join joinOfAttributePatterns = new Join();

      URI inheritanceProp = getInheritanceProperty();
      Var inheritPredVar = new Var("-acl_inherit_pred", inheritanceProp);

      int i = 0;

      List<Var> attributeVars = new ArrayList<Var>();
      for (URI attribute : attributes) {
        Var attributeVar = new Var("-acl_attr_" + i++);
        attributeVars.add(attributeVar);

        Var attributePredVar = new Var("-acl_attr_pred_" + i, attribute);

        // SP(?subject, accessAttr_i, ?accessAttrValue_i)
        StatementPattern attributePattern = new StatementPattern(subjectVar, attributePredVar,
            attributeVar);

        if (inheritanceProp != null) {
          // create a union expression for this attribute.
          Union union = new Union();
          union.addArg(attributePattern);

          // the join for checking if the access attribute is inherited.
          Join inheritJoin = new Join();
          Var inheritVar = new Var("-acl_inherited_value" + i);
          // SP (?subject, inheritProp, ?S_i)
          StatementPattern inheritPattern = new StatementPattern(subjectVar, inheritPredVar, inheritVar);
          inheritJoin.addArg(inheritPattern);
          // SP (?S_i, accessAttr_i, ?accessAttrValue_i)
          StatementPattern inheritAttrPattern = new StatementPattern(inheritVar, attributePredVar,
              attributeVar);
          inheritJoin.addArg(inheritAttrPattern);

          union.addArg(inheritJoin);

          joinOfAttributePatterns.addArg(union);
        }
        else {
          // no inheritance: the attribute can be matched with a simple
          // statement pattern
          joinOfAttributePatterns.addArg(attributePattern);
        }
      }

      TupleExpr expandedPattern = null;

      if (joinOfAttributePatterns.getNumberOfArguments() == 1) {
        expandedPattern = new LeftJoin(statementPattern, joinOfAttributePatterns.getArg(0));
      }
      else {
        expandedPattern = new LeftJoin(statementPattern, joinOfAttributePatterns);
      }

      // build an Or-ed set of filter conditions on the status and team.
      Or filterConditions = new Or();

      /* first condition is that none are bound: this is the case where the subject
       * is not a restricted resource (and therefore has no associated attributes)
       *
       * And(Not(Bound(?acl_attr1)), Not(Bound(?acl_attr_1), ...)
       */
      And and = new And();
      for (Var attributeVar : attributeVars) {
        and.addArg(new Not(new Bound(attributeVar)));
      }

      if (and.getArgs().size() == 1) {
        filterConditions.addArg(and.getArg(0));
      }
      else {
        filterConditions.addArg(and);
      }

      if (permissions == null) {
        List<URI> roles = getRolesForUser(getCurrentUser());
        permissions = getAssignedPermissions(roles, ACL.VIEW);
      }

      // for each permission, we add an additional condition to the filter,
      // checking that either
      // team, or status, or both match.
      for (URI permission : permissions) {
        And permissionCondition = new And();

        for (int j = 0; j < attributes.size(); j++) {
          URI attribute = attributes.get(j);
          URI attributePermissionValue = getAttributeValueForPermission(permission, attribute);

          Compare attributeValueCompare = null;
          if (attributePermissionValue != null) {
            attributeValueCompare = new Compare(attributeVars.get(j), new Var("acl_attr_val_" + j,
                attributePermissionValue));
View Full Code Here

          return valueFactory.createLiteral(label, language);
        }
        else if (startDtIdx != -1) {
          // Get datatype
          String datatype = nTriplesLiteral.substring(startDtIdx + 2);
          URI dtURI = parseURI(datatype, valueFactory);
          return valueFactory.createLiteral(label, dtURI);
        }
        else {
          return valueFactory.createLiteral(label);
        }
View Full Code Here

  {
    if (literal.getLanguage() != null) {
      xmlWriter.setAttribute(LITERAL_LANG_ATT, literal.getLanguage());
    }
    else if (literal.getDatatype() != null) {
      URI datatype = literal.getDatatype();
      xmlWriter.setAttribute(LITERAL_DATATYPE_ATT, datatype.toString());
    }

    xmlWriter.textElement(LITERAL_TAG, literal.getLabel());
  }
View Full Code Here

    // Write in size
    s.writeInt(statements.size());
    // Write in all elements
    for (ModelStatement st : statements) {
      Resource subj = st.getSubject();
      URI pred = st.getPredicate();
      Value obj = st.getObject();
      Resource ctx = st.getContext();
      s.writeObject(new StatementImpl(subj, pred, obj, ctx));
    }
  }
View Full Code Here

    }
  }

  private Iterator find(Statement st) {
    Resource subj = st.getSubject();
    URI pred = st.getPredicate();
    Value obj = st.getObject();
    Resource ctx = st.getContext();
    return match(subj, pred, obj, ctx);
  }
View Full Code Here

TOP

Related Classes of org.openrdf.model.URI

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.