Skip to content
Permalink
Browse files

Vinculando N-N entre Pronto e ZenDesk

  • Loading branch information...
andrefaria committed Jun 16, 2012
1 parent 88d48f0 commit 69500f46831cd50b1677758c3d233fdc76f050cd
@@ -217,5 +217,4 @@ update projeto p set etapa_de_inicio_do_ciclo_key = (
update projeto p set etapa_de_termino_do_ciclo_key = (
select kanban_status_key from kanban_status where projeto_key = p.projeto_key
and ordem = (select max(ordem) from kanban_status where projeto_key = p.projeto_key)
);

);
@@ -285,14 +285,16 @@ class TicketController {

if (ticket.ticketKey > 0 && configuracaoDao.isZendeskAtivo()) {
if (ticket.getTicketKey() != null && ticket.isDone()) {
def zendeskTicketKey = ticketDao.obterNumeroDoTicketNoZendesk(Integer.valueOf(ticket.getTicketKey()))
if (zendeskTicketKey) {
zendeskService.notificarConclusao zendeskTicketKey, ticket.release
Set<Integer> zendeskTicketKey = ticketDao.obterTicketsIntegradosNoZendesk(Integer.valueOf(ticket.getTicketKey()))
if (zendeskTicketKey && zendeskTicketKey.size() > 0) {
zendeskTicketKey.each {
zendeskService.notificarConclusao it, ticket.release
}
}
}
}

model.addAttribute "zendeskTicketKey", ticketDao.obterNumeroDoTicketNoZendesk(ticket.ticketKey)
model.addAttribute "zendeskTicketKey", ticketDao.obterTicketsIntegradosNoZendesk(ticket.ticketKey)
return "redirect:/tickets/${ticket.ticketKey}"
} catch ( Exception e) {
e.printStackTrace()
@@ -703,11 +705,11 @@ class TicketController {
}

if (ticket.ticketKey > 0 && configuracaoDao.isZendeskAtivo()) {
def zendeskTicketKey = ticketDao.obterNumeroDoTicketNoZendesk(Integer.valueOf(ticket.getTicketKey()))
if (zendeskTicketKey) {
def zendeskTicketKey = ticketDao.obterTicketsIntegradosNoZendesk(Integer.valueOf(ticket.getTicketKey()))
if (zendeskTicketKey && zendeskTicketKey.size() > 0) {
model.addAttribute "zendeskTicketKey", zendeskTicketKey
model.addAttribute "zendeskUrl", configuracaoDao.getZendeskUrl()
model.addAttribute "zendeskTicket", zendeskService.obterTicket(zendeskTicketKey)
model.addAttribute "zendeskTicket", zendeskService.obterTickets(zendeskTicketKey)
}
}

@@ -730,7 +732,7 @@ class TicketController {
}

model.addAttribute "ordens", ordens
model.addAttribute "zendeskTicketKey", ticketDao.obterNumeroDoTicketNoZendesk(ticket.ticketKey)
model.addAttribute "zendeskTicketKey", ticketDao.obterTicketsIntegradosNoZendesk(ticket.ticketKey)
} else {
Ticket novoTicket = new Ticket()
novoTicket.setReporter(Seguranca.getUsuario())
@@ -843,12 +845,7 @@ class TicketController {
@ResponseBody String vincularTicketAoZendesk(Model model, @PathVariable int ticketKey, int zendeskTicketKey) {
JSONObject json = new JSONObject()
try {
Integer ticket = ticketDao.obterTicketKeyIntegradoComZendesk(zendeskTicketKey)
if(ticket == null){
ticketDao.inserirTicketKeyIntegradoComZendesk ticketKey, zendeskTicketKey
}else{
throw new ProntoException(MessageFormat.format("Não foi possível vincular este ticket ao Zendesk porque o ticket {0} já esta vinculado.", ticket));
}
ticketDao.inserirTicketKeyIntegradoComZendesk ticketKey, zendeskTicketKey
json.put "isSuccess", "true"
return json
} catch (e) {
@@ -859,10 +856,10 @@ class TicketController {
}
}

@RequestMapping("/{ticketKey}/excluirVinculoComZendesk")
@ResponseBody String excluirVinculoComZendesk(Model model, @PathVariable int ticketKey) {
@RequestMapping("/{ticketKey}/excluirVinculoComZendesk/{zendeskTicketKey}")
@ResponseBody String excluirVinculoComZendesk(Model model, @PathVariable int ticketKey, @PathVariable int zendeskTicketKey) {
try {
ticketDao.excluirVinculoComZendesk ticketKey
ticketDao.excluirVinculoComZendesk ticketKey, zendeskTicketKey
return "true"
} catch (e) {
return "false"
@@ -818,10 +818,10 @@ public class TicketDao extends DaoHibernate {
return mapa
}

Integer obterTicketKeyIntegradoComZendesk(int zendeskTicketKey){
Set<Integer> obterTicketsIntegradoComZendesk(int zendeskTicketKey){
def query = session.createSQLQuery('select izd.ticket_key from integracao_zendesk izd where izd.zendesk_ticket_key = :zendeskTicketKey')
query.setInteger('zendeskTicketKey',zendeskTicketKey)
return query.uniqueResult() as Integer
return query.list() as Set
}

void inserirTicketKeyIntegradoComZendesk(int ticketKey, int zendeskTicketKey){
@@ -831,9 +831,10 @@ public class TicketDao extends DaoHibernate {
query.executeUpdate()
}

void excluirVinculoComZendesk(int ticketKey){
def query = session.createSQLQuery('DELETE FROM integracao_zendesk WHERE ticket_key = :ticketKey')
void excluirVinculoComZendesk(int ticketKey, int zendeskTicketKey){
def query = session.createSQLQuery('DELETE FROM integracao_zendesk WHERE ticket_key = :ticketKey and zendesk_ticket_key = :zendeskTicketKey')
query.setInteger('ticketKey', ticketKey)
query.setInteger('zendeskTicketKey', zendeskTicketKey)
query.executeUpdate()
}

@@ -845,11 +846,11 @@ public class TicketDao extends DaoHibernate {
query.executeUpdate()
}

public Integer obterNumeroDoTicketNoZendesk(Integer ticketKey) {
public Set<Integer> obterTicketsIntegradosNoZendesk(Integer ticketKey) {
def sql = 'select zendesk_ticket_key from integracao_zendesk izd where izd.ticket_key = :ticketKey'
def query = session.createSQLQuery(sql)
query.setInteger 'ticketKey', ticketKey
return query.uniqueResult() as Integer
return query.list() as Set
}

public Integer obterQuantidadeDeImpedimentosPorUsuario(String username) {
@@ -44,6 +44,16 @@ class ZendeskService {
}


def obterTickets(Set<Integer> zendeskTicketKey){
if (zendeskTicketKey) {
return zendeskTicketKey.collect {
obterTicket(it)
}
} else {
return []
}
}

def obterTicket(int zendeskTicketKey){
def cache = CacheManager.getInstance().getCache("zendeskTickets")
def ticket = cache.get(zendeskTicketKey)
@@ -134,9 +144,9 @@ class ZendeskService {

def notificarConclusao(int zendeskTicketKey, String release) {
if (release)
this.incluirComentarioPublico zendeskTicketKey, 'Este chamado foi concluído pelo time de desenvolvimento e estará disponível na versão ' + release + '.'
this.incluirComentarioPublico zendeskTicketKey, 'Este chamado (ou parte dele) foi concluído pelo time de desenvolvimento e estará disponível na versão ' + release + '.'
else
this.incluirComentarioPublico zendeskTicketKey, 'Este chamado foi concluído pelo time de desenvolvimento e estará disponível na próxima atualização.'
this.incluirComentarioPublico zendeskTicketKey, 'Este chamado (ou parte dele) foi concluído pelo time de desenvolvimento e estará disponível na próxima atualização.'
}

private def incluirComentario(int zendeskTicketKey, String comentario, boolean publico) {
@@ -203,9 +203,9 @@ function confirmarVinculo(ticketKey){
}
}

function excluirVinculoComZendesk(ticketKey){
function excluirVinculoComZendesk(ticketKey, zendeskTicketKey){
$.ajax( {
url : pronto.raiz + 'tickets/' + ticketKey + '/excluirVinculoComZendesk',
url : pronto.raiz + 'tickets/' + ticketKey + '/excluirVinculoComZendesk/' + zendeskTicketKey,
cache : false,
success : function(data) {
if (data == "true") {
@@ -47,7 +47,9 @@
<li><a href="#comentarios">Comentários (${fn:length(ticket.comentarios)})</a></li>
<li><a href="#anexos">Anexos (${fn:length(anexos)})</a></li>
<c:if test="${zendeskTicket ne null}">
<li><a href="#zendesk">Zendesk (${fn:length(zendeskTicket.comments)})</a></li>
<c:forEach items="${zendeskTicket}" var="zdTicket">
<li><a href="#zendesk${zdTicket.nice_id}">Zendesk #${zdTicket.nice_id} (${fn:length(zdTicket.comments)})</a></li>
</c:forEach>
</c:if>
<li><a href="#historico">Histórico (${fn:length(ticket.logs)})</a></li>
<li><a href="#movimentos">Kanban (${fn:length(movimentos)})</a></li>
@@ -177,14 +179,16 @@
<form:hidden path="ticket.responsavel.username"/><br/>

<c:if test="${zendeskTicketKey ne null}">
<div id="divZendesk" style="clear: both;">
<div align="center" class="person">
<pronto:icons name="zendesk.png" title="Abrir Ticket no Zendesk" onclick="openWindow('${zendeskUrl}/tickets/${zendeskTicketKey}')"/>
<div class="person_name">#${zendeskTicketKey}</div>
<div>Zendesk</div>
<c:forEach items="${zendeskTicket}" var="zdTicket">
<div id="divZendesk" style="float: right;">
<div align="center" class="person">
<pronto:icons name="zendesk.png" title="Abrir Ticket no Zendesk" onclick="openWindow('${zendeskUrl}/tickets/${zdTicket.nice_id}')"/>
<div class="person_name">#${zdTicket.nice_id}</div>
<div>Zendesk</div>
</div>
<br/>
</div>
<br/>
</div>
</c:forEach>
</c:if>

<div class="group">
@@ -416,17 +420,22 @@
<c:when test="${empty zendeskTicketKey}">
<span>
<b>Nenhum Ticket Vinculado</b>
<pronto:icons name="adicionar.png" title="Vincular esta tarefa com uma tarefa do Zendesk" onclick="adicionarVinculoComZendesk()"/>
</span>
</c:when>
<c:otherwise>
<span>
<b>Ticket #${zendeskTicketKey} vinculado&nbsp;</b>
<pronto:icons name="excluir.png" title="Desvincular esta tarefa com a tarefa do Zendesk" onclick="excluirVinculoComZendesk(${ticket.ticketKey})"/>
<c:forEach items="${zendeskTicket}" var="zdTicket">
<b>Ticket #${zdTicket.nice_id} vinculado&nbsp;</b>
<pronto:icons name="excluir.png" title="Desvincular esta tarefa com a tarefa do Zendesk" onclick="excluirVinculoComZendesk(${ticket.ticketKey}, ${zdTicket.nice_id})"/>
<br/>
</c:forEach>
</span>
</c:otherwise>
</c:choose>
<p>Zendesk</p>
<p>
Zendesk
<pronto:icons name="adicionar.png" title="Vincular esta tarefa com uma tarefa do Zendesk" onclick="adicionarVinculoComZendesk()"/>
</p>
</div>
</c:if>
</div>
@@ -597,9 +606,13 @@
</div>

<c:if test="${zendeskTicket ne null}">
<div id="zendesk">
<%@ include file="ticket.zendesk.jsp" %>
</div>
<c:forEach items="${zendeskTicket}" var="zdTicket">
<div id="zendesk${zdTicket.nice_id}">
<c:set var="zendeskTicketAtual" value="${zdTicket}"/>
<c:set var="zendeskTicketAtualKey" value="${zdTicket.nice_id}"/>
<%@ include file="ticket.zendesk.jsp" %>
</div>
</c:forEach>
</c:if>

<div id="anexos">
@@ -1,27 +1,28 @@
<%@ include file="/commons/taglibs.jsp"%>
<div class="htmlbox comentario" style="position: relative;">

<div class="comentario-data">${zendeskTicket.created_at}</div>

<div class="comentario-data">${zendeskTicketAtual.created_at}</div>

<div class="person-comentario">
<div class="person">
<pronto:icons name="zendesk.png" title="Zendesk" onclick="openWindow('${zendeskUrl}/tickets/${zendeskTicketKey}')" clazz="gravatar50"/>
<pronto:icons name="zendesk.png" title="Zende sk" onclick="openWindow('${zendeskUrl}/tickets/${zendeskTicketAtualKey}')" clazz="gravatar50"/>
<div class="person_name">Zendesk</div>
</div>
</div>

<div class="comentario-html">
<h3>Ticket <a href="${zendeskUrl}/tickets/${zendeskTicketKey}" target="_blank">#${zendeskTicket.nice_id}</a> do Zendesk</h3>
<b>Status:</b> ${zendeskTicket.status}<br/>
<b>Tipo:</b> ${zendeskTicket.tipo}<br/>
<h3>Ticket <a href="${zendeskUrl}/tickets/${zendeskTicketAtualKey}" target="_blank">#${zendeskTicketAtual.nice_id}</a> do Zendesk</h3>
<b>Status:</b> ${zendeskTicketAtual.status}<br/>
<b>Tipo:</b> ${zendeskTicketAtual.tipo}<br/>


</div>

</div>

<c:if test="${!empty zendeskTicket.comments}">
<c:forEach items="${zendeskTicket.comments}" var="comentario">
<c:if test="${!empty zendeskTicketAtual.comments}">
<c:forEach items="${zendeskTicketAtual.comments}" var="comentario">
<div class="htmlbox comentario" style="position: relative;">

<div class="comentario-data">${comentario.created_at}</div>
@@ -58,7 +59,7 @@
</c:if>

<h3>Incluir comentário privado no Zendesk</h3>
<form action="${raiz}/zendesk/tickets/${zendeskTicket.nice_id }/comentarios" method="post">
<form action="${raiz}/zendesk/tickets/${zendeskTicketAtual.nice_id }/comentarios" method="post">
<div>
<textarea id="comentarioZendesk" name="comentarioZendesk"></textarea>
</div>

0 comments on commit 69500f4

Please sign in to comment.
You can’t perform that action at this time.