RDF::AllegroGraph::Transaction4 - AllegroGraph transaction handle for AGv4


RDF-AllegroGraph-Easy documentation Contained in the RDF-AllegroGraph-Easy distribution.

Index


Code Index:

NAME

Top

RDF::AllegroGraph::Transaction4 - AllegroGraph transaction handle for AGv4

INTERFACE

Top

Methods (additional to RDF::AllegroGraph::Session4)

commit

Commits all changes done inside the transaction to the underlying model.

NOTE: When the transaction object is still accessible, it will have the same content as the 'mother' session.

rollback

Discards all changes.

NOTE: When the transaction object is still accessible, it will be empty.

AUTHOR

Top

Robert Barta, <rho at devc.at>

COPYRIGHT & LICENSE

Top


RDF-AllegroGraph-Easy documentation Contained in the RDF-AllegroGraph-Easy distribution.
package RDF::AllegroGraph::Transaction4;

use strict;
use warnings;

use base qw(RDF::AllegroGraph::Session4);

use Data::Dumper;
use feature "switch";

use JSON;
use URI::Escape qw/uri_escape_utf8/;

use HTTP::Request::Common;

sub new {
    my $class = shift;
    return bless { @_ }, $class;
}

sub DESTROY {
    my $self = shift;
    $self->rollback;
}

sub commit {
    my $self = shift;
    my $url  = new URI ($self->{path} . '/commit');
    my $resp = $self->{CATALOG}->{SERVER}->{ua}->post ($url);
    die "protocol error: ".$resp->status_line.' ('.$resp->content.')' unless $resp->is_success;
}

sub rollback {
    my $self = shift;
    my $url  = new URI ($self->{path} . '/rollback');
    my $resp = $self->{CATALOG}->{SERVER}->{ua}->post ($url);
    die "protocol error: ".$resp->status_line.' ('.$resp->content.')' unless $resp->is_success;
}

1;

__END__