INSERT INTO rest_parameter 
	(idrestparameter, identifier, description) 
		VALUES (1,'CONTRACT_ID', 'ID do contrato')
	ON DUPLICATE KEY UPDATE
		description = 'ID do contrato';
		
INSERT INTO rest_parameter 
	(idrestparameter, identifier, description) 
		VALUES (2, 'ORIGIN_ID', 'ID da origem')
	ON DUPLICATE KEY UPDATE
		description = 'ID da origem';
		
INSERT INTO rest_parameter 
	(idrestparameter, identifier, description) 
		VALUES (3, 'REQUEST_ID', 'ID do tipo de demanda para requisições')
	ON DUPLICATE KEY UPDATE
		description = 'ID do tipo de demanda para requisições';
		
INSERT INTO rest_parameter 
	(idrestparameter, identifier, description) 
		VALUES (4, 'INCIDENT_ID', 'ID do tipo de demanda para incidentes')
	ON DUPLICATE KEY UPDATE
		description = 'ID do tipo de demanda para incidentes';
		
INSERT INTO rest_parameter 
	(idrestparameter, identifier, description) 
		VALUES (5, 'DEFAULT_DEPTO_ID', 'ID padrão da unidade')
	ON DUPLICATE KEY UPDATE
		description = 'ID padrão da unidade';
		
INSERT INTO rest_parameter 
	(idrestparameter, identifier, description) 
		VALUES (6, 'DEFAULT_SLA', 'ID padrão do acordo de nível de serviço')
	ON DUPLICATE KEY UPDATE
		description = 'ID padrão do acordo de nível de serviço';
		
INSERT INTO rest_parameter 
	(idrestparameter, identifier, description) 
		VALUES (56, 'DEFAULT_REASON_ID', 'ID justificativa padrão para alteração de situação')
	ON DUPLICATE KEY UPDATE
		description = 'ID justificativa padrão para alteração de situação';
		
INSERT INTO rest_parameter 
	(idrestparameter, identifier, description) 
		VALUES (106, 'DEFAULT_SERVICE_ID', 'ID do serviço padrão')
	ON DUPLICATE KEY UPDATE
		description = 'ID do serviço padrão';
		
INSERT INTO rest_parameter 
	(idrestparameter, identifier, description) 
		VALUES (107, 'CHANGE_USER', 'Permite alteração do solicitante')
	ON DUPLICATE KEY UPDATE
		description = 'Permite alteração do solicitante';
		
INSERT INTO rest_parameter 
	(idrestparameter, identifier, description) 
		VALUES (108, 'CHANGE_GROUP', 'Permite redirecionamento')
	ON DUPLICATE KEY UPDATE
		description = 'Permite redirecionamento';
		
INSERT INTO rest_parameter 
	(idrestparameter, identifier, description) 
		VALUES (109, 'CHANGE_SERVICE', 'Permite reclassificação')
	ON DUPLICATE KEY UPDATE
		description = 'Permite reclassificação';
		
INSERT INTO rest_parameter 
	(idrestparameter, identifier, description) 
		VALUES (156, 'DEFAULT_GROUP_ID', 'ID do grupo executor padrão')
	ON DUPLICATE KEY UPDATE
		description = 'ID do grupo executor padrão';
		
INSERT INTO rest_parameter 
	(idrestparameter, identifier, description) 
		VALUES (157, 'DEFAULT_DESCRIPTION', 'Complemento padrão da descrição')
	ON DUPLICATE KEY UPDATE
		description = 'Complemento padrão da descrição';
		
INSERT INTO rest_parameter 
	(idrestparameter, identifier, description) 
		VALUES (356, 'USER', 'SQL recupera usuário pelo login')
	ON DUPLICATE KEY UPDATE
		description = 'SQL recupera usuário pelo login';
		
INSERT INTO rest_parameter 
	(idrestparameter, identifier, description) 
		VALUES (357, 'REQUEST_BY_ID', 'SQL recupera solicitação/incidente pelo ID')
	ON DUPLICATE KEY UPDATE
		description = 'SQL recupera solicitação/incidente pelo ID';
		
INSERT INTO rest_parameter 
	(idrestparameter, identifier, description) 
		VALUES (358, 'REQUEST_BY_DESCRIPTION', 'SQL recupera solicitação/incidente pela descrição')
	ON DUPLICATE KEY UPDATE
		description = 'SQL recupera solicitação/incidente pela descrição';
		

SET @id:= (SELECT (CASE count(idrestoperation) WHEN 0 THEN 1 ELSE max(idrestoperation)+1 END ) FROM rest_operation);
INSERT INTO rest_operation (
			idrestoperation,
			idbatchprocessing, name, 
			description, operationtype, classtype, 
			javaclass, javascript, status, generatelog)
	VALUES (
			@id,
			NULL, 'addServiceRequest', 
			'Criação de solicitação de serviço',
			'Sync', 'Java',
			'br.com.centralit.citsmart.rest.operation.RestAddServiceRequest', NULL, 'A', 'Y')
ON DUPLICATE KEY UPDATE
	description = 'Criação de solicitação de serviço';

SET @id:= (SELECT (CASE count(idrestoperation) WHEN 0 THEN 1 ELSE max(idrestoperation)+1 END ) FROM rest_operation);
INSERT INTO rest_operation (
			idrestoperation,
			idbatchprocessing, name, 
			description, operationtype, classtype, 
			javaclass, javascript, status, generatelog)
	VALUES (
			@id,
			NULL, 'listTasks', 
			'Listagem de tarefas',
			'Sync', 'Java',
			'br.com.centralit.citsmart.rest.operation.RestListTasks', NULL, 'A', 'Y')
ON DUPLICATE KEY UPDATE
	description = 'Listagem de tarefas';

SET @id:= (SELECT (CASE count(idrestoperation) WHEN 0 THEN 1 ELSE max(idrestoperation)+1 END ) FROM rest_operation);
INSERT INTO rest_operation (
			idrestoperation,
			idbatchprocessing, name, 
			description, operationtype, classtype, 
			javaclass, javascript, status, generatelog)
	VALUES (
			@id,
			NULL, 'notification_getByUser', 
			'Retorna lista de notificações para Mobile',
			'Sync', 'Java',
			'br.com.centralit.citsmart.rest.operation.RestMobile', NULL, 'A', 'Y')
ON DUPLICATE KEY UPDATE
	description = 'Retorna lista de notificações para Mobile';

SET @id:= (SELECT (CASE count(idrestoperation) WHEN 0 THEN 1 ELSE max(idrestoperation)+1 END ) FROM rest_operation);
INSERT INTO rest_operation (
			idrestoperation,
			idbatchprocessing, name, 
			description, operationtype, classtype, 
			javaclass, javascript, status, generatelog)
	VALUES (
			@id,
			NULL, 'notification_getById', 
			'Retorna detalhes de uma notificação para Mobile',
			'Sync', 'Java',
			'br.com.centralit.citsmart.rest.operation.RestMobile', NULL, 'A', 'Y')
ON DUPLICATE KEY UPDATE
	description = 'Retorna detalhes de uma notificação para Mobile';

SET @id:= (SELECT (CASE count(idrestoperation) WHEN 0 THEN 1 ELSE max(idrestoperation)+1 END ) FROM rest_operation);
INSERT INTO rest_operation (
			idrestoperation,
			idbatchprocessing, name, 
			description, operationtype, classtype, 
			javaclass, javascript, status, generatelog)
	VALUES (
			@id,
			NULL, 'notification_feedback', 
			'Processa feedback de uma notificação para Mobile',
			'Sync', 'Java',
			'br.com.centralit.citsmart.rest.operation.RestMobile', NULL, 'A', 'Y')
