Coverage Report - br.mia.test.controler.ControladorGraph
 
Classes in this File Line Coverage Branch Coverage Complexity
ControladorGraph
0%
0/628
0%
0/374
0
 
 1  
 package br.mia.test.controler;
 2  
 
 3  
 import java.awt.datatransfer.UnsupportedFlavorException;
 4  
 import java.awt.geom.Point2D;
 5  
 import java.io.IOException;
 6  
 import java.sql.SQLException;
 7  
 import java.util.ArrayList;
 8  
 import java.util.HashMap;
 9  
 import java.util.List;
 10  
 
 11  
 import javax.swing.JTextField;
 12  
 import javax.swing.SwingConstants;
 13  
 
 14  
 import org.jgraph.JGraph;
 15  
 import org.jgraph.graph.DefaultEdge;
 16  
 import org.jgraph.graph.DefaultGraphCell;
 17  
 import org.jgraph.graph.GraphConstants;
 18  
 
 19  
 import br.mia.test.model.CasoUso;
 20  
 import br.mia.test.model.Filtro;
 21  
 import br.mia.test.model.Fluxo;
 22  
 import br.mia.test.model.Link;
 23  
 import br.mia.test.model.RegraNegocio;
 24  
 import br.mia.test.model.Step;
 25  
 import br.mia.test.model.TestDataValor;
 26  
 import br.mia.test.model.dao.DAOFiltro;
 27  
 import br.mia.test.model.dao.DAOStep;
 28  
 import br.mia.test.testcase.DadosTeste;
 29  
 import br.mia.test.view.factory.BotaoFactory;
 30  
 import br.mia.test.view.graph.BotaoCell;
 31  
 import br.mia.test.view.graph.CodeGrafoPane;
 32  
 import br.mia.test.view.graph.CondicionalCell;
 33  
 import br.mia.test.view.graph.DadoEdge;
 34  
 import br.mia.test.view.graph.DataCell;
 35  
 import br.mia.test.view.graph.FiltroEdge;
 36  
 import br.mia.test.view.graph.FlowCell;
 37  
 import br.mia.test.view.graph.GrafoPane;
 38  
 import br.mia.test.view.graph.LinkEdge;
 39  
 import br.mia.test.view.graph.LinkPort;
 40  
 import br.mia.test.view.graph.RuleCell;
 41  
 import br.mia.test.view.graph.RuleEdge;
 42  
 import br.mia.test.view.graph.StateFlowCell;
 43  
 import br.mia.test.view.graph.StepCell;
 44  
 import br.mia.test.view.graph.Util;
 45  
 import br.mia.test.view.graph.ValorCell;
 46  0
 import br.mia.test.view.graph.ValorEdge;
 47  0
 import br.mia.test.view.graph.observer.ObserverCodeGraphPane;
 48  
 import br.mia.test.view.graph.observer.ObserverComponent;
 49  
 import br.mia.test.view.graph.observer.ObserverComponentCodigo;
 50  
 import br.mia.test.view.graph.observer.ObserverGraphPane;
 51  
 
 52  
 /***
 53  
  * Controlador para gera��o do modelo gr�fico
 54  
  *
 55  
  * @author 74397176353
 56  
  *
 57  
  */
 58  0
 public class ControladorGraph extends AbstractControlerPane
 59  
 {
 60  
 
 61  
     /***
 62  
      * Cola passos no modelo grafico
 63  0
      *
 64  
      * @param flowCell
 65  0
      * @param stepCell
 66  0
      * @param fluxo
 67  0
      * @param useCase
 68  0
      * @param objetos
 69  0
      * @param passosCobertos
 70  0
      * @throws UnsupportedFlavorException
 71  0
      * @throws IOException
 72  0
      */
 73  0
     public void colarPassos(FlowCell flowCell, StepCell stepCell, Fluxo fluxo,
 74  0
             CasoUso useCase, ArrayList<Object> objetos,
 75  0
             ArrayList<Object> passosCobertos)
 76  0
             throws UnsupportedFlavorException, IOException {
 77  0
         String conteudo = br.mia.test.util.Util.getClipboardContents();
 78  0
 
 79  0
         String[] linhas = conteudo.split("\n");
 80  0
 
 81  0
         StepCell auxiliar = stepCell;
 82  
 
 83  0
         int x = 20;
 84  0
         int y = 20;
 85  0
         if (stepCell != null) {
 86  0
             x = stepCell.getX();
 87  0
             y = stepCell.getY() + 20;
 88  
         }
 89  0
         if (flowCell != null) {
 90  0
             x = flowCell.getX();
 91  0
             y = flowCell.getY() + 20;
 92  0
 
 93  
         }
 94  0
 
 95  0
         DAOStep dao = new DAOStep();
 96  0
         for (int i = 0; i <= linhas.length - 1; i++) {
 97  0
 
 98  0
             String descricaoAux = linhas[i].toString();
 99  0
             if (descricaoAux.replaceAll(" ", "").length() > 0) {
 100  0
 
 101  0
                 Step step = new Step();
 102  0
                 step.setDescricao(linhas[i]);
 103  0
 
 104  0
                 try {
 105  0
                     step = (Step) dao.insert(step, fluxo);
 106  0
                     fluxo.getSteps().add(step);
 107  0
 
 108  0
                     StepCell novoStepCell = Util.criaPasso(fluxo, step,
 109  0
                             useCase, x, y, passosCobertos);
 110  0
 
 111  0
                     objetos.add(novoStepCell);
 112  0
                     if (auxiliar != null) {
 113  0
                         Util.criaLinkPasso(auxiliar, novoStepCell, objetos);
 114  
                     }
 115  0
                     y = y + 40;
 116  0
                     auxiliar = novoStepCell;
 117  0
                 } catch (Exception e1) {
 118  0
                     ControladorErro.trata(e1, this);
 119  0
                 }
 120  0
 
 121  0
             }
 122  0
         }
 123  0
 
 124  0
     }
 125  0
 
 126  0
     public void criaCodigo(CasoUso useCase, ArrayList<Object> passosCobertos,
 127  0
             JGraph graph, ArrayList<Object> celulas,
 128  0
             ObserverCodeGraphPane observer) throws IOException {
 129  0
 
 130  0
         HashMap<Object, Object> mapa = new HashMap<Object, Object>();
 131  0
         HashMap<Object, Object> mapaStep = new HashMap<Object, Object>();
 132  0
         int x = 0;
 133  
 
 134  0
         HashMap<Object, Object> flows = new HashMap<Object, Object>();
 135  0
         for (Object object : useCase.getFlows()) {
 136  0
             Fluxo flow = (Fluxo) object;
 137  0
             FlowCell cell = new FlowCell(flow.getName(), flow, x, 0);
 138  0
             mapa.put(flow.getName(), cell);
 139  
 
 140  0
             celulas.add(cell);
 141  0
             int y = 40;
 142  0
             int contador = 0;
 143  0
             StepCell cellAnterior = null;
 144  0
 
 145  0
             if (!(flows.containsKey(flow.getName()))) {
 146  0
                 flows.put(flow.getName(), new ArrayList<StepCell>());
 147  0
             }
 148  0
 
 149  0
             if (!(flow.isMinimizado())) {
 150  0
 
 151  0
                 this.criaFlowCodigo(flow, useCase, x, y, passosCobertos, flows,
 152  0
                         mapaStep, contador, celulas, cellAnterior);
 153  0
             } else {
 154  0
                 this.criaFlowResumido(flow, useCase, x, y, passosCobertos,
 155  0
                         flows, mapaStep, contador, celulas, cellAnterior);
 156  
             }
 157  0
 
 158  0
             x = x + 150;
 159  
 
 160  0
         }
 161  
 
 162  0
         for (Object object : useCase.getFlows()) {
 163  0
 
 164  0
             Fluxo flow = (Fluxo) object;
 165  0
 
 166  0
             int contador = 0;
 167  0
 
 168  0
             if (!(flow.isMinimizado())) {
 169  0
                 this.criaLinkNaoResumido(flow, mapaStep, contador, celulas);
 170  0
             } else {
 171  0
                 this.criaLinkResumido(flow, mapaStep, celulas, contador);
 172  0
 
 173  0
             }
 174  0
 
 175  0
         }
 176  0
         if (!(observer.getMapas().contains(flows))) {
 177  0
             observer.getMapas().add(flows);
 178  0
         }
 179  0
 
 180  0
         CodeGrafoPane grafoPane = observer.getGrafoPane();
 181  0
         if (grafoPane != null) {
 182  0
             grafoPane.setCelulas(celulas);
 183  0
         }
 184  0
         graph.getGraphLayoutCache().insert(celulas.toArray());
 185  0
         ObserverComponentCodigo observerComponent = new ObserverComponentCodigo(
 186  0
                 grafoPane);
 187  0
         observerComponent.getGraph().add(graph);
 188  0
         observerComponent.getObjetos().add(useCase);
 189  0
         graph.addGraphSelectionListener(observerComponent);
 190  0
         graph.addKeyListener(observerComponent);
 191  0
 
 192  0
     }
 193  0
 
 194  0
     public void cria(CasoUso useCase, ArrayList<Object> passosCobertos,
 195  0
             JGraph graph, List<Object> list, ObserverGraphPane observer) {
 196  0
 
 197  0
         HashMap<Object, Object> mapa = new HashMap<Object, Object>();
 198  0
         HashMap<Object, Object> mapaStep = new HashMap<Object, Object>();
 199  0
         int x = 0;
 200  
 
 201  0
         HashMap<Object, Object> flows = new HashMap<Object, Object>();
 202  0
         for (Object object : useCase.getFlows()) {
 203  0
             Fluxo flow = (Fluxo) object;
 204  0
             FlowCell cell = new FlowCell(flow.getName(), flow, x, 0);
 205  0
             mapa.put(flow.getName(), cell);
 206  
 
 207  0
             list.add(cell);
 208  0
             int y = 40;
 209  0
             int contador = 0;
 210  0
             StepCell cellAnterior = null;
 211  0
 
 212  0
             if (!(flows.containsKey(flow.getName()))) {
 213  0
                 flows.put(flow.getName(), new ArrayList<StepCell>());
 214  0
             }
 215  0
 
 216  0
             if (!(flow.isMinimizado())) {
 217  0
 
 218  0
                 this.criaFlow(flow, useCase, x, y, passosCobertos, flows,
 219  0
                         mapaStep, contador, list, cellAnterior);
 220  0
             } else {
 221  0
                 this.criaFlowResumido(flow, useCase, x, y, passosCobertos,
 222  0
                         flows, mapaStep, contador, list, cellAnterior);
 223  
             }
 224  0
 
 225  0
             x = x + 150;
 226  
 
 227  0
         }
 228  
 
 229  0
         for (Object object : useCase.getFlows()) {
 230  0
 
 231  0
             Fluxo flow = (Fluxo) object;
 232  0
 
 233  0
             int contador = 0;
 234  0
 
 235  0
             if (!(flow.isMinimizado())) {
 236  0
                 this.criaLinkNaoResumido(flow, mapaStep, contador, list);
 237  0
             } else {
 238  0
                 this.criaLinkResumido(flow, mapaStep, list, contador);
 239  0
 
 240  0
             }
 241  0
 
 242  0
         }
 243  0
         if (!(observer.getMapas().contains(flows))) {
 244  0
             observer.getMapas().add(flows);
 245  0
         }
 246  0
 
 247  0
         GrafoPane grafoPane = observer.getGrafoPane();
 248  0
         if (grafoPane != null) {
 249  0
             grafoPane.setCelulas(list);
 250  
         }
 251  
 
 252  0
         graph.getGraphLayoutCache().insert(list.toArray());
 253  0
         ObserverComponent observerComponent = new ObserverComponent(grafoPane);
 254  0
         observerComponent.getGraph().add(graph);
 255  0
         observerComponent.getObjetos().add(useCase);
 256  0
         graph.addGraphSelectionListener(observerComponent);
 257  0
         graph.addKeyListener(observerComponent);
 258  
 
 259  0
     }
 260  0
 
 261  
     @SuppressWarnings("unchecked")
 262  0
     public void criaFlow(Fluxo flow, CasoUso useCase, int x, int y,
 263  0
             ArrayList<Object> passosCobertos, HashMap<Object, Object> flows,
 264  0
             HashMap<Object, Object> mapaStep, int contador, List<Object> list,
 265  0
             StepCell cellAnterior) {
 266  0
         for (Object object1 : flow.getSteps()) {
 267  0
 
 268  0
             Step step = (Step) object1;
 269  0
 
 270  0
             StepCell cell1 = Util.criaPasso(flow, step, useCase, x, y,
 271  0
                     passosCobertos);
 272  0
 
 273  0
             ArrayList<StepCell> steps = (ArrayList<StepCell>) flows.get(flow
 274  0
                     .getName());
 275  0
 
 276  0
             steps.add(cell1);
 277  0
 
 278  0
             y = y + 40;
 279  0
 
 280  0
             mapaStep.put(flow.getName() + contador, cell1);
 281  0
             if (!(list.contains(cell1))) {
 282  0
                 list.add(cell1);
 283  0
             }
 284  0
             contador++;
 285  0
 
 286  0
             for (Filtro filtro : step.getFiltros()) {
 287  0
                 y = y + 40;
 288  0
                 CondicionalCell condicao = Util.criaCondicao(filtro, 40 + x, y,
 289  0
                         step, flow, useCase);
 290  0
 
 291  0
                 FiltroEdge edge = Util.criaLinkCondicao(condicao, cell1);
 292  0
                 list.add(condicao);
 293  0
                 if (!(list.contains(edge))) {
 294  0
                     list.add(edge);
 295  0
                 }
 296  0
 
 297  0
             }
 298  0
 
 299  0
             if (cellAnterior != null) {
 300  0
 
 301  0
                 Util.criaLinkPasso(cellAnterior, cell1, list);
 302  0
 
 303  0
             }
 304  0
 
 305  0
             cellAnterior = cell1;
 306  0
 
 307  0
             for (Object object2 : step.getDatas()) {
 308  0
                 DadosTeste data = (DadosTeste) object2;
 309  0
                 x = x + 40;
 310  0
                 DataCell cell2 = Util.criaDado(data, x, y, step);
 311  0
 
 312  0
                 x = x - 40;
 313  0
 
 314  0
                 y = y + 40;
 315  0
 
 316  0
                 mapaStep.put(flow.getName() + contador + data.getName(), cell2);
 317  0
                 if (!(list.contains(cell2))) {
 318  0
                     list.add(cell2);
 319  0
                 }
 320  0
 
 321  0
                 DadoEdge edge1 = Util.criaLinkDado(cell1, cell2);
 322  0
                 if (!(list.contains(edge1))) {
 323  0
                     list.add(edge1);
 324  0
                 }
 325  0
 
 326  0
             }
 327  0
             for (Object object2 : step.getRegras()) {
 328  0
                 RegraNegocio rule = (RegraNegocio) object2;
 329  0
                 x = x - 40;
 330  0
                 RuleCell cell2 = Util.criaRule(rule, x, y, step);
 331  0
 
 332  0
                 x = x + 40;
 333  
 
 334  0
                 y = y + 40;
 335  
 
 336  0
                 mapaStep.put(flow.getName() + contador + rule.getName(), cell2);
 337  0
                 if (!(list.contains(cell2))) {
 338  0
                     list.add(cell2);
 339  0
                 }
 340  
 
 341  0
                 RuleEdge edge1 = Util.criaLinkRule(cell1, cell2);
 342  0
                 if (!(list.contains(edge1))) {
 343  0
                     list.add(edge1);
 344  0
                 }
 345  
 
 346  0
             }
 347  0
 
 348  
         }
 349  0
 
 350  0
     }
 351  
 
 352  0
     @SuppressWarnings("unchecked")
 353  0
     public void criaFlowCodigo(Fluxo flow, CasoUso useCase, int x, int y,
 354  0
             ArrayList<Object> passosCobertos, HashMap<Object, Object> flows,
 355  0
             HashMap<Object, Object> mapaStep, int contador,
 356  0
             ArrayList<Object> celulas, StepCell cellAnterior)
 357  0
             throws IOException {
 358  0
         for (Object object1 : flow.getSteps()) {
 359  
 
 360  0
             Step step = (Step) object1;
 361  0
 
 362  
             StepCell cell1;
 363  0
 
 364  0
             if (step.getTipoObjeto() != null) {
 365  0
 
 366  0
                 if (step.getTipoObjeto().equals("Bot�o")) {
 367  0
                     cell1 = new BotaoCell(step.getPalavraChave(), useCase,
 368  0
                             step, flow, flow.getSteps().indexOf(step), 20 + x,
 369  0
                             20 + y, passosCobertos);
 370  0
 
 371  0
                     GraphConstants.setIcon(cell1.getAttributes(), BotaoFactory
 372  0
                             .createIcon("button"));
 373  0
 
 374  0
                     GraphConstants.setVerticalTextPosition(cell1
 375  0
                             .getAttributes(), SwingConstants.BOTTOM);
 376  
 
 377  0
                 } else {
 378  0
                     cell1 = new StepCell(step.getPalavraChave(), useCase, step,
 379  0
                             flow, flow.getSteps().indexOf(step), 20 + x,
 380  0
                             20 + y, passosCobertos);
 381  0
                 }
 382  0
             } else {
 383  0
                 cell1 = new StepCell(step.getPalavraChave(), useCase, step,
 384  0
                         flow, flow.getSteps().indexOf(step), 20 + x, 20 + y,
 385  0
                         passosCobertos);
 386  0
             }
 387  0
 
 388  0
             ArrayList<StepCell> steps = (ArrayList<StepCell>) flows.get(flow
 389  0
                     .getName());
 390  0
 
 391  0
             steps.add(cell1);
 392  0
 
 393  0
             y = y + 40;
 394  0
 
 395  0
             mapaStep.put(flow.getName() + contador, cell1);
 396  0
             if (!(celulas.contains(cell1))) {
 397  0
                 celulas.add(cell1);
 398  0
             }
 399  0
             contador++;
 400  0
 
 401  0
             for (Filtro filtro : step.getFiltros()) {
 402  0
                 CondicionalCell condicao = Util.criaCondicao(filtro, 40 + x,
 403  0
                         40 + y, step, flow, useCase);
 404  0
                 FiltroEdge edge = Util.criaLinkCondicao(condicao, cell1);
 405  0
                 celulas.add(condicao);
 406  0
                 if (!(celulas.contains(edge))) {
 407  0
                     celulas.add(edge);
 408  0
                 }
 409  0
 
 410  0
             }
 411  0
 
 412  0
             if (cellAnterior != null) {
 413  0
 
 414  0
                 DefaultEdge edge = new DefaultEdge();
 415  0
                 int arrow = GraphConstants.ARROW_CLASSIC;
 416  0
                 GraphConstants.setLineEnd(edge.getAttributes(), arrow);
 417  0
                 GraphConstants.setEndFill(edge.getAttributes(), true);
 418  0
 
 419  0
                 edge.setSource(cellAnterior.getChildAt(0));
 420  0
                 edge.setTarget(cell1.getChildAt(0));
 421  0
                 cell1.setSetaAnterior(edge);
 422  0
                 if (!(celulas.contains(edge))) {
 423  0
                     celulas.add(edge);
 424  0
                 }
 425  0
             }
 426  0
 
 427  0
             cellAnterior = cell1;
 428  0
 
 429  0
             for (Object object2 : step.getDatas()) {
 430  0
                 DadosTeste data = (DadosTeste) object2;
 431  0
                 x = x + 40;
 432  0
                 DataCell cell2 = Util.criaDado(data, x, y, step);
 433  0
 
 434  0
                 x = x - 40;
 435  0
 
 436  0
                 y = y + 40;
 437  0
 
 438  0
                 mapaStep.put(flow.getName() + contador + data.getName(), cell2);
 439  0
                 if (!(celulas.contains(cell2))) {
 440  0
                     celulas.add(cell2);
 441  0
                 }
 442  0
 
 443  0
                 DadoEdge edge1 = Util.criaLinkDado(cell1, cell2);
 444  0
                 if (!(celulas.contains(edge1))) {
 445  0
                     celulas.add(edge1);
 446  0
                 }
 447  0
 
 448  0
             }
 449  0
             for (Object object2 : step.getRegras()) {
 450  0
                 RegraNegocio rule = (RegraNegocio) object2;
 451  0
                 x = x - 40;
 452  0
                 RuleCell cell2 = Util.criaRule(rule, x, y, step);
 453  0
 
 454  0
                 x = x + 40;
 455  
 
 456  0
                 y = y + 40;
 457  
 
 458  0
                 mapaStep.put(flow.getName() + contador + rule.getName(), cell2);
 459  0
                 if (!(celulas.contains(cell2))) {
 460  0
                     celulas.add(cell2);
 461  0
                 }
 462  
 
 463  0
                 RuleEdge edge1 = Util.criaLinkRule(cell1, cell2);
 464  0
                 if (!(celulas.contains(edge1))) {
 465  0
                     celulas.add(edge1);
 466  0
                 }
 467  0
 
 468  0
             }
 469  0
 
 470  0
         }
 471  0
 
 472  0
     }
 473  0
 
 474  0
     public void criaLinkNaoResumido(Fluxo flow,
 475  0
             HashMap<Object, Object> mapaStep, int contador, List<Object> list) {
 476  0
         if (flow.isShowLink()) {
 477  0
             for (Object object1 : flow.getSteps()) {
 478  0
 
 479  0
                 Step step = (Step) object1;
 480  
 
 481  0
                 for (Object object2 : step.getLinks()) {
 482  0
 
 483  0
                     Link link = (Link) object2;
 484  0
 
 485  0
                     Fluxo flowLink = link.getFlow();
 486  0
 
 487  0
                     StepCell cellOrigem = (StepCell) mapaStep.get(flow
 488  0
                             .getName()
 489  0
                             + contador);
 490  0
 
 491  0
                     if (flowLink != null) {
 492  0
                         if (!(Util.getFlows().contains(flowLink.getName()))) {
 493  0
 
 494  0
                             StepCell cellDestino = (StepCell) mapaStep
 495  0
                                     .get(flowLink.getName()
 496  0
                                             + link.getStepNumber());
 497  0
 
 498  0
                             if (cellDestino != null) {
 499  0
 
 500  0
                                 DefaultEdge edge = Util.criaLink(cellOrigem,
 501  0
                                         cellDestino, link);
 502  0
 
 503  0
                                 if (!(list.contains(edge))) {
 504  0
                                     list.add(edge);
 505  
                                 }
 506  
                             }
 507  0
                         } else {
 508  0
                             StateFlowCell cellDestino = (StateFlowCell) mapaStep
 509  0
                                     .get(flowLink.getName());
 510  0
                             DefaultEdge edge = Util.criaLink(cellOrigem,
 511  0
                                     cellDestino, link);
 512  0
                             if (!(list.contains(edge))) {
 513  0
                                 list.add(edge);
 514  
                             }
 515  
                         }
 516  
 
 517  
                     }
 518  
                 }
 519  
 
 520  0
                 contador++;
 521  0
             }
 522  
         }
 523  0
     }
 524  
 
 525  0
     /***
 526  0
      * Cria link para fluxos no modeo escondido
 527  0
      *
 528  0
      * @param flow
 529  0
      * @param mapaStep
 530  0
      * @param list
 531  
      * @param contador
 532  0
      */
 533  0
     public void criaLinkResumido(Fluxo flow, HashMap<Object, Object> mapaStep,
 534  
             List<Object> list, int contador) {
 535  0
         for (Object object1 : flow.getSteps()) {
 536  0
 
 537  0
             Step step = (Step) object1;
 538  0
 
 539  0
             for (Object object2 : step.getLinks()) {
 540  0
                 Link link = (Link) object2;
 541  0
 
 542  0
                 Fluxo flowLink = link.getFlow();
 543  0
 
 544  0
                 try {
 545  0
 
 546  0
                     StateFlowCell cellOrigem = (StateFlowCell) mapaStep
 547  0
                             .get(flow.getName());
 548  0
 
 549  0
                     if (!(Util.getFlows().contains(flowLink.getName()))) {
 550  0
 
 551  0
                         StepCell cellDestino = (StepCell) mapaStep.get(flowLink
 552  0
                                 .getName()
 553  0
                                 + link.getStepNumber());
 554  
 
 555  0
                         if (cellDestino != null) {
 556  0
 
 557  0
                             DefaultEdge edge = Util.criaLink(cellOrigem,
 558  0
                                     cellDestino, link);
 559  0
                             if (!(list.contains(edge))) {
 560  0
                                 list.add(edge);
 561  0
                             }
 562  0
                         }
 563  0
 
 564  
                     } else {
 565  
 
 566  0
                         StateFlowCell cellDestino = (StateFlowCell) mapaStep
 567  0
                                 .get(flowLink.getName());
 568  0
 
 569  0
                         DefaultEdge edge = Util.criaLink(cellOrigem,
 570  0
                                 cellDestino, link);
 571  0
                         if (!(list.contains(edge))) {
 572  0
                             list.add(edge);
 573  
                         }
 574  
 
 575  0
                     }
 576  0
                 } catch (Exception e) {
 577  0
                     ControladorErro.trata(e, this);
 578  
                 }
 579  0
 
 580  0
             }
 581  
 
 582  0
             contador++;
 583  0
         }
 584  0
 
 585  0
     }
 586  0
 
 587  0
     @SuppressWarnings("unchecked")
 588  0
     public void criaFlowResumido(Fluxo flow, CasoUso useCase, int x, int y,
 589  
             ArrayList passosCobertos, HashMap<Object, Object> flows,
 590  0
             HashMap<Object, Object> mapaStep, int contador, List<Object> list,
 591  
             StepCell cellAnterior) {
 592  0
 
 593  0
         StateFlowCell flowCell = new StateFlowCell(flow.getName(), flow,
 594  0
                 20 + x, 20 + y);
 595  
 
 596  0
         if (!(list.contains(flowCell))) {
 597  0
             list.add(flowCell);
 598  0
         }
 599  0
 
 600  0
         mapaStep.put(flow.getName(), flowCell);
 601  0
 
 602  0
         for (Object object1 : flow.getSteps()) {
 603  0
 
 604  0
             Step step = (Step) object1;
 605  0
 
 606  0
             StepCell cell1 = new StepCell(step.getDescricao(), useCase, step,
 607  0
                     flow, flow.getSteps().indexOf(step), 20 + x, 20 + y,
 608  0
                     passosCobertos);
 609  0
 
 610  0
             ArrayList<Object> steps = (ArrayList<Object>) flows.get(flow
 611  0
                     .getName());
 612  0
 
 613  0
             steps.add(cell1);
 614  
 
 615  0
             y = y + 40;
 616  
 
 617  0
             mapaStep.put(flow.getName() + contador, cell1);
 618  
 
 619  0
             contador++;
 620  
         }
 621  
 
 622  0
     }
 623  
 
 624  
     @Override
 625  
     public void deletarEspecifico(Object[] selecionados, CasoUso useCase,
 626  
             List<DefaultGraphCell> remocao) throws InstantiationException,
 627  
             IllegalAccessException, ClassNotFoundException, SQLException,
 628  
             IOException {
 629  0
         StepCell primeiro = null;
 630  
 
 631  0
         for (int i = 0; i <= selecionados.length - 1; i++) {
 632  0
             primeiro = (StepCell) selecionados[i];
 633  0
             ControladorStep controlador = new ControladorStep();
 634  0
             controlador.deletarStep(primeiro.getStep(), useCase, primeiro
 635  0
                     .getFlow());
 636  
 
 637  0
             remocao.add(primeiro);
 638  
 
 639  
         }
 640  
 
 641  0
     }
 642  
 
 643  
     @Override
 644  
     public void ligarValorEspecifico(Object[] celulas,
 645  
             List<DefaultGraphCell> adicao) throws InstantiationException,
 646  
             IllegalAccessException, ClassNotFoundException, SQLException,
 647  
             IOException {
 648  0
         DataCell primeiro1 = null;
 649  0
         for (int i = 0; i <= selecionados.length - 1; i++) {
 650  
 
 651  0
             Object celula = selecionados[i];
 652  
 
 653  0
             if (celula instanceof DataCell) {
 654  
 
 655  0
                 primeiro1 = (DataCell) celula;
 656  
             }
 657  0
             if (celula instanceof ValorCell) {
 658  
 
 659  0
                 ValorCell valorCell = (ValorCell) celula;
 660  
 
 661  0
                 TestDataValor valor = valorCell.getValor();
 662  
 
 663  0
                 DadosTeste data = primeiro1.getData();
 664  
 
 665  0
                 ValorEdge seta = Util.criaLinkValor(primeiro1, valorCell);
 666  0
                 adicao.add(seta);
 667  
 
 668  0
                 FlowController controlador = new FlowController();
 669  0
                 controlador.inserirValor(data, valor);
 670  
 
 671  
             }
 672  
 
 673  
         }
 674  
 
 675  0
     }
 676  
 
 677  
     @Override
 678  
     public void ligarRegraEspecifico(Object[] celulas,
 679  
             List<DefaultGraphCell> adicao) {
 680  
 
 681  0
         StepCell primeiro3 = null;
 682  
 
 683  0
         for (int i = 0; i <= selecionados.length - 1; i++) {
 684  
 
 685  0
             Object celula = selecionados[i];
 686  
 
 687  0
             if (celula instanceof StepCell) {
 688  
 
 689  0
                 primeiro3 = (StepCell) celula;
 690  
             }
 691  0
             if (celula instanceof RuleCell) {
 692  
 
 693  0
                 RuleCell data = (RuleCell) celula;
 694  
 
 695  0
                 data.setStep(primeiro3.getStep());
 696  
 
 697  0
                 RuleEdge seta = Util.criaLinkRule(primeiro3, data);
 698  0
                 adicao.add(seta);
 699  
 
 700  0
                 FlowController controlador = new FlowController();
 701  0
                 controlador.inserirRegra(primeiro3.getStep(), primeiro3
 702  0
                         .getFlow(), data.getRule());
 703  
 
 704  
             }
 705  
 
 706  
         }
 707  
 
 708  0
     }
 709  
 
 710  
     @Override
 711  
     public void ligarDadoEspecifico(Object[] celulas,
 712  
             List<DefaultGraphCell> adicao) {
 713  
 
 714  0
         StepCell primeiro1 = null;
 715  0
         for (int i = 0; i <= celulas.length - 1; i++) {
 716  
 
 717  0
             Object celula = celulas[i];
 718  
 
 719  0
             if (celula instanceof StepCell) {
 720  
 
 721  0
                 primeiro1 = (StepCell) celula;
 722  
             }
 723  0
             if (celula instanceof DataCell) {
 724  
 
 725  0
                 DataCell data = (DataCell) celula;
 726  0
                 DadoEdge seta = Util.criaLinkDado(primeiro1, data);
 727  0
                 adicao.add(seta);
 728  
 
 729  0
                 FlowController controlador = new FlowController();
 730  0
                 controlador.inserirDados(primeiro1.getStep(), primeiro1
 731  0
                         .getFlow(), data.getData());
 732  
 
 733  
             }
 734  
 
 735  
         }
 736  
 
 737  0
     }
 738  
 
 739  
     @Override
 740  
     public void atualizarStepEspecifico(Object[] celulas2) {
 741  0
         StepCell primeiro = null;
 742  0
         for (int i = 0; i <= celulas2.length - 1; i++) {
 743  
 
 744  0
             Object celula = celulas2[i];
 745  
 
 746  0
             if (celula instanceof StepCell) {
 747  
 
 748  0
                 primeiro = (StepCell) celula;
 749  
 
 750  0
                 FlowController controlador = new FlowController();
 751  
 
 752  0
                 String descricao = primeiro.toString();
 753  
 
 754  0
                 controlador.renomear(primeiro.getStep(), primeiro.getFlow(),
 755  0
                         descricao, primeiro.getUseCase());
 756  
 
 757  
             }
 758  
         }
 759  
 
 760  0
     }
 761  
 
 762  
     @Override
 763  
     public void criarLinkEspecifico(Object[] celulas,
 764  
             List<DefaultGraphCell> adicao) {
 765  0
         StepCell primeiro = null;
 766  0
         for (int i = 0; i <= celulas.length - 1; i++) {
 767  
 
 768  0
             Object celula = celulas[i];
 769  
 
 770  0
             if (celula instanceof StepCell) {
 771  
 
 772  0
                 if (primeiro != null) {
 773  0
                     StepCell segundo = (StepCell) celula;
 774  
 
 775  0
                     DefaultEdge seta = Util.criaLink(primeiro, segundo,
 776  0
                             new Link());
 777  0
                     adicao.add(seta);
 778  
 
 779  0
                     FlowController controlador = new FlowController();
 780  0
                     controlador.inserirLink(primeiro.getStep(), segundo
 781  0
                             .getFlow(), segundo.getStepNumber(), primeiro
 782  0
                             .getUseCase());
 783  0
                     primeiro = (StepCell) celula;
 784  
 
 785  
                 } else {
 786  
 
 787  0
                     primeiro = (StepCell) celula;
 788  
 
 789  
                 }
 790  
 
 791  
             }
 792  
 
 793  
         }
 794  
 
 795  0
     }
 796  
 
 797  
     @Override
 798  
     public void definirProbabilidadeEspecifico(Object[] celulas,
 799  
             CasoUso useCase, List<DefaultGraphCell> adicao) {
 800  0
         for (int i = 0; i <= celulas.length - 1; i++) {
 801  
 
 802  0
             Object celula = celulas[i];
 803  
 
 804  0
             if (celula instanceof LinkEdge) {
 805  
 
 806  0
                 LinkEdge edge = (LinkEdge) celula;
 807  0
                 LinkPort porta = (LinkPort) edge.getSource();
 808  0
                 Step step = porta.getStep();
 809  0
                 double probabilidade = Double.parseDouble(edge.toString());
 810  0
                 Link link = edge.getLink();
 811  0
                 link.setProbabilidade(probabilidade);
 812  0
                 FlowController controlador = new FlowController();
 813  0
                 controlador.atualizaLink(link, step, link.getFlow(), useCase);
 814  
 
 815  
             }
 816  
 
 817  
         }
 818  
 
 819  0
     }
 820  
 
 821  
     @Override
 822  
     public void aplicarFiltroValidoEspecifico(Object[] celulas,
 823  
             CasoUso useCase, List<DefaultGraphCell> adicao, JGraph graph)
 824  
             throws SQLException, InstantiationException,
 825  
             IllegalAccessException, ClassNotFoundException, IOException {
 826  0
         for (int i = 0; i <= celulas.length - 1; i++) {
 827  
 
 828  0
             Object celula = celulas[i];
 829  
 
 830  0
             if (celula instanceof StepCell) {
 831  0
                 StepCell stepCell = (StepCell) celula;
 832  0
                 Step step = stepCell.getStep();
 833  
 
 834  0
                 Filtro filtro = new Filtro();
 835  
 
 836  0
                 filtro.setTipoCondicional(0);
 837  0
                 filtro.setStep(step);
 838  
 
 839  0
                 DAOFiltro daoFiltro = new DAOFiltro();
 840  0
                 filtro = daoFiltro.insere(step, filtro);
 841  
 
 842  0
                 step.getFiltros().add(filtro);
 843  
 
 844  0
                 Point2D point = graph.getCenterPoint();
 845  
 
 846  0
                 CondicionalCell condicao = Util.criaCondicao(filtro,
 847  0
                         (int) point.getX(), (int) point.getY(), step, stepCell
 848  0
                                 .getFlow(), useCase);
 849  0
                 adicao.add(condicao);
 850  
 
 851  0
                 FiltroEdge seta = Util.criaLinkCondicao(condicao, stepCell);
 852  0
                 adicao.add(seta);
 853  
 
 854  
             }
 855  
 
 856  
         }
 857  
 
 858  0
     }
 859  
 
 860  
     @Override
 861  
     public void retiraFiltrosEspecifico(Object[] celulas,
 862  
             List<DefaultGraphCell> adicao) throws SQLException,
 863  
             InstantiationException, IllegalAccessException,
 864  
             ClassNotFoundException, IOException {
 865  
 
 866  0
         for (int i = 0; i <= celulas.length - 1; i++) {
 867  
 
 868  0
             Object celula = celulas[i];
 869  
 
 870  0
             if (celula instanceof CondicionalCell) {
 871  0
                 CondicionalCell condicionalCell = (CondicionalCell) celula;
 872  0
                 Step step = condicionalCell.getStep();
 873  
 
 874  0
                 Filtro filtro = condicionalCell.getFiltro();
 875  
 
 876  0
                 DAOFiltro daoFiltro = new DAOFiltro();
 877  0
                 daoFiltro.delete(step, filtro);
 878  
 
 879  0
                 step.getFiltros().remove(filtro);
 880  
 
 881  0
                 adicao.add(condicionalCell);
 882  0
                 adicao.add(condicionalCell.getFiltroEdge());
 883  
             }
 884  
 
 885  
         }
 886  0
     }
 887  
 
 888  
     @Override
 889  
     public void inserirValorEspecifico(List<JTextField> fields,
 890  
             List<DefaultGraphCell> adicao) {
 891  
 
 892  0
         TestDataValor valor = new TestDataValor();
 893  0
         String valorString = fields.get(2).getText();
 894  0
         valor.setValor(valorString);
 895  
 
 896  0
         ValorCell valorCell = Util.criaValor(valor, 100, 100);
 897  0
         adicao.add(valorCell);
 898  
 
 899  0
     }
 900  
 }