@@ -681,6 +681,9 @@ void SEDMLUtils::setLibCombineTempDir()
681681const CDataObject *
682682SEDMLUtils::getObjectForSbmlId (const CModel * pModel, const std::string & id, const std::string & SBMLType, bool initial /* = false*/ )
683683{
684+ if (!pModel)
685+ return NULL ;
686+
684687 if (SBMLType == " Time" )
685688 return static_cast < const CDataObject * >(pModel->getObject (CCommonName (" Reference=Time" )));
686689
@@ -959,25 +962,7 @@ SedmlInfo::SedmlInfo(SedDocument * pDocument, bool ownDocument)
959962 if (!pDocument)
960963 return ;
961964
962- std::map< int , int > taskCount;
963-
964- for (unsigned int i = 0 ; i < pDocument->getNumTasks (); ++i)
965- {
966- auto * current = pDocument->getTask (i);
967- mTaskMap [current->getId ()] = getModelForTask (current);
968- taskCount[current->getTypeCode ()] = taskCount[current->getTypeCode ()] + 1 ;
969- mReports [current->getId ()] = std::vector< std::pair< std::string, std::string > >();
970- mPlots [current->getId ()] = std::vector< std::pair< std::string, std::string > >();
971- std::stringstream str;
972-
973- if (current->isSetName ())
974- str << current->getName () << " - " ;
975-
976- str << current->getId ();
977-
978- mTaskNames .push_back (std::make_pair (current->getId (), str.str ()));
979- mComplex |= taskCount[current->getTypeCode ()] > 1 || mTaskMap [current->getId ()].size () > 1 ;
980- }
965+ std::map< std::pair< int , int >, int > taskCount;
981966
982967 for (unsigned int i = 0 ; i < pDocument->getNumOutputs (); ++i)
983968 {
@@ -1000,6 +985,57 @@ SedmlInfo::SedmlInfo(SedDocument * pDocument, bool ownDocument)
1000985 mPlots [taskId].push_back (std::make_pair (current->getId (), str.str ()));
1001986 }
1002987 }
988+
989+ for (unsigned int i = 0 ; i < pDocument->getNumTasks (); ++i)
990+ {
991+ auto * current = pDocument->getTask (i);
992+
993+ if (isRecursiveWithoutOutputs (current))
994+ continue ;
995+
996+ mTaskMap [current->getId ()] = getModelForTask (current);
997+
998+ int simType = SEDML_SIMULATION;
999+
1000+ if (current->getTypeCode () == SEDML_TASK)
1001+ {
1002+ auto * simulation = pDocument->getSimulation (dynamic_cast < SedTask * >(current)->getSimulationReference ());
1003+
1004+ if (simulation != NULL )
1005+ simType = simulation->getTypeCode ();
1006+ }
1007+
1008+ auto currentKey = std::make_pair (current->getTypeCode (), simType);
1009+
1010+ taskCount[currentKey] = taskCount[currentKey] + 1 ;
1011+ std::stringstream str;
1012+
1013+ if (current->isSetName ())
1014+ str << current->getName () << " - " ;
1015+
1016+ str << current->getId ();
1017+
1018+ mTaskNames .push_back (std::make_pair (current->getId (), str.str ()));
1019+ mComplex |= taskCount[currentKey] > 1 || mTaskMap [current->getId ()].size () > 1 ;
1020+ }
1021+ }
1022+
1023+ bool SedmlInfo::hasOutputs (const std::string & taskId)
1024+ {
1025+ return !(mReports [taskId].empty () && mPlots [taskId].empty ());
1026+ }
1027+
1028+ bool SedmlInfo::isRecursiveWithoutOutputs (SedAbstractTask * task)
1029+ {
1030+ auto * repeat = dynamic_cast < SedRepeatedTask * >(task);
1031+
1032+ if (repeat == NULL )
1033+ return false ;
1034+
1035+ if (hasOutputs (task->getId ()))
1036+ return false ;
1037+
1038+ return true ;
10031039}
10041040
10051041SedmlInfo::~SedmlInfo ()
@@ -1283,6 +1319,7 @@ SedmlImportOptions::SedmlImportOptions(
12831319 , mPlots(plots)
12841320 , mReportId(reportId)
12851321 , mReportFile(reportFilename)
1322+ , mSkipModelImport(false )
12861323{
12871324}
12881325
@@ -1295,11 +1332,22 @@ SedmlImportOptions & SedmlImportOptions::operator=(const SedmlImportOptions & rh
12951332 mPlots = rhs.mPlots ;
12961333 mReportId = rhs.mReportId ;
12971334 mReportFile = rhs.mReportFile ;
1335+ mSkipModelImport = rhs.mSkipModelImport ;
12981336 }
12991337
13001338 return *this ;
13011339}
13021340
1341+ void SedmlImportOptions::setSkipModelImport (bool skipModelLoading)
1342+ {
1343+ mSkipModelImport = skipModelLoading;
1344+ }
1345+
1346+ bool SedmlImportOptions::skipModelImport () const
1347+ {
1348+ return mSkipModelImport ;
1349+ }
1350+
13031351const std::string & SedmlImportOptions::getTaskId () const
13041352{
13051353 return mTaskId ;
0 commit comments