<commit_before>angular.module('registry', ['schema-utils', 'psui', 'psui.form-ctrl', 'psui-objectlink', 'psui-default-src', 'psui-selectbox', 'xpsui'])
.controller('registry.customTemplateCtrl', ['$scope', '$routeParams', '$http', 'schema-utils.SchemaUtilFactory',
		'psui.notificationFactory', function($scope, $routeParams, $http, schemaUtilFactory, notificationFactory) {
		$scope.model = {};
		$scope.currentSchemaUri = schemaUtilFactory.decodeUri($routeParams.schema);

		$http({ method : 'GET',url: '/udao/getBySchema/'+$routeParams.schema+'/'+ $routeParams.id})
		.success(function(data, status, headers, config){
			$scope.model = data;
		}).error(function(err) {
			notificationFactory.error(err);
		});
}])
.controller('registry.newCtrl', ['$route',
		'$scope',
		'$routeParams',
		'$http',
		'$location',
		'schema-utils.SchemaUtilFactory',
		'psui.notificationFactory',
		function($route, $scope, $routeParams, $http, $location,schemaUtilFactory,notificationFactory) {
	$scope.currentSchemaUri = schemaUtilFactory.decodeUri($routeParams.schema);

	$scope.model = {};
	$scope.model.obj = {};
	
	$scope.schemaFormOptions = {
		modelPath: 'model.obj',
		schema: {}
	};

	$scope.save = function() {
		$scope.newForm.psui.prepareForSubmit();
		if ($scope.newForm.$invalid) {
			notificationFactory.error({translationCode: 'registry.form.not.filled.correctly', time: 5000});
			return;
		}

		$http({url: '/udao/saveBySchema/'+schemaUtilFactory.encodeUri(schemaUtilFactory.concatUri($scope.currentSchemaUri , 'new')), method: 'PUT',data: $scope.model.obj})
		.success(function(data, status, headers, config){
			notificationFactory.clear();
			$location.path('/#/registry/view/' + schemaUtilFactory.encodeUri($scope.currentSchemaUri) + '/' + data.id);
		}).error(function(err) {
			notificationFactory.error({translationCode:'registry.unsuccesfully.saved', time:3000});
		});
	};

	$scope.cancel = function() {
		$route.reload();
	};

	schemaUtilFactory.getCompiledSchema($scope.currentSchemaUri, 'new').success(function(data) {
		$scope.schemaFormOptions.schema = data;
		schemaUtilFactory.generateObjectFromSchema($scope.schemaFormOptions.schema, $scope.model.obj);
	}).error(function(err) {
		notificationFactory.error(err);
	});
}])
.controller('registry.viewCtrl', ['$scope', '$routeParams', '$http', '$location','schema-utils.SchemaUtilFactory','psui.notificationFactory', function($scope, $routeParams, $http, $location,schemaUtilFactory,notificationFactory) {
	$scope.currentSchema = $routeParams.schema;
	$scope.currentId = $routeParams.id;<commit_msg>FIX wrong redirection on new form submit<commit_after>angular.module('registry', ['schema-utils', 'psui', 'psui.form-ctrl', 'psui-objectlink', 'psui-default-src', 'psui-selectbox', 'xpsui'])
.controller('registry.customTemplateCtrl', ['$scope', '$routeParams', '$http', 'schema-utils.SchemaUtilFactory',
		'psui.notificationFactory', function($scope, $routeParams, $http, schemaUtilFactory, notificationFactory) {
		$scope.model = {};
		$scope.currentSchemaUri = schemaUtilFactory.decodeUri($routeParams.schema);

		$http({ method : 'GET',url: '/udao/getBySchema/'+$routeParams.schema+'/'+ $routeParams.id})
		.success(function(data, status, headers, config){
			$scope.model = data;
		}).error(function(err) {
			notificationFactory.error(err);
		});
}])
.controller('registry.newCtrl', ['$route',
		'$scope',
		'$routeParams',
		'$http',
		'$location',
		'schema-utils.SchemaUtilFactory',
		'psui.notificationFactory',
		function($route, $scope, $routeParams, $http, $location,schemaUtilFactory,notificationFactory) {
	$scope.currentSchemaUri = schemaUtilFactory.decodeUri($routeParams.schema);

	$scope.model = {};
	$scope.model.obj = {};
	
	$scope.schemaFormOptions = {
		modelPath: 'model.obj',
		schema: {}
	};

	$scope.save = function() {
		$scope.newForm.psui.prepareForSubmit();
		if ($scope.newForm.$invalid) {
			notificationFactory.error({translationCode: 'registry.form.not.filled.correctly', time: 5000});
			return;
		}

		$http({url: '/udao/saveBySchema/'+schemaUtilFactory.encodeUri(schemaUtilFactory.concatUri($scope.currentSchemaUri , 'new')), method: 'PUT',data: $scope.model.obj})
		.success(function(data, status, headers, config){
			notificationFactory.clear();
			$location.path('/registry/view/' + schemaUtilFactory.encodeUri($scope.currentSchemaUri) + '/' + data.id);
		}).error(function(err) {
			notificationFactory.error({translationCode:'registry.unsuccesfully.saved', time:3000});
		});
	};

	$scope.cancel = function() {
		$route.reload();
	};

	schemaUtilFactory.getCompiledSchema($scope.currentSchemaUri, 'new').success(function(data) {
		$scope.schemaFormOptions.schema = data;
		schemaUtilFactory.generateObjectFromSchema($scope.schemaFormOptions.schema, $scope.model.obj);
	}).error(function(err) {
		notificationFactory.error(err);
	});
}])
.controller('registry.viewCtrl', ['$scope', '$routeParams', '$http', '$location','schema-utils.SchemaUtilFactory','psui.notificationFactory', function($scope, $routeParams, $http, $location,schemaUtilFactory,notificationFactory) {
	$scope.currentSchema = $routeParams.schema;
	$scope.currentId = $routeParams.id;
{'fraction_non_alphanumeric': 0.18414421399496025, 'fraction_numerical': 0.0031013762357045937, 'mean_word_length': 6.478260869565218, 'pattern_counts': {'":': 0, '<': 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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '484930', 'n_tokens_mistral': 1710, 'n_tokens_neox': 1594, 'n_words': 219}