neo4j 1.0.0.beta.20 → 3.0.0.alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (79) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG +243 -0
  3. data/CONTRIBUTORS +12 -0
  4. data/Gemfile +10 -11
  5. data/README.md +23 -0
  6. data/bin/neo4j-jars +33 -0
  7. data/config/locales/en.yml +5 -0
  8. data/config/neo4j/config.yml +98 -0
  9. data/lib/neo4j.rb +28 -68
  10. data/lib/neo4j/active_node.rb +60 -0
  11. data/lib/neo4j/active_node/callbacks.rb +41 -0
  12. data/lib/neo4j/active_node/has_n.rb +138 -0
  13. data/lib/neo4j/active_node/has_n/decl_rel.rb +236 -0
  14. data/lib/neo4j/active_node/has_n/nodes.rb +82 -0
  15. data/lib/neo4j/active_node/identity.rb +28 -0
  16. data/lib/neo4j/active_node/initialize.rb +24 -0
  17. data/lib/neo4j/active_node/labels.rb +142 -0
  18. data/lib/neo4j/active_node/persistence.rb +193 -0
  19. data/lib/neo4j/active_node/property.rb +41 -0
  20. data/lib/neo4j/active_node/rels.rb +11 -0
  21. data/lib/neo4j/active_node/validations.rb +51 -0
  22. data/lib/neo4j/railtie.rb +40 -0
  23. data/lib/neo4j/version.rb +1 -1
  24. data/lib/neo4j/wrapper.rb +25 -0
  25. data/neo4j.gemspec +25 -15
  26. metadata +136 -149
  27. data/README.rdoc +0 -135
  28. data/lib/generators/neo4j.rb +0 -65
  29. data/lib/generators/neo4j/model/model_generator.rb +0 -39
  30. data/lib/generators/neo4j/model/templates/model.erb +0 -7
  31. data/lib/neo4j/config.rb +0 -153
  32. data/lib/neo4j/database.rb +0 -56
  33. data/lib/neo4j/equal.rb +0 -21
  34. data/lib/neo4j/event_handler.rb +0 -116
  35. data/lib/neo4j/index/class_methods.rb +0 -62
  36. data/lib/neo4j/index/index.rb +0 -33
  37. data/lib/neo4j/index/indexer.rb +0 -312
  38. data/lib/neo4j/index/indexer_registry.rb +0 -68
  39. data/lib/neo4j/index/lucene_query.rb +0 -191
  40. data/lib/neo4j/jars/geronimo-jta_1.1_spec-1.1.1.jar +0 -0
  41. data/lib/neo4j/jars/lucene-core-3.0.2.jar +0 -0
  42. data/lib/neo4j/jars/neo4j-index-1.2-1.2.M03.jar +0 -0
  43. data/lib/neo4j/jars/neo4j-kernel-1.2-1.2.M03.jar +0 -0
  44. data/lib/neo4j/jars/neo4j-lucene-index-0.2-1.2.M03.jar +0 -0
  45. data/lib/neo4j/load.rb +0 -21
  46. data/lib/neo4j/mapping/class_methods/init_node.rb +0 -50
  47. data/lib/neo4j/mapping/class_methods/init_rel.rb +0 -35
  48. data/lib/neo4j/mapping/class_methods/property.rb +0 -80
  49. data/lib/neo4j/mapping/class_methods/relationship.rb +0 -90
  50. data/lib/neo4j/mapping/class_methods/root.rb +0 -31
  51. data/lib/neo4j/mapping/class_methods/rule.rb +0 -295
  52. data/lib/neo4j/mapping/decl_relationship_dsl.rb +0 -214
  53. data/lib/neo4j/mapping/has_n.rb +0 -83
  54. data/lib/neo4j/mapping/node_mixin.rb +0 -97
  55. data/lib/neo4j/mapping/relationship_mixin.rb +0 -117
  56. data/lib/neo4j/model.rb +0 -4
  57. data/lib/neo4j/neo4j.rb +0 -95
  58. data/lib/neo4j/node.rb +0 -131
  59. data/lib/neo4j/node_mixin.rb +0 -4
  60. data/lib/neo4j/node_relationship.rb +0 -149
  61. data/lib/neo4j/node_traverser.rb +0 -157
  62. data/lib/neo4j/property.rb +0 -111
  63. data/lib/neo4j/rails/finders.rb +0 -121
  64. data/lib/neo4j/rails/lucene_connection_closer.rb +0 -19
  65. data/lib/neo4j/rails/mapping/property.rb +0 -35
  66. data/lib/neo4j/rails/model.rb +0 -324
  67. data/lib/neo4j/rails/railtie.rb +0 -16
  68. data/lib/neo4j/rails/transaction.rb +0 -67
  69. data/lib/neo4j/rails/tx_methods.rb +0 -15
  70. data/lib/neo4j/rails/validations/non_nil.rb +0 -11
  71. data/lib/neo4j/rails/validations/uniqueness.rb +0 -31
  72. data/lib/neo4j/rails/value.rb +0 -124
  73. data/lib/neo4j/rails/value_properties.rb +0 -29
  74. data/lib/neo4j/relationship.rb +0 -169
  75. data/lib/neo4j/relationship_mixin.rb +0 -4
  76. data/lib/neo4j/relationship_traverser.rb +0 -92
  77. data/lib/neo4j/to_java.rb +0 -31
  78. data/lib/neo4j/transaction.rb +0 -68
  79. data/lib/neo4j/type_converters.rb +0 -98
