Sophis Risque: how to create an instrument using the Sophis xml data model 'dataset'
Jul
12
Written by:
7/12/2012 2:43 PM
Needed and usefull for instance on unitary tests when creating new instruments in order to get new references and not to violate primary keys.
The following code permits such a creation:
01.
long
_sicovam = CSRInstrument::GetNewCode();
02.
03.
char
_xml[4096];
04.
05.
sprintf_s(_xml,
sizeof
(_xml),_xml_description.c_str(),_sicovam,_sicovam);
06.
07.
sophis::tools::dataModel::BasicDataSetHandle _dataHandle = sophis::tools::dataModel::BasicDataSet::create();
08.
09.
sophis::tools::dataModel::DataSet& _dataset = (*_dataHandle);
10.
11.
sophis::xml::dataModel::XMLDataImporter _import(_xml);
12.
13.
try
14.
15.
{
16.
17.
_import.importTo(_dataset);
18.
19.
}
20.
21.
catch
(ExceptionBase&
_exception
)
22.
23.
{
24.
25.
}
26.
27.
catch
(...)
28.
29.
{
30.
31.
}
32.
33.
// creation of the instrument using the Sophis xml description
34.
35.
CSRInstrument* _instrument = CSRInstrument::CreateFromDescription(_dataset);