/**********************************************************
 * This file has been automatically created by "typemaker2"
 * from the file "imexporter_context.xml".
 * Please do not edit this file, all changes will be lost.
 * Better edit the mentioned source file instead.
 **********************************************************/

#ifdef HAVE_CONFIG_H
# include <config.h>
#endif

#include "./imexporter_context_p.h"

#include <gwenhywfar/misc.h>
#include <gwenhywfar/debug.h>

/* code headers */

/* macro functions */
GWEN_LIST_FUNCTIONS(AB_IMEXPORTER_CONTEXT, AB_ImExporterContext)
GWEN_LIST2_FUNCTIONS(AB_IMEXPORTER_CONTEXT, AB_ImExporterContext)


AB_IMEXPORTER_CONTEXT *AB_ImExporterContext_new(void) {
  AB_IMEXPORTER_CONTEXT *p_struct;

  GWEN_NEW_OBJECT(AB_IMEXPORTER_CONTEXT, p_struct)
  p_struct->_refCount=1;
  GWEN_LIST_INIT(AB_IMEXPORTER_CONTEXT, p_struct)
  /* members */
  p_struct->accountInfoList=AB_ImExporterAccountInfo_List_new();
  p_struct->securityList=AB_Security_List_new();
  p_struct->messageList=AB_Message_List_new();
  /* virtual functions */

  return p_struct;
}

void AB_ImExporterContext_free(AB_IMEXPORTER_CONTEXT *p_struct) {
  if (p_struct) {
  assert(p_struct->_refCount);
  if (p_struct->_refCount==1) {
    GWEN_LIST_FINI(AB_IMEXPORTER_CONTEXT, p_struct)
  /* members */
    AB_ImExporterAccountInfo_List_free(p_struct->accountInfoList); p_struct->accountInfoList=NULL;
    AB_Security_List_free(p_struct->securityList); p_struct->securityList=NULL;
    AB_Message_List_free(p_struct->messageList); p_struct->messageList=NULL;
    p_struct->_refCount=0;
    GWEN_FREE_OBJECT(p_struct);
  }
  else
    p_struct->_refCount--;
  }
}

void AB_ImExporterContext_Attach(AB_IMEXPORTER_CONTEXT *p_struct) {
  assert(p_struct);
  assert(p_struct->_refCount);
  p_struct->_refCount++;
}

AB_IMEXPORTER_CONTEXT *AB_ImExporterContext_dup(const AB_IMEXPORTER_CONTEXT *p_src) {
  AB_IMEXPORTER_CONTEXT *p_struct;

  assert(p_src);
  p_struct=AB_ImExporterContext_new();
  /* member "accountInfoList" */
  if (p_struct->accountInfoList) {
    AB_ImExporterAccountInfo_List_free(p_struct->accountInfoList); p_struct->accountInfoList=NULL;
    p_struct->accountInfoList=NULL;
  }
  if (p_src->accountInfoList) {
    p_struct->accountInfoList=AB_ImExporterAccountInfo_List_dup(p_src->accountInfoList);
  }


  /* member "securityList" */
  if (p_struct->securityList) {
    AB_Security_List_free(p_struct->securityList); p_struct->securityList=NULL;
    p_struct->securityList=NULL;
  }
  if (p_src->securityList) {
    p_struct->securityList=AB_Security_List_dup(p_src->securityList);
  }


  /* member "messageList" */
  if (p_struct->messageList) {
    AB_Message_List_free(p_struct->messageList); p_struct->messageList=NULL;
    p_struct->messageList=NULL;
  }
  if (p_src->messageList) {
    p_struct->messageList=AB_Message_List_dup(p_src->messageList);
  }


  return p_struct;
}

