当前位置: 首页>>代码示例>>Golang>>正文


Golang Values.Reset方法代码示例

本文整理汇总了Golang中github.com/js-arias/jdh/pkg/jdh.Values.Reset方法的典型用法代码示例。如果您正苦于以下问题:Golang Values.Reset方法的具体用法?Golang Values.Reset怎么用?Golang Values.Reset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/js-arias/jdh/pkg/jdh.Values的用法示例。


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

示例1: trForceNode

func trForceNode(c *cmdapp.Command, nod *jdh.Node, txLs *list.List) {
	vals := new(jdh.Values)
	vals.Add(jdh.NodChildren, nod.Id)
	l, err := localDB.List(jdh.Nodes, vals)
	if err != nil {
		fmt.Fprintf(os.Stderr, "%s\n", c.ErrStr(err))
		os.Exit(1)
	}
	childs := 0
	for {
		desc := &jdh.Node{}
		if err := l.Scan(desc); err != nil {
			if err == io.EOF {
				break
			}
			fmt.Fprintf(os.Stderr, "%s\n", c.ErrStr(err))
			os.Exit(1)
		}
		trForceNode(c, desc, txLs)
		childs++
	}
	if childs > 1 {
		return
	}
	if len(nod.Taxon) == 0 {
		return
	}
	tax := taxon(c, localDB, nod.Taxon)
	if tax.IsValid {
		return
	}
	par := taxon(c, localDB, tax.Parent)
	todel := false
	for e := txLs.Front(); e != nil; e = e.Next() {
		tId := e.Value.(string)
		if tId == par.Id {
			todel = true
			break
		}
	}
	if todel {
		fmt.Fprintf(os.Stdout, "%s: deleted\n", tax.Name)
		if !repFlag {
			vals.Reset()
			vals.Add(jdh.KeyId, nod.Id)
			localDB.Exec(jdh.Delete, jdh.Nodes, vals)
		}
		return
	}
	fmt.Fprintf(os.Stdout, "%s: changed to: %s\n", tax.Name, par.Name)
	if !repFlag {
		vals.Reset()
		vals.Add(jdh.KeyId, nod.Id)
		vals.Add(jdh.NodTaxon, par.Id)
		localDB.Exec(jdh.Set, jdh.Nodes, vals)
		txLs.PushBack(par.Id)
	}
}
开发者ID:js-arias,项目名称:jdh,代码行数:58,代码来源:tr.force.go

示例2: newTxList

func newTxList(tax *jdh.Taxon, db jdh.DB, syns bool) *txList {
	ls := &txList{
		db:   db,
		tax:  tax,
		syns: syns,
	}
	id := ""
	if tax == nil {
		ls.tax = &jdh.Taxon{
			Id:   "0",
			Name: "root",
		}
	} else {
		id = tax.Id
	}
	vals := new(jdh.Values)
	vals.Add(jdh.TaxChildren, id)
	pl, err := db.List(jdh.Taxonomy, vals)
	if err != nil {
		return ls
	}
	for {
		d := &jdh.Taxon{}
		if err := pl.Scan(d); err != nil {
			break
		}
		ls.desc = append(ls.desc, d)
	}
	if !syns {
		return ls
	}
	vals.Reset()
	vals.Add(jdh.TaxSynonyms, id)
	pl, err = db.List(jdh.Taxonomy, vals)
	if err != nil {
		return ls
	}
	for {
		s := &jdh.Taxon{}
		if err := pl.Scan(s); err != nil {
			break
		}
		ls.desc = append(ls.desc, s)
	}
	return ls
}
开发者ID:js-arias,项目名称:jdh,代码行数:46,代码来源:taxonomy.go

示例3: raMkFetch

func raMkFetch(c *cmdapp.Command, spDB jdh.DB, tax *jdh.Taxon, prevRank, rank jdh.Rank, size float64) {
	r := tax.Rank
	if r == jdh.Unranked {
		r = prevRank
	}
	defer func() {
		l := getTaxDesc(c, localDB, tax.Id, true)
		raMkNav(c, l, spDB, r, rank, size)
	}()
	if len(tax.Id) == 0 {
		return
	}
	if r < rank {
		return
	}
	vals := new(jdh.Values)
	if spDB != localDB {
		eid := searchExtern(extDBFlag, tax.Extern)
		if len(eid) == 0 {
			return
		}
		vals.Add(jdh.SpeTaxonParent, eid)
	} else {
		vals.Add(jdh.SpeTaxonParent, tax.Id)
	}
	vals.Add(jdh.SpeGeoref, "true")
	inDB := true
	ras := raMkGetRas(c, tax.Id, size)
	if len(ras.Id) == 0 {
		inDB = false
		ras = &jdh.Raster{
			Taxon:  tax.Id,
			Cols:   uint(360 / size),
			Source: jdh.ExplicitPoints,
		}
	}
	l := speList(c, spDB, vals)
	for {
		spe := &jdh.Specimen{}
		if err := l.Scan(spe); err != nil {
			if err == io.EOF {
				break
			}
			fmt.Fprintf(os.Stderr, "%s\n", c.ErrStr(err))
			os.Exit(1)
		}
		if !spe.Georef.IsValid() {
			continue
		}
		if validFlag && (len(spe.Georef.Validation) == 0) {
			continue
		}
		azm, inc := spe.Georef.Point.Lon+180, 90-spe.Georef.Point.Lat
		x, y := int(azm/size), int(inc/size)
		if inDB {
			vals.Reset()
			vals.Add(jdh.KeyId, ras.Id)
			vals.Add(jdh.RasPixel, fmt.Sprintf("%d,%d,1", x, y))
			localDB.Exec(jdh.Set, jdh.RasDistros, vals)
			continue
		}
		if ras.Raster == nil {
			ras.Raster = pixlist.NewPixList()
		}
		pt := image.Pt(x, y)
		ras.Raster.Set(pt, 1)
	}
	if inDB || (ras.Raster == nil) {
		return
	}
	localDB.Exec(jdh.Add, jdh.RasDistros, ras)
}
开发者ID:js-arias,项目名称:jdh,代码行数:72,代码来源:ra.mk.go