ON DUPLICATE KEY UPDATE
	description = 'Processa feedback de uma notificação para Mobile';

SET @id:= (SELECT (CASE count(idrestoperation) WHEN 0 THEN 1 ELSE max(idrestoperation)+1 END ) FROM rest_operation);
INSERT INTO rest_operation (
			idrestoperation,
			idbatchprocessing, name, 
			description, operationtype, classtype, 
			javaclass, javascript, status, generatelog)
	VALUES (
			@id,
			NULL, 'notification_new', 
			'Cria uma notificação para Mobile',
			'Sync', 'Java',
			'br.com.centralit.citsmart.rest.operation.RestMobile', NULL, 'A', 'Y')
ON DUPLICATE KEY UPDATE
	description = 'Cria uma notificação para Mobile';

SET @id:= (SELECT (CASE count(idrestoperation) WHEN 0 THEN 1 ELSE max(idrestoperation)+1 END ) FROM rest_operation);
INSERT INTO rest_operation (
			idrestoperation,
			idbatchprocessing, name, 
			description, operationtype, classtype, 
			javaclass, javascript, status, generatelog)
	VALUES (
			@id,
			NULL, 'notification_getReasons', 
			'Retorna justificativas possíveis para uma notificação',
			'Sync', 'Java',
			'br.com.centralit.citsmart.rest.operation.RestMobile', NULL, 'A', 'Y')
ON DUPLICATE KEY UPDATE
	description = 'Retorna justificativas possíveis para uma notificação';

SET @id:= (SELECT (CASE count(idrestoperation) WHEN 0 THEN 1 ELSE max(idrestoperation)+1 END ) FROM rest_operation);
INSERT INTO rest_operation (
			idrestoperation,
			idbatchprocessing, name, 
			description, operationtype, classtype, 
			javaclass, javascript, status, generatelog)
	VALUES (
			@id,
			NULL, 'bicitsmart_recuperarTabelas', 
			'Retorna todos os dados das tabelas necessárias para o BI do Citsmart',
			'Sync', 'Java',
			'br.com.centralit.citsmart.rest.operation.RestBICitsmart', NULL, 'A', 'Y')
ON DUPLICATE KEY UPDATE
	description = 'Retorna todos os dados das tabelas necessárias para o BI do Citsmart';

SET @id:= (SELECT (CASE count(idrestoperation) WHEN 0 THEN 1 ELSE max(idrestoperation)+1 END ) FROM rest_operation);
INSERT INTO rest_operation (
			idrestoperation,
			idbatchprocessing, name, 
			description, operationtype, classtype, 
			javaclass, javascript, status, generatelog)
	VALUES (
			@id,
			NULL, 'service_coordinates', 
			'Recebe a coordenada da unidade check-in unidade',
			'Sync', 'Java',
			'br.com.centralit.citsmart.rest.v2.operation.RESTOperation', NULL, 'A', 'Y')
ON DUPLICATE KEY UPDATE
	description = 'Recebe a coordenada da unidade check-in unidade';

SET @id:= (SELECT (CASE count(idrestoperation) WHEN 0 THEN 1 ELSE max(idrestoperation)+1 END ) FROM rest_operation);
INSERT INTO rest_operation (
			idrestoperation,
			idbatchprocessing, name, 
			description, operationtype, classtype, 
			javaclass, javascript, status, generatelog)
	VALUES (
			@id,
			NULL, 'service_listContracts', 
			'Retornar lista de  Contratos ativos do Citsmart',
			'Sync', 'Java',
			'br.com.centralit.citsmart.rest.v2.operation.RESTOperation', NULL, 'A', 'Y')
ON DUPLICATE KEY UPDATE
	description = 'Retornar lista de Contratos ativos do Citsmart';

SET @id:= (SELECT (CASE count(idrestoperation) WHEN 0 THEN 1 ELSE max(idrestoperation)+1 END ) FROM rest_operation);
INSERT INTO rest_operation (
			idrestoperation,
			idbatchprocessing, name, 
			description, operationtype, classtype, 
			javaclass, javascript, status, generatelog)
	VALUES (
			@id,
			NULL, 'service_listDeniedReasons', 
			'Lista de Justificativa',
			'Sync', 'Java',
			'br.com.centralit.citsmart.rest.v2.operation.RESTOperation', NULL, 'A', 'Y')
ON DUPLICATE KEY UPDATE
	description = 'Lista de Justificativa';

SET @id:= (SELECT (CASE count(idrestoperation) WHEN 0 THEN 1 ELSE max(idrestoperation)+1 END ) FROM rest_operation);
INSERT INTO rest_operation (
			idrestoperation,
			idbatchprocessing, name, 
			description, operationtype, classtype, 
			javaclass, javascript, status, generatelog)
	VALUES (
			@id,
			NULL, 'service_listSolicitationStatus', 
			'Lista status da solicitação de serviço',
			'Sync', 'Java',
			'br.com.centralit.citsmart.rest.v2.operation.RESTOperation', NULL, 'A', 'Y')
ON DUPLICATE KEY UPDATE
	description = 'Lista status da solicitações de serviço';

SET @id:= (SELECT (CASE count(idrestoperation) WHEN 0 THEN 1 ELSE max(idrestoperation)+1 END ) FROM rest_operation);
INSERT INTO rest_operation (
			idrestoperation,
			idbatchprocessing, name, 
			description, operationtype, classtype, 
			javaclass, javascript, status, generatelog)
	VALUES (
			@id,
			NULL, 'service_listUnits', 
			'Lista de unidade de um contrato',
			'Sync', 'Java',
			'br.com.centralit.citsmart.rest.v2.operation.RESTOperation', NULL, 'A', 'Y')
ON DUPLICATE KEY UPDATE
	description = 'Lista de unidade de um contrato';

SET @id:= (SELECT (CASE count(idrestoperation) WHEN 0 THEN 1 ELSE max(idrestoperation)+1 END ) FROM rest_operation);
INSERT INTO rest_operation (
			idrestoperation,
			idbatchprocessing, name, 
			description, operationtype, classtype, 
			javaclass, javascript, status, generatelog)
	VALUES (
			@id,
			NULL, 'notification_attendantLocation', 
			'Localização de um atendente',
			'Sync', 'Java',
			'br.com.centralit.citsmart.rest.v2.operation.RESTMobile', NULL, 'A', 'Y')
ON DUPLICATE KEY UPDATE
	description = 'Localização de um atendente';

SET @id:= (SELECT (CASE count(idrestoperation) WHEN 0 THEN 1 ELSE max(idrestoperation)+1 END ) FROM rest_operation);
INSERT INTO rest_operation (
			idrestoperation,
			idbatchprocessing, name, 
			description, operationtype, classtype, 
			javaclass, javascript, status, generatelog)
	VALUES (
			@id,
			NULL, 'notification_getNewest', 
			'Lista de solicitações novas',
			'Sync', 'Java',
			'br.com.centralit.citsmart.rest.v2.operation.RESTMobile', NULL, 'A', 'Y')
ON DUPLICATE KEY UPDATE
	description = 'Lista de solicitações novas';

SET @id:= (SELECT (CASE count(idrestoperation) WHEN 0 THEN 1 ELSE max(idrestoperation)+1 END ) FROM rest_operation);
INSERT INTO rest_operation (
			idrestoperation,
			idbatchprocessing, name, 
			description, operationtype, classtype, 
			javaclass, javascript, status, generatelog)
	VALUES (
			@id,
			NULL, 'notification_getOldest', 
			'Lista de novas solicitações destinadas ao usuário',
			'Sync', 'Java',
			'br.com.centralit.citsmart.rest.v2.operation.RESTMobile', NULL, 'A', 'Y')
