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


Golang jdh.Values类代码示例

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


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

示例1: isInParentList

// IsInParentList search an id in the list of parents of the taxon.
func isInParentList(c *cmdapp.Command, db jdh.DB, id string, pIds []string) bool {
	args := new(jdh.Values)
	args.Add(jdh.TaxParents, id)
	pl, err := db.List(jdh.Taxonomy, args)
	if err != nil {
		fmt.Fprintf(os.Stderr, "%s\n", c.ErrStr(err))
		os.Exit(1)
	}
	defer pl.Close()
	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)
		}
		for _, pid := range pIds {
			if p.Id == pid {
				return true
			}
		}
	}
	return false
}
开发者ID:js-arias,项目名称:jdh,代码行数:27,代码来源:taxonomy.go

示例2: getValidParent

func getValidParent(c *cmdapp.Command, extId string) string {
	args := new(jdh.Values)
	args.Add(jdh.TaxParents, extId)
	l, err := extDB.List(jdh.Taxonomy, args)
	if err != nil {
		fmt.Fprintf(os.Stderr, "%s\n", c.ErrStr(err))
		os.Exit(1)
	}
	defer l.Close()
	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)
		}
		p := taxon(c, localDB, extDBFlag+":"+et.Id)
		if len(p.Id) > 0 {
			if p.IsValid {
				return p.Id
			} else {
				return p.Parent
			}
		}
	}
	return ""
}
开发者ID:js-arias,项目名称:jdh,代码行数:29,代码来源:tx.sync.go

示例3: trForceProc

func trForceProc(c *cmdapp.Command, phy *jdh.Phylogeny) {
	txLs := list.New()
	vals := new(jdh.Values)
	vals.Add(jdh.TreTaxon, phy.Id)
	l, err := localDB.List(jdh.Trees, vals)
	if err != nil {
		fmt.Fprintf(os.Stderr, "%s\n", c.ErrStr(err))
		os.Exit(1)
	}
	for {
		var tId jdh.IdElement
		if err := l.Scan(&tId); err != nil {
			if err == io.EOF {
				break
			}
			fmt.Fprintf(os.Stderr, "%s\n", c.ErrStr(err))
			os.Exit(1)
		}
		if len(tId.Id) == 0 {
			continue
		}
		txLs.PushBack(tId.Id)
	}
	if txLs.Len() == 0 {
		return
	}
	root := phyloNode(c, localDB, phy.Root)
	trForceNode(c, root, txLs)
}
开发者ID:js-arias,项目名称:jdh,代码行数:29,代码来源:tr.force.go

示例4: txEdVal

func txEdVal(from *jdh.Taxon) {
	if from.IsValid {
		return
	}
	vals := new(jdh.Values)
	vals.Add(jdh.KeyId, from.Id)
	vals.Add(jdh.TaxValid, "true")
	localDB.Exec(jdh.Set, jdh.Taxonomy, vals)
}
开发者ID:js-arias,项目名称:jdh,代码行数:9,代码来源:tx.ed.go

示例5: raLsRun

