func (p *mgoPersistenceProvider) loadVersionsByAPI(apiVersion string, graph *cayley.Handle, session *mgo.Session, target common.IServiceRegistry) error {
	var startingNodeID = utils.CreateAPIVersionKey(apiVersion)
	var path = cayley.StartPath(graph, startingNodeID).Out(utils.ContainsVersionRel)
	it := path.BuildIterator()
	for cayley.RawNext(it) {
		var version serviceVersion
		err := session.DB("test").C("serviceVersions").Find(bson.M{"_id": graph.NameOf(it.Result())}).One(&version)
		if err != nil {
			return err
		}
		target.LinkServiceToAPI(version.Service, version.Version, apiVersion)
	}

	return nil
}
func (p *mgoPersistenceProvider) loadVersionsByService(serviceIdentifier string, graph *cayley.Handle, session *mgo.Session, target common.IServiceRegistry) error {
	var startingNodeID = utils.CreateServiceDefinitionKey(serviceIdentifier)
	var path = cayley.StartPath(graph, startingNodeID).Out(utils.ContainsVersionRel)
	it := path.BuildIterator()
	for cayley.RawNext(it) {
		var version serviceVersion
		var serviceVersionNode = graph.NameOf(it.Result())
		err := session.DB("test").C("serviceVersions").Find(bson.M{"_id": serviceVersionNode}).One(&version)
		if err != nil {
			return fmt.Errorf("Cannot find %s in collection 'serviceVersions': %s", serviceVersionNode, err.Error())
		}
		target.AddServiceVersion(serviceIdentifier, version.Version)
	}

	return nil
}
func (p *mgoPersistenceProvider) loadAPIRevisions(session *mgo.Session, target common.IServiceRegistry, graph *cayley.Handle) error {
	result := []apiRevisionDefinition{}
	var err = session.DB("test").C("apiDefinitions").Find(bson.M{}).All(&result)
	if err != nil {
		return err
	}
	for _, e := range result {
		target.AddAPIVersion(e.Version, e.Name)
		err = p.loadVersionsByAPI(e.Version, graph, session, target)
		if err != nil {
			return err
		}
	}

	return nil
}
func (p *mgoPersistenceProvider) loadServiceDefinitions(session *mgo.Session, target common.IServiceRegistry, graph *cayley.Handle) error {
	result := []serviceDefinition{}
	var err = session.DB("test").C("serviceDefinitions").Find(bson.M{}).All(&result)
	if err != nil {
		return err
	}
	for _, e := range result {
		target.AddServiceDefinition(e.Identifier, e.Prefix, e.DisplayName)
		err = p.loadVersionsByService(e.Identifier, graph, session, target)
		if err != nil {
			return err
		}
	}

	return nil
}