QString ORM toSapNode const QString InstanceId EST Mapping ModelViewPo

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
QString
ORM::toSapNode(const QString & InstanceId,
EST::Mapping::ModelViewPointer mvp)
{
EST::Syslog log;
log.debug(QString("ORM::toSapNode from %1").arg(InstanceId));
QString result = "-1";
try
{
odb::transaction t(m_models->database().begin());
//EST::Mapping::LazyModelViewPointer lmvp = m_models->mainView;
//QSharedPointer<EST::Mapping::ModelView> mvp = lmvp.load();
CRID simId(EST::toStdWString(InstanceId));
EST::Mapping::Identifier idNode(simId);
EST::Mapping::LazyNodes nodes = mvp->fwd.node.values(idNode);
foreach(const EST::Mapping::LazyNodePointer &lnp, nodes)
{
EST::Mapping::NodePointer np = lnp.load();
if(! np.isNull())
{
QString result = QString::number(np->rid.handle());
log.debug(QString("ORM::toSapNode found %1 (count=%2)")
.arg(result)
.arg(nodes.size()));
return result;
}
}
}
catch(odb::exception &e)
{
log.critical(QString("ORM::toSapNode failed: %1").arg(e.what()));
}
return result;
}