AB_IMEXPORTER_CONTEXT *AB_ImExporterContext_copy(AB_IMEXPORTER_CONTEXT *p_struct, const AB_IMEXPORTER_CONTEXT *p_src) {
  assert(p_struct);
  assert(p_src);
  /* member "accountInfoList" */
  if (p_struct->accountInfoList) {
    AB_ImExporterAccountInfo_List_free(p_struct->accountInfoList); p_struct->accountInfoList=NULL;
    p_struct->accountInfoList=NULL;
  }
  if (p_src->accountInfoList) {
    p_struct->accountInfoList=AB_ImExporterAccountInfo_List_dup(p_src->accountInfoList);
  }


  /* member "securityList" */
  if (p_struct->securityList) {
    AB_Security_List_free(p_struct->securityList); p_struct->securityList=NULL;
    p_struct->securityList=NULL;
  }
  if (p_src->securityList) {
    p_struct->securityList=AB_Security_List_dup(p_src->securityList);
  }


  /* member "messageList" */
  if (p_struct->messageList) {
    AB_Message_List_free(p_struct->messageList); p_struct->messageList=NULL;
    p_struct->messageList=NULL;
  }
  if (p_src->messageList) {
    p_struct->messageList=AB_Message_List_dup(p_src->messageList);
  }


  return p_struct;
}

AB_IMEXPORTER_ACCOUNTINFO_LIST *AB_ImExporterContext_GetAccountInfoList(const AB_IMEXPORTER_CONTEXT *p_struct){
  assert(p_struct);
  return p_struct->accountInfoList;
}

AB_SECURITY_LIST *AB_ImExporterContext_GetSecurityList(const AB_IMEXPORTER_CONTEXT *p_struct){
  assert(p_struct);
  return p_struct->securityList;
}

AB_MESSAGE_LIST *AB_ImExporterContext_GetMessageList(const AB_IMEXPORTER_CONTEXT *p_struct){
  assert(p_struct);
  return p_struct->messageList;
}

void AB_ImExporterContext_SetAccountInfoList(AB_IMEXPORTER_CONTEXT *p_struct, AB_IMEXPORTER_ACCOUNTINFO_LIST *p_src){
  assert(p_struct);
  if (p_struct->accountInfoList) {
    AB_ImExporterAccountInfo_List_free(p_struct->accountInfoList); p_struct->accountInfoList=NULL;
    p_struct->accountInfoList=NULL;
  }
  p_struct->accountInfoList=p_src;
}

void AB_ImExporterContext_SetSecurityList(AB_IMEXPORTER_CONTEXT *p_struct, AB_SECURITY_LIST *p_src){
  assert(p_struct);
  if (p_struct->securityList) {
    AB_Security_List_free(p_struct->securityList); p_struct->securityList=NULL;
    p_struct->securityList=NULL;
  }
  p_struct->securityList=p_src;
}

void AB_ImExporterContext_SetMessageList(AB_IMEXPORTER_CONTEXT *p_struct, AB_MESSAGE_LIST *p_src){
  assert(p_struct);
  if (p_struct->messageList) {
    AB_Message_List_free(p_struct->messageList); p_struct->messageList=NULL;
    p_struct->messageList=NULL;
  }
  p_struct->messageList=p_src;
}

AB_IMEXPORTER_CONTEXT_LIST *AB_ImExporterContext_List_dup(const AB_IMEXPORTER_CONTEXT_LIST *p_src) {
  AB_IMEXPORTER_CONTEXT_LIST *p_dest;
  AB_IMEXPORTER_CONTEXT *p_elem;

  assert(p_src);
  p_dest=AB_ImExporterContext_List_new();
  p_elem=AB_ImExporterContext_List_First(p_src);
  while(p_elem) {
    AB_IMEXPORTER_CONTEXT *p_cpy;

    p_cpy=AB_ImExporterContext_dup(p_elem);
    AB_ImExporterContext_List_Add(p_cpy, p_dest);
    p_elem=AB_ImExporterContext_List_Next(p_elem);
  }

  return p_dest;
}

