|
From: <sar...@us...> - 2013-07-25 11:34:41
|
Revision: 18264
http://sourceforge.net/p/sbml/code/18264
Author: sarahkeating
Date: 2013-07-25 11:34:38 +0000 (Thu, 25 Jul 2013)
Log Message:
-----------
There are two places in the validation code that use the getReferencedElement function.
This function will now log errors relating to missing references.
The validation does not need these errors as they will be logged and therefore just end up as duplicates; so I added code that would remove any errors logged by the getReferencedElement function.
Modified Paths:
--------------
trunk/libsbml/src/sbml/packages/comp/validator/constraints/UniquePortReferences.cpp
trunk/libsbml/src/sbml/packages/comp/validator/constraints/UniqueReplacedReferences.cpp
Modified: trunk/libsbml/src/sbml/packages/comp/validator/constraints/UniquePortReferences.cpp
===================================================================
--- trunk/libsbml/src/sbml/packages/comp/validator/constraints/UniquePortReferences.cpp 2013-07-24 23:46:50 UTC (rev 18263)
+++ trunk/libsbml/src/sbml/packages/comp/validator/constraints/UniquePortReferences.cpp 2013-07-25 11:34:38 UTC (rev 18264)
@@ -94,14 +94,30 @@
void
UniquePortReferences::checkReferencedElement(Port& p)
{
- if (mReferencedElements->find(p.getReferencedElement(),
+ unsigned int numErrsB4 = p.getSBMLDocument()->getNumErrors();
+
+ SBase* refElem = p.getReferencedElement();
+
+ // if there is an issue with references the getReferencedElement
+ // code may log errors
+ // we dont want them - since we will log any errors here
+ // so remove them
+ unsigned int numErrsAfter = p.getSBMLDocument()->getNumErrors();
+ for (unsigned int i = numErrsAfter; i > numErrsB4; i--)
+ {
+ p.getSBMLDocument()->getErrorLog()->remove(
+ p.getSBMLDocument()->getError(i-1)->getErrorId());
+ }
+
+ if (mReferencedElements->find(refElem,
(ListItemComparator) (ObjectsSame)) != NULL)
{
logReferenceExists (p);
}
else
{
- mReferencedElements->add(p.getReferencedElement());
+
+ mReferencedElements->add(refElem);
}
}
Modified: trunk/libsbml/src/sbml/packages/comp/validator/constraints/UniqueReplacedReferences.cpp
===================================================================
--- trunk/libsbml/src/sbml/packages/comp/validator/constraints/UniqueReplacedReferences.cpp 2013-07-24 23:46:50 UTC (rev 18263)
+++ trunk/libsbml/src/sbml/packages/comp/validator/constraints/UniqueReplacedReferences.cpp 2013-07-25 11:34:38 UTC (rev 18264)
@@ -136,7 +136,22 @@
void
UniqueReplacedReferences::checkReferencedElement(ReplacedElement& repE)
{
- if (mReferencedElements->find(repE.getReferencedElement(),
+ unsigned int numErrsB4 = repE.getSBMLDocument()->getNumErrors();
+
+ SBase* refElem = repE.getReferencedElement();
+
+ // if there is an issue with references the getReferencedElement
+ // code may log errors
+ // we dont want them - since we will log any errors here
+ // so remove them
+ unsigned int numErrsAfter = repE.getSBMLDocument()->getNumErrors();
+ for (unsigned int i = numErrsAfter; i > numErrsB4; i--)
+ {
+ repE.getSBMLDocument()->getErrorLog()->remove(
+ repE.getSBMLDocument()->getError(i-1)->getErrorId());
+ }
+
+ if (mReferencedElements->find(refElem,
(ListItemComparator) (ObjectsSame1)) != NULL)
{
if (repE.getReferencedElement()->getTypeCode() != SBML_COMP_DELETION)
@@ -147,7 +162,7 @@
else
{
- mReferencedElements->add(repE.getReferencedElement());
+ mReferencedElements->add(refElem);
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|