Beispiel #1
0
// GetOrCreateNode returns a Node, creates one if it does not exist. This method
// overrides the neoism one as there is a bug
func GetOrCreateNode(db *neoism.Database, label, key string, p neoism.Props) (n *neoism.Node, created bool, err error) {
	node, created, err := db.GetOrCreateNode(util.UpperCaseFirst(label), key, p)
	// due to a bug in neoism, label is not added
	// see: https://github.com/jmcvetta/neoism/issues/62
	if created {
		node.AddLabel(util.UpperCaseFirst(label))
	}
	return node, created, err
}
Beispiel #2
0
func (s *state) getEntity(db *neoism.Database, xid string) *neoism.Node {
	p := neoism.Props{"_xid_": xid}
	e, created, err := db.GetOrCreateNode("Entity", "_xid_", p)
	if err != nil {
		glog.Fatal(err)
	}
	if created {
		e.AddLabel("Entity")
		glog.WithFields(logrus.Fields{
			"id":    e.Id(),
			"_xid_": xid,
		}).Debug("Added new entity")
	}
	return e
}
Beispiel #3
0
func createUrls(db *neoism.Database) {
	db.GetOrCreateNode("Url", "address", neoism.Props{"address": "http://www.google.com"})
	db.GetOrCreateNode("Url", "address", neoism.Props{"address": "http://www.yahoo.com"})
	db.GetOrCreateNode("Url", "address", neoism.Props{"address": "http://www.cnn.com"})
}