void AB_ImExporterContext_ReadDb(AB_IMEXPORTER_CONTEXT *p_struct, GWEN_DB_NODE *p_db){
  assert(p_struct);
  /* member "accountInfoList" */
  if (p_struct->accountInfoList) {
    AB_ImExporterAccountInfo_List_free(p_struct->accountInfoList); p_struct->accountInfoList=NULL;
    p_struct->accountInfoList=NULL;
  }
  { GWEN_DB_NODE *dbSource; dbSource=GWEN_DB_GetGroup(p_db, GWEN_PATH_FLAGS_NAMEMUSTEXIST, "accountInfoList"); if (dbSource) { AB_IMEXPORTER_ACCOUNTINFO_LIST *t; GWEN_DB_NODE *dbT; t=AB_ImExporterAccountInfo_List_new(); dbT=GWEN_DB_FindFirstGroup(dbSource, "accountInfo"); while(dbT) { AB_IMEXPORTER_ACCOUNTINFO *elem; elem=AB_ImExporterAccountInfo_fromDb(dbT); if (elem) AB_ImExporterAccountInfo_List_Add(elem, t); dbT=GWEN_DB_FindNextGroup(dbT, "accountInfo"); } p_struct->accountInfoList=t; } else p_struct->accountInfoList=AB_ImExporterAccountInfo_List_new(); }
  /* member "securityList" */
  if (p_struct->securityList) {
    AB_Security_List_free(p_struct->securityList); p_struct->securityList=NULL;
    p_struct->securityList=NULL;
  }
  { GWEN_DB_NODE *dbSource; dbSource=GWEN_DB_GetGroup(p_db, GWEN_PATH_FLAGS_NAMEMUSTEXIST, "securityList"); if (dbSource) { AB_SECURITY_LIST *t; GWEN_DB_NODE *dbT; t=AB_Security_List_new(); dbT=GWEN_DB_FindFirstGroup(dbSource, "security"); while(dbT) { AB_SECURITY *elem; elem=AB_Security_fromDb(dbT); if (elem) AB_Security_List_Add(elem, t); dbT=GWEN_DB_FindNextGroup(dbT, "security"); } p_struct->securityList=t; } else p_struct->securityList=AB_Security_List_new(); }
  /* member "messageList" */
  if (p_struct->messageList) {
    AB_Message_List_free(p_struct->messageList); p_struct->messageList=NULL;
    p_struct->messageList=NULL;
  }
  { GWEN_DB_NODE *dbSource; dbSource=GWEN_DB_GetGroup(p_db, GWEN_PATH_FLAGS_NAMEMUSTEXIST, "messageList"); if (dbSource) { AB_MESSAGE_LIST *t; GWEN_DB_NODE *dbT; t=AB_Message_List_new(); dbT=GWEN_DB_FindFirstGroup(dbSource, "message"); while(dbT) { AB_MESSAGE *elem; elem=AB_Message_fromDb(dbT); if (elem) AB_Message_List_Add(elem, t); dbT=GWEN_DB_FindNextGroup(dbT, "message"); } p_struct->messageList=t; } else p_struct->messageList=AB_Message_List_new(); }
}