data/README.rdoc DELETED
@@ -1,135 +0,0 @@
1
- == Welcome to Neo4j.rb
2
-
3
- Neo4j.rb is a graph database for JRuby.
4
-
5
- You can think of \Neo4j as a high-performance graph engine with all the features of a mature and robust database.
6
- The programmer works with an object-oriented, flexible network structure rather than with strict and static tables — yet enjoys all the benefits of a fully transactional, enterprise-strength database.
7
-
8
- It uses two powerful and mature Java libraries:
9
- * {Neo4J}[http://www.neo4j.org] - for persistence and traversal of the graph
10
- * {Lucene}[http://lucene.apache.org/java/docs/index.html] for querying and indexing.
11
-
12
- === Why Neo4j.rb or a Graph Database ?
13
-
14
- Here are some of the major benefits of Neo4j.rb
15
-
16
- * Domain Modeling - use the language of a graph (nodes/relationship/properties) to express your domain !
17
- * Schema Less and Efficient storage of Semi Structured Information
18
- * No {O/R mismatch}[http://en.wikipedia.org/wiki/Object-relational_impedance_mismatch] - very natural to map a graph to an \Object Oriented language like Ruby.
19
- * {Performance}[http://www.oscon.com/oscon2009/public/schedule/detail/8364]
20
- * Embedded Database - no database tier, easier to install, test, deploy and configure. It is run in the same process as your application.
21
- * Express Queries as Traversals
22
- * Fast deep traversal instead of slow SQL queries that span many table joins.
23
- * Very natural to express graph related problem with traversals (recommendation engine, find shortest parth etc..)
24
- * Seamless integration with Ruby on \Rails.
25
- * ACID Transaction with rollbacks support.
26
-
27
- === Documentation
28
-
29
- * {API Documentation}[http://neo4j.rubyforge.org]
30
- * {Documentation and Getting Started with Neo4j}[http://neo4j.rubyforge.org/guides/index.html]
31
-
32
- === Some Examples
33
-
34
- ==== Neo4j::Node
35
-
36
- Example of creating a Neo4j::Node
37
-
38
- require "rubygems"
39
- require 'neo4j'
40
-
41
- Neo4j::Transaction.run do
42
- node = Neo4j::Node.new (:name => 'andreas')
43
- node.outgoing(:friends) << Neo4j::Node.new (:name => 'peter')
44
- node.outgoing(:friends).each {|node| puts "name #{node[:name]}"}
45
- end
46
-
47
- ==== Neo4j::Mapping::NodeMixin
48
-
49
- Example of mapping a ruby class to a node and delaring properties and relationships and lucene index.
50
-
51
- class Person
52
- include Neo4j::NodeMixin
53
- property :name
54
- property :city
55
-
56
- has_n :friends
57
- has_one :address
58
- index :name
59
- end
60
-
61
- # assume we have an transaction already running
62
- andreas = Person.new (:name => 'andreas')
63
- andreas.friends << Person.new (:name => 'peter')
64
- andreas.friends.each {|person| puts "name #{person.name}" }
65
- Person.find("name: andreas").first.name # => 'andreas'
66
-
67
- ==== Neo4j::Rails::Model
68
-
69
- Example of using Neo4j with Rails 3 (ActiveModel)
70
-
71
- class User < Neo4j::Model
72
- attr_accessor :password
73
- attr_accessible :email, :password, :password_confirmation, :pending_account
74
-
75
- after_save :encrypt_password
76
-
77
- email_regex = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i
78
-
79
- property :email
80
- index :email
81
-
82
- has_one(:avatar).to(Avator)
83
-
84
- validates :email, :presence => true,:format => { :with => email_regex }
85
- validates :email, :uniqueness => true, :unless => :pending_account?
86
- accepts_nested_attributes_for :avatar, :allow_destroy => true
87
-
88
- ...
89
- end
90
-
91
- ==== Generate a Rails Application
92
-
93
- Example of creating an Neo4j Application from scratch:
94
-
95
- gem install rails
96
- rails new myapp -m http://andreasronge.github.com/rails3.rb
97
- cd myapp
98
- bundle
99
- rails generate scaffold User name:string email:string
100
- rails s
101
- open a webbrowser: http://localhost:3000/users
102
-
103
- You may get an error message "ERROR IOError: Connection reset by peer"
104
- using WEBrick (it still works). This error message is not shown when running
105
- the application with {Tomcat/Trinidad}[https://github.com/calavera/trinidad]
106
-
107
- To run it with Tomcat
108
-
109
- gem install trinidad
110
- trinidad
111
-
112
-
113
- === Presentation Materials and other URLs
114
- * {Intoduction to Neo4j.rb}[http://www.slideshare.net/andreasronge/neo4jrb]
115
- * {Nordic Ruby 2010 May 21-23}[http://nordicruby.org/speakers#user_29]
116
- * {Neo4j wiki, check the guidelines and domain modeling gallery pages}[http://wiki.neo4j.org/content/Main_Page]
117
-
118
- === Project information
119
- * {GitHub}[http://github.com/andreasronge/neo4j/tree/master]
120
- * {Lighthouse Issue Tracking}[http://neo4j.lighthouseapp.com]
121
- * {Twitter}[http://twitter.com/ronge]
122
- * IRC - #neo4j @ irc.freenode.net
123
- * {Mailing list, neo4jrb@googlegroups.com}[http://groups.google.com/group/neo4jrb]
124
-
125
- === Contributing
126
-
127
- Have you found a bug, need help or have a patch ?
128
- Just clone neo4j.rb and send me a pull request or email me.
129
- Do you need help - send me an email (andreas.ronge at gmail dot com).
130
- Please also check/add issues at lighthouse, http://neo4j.lighthouseapp.com
131
-
132
- === License
133
- * Neo4j.rb - MIT, see the LICENSE file http://github.com/andreasronge/neo4j/tree/master/LICENSE.
134
- * Lucene - Apache, see http://lucene.apache.org/java/docs/features.html
135
- * \Neo4j - Dual free software/commercial license, see http://neo4j.org/
@@ -1,65 +0,0 @@
1
- require 'rails/generators/named_base'
2
- require 'rails/generators/active_model'
3
-
4
- module Neo4j
5
- module Generators
6
- end
7
- end
8
-
9
- class Neo4j::Generators::Base < Rails::Generators::NamedBase #:nodoc:
10
- def self.source_root
11
- @_neo4j_source_root ||= File.expand_path(File.join(File.dirname(__FILE__),
12
- 'neo4j', generator_name, 'templates'))
13
- end
14
- end
15
-
16
- class Neo4j::Generators::ActiveModel < Rails::Generators::ActiveModel #:nodoc:
17
- def self.all(klass)
18
- "#{klass}.all"
19
- end
20
-
21
- def self.find(klass, params=nil)
22
- "#{klass}.find(#{params})"
23
- end
24
-
25
- def self.build(klass, params=nil)
26
- if params
27
- "#{klass}.new(#{params})"
28
- else
29
- "#{klass}.new"
30
- end
31
- end
32
-
33
- def save
34
- "#{name}.save"
35
- end
36
-
37
- def update_attributes(params=nil)
38
- "#{name}.update_attributes(#{params})"
39
- end
40
-
41
- def errors
42
- "#{name}.errors"
43
- end
44
-
45
- def destroy
46
- "#{name}.destroy"
47
- end
48
- end
49
-
50
- module Rails
51
- module Generators
52
- class GeneratedAttribute #:nodoc:
53
- def type_class
54
- case type.to_s.downcase
55
- when 'datetime' then 'DateTime'
56
- when 'date' then 'Date'
57
- when 'text' then 'String'
58
- when 'integer', 'number', 'fixnum' then 'Fixnum'
59
- when 'float' then 'Float'
60
- else 'String'
61
- end
62
- end
63
- end
64
- end
65
- end
@@ -1,39 +0,0 @@
1
- require File.join(File.dirname(__FILE__), '..', '..', 'neo4j.rb')
2
-
3
- class Neo4j::Generators::ModelGenerator < Neo4j::Generators::Base
4
- argument :attributes, :type => :array, :default => [], :banner => "field:type field:type"
5
-
6
- check_class_collision
7
-
8
- class_option :timestamps, :type => :boolean
9
- class_option :parent, :type => :string, :desc => "The parent class for the generated model"
10
-
11
- def create_model_file
12
- template "model.erb", File.join('app/models', "#{singular_name}.rb")
13
- end
14
-
15
- protected
16
- def migration?
17
- false
18
- end
19
-
20
- def timestamps?
21
- options[:timestamps]
22
- end
23
-
24
- def parent?
25
- options[:parent]
26
- end
27
-
28
- def timestamp_statements
29
- %q{
30
- property :created_at, DateTime
31
- # property :created_on, Date
32
-
33
- property :updated_at, DateTime
34
- # property :updated_on, Date
35
- }
36
- end
37
-
38
- hook_for :test_framework
39
- end
@@ -1,7 +0,0 @@
1
- class <%= class_name %> < <%= parent? ? options[:parent].classify : "Neo4j::Rails::Model" %>
2
- <% attributes.each do |attribute| -%>
3
- property :<%= attribute.name %><%= ", :type => #{attribute.type_class}" %>
4
- <% end -%>
5
-
6
- <%= timestamp_statements if timestamps? -%>
7
- end
data/lib/neo4j/config.rb DELETED
@@ -1,153 +0,0 @@
1
-
2
- module Neo4j
3
-
4
-
5
- # == Keeps configuration for neo4j
6
- #
7
- # The most important configuration is <tt>Neo4j::Config[:storage_path]</tt> which is used to
8
- # locate where the neo4j database is stored on the filesystem.
9
- # If this directory is empty then a new database will be created, otherwise it will use the
10
- # database from that directory.
11
- #
12
- # ==== Default Configurations
13
- # <tt>:storage_path</tt>:: default <tt>tmp/neo4j</tt> where the database is stored
14
- # <tt>:timestamps</tt>:: default <tt>true</tt> for Rails Neo4j::Model - if timestamps should be used when saving the model
15
- # <tt>:lucene</tt>:: default hash keys: <tt>:fulltext</tt>, <tt>:exact</tt> configuration how the lucene index is stored
16
- # <tt>:converters</tt>:: defines which converters should be used before writing and reading to neo4j, see Neo4j::TypeConverters
17
- #
18
- class Config
19
- # This code is copied from merb-core/config.rb.
20
- class << self
21
- # Returns the hash of default config values for neo4j
22
- #
23
- # ==== Returns
24
- # Hash:: The defaults for the config.
25
- def defaults
26
- @defaults ||= {
27
- :storage_path => 'tmp/neo4j',
28
- :timestamps => true,
29
-
30
- # TODO: Just pickup all converter classes that are in the Neo4j::TypeConverters module?
31
- :converters => { Date => Neo4j::TypeConverters::DateConverter,
32
- DateTime => Neo4j::TypeConverters::DateTimeConverter,
33
- Time => Neo4j::TypeConverters::TimeConverter
34
- },
35
-
36
- :lucene => {
37
- :fulltext => {"provider" => "lucene", "type" => "fulltext" },
38
- :exact => {"provider" => "lucene", "type" => "exact" }}
39
- }
40
- end
41
-
42
-
43
- # Yields the configuration.
44
- #
45
- # ==== Block parameters
46
- # c :: The configuration parameters, a hash.
47
- #
48
- # ==== Examples
49
- # Neo4j::Config.use do |config|
50
- # config[:storage_path] = '/var/neo4j'
51
- # end
52
- #
53
- # ==== Returns
54
- # nil
55
- def use
56
- @configuration ||= {}
57
- yield @configuration
58
- nil
59
- end
60
-
61
-
62
- # Set the value of a config entry.
63
- #
64
- # ==== Parameters
65
- # key :: The key to set the parameter for.
66
- # val :: The value of the parameter.
67
- #
68
- def []=(key, val)
69
- (@configuration ||= setup)[key] = val
70
- end
71
-
72
-
73
- # Gets the the value of a config entry
74
- #
75
- # ==== Parameters
76
- # key:: The key of the config entry value we want
77
- #
78
- def [](key)
79
- (@configuration ||= setup)[key]
80
- end
81
-
82
-
83
- # Remove the value of a config entry.
84
- #
85
- # ==== Parameters
86
- # key<Object>:: The key of the parameter to delete.
87
- #
88
- # ==== Returns
89
- # The value of the removed entry.
90
- #
91
- def delete(key)
92
- @configuration.delete(key)
93
- end
94
-
95
-
96
- # Remove all configuration. This can be useful for testing purpose.
97
- #
98
- #
99
- # ==== Returns
100
- # nil
101
- #
102
- def delete_all
103
- @configuration = nil
104
- end
105
-
106
-
107
- # Retrieve the value of a config entry, returning the provided default if the key is not present
108
- #
109
- # ==== Parameters
110
- # key:: The key to retrieve the parameter for.
111
- # default::The default value to return if the parameter is not set.
112
- #
113
- # ==== Returns
114
- # The value of the configuration parameter or the default.
115
- #
116
- def fetch(key, default)
117
- @configuration.fetch(key, default)
118
- end
119
-
120
- # Sets up the configuration
121
- #
122
- # ==== Returns
123
- # The configuration as a hash.
124
- #
125
- def setup()
126
- @configuration = {}
127
- @configuration.merge!(defaults)
128
- @configuration
129
- end
130
-
131
-
132
- # Returns the configuration as a hash.
133
- #
134
- # ==== Returns
135
- # The config as a hash.
136
- #
137
- def to_hash
138
- @configuration
139
- end
140
-
141
- # Returns the config as YAML.
142
- #
143
- # ==== Returns
144
- # The config as YAML.
145
- #
146
- def to_yaml
147
- require "yaml"
148
- @configuration.to_yaml
149
- end
150
- end
151
- end
152
-
153
- end
@@ -1,56 +0,0 @@
1
- module Neo4j
2
- class Database #:nodoc:
3
- attr_reader :graph, :lucene, :event_handler
4
-
5
- def initialize()
6
- @event_handler = EventHandler.new
7
- end
8
-
9
-
10
- def start
11
- @graph = org.neo4j.kernel.EmbeddedGraphDatabase.new(Config[:storage_path])
12
- @lucene = @graph.index #org.neo4j.index.impl.lucene.LuceneIndexProvider.new
13
- @graph.register_transaction_event_handler(@event_handler)
14
- @running = true
15
- @event_handler.neo4j_started(self)
16
- at_exit { shutdown }
17
- end
18
-
19
- def shutdown
20
- if @running
21
- @graph.unregister_transaction_event_handler(@event_handler)
22
- @event_handler.neo4j_shutdown(self)
23
- @graph.shutdown
24
- @graph = nil
25
- @lucene = nil
26
- end
27
-
28
- @running = false
29
- end
30
-
31
- def running?
32
- @running
33
- end
34
-
35
- def begin_tx
36
- @graph.begin_tx
37
- end
38
-
39
-
40
- def each_node
41
- iter = @graph.all_nodes.iterator
42
- while (iter.hasNext)
43
- yield iter.next.wrapper
44
- end
45
- end
46
-
47
- def _each_node
48
- iter = @graph.all_nodes.iterator
49
- while (iter.hasNext)
50
- yield iter.next
51
- end
52
- end
53
-
54
- end
55
-
56
- end