ON DUPLICATE KEY UPDATE
	description = 'Lista de novas solicitações destinadas ao usuário';

SET @id:= (SELECT (CASE count(idrestoperation) WHEN 0 THEN 1 ELSE max(idrestoperation)+1 END ) FROM rest_operation);
INSERT INTO rest_operation (
			idrestoperation,
			idbatchprocessing, name, 
			description, operationtype, classtype, 
			javaclass, javascript, status, generatelog)
	VALUES (
			@id,
			NULL, 'notification_checkin', 
			'Check-in da solicitação',
			'Sync', 'Java',
			'br.com.centralit.citsmart.rest.v2.operation.RESTMobile', NULL, 'A', 'Y')
ON DUPLICATE KEY UPDATE
	description = 'Check-in da solicitação';

SET @id:= (SELECT (CASE count(idrestoperation) WHEN 0 THEN 1 ELSE max(idrestoperation)+1 END ) FROM rest_operation);
INSERT INTO rest_operation (
			idrestoperation,
			idbatchprocessing, name, 
			description, operationtype, classtype, 
			javaclass, javascript, status, generatelog)
	VALUES (
			@id,
			NULL, 'notification_checkinDenied', 
			'Negação de check-in de uma sugestão de solicitação de serviço',
			'Sync', 'Java',
			'br.com.centralit.citsmart.rest.v2.operation.RESTMobile', NULL, 'A', 'Y')
ON DUPLICATE KEY UPDATE
	description = 'Negação de check-in de uma sugestão de solicitação de serviço';

SET @id:= (SELECT (CASE count(idrestoperation) WHEN 0 THEN 1 ELSE max(idrestoperation)+1 END ) FROM rest_operation);
INSERT INTO rest_operation (
			idrestoperation,
			idbatchprocessing, name, 
			description, operationtype, classtype, 
			javaclass, javascript, status, generatelog)
	VALUES (
			@id,
			NULL, 'notification_checkout', 
			'Check-out, finalização de uma solicitação de serviço',
			'Sync', 'Java',
			'br.com.centralit.citsmart.rest.v2.operation.RESTMobile', NULL, 'A', 'Y')
ON DUPLICATE KEY UPDATE
	description = 'Check-out, finalização de uma solicitação de serviço';

SET @id:= (SELECT (CASE count(idrestoperation) WHEN 0 THEN 1 ELSE max(idrestoperation)+1 END ) FROM rest_operation);
INSERT INTO rest_operation (
			idrestoperation,
			idbatchprocessing, name, 
			description, operationtype, classtype, 
			javaclass, javascript, status, generatelog)
	VALUES (
			@id,
			NULL, 'notification_getByCoordinates', 
			'Lista de solicitações novas - coordenadas',
			'Sync', 'Java',
			'br.com.centralit.citsmart.rest.v2.operation.RESTMobile', NULL, 'A', 'Y')
ON DUPLICATE KEY UPDATE
	description = 'Lista de solicitações novas - coordenadas';

SET @id:= (SELECT (CASE count(idrestoperation) WHEN 0 THEN 1 ELSE max(idrestoperation)+1 END ) FROM rest_operation);
INSERT INTO rest_operation (
			idrestoperation,
			idbatchprocessing, name, 
			description, operationtype, classtype, 
			javaclass, javascript, status, generatelog)
	VALUES (
			@id,
			NULL, 'notification_attendRequest', 
			'Atender solicitação',
			'Sync', 'Java',
			'br.com.centralit.citsmart.rest.v2.operation.RESTMobile', NULL, 'A', 'Y')
ON DUPLICATE KEY UPDATE
	description = 'Atender solicitação';

SET @id:= (SELECT (CASE count(idrestoperation) WHEN 0 THEN 1 ELSE max(idrestoperation)+1 END ) FROM rest_operation);
INSERT INTO rest_operation (
			idrestoperation,
			idbatchprocessing, name, 
			description, operationtype, classtype, 
			javaclass, javascript, status, generatelog)
	VALUES (
			@id,
			NULL, 'service_deviceDisassociate', 
			'Desassociar device do atendente',
			'Sync', 'Java',
			'br.com.centralit.citsmart.rest.v2.operation.RESTOperation', NULL, 'A', 'Y')
ON DUPLICATE KEY UPDATE
	description = 'Desassociar device do atendente';

SET @id:= (SELECT (CASE count(idrestoperation) WHEN 0 THEN 1 ELSE max(idrestoperation)+1 END ) FROM rest_operation);
INSERT INTO rest_operation (
			idrestoperation,
			idbatchprocessing, name, 
			description, operationtype, classtype, 
			javaclass, javascript, status, generatelog)
	VALUES (
			@id,
			NULL, 'notification_updateNotification', 
			'Restaura tarefas e permissões de uma solicitação de serviço',
			'Sync', 'Java',
			'br.com.centralit.citsmart.rest.v2.operation.RESTMobile', NULL, 'A', 'Y')
ON DUPLICATE KEY UPDATE
	description = 'Restaura tarefas e permissões de uma solicitação de serviço';

SET @id:= (SELECT (CASE count(idrestoperation) WHEN 0 THEN 1 ELSE max(idrestoperation)+1 END ) FROM rest_operation);
INSERT INTO rest_operation (
			idrestoperation,
			idbatchprocessing, name, 
			description, operationtype, classtype, 
			javaclass, javascript, status, generatelog)
	VALUES (
			@id,
			NULL, 'notification_getById_v2', 
			'Retorna detalhes de uma notificação para mobile',
			'Sync', 'Java',
			'br.com.centralit.citsmart.rest.v2.operation.RESTMobile', NULL, 'A', 'Y')
ON DUPLICATE KEY UPDATE
	description = 'Retorna detalhes de uma notificação para mobile';

SET @id:= (SELECT (CASE count(idrestoperation) WHEN 0 THEN 1 ELSE max(idrestoperation)+1 END ) FROM rest_operation);
INSERT INTO rest_operation (
			idrestoperation,
			idbatchprocessing, name, 
			description, operationtype, classtype, 
			javaclass, javascript, status, generatelog)
	VALUES (
			@id,
			NULL, 'request_create', 
			'Cria novas solicitações de serviço',
			'Sync', 'Java',
			'br.com.centralit.citsmart.rest.v3.operation.RESTOperation', NULL, 'A', 'Y')
ON DUPLICATE KEY UPDATE
	description = 'Cria novas solicitações de serviço';

SET @id:= (SELECT (CASE count(idrestoperation) WHEN 0 THEN 1 ELSE max(idrestoperation)+1 END ) FROM rest_operation);
INSERT INTO rest_operation (
			idrestoperation,
			idbatchprocessing, name, 
			description, operationtype, classtype, 
			javaclass, javascript, status, generatelog)
	VALUES (
			@id,
			NULL, 'request_update', 
			'Altera solicitações de serviço',
			'Sync', 'Java',
			'br.com.centralit.citsmart.rest.v3.operation.RESTOperation', NULL, 'A', 'Y')
ON DUPLICATE KEY UPDATE
	description = 'Altera solicitações de serviço';

SET @id:= (SELECT (CASE count(idrestoperation) WHEN 0 THEN 1 ELSE max(idrestoperation)+1 END ) FROM rest_operation);
INSERT INTO rest_operation (
			idrestoperation,
			idbatchprocessing, name, 
			description, operationtype, classtype, 
			javaclass, javascript, status, generatelog)
	VALUES (
			@id,
			NULL, 'request_updateStatus', 
			'Atualiza status de uma solicitação',
			'Sync', 'Java',
			'br.com.centralit.citsmart.rest.v3.operation.RESTOperation', NULL, 'A', 'Y')