int AB_ImExporterContext_WriteDb(const AB_IMEXPORTER_CONTEXT *p_struct, GWEN_DB_NODE *p_db) {
  int p_rv;

  assert(p_struct);
  /* member "accountInfoList" */
  { if (p_struct->accountInfoList) { GWEN_DB_NODE *dbDest; AB_IMEXPORTER_ACCOUNTINFO *elem; dbDest=GWEN_DB_GetGroup(p_db, GWEN_DB_FLAGS_OVERWRITE_GROUPS, "accountInfoList"); assert(dbDest); p_rv=0; elem=AB_ImExporterAccountInfo_List_First(p_struct->accountInfoList); while(elem) { GWEN_DB_NODE *dbElem; dbElem=GWEN_DB_GetGroup(dbDest, GWEN_PATH_FLAGS_CREATE_GROUP, "accountInfo"); assert(dbElem); p_rv=AB_ImExporterAccountInfo_toDb(elem, dbElem); if (p_rv<0) { DBG_INFO(GWEN_LOGDOMAIN, "here (%d)", p_rv); break; } elem=AB_ImExporterAccountInfo_List_Next(elem); } } else p_rv=0; }
  if (p_rv<0) {
    DBG_INFO(GWEN_LOGDOMAIN, "here (%d)\n", p_rv);
    return p_rv;
  }


  /* member "securityList" */
  { if (p_struct->securityList) { GWEN_DB_NODE *dbDest; AB_SECURITY *elem; dbDest=GWEN_DB_GetGroup(p_db, GWEN_DB_FLAGS_OVERWRITE_GROUPS, "securityList"); assert(dbDest); p_rv=0; elem=AB_Security_List_First(p_struct->securityList); while(elem) { GWEN_DB_NODE *dbElem; dbElem=GWEN_DB_GetGroup(dbDest, GWEN_PATH_FLAGS_CREATE_GROUP, "security"); assert(dbElem); p_rv=AB_Security_toDb(elem, dbElem); if (p_rv<0) { DBG_INFO(GWEN_LOGDOMAIN, "here (%d)", p_rv); break; } elem=AB_Security_List_Next(elem); } } else p_rv=0; }
  if (p_rv<0) {
    DBG_INFO(GWEN_LOGDOMAIN, "here (%d)\n", p_rv);
    return p_rv;
  }


  /* member "messageList" */
  { if (p_struct->messageList) { GWEN_DB_NODE *dbDest; AB_MESSAGE *elem; dbDest=GWEN_DB_GetGroup(p_db, GWEN_DB_FLAGS_OVERWRITE_GROUPS, "messageList"); assert(dbDest); p_rv=0; elem=AB_Message_List_First(p_struct->messageList); while(elem) { GWEN_DB_NODE *dbElem; dbElem=GWEN_DB_GetGroup(dbDest, GWEN_PATH_FLAGS_CREATE_GROUP, "message"); assert(dbElem); p_rv=AB_Message_toDb(elem, dbElem); if (p_rv<0) { DBG_INFO(GWEN_LOGDOMAIN, "here (%d)", p_rv); break; } elem=AB_Message_List_Next(elem); } } else p_rv=0; }
  if (p_rv<0) {
    DBG_INFO(GWEN_LOGDOMAIN, "here (%d)\n", p_rv);
    return p_rv;
  }


  return 0;
}

AB_IMEXPORTER_CONTEXT *AB_ImExporterContext_fromDb(GWEN_DB_NODE *p_db) {
  AB_IMEXPORTER_CONTEXT *p_struct;
  p_struct=AB_ImExporterContext_new();
  AB_ImExporterContext_ReadDb(p_struct, p_db);
  return p_struct;
}

int AB_ImExporterContext_toDb(const AB_IMEXPORTER_CONTEXT *p_struct, GWEN_DB_NODE *p_db) {
  return AB_ImExporterContext_WriteDb(p_struct, p_db);
}

