Exemple #1
0
// GetGeoLinkResource for GeoLink All Hands Demo, remove afterwards, dont' want person specific version
func GetGeoLinkResource(uri string) *sparql.Results {
	log.Printf("GetGeoLinkResource: %s\n", uri)

	repo, err := sparql.NewRepo("http://data.geolink.org/sparql",
		sparql.Timeout(time.Millisecond*15000),
	)
	if err != nil {
		log.Printf("%s\n", err)
	}

	f := bytes.NewBufferString(queries)
	bank := sparql.LoadBank(f)

	// q, err := bank.Prepare("my-query", struct{ Limit, Offset int }{10, 100})
	q, err := bank.Prepare("geolinkperson", struct{ URI string }{uri})
	if err != nil {
		log.Printf("%s\n", err)
	}

	res, err := repo.Query(q)
	if err != nil {
		log.Printf("%s\n", err)
	}

	return res //  Just a test return, would not be what I really return
}
Exemple #2
0
// GetRDFResource takes a URI as an arugment and returns information about the RDF resource
func GetRDFResource(uri string) *sparql.Results {
	log.Printf("GetRDFResource: %s\n", uri)

	repo, err := sparql.NewRepo("http://data.oceandrilling.org/sparql",
		sparql.Timeout(time.Millisecond*15000),
	)
	if err != nil {
		log.Printf("%s\n", err)
	}

	f := bytes.NewBufferString(queries)
	bank := sparql.LoadBank(f)

	// q, err := bank.Prepare("my-query", struct{ Limit, Offset int }{10, 100})
	q, err := bank.Prepare("generic", struct{ URI string }{uri})
	if err != nil {
		log.Printf("%s\n", err)
	}

	res, err := repo.Query(q)
	if err != nil {
		log.Printf("%s\n", err)
	}

	// // Print loop testing
	// bindingsTest := res.Results.Bindings // map[string][]binding
	// fmt.Println("res.Resuolts.Bindings:")
	// for k, i := range bindingsTest {
	// 	fmt.Printf("At postion %v with %v and %v\n", k, i["pro"], i["vol"])
	// }

	// bindingsTest2 := res.Bindings() // map[string][]rdf.Term
	// fmt.Println("res.Bindings():")
	// for k, i := range bindingsTest2 {
	// 	fmt.Printf("At postion %v with %v \n", k, i)
	// }

	// solutionsTest := res.Solutions() // map[string][]rdf.Term
	// fmt.Println("res.Solutions():")
	// for k, i := range solutionsTest {
	// 	fmt.Printf("At postion %v with %v \n", k, i)
	// }

	return res //  Just a test return, would not be what I really return
}
// TODO ..  error nice if I don't get what I expect in these params
func MaxAge(leg string, site string, hole string) float64 {
	repo, err := sparql.NewRepo("http://data.oceandrilling.org/sparql",
		//sparql.DigestAuth("dba", "dba"),
		sparql.Timeout(time.Millisecond*15000),
	)
	if err != nil {
		log.Print(err)
	}

	f := bytes.NewBufferString(queries)
	bank := sparql.LoadBank(f)

	fmt.Printf("Making call for %s %s %s\n", leg, site, hole)

	q, err := bank.Prepare("agemodel", struct{ URI string }{fmt.Sprintf("<http://data.oceandrilling.org/codices/lsh/%s/%s/%s>", leg, site, hole)})
	if err != nil {
		log.Print(err)
	}

	res, err := repo.Query(q)
	if err != nil {
		log.Print(err)
	}

	maxage := 0.0
	solutionsTest := res.Solutions() // map[string][]rdf.Term
	for _, i := range solutionsTest {
		age, err := strconv.ParseFloat(fmt.Sprint(i["age"]), 64)
		if err != nil {
			log.Print(err)
		}
		if age > maxage {
			maxage = age
		}
	}

	fmt.Println("res.Solutions():")
	for k, i := range solutionsTest {
		fmt.Printf("At postion %v with %v \n", k, i)
	}

	return maxage

}
func ExpPublications(queryterm string) string {
	repo, err := sparql.NewRepo("http://data.oceandrilling.org/sparql",
		//sparql.DigestAuth("dba", "dba"),
		sparql.Timeout(time.Millisecond*15000),
	)
	if err != nil {
		log.Print(err)
	}

	f := bytes.NewBufferString(queries)
	bank := sparql.LoadBank(f)

	// q, err := bank.Prepare("my-query", struct{ Limit, Offset int }{10, 100})
	q, err := bank.Prepare("legcall", struct{ Leg string }{"113"})
	if err != nil {
		log.Print(err)
	}

	res, err := repo.Query(q)
	if err != nil {
		log.Print(err)
	}

	// Print loop testing
	bindingsTest := res.Results.Bindings // map[string][]rdf.Term
	fmt.Println("res.Resuolts.Bindings:")
	for k, i := range bindingsTest {
		fmt.Printf("At postion %v with %v and %v\n", k, i["pro"], i["vol"])
	}

	bindingsTest2 := res.Bindings() // map[string][]rdf.Term
	fmt.Println("res.Bindings():")
	for k, i := range bindingsTest2 {
		fmt.Printf("At postion %v with %v \n", k, i)
	}

	solutionsTest := res.Solutions() // map[string][]rdf.Term
	fmt.Println("res.Solutions():")
	for k, i := range solutionsTest {
		fmt.Printf("At postion %v with %v \n", k, i)
	}

	return q
}
func LegSite() *sparql.Results {
	repo, err := sparql.NewRepo("http://data.oceandrilling.org/sparql",
		//sparql.DigestAuth("dba", "dba"),
		sparql.Timeout(time.Millisecond*15000),
	)
	if err != nil {
		log.Print(err)
	}

	f := bytes.NewBufferString(queries)
	bank := sparql.LoadBank(f)

	q, err := bank.Prepare("legcall2")
	if err != nil {
		log.Print(err)
	}

	res, err := repo.Query(q)
	if err != nil {
		log.Print(err)
	}

	// Print loop testing
	bindingsTest := res.Results.Bindings // map[string][]rdf.Term
	fmt.Println("res.Resuolts.Bindings:")
	for k, i := range bindingsTest {
		fmt.Printf("At postion %v with %v and %v\n", k, i["p"], i["o"])
	}

	bindingsTest2 := res.Bindings() // map[string][]rdf.Term
	fmt.Println("res.Bindings():")
	for k, i := range bindingsTest2 {
		fmt.Printf("At postion %v with %v \n", k, i)
	}

	solutionsTest := res.Solutions() // map[string][]rdf.Term
	fmt.Println("res.Solutions():")
	for k, i := range solutionsTest {
		fmt.Printf("At postion %v with %v \n", k, i)
	}

	return res

}
func AgeModel(leg string, site string, hole string) *sparql.Results {
	repo, err := sparql.NewRepo("http://data.oceandrilling.org/sparql",
		//sparql.DigestAuth("dba", "dba"),
		sparql.Timeout(time.Millisecond*15000),
	)
	if err != nil {
		log.Print(err)
	}

	f := bytes.NewBufferString(queries)
	bank := sparql.LoadBank(f)

	q, err := bank.Prepare("agemodel", struct{ URI string }{fmt.Sprintf("<http://data.oceandrilling.org/codices/lsh/%s/%s/%s>", leg, site, hole)})
	if err != nil {
		log.Print(err)
	}

	res, err := repo.Query(q)
	if err != nil {
		log.Print(err)
	}

	// Print loop testing
	bindingsTest := res.Results.Bindings // map[string][]rdf.Term
	fmt.Println("res.Resuolts.Bindings:")
	for k, i := range bindingsTest {
		fmt.Printf("At postion %v with %v and %v\n", k, i["p"], i["o"])
	}

	bindingsTest2 := res.Bindings() // map[string][]rdf.Term
	fmt.Println("res.Bindings():")
	for k, i := range bindingsTest2 {
		fmt.Printf("At postion %v with %v \n", k, i)
	}

	solutionsTest := res.Solutions() // map[string][]rdf.Term
	fmt.Println("res.Solutions():")
	for k, i := range solutionsTest {
		fmt.Printf("At postion %v with %v \n", k, i)
	}

	return res

}
Exemple #7
0
// Had problem with this due to likely some issues now resolved with SPARQL library
func CSIROCall(age string) *sparql.Results {
	repo, err := sparql.NewRepo("http://resource.geosciml.org/sparql/isc2014",
		sparql.Timeout(time.Millisecond*15000),
	)
	if err != nil {
		log.Printf("%s\n", err)
	}

	f := bytes.NewBufferString(queries)
	bank := sparql.LoadBank(f)

	q, err := bank.Prepare("csiro", struct{ Age string }{age})
	if err != nil {
		log.Printf("%s\n", err)
	}

	res, err := repo.Query(q)
	if err != nil {
		log.Printf("%s\n", err)
	}

	return res
}
Exemple #8
0
func SPARQLCall(leg string, site string, hole string, query string, endpoint string) *sparql.Results {
	repo, err := sparql.NewRepo(endpoint,
		sparql.Timeout(time.Millisecond*15000),
	)
	if err != nil {
		log.Printf("%s\n", err)
	}

	f := bytes.NewBufferString(queries)
	bank := sparql.LoadBank(f)

	q, err := bank.Prepare(query, struct{ Leg, Site, Hole string }{leg, site, hole})
	if err != nil {
		log.Printf("%s\n", err)
	}

	res, err := repo.Query(q)
	if err != nil {
		log.Printf("%s\n", err)
	}

	return res
}