Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: com/k_int/OpenRequest/helpers/ISOForwardNotificationMessageFactory.java


1   /**
2    * Title:       ISOShippedMessageFactory
3    * @version:    $Id: ISOForwardNotificationMessageFactory.java,v 1.1.1.1 2002/10/20 10:24:01 ianibbo Exp $
4    * Copyright:   Copyright (C) 2002 Knowledge Integration Ltd (See the COPYING file for details.)
5    * @author:     Ian Ibbotson ( ian.ibbotson@k-int.com )
6    * Company:     Knowledge Integration Ltd.
7    * Description: Create an ISO ILL Request PDU in different situations
8    */
9   
10  //
11  // This program is free software; you can redistribute it and/or
12  // modify it under the terms of the GNU General Public License
13  // as published by the Free Software Foundation; either version 2.1 of
14  // the license, or (at your option) any later version.
15  //
16  // This program is distributed in the hope that it will be useful,
17  // but WITHOUT ANY WARRANTY; without even the implied warranty of
18  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  // GNU Lesser General Public License for more details.
20  //
21  // You should have received a copy of the GNU Lesser General Public License
22  // along with this program; if not, write to the Free Software
23  // Foundation, Inc., 59 Temple Place - Suite
24  // 330, Boston, MA  02111-1307, USA.
25  //
26  
27  package com.k_int.OpenRequest.helpers;
28  
29  import com.k_int.util.LoggingFacade.*;
30  import javax.naming.*;
31  import cirrus.hibernate.*;
32  import java.util.Properties;
33  import java.util.Vector;
34  import java.util.Date;
35  
36  import com.k_int.codec.util.*;
37  import com.k_int.OpenRequest.isoill.gen.ISO_10161_ILL_1.*;
38  import com.k_int.OpenRequest.api.*;
39  import com.k_int.OpenRequest.db.*;
40  import com.k_int.OpenRequest.db.Location.*;
41  
42  import java.math.BigInteger;
43  
44  import org.w3c.dom.*;
45  import javax.xml.parsers.DocumentBuilder;
46  import javax.xml.parsers.DocumentBuilderFactory;
47  import javax.xml.parsers.ParserConfigurationException;
48  
49  /**
50   *  Create an ISO ILL Shipped Message.
51   *  This class will construct an iso ill shipped message in a variety of different
52   *  situations according to the supplied parameters.
53   *  @author Ian Ibbotson
54   *  @version $Id: ISOForwardNotificationMessageFactory.java,v 1.1.1.1 2002/10/20 10:24:01 ianibbo Exp $
55   */
56  public class ISOForwardNotificationMessageFactory
57  {
58    private static LoggingContext cat = LogContextFactory.getContext("com.k_int.OpenRequest.ISOShippedMsgFactory");
59  
60    /**
61     *  create a Shipped message.
62     *
63     *  Requires: An ILL Transaction in a state for which FWDreq is a valid action
64     *
65     *  Provides: A completed ILL Forward Notificatoin message with data derived as follows:
66     *            N.B where a member could be set from the transaction store, speak with k-int
67     *            about defaulting that member in, it's better than starting to track transaction data
68     *            in databases outside the transaction store.
69     *
70     *  element name/type                        M/O  Source
71     *  retval : ILL_APDU_type (Choice of pdu)  M       Filled in by factory
72     *    .which : int        M       Filled in by factory
73     *    .o : Shipped_type      M       Filled in by factory
74     *      .protocol_version_num
75     *      .transaction_id      M  Constructed field, populated by this method
76     *        .initial_requester_id    M  
77     *          .person_or_institution_symbol  O  Set by factory from database
78     *          .name_of_person_or_institution    O  Not set
79     *        .tgq        M  Set by factory from database
80     *        .tq          M  Set by factory from database
81     *        .stq        O  Set by factory from database
82     *      .service_date_time      M  Constructed by factory
83     *        .date_time_of_this_service          M       Constructed by factory
84     *          .date                             M       Set by factory from system clock
85     *          .time                             O       Set by factory from system clock
86     *        .date_time_of_original_service      M       Constructed by factory
87     *          .date                             M       Set by factory from system clock
88     *          .time                             O       Set by factory from system clock
89     *      .requester_id        M  Set by factory from database
90     *        .person_or_institution_symbol       O       Set by factory from database
91     *        .person_or_institution_name         O       Not set
92     *      .responder_id        M  Set from new_responder param of create method
93     *        .person_or_institution_symbol       O       Set from new_responder param of create method
94     *        .person_or_institution_name         O       Set from new_responder param of create method
95     *
96     *                   -- End of common elements. Shipped specific follow --
97     *
98     *      .responder_address      O       Set from new_responder param of create method
99     *        .telecom_service_identifier         O  Set from new_responder param of create method
100    *        .telecom_service_address            O  Set from new_responder param of create method
101    *      .intermediary_id      O       Set to sending location (original resp id)
102    *        .person_or_institution_symbol       O       As above
103    *        .person_or_institution_name         O       As above
104    *      .notification_note      O       Not set
105    *      .forward_notification_extensions      O       Not set
106    *  Ends description of how forward notification PDU is populated by this factory method
107    *
108    *  @author Ian Ibbotson
109    *  @param database_session The database session we will use to access the database
110    *  @param request_id request id (internal number) of the transaction we are dealing with
111    *  @param extens An array of extension factories that will set up a shipped extension
112    *                for each factory in the array.
113    * 
114    *  @return An ILL_APDU containing a Shipped message
115    */
116   public static ILL_APDU_type create(Session database_session, 
117                                      ILLTransaction transaction,
118                                      LocationSymbol new_responder,
119                                      String notification_note,
120                                      ISOExtensionFactory[] extens) throws java.sql.SQLException,
121                                                              cirrus.hibernate.HibernateException
122   {
123     Forward_Notification_type fwd_notification = new Forward_Notification_type();
124     ILL_APDU_type retval = new ILL_APDU_type( ILL_APDU_type.forward_notification_var_CID, fwd_notification);
125 
126     // Fill out protocol version num,  transaction id
127     ISOHeaderDetailsHelper.fillOutHeader(database_session, transaction, fwd_notification);
128 
129     String new_responder_symbol = new_responder.toString();
130 
131     fwd_notification.intermediary_id = fwd_notification.responder_id;
132     fwd_notification.responder_id =
133             new System_Id_type(                                                //   o responder id
134                 new Person_Or_Institution_Symbol_type(                         //   o     Person or inst sym
135                   Person_Or_Institution_Symbol_type.institution_symbol_CID,
136                   ILLStringHelper.generalString(new_responder_symbol)),
137                 null);
138 
139     Service new_delivery_service = (Service) new_responder.getCanonical_location().getServices().get(0);
140     String teleco_service_type = (String) new_delivery_service.getProperties().get("TelecoServiceType");
141     String teleco_service_address = (String) new_delivery_service.getProperties().get("TelecoServiceAddress");
142 
143     fwd_notification.responder_address = new System_Address_type(
144       ILLStringHelper.generalString(teleco_service_type),
145       ILLStringHelper.generalString(teleco_service_address));
146 
147     if ( notification_note != null )
148       fwd_notification.notification_note = ILLStringHelper.generalString(notification_note);
149 
150     if ( ( extens != null ) && ( extens.length > 0 ) )
151     {
152       Vector extensions = new Vector();
153       for ( int i=0; i<extens.length; i++ )
154       {
155         // Process exten i and add to vector
156       }
157 
158       fwd_notification.forward_notification_extensions = extensions;
159     }
160 
161     return retval;
162   }
163 }