| 1 | package Neo4j::Index; | ||
| 2 | use strict; | ||
| 3 | use warnings; | ||
| 4 | |||
| 5 | use 5.10.0; | ||
| 6 | use Moose; | ||
| 7 | |||
| 8 | use Neo4j::REST::Client; | ||
| 9 | |||
| 10 | use JSON; | ||
| 11 | |||
| 12 | |||
| 13 | has 'client' => ( | ||
| 14 | required => 1, | ||
| 15 | isa => 'Neo4j::REST::Client', | ||
| 16 | is => 'ro', | ||
| 17 | ); | ||
| 18 | |||
| 19 | has '_self_endpoint' => ( | ||
| 20 | isa => 'Str', | ||
| 21 | is => 'rw', | ||
| 22 | required => 0, | ||
| 23 | ); | ||
| 24 | |||
| 25 | # TODO use Lucene::QueryParser | ||
| 26 | |||
| 27 | has 'name' => ( | ||
| 28 | isa => 'Str', | ||
| 29 | is => 'rw', | ||
| 30 | ); | ||
| 31 | |||
| 32 | has 'template' => ( | ||
| 33 | isa => 'Str', | ||
| 34 | is => 'rw', | ||
| 35 | ); | ||
| 36 | |||
| 37 | has 'provider' => ( | ||
| 38 | isa => 'Str', | ||
| 39 | is => 'rw', | ||
| 40 | ); | ||
| 41 | |||
| 42 | |||
| 43 | has 'index_type' => ( | ||
| 44 | isa => 'Str', | ||
| 45 | is => 'rw', | ||
| 46 | ); | ||
| 47 | |||
| 48 | with 'Neo4j::Role::REST', 'Neo4j::Role::Data'; | ||
| 49 | |||
| 50 | # with every new Neo4j::Node, we create it on the database | ||
| 51 | sub BUILD { | ||
| 52 | my $self = shift; | ||
| 53 | if ( defined $self->id ) { | ||
| 54 | # I have an ID already! I exist! just retrieve me! | ||
| 55 | $self->get( $self->id ); | ||
| 56 | |||
| 57 | } elsif ( defined $self->_self_endpoint ) { | ||
| 58 | $self->_self_endpoint; | ||
| 59 | $self->get( ( split( '/', $self->_self_endpoint ) )[-1] ); | ||
| 60 | |||
| 61 | } else { | ||
| 62 | $self->create; | ||
| 63 | |||
| 64 | # have to create one from the provided data | ||
| 65 | } | ||
| 66 | } | ||
| 67 | |||
| 68 | sub list_indexes { | ||
| 69 | } | ||
| 70 | |||
| 71 | sub new_index { | ||
| 72 | } | ||
| 73 | |||
| 74 | sub add_to_index { | ||
| 75 | } | ||
| 76 | |||
| 77 | sub delete_from_index { | ||
| 78 | } | ||
| 79 | |||
| 80 | sub exact_match { | ||
| 81 | } | ||
| 82 | |||
| 83 | sub query { | ||
| 84 | } | ||
| 85 | |||
| 86 | 1; |