Skip to content

Commit

Permalink
* fix dependency conflicts
Browse files Browse the repository at this point in the history
* use titan-api 0.4.0
  • Loading branch information
Ruben Weijers committed Apr 10, 2014
1 parent 2a179f5 commit abf6972
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 26 deletions.
3 changes: 2 additions & 1 deletion project.clj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
[clojurewerkz/support "0.15.0"]
[com.thinkaurelius.titan/titan-all "0.4.2"]
[potemkin "0.3.4"]
[clojurewerkz/ogre "2.3.0.1"]
[com.tinkerpop.blueprints/blueprints-core "2.4.0"]
[clojurewerkz/ogre "2.3.0.1" :exclusions [com.tinkerpop.blueprints/blueprints-core]]
[clojurewerkz/archimedes "1.0.0-alpha4"]]
:source-paths ["src/clojure"]
:java-source-paths ["src/java"]
Expand Down
53 changes: 29 additions & 24 deletions src/clojure/clojurewerkz/titanium/types.clj
Original file line number Diff line number Diff line change
Expand Up @@ -29,64 +29,69 @@
[type-maker unique-direction unique-locked]
(when unique-direction
(when (#{:both :in} unique-direction)
(.unique type-maker
Direction/IN
(.unique type-maker
Direction/IN
(convert-bool-to-lock unique-locked)))
(when (#{:both :out} unique-direction)
(.unique type-maker
Direction/OUT
(.unique type-maker
Direction/OUT
(convert-bool-to-lock unique-locked)))))

(defn deflabel
"Creates a edge label with the given properties."
([tname] (deflabel tname {}))
([tname {:keys [simple direction primary-key signature
unique-direction unique-locked group]
unique-direction unique-locked]
:or {direction "directed"
primary-key nil
signature nil
unique-direction false
type :m->m ; :m->1 :1->1 :1->m
unique-locked true}}]
(ensure-graph-is-transaction-safe)
(let [type-maker (.. (get-graph)
makeType
(name (name tname))
(group group))]
(unique-direction-converter type-maker unique-direction unique-locked)
(makeLabel (name (name tname))))]
(case type
:m->m (.manyToMany type-maker)
:m->1 (.manyToOne type-maker (convert-bool-to-lock unique-locked))
:1->1 (.oneToOne type-maker (convert-bool-to-lock unique-locked))
:1->m (.oneToMany type-maker (convert-bool-to-lock unique-locked))
nil)
(case direction
"directed" (.directed type-maker)
"unidirected" (.unidirected type-maker))
(when signature (.signature type-maker signature))
(when primary-key (.primaryKey type-maker (into-array TitanType primary-key)))
(.makeEdgeLabel type-maker))))
(when primary-key (.sortKey type-maker (into-array TitanType primary-key)))
(.make type-maker))))

(defn defkey
"Creates a property key with the given properties."
([tname data-type] (defkey tname data-type {}))
([tname data-type {:keys [unique-direction
unique-locked
group
([tname data-type {:keys [type ; :unique / :single / nil ; TODO add support for Keymaker.list
unique-locked
indexed-vertex?
indexed-edge?
searchable?]
:or {unique-direction false
unique-locked true}}]
:or {type nil
unique-locked true}}]
(ensure-graph-is-transaction-safe)
(let [type-maker (.. (get-graph)
makeType
(name (name tname))
(group group)
(makeKey (name (name tname)))
(dataType data-type))]
(when indexed-vertex?
(when indexed-vertex?
(if searchable?
(.indexed type-maker "search" Vertex)
(.indexed type-maker Vertex)))
(when indexed-edge?
(when indexed-edge?
(if searchable?
(.indexed type-maker "search" Edge)
(.indexed type-maker Edge)))
(unique-direction-converter type-maker unique-direction unique-locked)
(.makePropertyKey type-maker))))

(case type
:unique (.unique type-maker (convert-bool-to-lock unique-locked))
:single (.single type-maker (convert-bool-to-lock unique-locked))
:list (.list type-maker)
nil)
(.make type-maker))))

(defn deflabel-once
"Checks to see if a edge label with the given name exists already.
Expand Down
2 changes: 1 addition & 1 deletion test/clojurewerkz/titanium/graph_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
(testing "Dueling transactions"
(tg/transact!
(tt/defkey-once :vertex-id Long {:indexed-vertex? true
:unique-direction :both}))
:type :unique}))
(testing "Without retries"
(let [random-long (long (rand-int 100000))
f1 (future (tg/transact! (tv/upsert! :vertex-id {:vertex-id random-long})))
Expand Down

0 comments on commit abf6972

Please sign in to comment.