ON DUPLICATE KEY UPDATE
	description = 'Atualiza status de uma solicitação';

SET @id:= (SELECT (CASE count(idrestoperation) WHEN 0 THEN 1 ELSE max(idrestoperation)+1 END ) FROM rest_operation);
INSERT INTO rest_operation (
			idrestoperation,
			idbatchprocessing, name, 
			description, operationtype, classtype, 
			javaclass, javascript, status, generatelog)
	VALUES (
			@id,
			NULL, 'request_getByUser', 
			'Consulta requisições por usuário',
			'Sync', 'Java',
			'br.com.centralit.citsmart.rest.v3.operation.RESTOperation', NULL, 'A', 'Y')
ON DUPLICATE KEY UPDATE
	description = 'Consulta requisições por usuário';

SET @id:= (SELECT (CASE count(idrestoperation) WHEN 0 THEN 1 ELSE max(idrestoperation)+1 END ) FROM rest_operation);
INSERT INTO rest_operation (
			idrestoperation,
			idbatchprocessing, name, 
			description, operationtype, classtype, 
			javaclass, javascript, status, generatelog)
	VALUES (
			@id,
			NULL, 'request_getById', 
			'Detalha requisição pelo número',
			'Sync', 'Java',
			'br.com.centralit.citsmart.rest.v3.operation.RESTOperation', NULL, 'A', 'N')
ON DUPLICATE KEY UPDATE
	description = 'Detalha requisição pelo número';

SET @id:= (SELECT (CASE count(idrestoperation) WHEN 0 THEN 1 ELSE max(idrestoperation)+1 END ) FROM rest_operation);
INSERT INTO rest_operation (
			idrestoperation,
			idbatchprocessing, name, 
			description, operationtype, classtype, 
			javaclass, javascript, status, generatelog)
	VALUES (
			@id,
			NULL, 'request_create_occurrence', 
			'Cria uma ocorrência de solicitação',
			'Sync', 'Java',
			'br.com.centralit.citsmart.rest.v3.operation.RESTOperation', NULL, 'A', 'N')
ON DUPLICATE KEY UPDATE
	description = 'Cria uma ocorrência de solicitação';

SET @id:= (SELECT (CASE count(idrestoperation) WHEN 0 THEN 1 ELSE max(idrestoperation)+1 END ) FROM rest_operation);
INSERT INTO rest_operation (
			idrestoperation,
			idbatchprocessing, name, 
			description, operationtype, classtype, 
			javaclass, javascript, status, generatelog)
	VALUES (
			@id,
			NULL, 'request_list_occurrences', 
			'Lista as ocorrências de uma solicitação',
			'Sync', 'Java',
			'br.com.centralit.citsmart.rest.v3.operation.RESTOperation', NULL, 'A', 'N')
ON DUPLICATE KEY UPDATE
	description = 'Lista as ocorrências de uma solicitação';

SET @id:= (SELECT (CASE count(idrestoperation) WHEN 0 THEN 1 ELSE max(idrestoperation)+1 END ) FROM rest_operation);
INSERT INTO rest_operation (
			idrestoperation,
			idbatchprocessing, name, 
			description, operationtype, classtype, 
			javaclass, javascript, status, generatelog)
	VALUES (
			@id,
			NULL, 'request_getNotSynchronized', 
			'Recupera requisições não sincronizadas',
			'Sync', 'Java',
			'br.com.centralit.citsmart.rest.v3.operation.RESTSynchronize', NULL, 'A', 'N')
ON DUPLICATE KEY UPDATE
	description = 'Recupera requisições não sincronizadas';

SET @id:= (SELECT (CASE count(idrestoperation) WHEN 0 THEN 1 ELSE max(idrestoperation)+1 END ) FROM rest_operation);
INSERT INTO rest_operation (
			idrestoperation,
			idbatchprocessing, name, 
			description, operationtype, classtype, 
			javaclass, javascript, status, generatelog)
	VALUES (
			@id,
			NULL, 'synchronize', 
			'Sincronização de dados',
			'Sync', 'Java',
			'br.com.centralit.citsmart.rest.v3.operation.RESTSynchronize', NULL, 'A', 'N')
ON DUPLICATE KEY UPDATE
	description = 'Sincronização de dados';

SET @id:= (SELECT (CASE count(idrestoperation) WHEN 0 THEN 1 ELSE max(idrestoperation)+1 END ) FROM rest_operation);
INSERT INTO rest_operation (
			idrestoperation,
			idbatchprocessing, name, 
			description, operationtype, classtype, 
			javaclass, javascript, status, generatelog)
	VALUES (
			@id,
			NULL, 'occurrence_getNotSynchronized', 
			'Recupera ocorrências não sincronizadas',
			'Sync', 'Java',
			'br.com.centralit.citsmart.rest.v3.operation.RESTSynchronize', NULL, 'A', 'N')
ON DUPLICATE KEY UPDATE
	description = 'Recupera ocorrências não sincronizadas';

SET @id:= (SELECT (CASE count(idrestoperation) WHEN 0 THEN 1 ELSE max(idrestoperation)+1 END ) FROM rest_operation);
INSERT INTO rest_operation (
			idrestoperation,
			idbatchprocessing, name, 
			description, operationtype, classtype, 
			javaclass, javascript, status, generatelog)
	VALUES (
			@id,
			NULL, 'occurrence_synchronize', 
			'Sincroniza ocorrências',
			'Sync', 'Java',
			'br.com.centralit.citsmart.rest.v3.operation.RESTSynchronize', NULL, 'A', 'N')
ON DUPLICATE KEY UPDATE
	description = 'Sincroniza ocorrências';


SET @id:= (SELECT (CASE count(idrestoperation) WHEN 0 THEN 1 ELSE max(idrestoperation)+1 END ) FROM rest_operation);
INSERT INTO rest_operation (
			idrestoperation,
			idbatchprocessing, name, 
			description, operationtype, classtype, 
			javaclass, javascript, status, generatelog)
	VALUES (
			@id,
			NULL, 'synchronize_find', 
			'Recupera lista de objetos de sincronização',
			'Sync', 'Java',
			'br.com.centralit.citsmart.rest.v3.operation.RESTSynchronize', NULL, 'A', 'N')
ON DUPLICATE KEY UPDATE
	description = 'Recupera lista de objetos de sincronização';

SET @id:= (SELECT (CASE count(idrestoperation) WHEN 0 THEN 1 ELSE max(idrestoperation)+1 END ) FROM rest_operation);
INSERT INTO rest_operation (
			idrestoperation,
			idbatchprocessing, name, 
			description, operationtype, classtype, 
			javaclass, javascript, status, generatelog)
	VALUES (
			@id,
			NULL, 'synchronize_delete', 
			'Exclui sincronização',
			'Sync', 'Java',
			'br.com.centralit.citsmart.rest.v3.operation.RESTSynchronize', NULL, 'A', 'N')
ON DUPLICATE KEY UPDATE
	description = 'Exclui sincronização';
	

SET @id:= (SELECT (CASE count(idrestoperation) WHEN 0 THEN 1 ELSE max(idrestoperation)+1 END ) FROM rest_operation);
INSERT INTO rest_operation (
			idrestoperation,
			idbatchprocessing, name, 
			description, operationtype, classtype, 
			javaclass, javascript, status, generatelog)
	VALUES (
			@id,
			NULL, 'data_query', 
			'Executa consultas no banco de dados',
			'Sync', 'Java',
			'br.com.centralit.citsmart.rest.v3.operation.RESTDataQuery', NULL, 'A', 'Y')
ON DUPLICATE KEY UPDATE
	description = 'Executa consultas no banco de dados';
	