func raLsRun(c *cmdapp.Command, args []string) {
	openLocal(c)
	var tax *jdh.Taxon
	if len(taxonFlag) > 0 {
		tax = taxon(c, localDB, taxonFlag)
		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 childFlag {
		vals.Add(jdh.RDisTaxonParent, tax.Id)
	} else {
		vals.Add(jdh.RDisTaxon, tax.Id)
	}
	l := rasList(c, localDB, vals)
	defer l.Close()
	ct := tax
	for {
		ras := &jdh.Raster{}
		if err := l.Scan(ras); err != nil {
			if err == io.EOF {
				break
			}
			fmt.Fprintf(os.Stderr, "%s\n", c.ErrStr(err))
			os.Exit(1)
		}
		if machineFlag {
			fmt.Fprintf(os.Stdout, "%s\n", ras.Id)
			continue
		}
		if ras.Taxon != ct.Id {
			ct = taxon(c, localDB, ras.Taxon)
		}
		if verboseFlag {
			fmt.Fprintf(os.Stdout, "%s %s %s\t%s\t%dx%d\n", ct.Id, ct.Name, ct.Authority, ras.Id, ras.Cols, ras.Cols/2)
			continue
		}
		fmt.Fprintf(os.Stdout, "%s\t%s\t%dx%d\n", ct.Name, ras.Id, ras.Cols, ras.Cols/2)
	}
}
开发者ID:js-arias,项目名称:jdh,代码行数:57,代码来源:ra.ls.go

示例6: spPopFetch

func spPopFetch(c *cmdapp.Command, tax *jdh.Taxon, prevRank, rank jdh.Rank) {
	r := tax.Rank
	if r == jdh.Unranked {
		r = prevRank
	}
	defer func() {
		l := getTaxDesc(c, localDB, tax.Id, true)
		spPopNav(c, l, r, rank)
		l = getTaxDesc(c, localDB, tax.Id, false)
		spPopNav(c, l, r, rank)
	}()
	if len(tax.Id) == 0 {
		return
	}
	if r < rank {
		return
	}
	eid := searchExtern(extDBFlag, tax.Extern)
	if len(eid) == 0 {
		return
	}
	vals := new(jdh.Values)
	vals.Add(jdh.SpeTaxon, eid)
	if geoRefFlag {
		vals.Add(jdh.SpeGeoref, "true")
	}
	l := speList(c, extDB, 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 osp := specimen(c, localDB, extDBFlag+":"+spe.Id); len(osp.Id) > 0 {
			continue
		}
		if len(spe.Catalog) > 0 {
			if osp := specimen(c, localDB, spe.Catalog); len(osp.Id) > 0 {
				exsp := searchExtern(extDBFlag, osp.Extern)
				if exsp == spe.Id {
					continue
				}
				fmt.Fprintf(os.Stderr, "specimen %s already in database as %s [duplicated in %s]\n", spe.Catalog, osp.Id, extDBFlag)
				continue
			}
		}
		addToSpecimens(c, spe, tax.Id)
	}
}
开发者ID:js-arias,项目名称:jdh,代码行数:52,代码来源:sp.pop.go

示例7: trDelNode

func trDelNode(c *cmdapp.Command) {
	vals := new(jdh.Values)
	if colpFlag {
		vals.Add(jdh.NodCollapse, nodeFlag)
	} else {
		vals.Add(jdh.KeyId, nodeFlag)
	}
	if _, err := localDB.Exec(jdh.Delete, jdh.Nodes, vals); err != nil {
		fmt.Fprintf(os.Stderr, "%s\n", c.ErrStr(err))
		os.Exit(1)
	}
	localDB.Exec(jdh.Commit, "", nil)
}
开发者ID:js-arias,项目名称:jdh,代码行数:13,代码来源:tr.del.go

示例8: setNode

func setNode(nod *jdh.Node, anc *trNode, data *trData) *trNode {
	trn := &trNode{
		id:     nod.Id,
		taxon:  nod.Taxon,
		parent: anc,
	}
	data.node = append(data.node, trn)
	if anc != nil {
		trn.nest = anc.nest + 1
		trn.minX = float32(trn.nest)
	}
	if len(nod.Taxon) > 0 {
		tax := taxon(cmd, localDB, nod.Taxon)
		trn.name.Text = tax.Name
		if !tax.IsValid {
			val := taxon(cmd, localDB, tax.Parent)
			nm := fmt.Sprintf("[%s syn. of %s]", tax.Name, val.Name)
			trn.name.Text = nm
		}
	}
	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", cmd.ErrStr(err))
		os.Exit(1)
	}
	for {
		desc := &jdh.Node{}
		if err := l.Scan(desc); err != nil {
			if err == io.EOF {
				break
			}
			fmt.Fprintf(os.Stderr, "%s\n", cmd.ErrStr(err))
			os.Exit(1)
		}
		d := setNode(desc, trn, data)
		trn.terms += d.terms
		if trn.level <= d.level {
			trn.level = d.level + 1
		}
		trn.children = append(trn.children, d)
	}
	if len(trn.children) == 0 {
		data.terms++
		trn.terms = 1
	} else {
		sort.Sort(bySize(trn.children))
	}
	return trn
}
开发者ID:js-arias,项目名称:jdh,代码行数:51,代码来源:phylogeny.go

示例9: getTaxDesc

// GetTaxDesc return the list of descendants of a taxon.
func getTaxDesc(c *cmdapp.Command, db jdh.DB, id string, valid bool) jdh.ListScanner {
	args := new(jdh.Values)
	if valid {
		args.Add(jdh.TaxChildren, id)
	} else {
		args.Add(jdh.TaxSynonyms, id)
	}
	l, err := db.List(jdh.Taxonomy, args)
	if err != nil {
		fmt.Fprintf(os.Stderr, "%s\n", c.ErrStr(err))
		os.Exit(1)
	}
	return l
}
开发者ID:js-arias,项目名称:jdh,代码行数:15,代码来源:taxonomy.go

示例10: dsDelRun

func dsDelRun(c *cmdapp.Command, args []string) {
	if len(idFlag) == 0 {
		fmt.Fprintf(os.Stderr, "%s\n", c.ErrStr("expectiong dataset id"))
		c.Usage()
	}
	openLocal(c)
	vals := new(jdh.Values)
	vals.Add(jdh.KeyId, idFlag)
	if _, err := localDB.Exec(jdh.Delete, jdh.Datasets, vals); err != nil {
		fmt.Fprintf(os.Stderr, "%s\n", c.ErrStr(err))
		os.Exit(1)
	}
	localDB.Exec(jdh.Commit, "", nil)
}
开发者ID:js-arias,项目名称:jdh,代码行数:14,代码来源:ds.del.go

示例11: txEdSyn

func txEdSyn(from, to *jdh.Taxon) {
	if from.Id == "0" {
		return
	}
	if from.Id == to.Id {
		return
	}
	if (from.Parent == to.Id) && (!from.IsValid) {
		return
	}
	vals := new(jdh.Values)
	vals.Add(jdh.KeyId, from.Id)
	vals.Add(jdh.TaxSynonym, to.Id)
	localDB.Exec(jdh.Set, jdh.Taxonomy, vals)
}
开发者ID:js-arias,项目名称:jdh,代码行数:15,代码来源:tx.ed.go

