1   package ch.ige.edossier.web.server.dao.test;
2   
3   import java.util.List;
4   import ch.ige.edossier.web.server.dao.*;
5   import ch.ige.edossier.web.vo.*;
6   
7   /**
8    * B32.03 - eDossier-Interceptions - Diplomarbeit an der Software-Schule Schweiz<br>
9    * Data Access Objekt Testklasse
10   * <p>
11   * Copyright (c) 2004, Eidgenössisches Institut für Geistiges Eigentum
12   * @author    Anita Rueegsegger, Marc Bouquet
13   * @version   $Id: TestClass.java,v 1.5 2004/11/02 02:01:47 bouquet Exp $
14   */
15  public class TestClass
16  {
17    public TestClass()
18    {
19      int accountId = testAccountData();
20      int dossierId = testDossierData( accountId );
21      int interceptionId = testInterceptionData( dossierId );
22      testAnswerData( interceptionId );
23    }
24  
25    public static void main( String[] args )
26    {
27      new TestClass();
28    }
29  
30    public int testAccountData()
31    {
32      AccountDAO accountDAO = new AccountDAO();
33      AccountVO accountVO = null;
34      int accountId = 0;
35  
36      try
37      {
38        System.out.println( "Select All" );
39        List list = accountDAO.selectAll();
40        for( int i = 0; i < list.size(); i++ )
41        {
42          accountVO = ( AccountVO )list.get( i );
43          System.out.println( accountVO.toString() );
44        }
45  
46        System.out.println( "Select" );
47        accountId = ( ( AccountVO )list.get( 0 ) ).getAccountId();
48        accountVO = accountDAO.select( accountId );
49        System.out.println( accountVO.toString() );
50      }
51      catch( Exception ex )
52      {
53        System.out.println( ex );
54      }
55  
56      return accountId;
57    }
58  
59    public int testDossierData( int accountId )
60    {
61      DossierDAO dossierDAO = new DossierDAO();
62      DossierVO dossierVO = null;
63      int dossierId = 0;
64  
65      try
66      {
67        System.out.println( "Dossier Select By Account" );
68        List list = dossierDAO.selectByAccount( accountId );
69        for( int i = 0; i < list.size(); i++ )
70        {
71          dossierVO = ( DossierVO )list.get( i );
72          System.out.println( dossierVO.toString() );
73        }
74  
75        System.out.println( "Dossier Select" );
76        if( list.size() > 0 )
77        {
78          dossierId = ( ( DossierVO )list.get( 0 ) ).getDossierId();
79          dossierVO = dossierDAO.select( dossierId );
80          System.out.println( dossierVO.toString() );
81        }
82      }
83      catch( Exception ex )
84      {
85        System.out.println( ex );
86      }
87  
88      return dossierId;
89    }
90  
91    public int testInterceptionData( int dossierId )
92    {
93      InterceptionDAO interceptionDAO = new InterceptionDAO();
94      InterceptionVO interceptionVO = null;
95      int interceptionId = 0;
96  
97      try
98      {
99        System.out.println( "INTERCEPTION SELECT BY DOSSIER" );
100       List list = interceptionDAO.selectByDossier( dossierId );
101       for( int i = 0; i < list.size(); i++ )
102       {
103         interceptionVO = ( InterceptionVO )list.get( i );
104         System.out.println( interceptionVO.toString() );
105       }
106 
107       System.out.println( "INTERCEPTION SELECT" );
108       if( list.size() > 0 )
109       {
110         interceptionId = ( ( InterceptionVO )list.get( 0 ) ).getInterceptionId();
111         interceptionVO = interceptionDAO.select( interceptionId );
112         System.out.println( interceptionVO.toString() );
113       }
114     }
115     catch( Exception ex )
116     {
117       System.out.println( ex );
118     }
119 
120     return interceptionId;
121   }
122 
123   public int testAnswerData( int interceptionId )
124   {
125     AnswerDAO answerDAO = new AnswerDAO();
126     AnswerVO answerVO = null;
127 
128     try
129     {
130       System.out.println( "ANSWER SELECT BY INTERCEPTION" );
131       answerVO = answerDAO.selectByInterception( interceptionId );
132       if( answerVO != null )
133       {
134         System.out.println( answerVO.toString() );
135       }
136 
137       System.out.println( "ANSWER DELETE" );
138       answerDAO.delete( answerVO.getAnswerId() );
139 
140       System.out.println( "ANSWER INSERT" );
141       answerDAO.insert( answerVO );
142 
143     }
144     catch( Exception ex )
145     {
146       System.out.println( ex );
147     }
148 
149     return answerVO.getAnswerId();
150   }
151 
152 }
153