The configure method takes test_only flag so we can avoid
[metaproxy-moved-to-github.git] / src / filter_record_transform.cpp
index 5de0f35..d268b7d 100644 (file)
@@ -1,7 +1,22 @@
-/* $Id: filter_record_transform.cpp,v 1.11 2007-05-09 07:14:28 adam Exp $
+/* $Id: filter_record_transform.cpp,v 1.14 2008-02-20 15:07:52 adam Exp $
    Copyright (c) 2005-2007, Index Data.
 
-   See the LICENSE file for details
+This file is part of Metaproxy.
+
+Metaproxy is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 2, or (at your option) any later
+version.
+
+Metaproxy is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with Metaproxy; see the file LICENSE.  If not, write to the
+Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
+02111-1307, USA.
  */
 
 #include "config.hpp"
@@ -48,7 +63,7 @@ yf::RecordTransform::~RecordTransform()
 {  // must have a destructor because of boost::scoped_ptr
 }
 
-void yf::RecordTransform::configure(const xmlNode *xmlnode)
+void yf::RecordTransform::configure(const xmlNode *xmlnode, bool test_only)
 {
     m_p->configure(xmlnode);
 }
@@ -267,35 +282,44 @@ void yf::RecordTransform::Impl::process(mp::Package &package) const
                  = pr_res->records->u.databaseOrSurDiagnostics->records[i];
              if (npr->which == Z_NamePlusRecord_databaseRecord)
              {
+                 WRBUF output_record = wrbuf_alloc();
                  Z_External *r = npr->u.databaseRecord;
-                 //oident *ent = oid_getentbyoid(r->direct_reference);
-                 if (r->which == Z_External_octet) 
+                 int ret_trans = 0;
+                 if (r->which == Z_External_OPAC)
+                 {
+#if YAZ_VERSIONL >= 0x030011
+                     ret_trans = 
+                         yaz_record_conv_opac_record(rc, r->u.opac,
+                                                     output_record);
+#else
+                     ;
+#endif
+                 }
+                 else if (r->which == Z_External_octet) 
                  {
-                     WRBUF output_record = wrbuf_alloc();
-                     int ret_trans 
-                         =  yaz_record_conv_record(rc,
-                                                   (const char *)
-                                                   r->u.octet_aligned->buf, 
-                                                   r->u.octet_aligned->len,
-                                                   output_record);
-                     if (ret_trans == 0)
-                     {
-                         npr->u.databaseRecord =
-                             z_ext_record_oid(odr_en, match_syntax,
+                     ret_trans =
+                         yaz_record_conv_record(rc, (const char *)
+                                                r->u.octet_aligned->buf, 
+                                                r->u.octet_aligned->len,
+                                                output_record);
+                 }
+                 if (ret_trans == 0)
+                 {
+                     npr->u.databaseRecord =
+                         z_ext_record_oid(odr_en, match_syntax,
                                           wrbuf_buf(output_record),
                                           wrbuf_len(output_record));
-                     }
-                     else
-                     {
-                         pr_res->records->
-                             u.databaseOrSurDiagnostics->records[i] 
-                             =  zget_surrogateDiagRec(
-                                 odr_en, npr->databaseName,
-                                 YAZ_BIB1_SYSTEM_ERROR_IN_PRESENTING_RECORDS,
-                                 yaz_record_conv_get_error(rc));
-                     }
-                     wrbuf_destroy(output_record);
                  }
+                 else
+                 {
+                     pr_res->records->
+                         u.databaseOrSurDiagnostics->records[i] 
+                         =  zget_surrogateDiagRec(
+                             odr_en, npr->databaseName,
+                             YAZ_BIB1_SYSTEM_ERROR_IN_PRESENTING_RECORDS,
+                             yaz_record_conv_get_error(rc));
+                 }
+                 wrbuf_destroy(output_record);
              }
          }
     }