示例4: txSyncMatch

// TxSyncMatch implements the match option of tx.sync.
func txSyncMatch(c *cmdapp.Command, tax *jdh.Taxon) {
	defer func() {
		l := getTaxDesc(c, localDB, tax.Id, true)
		txSyncMatchNav(c, l)
		l = getTaxDesc(c, localDB, tax.Id, false)
		txSyncMatchNav(c, l)
	}()

	if len(tax.Id) == 0 {
		return
	}
	eid := searchExtern(extDBFlag, tax.Extern)
	if len(eid) > 0 {
		return
	}
	var pEids []string
	args := new(jdh.Values)
	args.Add(jdh.TaxParents, tax.Id)
	pl, err := localDB.List(jdh.Taxonomy, args)
	if err != nil {
		fmt.Fprintf(os.Stderr, "%s\n", c.ErrStr(err))
		os.Exit(1)
	}
	for {
		p := &jdh.Taxon{}
		if err := pl.Scan(p); err != nil {
			if err == io.EOF {
				break
			}
			fmt.Fprintf(os.Stderr, "%s\n", c.ErrStr(err))
			os.Exit(1)
		}
		pe := searchExtern(extDBFlag, p.Extern)
		if len(pEids) == 0 {
			continue
		}
		pEids = append(pEids, pe)
	}
	args.Reset()
	args.Add(jdh.TaxName, tax.Name)
	l, err := extDB.List(jdh.Taxonomy, args)
	if err != nil {
		fmt.Fprintf(os.Stderr, "%s\n", c.ErrStr(err))
		os.Exit(1)
	}
	var extTax *jdh.Taxon
	for {
		et := &jdh.Taxon{}
		if err := l.Scan(et); err != nil {
			if err == io.EOF {
				break
			}
			fmt.Fprintf(os.Stderr, "%s\n", c.ErrStr(err))
			os.Exit(1)
		}
		if len(pEids) > 0 {
			if !isInParentList(c, extDB, et.Id, pEids) {
				continue
			}
		}
		if (len(tax.Authority) > 0) && (len(et.Authority) > 0) {
			if tax.Authority != et.Authority {
				continue
			}
		}
		if extTax == nil {
			extTax = et
			continue
		}
		// The name is ambiguous
		fmt.Fprintf(os.Stderr, "taxon name %s is ambiguous in %s\n", tax.Name, extDBFlag)
		l.Close()
		return
	}
	if extTax == nil {
		return
	}
	args.Reset()
	args.Add(jdh.KeyId, tax.Id)
	args.Add(jdh.KeyExtern, extDBFlag+":"+extTax.Id)
	localDB.Exec(jdh.Set, jdh.Taxonomy, args)
}
开发者ID:js-arias,项目名称:jdh,代码行数:83,代码来源:tx.sync.go

示例5: txDelRun

func txDelRun(c *cmdapp.Command, args []string) {
	openLocal(c)
	var tax *jdh.Taxon
	if len(idFlag) > 0 {
		tax = taxon(c, localDB, idFlag)
		if len(tax.Id) == 0 {
			return
		}
	} else if len(args) > 0 {
		if len(args) > 2 {
			fmt.Fprintf(os.Stderr, "%s\n", c.ErrStr("too many arguments"))
			os.Exit(1)
		}
		pName := ""
		if len(args) > 1 {
			pName = args[1]
		}
		tax = pickTaxName(c, localDB, args[0], pName)
		if len(tax.Id) == 0 {
			return
		}
	} else {
		fmt.Fprintf(os.Stderr, "%s\n", c.ErrStr("expectiong taxon name or id"))
		c.Usage()
	}
	vals := new(jdh.Values)
	if colpFlag {
		if len(tax.Parent) > 0 {
			vals.Add(jdh.KeyId, tax.Id)
			vals.Add(jdh.TaxSynonym, "")
			if _, err := localDB.Exec(jdh.Set, jdh.Taxonomy, vals); err != nil {
				fmt.Fprintf(os.Stderr, "%s\n", c.ErrStr(err))
				os.Exit(1)
			}
		} else {
			l := getTaxDesc(c, localDB, tax.Id, true)
			for {
				desc := &jdh.Taxon{}
				if err := l.Scan(desc); err != nil {
					if err == io.EOF {
						break
					}
					fmt.Fprintf(os.Stderr, "%s\n", c.ErrStr(err))
					os.Exit(1)
				}
				vals.Reset()
				vals.Add(jdh.KeyId, desc.Id)
				vals.Add(jdh.TaxParent, "")
				if _, err := localDB.Exec(jdh.Set, jdh.Taxonomy, vals); err != nil {
					fmt.Fprintf(os.Stderr, "%s\n", c.ErrStr(err))
					os.Exit(1)
				}
			}
		}
	}
	vals.Reset()
	vals.Add(jdh.KeyId, tax.Id)
	if _, err := localDB.Exec(jdh.Delete, jdh.Taxonomy, vals); err != nil {
		fmt.Fprintf(os.Stderr, "%s\n", c.ErrStr(err))
		os.Exit(1)
	}
	localDB.Exec(jdh.Commit, "", nil)
}
开发者ID:js-arias,项目名称:jdh,代码行数:63,代码来源:tx.del.go


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