Example #1
0
func toProps(o organisation) neoism.Props {
	p := map[string]interface{}{
		"uuid": o.UUID,
	}

	if o.Extinct == true {
		p["extinct"] = true
	}
	if o.FormerNames != nil && len(o.FormerNames) != 0 {
		p["formerNames"] = o.FormerNames
	}
	if o.HiddenLabel != "" {
		p["hiddenLabel"] = o.HiddenLabel
	}
	if o.LegalName != "" {
		p["legalName"] = o.LegalName
	}
	if o.LocalNames != nil && len(o.LocalNames) != 0 {
		p["localNames"] = o.LocalNames
	}
	if o.ProperName != "" {
		p["properName"] = o.ProperName
	}
	if o.ShortName != "" {
		p["shortName"] = o.ShortName
	}
	if o.TradeNames != nil && len(o.TradeNames) != 0 {
		p["tradeNames"] = o.TradeNames
	}
	p["uuid"] = o.UUID

	return neoism.Props(p)
}
Example #2
0
func (bnc RolesNeoEngine) Write(obj interface{}) error {
	r := obj.(Role)

	p := map[string]interface{}{
		"uuid":         r.UUID,
		"prefLabel":    r.PrefLabel,
		"fsIdentifier": r.Identifier,
	}

	query := &neoism.CypherQuery{
		Statement: `
			MERGE (r:Thing {uuid: {uuid}})
			SET r:Role
			SET r = {props}
                `,
		Parameters: map[string]interface{}{
			"uuid":  r.UUID,
			"props": neoism.Props(p),
		},
	}

	queries := []*neoism.CypherQuery{query}

	return bnc.Cr.CypherBatch(queries)
}
func (eng ContentNeoEngine) createOrUpdateArticle(c Content) error {

	p := map[string]interface{}{
		"uuid":                 c.UUID,
		"headline":             c.Title,
		"title":                c.Title,
		"prefLabel":            c.Title,
		"body":                 c.Body,
		"byline":               c.Byline,
		"publishedDate":        c.PublishedDate,
		"publishedDateEpochMs": c.PublishedDate.Unix(),
	}

	var queries []*neoism.CypherQuery

	stmt := `
		MERGE (c:Thing {uuid: {uuid}})
		SET c = {props}
		SET c :Content
		SET c :Article
		`

	if c.MainImage != "" {
		stmt += `
			MERGE (i:Thing {uuid: {iuuid}})
			MERGE (c)-[r:HAS_MAINIMAGE]->(i)
			`
	}

	queries = append(queries, &neoism.CypherQuery{
		Statement: stmt,
		Parameters: map[string]interface{}{
			"uuid":  c.UUID,
			"props": neoism.Props(p),
			"iuuid": c.MainImage,
		},
	})

	for _, b := range c.Brands {
		queries = append(queries, &neoism.CypherQuery{
			Statement: `
				MERGE (c:Content {uuid: {cuuid}})
				MERGE (b:Thing {uuid: {buuid}})
				MERGE (c)-[r:HAS_BRAND]->(b)
			`,
			Parameters: map[string]interface{}{
				"cuuid": c.UUID,
				"buuid": uriToUUID(b.ID),
			},
		})
	}

	return eng.Cr.CypherBatch(queries)
}
Example #4
0
func (s peopleNeoService) Write(obj interface{}) error {
	o := obj.(Person)

	p := map[string]interface{}{
		"uuid": o.UUID,
	}

	if o.Name != "" {
		p["name"] = o.Name
		p["prefLabel"] = o.Name
	}

	if o.Salutation != "" {
		p["salutation"] = o.Salutation
	}

	if o.BirthYear != 0 {
		p["birthYear"] = o.BirthYear
	}

	for _, identifier := range o.Identifiers {
		if identifier.Authority == "http://api.ft.com/system/FACTSET-PPL" {
			p["factsetIdentifier"] = identifier.IdentifierValue
		}
	}
	p["uuid"] = o.UUID

	parms := map[string]interface{}{
		"uuid":     o.UUID,
		"allProps": neoism.Props(p),
	}

	statement := `
			MERGE (n:Thing {uuid: {uuid}})
			SET n = {allProps}
			SET n :Concept
			SET n :Person
		`

	return s.cr.CypherBatch([]*neoism.CypherQuery{
		&neoism.CypherQuery{Statement: statement, Parameters: parms},
	})
}
Example #5
0
func (bnc RolesNeoEngine) Write(obj interface{}) error {
	o := obj.(Organisation)

	p := map[string]interface{}{
		"uuid": o.UUID,
	}

	if o.Extinct == true {
		p["extinct"] = true
	}
	if o.FormerNames != nil && len(o.FormerNames) != 0 {
		p["formerNames"] = o.FormerNames
	}
	if o.HiddenLabel != "" {
		p["hiddenLabel"] = o.HiddenLabel
	}
	if o.LegalName != "" {
		p["legalName"] = o.LegalName
	}
	if o.LocalNames != nil && len(o.LocalNames) != 0 {
		p["localNames"] = o.LocalNames
	}
	if o.ProperName != "" {
		p["properName"] = o.ProperName
		p["prefLabel"] = o.ProperName
	}
	if o.ShortName != "" {
		p["shortName"] = o.ShortName
	}
	if o.TradeNames != nil && len(o.TradeNames) != 0 {
		p["tradeNames"] = o.TradeNames
	}
	for _, identifier := range o.Identifiers {
		if identifier.Authority == fsAuthority {
			p["factsetIdentifier"] = identifier.IdentifierValue
		}
		if identifier.Authority == leiAuthority {
			p["leiIdentifier"] = identifier.IdentifierValue
		}
	}
	p["uuid"] = o.UUID

	parms := map[string]interface{}{
		"uuid":     o.UUID,
		"allProps": neoism.Props(p),
		"puuid":    o.ParentOrganisation,
		"icuuid":   o.IndustryClassification,
	}

	statement := `
			MERGE (n:Thing {uuid: {uuid}})
			SET n = {allProps}
			SET n :Concept
			SET n :Organisation
		`

	nextType := o.Type
	for nextType != "Organisation" && nextType != "" {
		statement += fmt.Sprintf("SET n :%s\n", nextType)
		nextType = superTypes[nextType]
	}

	if o.ParentOrganisation != "" {
		statement += `
			MERGE (p:Thing {uuid: {puuid}})
			MERGE (n)-[:SUB_ORG_OF]->(p)
		`
	}

	if o.IndustryClassification != "" {
		statement += `
			MERGE (ic:Thing {uuid: {icuuid}})
			MERGE (n)-[:IN_INDUSTRY]->(ic)
		`
	}

	queries := []*neoism.CypherQuery{
		&neoism.CypherQuery{Statement: statement, Parameters: parms},
	}

	return bnc.Cr.CypherBatch(queries)
}