SET @id:= (SELECT (CASE count(idrestoperation) WHEN 0 THEN 1 ELSE max(idrestoperation)+1 END ) FROM rest_operation);
INSERT INTO rest_operation (
			idrestoperation,
			idbatchprocessing, name, 
			description, operationtype, classtype, 
			javaclass, javascript, status, generatelog)
	VALUES (
			@id,
			NULL, 'notification_buscaNotificacao', 
			'Serviço de busca de solicitações para o citsmart mobile',
			'Sync', 'Java',
			'br.com.centralit.citsmart.rest.v2.operation.RESTMobile', NULL, 'A', 'Y')
ON DUPLICATE KEY UPDATE
	description = 'Serviço de busca de solicitações para o citsmart mobile';
	


SET @idrestparameter := (SELECT rest_parameter.idrestparameter FROM rest_parameter
	WHERE rest_parameter.identifier LIKE 'CONTRACT_ID');
SET @idrestoperation := (SELECT rest_operation.idrestoperation FROM rest_operation
	WHERE rest_operation.name LIKE 'addServiceRequest');
INSERT INTO rest_domain 
	(idrestparameter, idrestoperation, value) 
		VALUES (@idrestparameter, @idrestoperation, '1')
	ON DUPLICATE KEY UPDATE
		value = '1';
		
SET @idrestparameter := (SELECT rest_parameter.idrestparameter FROM rest_parameter
	WHERE rest_parameter.identifier LIKE 'CONTRACT_ID');
SET @idrestoperation := (SELECT rest_operation.idrestoperation FROM rest_operation
	WHERE rest_operation.name LIKE 'notification_new');
INSERT INTO rest_domain 
	(idrestparameter, idrestoperation, value) 
		VALUES (@idrestparameter, @idrestoperation, '1')
	ON DUPLICATE KEY UPDATE
		value = '1';
		
SET @idrestparameter := (SELECT rest_parameter.idrestparameter FROM rest_parameter
	WHERE rest_parameter.identifier LIKE 'CONTRACT_ID');
SET @idrestoperation := (SELECT rest_operation.idrestoperation FROM rest_operation
	WHERE rest_operation.name LIKE 'request_create');
INSERT INTO rest_domain 
	(idrestparameter, idrestoperation, value) 
		VALUES (@idrestparameter, @idrestoperation, '1')
	ON DUPLICATE KEY UPDATE
		value = '1';
		
SET @idrestparameter := (SELECT rest_parameter.idrestparameter FROM rest_parameter
	WHERE rest_parameter.identifier LIKE 'ORIGIN_ID');
SET @idrestoperation := (SELECT rest_operation.idrestoperation FROM rest_operation
	WHERE rest_operation.name LIKE 'addServiceRequest');
INSERT INTO rest_domain 
	(idrestparameter, idrestoperation, value) 
		VALUES (@idrestparameter, @idrestoperation, '7')
	ON DUPLICATE KEY UPDATE
		value = '7';
		
SET @idrestparameter := (SELECT rest_parameter.idrestparameter FROM rest_parameter
	WHERE rest_parameter.identifier LIKE 'ORIGIN_ID');
SET @idrestoperation := (SELECT rest_operation.idrestoperation FROM rest_operation
	WHERE rest_operation.name LIKE 'notification_new');
INSERT INTO rest_domain 
	(idrestparameter, idrestoperation, value) 
		VALUES (@idrestparameter, @idrestoperation, '10')
	ON DUPLICATE KEY UPDATE
		value = '10';
		
SET @idrestparameter := (SELECT rest_parameter.idrestparameter FROM rest_parameter
	WHERE rest_parameter.identifier LIKE 'REQUEST_ID');
SET @idrestoperation := (SELECT rest_operation.idrestoperation FROM rest_operation
	WHERE rest_operation.name LIKE 'addServiceRequest');
INSERT INTO rest_domain 
	(idrestparameter, idrestoperation, value) 
		VALUES (@idrestparameter, @idrestoperation, '1')
	ON DUPLICATE KEY UPDATE
		value = '1';
		
SET @idrestparameter := (SELECT rest_parameter.idrestparameter FROM rest_parameter
	WHERE rest_parameter.identifier LIKE 'REQUEST_ID');
SET @idrestoperation := (SELECT rest_operation.idrestoperation FROM rest_operation
	WHERE rest_operation.name LIKE 'notification_new');
INSERT INTO rest_domain 
	(idrestparameter, idrestoperation, value) 
		VALUES (@idrestparameter, @idrestoperation, '1')
	ON DUPLICATE KEY UPDATE
		value = '1';
		
SET @idrestparameter := (SELECT rest_parameter.idrestparameter FROM rest_parameter
	WHERE rest_parameter.identifier LIKE 'REQUEST_ID');
SET @idrestoperation := (SELECT rest_operation.idrestoperation FROM rest_operation
	WHERE rest_operation.name LIKE 'request_create');
INSERT INTO rest_domain 
	(idrestparameter, idrestoperation, value) 
		VALUES (@idrestparameter, @idrestoperation, '1')
	ON DUPLICATE KEY UPDATE
		value = '1';
		
SET @idrestparameter := (SELECT rest_parameter.idrestparameter FROM rest_parameter
	WHERE rest_parameter.identifier LIKE 'INCIDENT_ID');
SET @idrestoperation := (SELECT rest_operation.idrestoperation FROM rest_operation
	WHERE rest_operation.name LIKE 'addServiceRequest');
INSERT INTO rest_domain 
	(idrestparameter, idrestoperation, value) 
		VALUES (@idrestparameter, @idrestoperation, '3')
	ON DUPLICATE KEY UPDATE
		value = '3';
		
SET @idrestparameter := (SELECT rest_parameter.idrestparameter FROM rest_parameter
	WHERE rest_parameter.identifier LIKE 'INCIDENT_ID');
SET @idrestoperation := (SELECT rest_operation.idrestoperation FROM rest_operation
	WHERE rest_operation.name LIKE 'notification_new');
INSERT INTO rest_domain 
	(idrestparameter, idrestoperation, value) 
		VALUES (@idrestparameter, @idrestoperation, '')
	ON DUPLICATE KEY UPDATE
		value = '3';
		
SET @idrestparameter := (SELECT rest_parameter.idrestparameter FROM rest_parameter
	WHERE rest_parameter.identifier LIKE 'INCIDENT_ID');
SET @idrestoperation := (SELECT rest_operation.idrestoperation FROM rest_operation
	WHERE rest_operation.name LIKE 'request_create');
INSERT INTO rest_domain 
	(idrestparameter, idrestoperation, value) 
		VALUES (@idrestparameter, @idrestoperation, '3')
	ON DUPLICATE KEY UPDATE
		value = '3';
		
SET @idrestparameter := (SELECT rest_parameter.idrestparameter FROM rest_parameter
	WHERE rest_parameter.identifier LIKE 'DEFAULT_DEPTO_ID');
SET @idrestoperation := (SELECT rest_operation.idrestoperation FROM rest_operation
	WHERE rest_operation.name LIKE 'addServiceRequest');
INSERT INTO rest_domain 
	(idrestparameter, idrestoperation, value) 
		VALUES (@idrestparameter, @idrestoperation, '3')
	ON DUPLICATE KEY UPDATE
		value = '3';
		
SET @idrestparameter := (SELECT rest_parameter.idrestparameter FROM rest_parameter
	WHERE rest_parameter.identifier LIKE 'DEFAULT_DEPTO_ID');
SET @idrestoperation := (SELECT rest_operation.idrestoperation FROM rest_operation
	WHERE rest_operation.name LIKE 'notification_new');
