File tree Expand file tree Collapse file tree 1 file changed +33
-1
lines changed
Expand file tree Collapse file tree 1 file changed +33
-1
lines changed Original file line number Diff line number Diff line change @@ -139,16 +139,48 @@ int getReportIndex(const std::string& reportName)
139139
140140void addReportItemsToList (const std::vector<std::string>& items, std::function< std::vector< CRegisteredCommonName >* () > getCnListFunction)
141141{
142+ if (!pDataModel || !getCnListFunction ())
143+ return ;
144+
142145 for (const auto & item : items)
143146 {
147+ bool fromDisplayName = true ;
144148 const auto * obj = pDataModel->findObjectByDisplayName (item);
145149 if (!obj)
146- obj = dynamic_cast <const CDataObject*>(pDataModel->getObject (item));
150+ {
151+ obj = dynamic_cast < const CDataObject * >(pDataModel->getObject (item));
152+ fromDisplayName = false ;
153+ }
147154 if (!obj)
148155 {
149156 std::cerr << " report item cannot be resolved: " << item << std::endl;
150157 continue ;
151158 }
159+
160+ // if the item is not a reference after resolving from
161+ // display name, choose specific reference for model entities
162+ if (fromDisplayName && obj->getObjectType () != " Reference" )
163+ {
164+ const CMetab * metab = dynamic_cast < const CMetab * >(obj);
165+ if (metab)
166+ {
167+ obj = metab->getConcentrationReference ();
168+ }
169+
170+ const CReaction * reaction = dynamic_cast < const CReaction * >(obj);
171+ if (reaction)
172+ {
173+ obj = reaction->getFluxReference ();
174+ }
175+
176+ const CModelEntity * modelEntity = dynamic_cast < const CModelEntity * >(obj);
177+ if (modelEntity)
178+ {
179+ obj = modelEntity->getValueReference ();
180+ }
181+ }
182+
183+
152184 getCnListFunction ()->push_back (obj->getCN ());
153185 }
154186}
You can’t perform that action at this time.
0 commit comments