neo4j 1.0.0.beta.21-java
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +141 -0
- data/CONTRIBUTORS +17 -0
- data/Gemfile +16 -0
- data/README.rdoc +135 -0
- data/lib/generators/neo4j.rb +65 -0
- data/lib/generators/neo4j/model/model_generator.rb +39 -0
- data/lib/generators/neo4j/model/templates/model.erb +7 -0
- data/lib/neo4j.rb +77 -0
- data/lib/neo4j/config.rb +153 -0
- data/lib/neo4j/database.rb +56 -0
- data/lib/neo4j/equal.rb +21 -0
- data/lib/neo4j/event_handler.rb +116 -0
- data/lib/neo4j/index/class_methods.rb +62 -0
- data/lib/neo4j/index/index.rb +33 -0
- data/lib/neo4j/index/indexer.rb +312 -0
- data/lib/neo4j/index/indexer_registry.rb +68 -0
- data/lib/neo4j/index/lucene_query.rb +191 -0
- data/lib/neo4j/jars/geronimo-jta_1.1_spec-1.1.1.jar +0 -0
- data/lib/neo4j/jars/lucene-core-3.0.2.jar +0 -0
- data/lib/neo4j/jars/neo4j-index-1.2-1.2.M03.jar +0 -0
- data/lib/neo4j/jars/neo4j-kernel-1.2-1.2.M03.jar +0 -0
- data/lib/neo4j/jars/neo4j-lucene-index-0.2-1.2.M03.jar +0 -0
- data/lib/neo4j/load.rb +21 -0
- data/lib/neo4j/mapping/class_methods/init_node.rb +50 -0
- data/lib/neo4j/mapping/class_methods/init_rel.rb +35 -0
- data/lib/neo4j/mapping/class_methods/list.rb +13 -0
- data/lib/neo4j/mapping/class_methods/property.rb +82 -0
- data/lib/neo4j/mapping/class_methods/relationship.rb +91 -0
- data/lib/neo4j/mapping/class_methods/rule.rb +295 -0
- data/lib/neo4j/mapping/decl_relationship_dsl.rb +214 -0
- data/lib/neo4j/mapping/has_list.rb +134 -0
- data/lib/neo4j/mapping/has_n.rb +83 -0
- data/lib/neo4j/mapping/node_mixin.rb +112 -0
- data/lib/neo4j/mapping/relationship_mixin.rb +120 -0
- data/lib/neo4j/model.rb +4 -0
- data/lib/neo4j/neo4j.rb +95 -0
- data/lib/neo4j/node.rb +131 -0
- data/lib/neo4j/node_mixin.rb +4 -0
- data/lib/neo4j/node_relationship.rb +149 -0
- data/lib/neo4j/node_traverser.rb +157 -0
- data/lib/neo4j/property.rb +111 -0
- data/lib/neo4j/rails/attributes.rb +155 -0
- data/lib/neo4j/rails/callbacks.rb +34 -0
- data/lib/neo4j/rails/finders.rb +134 -0
- data/lib/neo4j/rails/lucene_connection_closer.rb +19 -0
- data/lib/neo4j/rails/mapping/property.rb +60 -0
- data/lib/neo4j/rails/model.rb +105 -0
- data/lib/neo4j/rails/persistence.rb +260 -0
- data/lib/neo4j/rails/railtie.rb +21 -0
- data/lib/neo4j/rails/relationships/mapper.rb +96 -0
- data/lib/neo4j/rails/relationships/relationship.rb +30 -0
- data/lib/neo4j/rails/relationships/relationships.rb +60 -0
- data/lib/neo4j/rails/serialization.rb +25 -0
- data/lib/neo4j/rails/timestamps.rb +65 -0
- data/lib/neo4j/rails/transaction.rb +67 -0
- data/lib/neo4j/rails/tx_methods.rb +15 -0
- data/lib/neo4j/rails/validations.rb +38 -0
- data/lib/neo4j/rails/validations/non_nil.rb +11 -0
- data/lib/neo4j/rails/validations/uniqueness.rb +37 -0
- data/lib/neo4j/relationship.rb +169 -0
- data/lib/neo4j/relationship_mixin.rb +4 -0
- data/lib/neo4j/relationship_traverser.rb +92 -0
- data/lib/neo4j/to_java.rb +31 -0
- data/lib/neo4j/transaction.rb +68 -0
- data/lib/neo4j/type_converters.rb +117 -0
- data/lib/neo4j/version.rb +3 -0
- data/lib/orm_adapter/adapters/neo4j.rb +55 -0
- data/lib/tmp/neo4j/active_tx_log +1 -0
- data/lib/tmp/neo4j/index/lucene-store.db +0 -0
- data/lib/tmp/neo4j/index/lucene.log.active +0 -0
- data/lib/tmp/neo4j/lucene-fulltext/lucene-store.db +0 -0
- data/lib/tmp/neo4j/lucene-fulltext/lucene.log.active +0 -0
- data/lib/tmp/neo4j/lucene/lucene-store.db +0 -0
- data/lib/tmp/neo4j/lucene/lucene.log.active +0 -0
- data/lib/tmp/neo4j/messages.log +85 -0
- data/lib/tmp/neo4j/neostore +0 -0
- data/lib/tmp/neo4j/neostore.id +0 -0
- data/lib/tmp/neo4j/neostore.nodestore.db +0 -0
- data/lib/tmp/neo4j/neostore.nodestore.db.id +0 -0
- data/lib/tmp/neo4j/neostore.propertystore.db +0 -0
- data/lib/tmp/neo4j/neostore.propertystore.db.arrays +0 -0
- data/lib/tmp/neo4j/neostore.propertystore.db.arrays.id +0 -0
- data/lib/tmp/neo4j/neostore.propertystore.db.id +0 -0
- data/lib/tmp/neo4j/neostore.propertystore.db.index +0 -0
- data/lib/tmp/neo4j/neostore.propertystore.db.index.id +0 -0
- data/lib/tmp/neo4j/neostore.propertystore.db.index.keys +0 -0
- data/lib/tmp/neo4j/neostore.propertystore.db.index.keys.id +0 -0
- data/lib/tmp/neo4j/neostore.propertystore.db.strings +0 -0
- data/lib/tmp/neo4j/neostore.propertystore.db.strings.id +0 -0
- data/lib/tmp/neo4j/neostore.relationshipstore.db +0 -0
- data/lib/tmp/neo4j/neostore.relationshipstore.db.id +0 -0
- data/lib/tmp/neo4j/neostore.relationshiptypestore.db +0 -0
- data/lib/tmp/neo4j/neostore.relationshiptypestore.db.id +0 -0
- data/lib/tmp/neo4j/neostore.relationshiptypestore.db.names +0 -0
- data/lib/tmp/neo4j/neostore.relationshiptypestore.db.names.id +0 -0
- data/lib/tmp/neo4j/nioneo_logical.log.active +0 -0
- data/lib/tmp/neo4j/tm_tx_log.1 +0 -0
- data/neo4j.gemspec +31 -0
- metadata +216 -0
data/CHANGELOG
ADDED
@@ -0,0 +1,141 @@
|
|
1
|
+
== 0.4.4 / 2010-08-01
|
2
|
+
* Fixed bug on traversing when using the RelationshipMixin (#121)
|
3
|
+
* BatchInserter and JRuby 1.6 - Fix iteration error with trying to modify in-place hash
|
4
|
+
|
5
|
+
== 0.4.3 / 2010-04-10
|
6
|
+
* Fixed .gitignore - make sure that we do not include unnecessarily files like neo4j databases. Release 0.4.2 contained test data.
|
7
|
+
* Added synchronize around Index.new so that two thread can't modify the same index at the same time.
|
8
|
+
|
9
|
+
== 0.4.2 / 2010-04-08
|
10
|
+
* No index on properties for the initialize method bug (#116)
|
11
|
+
* Tidy up Thread Synchronization in Lucene wrapper - lucene indexing performance improvement (#117)
|
12
|
+
* Permission bug loading neo4j jar file (#118)
|
13
|
+
* Spike: Make NodeMixin ActiveModel complient - experimental (#115)
|
14
|
+
|
15
|
+
== 0.4.1 / 2010-03-11
|
16
|
+
* Migrations (#108)
|
17
|
+
* BatchInserter (#111)
|
18
|
+
* Neo4j::Relationship.new should take a hash of properties (#110)
|
19
|
+
* Upgrade to neo4j-1.0 (#114)
|
20
|
+
* Bigfix: has_one should replace old relationship (#106)
|
21
|
+
* Bugfix: custom accessors for NodeMixin#update (#113)
|
22
|
+
* Bugfix: Indexed properties problem on extented ruby classes critical "properties indexer" (#112)
|
23
|
+
|
24
|
+
== 0.4.0 / 2010-02-06
|
25
|
+
* Performance improvements and Refactoring: Use and Extend Neo4j Java Classes (#97)
|
26
|
+
* Support for Index and Declaration of Properties on Relationships (#91)
|
27
|
+
* Upgrade to neo4j-1.0 rc (#100)
|
28
|
+
* All internal properties should be prefix with a '_',0.4.0 (#105)
|
29
|
+
* Generate relationship accessor methods for declared has_n and has_one relationships (#104)
|
30
|
+
* New way of creating relationship - Neo4j::Relationship.new (#103)
|
31
|
+
* Neo4j#init_node method should take one or more args (#98)
|
32
|
+
* Namespaced relationships: has_one...from using the wrong has_n...to(#92)
|
33
|
+
* Neo4j::NodeMixin and Neo4j::Node should allow a hash for initialization (#99)
|
34
|
+
|
35
|
+
== 0.3.3 / 2009-11-25
|
36
|
+
* Support for a counter property on has_lists (#75)
|
37
|
+
* Support for Cascade delete. On has_n, had_one and has_list (#81)
|
38
|
+
* NodeMixin#all should work with inheritance - Child classes should have a relationship of their own. (#64)
|
39
|
+
* Support for other lucene analyzer then StandardAnalyzer (#87)
|
40
|
+
* NodeMixin initialize should accept block like docs (#82)
|
41
|
+
* Add incoming relationship should work as expected: n1.relationships.incoming(:foo) << n2 (#80)
|
42
|
+
* Delete node from a has_list relationship should work as expected (#79)
|
43
|
+
* Improve stacktraces (#94)
|
44
|
+
* Removed sideeffect of rspecs (#90)
|
45
|
+
* Add debug method on NodeMixin to print it self (#88)
|
46
|
+
* Removed to_a method (#73)
|
47
|
+
* Upgrade to neo4j-1.0b10 (#95)
|
48
|
+
* Upgrade to lucene 2.9.0 (#83)
|
49
|
+
* Refactoring: RSpecs (#74)
|
50
|
+
* Refactoring: aggregate each, renamed to property aggregator (#72)
|
51
|
+
* BugFix: neo4j gem cannot be built from the source (#86)
|
52
|
+
* BugFix: Neo4j::relationship should not raise Exception if there are no relationships (#78)
|
53
|
+
|
54
|
+
== 0.3.2 / 2009-09-17
|
55
|
+
* Added support for aggregating nodes (#65)
|
56
|
+
* Wrapped Neo4j GraphAlgo AllSimplePath (#70)
|
57
|
+
* Added traversal with traversal position (#71)
|
58
|
+
* Removed DynamicAccessors mixin, replaced by [] operator (#67)
|
59
|
+
* Impl Neo4j.all_nodes (#69)
|
60
|
+
* Upgrated Neo4j jar file to 1.0-b9
|
61
|
+
* The Neo4j#relationship method now allows a filter parameter (#66)
|
62
|
+
* Neo4j.rb now can read database not created by Neo4j.rb - does not require classname property (#63)
|
63
|
+
* REST - added an "all" value for the depth traversal query parameter (#62)
|
64
|
+
* REST - Performance improvments using the Rest Mixin (#60)
|
65
|
+
|
66
|
+
== 0.3.1 / 2009-07-25
|
67
|
+
* Feature, extension - find path between given pair of nodes (#58)
|
68
|
+
* Fix a messy exception on GET /nodes/UnknownClassName (#57)
|
69
|
+
* Bug - exception on GET /nodes/classname/rel if rel is a has_one relationship (#56)
|
70
|
+
* Bug: GET /nodes/classname missing out nodes with no properties (#55)
|
71
|
+
* Bug: Lucene sorting caused exception if there were no documents (#54)
|
72
|
+
* Bug: reindexer fails to connect nodes to the IndexNode (#53)
|
73
|
+
|
74
|
+
== 0.3.0 / 2009-06-25
|
75
|
+
* Neo4j should track node changes
|
76
|
+
* RESTful support for lucene queries, sorting and paging
|
77
|
+
* RESTful support for Relationships
|
78
|
+
* RESTful support for Node and properties
|
79
|
+
* Experimental support for Master-Slave Replication via REST
|
80
|
+
* RESTful Node representation should contain hyperlinks to relationships
|
81
|
+
* Added some handy method like first and empty? on relationships
|
82
|
+
* Use new neo4j: neo-1.0-b8
|
83
|
+
* Add an event handler for create/delete nodes start/stop neo, update property/relationship
|
84
|
+
* The NodeMixin should behave like a hash, added [] and []= methods
|
85
|
+
* Support list topology - has_list and belongs_to_list Neo4j::NodeMixin Classmethods
|
86
|
+
* Should be possible to add relationships without declaring them (Neo4j#relationships.outgoing(:friends) << node)
|
87
|
+
* Neo4j extensions file structure, should be easy to create your own extensions
|
88
|
+
* Rename relation to relationship (Neo4j::Relations => Neo4j::Relationships, DynamicRelation => Relationship) [data incompatible change]
|
89
|
+
* Auto Transaction is now optional
|
90
|
+
* Setting Float properties fails under JRuby1.2.0
|
91
|
+
* Bug: Indexing relationships does not work
|
92
|
+
* Make the ReferenceNode include Neo4j::NodeMixin
|
93
|
+
* Added handy Neo4j class that simply includes the Neo4j::NodeMixin
|
94
|
+
* Neo4j::IndexNode now holds references to all nodes (Neo4j.ref_node -> Neo4j::IndexNode -> ...)
|
95
|
+
|
96
|
+
|
97
|
+
== 0.2.1 / 2009-03-15
|
98
|
+
* Refactoring of lucene indexing of the node space (28)
|
99
|
+
* Fixed bug on Neo4j::Nodemixin#property? (#22)
|
100
|
+
|
101
|
+
|
102
|
+
== 0.2.0 / 2009-01-20
|
103
|
+
* Impl. Neo4j::Node#traverse - enables traversal and filtering using TraversalPosition info (#17,#19)
|
104
|
+
* Impl. traversal to any depth (#15)
|
105
|
+
* Impl. traversal several relationships type at the same time (#16)
|
106
|
+
* Fixed a Lucene timezone bug (#20)
|
107
|
+
* Lots of refactoring of the neo4j.rb traversal code and RSpecs
|
108
|
+
|
109
|
+
== 0.1.0 / 2008-12-18
|
110
|
+
* Property can now be of any type (and not only String, Fixnum, Float)
|
111
|
+
* Indexing and Query with Date and DateTime
|
112
|
+
* YARD documentation
|
113
|
+
* Properties can be removed
|
114
|
+
* A property can be set to nil (it will then be removed).
|
115
|
+
|
116
|
+
== 0.0.7 / 2008-12-10
|
117
|
+
* Added method to_param and methods on the value object needed for Ruby on Rails
|
118
|
+
* Impl. update from a value object/hash for a node
|
119
|
+
* Impl. generation of value object classes/instances from a node.
|
120
|
+
* Refactoring the Transaction handling (reuse PlaceboTransaction instances if possible)
|
121
|
+
* Removed the need to start and stop neo. It will be done automatically when needed.
|
122
|
+
|
123
|
+
|
124
|
+
== 0.0.6 / 2008-12-03
|
125
|
+
* Removed the configuration from the Neo4j.start method. Now exist in Neo4j::Config and Lucene::Config.
|
126
|
+
* Implemented sort_by method.
|
127
|
+
* Lazy loading of search result. Execute the query and load the nodes only if needed.
|
128
|
+
* Added support to use lucene query language, example: Person.find("name:foo AND age:42")
|
129
|
+
* All test now uses RAM based lucene indexes.
|
130
|
+
|
131
|
+
== 0.0.5 / 2008-11-17
|
132
|
+
* Supports keeping lucene index in memory instead of on disk
|
133
|
+
* Added support for lucene full text search
|
134
|
+
* Fixed so neo4j runs on JRuby 1.1.5
|
135
|
+
* Implemented support for reindex all instances of a node class. This is needed if the lucene index is kept in memory or if the index is changed.
|
136
|
+
* Added ReferenceNode. All nodes now have a relationship from this reference node.
|
137
|
+
* Lots of refactoring
|
138
|
+
* Added the IMDB example. It shows how to create a neo database, lucene queries and node traversals.
|
139
|
+
|
140
|
+
== 0.0.4 / 2008-10-23
|
141
|
+
* First release to rubyforge
|
data/CONTRIBUTORS
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
Maintainer:
|
2
|
+
Andreas Ronge <andreas dot ronge at gmail dot com>
|
3
|
+
|
4
|
+
Contributors:
|
5
|
+
* Ben Jackson
|
6
|
+
* Dwight van Tuyl
|
7
|
+
* Martin Kleppmann
|
8
|
+
* Peter Neubauer
|
9
|
+
* Jan-Felix Wittmann
|
10
|
+
* Marius Mårnes Mathiesen
|
11
|
+
* Bert Fitié
|
12
|
+
* Jan Berkel
|
13
|
+
* David Beckwith
|
14
|
+
* Johny Ho
|
15
|
+
* Carlo Cabanilla
|
16
|
+
* Anders Janmyr
|
17
|
+
* Nick Sieger
|
data/Gemfile
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
source :gemcutter
|
2
|
+
|
3
|
+
gemspec
|
4
|
+
|
5
|
+
group 'test' do
|
6
|
+
gem "rake", ">= 0.8.7"
|
7
|
+
gem "rdoc", ">= 2.5.10"
|
8
|
+
gem "horo", ">= 1.0.2"
|
9
|
+
gem "rspec", ">= 2.0.0"
|
10
|
+
gem "rspec-rails-matchers", ">= 0.2.1"
|
11
|
+
gem "test-unit"
|
12
|
+
end
|
13
|
+
|
14
|
+
#gem 'ruby-debug-base19' if RUBY_VERSION.include? "1.9"
|
15
|
+
#gem 'ruby-debug-base' if RUBY_VERSION.include? "1.8"
|
16
|
+
#gem "ruby-debug-ide"
|
data/README.rdoc
ADDED
@@ -0,0 +1,135 @@
|
|
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/
|
@@ -0,0 +1,65 @@
|
|
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
|
@@ -0,0 +1,39 @@
|
|
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
|
@@ -0,0 +1,7 @@
|
|
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.rb
ADDED
@@ -0,0 +1,77 @@
|
|
1
|
+
include Java
|
2
|
+
|
3
|
+
require 'enumerator'
|
4
|
+
require 'forwardable'
|
5
|
+
require 'time'
|
6
|
+
require 'date'
|
7
|
+
|
8
|
+
require 'neo4j/jars/neo4j-index-1.2-1.2.M03.jar'
|
9
|
+
require 'neo4j/jars/neo4j-kernel-1.2-1.2.M03.jar'
|
10
|
+
require 'neo4j/jars/neo4j-lucene-index-0.2-1.2.M03.jar'
|
11
|
+
require 'neo4j/jars/geronimo-jta_1.1_spec-1.1.1.jar'
|
12
|
+
require 'neo4j/jars/lucene-core-3.0.2.jar'
|
13
|
+
require 'neo4j/to_java'
|
14
|
+
require 'neo4j/version'
|
15
|
+
require 'neo4j/equal'
|
16
|
+
|
17
|
+
require 'neo4j/event_handler'
|
18
|
+
require 'neo4j/database'
|
19
|
+
require 'neo4j/neo4j'
|
20
|
+
|
21
|
+
require 'neo4j/index/index'
|
22
|
+
require 'neo4j/index/class_methods'
|
23
|
+
require 'neo4j/index/indexer_registry'
|
24
|
+
require 'neo4j/index/indexer'
|
25
|
+
require 'neo4j/index/lucene_query'
|
26
|
+
require 'neo4j/relationship_traverser'
|
27
|
+
require 'neo4j/node_traverser'
|
28
|
+
require 'neo4j/property'
|
29
|
+
require 'neo4j/transaction'
|
30
|
+
require 'neo4j/node_relationship'
|
31
|
+
require 'neo4j/load'
|
32
|
+
require 'neo4j/relationship'
|
33
|
+
require 'neo4j/node'
|
34
|
+
require 'neo4j/config'
|
35
|
+
require 'neo4j/type_converters'
|
36
|
+
require 'neo4j/mapping/class_methods/init_node'
|
37
|
+
require 'neo4j/mapping/class_methods/init_rel'
|
38
|
+
require 'neo4j/mapping/class_methods/property'
|
39
|
+
require 'neo4j/mapping/class_methods/relationship'
|
40
|
+
require 'neo4j/mapping/class_methods/list'
|
41
|
+
require 'neo4j/mapping/decl_relationship_dsl'
|
42
|
+
require 'neo4j/mapping/has_n'
|
43
|
+
require 'neo4j/mapping/has_list'
|
44
|
+
require 'neo4j/mapping/node_mixin'
|
45
|
+
require 'neo4j/mapping/relationship_mixin'
|
46
|
+
require 'neo4j/node_mixin'
|
47
|
+
require 'neo4j/relationship_mixin'
|
48
|
+
require 'neo4j/mapping/class_methods/rule'
|
49
|
+
|
50
|
+
# rails
|
51
|
+
require 'rails/railtie'
|
52
|
+
require 'active_model'
|
53
|
+
require 'neo4j/rails/tx_methods'
|
54
|
+
require 'neo4j/rails/transaction'
|
55
|
+
require 'neo4j/rails/railtie'
|
56
|
+
require 'neo4j/rails/validations/uniqueness'
|
57
|
+
require 'neo4j/rails/validations/non_nil'
|
58
|
+
require 'neo4j/rails/finders'
|
59
|
+
require 'neo4j/rails/mapping/property'
|
60
|
+
require 'neo4j/rails/validations'
|
61
|
+
require 'neo4j/rails/callbacks'
|
62
|
+
require 'neo4j/rails/timestamps'
|
63
|
+
require 'neo4j/rails/serialization'
|
64
|
+
require 'neo4j/rails/attributes'
|
65
|
+
require 'neo4j/rails/persistence'
|
66
|
+
require 'neo4j/rails/relationships/mapper'
|
67
|
+
require 'neo4j/rails/relationships/relationship'
|
68
|
+
require 'neo4j/rails/relationships/relationships'
|
69
|
+
require 'neo4j/rails/model'
|
70
|
+
require 'neo4j/rails/lucene_connection_closer'
|
71
|
+
|
72
|
+
require 'neo4j/model'
|
73
|
+
require 'orm_adapter/adapters/neo4j'
|
74
|
+
|
75
|
+
# hmm, looks like Enumerator have been moved in some ruby versions
|
76
|
+
Enumerator = Enumerable::Enumerator unless defined? Enumerator
|
77
|
+
|