// basic elements for text

module gsdlInterface {

typedef sequence<unsigned short> usString;

typedef sequence<string> stringSeq;

struct corbatext_t
{ 
  usString text;
  unsigned short encoding;
  unsigned long  length;
};

typedef sequence<corbatext_t> corbatext_tarray;

typedef corbatext_tarray corbatext_tset;

struct corbatext_tmap
{
  corbatext_tarray names;
  corbatext_tarray values;
};

// colserver/comtypes.h defines collectionmeta_map of collectionmeta 
// as (sorted) tuples of: metadata name -> lang -> value
// However, the C++ definition is: 
// typedef map<text_t, text_tmap, lttext_t> collectionmeta_map;
// Where lttext_t is defined to be a sorting function in text_t.h
// Each collectionmeta name maps to one or more (lang,value) pairs. 
// The struct below defines the entry for one collectionmeta name.
struct corbatext_tcollectionmeta {
  corbatext_t name;
  corbatext_tmap tuples;
  //corbatext_tarray languages;
  //corbatext_tarray values;
};

typedef sequence<corbatext_tcollectionmeta> corbatext_tcollectionmeta_map;


// standard error values

enum corbaComError
{ corbaNoError, 
  corbaAuthenticationFailure, 
  corbaProtocolError, 
  corbaConfigurationError, 
  corbaSystemProblem
};

//
// getColInfo response
//

struct corbaShortColInfo
{
  corbatext_t name;
  corbatext_t host;
  long        response;
};

struct corbaColInfoResponse
{
  corbaShortColInfo shortInfo;
  boolean           useBook;
  boolean           isPublic;
  boolean           isBeta;

  unsigned long     buildDate;
  corbatext_tarray  ccsCols;        // Added 05/04/2000
  corbatext_tarray  languages;
  unsigned long     numDocs;
  unsigned long     numWords;
  unsigned long     numBytes;
  corbatext_tcollectionmeta_map    collectionMeta; //corbatext_tmap    collectionMeta;
  corbatext_tmap    format;
  corbatext_tmap    building;
  corbatext_t       httpdomain ;    // Added 27/07/2000
  corbatext_t       httpprefix;     // Added 27/07/2000
  corbatext_t       receptionist;

  // The following member fields were added 14/03/2011 to 
  // match up with ColInfoResponse_t definition in comtypes.h

  boolean isSegmented;
  boolean isCollectGroup; // used to group a set of collections as one item on the home page
  unsigned long ccsOptions; // uses CCS #defines from above
  unsigned long stemIndexes; // uses SI #defines from above
  unsigned long numSections; // 0 if not known
  corbatext_tcollectionmeta_map	 collection_macros; // for collectionmacro config directive (> gsdl 2.53)
  corbatext_t         buildType;           // 'mg' or 'mgpp' or 'lucene'
  corbatext_t         infodbType;          // 'gdbm', 'sqlite', etc.
  corbatext_t         authenticate;        // 'document' or 'collection'
  corbatext_t         auth_group;          // 'mygroup' 'yourgroup'
  corbatext_tmap      public_documents;    // the acl to allow access to listed documents
  corbatext_tmap      private_documents;   // the acl to disallow access to listed documents
  corbatext_tmap      dynamic_classifiers;
  corbatext_t         earliestDatestamp;   // For OAIserver validation. Time since linux Epoch, expressed as (long) integer value in string form

};

//
// getDocument request
//

struct corbaDocRequest
{ 
  corbatext_t OID;
  corbatext_t docType;
  corbatext_t docFormat;
};

//
// getDocument response
//

struct corbaDocResponse
{ 
  corbatext_t doc;
};

enum corbaFilterType
{
  booleanType,
  integerType,
  enumeratedType,
  stringType
};

enum corbaFilterRepeatable
{
  onePerQuery,
  onePerTerm,
  nPerTerm
};

struct corbaFilterOption
{
  corbatext_t           name;
  corbaFilterType       type;
  corbaFilterRepeatable repeatable;
  corbatext_t           defaultValue;
  corbatext_tarray      validValues;
};

typedef sequence<corbaFilterOption> corbaFilterOptionList;

struct corbaFilterOptionsResponse
{
  corbaFilterOptionList options;
  corbatext_tarray      names;
};

//
// structures for filter call
//

struct corbaOptionValue
{
  corbatext_t name;
  corbatext_t value;
};

typedef sequence<corbaOptionValue> corbaOptionValue_array;

struct corbaFilterRequest
{ 
  corbatext_t            filter;
  corbaOptionValue_array filterOptions;
  corbatext_tarray       docSet;
  long                   filterResultOptions;
  corbatext_t            requestParams;
  corbatext_t            refParams;
  corbatext_tset         fields;
  boolean                getParents;
};

struct corbaTermInfo
{
  corbatext_t      term;
  long             frequency;
  corbatext_tarray matchTerms;
};

typedef sequence<corbaTermInfo> corbaTermInfo_array;

struct corbaMetadataInfo
{
  corbatext_t      params;
  boolean          isRef;
  corbatext_tarray values;
  long             id;
  long             parentid; // dodge for avoiding pointers for the moment
};

typedef sequence<corbaMetadataInfo> corbaMetadataInfo_array;

struct corbaMetadataInfo_map
{ 
  corbatext_tarray        names;
  corbaMetadataInfo_array values;
};

typedef sequence<long> corbaDocFreq_array;

struct corbaResultDocInfo
{
  corbatext_t             OID;
  long                    resultNum;
  long                    ranking;
  long                    termsMatched;
  long                    phraseMatched;
  corbaDocFreq_array      docFreq;
  corbaMetadataInfo_map   metadata;
  corbatext_t             classifierMetadataType;    // Added 05/04/2000
  long                    classifierMetadataOffset;  // Added 05/04/2000
  corbaMetadataInfo_array metaparents;
};

typedef sequence<corbaResultDocInfo> corbaResultDocInfo_array;

enum corbaIsApprox
{
  resultExact,
  resultApprox,
  resultMany
};

struct corbaFilterResponse
{
  long                     numDocs;
  corbaIsApprox            isApprox;
  corbaTermInfo_array      termInfo;
  corbaResultDocInfo_array docInfo;
};

interface corbaiface
{
  boolean   initialise(inout corbaComError error);
  void      configure(in corbatext_t key, in corbatext_tarray cfgline,
		      inout corbaComError error);
  void      collectionList(inout corbatext_tarray collist,
			   inout corbaComError error);
  void      hasCollection(in corbatext_t corbaCollection, inout boolean has,
		       inout corbaComError error);
  void      ping(in corbatext_t collection, inout boolean wasSuccess, inout corbaComError error);
  void      getDocument(in corbatext_t collection,
			inout corbaDocRequest request, inout corbaDocResponse response,
			inout corbaComError error);
  void      getCollectInfo(in corbatext_t collection,
			   inout corbaColInfoResponse response,
			   inout corbaComError error);
  void      getFilterInfo(in corbatext_t collection, 
                          inout corbatext_tarray filterNames, 
			  inout corbaComError error);
  void      getFilterOptions(in corbatext_t collection,
                             in corbatext_t option,
                             inout corbaFilterOptionsResponse response,
			     inout corbaComError error);
  void      filter(in corbatext_t collection,
		   in corbaFilterRequest request,
                   inout corbaFilterResponse response,
                   inout corbaComError error);

  void      getRssItems (in corbatext_t collection, 
			 in corbatext_t gsdlhome, 
			 inout corbatext_t rss_items, 
			 inout corbaComError error);

};

};