void AB_ImExporterContext_ReadXml(AB_IMEXPORTER_CONTEXT *p_struct, GWEN_XMLNODE *p_db){
  assert(p_struct);
  /* member "accountInfoList" */
  if (p_struct->accountInfoList) {
    AB_ImExporterAccountInfo_List_free(p_struct->accountInfoList); p_struct->accountInfoList=NULL;
    p_struct->accountInfoList=NULL;
  }
  { GWEN_XMLNODE *dbSource; dbSource=GWEN_XMLNode_FindFirstTag(p_db, "accountInfoList", NULL, NULL); if (dbSource) { AB_IMEXPORTER_ACCOUNTINFO_LIST *t; GWEN_XMLNODE *dbT; t=AB_ImExporterAccountInfo_List_new(); dbT=GWEN_XMLNode_FindFirstTag(dbSource, "accountInfo", NULL, NULL); while(dbT) { AB_IMEXPORTER_ACCOUNTINFO *elem; elem=AB_ImExporterAccountInfo_fromXml(dbT); if (elem) AB_ImExporterAccountInfo_List_Add(elem, t); dbT=GWEN_XMLNode_FindNextTag(dbT, "accountInfo", NULL, NULL); } p_struct->accountInfoList=t; } else p_struct->accountInfoList=AB_ImExporterAccountInfo_List_new(); }
  /* member "securityList" */
  if (p_struct->securityList) {
    AB_Security_List_free(p_struct->securityList); p_struct->securityList=NULL;
    p_struct->securityList=NULL;
  }
  { GWEN_XMLNODE *dbSource; dbSource=GWEN_XMLNode_FindFirstTag(p_db, "securityList", NULL, NULL); if (dbSource) { AB_SECURITY_LIST *t; GWEN_XMLNODE *dbT; t=AB_Security_List_new(); dbT=GWEN_XMLNode_FindFirstTag(dbSource, "security", NULL, NULL); while(dbT) { AB_SECURITY *elem; elem=AB_Security_fromXml(dbT); if (elem) AB_Security_List_Add(elem, t); dbT=GWEN_XMLNode_FindNextTag(dbT, "security", NULL, NULL); } p_struct->securityList=t; } else p_struct->securityList=AB_Security_List_new(); }
  /* member "messageList" */
  if (p_struct->messageList) {
    AB_Message_List_free(p_struct->messageList); p_struct->messageList=NULL;
    p_struct->messageList=NULL;
  }
  { GWEN_XMLNODE *dbSource; dbSource=GWEN_XMLNode_FindFirstTag(p_db, "messageList", NULL, NULL); if (dbSource) { AB_MESSAGE_LIST *t; GWEN_XMLNODE *dbT; t=AB_Message_List_new(); dbT=GWEN_XMLNode_FindFirstTag(dbSource, "message", NULL, NULL); while(dbT) { AB_MESSAGE *elem; elem=AB_Message_fromXml(dbT); if (elem) AB_Message_List_Add(elem, t); dbT=GWEN_XMLNode_FindNextTag(dbT, "message", NULL, NULL); } p_struct->messageList=t; } else p_struct->messageList=AB_Message_List_new(); }
}

void AB_ImExporterContext_WriteXml(const AB_IMEXPORTER_CONTEXT *p_struct, GWEN_XMLNODE *p_db) {
  assert(p_struct);
  /* member "accountInfoList" */
  { if (p_struct->accountInfoList) { GWEN_XMLNODE *dbDest; AB_IMEXPORTER_ACCOUNTINFO *elem; dbDest=GWEN_XMLNode_new(GWEN_XMLNodeTypeTag, "accountInfoList"); elem=AB_ImExporterAccountInfo_List_First(p_struct->accountInfoList); while(elem) { GWEN_XMLNODE *dbElem; dbElem=GWEN_XMLNode_new(GWEN_XMLNodeTypeTag, "accountInfo"); assert(dbElem); AB_ImExporterAccountInfo_toXml(elem, dbElem); GWEN_XMLNode_AddChild(dbDest, dbElem); elem=AB_ImExporterAccountInfo_List_Next(elem); } GWEN_XMLNode_AddChild(p_db, dbDest); } }


  /* member "securityList" */
  { if (p_struct->securityList) { GWEN_XMLNODE *dbDest; AB_SECURITY *elem; dbDest=GWEN_XMLNode_new(GWEN_XMLNodeTypeTag, "securityList"); elem=AB_Security_List_First(p_struct->securityList); while(elem) { GWEN_XMLNODE *dbElem; dbElem=GWEN_XMLNode_new(GWEN_XMLNodeTypeTag, "security"); assert(dbElem); AB_Security_toXml(elem, dbElem); GWEN_XMLNode_AddChild(dbDest, dbElem); elem=AB_Security_List_Next(elem); } GWEN_XMLNode_AddChild(p_db, dbDest); } }


  /* member "messageList" */
  { if (p_struct->messageList) { GWEN_XMLNODE *dbDest; AB_MESSAGE *elem; dbDest=GWEN_XMLNode_new(GWEN_XMLNodeTypeTag, "messageList"); elem=AB_Message_List_First(p_struct->messageList); while(elem) { GWEN_XMLNODE *dbElem; dbElem=GWEN_XMLNode_new(GWEN_XMLNodeTypeTag, "message"); assert(dbElem); AB_Message_toXml(elem, dbElem); GWEN_XMLNode_AddChild(dbDest, dbElem); elem=AB_Message_List_Next(elem); } GWEN_XMLNode_AddChild(p_db, dbDest); } }


}