INSERT INTO rest_domain 
	(idrestparameter, idrestoperation, value) 
		VALUES (@idrestparameter, @idrestoperation, '3')
	ON DUPLICATE KEY UPDATE
		value = '3';
		
SET @idrestparameter := (SELECT rest_parameter.idrestparameter FROM rest_parameter
	WHERE rest_parameter.identifier LIKE 'DEFAULT_SLA');
SET @idrestoperation := (SELECT rest_operation.idrestoperation FROM rest_operation
	WHERE rest_operation.name LIKE 'request_create');
INSERT INTO rest_domain 
	(idrestparameter, idrestoperation, value) 
		VALUES (@idrestparameter, @idrestoperation, '1421')
	ON DUPLICATE KEY UPDATE
		value = '1421';
		
SET @idrestparameter := (SELECT rest_parameter.idrestparameter FROM rest_parameter
	WHERE rest_parameter.identifier LIKE 'DEFAULT_SLA');
SET @idrestoperation := (SELECT rest_operation.idrestoperation FROM rest_operation
	WHERE rest_operation.name LIKE 'request_update');
INSERT INTO rest_domain 
	(idrestparameter, idrestoperation, value) 
		VALUES (@idrestparameter, @idrestoperation, '1421')
	ON DUPLICATE KEY UPDATE
		value = '1421';
		
SET @idrestparameter := (SELECT rest_parameter.idrestparameter FROM rest_parameter
	WHERE rest_parameter.identifier LIKE 'DEFAULT_REASON_ID');
SET @idrestoperation := (SELECT rest_operation.idrestoperation FROM rest_operation
	WHERE rest_operation.name LIKE 'request_updateStatus');
INSERT INTO rest_domain 
	(idrestparameter, idrestoperation, value) 
		VALUES (@idrestparameter, @idrestoperation, '7')
	ON DUPLICATE KEY UPDATE
		value = '7';
		
SET @idrestparameter := (SELECT rest_parameter.idrestparameter FROM rest_parameter
	WHERE rest_parameter.identifier LIKE 'DEFAULT_SERVICE_ID');
SET @idrestoperation := (SELECT rest_operation.idrestoperation FROM rest_operation
	WHERE rest_operation.name LIKE 'request_create');
INSERT INTO rest_domain 
	(idrestparameter, idrestoperation, value) 
		VALUES (@idrestparameter, @idrestoperation, '5136')
	ON DUPLICATE KEY UPDATE
		value = '5136';
		
SET @idrestparameter := (SELECT rest_parameter.idrestparameter FROM rest_parameter
	WHERE rest_parameter.identifier LIKE 'CHANGE_USER');
SET @idrestoperation := (SELECT rest_operation.idrestoperation FROM rest_operation
	WHERE rest_operation.name LIKE 'request_update');
INSERT INTO rest_domain 
	(idrestparameter, idrestoperation, value) 
		VALUES (@idrestparameter, @idrestoperation, 'N')
	ON DUPLICATE KEY UPDATE
		value = 'N';
		
SET @idrestparameter := (SELECT rest_parameter.idrestparameter FROM rest_parameter
	WHERE rest_parameter.identifier LIKE 'CHANGE_GROUP');
SET @idrestoperation := (SELECT rest_operation.idrestoperation FROM rest_operation
	WHERE rest_operation.name LIKE 'request_update');
INSERT INTO rest_domain 
	(idrestparameter, idrestoperation, value) 
		VALUES (@idrestparameter, @idrestoperation, 'N')
	ON DUPLICATE KEY UPDATE
		value = 'N';
		
SET @idrestparameter := (SELECT rest_parameter.idrestparameter FROM rest_parameter
	WHERE rest_parameter.identifier LIKE 'CHANGE_SERVICE');
SET @idrestoperation := (SELECT rest_operation.idrestoperation FROM rest_operation
	WHERE rest_operation.name LIKE 'request_update');
INSERT INTO rest_domain 
	(idrestparameter, idrestoperation, value) 
		VALUES (@idrestparameter, @idrestoperation, 'N')
	ON DUPLICATE KEY UPDATE
		value = 'N';
		
SET @idrestparameter := (SELECT rest_parameter.idrestparameter FROM rest_parameter
	WHERE rest_parameter.identifier LIKE 'DEFAULT_GROUP_ID');
SET @idrestoperation := (SELECT rest_operation.idrestoperation FROM rest_operation
	WHERE rest_operation.name LIKE 'request_create');
INSERT INTO rest_domain 
	(idrestparameter, idrestoperation, value) 
		VALUES (@idrestparameter, @idrestoperation, '159')
	ON DUPLICATE KEY UPDATE
		value = '159';
		
SET @idrestparameter := (SELECT rest_parameter.idrestparameter FROM rest_parameter
	WHERE rest_parameter.identifier LIKE 'DEFAULT_DESCRIPTION');
SET @idrestoperation := (SELECT rest_operation.idrestoperation FROM rest_operation
	WHERE rest_operation.name LIKE 'request_create');
INSERT INTO rest_domain 
	(idrestparameter, idrestoperation, value) 
		VALUES (@idrestparameter, @idrestoperation, 'Requisição criada por ESI centralizador')
	ON DUPLICATE KEY UPDATE
		value = 'Requisição criada por ESI centralizador';
		
SET @idrestparameter := (SELECT rest_parameter.idrestparameter FROM rest_parameter
	WHERE rest_parameter.identifier LIKE 'USER');
SET @idrestoperation := (SELECT rest_operation.idrestoperation FROM rest_operation
	WHERE rest_operation.name LIKE 'data_query');
INSERT INTO rest_domain 
	(idrestparameter, idrestoperation, value) 
		VALUES (@idrestparameter, @idrestoperation, 'select idusuario, login, nome, idempregado, status from usuario where login = ${login}')
	ON DUPLICATE KEY UPDATE
		value = 'select idusuario, login, nome, idempregado, status from usuario where login = ${login}';
		
SET @idrestparameter := (SELECT rest_parameter.idrestparameter FROM rest_parameter
	WHERE rest_parameter.identifier LIKE 'REQUEST_BY_ID');
SET @idrestoperation := (SELECT rest_operation.idrestoperation FROM rest_operation
	WHERE rest_operation.name LIKE 'data_query');
