<commit_before>/*
 * Copyright 1999-2010 <NAME>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/**
 * Represents the main entry-point to work with OrientDB databases.
 * 
 * @author <NAME>
 */
function ODatabase(databasePath) {
	this.databaseUrl = "";
	this.databaseName = "";
	this.databaseInfo = null;
	this.queryResult = null;
	this.commandResult = null;
	this.errorMessage = null;

	if (databasePath) {
		this.databaseUrl = databasePath.substring(0, databasePath
				.lastIndexOf('/'));
		this.databaseName = databasePath.substring(databasePath
				.lastIndexOf('/') + 1);
	}

	this.getDatabaseInfo = function() {
		return this.databaseInfo;
	}
	this.setDatabaseInfo = function(iDatabaseInfo) {
		this.databaseInfo = iDatabaseInfo;
	}

	this.getQueryResult = function() {
		return this.queryResult;
	}
	this.setQueryResult = function(iQueryResult) {
		this.queryResult = iQueryResult;
	}

	this.getCommandResult = function() {
		return this.commandResult;
	}
	this.setCommandResult = function(iCommandResult) {
		this.commandResult = iCommandResult;
	}

	this.getErrorMessage = function() {
		return this.errorMessage;
	}
	this.setErrorMessage = function(iErrorMessage) {
		this.errorMessage = iErrorMessage;
	}

	this.getDatabaseUrl = function() {
		return databaseUrl;
	}
	this.setDatabaseUrl = function(iDatabaseUrl) {
		this.databaseUrl = iDatabaseUrl;
	}

	this.getDatabaseName = function() {
		return this.databaseName;
	}
	this.setDatabaseName = function(iDatabaseName) {
		this.databaseName = iDatabaseName;
	}

	this.open = function() {
		$.ajax({
			type : "GET",
			url : this.databaseUrl + '/connect/' + this.databaseName,
			context : this,
			async : false,
			success : function(msg) {
				this.setErrorMessage(null);
				this.setDatabaseInfo(eval("(" + msg + ")"));
			},
			error : function(msg) {
				this.setErrorMessage('Connect error: ' + msg.responseText);
				this.setDatabaseInfo(null);
			}
		});
		return this.getDatabaseInfo();
	}

	this.query = function(iQuery) {
		if (this.databaseInfo == null) {
			this.open();
		}
		$.ajax({
			type : "GET",
			url : this.databaseUrl + '/query/' + this.databaseName + '/sql/'
					+ iQuery,
			context : this,
			async : false,
			success : function(msg) {
				this.setErrorMessage(null);
				this.setQueryResult(eval("(" + msg + ")"));
			},
			error : function(msg) {
				this.setQueryResult(null);
				this.setErrorMessage('Query error: ' + msg.responseText);
			}
		});
		return this.getQueryResult();
	}

	this.classInfo = function(iClassName) {
		if (this.databaseInfo == null) {
			this.open();
		}
		$.ajax({
			type : "GET",
			url : this.databaseUrl + '/class/' + this.databaseName + '/'
					+ iClassName,
			context : this,
			async : false,<commit_msg>Added ODocument.load() as Javascript<commit_after>/*
 * Copyright 1999-2010 <NAME>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/**
 * Represents the main entry-point to work with OrientDB databases.
 * 
 * @author <NAME>
 */
function ODatabase(databasePath) {
	this.databaseUrl = "";
	this.databaseName = "";
	this.databaseInfo = null;
	this.queryResult = null;
	this.commandResult = null;
	this.errorMessage = null;

	if (databasePath) {
		this.databaseUrl = databasePath.substring(0, databasePath
				.lastIndexOf('/'));
		this.databaseName = databasePath.substring(databasePath
				.lastIndexOf('/') + 1);
	}

	this.getDatabaseInfo = function() {
		return this.databaseInfo;
	}
	this.setDatabaseInfo = function(iDatabaseInfo) {
		this.databaseInfo = iDatabaseInfo;
	}

	this.getQueryResult = function() {
		return this.queryResult;
	}
	this.setQueryResult = function(iQueryResult) {
		this.queryResult = iQueryResult;
	}

	this.getCommandResult = function() {
		return this.commandResult;
	}
	this.setCommandResult = function(iCommandResult) {
		this.commandResult = iCommandResult;
	}

	this.getErrorMessage = function() {
		return this.errorMessage;
	}
	this.setErrorMessage = function(iErrorMessage) {
		this.errorMessage = iErrorMessage;
	}

	this.getDatabaseUrl = function() {
		return databaseUrl;
	}
	this.setDatabaseUrl = function(iDatabaseUrl) {
		this.databaseUrl = iDatabaseUrl;
	}

	this.getDatabaseName = function() {
		return this.databaseName;
	}
	this.setDatabaseName = function(iDatabaseName) {
		this.databaseName = iDatabaseName;
	}

	this.open = function() {
		$.ajax({
			type : "GET",
			url : this.databaseUrl + '/connect/' + this.databaseName,
			context : this,
			async : false,
			success : function(msg) {
				this.setErrorMessage(null);
				this.setDatabaseInfo(eval("(" + msg + ")"));
			},
			error : function(msg) {
				this.setErrorMessage('Connect error: ' + msg.responseText);
				this.setDatabaseInfo(null);
			}
		});
		return this.getDatabaseInfo();
	}

	this.query = function(iQuery) {
		if (this.databaseInfo == null) {
			this.open();
		}
		$.ajax({
			type : "GET",
			url : this.databaseUrl + '/query/' + this.databaseName + '/sql/'
					+ iQuery,
			context : this,
			async : false,
			success : function(msg) {
				this.setErrorMessage(null);
				this.setQueryResult(eval("(" + msg + ")"));
			},
			error : function(msg) {
				this.setQueryResult(null);
				this.setErrorMessage('Query error: ' + msg.responseText);
			}
		});
		return this.getQueryResult();
	}
	
	this.load = function(iRID) {
		if (this.databaseInfo == null) {
			this.open();
		}
		
		if( iRID.charAt(0) == '#' )
			iRID = iRID.substring(1);
		
		$.ajax({
			type : "GET",
			url : this.databaseUrl + '/document/' + this.databaseName + '/'
					+ iRID,
			context : this,
			async : false,
			success : function(msg) {
				this.setErrorMessage(null);
				this.setQueryResult(eval("(" + msg + ")"));
			},
			error : function(msg) {
				this.setQueryResult(null);
				this.setErrorMessage('Query error: ' + msg.responseText);
			}
		});
		return this.getQueryResult();
	}

	this.classInfo = function(iClassName) {
		if (this.databaseInfo == null) {
			this.open();
		}
		$.ajax({
			type : "GET",
			url : this.databaseUrl + '/class/' + this.databaseName + '/'
					+ iClassName,
			context : this,
			async : false,
{'fraction_non_alphanumeric': 0.1366643209007741, 'fraction_numerical': 0.00422237860661506, 'mean_word_length': 3.5289993626513705, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2251395', 'n_tokens_mistral': 2549, 'n_tokens_neox': 2238, 'n_words': 515}