Skip to content

Commit

Permalink
changed all relation schemas, memory and sql tests passing
Browse files Browse the repository at this point in the history
  • Loading branch information
gbuisson committed Mar 10, 2016
1 parent 02557e7 commit f089a28
Show file tree
Hide file tree
Showing 4 changed files with 149 additions and 129 deletions.
38 changes: 14 additions & 24 deletions src/cia/schemas/relationships.clj
Original file line number Diff line number Diff line change
Expand Up @@ -22,46 +22,36 @@
(s/optional-key :relationship) s/Str}
reference-map))

(defn relation [string-type map-type]
(s/conditional
map? map-type
:else string-type))

(s/defschema RelatedIndicators
[(relation IndicatorReference
(enriched-ref {:indicator IndicatorReference}))])
[(enriched-ref {:indicator_id IndicatorReference})])

(s/defschema RelatedActors
[(relation ActorReference
(enriched-ref {:actor ActorReference}))])
[(enriched-ref {:actor_id ActorReference})])

(s/defschema RelatedCampaigns
[(relation CampaignReference
(enriched-ref {:campaign CampaignReference}))])
[(enriched-ref {:campaign_id CampaignReference})])

(s/defschema RelatedCOAs
[(relation COAReference
(enriched-ref {:COA COAReference}))])
[(enriched-ref {:COA_id COAReference})])

(s/defschema RelatedExploitTargets
[(relation ExploitTargetReference
(enriched-ref {:exploit_target ExploitTargetReference}))])
[(enriched-ref {:exploit_target_id ExploitTargetReference})])

(s/defschema RelatedIncidents
[(relation IncidentReference
(enriched-ref {:incident IncidentReference}))])
[(enriched-ref {:incident_id IncidentReference})])

(s/defschema RelatedIndicators
[(relation IndicatorReference
(enriched-ref {:indicator IndicatorReference}))])
[(enriched-ref {:indicator_id IndicatorReference})])

(s/defschema RelatedJudgements
[(relation JudgementReference
(enriched-ref {:judgement JudgementReference}))])
[(enriched-ref {:judgement_id JudgementReference})])

(s/defschema RelatedTTP
(enriched-ref {:ttp TTPReference}))
(enriched-ref {:ttp_id TTPReference}))

(s/defschema RelatedTTPs
[(relation TTPReference
RelatedTTP)])
[(enriched-ref {:ttp_id TTPReference})])

;; (s/defschema RelatedTTPs
;; [(relation TTPReference
;; RelatedTTP)])
4 changes: 2 additions & 2 deletions src/cia/stores/memory.clj
Original file line number Diff line number Diff line change
Expand Up @@ -267,8 +267,8 @@
(filter (fn [indicator]
(some (fn [judgement-relation]
(let [judgement-id (if (map? judgement-relation)
(:judgement judgement-relation)
judgement-relation)]
(:judgement_id judgement-relation)
judgement-relation)]
(contains? judgement-ids judgement-id)))
(:judgements indicator)))
(vals @indicator-state))))
Expand Down
2 changes: 1 addition & 1 deletion src/cia/stores/sql/judgement.clj
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

(def judgement-indicator-relationship-map
{:entity-relationship-key :indicators
:relationship-reference-key :indicator
:relationship-reference-key :indicator_id
:entity-id-key :judgement_id
:other-id-key :indicator_id})

Expand Down
Loading

0 comments on commit f089a28

Please sign in to comment.