All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.xowl.infra.server.site.modules.db-procedures-new.js Maven / Gradle / Ivy

There is a newer version: 2.3.4
Show newest version
// Copyright (c) 2016 Association Cénotélie (cenotelie.fr)
// Provided under LGPL v3

var xowl = new XOWL();
var dbName = getParameterByName("db");
var DEFAULT_QUERY =
	"PREFIX rdf: \n" +
	"PREFIX rdfs: \n" +
	"PREFIX xsd: \n" +
	"PREFIX owl: \n" +
	"PREFIX xowl: \n\n" +
	"SELECT DISTINCT ?x ?y WHERE { GRAPH ?g { ?x a ?y } }";

function init() {
	doSetupPage(xowl, true, [
		{name: "Database " + dbName, uri: "db.html?db=" + encodeURIComponent(dbName)},
		{name: "Procedures", uri: "db-procedures.html?db=" + encodeURIComponent(dbName)},
		{name: "New Procedure"}
	], function() {
		if (!dbName || dbName === null || dbName === "")
			return;
		document.getElementById("field-definition").value = DEFAULT_QUERY;
	});
}

function onCreateProcedure() {
	var name = document.getElementById("field-name").value;
	var params = document.getElementById("field-params").value;
	var definition = document.getElementById("field-definition").value;
	if (name === null || name === "" || definition === null || definition === "")
		return;
	if (!onOperationRequest("Creating procedure " + name + " ..."))
		return;
	var parameters = [];
	params = params === null ? [] : params.split(",");
	for (var i = 0; i != params.length; i++) {
		var param = params[i].trim();
		if (param.length > 0)
			parameters.push(param);
	}
	xowl.addDBProcedure(function (status, type, content) {
		if (onOperationEnded(status, content)) {
			displayMessage("success", "Created procedure " + name + ".");
			waitAndGo("db-procedures.html?db=" + encodeURIComponent(dbName));
		}
	}, dbName, {
		"type": "org.xowl.infra.server.api.XOWLStoredProcedure",
		"name": name,
		"definition": definition,
		"parameters": parameters
	});
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy