/** @class FindIndependVar @author Brian Magill @datecreated 2/22/2008 $Date:$ $Revision:$ @copyright (©) Copyright 2006 by GATS Inc. 11864 Canon Blvd., Suite 101, Newport News, VA 23606 All Rights Reserved. No part of this software or publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by any means, electronic, mechanical, photocopying, recording, or otherwise without the prior written permission of GATS Inc. @brief Returns the independent variable associated with a table */ //---------------------------------------------------------------------- // #include #include #include //#include "EventVar.h" #include "FindIndependVar.h" #include "GATS_DB_Exception.h" #include "GATS_Utilities.hpp" using namespace std; using namespace gatsDBpp; string FindIndependVar::operator () (std::string tableName) const { try { GATS_DB_Results results; string strErr; string varName; // long arraySize; string strSQL = "SELECT C.Assoc_Entity FROM " + metaSummary + " A, " + IndepVarTable + " B, " + dependTable + " C " + " WHERE A.IndependentVar = B.IndependentVar AND" + " B.TableName = C.TableName AND B.Parameter = C.Parameter" + " AND A.TableName = '" + tableName + "'"; results = dbConn->Query(strSQL.c_str()); if (results.size() > 0 ) varName = results[0][0].asString(); else { strErr = string("No entry for table ") + tableName; throw runtime_error(strErr); } return varName; } catch (exception &ex) { string errstr = "FindIndependVar::operator() Error: " + string(ex.what() ) + string(" for table ") + tableName; throw runtime_error(errstr); } }