-// Copyright (C) 2006-2012 CEA/DEN, EDF R&D
+// Copyright (C) 2006-2016 CEA/DEN, EDF R&D
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
+// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
#include "TypeCode.hxx"
#include "SalomeProc.hxx"
+#include "Basics_Utils.hxx"
#include "SALOME_NamingService.hxx"
+#include "SALOME_KernelServices.hxx"
#include "SALOMEDS.hh"
#include "SALOMEDS_Attributes.hh"
void StudyInNode::execute()
{
DEBTRACE("+++++++ StudyInNode::execute +++++++++++");
- SALOME_NamingService NS(getSALOMERuntime()->getOrb());
- CORBA::Object_var obj=NS.Resolve("/myStudyManager");
- if(CORBA::is_nil(obj))
- {
- _errorDetails="Execution problem: no naming service";
- throw Exception(_errorDetails);
- }
-
- SALOMEDS::StudyManager_var aStudyManager = SALOMEDS::StudyManager::_narrow(obj);
- if(CORBA::is_nil(aStudyManager))
- {
- _errorDetails="Execution problem: no naming service";
- throw Exception(_errorDetails);
- }
-
- int studyid=1;
- if (getProperty("StudyID") != "")
- {
- // StudyId is specified
- studyid=atoi(getProperty("StudyID").c_str());
- }
- else
- {
- Proc* p=getProc();
- if(p)
- {
- std::string value=p->getProperty("DefaultStudyID");
- if(!value.empty())
- studyid= atoi(value.c_str());
- }
- }
-
-
- SALOMEDS::Study_var myStudy =aStudyManager->GetStudyByID(studyid);
- if(CORBA::is_nil(myStudy))
- {
- std::stringstream msg;
- msg << "Execution problem: no study with id " << studyid;
- _errorDetails=msg.str();
- throw Exception(_errorDetails);
- }
std::list<OutputPort *>::const_iterator iter;
for(iter = _setOfOutputPort.begin(); iter != _setOfOutputPort.end(); iter++)
OutputStudyPort *outp = dynamic_cast<OutputStudyPort *>(*iter);
try
{
- outp->getDataFromStudy(myStudy);
+ outp->getDataFromStudy();
}
catch(Exception& e)
{
}
/*
-SALOMEDS::SObject_ptr findOrCreateSoWithName(SALOMEDS::Study_ptr study, SALOMEDS::StudyBuilder_ptr builder,
+SALOMEDS::SObject_ptr findOrCreateSoWithName(SALOMEDS::StudyBuilder_ptr builder,
SALOMEDS::SObject_ptr sobj, const std::string& name)
{
- SALOMEDS::ChildIterator_var anIterator= study->NewChildIterator(sobj);
+ SALOMEDS::ChildIterator_var anIterator= KERNEL::getStudyServant()->NewChildIterator(sobj);
SALOMEDS::GenericAttribute_var anAttr;
SALOMEDS::AttributeName_var namAttr ;
SALOMEDS::SObject_var result=SALOMEDS::SObject::_nil();
void StudyOutNode::execute()
{
DEBTRACE("+++++++ StudyOutNode::execute +++++++++++");
- SALOME_NamingService NS(getSALOMERuntime()->getOrb());
- CORBA::Object_var obj=NS.Resolve("/myStudyManager");
- if(CORBA::is_nil(obj))
- {
- _errorDetails="Execution problem: no naming service";
- throw Exception(_errorDetails);
- }
-
- SALOMEDS::StudyManager_var aStudyManager = SALOMEDS::StudyManager::_narrow(obj);
- if(CORBA::is_nil(aStudyManager))
- {
- _errorDetails="Execution problem: no naming service";
- throw Exception(_errorDetails);
- }
-
- int studyid=1;
- if (getProperty("StudyID") != "")
- {
- // StudyId is specified
- studyid=atoi(getProperty("StudyID").c_str());
- }
- else
- {
- Proc* p=getProc();
- if(p)
- {
- std::string value=p->getProperty("DefaultStudyID");
- if(!value.empty())
- studyid= atoi(value.c_str());
- }
- }
-
- SALOMEDS::Study_var myStudy =aStudyManager->GetStudyByID(studyid);
- if(CORBA::is_nil(myStudy))
- {
- //open a new one
- std::stringstream msg;
- msg << "Study" << studyid;
- myStudy=aStudyManager->NewStudy(msg.str().c_str());
- if(CORBA::is_nil(myStudy))
- {
- _errorDetails="Execution problem: can not create new study " + msg.str();
- throw Exception(_errorDetails);
- }
- }
- DEBTRACE(myStudy->StudyId());
- SALOMEDS::StudyBuilder_var aBuilder =myStudy->NewBuilder() ;
+ SALOMEDS::StudyBuilder_var aBuilder =KERNEL::getStudyServant()->NewBuilder() ;
if(CORBA::is_nil(aBuilder))
{
_errorDetails="Execution problem: can not create StudyBuilder";
for(iter = _setOfInputPort.begin(); iter != _setOfInputPort.end(); iter++)
{
InputStudyPort *inp = dynamic_cast<InputStudyPort *>(*iter);
- inp->putDataInStudy(myStudy,aBuilder);
+ inp->putDataInStudy(aBuilder);
}
// save in file if ref is given
if(_ref != "")
{
- aStudyManager->SaveAs(_ref.c_str(),myStudy, false);
+ KERNEL::getStudyServant()->SaveAs(Kernel_Utils::decode_s( _ref ), false, false);
}
DEBTRACE("+++++++ end StudyOutNode::execute +++++++++++" );
}