• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang dsocial.Group类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/pomack/dsocial/go/models/dsocial.Group的典型用法代码示例。如果您正苦于以下问题:Golang Group类的具体用法?Golang Group怎么用?Golang Group使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Group类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: findMatchingDsocialGroup

func (p *Pipeline) findMatchingDsocialGroup(ds DataStoreService, dsocialUserId string, group *Group) (extDsocialGroup *dm.Group, isSame bool, err os.Error) {
	emptyGroup := new(dm.Group)
	if group.DsocialGroupId != "" {
		extDsocialGroup, _, _ = ds.RetrieveDsocialGroup(dsocialUserId, group.DsocialGroupId)
		if extDsocialGroup != nil {
			_, isSame = emptyGroup.IsSimilarOrUpdated(extDsocialGroup, group.Value)
			fmt.Printf("[PIPELINE]: findMatchingDsocialGroup for %s with based on existing group id will use %s and isSame %v\n", group.Value.Name, extDsocialGroup.Name, isSame)
		}
	}
	if extDsocialGroup == nil {
		// this is a new group from an existing service
		potentialMatches, err := ds.SearchForDsocialGroups(dsocialUserId, group.Value.Name)
		if err != nil {
			return nil, false, err
		}
		for _, potentialMatch := range potentialMatches {
			var isSimilar bool
			if isSimilar, isSame = emptyGroup.IsSimilarOrUpdated(potentialMatch, group.Value); isSimilar {
				extDsocialGroup = potentialMatch
				break
			}
		}
		if extDsocialGroup != nil {
			fmt.Printf("[PIPELINE]: findMatchingDsocialGroup for %s was %s and isSame %v\n\tStoring mapping: %s/%s/%s -> %s\n", group.Value.Name, extDsocialGroup.Name, isSame, group.ExternalServiceId, group.ExternalUserId, group.ExternalGroupId, extDsocialGroup.Id)
			_, _, err = ds.StoreDsocialExternalGroupMapping(group.ExternalServiceId, group.ExternalUserId, group.ExternalGroupId, dsocialUserId, extDsocialGroup.Id)
			group.DsocialGroupId = extDsocialGroup.Id
		} else {
			fmt.Printf("[PIPELINE]: findMatchingDsocialGroup cannot find similar for %s\n", group.Value.Name)
		}
	}
	return extDsocialGroup, isSame, err
}
开发者ID:pombredanne,项目名称:dsocial.go,代码行数:32,代码来源:pipeline.go


示例2: AddIdsForDsocialGroup

func AddIdsForDsocialGroup(g *dm.Group, ds DataStoreService, dsocialUserId string) (err os.Error) {
	if g == nil {
		return
	}
	if g.UserId == "" {
		g.UserId = dsocialUserId
	}
	if g.Acl.OwnerId == "" {
		g.Acl.OwnerId = dsocialUserId
	}
	if g.Id == "" {
		g.Id = ds.GenerateId(dsocialUserId, "group")
	}
	return
}
开发者ID:pombredanne,项目名称:dsocial.go,代码行数:15,代码来源:service.go


示例3: StoreDsocialGroupForExternalGroup