INSERT INTO rest_domain 
	(idrestparameter, idrestoperation, value) 
		VALUES (@idrestparameter, @idrestoperation, 'SELECT sol.idSolicitacaoServico, sol.idbaseconhecimento,sol.idServicoContrato, sol.idSolicitante, sol.idItemConfiguracao, sol.idItemConfiguracaoFilho, sol.idtipodemandaservico, sol.idcontatosolicitacaoservico, sol.idOrigem, sol.idResponsavel, sol.idTipoProblema, sol.idPrioridade, sol.idUnidade, sol.idFaseAtual, sol.idGrupoAtual, sol.dataHoraSolicitacao, sol.dataHoraLimite, sol.atendimentoPresencial, sol.prazoCapturaHH, sol.prazoCapturaMM, sol.prazoHH, sol.prazoMM, sol.descricao, sol.resposta, sol.dataHoraInicio, sol.dataHoraFim, sol.situacao, sol.idSolicitacaoPai, sol.detalhamentoCausa, sol.idCausaIncidente, sol.idCategoriaSolucao, sol.seqreabertura, sol.enviaEmailCriacao, sol.enviaEmailFinalizacao, sol.enviaEmailAcoes, sol.idgruponivel1, sol.solucaoTemporaria, sol.houveMudanca, sol.slaACombinar, sol.prazohhAnterior, sol.prazommAnterior, sol.idCalendario, sol.tempoDecorridoHH, sol.tempoDecorridoMM, sol.dataHoraSuspensao, sol.dataHoraReativacao, sol.impacto, sol.urgencia, sol.dataHoraCaptura, sol.tempoCapturaHH, sol.tempoCapturaMM, sol.tempoAtrasoHH, sol.tempoAtrasoMM, sol.tempoAtendimentoHH, sol.tempoAtendimentoMM, sol.idacordonivelservico, sol.idultimaaprovacao, sol.datahorainiciosla, sol.datahorasuspensaosla, sol.datahorareativacaosla, sol.situacaosla, sol.idtarefaencerramento, sol.justificativavencimentosla, aprov.aprovacao, s.idservico, s.nomeServico, td.idTipoDemandaServico, td.nomeTipoDemandaServico, c.idContrato, c.numero as numeroContrato, e1.nome as solicitante, u1.nome as unidade, e2.nome as responsavel, g1.sigla as grupoAtual, g2.sigla as grupoNivel1, cs.nomecontato, cs.emailcontato, cs.telefonecontato, cs.localizacaofisica, cs.idlocalidade, sol.idSolicitacaoRelacionada, e3.email as emailResponsavel, sol.codigoExterno FROM solicitacaoservico sol INNER JOIN tipodemandaservico td ON td.idtipodemandaservico = sol.idtipodemandaservico LEFT JOIN servicocontrato sc ON sc.idservicocontrato = sol.idservicocontrato LEFT JOIN contratos c ON c.idcontrato = sc.idcontrato LEFT JOIN servico s ON s.idservico = sc.idservico LEFT JOIN empregados e1 ON e1.idempregado = sol.idsolicitante LEFT JOIN unidade u1 ON u1.idunidade = e1.idunidade LEFT JOIN usuario usu ON usu.idusuario = sol.idresponsavel LEFT JOIN empregados e2 ON e2.idempregado = usu.idempregado LEFT JOIN unidade u2 ON u2.idunidade = e2.idunidade LEFT JOIN origematendimento oa ON oa.idorigem = sol.idorigem LEFT JOIN prioridade p ON p.idprioridade = sol.idprioridade LEFT JOIN faseservico fs ON fs.idfase = sol.idfaseatual LEFT JOIN grupo g1 ON g1.idgrupo = sol.idgrupoatual LEFT JOIN grupo g2 ON g2.idgrupo = sol.idgruponivel1 LEFT JOIN empregados e3 ON e3.idempregado = sol.idresponsavel LEFT JOIN contatosolicitacaoservico cs ON cs.idcontatosolicitacaoservico = sol.idcontatosolicitacaoservico LEFT JOIN aprovacaosolicitacaoservico aprov ON aprov.idaprovacaosolicitacaoservico = sol.idultimaaprovacao WHERE sol.idsolicitacaoservico = ${id}')
	ON DUPLICATE KEY UPDATE
		value = 'SELECT sol.idSolicitacaoServico, sol.idbaseconhecimento,sol.idServicoContrato, sol.idSolicitante, sol.idItemConfiguracao, sol.idItemConfiguracaoFilho, sol.idtipodemandaservico, sol.idcontatosolicitacaoservico, sol.idOrigem, sol.idResponsavel, sol.idTipoProblema, sol.idPrioridade, sol.idUnidade, sol.idFaseAtual, sol.idGrupoAtual, sol.dataHoraSolicitacao, sol.dataHoraLimite, sol.atendimentoPresencial, sol.prazoCapturaHH, sol.prazoCapturaMM, sol.prazoHH, sol.prazoMM, sol.descricao, sol.resposta, sol.dataHoraInicio, sol.dataHoraFim, sol.situacao, sol.idSolicitacaoPai, sol.detalhamentoCausa, sol.idCausaIncidente, sol.idCategoriaSolucao, sol.seqreabertura, sol.enviaEmailCriacao, sol.enviaEmailFinalizacao, sol.enviaEmailAcoes, sol.idgruponivel1, sol.solucaoTemporaria, sol.houveMudanca, sol.slaACombinar, sol.prazohhAnterior, sol.prazommAnterior, sol.idCalendario, sol.tempoDecorridoHH, sol.tempoDecorridoMM, sol.dataHoraSuspensao, sol.dataHoraReativacao, sol.impacto, sol.urgencia, sol.dataHoraCaptura, sol.tempoCapturaHH, sol.tempoCapturaMM, sol.tempoAtrasoHH, sol.tempoAtrasoMM, sol.tempoAtendimentoHH, sol.tempoAtendimentoMM, sol.idacordonivelservico, sol.idultimaaprovacao, sol.datahorainiciosla, sol.datahorasuspensaosla, sol.datahorareativacaosla, sol.situacaosla, sol.idtarefaencerramento, sol.justificativavencimentosla, aprov.aprovacao, s.idservico, s.nomeServico, td.idTipoDemandaServico, td.nomeTipoDemandaServico, c.idContrato, c.numero as numeroContrato, e1.nome as solicitante, u1.nome as unidade, e2.nome as responsavel, g1.sigla as grupoAtual, g2.sigla as grupoNivel1, cs.nomecontato, cs.emailcontato, cs.telefonecontato, cs.localizacaofisica, cs.idlocalidade, sol.idSolicitacaoRelacionada, e3.email as emailResponsavel, sol.codigoExterno FROM solicitacaoservico sol INNER JOIN tipodemandaservico td ON td.idtipodemandaservico = sol.idtipodemandaservico LEFT JOIN servicocontrato sc ON sc.idservicocontrato = sol.idservicocontrato LEFT JOIN contratos c ON c.idcontrato = sc.idcontrato LEFT JOIN servico s ON s.idservico = sc.idservico LEFT JOIN empregados e1 ON e1.idempregado = sol.idsolicitante LEFT JOIN unidade u1 ON u1.idunidade = e1.idunidade LEFT JOIN usuario usu ON usu.idusuario = sol.idresponsavel LEFT JOIN empregados e2 ON e2.idempregado = usu.idempregado LEFT JOIN unidade u2 ON u2.idunidade = e2.idunidade LEFT JOIN origematendimento oa ON oa.idorigem = sol.idorigem LEFT JOIN prioridade p ON p.idprioridade = sol.idprioridade LEFT JOIN faseservico fs ON fs.idfase = sol.idfaseatual LEFT JOIN grupo g1 ON g1.idgrupo = sol.idgrupoatual LEFT JOIN grupo g2 ON g2.idgrupo = sol.idgruponivel1 LEFT JOIN empregados e3 ON e3.idempregado = sol.idresponsavel LEFT JOIN contatosolicitacaoservico cs ON cs.idcontatosolicitacaoservico = sol.idcontatosolicitacaoservico LEFT JOIN aprovacaosolicitacaoservico aprov ON aprov.idaprovacaosolicitacaoservico = sol.idultimaaprovacao WHERE sol.idsolicitacaoservico = ${id}';
		
SET @idrestparameter := (SELECT rest_parameter.idrestparameter FROM rest_parameter
	WHERE rest_parameter.identifier LIKE 'REQUEST_BY_DESCRIPTION');
SET @idrestoperation := (SELECT rest_operation.idrestoperation FROM rest_operation
	WHERE rest_operation.name LIKE 'data_query');