void AB_ImExporterContext_toXml(const AB_IMEXPORTER_CONTEXT *p_struct, GWEN_XMLNODE *p_db) {
  AB_ImExporterContext_WriteXml(p_struct, p_db);
}

AB_IMEXPORTER_CONTEXT *AB_ImExporterContext_fromXml(GWEN_XMLNODE *p_db) {
  AB_IMEXPORTER_CONTEXT *p_struct;
  p_struct=AB_ImExporterContext_new();
  AB_ImExporterContext_ReadXml(p_struct, p_db);
  return p_struct;
}

static AB_IMEXPORTER_CONTEXT *AB_ImExporterContext_List2__freeAll_cb(AB_IMEXPORTER_CONTEXT *t, void *user_data) { AB_ImExporterContext_free(t); return NULL; } int AB_ImExporterContext_List2_freeAll(AB_IMEXPORTER_CONTEXT_LIST2 *tl) { if (tl) { AB_ImExporterContext_List2_ForEach(tl, AB_ImExporterContext_List2__freeAll_cb, NULL); AB_ImExporterContext_List2_free(tl); } else { DBG_ERROR(AQBANKING_LOGDOMAIN, "List missing"); return GWEN_ERROR_INVALID; } return 0; }
void AB_ImExporterContext_Clear(AB_IMEXPORTER_CONTEXT *st) { assert(st); if (st->accountInfoList) AB_ImExporterAccountInfo_List_Clear(st->accountInfoList); if (st->securityList) AB_Security_List_Clear(st->securityList); if (st->messageList) AB_Message_List_Clear(st->messageList); }
void AB_ImExporterContext_AddContext(AB_IMEXPORTER_CONTEXT *st, AB_IMEXPORTER_CONTEXT *stSrc) { assert(st); if (stSrc->accountInfoList) { AB_IMEXPORTER_ACCOUNTINFO *iea; iea=AB_ImExporterAccountInfo_List_First(stSrc->accountInfoList); while(iea) { AB_IMEXPORTER_ACCOUNTINFO *ieaNext; ieaNext=AB_ImExporterAccountInfo_List_Next(iea); AB_ImExporterAccountInfo_List_Del(iea); AB_ImExporterAccountInfo_List_Add(iea, st->accountInfoList); iea=ieaNext; } } if (stSrc->securityList) { AB_SECURITY *sec; sec=AB_Security_List_First(stSrc->securityList); while(sec) { AB_SECURITY *secNext; secNext=AB_Security_List_Next(sec); AB_Security_List_Del(sec); AB_Security_List_Add(sec, st->securityList); sec=secNext; } } if (stSrc->messageList) { AB_MESSAGE *msg; msg=AB_Message_List_First(stSrc->messageList); while(msg) { AB_MESSAGE *msgNext; msgNext=AB_Message_List_Next(msg); AB_Message_List_Del(msg); AB_Message_List_Add(msg, st->messageList); msg=msgNext; } } AB_ImExporterContext_free(stSrc); }
AB_IMEXPORTER_ACCOUNTINFO *AB_ImExporterContext_GetFirstAccountInfo(const AB_IMEXPORTER_CONTEXT *st) { assert(st); if (st->accountInfoList) return AB_ImExporterAccountInfo_List_First(st->accountInfoList); return NULL; }
void AB_ImExporterContext_AddAccountInfo(AB_IMEXPORTER_CONTEXT *st, AB_IMEXPORTER_ACCOUNTINFO *ai) { assert(st); if (ai) { if (NULL==st->accountInfoList) st->accountInfoList=AB_ImExporterAccountInfo_List_new(); AB_ImExporterAccountInfo_List_Add(ai, st->accountInfoList); } }
int AB_ImExporterContext_GetAccountInfoCount(const AB_IMEXPORTER_CONTEXT *st) { assert(st); if (st->accountInfoList) return AB_ImExporterAccountInfo_List_GetCount(st->accountInfoList); return 0; }
AB_IMEXPORTER_ACCOUNTINFO *AB_ImExporterContext_GetOrAddAccountInfo(AB_IMEXPORTER_CONTEXT *st, uint32_t uniqueId, const char *iban, const char *bankCode, const char *accountNumber, int accountType) { assert(st); if (NULL==st->accountInfoList) st->accountInfoList=AB_ImExporterAccountInfo_List_new(); return AB_ImExporterAccountInfo_List_GetOrAdd(st->accountInfoList, uniqueId, iban, bankCode, accountNumber, accountType); }
AB_SECURITY *AB_ImExporterContext_GetFirstSecurity(const AB_IMEXPORTER_CONTEXT *st) { assert(st); if (st->securityList) return AB_Security_List_First(st->securityList); return NULL; }
AB_SECURITY *AB_ImExporterContext_FindSecurity(const AB_IMEXPORTER_CONTEXT *st, const char *nameSpace, const char *id) { assert(st); if (st->securityList) { AB_SECURITY *sec; assert(st); if (nameSpace==NULL) nameSpace=""; if (id==NULL) id=""; sec=AB_Security_List_First(st->securityList); while(sec) { const char *s1, *s2; s1=AB_Security_GetUniqueId(sec); if (s1==NULL) s1=""; s2=AB_Security_GetNameSpace(sec); if (s2==NULL) s2=""; if (strcasecmp(s2, nameSpace)==0 && strcasecmp(s1, id)==0) return sec; sec=AB_Security_List_Next(sec); } } return NULL; }
void AB_ImExporterContext_AddSecurity(AB_IMEXPORTER_CONTEXT *st, AB_SECURITY *sec) { assert(st); if (sec) { if (NULL==st->securityList) st->securityList=AB_Security_List_new(); AB_Security_List_Add(sec, st->securityList); } }
AB_MESSAGE *AB_ImExporterContext_GetFirstMessage(const AB_IMEXPORTER_CONTEXT *st) { assert(st); if (st->messageList) return AB_Message_List_First(st->messageList); return NULL; }
void AB_ImExporterContext_AddMessage(AB_IMEXPORTER_CONTEXT *st, AB_MESSAGE *msg) { assert(st); if (msg) { if (NULL==st->messageList) st->messageList=AB_Message_List_new(); AB_Message_List_Add(msg, st->messageList); } }
void AB_ImExporterContext_AddTransaction(AB_IMEXPORTER_CONTEXT *st, AB_TRANSACTION *t) { assert(st); if (t) { AB_IMEXPORTER_ACCOUNTINFO *ai=NULL; if (NULL==st->accountInfoList) { /* no account info list, nothing to search, just create the list */ st->accountInfoList=AB_ImExporterAccountInfo_List_new(); } else { /* first try to get by unique account id */ if (AB_Transaction_GetUniqueAccountId(t)) ai=AB_ImExporterAccountInfo_List_GetByAccountId(st->accountInfoList, AB_Transaction_GetUniqueAccountId(t)); /* next try by IBAN */ if (ai==NULL) { const char *s; s=AB_Transaction_GetLocalIban(t); if (s && *s) ai=AB_ImExporterAccountInfo_List_GetByIban(st->accountInfoList, s); } /* then try by account number and bank code */ if (ai==NULL) ai=AB_ImExporterAccountInfo_List_GetByBankCodeAndAccountNumber(st->accountInfoList, AB_Transaction_GetLocalBankCode(t), AB_Transaction_GetLocalAccountNumber(t), AB_AccountType_Unknown); } /* create account info if not found */ if (ai==NULL) { /* create account info */ ai=AB_ImExporterAccountInfo_new(); AB_ImExporterAccountInfo_FillFromTransaction(ai, t); AB_ImExporterAccountInfo_List_Add(ai, st->accountInfoList); } /* set transaction type if none set */ if (AB_Transaction_GetType(t)<=AB_Transaction_TypeNone) AB_Transaction_SetType(t, AB_Transaction_TypeStatement); /* finally add transaction */ AB_ImExporterAccountInfo_AddTransaction(ai, t); } }

/* code headers */