// Stores dsocial group
// Returns:
//   dsocialGroup : the group, modified to include items like Id and LastModified/Created
//   err : error or nil
func (p *InMemoryDataStore) StoreDsocialGroupForExternalGroup(externalServiceId, externalUserId, externalGroupId, dsocialUserId string, group *dm.Group) (dsocialGroup *dm.Group, err os.Error) {
	//k := strings.Join([]string{dsocialUserId, externalServiceId, externalUserId, externalGroupId}, "/")
	k := strings.Join([]string{externalServiceId, externalUserId, externalGroupId}, "|")
	if externalServiceId == "" || externalUserId == "" || externalGroupId == "" {
		panic(fmt.Sprintf("One of the following three strings are empty: externalServiceId: %s, externalUserId: %s, externalGroupId: %s\n", externalServiceId, externalUserId, externalGroupId))
	} else if strings.Contains(externalServiceId, "|") || strings.Contains(externalUserId, "|") || strings.Contains(externalGroupId, "|") {
		panic(fmt.Sprintf("One of the following three strings contain pipe character: externalServiceId: %s, externalUserId: %s, externalGroupId: %s\n", externalServiceId, externalUserId, externalGroupId))
	}
	extid := dsocialUserId + "/" + k
	bc.AddIdsForDsocialGroup(group, p, dsocialUserId)
	g := new(dm.Group)
	*g = *group
	g.Id = extid
	fmt.Printf("[DS]: Storing %s with id %v for %s\n", _INMEMORY_GROUP_FOR_EXTERNAL_GROUP_COLLECTION_NAME, extid, g.Name)
	p.store(dsocialUserId, _INMEMORY_GROUP_FOR_EXTERNAL_GROUP_COLLECTION_NAME, extid, g)
	dsocialGroup = group
	return
}
开发者ID:pombredanne,项目名称:dsocial.go,代码行数:22,代码来源:contacts_service.go


示例4: StoreDsocialGroup

// Stores dsocial group
// Returns:
//   dsocialGroup : the group, modified to include items like Id and LastModified/Created
//   err : error or nil
func (p *InMemoryDataStore) StoreDsocialGroup(dsocialUserId, dsocialGroupId string, group *dm.Group) (dsocialGroup *dm.Group, err os.Error) {
	if dsocialGroupId == "" {
		dsocialGroupId = p.GenerateId(dsocialUserId, "group")
		fmt.Printf("[DS]: Generated Id for storing dsocial group: %v\n", dsocialGroupId)
		group.Id = dsocialGroupId
	} else {
		fmt.Printf("[DS]: Using existing group id: %v\n", dsocialGroupId)
	}
	//k := strings.Join([]string{dsocialUserId, dsocialGroupId}, "/")
	g := new(dm.Group)
	*g = *group
	p.store(dsocialUserId, _INMEMORY_GROUP_COLLECTION_NAME, dsocialGroupId, g)
	dsocialGroup = group
	return
}
开发者ID:pombredanne,项目名称:dsocial.go,代码行数:19,代码来源:contacts_service.go


示例5: groupImport