INSERT INTO rest_domain 
	(idrestparameter, idrestoperation, value) 
		VALUES (@idrestparameter, @idrestoperation, 'SELECT sol.idSolicitacaoServico, sol.idbaseconhecimento, sol.idServicoContrato, sol.idSolicitante, sol.idItemConfiguracao, sol.idItemConfiguracaoFilho, sol.idtipodemandaservico, sol.idcontatosolicitacaoservico, sol.idOrigem, sol.idResponsavel, sol.idTipoProblema, sol.idPrioridade, sol.idUnidade, sol.idFaseAtual, sol.idGrupoAtual, sol.dataHoraSolicitacao, sol.dataHoraLimite, sol.atendimentoPresencial, sol.prazoCapturaHH, sol.prazoCapturaMM, sol.prazoHH, sol.prazoMM, sol.descricao, sol.resposta, sol.dataHoraInicio, sol.dataHoraFim, sol.situacao, sol.idSolicitacaoPai, sol.detalhamentoCausa, sol.idCausaIncidente, sol.idCategoriaSolucao, sol.seqreabertura, sol.enviaEmailCriacao, sol.enviaEmailFinalizacao, sol.enviaEmailAcoes, sol.idgruponivel1, sol.solucaoTemporaria, sol.houveMudanca, sol.slaACombinar,sol.prazohhAnterior, sol.prazommAnterior, sol.idCalendario, sol.tempoDecorridoHH, sol.tempoDecorridoMM, sol.dataHoraSuspensao, sol.dataHoraReativacao, sol.impacto, sol.urgencia, sol.dataHoraCaptura, sol.tempoCapturaHH, sol.tempoCapturaMM, sol.tempoAtrasoHH, sol.tempoAtrasoMM, sol.tempoAtendimentoHH, sol.tempoAtendimentoMM, sol.idacordonivelservico, sol.idultimaaprovacao, sol.datahorainiciosla, sol.datahorasuspensaosla, sol.datahorareativacaosla, sol.situacaosla, sol.idtarefaencerramento, sol.justificativavencimentosla, aprov.aprovacao, s.idservico, s.nomeServico, td.idTipoDemandaServico, td.nomeTipoDemandaServico, c.idContrato, c.numero numeroContrato, e1.nome solicitante, u1.nome unidade, e2.nome responsavel, g1.sigla grupoAtual, g2.sigla grupoNivel1, cs.nomecontato, cs.emailcontato, cs.telefonecontato, cs.localizacaofisica, cs.idlocalidade, sol.idSolicitacaoRelacionada, e3.email as emailResponsavel, sol.codigoExterno FROM solicitacaoservico sol INNER JOIN tipodemandaservico td ON td.idtipodemandaservico = sol.idtipodemandaservico LEFT JOIN servicocontrato sc ON sc.idservicocontrato = sol.idservicocontrato LEFT JOIN contratos c ON c.idcontrato = sc.idcontrato LEFT JOIN servico s ON s.idservico = sc.idservico LEFT JOIN empregados e1 ON e1.idempregado = sol.idsolicitante LEFT JOIN unidade u1 ON u1.idunidade = e1.idunidade LEFT JOIN usuario usu ON usu.idusuario = sol.idresponsavel LEFT JOIN empregados e2 ON e2.idempregado = usu.idempregado LEFT JOIN unidade u2 ON u2.idunidade = e2.idunidade LEFT JOIN origematendimento oa ON oa.idorigem = sol.idorigem LEFT JOIN prioridade p ON p.idprioridade = sol.idprioridade LEFT JOIN faseservico fs ON fs.idfase = sol.idfaseatual LEFT JOIN grupo g1 ON g1.idgrupo = sol.idgrupoatual LEFT JOIN grupo g2 ON g2.idgrupo = sol.idgruponivel1 LEFT JOIN empregados e3 ON e3.idempregado = sol.idresponsavel LEFT JOIN contatosolicitacaoservico cs ON cs.idcontatosolicitacaoservico = sol.idcontatosolicitacaoservico LEFT JOIN aprovacaosolicitacaoservico aprov ON aprov.idaprovacaosolicitacaoservico = sol.idultimaaprovacao WHERE sol.descricao like ${description}')
	ON DUPLICATE KEY UPDATE
		value = 'SELECT sol.idSolicitacaoServico, sol.idbaseconhecimento, sol.idServicoContrato, sol.idSolicitante, sol.idItemConfiguracao, sol.idItemConfiguracaoFilho, sol.idtipodemandaservico, sol.idcontatosolicitacaoservico, sol.idOrigem, sol.idResponsavel, sol.idTipoProblema, sol.idPrioridade, sol.idUnidade, sol.idFaseAtual, sol.idGrupoAtual, sol.dataHoraSolicitacao, sol.dataHoraLimite, sol.atendimentoPresencial, sol.prazoCapturaHH, sol.prazoCapturaMM, sol.prazoHH, sol.prazoMM, sol.descricao, sol.resposta, sol.dataHoraInicio, sol.dataHoraFim, sol.situacao, sol.idSolicitacaoPai, sol.detalhamentoCausa, sol.idCausaIncidente, sol.idCategoriaSolucao, sol.seqreabertura, sol.enviaEmailCriacao, sol.enviaEmailFinalizacao, sol.enviaEmailAcoes, sol.idgruponivel1, sol.solucaoTemporaria, sol.houveMudanca, sol.slaACombinar,sol.prazohhAnterior, sol.prazommAnterior, sol.idCalendario, sol.tempoDecorridoHH, sol.tempoDecorridoMM, sol.dataHoraSuspensao, sol.dataHoraReativacao, sol.impacto, sol.urgencia, sol.dataHoraCaptura, sol.tempoCapturaHH, sol.tempoCapturaMM, sol.tempoAtrasoHH, sol.tempoAtrasoMM, sol.tempoAtendimentoHH, sol.tempoAtendimentoMM, sol.idacordonivelservico, sol.idultimaaprovacao, sol.datahorainiciosla, sol.datahorasuspensaosla, sol.datahorareativacaosla, sol.situacaosla, sol.idtarefaencerramento, sol.justificativavencimentosla, aprov.aprovacao, s.idservico, s.nomeServico, td.idTipoDemandaServico, td.nomeTipoDemandaServico, c.idContrato, c.numero numeroContrato, e1.nome solicitante, u1.nome unidade, e2.nome responsavel, g1.sigla grupoAtual, g2.sigla grupoNivel1, cs.nomecontato, cs.emailcontato, cs.telefonecontato, cs.localizacaofisica, cs.idlocalidade, sol.idSolicitacaoRelacionada, e3.email as emailResponsavel, sol.codigoExterno FROM solicitacaoservico sol INNER JOIN tipodemandaservico td ON td.idtipodemandaservico = sol.idtipodemandaservico LEFT JOIN servicocontrato sc ON sc.idservicocontrato = sol.idservicocontrato LEFT JOIN contratos c ON c.idcontrato = sc.idcontrato LEFT JOIN servico s ON s.idservico = sc.idservico LEFT JOIN empregados e1 ON e1.idempregado = sol.idsolicitante LEFT JOIN unidade u1 ON u1.idunidade = e1.idunidade LEFT JOIN usuario usu ON usu.idusuario = sol.idresponsavel LEFT JOIN empregados e2 ON e2.idempregado = usu.idempregado LEFT JOIN unidade u2 ON u2.idunidade = e2.idunidade LEFT JOIN origematendimento oa ON oa.idorigem = sol.idorigem LEFT JOIN prioridade p ON p.idprioridade = sol.idprioridade LEFT JOIN faseservico fs ON fs.idfase = sol.idfaseatual LEFT JOIN grupo g1 ON g1.idgrupo = sol.idgrupoatual LEFT JOIN grupo g2 ON g2.idgrupo = sol.idgruponivel1 LEFT JOIN empregados e3 ON e3.idempregado = sol.idresponsavel LEFT JOIN contatosolicitacaoservico cs ON cs.idcontatosolicitacaoservico = sol.idcontatosolicitacaoservico LEFT JOIN aprovacaosolicitacaoservico aprov ON aprov.idaprovacaosolicitacaoservico = sol.idultimaaprovacao WHERE sol.descricao like ${description}';
