|
From: <sar...@us...> - 2013-07-29 12:50:29
|
Revision: 18272
http://sourceforge.net/p/sbml/code/18272
Author: sarahkeating
Date: 2013-07-29 12:50:25 +0000 (Mon, 29 Jul 2013)
Log Message:
-----------
adding messages to the CompFlatteningConverter that indicate what has happened about other packages
also removed any other messages that got coincidently logged by the checks for unrecognised packages
Modified Paths:
--------------
trunk/libsbml/src/sbml/packages/comp/util/CompFlatteningConverter.cpp
trunk/libsbml/src/sbml/packages/comp/util/test/TestCompFlatteningConverter.cpp
trunk/libsbml/src/sbml/packages/comp/validator/CompSBMLError.h
trunk/libsbml/src/sbml/packages/comp/validator/CompSBMLErrorTable.h
Modified: trunk/libsbml/src/sbml/packages/comp/util/CompFlatteningConverter.cpp
===================================================================
--- trunk/libsbml/src/sbml/packages/comp/util/CompFlatteningConverter.cpp 2013-07-29 06:55:55 UTC (rev 18271)
+++ trunk/libsbml/src/sbml/packages/comp/util/CompFlatteningConverter.cpp 2013-07-29 12:50:25 UTC (rev 18272)
@@ -164,7 +164,7 @@
if (getPerformValidation() == true)
{
- mDocument->getErrorLog()->clearLog();
+// mDocument->getErrorLog()->clearLog();
unsigned char origValidators = mDocument->getApplicableValidators();
mDocument->setApplicableValidators(AllChecksON);
@@ -192,7 +192,8 @@
if (flatmodel == NULL)
{
mDocument->getErrorLog()->logPackageError("comp", CompModelFlatteningFailed,
- mDocument->getLevel(), mDocument->getVersion(), 1);
+ mDocument->getPlugin("comp")->getPackageVersion(), mDocument->getLevel(),
+ mDocument->getVersion());
return LIBSBML_OPERATION_FAILED;
}
@@ -330,20 +331,19 @@
util_free(doc);
unsigned int errors = d->getNumErrors();
- for (unsigned int i = 0; i < errors; i++)
- {
- mDocument->getErrorLog()->add(*(d->getError(i)));
- }
- delete d;
+ //for (unsigned int i = 0; i < errors; i++)
+ //{
+ // mDocument->getErrorLog()->add(*(d->getError(i)));
+ //}
- if (mDocument->getErrorLog()->contains(RequiredPackagePresent))
+ if (d->getErrorLog()->contains(RequiredPackagePresent))
{
canFlatten = false;
required = true;
unrecognised = true;
}
- if (mDocument->getErrorLog()->contains(UnrequiredPackagePresent))
+ if (d->getErrorLog()->contains(UnrequiredPackagePresent))
{
unrecognised = true;
}
@@ -372,21 +372,93 @@
}
- // clear the error log so we can add messages about flattening or not
+ // add messages about flattening or not
+ for (unsigned int i = 0; i < d->getErrorLog()->getNumErrors(); i++)
+ {
+ if (d->getError(i)->getErrorId() == RequiredPackagePresent
+ || d->getError(i)->getErrorId() == UnrequiredPackagePresent)
+ {
+ mDocument->getErrorLog()->add(*(d->getError(i)));
+ }
+ }
+ delete d;
+
if (canFlatten == false)
{
if (unrecognised == true)
{
if (required == true)
{
- //mDocument->getErrorLog()->logError(CompFlatteningNotRecognisedReqd, 3, 1);
- // log error: unrecognised required package
+ XMLNamespaces *ns = mDocument->getSBMLNamespaces()->getNamespaces();
+ for (int i = 0; i < ns->getLength(); i++)
+ {
+ if (mDocument->isIgnoredPackage(ns->getURI(i)) == true)
+ {
+ std::string message;
+ std::string nameOfPackage = ns->getPrefix(i);
+ if (getIgnorePackages() == true)
+ {
+ message = "The require package ";
+ message += nameOfPackage;
+ message += " cannot be flattened and the CompFlatteningConverter ";
+ message += "has the 'ignore packages' option set to 'true'. ";
+ message += "Thus flattening will not be attempted.";
+ }
+ else
+ {
+ message = "The package ";
+ message += nameOfPackage;
+ message += " cannot be flattened and the CompFlatteningConverter ";
+ message += "has the 'ignore packages' option set to 'false'. ";
+ message += "Thus information from the ";
+ message += nameOfPackage;
+ message += " package will not appear in the flattened model.";
+ }
+ mDocument->getErrorLog()->logPackageError("comp",
+ CompFlatteningNotRecognisedReqd,
+ mDocument->getPlugin("comp")->getPackageVersion(),
+ mDocument->getLevel(), mDocument->getVersion(), message);
+ }
+ }
}
}
else
{
// log error: required package but falttening not implemented
- //mDocument->getErrorLog()->logError(CompFlatteningNotImplementedReqd, 3, 1);
+ for (unsigned int i = 0; i < mDocument->getNumPlugins(); i++)
+ {
+ if (static_cast<SBMLDocumentPlugin*>(mDocument->getPlugin(i))
+ ->getRequired() == true
+ && static_cast<SBMLDocumentPlugin*>(mDocument->getPlugin(i))
+ ->isFlatteningImplemented() == false)
+ {
+ std::string nameOfPackage =
+ mDocument->getPlugin(i)->getPackageName();
+ std::string message;
+ if (getIgnorePackages() == true)
+ {
+ message = "The package ";
+ message += nameOfPackage;
+ message += " cannot be flattened and the CompFlatteningConverter ";
+ message += "has the 'ignore packages' option set to 'true'. ";
+ message += "Thus flattening will not be attempted.";
+ }
+ else
+ {
+ message = "The package ";
+ message += nameOfPackage;
+ message += " cannot be flattened and the CompFlatteningConverter ";
+ message += "has the 'ignore packages' option set to 'false'. Thus ";
+ message += "flattening will be attempted but information from the ";
+ message += nameOfPackage;
+ message += " in the flattened model may not be accurate.";
+ }
+ mDocument->getErrorLog()->logPackageError("comp",
+ CompFlatteningNotImplementedNotReqd,
+ mDocument->getPlugin("comp")->getPackageVersion(),
+ mDocument->getLevel(), mDocument->getVersion(), message);
+ }
+ }
}
if (getIgnorePackages() == false)
{
@@ -397,43 +469,82 @@
{
if (unrecognised == true)
{
- // log error: unrecognised unrequired INFO lost
- //mDocument->getErrorLog()->logError(CompFlatteningNotRecognisedNotReqd, 3, 1);
-
- if (getIgnorePackages() == true)
+ XMLNamespaces *ns = mDocument->getSBMLNamespaces()->getNamespaces();
+ for (int i = 0; i < ns->getLength(); i++)
{
- XMLNamespaces *ns = mDocument->getSBMLNamespaces()->getNamespaces();
- for (int i = 0; i < ns->getLength(); i++)
+ if (mDocument->isIgnoredPackage(ns->getURI(i)) == true)
{
- if (mDocument->isIgnoredPackage(ns->getURI(i)) == true)
+ std::string message;
+ std::string nameOfPackage = ns->getPrefix(i);
+ if (getIgnorePackages() == true)
{
+ message = "The package ";
+ message += nameOfPackage;
+ message += " cannot be flattened and the CompFlatteningConverter ";
+ message += "has the 'ignore packages' option set to 'true'. ";
+ message += "Thus all information from the ";
+ message += nameOfPackage;
+ message += " package will be removed from the flattened model.";
mDocument->enablePackageInternal(ns->getURI(i),
ns->getPrefix(i), false);
}
+ else
+ {
+ message = "The package ";
+ message += nameOfPackage;
+ message += " cannot be flattened and the CompFlatteningConverter ";
+ message += "has the 'ignore packages' option set to 'false'. ";
+ message += "Thus information from the ";
+ message += nameOfPackage;
+ message += " will not appear in the flattened model.";
+ }
+ mDocument->getErrorLog()->logPackageError("comp",
+ CompFlatteningNotRecognisedNotReqd,
+ mDocument->getPlugin("comp")->getPackageVersion(),
+ mDocument->getLevel(), mDocument->getVersion(), message);
}
}
}
if (notImplemented == true)
{
- // log error: unrequire not implemented: INFO lost
- //mDocument->getErrorLog()->logError(CompFlatteningNotImplementedNotReqd, 3, 1);
-
- // disable any non required unimplemented package
- if (getIgnorePackages() == true)
+ for (unsigned int i = 0; i < mDocument->getNumPlugins(); i++)
{
- for (unsigned int i = 0; i < mDocument->getNumPlugins(); i++)
+ if (static_cast<SBMLDocumentPlugin*>(mDocument->getPlugin(i))
+ ->getRequired() == false
+ && static_cast<SBMLDocumentPlugin*>(mDocument->getPlugin(i))
+ ->isFlatteningImplemented() == false)
{
- if (static_cast<SBMLDocumentPlugin*>(mDocument->getPlugin(i))
- ->isFlatteningImplemented() == false)
+ std::string nameOfPackage =
+ mDocument->getPlugin(i)->getPackageName();
+ std::string message;
+ if (getIgnorePackages() == true)
{
- if (static_cast<SBMLDocumentPlugin*>(mDocument->getPlugin(i))
- ->getRequired() == false)
- {
- std::string pkgURI = mDocument->getPlugin(i)->getURI();
- std::string prefix = mDocument->getPlugin(i)->getPrefix();
- mDocument->disablePackage(pkgURI, prefix);
- }
+ message = "The package ";
+ message += nameOfPackage;
+ message += " cannot be flattened and the CompFlatteningConverter ";
+ message += "has the 'ignore packages' option set to 'true'. ";
+ message += "Thus all information from the ";
+ message += nameOfPackage;
+ message += " package will be removed from the flattened model.";
+
+ std::string pkgURI = mDocument->getPlugin(i)->getURI();
+ std::string prefix = mDocument->getPlugin(i)->getPrefix();
+ mDocument->disablePackage(pkgURI, prefix);
}
+ else
+ {
+ message = "The package ";
+ message += nameOfPackage;
+ message += " cannot be flattened and the CompFlatteningConverter ";
+ message += "has the 'ignore packages' option set to 'false'. ";
+ message += "Thus information from the ";
+ message += nameOfPackage;
+ message += " in the flattened model may not be accurate.";
+ }
+ mDocument->getErrorLog()->logPackageError("comp",
+ CompFlatteningNotImplementedNotReqd,
+ mDocument->getPlugin("comp")->getPackageVersion(),
+ mDocument->getLevel(), mDocument->getVersion(), message);
}
}
}
Modified: trunk/libsbml/src/sbml/packages/comp/util/test/TestCompFlatteningConverter.cpp
===================================================================
--- trunk/libsbml/src/sbml/packages/comp/util/test/TestCompFlatteningConverter.cpp 2013-07-29 06:55:55 UTC (rev 18271)
+++ trunk/libsbml/src/sbml/packages/comp/util/test/TestCompFlatteningConverter.cpp 2013-07-29 12:50:25 UTC (rev 18272)
@@ -1286,6 +1286,7 @@
ConversionProperties* props = new ConversionProperties();
props->addOption("flatten comp");
+ props->addOption("perform validation", false);
SBMLConverter* converter = SBMLConverterRegistry::getInstance().getConverterFor(*props);
@@ -1314,9 +1315,16 @@
if (SBMLExtensionRegistry::isPackageEnabled("layout") == true)
{
ffile = filename + "aggregate_layout_flat_layout_removed.xml";
+ fail_unless(result == LIBSBML_OPERATION_SUCCESS);
+ fail_unless(doc->getNumErrors() == 1);
+ fail_unless(doc->getErrorLog()->getError(0)->getErrorId() == 1090109);
}
else
{
+ fail_unless(result == LIBSBML_OPERATION_SUCCESS);
+ fail_unless(doc->getNumErrors() == 2);
+ fail_unless(doc->getErrorLog()->getError(0)->getErrorId() == 99108);
+ fail_unless(doc->getErrorLog()->getError(1)->getErrorId() == 1090108);
ffile = filename + "aggregate_layout_flat_layout_removed.xml";
}
@@ -1339,6 +1347,7 @@
props->addOption("flatten comp");
props->addOption("ignorePackages", true);
+ props->addOption("perform validation", false);
SBMLConverter* converter = SBMLConverterRegistry::getInstance().getConverterFor(*props);
@@ -1369,11 +1378,16 @@
{
// fbc is not required so should just get removed
fail_unless(result == LIBSBML_OPERATION_SUCCESS);
+ fail_unless(doc->getNumErrors() == 1);
+ fail_unless(doc->getErrorLog()->getError(0)->getErrorId() == 1090109);
ffile = filename + "aggregate_fbc_flat_fbc_removed.xml";
}
else
{
fail_unless(result == LIBSBML_OPERATION_SUCCESS);
+ fail_unless(doc->getNumErrors() == 2);
+ fail_unless(doc->getErrorLog()->getError(0)->getErrorId() == 99108);
+ fail_unless(doc->getErrorLog()->getError(1)->getErrorId() == 1090108);
ffile = filename + "aggregate_fbc_flat_fbc_removed.xml";
}
@@ -1396,6 +1410,7 @@
props->addOption("flatten comp");
props->addOption("ignorePackages", true);
+ props->addOption("perform validation", false);
SBMLConverter* converter = SBMLConverterRegistry::getInstance().getConverterFor(*props);
@@ -1426,11 +1441,16 @@
{
// fbc is not required so should just get removed
fail_unless(result == LIBSBML_OPERATION_SUCCESS);
+ fail_unless(doc->getNumErrors() == 1);
+ fail_unless(doc->getErrorLog()->getError(0)->getErrorId() == 1090109);
ffile = filename + "aggregate_fbc_flat_fbc_removed.xml";
}
else
{
fail_unless(result == LIBSBML_OPERATION_SUCCESS);
+ fail_unless(doc->getNumErrors() == 2);
+ fail_unless(doc->getErrorLog()->getError(0)->getErrorId() == 99108);
+ fail_unless(doc->getErrorLog()->getError(1)->getErrorId() == 1090108);
ffile = filename + "aggregate_fbc_flat_fbc_removed.xml";
}
@@ -1453,6 +1473,7 @@
props->addOption("flatten comp");
props->addOption("ignorePackages", false);
+ props->addOption("perform validation", false);
SBMLConverter* converter = SBMLConverterRegistry::getInstance().getConverterFor(*props);
@@ -1481,11 +1502,16 @@
if (SBMLExtensionRegistry::isPackageEnabled("fbc") == true)
{
fail_unless(result == LIBSBML_OPERATION_SUCCESS);
+ fail_unless(doc->getNumErrors() == 1);
+ fail_unless(doc->getErrorLog()->getError(0)->getErrorId() == 1090109);
ffile = filename + "aggregate_fbc_flat_fbc_not_removed.xml";
}
else
{
fail_unless(result == LIBSBML_OPERATION_SUCCESS);
+ fail_unless(doc->getNumErrors() == 2);
+ fail_unless(doc->getErrorLog()->getError(0)->getErrorId() == 99108);
+ fail_unless(doc->getErrorLog()->getError(1)->getErrorId() == 1090108);
ffile = filename + "aggregate_fbc_flat_fbc_not_enabled.xml";
}
Modified: trunk/libsbml/src/sbml/packages/comp/validator/CompSBMLError.h
===================================================================
--- trunk/libsbml/src/sbml/packages/comp/validator/CompSBMLError.h 2013-07-29 06:55:55 UTC (rev 18271)
+++ trunk/libsbml/src/sbml/packages/comp/validator/CompSBMLError.h 2013-07-29 12:50:25 UTC (rev 18272)
@@ -167,6 +167,11 @@
, CompFlatModelNotValid = 1090105
, CompLineNumbersUnreliable = 1090106
+, CompFlatteningNotRecognisedNotReqd = 1090108
+, CompFlatteningNotRecognisedReqd = 1090107
+, CompFlatteningNotImplementedNotReqd = 1090109
+, CompFlatteningNotImplementedReqd = 1090110
+
} CompSBMLErrorCode_t;
Modified: trunk/libsbml/src/sbml/packages/comp/validator/CompSBMLErrorTable.h
===================================================================
--- trunk/libsbml/src/sbml/packages/comp/validator/CompSBMLErrorTable.h 2013-07-29 06:55:55 UTC (rev 18271)
+++ trunk/libsbml/src/sbml/packages/comp/validator/CompSBMLErrorTable.h 2013-07-29 12:50:25 UTC (rev 18272)
@@ -1276,6 +1276,53 @@
"Hierarchical Model Composition package." ,
{ ""
}
+ },
+
+ // 1090107
+ { CompFlatteningNotRecognisedNotReqd,
+ "Flattening not implemented for unrequired package.",
+ LIBSBML_CAT_GENERAL_CONSISTENCY,
+ LIBSBML_SEV_WARNING,
+ "The CompFlatteningConverter has encountered an unrequired package for "
+ "which libSBML does not recognize the information.",
+ { ""
+ }
+ },
+
+ // 1090108
+ { CompFlatteningNotRecognisedReqd,
+ "Flattening not implemented for required package.",
+ LIBSBML_CAT_GENERAL_CONSISTENCY,
+ LIBSBML_SEV_WARNING,
+ "The CompFlatteningConverter has encountered a required package for "
+ "which libSBML does not recognize the information.",
+ { ""
+ }
+ },
+
+ // 1090109
+ { CompFlatteningNotImplementedNotReqd,
+ "Flattening not implemented for unrequired package.",
+ LIBSBML_CAT_GENERAL_CONSISTENCY,
+ LIBSBML_SEV_WARNING,
+ "The CompFlatteningConverter has encountered an unrequired package for "
+ "which "
+ "the necessary routines to allow flattening have not yet been implemented. "
+ "" ,
+ { ""
+ }
+ },
+
+ // 1090110
+ { CompFlatteningNotImplementedReqd,
+ "Flattening not implemented for required package.",
+ LIBSBML_CAT_GENERAL_CONSISTENCY,
+ LIBSBML_SEV_WARNING,
+ "The CompFlatteningConverter has encountered a required package for which "
+ "the necessary routines to allow flattening have not yet been implemented. "
+ "" ,
+ { ""
+ }
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|