func (p *Pipeline) groupImport(cs ContactsService, ds DataStoreService, dsocialUserId string, group *Group, minimumIncludes *list.List, allowAdd, allowDelete, allowUpdate bool) (*dm.Group, string, os.Error) {
	emptyGroup := new(dm.Group)
	if group == nil || group.Value == nil {
		return nil, "", nil
	}
	//fmt.Printf("[PIPELINE]: Syncing group: %s\n", group.Value.Name)
	if group.Value.ContactIds == nil {
		group.Value.ContactIds = make([]string, 0, 10)
	}
	if group.Value.ContactNames == nil {
		group.Value.ContactNames = make([]string, 0, 10)
	}
	if len(group.Value.ContactIds) == 0 && len(group.Value.ContactNames) == 0 && minimumIncludes != nil {
		sv1 := vector.StringVector(group.Value.ContactIds)
		sv2 := vector.StringVector(group.Value.ContactNames)
		sv1.Resize(sv1.Len(), sv1.Len()+minimumIncludes.Len())
		sv2.Resize(sv2.Len(), sv2.Len()+minimumIncludes.Len())
		for iter := minimumIncludes.Front(); iter != nil; iter = iter.Next() {
			contactRef := iter.Value.(*dm.ContactRef)
			sv1.Push(contactRef.Id)
			sv2.Push(contactRef.Name)
		}
	} else if minimumIncludes != nil {
		for iter := minimumIncludes.Front(); iter != nil; iter = iter.Next() {
			contactRef := iter.Value.(*dm.ContactRef)
			refLocation := -1
			if contactRef.Id != "" {
				for i, id := range group.Value.ContactIds {
					if id == contactRef.Id {
						refLocation = i
						break
					}
				}
			}
			if refLocation == -1 && contactRef.Name != "" {
				for i, name := range group.Value.ContactNames {
					if name == contactRef.Name {
						refLocation = i
						break
					}
				}
			}
			if refLocation == -1 {
				sv1 := vector.StringVector(group.Value.ContactIds)
				sv2 := vector.StringVector(group.Value.ContactNames)
				sv1.Push(contactRef.Id)
				sv2.Push(contactRef.Name)
			} else {
				group.Value.ContactIds[refLocation] = contactRef.Id
				group.Value.ContactNames[refLocation] = contactRef.Name
			}
		}
	}
	extDsocialGroup, _, err := ds.RetrieveDsocialGroupForExternalGroup(group.ExternalServiceId, group.ExternalUserId, group.ExternalGroupId, dsocialUserId)
	if err != nil {
		return nil, "", err
	}
	var matchingGroup *dm.Group
	var isSame bool
	if extDsocialGroup == nil {
		// We don't have a mapping for this external group to an internal group mapping
		// meaning we've never imported this group previously from THIS service, but we may
		// already have the group in our system, so let's see if we can find it
		matchingGroup, isSame, err = p.findMatchingDsocialGroup(ds, dsocialUserId, group)
		if err != nil {
			return matchingGroup, "", err
		}
		if matchingGroup != nil {
			group.DsocialGroupId = matchingGroup.Id
			extGroup := cs.ConvertToExternalGroup(matchingGroup, nil, dsocialUserId)
			ds.StoreExternalGroup(group.ExternalServiceId, group.ExternalUserId, dsocialUserId, group.ExternalGroupId, extGroup)
			extDsocialGroup = cs.ConvertToDsocialGroup(extGroup, matchingGroup, dsocialUserId)
			if extDsocialGroup != nil {
				AddIdsForDsocialGroup(extDsocialGroup, ds, dsocialUserId)
				fmt.Printf("[PIPELINE]: groupImport() before store dsoc group ExternalGroupId: %v and extDsocialGroup.Id %v matchingGroup.Id %v\n", group.ExternalGroupId, extDsocialGroup.Id, matchingGroup.Id)
				//group.ExternalGroupId = extDsocialGroup.Id
				//extDsocialGroup.Id = group.DsocialGroupId
				extDsocialGroup, err = ds.StoreDsocialGroupForExternalGroup(group.ExternalServiceId, group.ExternalUserId, group.ExternalGroupId, dsocialUserId, extDsocialGroup)
				if extDsocialGroup == nil || err != nil {
					return matchingGroup, "", err
				}
				//extDsocialGroup.Id = group.DsocialGroupId
				fmt.Printf("[PIPELINE]: groupImport() before store mapping ExternalGroupId: %v and DsocialGroupId %v\n", group.ExternalGroupId, group.DsocialGroupId)
				if _, _, err = ds.StoreDsocialExternalGroupMapping(group.ExternalServiceId, group.ExternalUserId, group.ExternalGroupId, dsocialUserId, group.DsocialGroupId); err != nil {
					return matchingGroup, "", err
				}
			}
		}
	} else {
		// we have a mapping for this external group to an internal group mapping
		// from THIS service, therefore let's use it
		if group.DsocialGroupId == "" {
			group.DsocialGroupId, err = ds.DsocialIdForExternalGroupId(group.ExternalServiceId, group.ExternalUserId, dsocialUserId, group.ExternalGroupId)
			if err != nil {
				return nil, "", err
			}
		}
		if group.DsocialGroupId != "" {
			matchingGroup, _, err = ds.RetrieveDsocialGroup(dsocialUserId, group.DsocialGroupId)
			if err != nil {
//.........这里部分代码省略.........
开发者ID:pombredanne,项目名称:dsocial.go,代码行数:101,代码来源:pipeline.go



注:本文中的github.com/pomack/dsocial/go/models/dsocial.Group类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang dsocial.User类代码示例发布时间:2022-05-28
下一篇:
Golang dsocial.Contact类代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap