func createAnnotationQuery(contentUUID string, ann annotation, platformVersion string) (*neoism.CypherQuery, error) { query := neoism.CypherQuery{} thingID, err := extractUUIDFromURI(ann.Thing.ID) if err != nil { return nil, err } //todo temporary change to deal with multiple provenances /*if len(ann.Provenances) > 1 { return nil, errors.New("Cannot insert a MENTIONS annotation with multiple provenances") }*/ var prov provenance params := map[string]interface{}{} params["platformVersion"] = platformVersion params["lifecycle"] = "annotations-" + platformVersion if len(ann.Provenances) >= 1 { prov = ann.Provenances[0] annotatedBy, annotatedDateEpoch, relevanceScore, confidenceScore, supplied, err := extractDataFromProvenance(&prov) if err != nil { log.Infof("ERROR=%s", err) return nil, err } if supplied == true { if annotatedBy != "" { params["annotatedBy"] = annotatedBy } if prov.AtTime != "" { params["annotatedDateEpoch"] = annotatedDateEpoch params["annotatedDate"] = prov.AtTime } params["relevanceScore"] = relevanceScore params["confidenceScore"] = confidenceScore } } relation := getRelationshipFromPredicate(ann.Thing.Predicate) query.Statement = createAnnotationRelationship(relation) query.Parameters = map[string]interface{}{ "contentID": contentUUID, "conceptID": thingID, "platformVersion": platformVersion, "annProps": params, } return &query, nil }
func dropAllAnnotationsQuery(contentUUID string, platformVersion string) *neoism.CypherQuery { var matchStmtTemplate string //TODO hard-coded verification: //WE STILL NEED THIS UNTIL EVERYTHNG HAS A LIFECYCLE PROPERTY! // -> necessary for brands - which got written by content-api with isClassifiedBy relationship, and should not be deleted by annotations-rw // -> so far brands are the only v2 concepts which have isClassifiedBy relationship; as soon as this changes: implementation needs to be updated if platformVersion == "v2" { matchStmtTemplate = ` OPTIONAL MATCH (:Thing{uuid:{contentID}})-[r:MENTIONS{platformVersion:{platformVersion}}]->(t:Thing) DELETE r` } else { matchStmtTemplate = ` OPTIONAL MATCH (:Thing{uuid:{contentID}})-[r]->(t:Thing) WHERE r.platformVersion={platformVersion} DELETE r` } query := neoism.CypherQuery{} query.Statement = matchStmtTemplate query.Parameters = neoism.Props{"contentID": contentUUID, "platformVersion": platformVersion} return &query }