<commit_before>"use strict"

function BimServerApi(baseUrl, notifier) {
	var othis = this;
	othis.interfaceMapping = {
		"ServiceInterface": "org.bimserver.ServiceInterface",
		"AuthInterface": "org.bimserver.AuthInterface",
		"SettingsInterface": "org.bimserver.SettingsInterface",
		"AdminInterface": "org.bimserver.AdminInterface",
		"PluginInterface": "org.bimserver.PluginInterface",
		"MetaInterface": "org.bimserver.MetaInterface",
		"Bimsie1LowLevelInterface": "org.buildingsmart.bimsie1.Bimsie1LowLevelInterface",
		"Bimsie1NotificationRegistryInterface": "org.buildingsmart.bimsie1.Bimsie1NotificationRegistryInterface",
		"Bimsie1AuthInterface": "org.buildingsmart.bimsie1.Bimsie1AuthInterface",
		"Bimsie1ServiceInterface": "org.buildingsmart.bimsie1.Bimsie1ServiceInterface"
	};

	othis.jsonSerializerFetcher = new Synchronizer(function(callback){
		othis.call("PluginInterface", "getSerializerByPluginClassName", {pluginClassName: "org.bimserver.serializers.JsonSerializerPlugin"}, function(serializer){
			callback(serializer.oid);
		});
	});

	othis.translations = {
		GETDATAOBJECTSBYTYPE_BUSY: "Loading objects",
		REQUESTPASSWORDCHANGE_BUSY: "Busy sending password reset e-mail",
		REQUESTPASSWORDCHANGE_DONE: "A password reset e-mail has been sent",
		SETSERVERSETTINGS_DONE: "Server settings successfully updated",
		ENABLEPLUGIN_DONE: "Plugin successfully enabled",
		DISABLEPLUGIN_DONE: "Plugin successfully disabled",
		SETDEFAULTWEBMODULE_DONE: "Default webmodule changed, a restart of the BIMserver is required for the changes to take effect",
		SETDEFAULTQUERYENGINE_DONE: "Default Query Engine successfully changed",
		SETDEFAULTMODELMERGER_DONE: "Default Model Merger successfully changed",
		SETDEFAULTSERIALIZER_DONE: "Default Serializer successfully changed",
		SETDEFAULTOBJECTIDM_DONE: "Default ObjectIDM successfully changed",
		SETDEFAULTRENDERENGINE_DONE: "Default Render Engine successfully changed",
		SETDEFAULTMODELCOMPARE_DONE: "Default Model Compare successfully changed",
		LOGIN_BUSY: "Trying to login",
		CHANGEUSERTYPE_DONE: "Type of user successfully changed",
		ADDUSER_DONE: "User successfully added",
		UPDATEINTERNALSERVICE_DONE: "Internal service successfully updated",
		UPDATEMODELCOMPARE_DONE: "Model compare plugin successfully updated",
		UPDATEMODELMERGER_DONE: "Model merger successfully updated",
		UPDATEQUERYENGINE_DONE: "Query engine plugin successfully updated",
		UPDATEOBJECTIDM_DONE: "ObjectIDM succesfully updated",
		UPDATEDESERIALIZER_DONE: "Serializer succesfully updated",
		ADDUSERTOPROJECT_DONE: "User successfully added to project",
		REMOVEUSERFROMPROJECT_DONE: "User successfully removed from project",
		UNDELETEPROJECT_DONE: "Project successfully undeleted",
		DELETEPROJECT_DONE: "Project successfully deleted",
		ADDPROJECT_DONE: "Project successfully added",
		DOWNLOAD_BUSY: "Busy downloading...",
		VALIDATEACCOUNT_DONE: "Account successfully validated, you can now login",
		ADDPROJECTASSUBPROJECT_DONE: "Sub project added successfully",
		DOWNLOADBYJSONQUERY_BUSY: "Downloading BIM",
		CHECKINFROMURL_DONE: "Done checking in from URL",
		GETLOGGEDINUSER_BUSY: "Getting user details",
		SETPLUGINSETTINGS_DONE: "Plugin settings successfully saved",
		GETSERVERINFO_BUSY: "Getting server info",
		GETVERSION_BUSY: "Getting server version",
		GETPROJECTBYPOID_BUSY: "Getting project details",
		GETALLRELATEDPROJECTS_BUSY: "Getting related project's details",
		GETSERIALIZERBYPLUGINCLASSNAME_BUSY: "Getting serializer info",
		CLEANUPLONGACTION_BUSY: "Cleaning up",
		GETREVISIONSUMMARY_BUSY: "Getting revision summary",
		DOWNLOADBYOIDS_BUSY: "Downloading model data",
		REGISTERPROGRESSHANDLER_BUSY: "Registering for updates on progress"
	}

	othis.token = null;
	othis.baseUrl = baseUrl;
	if (othis.baseUrl.substring(othis.baseUrl.length - 1) == "/") {
		othis.baseUrl = othis.baseUrl.substring(0, othis.baseUrl.length - 1);
	}
	othis.address = othis.baseUrl + "/json";
	othis.notifier = notifier;
	if (othis.notifier == null) {
		othis.notifier = {
			setInfo: function(message, timeout){},
			setSuccess: function(message, timeout){},
			setError: function(){},
			resetStatus: function(){},
			resetStatusQuick: function(){},
			clear: function(){}
		};
	}
	othis.server = new BimServerWebSocket(baseUrl, othis);
	othis.user = null;
	othis.listeners = {};
	othis.autoLoginTried = false;
	othis.serializersByPluginClassName = [];
	othis.debug = false;
	othis.classes = {};
	othis.binaryDataListener = {};
	othis.schemas = {};

	this.init = function(callback) {
		$.ajax({
			dataType: "json",
			url: othis.baseUrl + "/js/ifc2x3tc1.js?_v=" + othis.version,
			cache: true,
			success: function(result){
				othis.schemas["ifc2x3tc1"] = result.classes;
				othis.addSubtypesToSchema(result.classes);
				$.ajax({
					dataType: "json",
					url: othis.baseUrl + "/js/ifc4.js?_v=" + othis.version,
					cache: true,
					success: function(result){
						othis.schemas["ifc4"] = result.classes;
						othis.addSubtypesToSchema(result.classes);
						callback();
					}
				});
			}
		});
	};

	this.addSubtypesToSchema = function(classes) {
		for (var typeName in classes) {
			var type = classes[typeName];
			if (type.superclasses != null) {
				type.superclasses.forEach(function(superClass){
					var directSubClasses = classes[superClass].directSubClasses;
					if (directSubClasses == null) {
						directSubClasses = [];
						classes[superClass].directSubClasses = directSubClasses;
					}
					directSubClasses.push(typeName);
				});
			}
		}<commit_msg>added calls to get server info and version to bimserverapi, please remove from code calling the init() function<commit_after>"use strict"

function BimServerApi(baseUrl, notifier) {
	var othis = this;
	othis.interfaceMapping = {
		"ServiceInterface": "org.bimserver.ServiceInterface",
		"AuthInterface": "org.bimserver.AuthInterface",
		"SettingsInterface": "org.bimserver.SettingsInterface",
		"AdminInterface": "org.bimserver.AdminInterface",
		"PluginInterface": "org.bimserver.PluginInterface",
		"MetaInterface": "org.bimserver.MetaInterface",
		"Bimsie1LowLevelInterface": "org.buildingsmart.bimsie1.Bimsie1LowLevelInterface",
		"Bimsie1NotificationRegistryInterface": "org.buildingsmart.bimsie1.Bimsie1NotificationRegistryInterface",
		"Bimsie1AuthInterface": "org.buildingsmart.bimsie1.Bimsie1AuthInterface",
		"Bimsie1ServiceInterface": "org.buildingsmart.bimsie1.Bimsie1ServiceInterface"
	};

	othis.jsonSerializerFetcher = new Synchronizer(function(callback){
		othis.call("PluginInterface", "getSerializerByPluginClassName", {pluginClassName: "org.bimserver.serializers.JsonSerializerPlugin"}, function(serializer){
			callback(serializer.oid);
		});
	});

	othis.translations = {
		GETDATAOBJECTSBYTYPE_BUSY: "Loading objects",
		REQUESTPASSWORDCHANGE_BUSY: "Busy sending password reset e-mail",
		REQUESTPASSWORDCHANGE_DONE: "A password reset e-mail has been sent",
		SETSERVERSETTINGS_DONE: "Server settings successfully updated",
		ENABLEPLUGIN_DONE: "Plugin successfully enabled",
		DISABLEPLUGIN_DONE: "Plugin successfully disabled",
		SETDEFAULTWEBMODULE_DONE: "Default webmodule changed, a restart of the BIMserver is required for the changes to take effect",
		SETDEFAULTQUERYENGINE_DONE: "Default Query Engine successfully changed",
		SETDEFAULTMODELMERGER_DONE: "Default Model Merger successfully changed",
		SETDEFAULTSERIALIZER_DONE: "Default Serializer successfully changed",
		SETDEFAULTOBJECTIDM_DONE: "Default ObjectIDM successfully changed",
		SETDEFAULTRENDERENGINE_DONE: "Default Render Engine successfully changed",
		SETDEFAULTMODELCOMPARE_DONE: "Default Model Compare successfully changed",
		LOGIN_BUSY: "Trying to login",
		CHANGEUSERTYPE_DONE: "Type of user successfully changed",
		ADDUSER_DONE: "User successfully added",
		UPDATEINTERNALSERVICE_DONE: "Internal service successfully updated",
		UPDATEMODELCOMPARE_DONE: "Model compare plugin successfully updated",
		UPDATEMODELMERGER_DONE: "Model merger successfully updated",
		UPDATEQUERYENGINE_DONE: "Query engine plugin successfully updated",
		UPDATEOBJECTIDM_DONE: "ObjectIDM succesfully updated",
		UPDATEDESERIALIZER_DONE: "Serializer succesfully updated",
		ADDUSERTOPROJECT_DONE: "User successfully added to project",
		REMOVEUSERFROMPROJECT_DONE: "User successfully removed from project",
		UNDELETEPROJECT_DONE: "Project successfully undeleted",
		DELETEPROJECT_DONE: "Project successfully deleted",
		ADDPROJECT_DONE: "Project successfully added",
		DOWNLOAD_BUSY: "Busy downloading...",
		VALIDATEACCOUNT_DONE: "Account successfully validated, you can now login",
		ADDPROJECTASSUBPROJECT_DONE: "Sub project added successfully",
		DOWNLOADBYJSONQUERY_BUSY: "Downloading BIM",
		CHECKINFROMURL_DONE: "Done checking in from URL",
		GETLOGGEDINUSER_BUSY: "Getting user details",
		SETPLUGINSETTINGS_DONE: "Plugin settings successfully saved",
		GETSERVERINFO_BUSY: "Getting server info",
		GETVERSION_BUSY: "Getting server version",
		GETPROJECTBYPOID_BUSY: "Getting project details",
		GETALLRELATEDPROJECTS_BUSY: "Getting related project's details",
		GETSERIALIZERBYPLUGINCLASSNAME_BUSY: "Getting serializer info",
		CLEANUPLONGACTION_BUSY: "Cleaning up",
		GETREVISIONSUMMARY_BUSY: "Getting revision summary",
		DOWNLOADBYOIDS_BUSY: "Downloading model data",
		REGISTERPROGRESSHANDLER_BUSY: "Registering for updates on progress"
	}

	othis.token = null;
	othis.baseUrl = baseUrl;
	if (othis.baseUrl.substring(othis.baseUrl.length - 1) == "/") {
		othis.baseUrl = othis.baseUrl.substring(0, othis.baseUrl.length - 1);
	}
	othis.address = othis.baseUrl + "/json";
	othis.notifier = notifier;
	if (othis.notifier == null) {
		othis.notifier = {
			setInfo: function(message, timeout){},
			setSuccess: function(message, timeout){},
			setError: function(){},
			resetStatus: function(){},
			resetStatusQuick: function(){},
			clear: function(){}
		};
	}
	othis.server = new BimServerWebSocket(baseUrl, othis);
	othis.user = null;
	othis.listeners = {};
	othis.autoLoginTried = false;
	othis.serializersByPluginClassName = [];
	othis.debug = false;
	othis.classes = {};
	othis.binaryDataListener = {};
	othis.schemas = {};

	this.init = function(callback) {
		// TODO make 1 call
		othis.call("AdminInterface", "getServerInfo", {}, function(serverInfo){
			othis.call("AdminInterface", "getVersion", {}, function(version){
				othis.version = version;
				$.ajax({
					dataType: "json",
					url: othis.baseUrl + "/js/ifc2x3tc1.js?_v=" + othis.version,
					cache: true,
					success: function(result){
						othis.schemas["ifc2x3tc1"] = result.classes;
						othis.addSubtypesToSchema(result.classes);
						$.ajax({
							dataType: "json",
							url: othis.baseUrl + "/js/ifc4.js?_v=" + othis.version,
							cache: true,
							success: function(result){
								othis.schemas["ifc4"] = result.classes;
								othis.addSubtypesToSchema(result.classes);
								callback(this, serverInfo);
							}
						});
					}
				});
			});
		});
	};

	this.addSubtypesToSchema = function(classes) {
		for (var typeName in classes) {
			var type = classes[typeName];
			if (type.superclasses != null) {
				type.superclasses.forEach(function(superClass){
					var directSubClasses = classes[superClass].directSubClasses;
					if (directSubClasses == null) {
						directSubClasses = [];
						classes[superClass].directSubClasses = directSubClasses;
					}
					directSubClasses.push(typeName);
				});
			}
		}
{'fraction_non_alphanumeric': 0.1088037693045982, 'fraction_numerical': 0.004100863798970422, 'mean_word_length': 5.527334851936219, 'pattern_counts': {'":': 20, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '341007', 'n_tokens_mistral': 4031, 'n_tokens_neox': 3631, 'n_words': 758}