ufjf-dcc / tcc-web

4 stars 12 forks source link

Trabalhos passados #35

Closed jairofsouza closed 9 years ago

jairofsouza commented 9 years ago

O coordenador tem que ter acesso a trabalhos passados para atualizar, aprovar e enviar PDF mesmo fora do período. O coordenador tem que ter direito a apagar trabalhos/projetos.

lucaslarcher commented 9 years ago

o acesso a trabalhos passados já ocorre, agora vamos a tarefa de excluir, vou criar um excluit tcc geral e utilizar por enquanto so em trabalhos nao finalizados:

primeiro novo função em ParticipacaoBusiness, adicionar a função:

public boolean excluiLista(List<Participacao> participacoes)
{
    return participacaoDAO.excluiLista(participacoes);
}

agora em TCCBussines a nova função:

public boolean excluitTCC(TCC tcc) { ParticipacaoBusiness PB = new ParticipacaoBusiness(); PB.excluiLista(PB.getParticipacoesByTCC(tcc));

    File f;
    if(tcc.getArquivoTCCFinal()!=null)
    {
        f = new File(ConfHandler.getConf("FILE.PATH")+tcc.getArquivoTCCFinal());
        if(f!=null)
            f.delete();
    }
    if(tcc.getArquivoExtraTCCFinal()!=null)
    {
        f = new File(ConfHandler.getConf("FILE.PATH")+tcc.getArquivoExtraTCCFinal());
        if(f!=null)
            f.delete();
    }
    if(tcc.getArquivoExtraTCCBanca()!=null)
    {
        f = new File(ConfHandler.getConf("FILE.PATH")+tcc.getArquivoExtraTCCBanca());
        if(f!=null)
            f.delete();
    }
    if(tcc.getArquivoTCCBanca()!=null)
    {
        f = new File(ConfHandler.getConf("FILE.PATH")+tcc.getArquivoTCCBanca());
        if(f!=null)
            f.delete();
    }

    if((new TCCDAO()).exclui(tcc))
        return true;
    return false;
}

agora podemos excluir os TCCs

para colocar isso na pagina vamos em tccs-curso e criaremos uma nova coluna pra excluir e sua devida row, columns e rows ficam assim:

        <template name="lista">
            <row xmlns:w="client"
                w:onClick="visualzarTCC(${each.idTCC});"
                tooltip="${forEachStatus.index}, position=at_pointer">
                <div>
                    <label value="@load(each.nomeTCC)" />
                    <popup id="${forEachStatus.index}">
                        <vlayout width="550px">
                            <label value="Resumo"
                                style="font-size: 14px; font-weight: bold; text-align: justify; display: block;" />
                            <label value="@load(each.resumoTCC)" />
                            <hlayout>
                                <label value="Ano: "
                                    style="font-weight:bold;" />
                                <label
                                    onCreate="@command('getEachTccYear', tcc=each, lbl=self)" />
                            </hlayout>
                            <label value="Orientador"
                                style="font-size: 14px; font-weight: bold; text-align: justify; display: block;" />
                            <label
                                value="@load(each.orientador.nomeUsuario)" />
                            <label value="Palavras-chave"
                                visible="@load(not empty each.palavrasChave)"
                                style="font-size: 14px; font-weight: bold; text-align: justify; display: block;" />
                            <label
                                value="@load(each.palavrasChave)" />
                        </vlayout>
                    </popup>
                </div>
                <label value="@load(each.aluno.nomeUsuario)" />
                <label value="@load(each.orientador.nomeUsuario)" />
                <label value="@load(each.dataEnvioBanca)" />
                <label value="@load(each.statusTCC)" />
                <image src="/img/pdf.png" style="cursor: pointer"
                    onClick="@command('downloadPDF', tcc=each)" />
                <image style="cursor: pointer"
                    src="@load(not empty each.arquivoExtraTCCFinal ? '/img/rar.png' : '/img/norar.png')"
                    onClick="@command('downloadExtra', tcc=each)" />
                <button image="/img/delete.png" 
                    onClick="@command('excluirTCC', tcc=each)" />
            </row>

agora falta a função para alimentar isso:

em TCCsCursoController adicione a função:

@Command
public void excluirTCC(@BindingParam("tcc") final TCC tcc)
{
    final String mensagem;
    if(tcc.isProjeto())
        mensagem = "Projeto";
    else
        mensagem = "Trabalho";

    Messagebox.show("Tem certeza que deseja excluir este "+mensagem+"?", "Confirmação", Messagebox.YES | Messagebox.NO, Messagebox.QUESTION, new org.zkoss.zk.ui.event.EventListener() {
        public void onEvent(Event evt) throws InterruptedException {
            if (evt.getName().equals("onYes")) {
                if((new TCCBusiness()).excluitTCC(tcc))
                    Messagebox.show(mensagem, "Confirmação", Messagebox.OK, Messagebox.EXCLAMATION, new org.zkoss.zk.ui.event.EventListener() {
                        public void onEvent(Event evt) throws InterruptedException {
                            if (evt.getName().equals("onOK")) {
                                Executions.sendRedirect(null);
                            } 
                            else
                                Executions.sendRedirect(null);
                        }
                    });
                else
                    Messagebox.show("Erro!");
            } 

        }
    });
}