| 
						
						
						
					 | 
				
			
			 | 
			 | 
			
				@ -1,23 +1,17 @@
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				(ns wanijo.attribute.domain
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				  (:require [clojure.spec.alpha :as spec]
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            [wanijo.specs :as specs]
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            [wanijo.framework.neo4j :as neo4j]))
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				(spec/def ::name
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				  (spec/and string? not-empty))
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				(def types
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				  #{"string" "markdown"})
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				(spec/def ::type
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				  (spec/and string? types))
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				(spec/def ::created-at
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				  (spec/and string? ::neo4j/date-str))
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				(spec/def ::type types)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				(spec/def ::name
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				  (spec/and ::specs/name (complement empty?)))
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				(spec/def ::attribute
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				  (spec/keys ::req-un [::name
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                       ::type
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                       ::created-at]))
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                       ::specs/created-at]))
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				(neo4j/defquery
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				  findy-by-schema
 | 
			
		
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
			
			 | 
			 | 
			
				@ -25,7 +19,6 @@
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				   WHERE s.uuid = {uuid}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				   RETURN a
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				   ORDER BY a.name")
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				(defn find-by-schema! [schema-uuid]
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				  (map :a
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				       (neo4j/exec-query!
 | 
			
		
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
			
			 | 
			 | 
			
				@ -43,7 +36,6 @@
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				      SET a.uuid = {attribute_uuid}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				      SET a.required = {required}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				      SET a.created_at = {created_at}")
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				(defn create-new! [attr schema-uuid user-uuid]
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				  (neo4j/exec-query!
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				   create-new
 | 
			
		
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
			
			 | 
			 | 
			
				@ -59,7 +51,6 @@
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				     SET a.type = {type}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				     SET a.name = {name}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				     SET a.required = {required}")
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				(defn edit! [attr]
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				  (neo4j/exec-query!
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				   edit
 | 
			
		
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
			
			 | 
			 | 
			
				@ -69,7 +60,6 @@
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				  "MATCH (a:attribute)-[c]-()
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				   WHERE a.uuid = {uuid}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				   DELETE c, a")
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				(defn delete-by-uuid! [uuid]
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				  (neo4j/exec-query!
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				   delete-by-uuid
 | 
			
		
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
			
			 | 
			 | 
			
				@ -80,7 +70,6 @@
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				   WHERE a.required = 1
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				   RETURN a
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				   ORDER BY a.name")
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				(defn required! [schema-uuid]
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				  (map :a
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				       (neo4j/exec-query! required
 | 
			
		
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
			
			 | 
			 | 
			
				@ -89,7 +78,6 @@
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				(neo4j/defquery schema-of
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				  "MATCH (a:attribute {uuid:{uuid}})-[:of]->(s:schema)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				   RETURN s")
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				(defn schema-of! [uuid]
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				  (->> (neo4j/exec-query! schema-of
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                          {:uuid uuid})
 | 
			
		
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
			
			 | 
			 | 
			
				@ -102,7 +90,6 @@
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				         (a:attribute)-[:of]->(s)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				   RETURN a
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				   ORDER BY a.name")
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				(defn find-by-instance! [instance-uuid]
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				  (map :a
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				       (neo4j/exec-query! find-by-instance
 | 
			
		
		
	
	
		
			
				
					| 
						
							
								
							
						
						
						
					 | 
				
			
			 | 
			 | 
			
				
 
 |