#ifndef __JDB_JPERSONS__
#define __JDB_JPERSONS__

#include <TROOT.h>
#include <TObject.h>

#include <string>

#include "JDB/JDBString.hh"
#include "JDB/JSonSupportkit.hh"

/**
 * \author mdejong
 */
namespace JDATABASE {}
namespace JPP { using namespace JDATABASE; }

namespace JDATABASE {

  struct JPersons :
    public TObject
  {
    static const char* const getName() { return "persons"; } //!< Table name

    std::string   OID;
    std::string   LOGIN;
    JDBString     NAME;
    JDBString     SURNAME;
    std::string   LOCATIONID;
    JDBString     CITY;
    JDBString     ADDRESS;
    std::string   ACTIVESTATUS;
    std::string   MEMBERSTATUS;
    std::string   AUTHORSTATUS;

    ClassDef(JPersons, 1);
  };

  namespace APIV2 {

    struct JPerson :
      public JSonHelper<JPerson>,
      public TObject
    {
      static const char* const getName() { return "Person"; } //!< Table name

      JPerson() {}

      /**
       * Copy constructor.
       *
       * \param  person         person
       */
      JPerson(const JPersons& person) :
	OID        (person.OID),
	Login      (person.LOGIN),
	Name       (person.NAME),
	Surname    (person.SURNAME),
	Location   (person.LOCATIONID)
      {}

      /**
       * Type conversion operator.
       *
       * \return                person
       */
      operator JPersons() const
      {
	JPersons person;

	person.OID        = this->OID;
	person.LOGIN      = this->Login;
	person.NAME       = this->Name;
	person.SURNAME    = this->Surname;
	person.LOCATIONID = this->Location;

	return person;
      }
      
      std::string   OID;
      std::string   Login;
      std::string   Name;
      std::string   Surname;
      std::string   Location;
      std::string   Title;
      std::string   GroupCode;
      std::string   Occupation;
      std::string   CreationDate;

      ClassDef(JPerson, 1);
    };
  }
}

#endif