示例12: trViewMouse

func trViewMouse(tv sparta.Widget, e interface{}) bool {
	dt := tv.Property(sparta.Data)
	if dt == nil {
		return true
	}
	data := dt.(*trData)
	ev := e.(sparta.MouseEvent)
	switch ev.Button {
	case sparta.MouseRight:
		if !setFlag {
			return true
		}
		if data.sel == nil {
			return true
		}
		sel := trViewNearestNode(ev.Loc, data.node)
		if sel == nil {
			return true
		}
		x, y, pos := data.x, data.y, data.pos
		p := tv.Property(sparta.Parent).(sparta.Widget)
		d := p.Property(sparta.Data).(*trList)
		if sel == data.sel {
			vals := new(jdh.Values)
			vals.Add(jdh.NodCollapse, sel.id)
			localDB.Exec(jdh.Delete, jdh.Nodes, vals)
			localDB.Exec(jdh.Commit, "", nil)
		} else if !sel.isValidSis(data.sel) {
			return true
		} else {
			vals := new(jdh.Values)
			vals.Add(jdh.KeyId, data.sel.id)
			vals.Add(jdh.NodSister, sel.id)
			localDB.Exec(jdh.Set, jdh.Nodes, vals)
			localDB.Exec(jdh.Commit, "", nil)
		}
		rect := tv.Property(sparta.Geometry).(image.Rectangle)
		data = setTree(d.phyLs[d.pos], rect)
		data.x, data.y, data.pos = x, y, pos
		tv.SetProperty(sparta.Data, data)
		data.putOnScreen()
		tv.Update()
	case sparta.MouseLeft:
		data.sel = trViewNearestNode(ev.Loc, data.node)
		tv.Update()
	case -sparta.MouseWheel:
		data.pos.Y -= 5
		data.putOnScreen()
		tv.Update()
	case sparta.MouseWheel:
		data.pos.Y += 5
		data.putOnScreen()
		tv.Update()
	}
	return true
}
开发者ID:js-arias,项目名称:jdh,代码行数:56,代码来源:tr.view.go

示例13: taxInDB

// TaxInDB returns true if a taxon is in the database.
func taxInDB(c *cmdapp.Command, db jdh.DB, name, parent string, rank jdh.Rank, valid bool) *jdh.Taxon {
	args := new(jdh.Values)
	args.Add(jdh.TaxName, name)
	if len(parent) != 0 {
		args.Add(jdh.TaxParent, parent)
	}
	if rank != jdh.Unranked {
		args.Add(jdh.TaxRank, rank.String())
	}
	l, err := db.List(jdh.Taxonomy, args)
	if err != nil {
		fmt.Fprintf(os.Stderr, "%s\n", c.ErrStr(err))
		os.Exit(1)
	}
	defer l.Close()
	for {
		tax := &jdh.Taxon{}
		if err := l.Scan(tax); err != nil {
			if err == io.EOF {
				return nil
			}
		}
		if len(tax.Id) > 0 {
			if tax.IsValid == valid {
				return tax
			}
		}
	}
}
开发者ID:js-arias,项目名称:jdh,代码行数:30,代码来源:taxonomy.go

示例14: valsFromArgs

// ValsFromArgs adds values from an argument list or the stdin.
func valsFromArgs(id string, args []string) *jdh.Values {
	vals := new(jdh.Values)
	vals.Add(jdh.KeyId, id)
	if len(args) == 0 {
		in := bufio.NewReader(os.Stdin)
		for {
			tn, err := readLine(in)
			if err != nil {
				break
			}
			ln := strings.Join(tn, " ")
			if strings.Index(ln, "=") < 1 {
				continue
			}
			vals.Add(parseKeyValArg(ln))
		}
	} else {
		for _, a := range args {
			if strings.Index(a, "=") < 1 {
				continue
			}
			vals.Add(parseKeyValArg(a))
		}
	}
	return vals
}
开发者ID:js-arias,项目名称:jdh,代码行数:27,代码来源:db.go

示例15: trDelRun

func trDelRun(c *cmdapp.Command, args []string) {
	openLocal(c)
	if len(nodeFlag) > 0 {
		trDelNode(c)
		return
	}
	if len(idFlag) == 0 {
		fmt.Fprintf(os.Stderr, "%s\n", c.ErrStr("expectiong tree or node id"))
		c.Usage()
	}
	vals := new(jdh.Values)
	vals.Add(jdh.KeyId, idFlag)
	if _, err := localDB.Exec(jdh.Delete, jdh.Trees, vals); err != nil {
		fmt.Fprintf(os.Stderr, "%s\n", c.ErrStr(err))
		os.Exit(1)
	}
	localDB.Exec(jdh.Commit, "", nil)
}
开发者ID:js-arias,项目名称:jdh,代码行数:18,代码来源:tr.del.go


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