@Override
  public void addRelation(
      CoreSession session,
      DocumentModel from,
      Node toResource,
      String predicate,
      boolean inverse,
      boolean includeStatementsInEvents,
      String comment)
      throws ClientException {
    Graph graph = getRelationManager().getGraphByName(RelationConstants.GRAPH_NAME);
    QNameResource fromResource = getNodeFromDocumentModel(from);

    Resource predicateResource = new ResourceImpl(predicate);
    Statement stmt = null;
    List<Statement> statements = null;
    if (inverse) {
      stmt = new StatementImpl(toResource, predicateResource, fromResource);
      statements = graph.getStatements(toResource, predicateResource, fromResource);
      if (statements != null && statements.size() > 0) {
        throw new RelationAlreadyExistsException();
      }
    } else {
      stmt = new StatementImpl(fromResource, predicateResource, toResource);
      statements = graph.getStatements(fromResource, predicateResource, toResource);
      if (statements != null && statements.size() > 0) {
        throw new RelationAlreadyExistsException();
      }
    }

    // Comment ?
    if (!StringUtils.isEmpty(comment)) {
      stmt.addProperty(RelationConstants.COMMENT, new LiteralImpl(comment));
    }
    Literal now = RelationDate.getLiteralDate(new Date());
    if (stmt.getProperties(RelationConstants.CREATION_DATE) == null) {
      stmt.addProperty(RelationConstants.CREATION_DATE, now);
    }
    if (stmt.getProperties(RelationConstants.MODIFICATION_DATE) == null) {
      stmt.addProperty(RelationConstants.MODIFICATION_DATE, now);
    }

    if (session.getPrincipal() != null && stmt.getProperty(RelationConstants.AUTHOR) != null) {
      stmt.addProperty(RelationConstants.AUTHOR, new LiteralImpl(session.getPrincipal().getName()));
    }

    // notifications

    Map<String, Serializable> options = new HashMap<String, Serializable>();
    String currentLifeCycleState = from.getCurrentLifeCycleState();
    options.put(CoreEventConstants.DOC_LIFE_CYCLE, currentLifeCycleState);
    if (includeStatementsInEvents) {
      putStatements(options, stmt);
    }
    options.put(RelationEvents.GRAPH_NAME_EVENT_KEY, RelationConstants.GRAPH_NAME);

    // before notification
    notifyEvent(RelationEvents.BEFORE_RELATION_CREATION, from, options, comment, session);

    // add statement
    graph.add(stmt);

    // XXX AT: try to refetch it from the graph so that resources are
    // transformed into qname resources: useful for indexing
    if (includeStatementsInEvents) {
      putStatements(options, graph.getStatements(stmt));
    }

    // after notification
    notifyEvent(RelationEvents.AFTER_RELATION_CREATION, from, options, comment, session);
  }
  // MODIFORI
  public String addStatement(DocumentModel currentDoc) throws ClientException {
    Resource documentResource = getDocumentResource(currentDoc);
    if (documentResource == null) {
      throw new ClientException("Document resource could not be retrieved");
    }

    Resource predicate = new ResourceImpl(predicateUri);
    Node object = null;
    if (objectType.equals("literal")) {
      objectLiteralValue = objectLiteralValue.trim();
      object = new LiteralImpl(objectLiteralValue);
    } else if (objectType.equals("uri")) {
      objectUri = objectUri.trim();
      object = new ResourceImpl(objectUri);
    } else if (objectType.equals("document")) {
      objectDocumentUid = objectDocumentUid.trim();
      String repositoryName = navigationContext.getCurrentServerLocation().getName();
      String localName = repositoryName + "/" + objectDocumentUid;
      object = new QNameResourceImpl(RelationConstants.DOCUMENT_NAMESPACE, localName);
    }

    // if outgoing statement is null
    if (outgoingStatements == null) {
      getOutgoingStatementsInfo(currentDoc);
    }

    // create new statement
    Statement stmt = new StatementImpl(documentResource, predicate, object);
    if (!outgoingStatements.contains(stmt)) {
      // add statement to the graph
      List<Statement> stmts = new ArrayList<Statement>();
      String eventComment = null;
      if (comment != null) {
        comment = comment.trim();
        if (comment.length() > 0) {
          stmt.addProperty(RelationConstants.COMMENT, new LiteralImpl(comment));
          eventComment = comment;
        }
      }
      Literal now = RelationDate.getLiteralDate(new Date());
      stmt.addProperty(RelationConstants.CREATION_DATE, now);
      stmt.addProperty(RelationConstants.MODIFICATION_DATE, now);
      if (currentUser != null) {
        stmt.addProperty(RelationConstants.AUTHOR, new LiteralImpl(currentUser.getName()));
      }

      stmts.add(stmt);

      // notifications

      Map<String, Serializable> options = new HashMap<String, Serializable>();
      String currentLifeCycleState = currentDoc.getCurrentLifeCycleState();
      options.put(CoreEventConstants.DOC_LIFE_CYCLE, currentLifeCycleState);
      if (includeStatementsInEvents) {
        putStatements(options, stmt);
      }
      options.put(RelationEvents.GRAPH_NAME_EVENT_KEY, RelationConstants.GRAPH_NAME);

      // before notification
      notifyEvent(RelationEvents.BEFORE_RELATION_CREATION, currentDoc, options, eventComment);

      // add statement
      relationManager.add(RelationConstants.GRAPH_NAME, stmts);

      // XXX AT: try to refetch it from the graph so that resources are
      // transformed into qname resources: useful for indexing
      if (includeStatementsInEvents) {
        putStatements(options, relationManager.getStatements(RelationConstants.GRAPH_NAME, stmt));
      }

      // after notification
      notifyEvent(RelationEvents.AFTER_RELATION_CREATION, currentDoc, options, eventComment);

      // make sure statements will be recomputed
      resetStatements();

      // commenté pour ne pas affiché Relation créée qui ne parle pas à l'utilisateur
      // facesMessages.add(FacesMessage.SEVERITY_INFO,
      // resourcesAccessor.getMessages().get("label.relation.created"));
      resetCreateFormValues();
    } else {
      facesMessages.add(
          FacesMessage.SEVERITY_WARN,
          resourcesAccessor.getMessages().get("label.relation.already.exists"));
    }
    return "document_relations";
  }