From: mpv Date: Tue, 19 Feb 2013 12:39:16 +0000 (+0000) Subject: Adopt the SIMAN code to the SALOME 7: move checkout/checkin mechanizms from SALOMEDSI... X-Git-Tag: Delivery_V1_0_2013_07_12~6 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=14fbeb7a729755cc007c4e7356801f439dbbfcf6;p=modules%2Fkernel.git Adopt the SIMAN code to the SALOME 7: move checkout/checkin mechanizms from SALOMEDSImpl to SALOMEDS in order to make SALOMEDSImpl independent from CORBA product --- diff --git a/idl/SALOMEDS.idl b/idl/SALOMEDS.idl index 38afde16e..644c34ed3 100644 --- a/idl/SALOMEDS.idl +++ b/idl/SALOMEDS.idl @@ -618,13 +618,6 @@ during each working session. */ Study getReferencedStudy(); -/*! - Private method, returns an implementation of this Study. - \param theHostname is a hostname of the caller - \param thePID is a process ID of the caller - \param isLocal is set True if the Study is launched locally with the caller -*/ - long long GetLocalImpl(in string theHostname, in long thePID, out boolean isLocal); }; //========================================================================== diff --git a/src/SALOMEDS/Makefile.am b/src/SALOMEDS/Makefile.am index 3760c9fc0..4961d918c 100644 --- a/src/SALOMEDS/Makefile.am +++ b/src/SALOMEDS/Makefile.am @@ -280,7 +280,12 @@ libSalomeDS_la_SOURCES = \ if WITH_SIMANIO -COMMON_CPPFLAGS += -DWITH_SIMANIO +COMMON_CPPFLAGS += -DWITH_SIMANIO @SIMANIO_CPPFLAGS@ +COMMON_LIBS += @SIMANIO_LIBS@ + +COMMON_CPPFLAGS += -I$(srcdir)/../KernelHelpers -I$(srcdir)/../Container -I$(srcdir)/../TOOLSDS + +COMMON_LIBS += ../KernelHelpers/libSalomeKernelHelpers.la ../Container/libSalomeContainer.la ../TOOLSDS/libTOOLSDS.la endif diff --git a/src/SALOMEDS/SALOMEDS_SimanStudy.cxx b/src/SALOMEDS/SALOMEDS_SimanStudy.cxx index 1000eadd7..62781d1f5 100644 --- a/src/SALOMEDS/SALOMEDS_SimanStudy.cxx +++ b/src/SALOMEDS/SALOMEDS_SimanStudy.cxx @@ -40,16 +40,18 @@ #include "Utils_ORB_INIT.hxx" #include "Utils_SINGLETON.hxx" +/* SALOMEDS_SimanStudy::SALOMEDS_SimanStudy(SALOMEDSImpl_SimanStudy* theStudy) { _isLocal = true; _local_impl = theStudy; _corba_impl = SALOMEDS::SimanStudy::_nil(); init_orb(); -} +}*/ SALOMEDS_SimanStudy::SALOMEDS_SimanStudy(SALOMEDS::SimanStudy_ptr theStudy) { + /* #ifdef WIN32 long pid = (long)_getpid(); #else @@ -65,6 +67,8 @@ SALOMEDS_SimanStudy::SALOMEDS_SimanStudy(SALOMEDS::SimanStudy_ptr theStudy) _local_impl = NULL; _corba_impl = SALOMEDS::SimanStudy::_duplicate(theStudy); } + */ + _corba_impl = SALOMEDS::SimanStudy::_duplicate(theStudy); init_orb(); } @@ -77,26 +81,26 @@ void SALOMEDS_SimanStudy::CheckOut(const _PTR(Study) theTarget) { if (!theTarget) return; SALOMEDS_Study* aStudy = dynamic_cast(theTarget.get()); - if (_isLocal) { + /*if (_isLocal) { //SALOMEDS::Locker lock; mpv: this may cause dedlock when importData in module calls another SALOMEDS method with lock _local_impl->CheckOut(aStudy->GetLocalImpl()); } - else _corba_impl->CheckOut(aStudy->GetStudy()); + else*/ _corba_impl->CheckOut(aStudy->GetStudy()); } void SALOMEDS_SimanStudy::CheckIn(const std::string theModuleName) { - if (_isLocal) { + /*if (_isLocal) { //SALOMEDS::Locker lock; mpv: this may cause dedlock when getModifiedData in module calls another SALOMEDS method with lock _local_impl->CheckIn(theModuleName); } - else _corba_impl->CheckIn((char*)theModuleName.c_str()); + else*/ _corba_impl->CheckIn((char*)theModuleName.c_str()); } _PTR(Study) SALOMEDS_SimanStudy::getReferencedStudy() { SALOMEDSClient_Study* aStudy = NULL; - if (_isLocal) { + /*if (_isLocal) { SALOMEDS::Locker lock; SALOMEDSImpl_Study* aStudy_impl = _local_impl->getReferencedStudy(); @@ -107,68 +111,71 @@ _PTR(Study) SALOMEDS_SimanStudy::getReferencedStudy() SALOMEDS::Study_var aStudy_impl = _corba_impl->getReferencedStudy(); if (CORBA::is_nil(aStudy_impl)) return _PTR(Study)(aStudy); aStudy = new SALOMEDS_Study(aStudy_impl); - } + }*/ + SALOMEDS::Study_var aStudy_impl = _corba_impl->getReferencedStudy(); + if (CORBA::is_nil(aStudy_impl)) return _PTR(Study)(aStudy); + aStudy = new SALOMEDS_Study(aStudy_impl); return _PTR(Study)(aStudy); } std::string SALOMEDS_SimanStudy::StudyId() { std::string anId; - if (_isLocal) { + /*if (_isLocal) { SALOMEDS::Locker lock; anId = _local_impl->StudyId(); } - else anId = (CORBA::String_var)_corba_impl->StudyId(); + else*/ anId = (CORBA::String_var)_corba_impl->StudyId(); return anId; } void SALOMEDS_SimanStudy::StudyId(const std::string theId) { - if (_isLocal) { + /*if (_isLocal) { SALOMEDS::Locker lock; _local_impl->StudyId(theId); } - else _corba_impl->StudyId((char*)theId.c_str()); + else*/ _corba_impl->StudyId((char*)theId.c_str()); } std::string SALOMEDS_SimanStudy::ScenarioId() { std::string anId; - if (_isLocal) { + /*if (_isLocal) { SALOMEDS::Locker lock; anId = _local_impl->ScenarioId(); } - else anId = (CORBA::String_var)_corba_impl->ScenarioId(); + else*/ anId = (CORBA::String_var)_corba_impl->ScenarioId(); return anId; } void SALOMEDS_SimanStudy::ScenarioId(const std::string theId) { - if (_isLocal) { + /*if (_isLocal) { SALOMEDS::Locker lock; _local_impl->ScenarioId(theId); } - else _corba_impl->ScenarioId((char*)theId.c_str()); + else*/ _corba_impl->ScenarioId((char*)theId.c_str()); } std::string SALOMEDS_SimanStudy::UserId() { std::string anId; - if (_isLocal) { + /*if (_isLocal) { SALOMEDS::Locker lock; anId = _local_impl->UserId(); } - else anId = (CORBA::String_var)_corba_impl->UserId(); + else*/ anId = (CORBA::String_var)_corba_impl->UserId(); return anId; } void SALOMEDS_SimanStudy::UserId(const std::string theId) { - if (_isLocal) { + /*if (_isLocal) { SALOMEDS::Locker lock; _local_impl->UserId(theId); } - else _corba_impl->UserId((char*)theId.c_str()); + else*/ _corba_impl->UserId((char*)theId.c_str()); } void SALOMEDS_SimanStudy::init_orb() diff --git a/src/SALOMEDS/SALOMEDS_SimanStudy.hxx b/src/SALOMEDS/SALOMEDS_SimanStudy.hxx index 3cfe76f4f..c8c1090ce 100644 --- a/src/SALOMEDS/SALOMEDS_SimanStudy.hxx +++ b/src/SALOMEDS/SALOMEDS_SimanStudy.hxx @@ -30,8 +30,9 @@ #include #include +#include #include "SALOMEDSClient.hxx" -#include "SALOMEDSImpl_SimanStudy.hxx" +//#include "SALOMEDSImpl_SimanStudy.hxx" // IDL headers #include @@ -41,14 +42,14 @@ class Standard_EXPORT SALOMEDS_SimanStudy: public SALOMEDSClient_SimanStudy { private: - bool _isLocal; - SALOMEDSImpl_SimanStudy* _local_impl; + // bool _isLocal; + //SALOMEDSImpl_SimanStudy* _local_impl; // MPV: no local implementation yet: siman operations works only with CORBA interface SALOMEDS::SimanStudy_var _corba_impl; CORBA::ORB_var _orb; public: - SALOMEDS_SimanStudy(SALOMEDSImpl_SimanStudy* theStudy); + //SALOMEDS_SimanStudy(SALOMEDSImpl_SimanStudy* theStudy); SALOMEDS_SimanStudy(SALOMEDS::SimanStudy_ptr theStudy); ~SALOMEDS_SimanStudy(); diff --git a/src/SALOMEDS/SALOMEDS_SimanStudy_i.cxx b/src/SALOMEDS/SALOMEDS_SimanStudy_i.cxx index c9785f2b7..d5addfa23 100644 --- a/src/SALOMEDS/SALOMEDS_SimanStudy_i.cxx +++ b/src/SALOMEDS/SALOMEDS_SimanStudy_i.cxx @@ -26,22 +26,31 @@ // #include "utilities.h" #include "SALOMEDS_SimanStudy_i.hxx" -#include "SALOMEDSImpl_SimanStudy.hxx" -#include "SALOMEDSImpl_StudyManager.hxx" #include "SALOMEDS_Study_i.hxx" #include "SALOMEDS_Study.hxx" #include "Basics_Utils.hxx" +#ifdef WITH_SIMANIO +#include +#include +#include +#include +#include +#include +#include +#endif + +using namespace std; + //============================================================================ /*! Function : SALOMEDS_SimanStudy_i * Purpose : standard constructor */ //============================================================================ -SALOMEDS_SimanStudy_i::SALOMEDS_SimanStudy_i(SALOMEDSImpl_SimanStudy* theImpl, CORBA::ORB_ptr orb) +SALOMEDS_SimanStudy_i::SALOMEDS_SimanStudy_i(/*SALOMEDSImpl_SimanStudy* theImpl,*/ CORBA::ORB_ptr orb) { _orb = CORBA::ORB::_duplicate(orb); - _impl = theImpl; } //============================================================================ @@ -51,8 +60,29 @@ SALOMEDS_SimanStudy_i::SALOMEDS_SimanStudy_i(SALOMEDSImpl_SimanStudy* theImpl, C //============================================================================ SALOMEDS_SimanStudy_i::~SALOMEDS_SimanStudy_i() { - //delete implementation - delete _impl; +#ifdef WITH_SIMANIO + if (_checkedOut) { + SimanIO_Configuration::ActivitiesIterator actIter(*_checkedOut); + for(; actIter.More(); actIter.Next()) { + SimanIO_Activity::DocumentsIterator aDocIter(actIter.Activity()); for(; aDocIter.More(); aDocIter.Next()) { + const SimanIO_Document& aDoc = aDocIter.Document(); + SimanIO_Document::FilesIterator aFileIter(aDoc); + for(; aFileIter.More(); aFileIter.Next()) { + string aURL = aFileIter.URL(); + string aDir = Kernel_Utils::GetDirName(aURL); + aDir += "/"; + string aFileName = aURL.substr(aDir.size()); + SALOMEDS::ListOfFileNames aTmpFiles; + aTmpFiles.length(1); + aTmpFiles[0] = aFileName.c_str(); + // try to remove temporary directory that contains this file if directory becomes empty + SALOMEDS_Tool::RemoveTemporaryFiles(aDir, aTmpFiles, true); + } + } + } + delete _checkedOut; + } +#endif } //============================================================================ @@ -66,7 +96,54 @@ void SALOMEDS_SimanStudy_i::CheckOut(SALOMEDS::Study_ptr theTarget) SALOMEDS_Study aStudy(theTarget); _study = aStudy.GetLocalImpl(); if (_study) { - _impl->CheckOut(_study); +#ifdef WITH_SIMANIO + int aLocked = _study->GetProperties()->IsLocked(); + if (aLocked) _study->GetProperties()->SetLocked(false); + + SimanIO_Link aLink(_studyId.c_str(), _scenarioId.c_str(), _userId.c_str()); + if (aLink.IsConnected()) { + // Set "C" locale temporarily to avoid possible localization problems + Kernel_Utils::Localizer loc; + *_checkedOut = aLink.RetrieveConf(); + SimanIO_Configuration::ActivitiesIterator actIter(*_checkedOut); + for(; actIter.More(); actIter.Next()) { + Engines::EngineComponent_var aComp = + KERNEL::getLifeCycleCORBA()->FindOrLoad_Component("FactoryServerPy", actIter.Activity().Module()); + if (CORBA::is_nil(aComp)) // it is not python container, try to find in C++ container + aComp = KERNEL::getLifeCycleCORBA()->FindOrLoad_Component("FactoryServer", actIter.Activity().Module()); + if (CORBA::is_nil(aComp)) { + MESSAGE("Checkout: component "<(); + const SimanIO_Document& aDoc = aDocIter.Document(); + SimanIO_Document::FilesIterator aFileIter(aDoc); + for(; aFileIter.More(); aFileIter.Next()) { + if (aFileIter.GetProcessing() == FILE_IMPORT) { + // files provided by SIMAN will be removed later, on study close + Engines::DataContainer_var aData = (new Engines_DataContainer_i( + aFileIter.URL(), aDoc.Name(), "", false))->_this(); + Engines::ListOfOptions anEmptyOpts; + Engines::ListOfIdentifiers_var anIds = aComp->importData(_study->StudyId(), aData, anEmptyOpts); + for(int anIdNum = 0; anIdNum < anIds->length(); anIdNum++) { + const char* anId = anIds[anIdNum]; + _filesId[aDocIter.DocId()][anId] = aFileIter.Id(); + } + } else { + cout<<"!!! File just downloaded, not imported:"<GetProperties()->SetLocked(true); +#endif } } @@ -78,7 +155,89 @@ void SALOMEDS_SimanStudy_i::CheckOut(SALOMEDS::Study_ptr theTarget) void SALOMEDS_SimanStudy_i::CheckIn(const char* theModuleName) { if (_study) { - _impl->CheckIn(theModuleName); +#ifdef WITH_SIMANIO + string aModuleName(theModuleName); + SimanIO_Link aLink(_studyId.c_str(), _scenarioId.c_str(), _userId.c_str()); + if (aLink.IsConnected()) { + // Set "C" locale temporarily to avoid possible localization problems + Kernel_Utils::Localizer loc; + SimanIO_Configuration aToStore; // here create and store data in this configuration to check in to SIMAN + string aTmpDir = SALOMEDS_Tool::GetTmpDir(); // temporary directory for checked in files + int aFileIndex = 0; // for unique file name generation + list aTemporaryFileNames; + SimanIO_Configuration::ActivitiesIterator actIter(*_checkedOut); + for(; actIter.More(); actIter.Next()) { + int aDocId = actIter.Activity().DocumentMaxID(); + //if (aDocId < 0) continue; // no documents => no check in + if (!aModuleName.empty() && aModuleName != actIter.Activity().Module()) { + continue; + } + Engines::EngineComponent_var aComp = + KERNEL::getLifeCycleCORBA()->FindOrLoad_Component("FactoryServerPy", actIter.Activity().Module()); + if (CORBA::is_nil(aComp)) // it is not python container, try to find in C++ container + aComp = KERNEL::getLifeCycleCORBA()->FindOrLoad_Component("FactoryServer", actIter.Activity().Module()); + if (CORBA::is_nil(aComp)) { + MESSAGE("Checkin: component "<getModifiedData(_study->StudyId()); + int aNumData = aList->length(); + for(int aDataIndex = 0; aDataIndex < aNumData; aDataIndex++) { + Engines::DataContainer_var aData = aList[aDataIndex]; + // store this in the configuration + SimanIO_Activity& aStoreActivity = aToStore.GetOrCreateActivity(actIter.ActivityId()); + aStoreActivity.SetName(actIter.Activity().Name()); + aStoreActivity.SetModule(actIter.Activity().Module()); + SimanIO_Document& aStoreDoc = aStoreActivity.GetOrCreateDocument(aDocId); + aStoreDoc.SetName(aDoc.Name()); + // prepare a file to store + SimanIO_File aStoreFile; + + stringstream aNumStore; + aNumStore<<"file"<<(++aFileIndex); + string aFileName(aNumStore.str()); + string anExtension(aData->extension()); + aFileName += "." + anExtension; + string aFullPath = aTmpDir + aFileName; + Engines::TMPFile* aFileStream = aData->get(); + const char *aBuffer = (const char*)aFileStream->NP_data(); +#ifdef WIN32 + std::ofstream aFile(aFullPath.c_str(), std::ios::binary); +#else + std::ofstream aFile(aFullPath.c_str()); +#endif + aFile.write(aBuffer, aFileStream->length()); + aFile.close(); + aTemporaryFileNames.push_back(aFileName); + + aStoreFile.url = aFullPath; + if (_filesId[aDocId].find(aData->identifier()) != _filesId[aDocId].end()) { // file is already exists + aStoreFile.id = _filesId[aDocId][aData->identifier()]; + aStoreFile.result = aDoc.File(aStoreFile.id).result; + } else { + aStoreFile.id = -1; // to be created as new + aStoreFile.result = true; // new is always result + } + + aStoreDoc.AddFile(aStoreFile); + } + } + } + aLink.StoreConf(aToStore); + // after files have been stored, remove them from the temporary directory + SALOMEDS::ListOfFileNames aTmpFiles; + aTmpFiles.length(aTemporaryFileNames.size()); + list::iterator aFilesIter = aTemporaryFileNames.begin(); + for(int a = 0; aFilesIter != aTemporaryFileNames.end(); aFilesIter++, a++) { + aTmpFiles[a] = aFilesIter->c_str(); + } + SALOMEDS_Tool::RemoveTemporaryFiles(aTmpDir, aTmpFiles, true); + } else { + MESSAGE("There is no connection to SIMAN!") + } +#endif } } @@ -100,7 +259,7 @@ SALOMEDS::Study_ptr SALOMEDS_SimanStudy_i::getReferencedStudy() //============================================================================ char* SALOMEDS_SimanStudy_i::StudyId() { - return CORBA::string_dup(_impl->StudyId().c_str()); + return CORBA::string_dup(_studyId.c_str()); } //============================================================================ @@ -110,7 +269,7 @@ char* SALOMEDS_SimanStudy_i::StudyId() //============================================================================ void SALOMEDS_SimanStudy_i::StudyId(const char* theId) { - _impl->StudyId(theId); + _studyId = theId; } //============================================================================ @@ -120,7 +279,7 @@ void SALOMEDS_SimanStudy_i::StudyId(const char* theId) //============================================================================ char* SALOMEDS_SimanStudy_i::ScenarioId() { - return CORBA::string_dup(_impl->ScenarioId().c_str()); + return CORBA::string_dup(_scenarioId.c_str()); } //============================================================================ @@ -130,7 +289,7 @@ char* SALOMEDS_SimanStudy_i::ScenarioId() //============================================================================ void SALOMEDS_SimanStudy_i::ScenarioId(const char* theId) { - _impl->ScenarioId(theId); + _scenarioId = theId; } //============================================================================ @@ -140,7 +299,7 @@ void SALOMEDS_SimanStudy_i::ScenarioId(const char* theId) //============================================================================ char* SALOMEDS_SimanStudy_i::UserId() { - return CORBA::string_dup(_impl->UserId().c_str()); + return CORBA::string_dup(_userId.c_str()); } //============================================================================ @@ -150,20 +309,20 @@ char* SALOMEDS_SimanStudy_i::UserId() //============================================================================ void SALOMEDS_SimanStudy_i::UserId(const char* theId) { - _impl->UserId(theId); + _userId = theId; } - -SALOMEDS_SimanStudy_i* SALOMEDS_SimanStudy_i::GetSimanServant(SALOMEDSImpl_SimanStudy* aSimanImpl, CORBA::ORB_ptr orb) +SALOMEDS_SimanStudy_i* SALOMEDS_SimanStudy_i::GetSimanServant(CORBA::ORB_ptr orb) { static SALOMEDS_SimanStudy_i* aServant = 0; if (aServant == 0) { - aServant = new SALOMEDS_SimanStudy_i(aSimanImpl, orb); + aServant = new SALOMEDS_SimanStudy_i(orb); } return aServant; } /// PRIVATE FUNCTIONS +/* CORBA::LongLong SALOMEDS_SimanStudy_i::GetLocalImpl(const char* theHostname, CORBA::Long thePID, CORBA::Boolean& isLocal) { #ifdef WIN32 @@ -174,3 +333,4 @@ CORBA::LongLong SALOMEDS_SimanStudy_i::GetLocalImpl(const char* theHostname, COR isLocal = (strcmp(theHostname, Kernel_Utils::GetHostname().c_str()) == 0 && pid == thePID)?1:0; return reinterpret_cast(_impl); } +*/ diff --git a/src/SALOMEDS/SALOMEDS_SimanStudy_i.hxx b/src/SALOMEDS/SALOMEDS_SimanStudy_i.hxx index cd894aa47..be8d65ba5 100644 --- a/src/SALOMEDS/SALOMEDS_SimanStudy_i.hxx +++ b/src/SALOMEDS/SALOMEDS_SimanStudy_i.hxx @@ -34,20 +34,26 @@ //SALOMEDS headers #include "SALOMEDS_Study_i.hxx" -class SALOMEDSImpl_SimanStudy; -class SALOMEDSImpl_Study; +class SimanIO_Configuration; class Standard_EXPORT SALOMEDS_SimanStudy_i: public POA_SALOMEDS::SimanStudy { private: CORBA::ORB_var _orb; - SALOMEDSImpl_SimanStudy* _impl; + //SALOMEDSImpl_SimanStudy* _impl; SALOMEDSImpl_Study* _study; + std::string _studyId; // SIMAN ID + std::string _scenarioId; // SIMAN ID + std::string _userId; // SIMAN ID + + SimanIO_Configuration* _checkedOut; // pointer to information about checked out data std::map > _filesId; // map from document id to component identifiers to SIMAN file ID + std::map > _filesId; // map from document id to component identifiers to SIMAN file ID + public: - //! standard constructor - SALOMEDS_SimanStudy_i(SALOMEDSImpl_SimanStudy*, CORBA::ORB_ptr); + //! constructor create global Siman stduy (is called in StudyManager only) + SALOMEDS_SimanStudy_i(/*SALOMEDSImpl_SimanStudy*,*/ CORBA::ORB_ptr); //! standard destructor virtual ~SALOMEDS_SimanStudy_i(); @@ -112,8 +118,8 @@ public: */ virtual void UserId(const char* theId); - virtual CORBA::LongLong GetLocalImpl(const char* theHostname, CORBA::Long thePID, CORBA::Boolean& isLocal); + //virtual CORBA::LongLong GetLocalImpl(const char* theHostname, CORBA::Long thePID, CORBA::Boolean& isLocal); - static SALOMEDS_SimanStudy_i* GetSimanServant(SALOMEDSImpl_SimanStudy*, CORBA::ORB_ptr orb); + static SALOMEDS_SimanStudy_i* GetSimanServant(CORBA::ORB_ptr orb); }; #endif diff --git a/src/SALOMEDS/SALOMEDS_StudyManager.cxx b/src/SALOMEDS/SALOMEDS_StudyManager.cxx index 37fc806dc..80792f822 100644 --- a/src/SALOMEDS/SALOMEDS_StudyManager.cxx +++ b/src/SALOMEDS/SALOMEDS_StudyManager.cxx @@ -328,7 +328,7 @@ SALOMEDS_Driver_i* GetDriver(const SALOMEDSImpl_SObject& theObject, CORBA::ORB_p _PTR(SimanStudy) SALOMEDS_StudyManager::GetSimanStudy() { SALOMEDSClient_SimanStudy* aSiman = NULL; - if (_isLocal) { + /*if (_isLocal) { SALOMEDS::Locker lock; SALOMEDSImpl_SimanStudy* aSiman_impl = _local_impl->GetSimanStudy(); @@ -339,6 +339,9 @@ _PTR(SimanStudy) SALOMEDS_StudyManager::GetSimanStudy() SALOMEDS::SimanStudy_var aSiman_impl = _corba_impl->GetSimanStudy(); if(CORBA::is_nil(aSiman_impl)) return _PTR(SimanStudy)(aSiman); aSiman = new SALOMEDS_SimanStudy(aSiman_impl); - } + }*/ + SALOMEDS::SimanStudy_var aSiman_impl = _corba_impl->GetSimanStudy(); + if(CORBA::is_nil(aSiman_impl)) return _PTR(SimanStudy)(aSiman); + aSiman = new SALOMEDS_SimanStudy(aSiman_impl); return _PTR(SimanStudy)(aSiman); } diff --git a/src/SALOMEDS/SALOMEDS_StudyManager_i.cxx b/src/SALOMEDS/SALOMEDS_StudyManager_i.cxx index 55c6f2bcd..84160f6dd 100644 --- a/src/SALOMEDS/SALOMEDS_StudyManager_i.cxx +++ b/src/SALOMEDS/SALOMEDS_StudyManager_i.cxx @@ -90,6 +90,7 @@ SALOMEDS_StudyManager_i::~SALOMEDS_StudyManager_i() delete _name_service; delete _factory; delete _impl; + delete SALOMEDS_SimanStudy_i::GetSimanServant(_orb); } //============================================================================ @@ -488,9 +489,7 @@ SALOMEDS::SimanStudy_ptr SALOMEDS_StudyManager_i::GetSimanStudy() { SALOMEDS::Locker lock; - SALOMEDSImpl_SimanStudy* aSimanImpl = _impl->GetSimanStudy(); - - SALOMEDS_SimanStudy_i* aSiman_servant = SALOMEDS_SimanStudy_i::GetSimanServant(aSimanImpl, _orb); + SALOMEDS_SimanStudy_i* aSiman_servant = SALOMEDS_SimanStudy_i::GetSimanServant(_orb); return aSiman_servant->_this(); } diff --git a/src/SALOMEDSClient/Makefile.am b/src/SALOMEDSClient/Makefile.am index 7c7140d9d..8a84a1ad2 100644 --- a/src/SALOMEDSClient/Makefile.am +++ b/src/SALOMEDSClient/Makefile.am @@ -88,12 +88,6 @@ COMMON_CPPFLAGS= \ -I$(top_builddir)/idl \ @CORBA_CXXFLAGS@ @CORBA_INCLUDES@ -if WITH_SIMANIO - -COMMON_CPPFLAGS += -DWITH_SIMANIO - -endif - # This local variable defines the list of dependant libraries common to all target in this package. COMMON_LIBS = $(top_builddir)/idl/libSalomeIDLKernel.la diff --git a/src/SALOMEDSClient/SALOMEDSClient.hxx b/src/SALOMEDSClient/SALOMEDSClient.hxx index 0289ab11b..24f6e9654 100644 --- a/src/SALOMEDSClient/SALOMEDSClient.hxx +++ b/src/SALOMEDSClient/SALOMEDSClient.hxx @@ -58,6 +58,7 @@ #include "SALOMEDSClient_GenericAttribute.hxx" #include "SALOMEDSClient_SComponent.hxx" #include "SALOMEDSClient_SComponentIterator.hxx" +#include "SALOMEDSClient_SimanStudy.hxx" #include "SALOMEDSClient_SObject.hxx" #include "SALOMEDSClient_Study.hxx" #include "SALOMEDSClient_StudyBuilder.hxx" @@ -65,8 +66,4 @@ #include "SALOMEDSClient_UseCaseBuilder.hxx" #include "SALOMEDSClient_UseCaseIterator.hxx" -#ifdef WITH_SIMANIO -#include "SALOMEDSClient_SimanStudy.hxx" -#endif - #endif diff --git a/src/SALOMEDSClient/SALOMEDSClient_SimanStudy.hxx b/src/SALOMEDSClient/SALOMEDSClient_SimanStudy.hxx index 456019816..e06093e72 100644 --- a/src/SALOMEDSClient/SALOMEDSClient_SimanStudy.hxx +++ b/src/SALOMEDSClient/SALOMEDSClient_SimanStudy.hxx @@ -52,5 +52,4 @@ public: virtual void UserId(const std::string theId) = 0; }; - #endif diff --git a/src/SALOMEDSImpl/Makefile.am b/src/SALOMEDSImpl/Makefile.am index 34e4dbbb6..4f39f5294 100644 --- a/src/SALOMEDSImpl/Makefile.am +++ b/src/SALOMEDSImpl/Makefile.am @@ -165,8 +165,6 @@ libSalomeDSImpl_la_SOURCES =\ SALOMEDSImpl_TMPFile.cxx \ SALOMEDSImpl_GenericVariable.cxx \ SALOMEDSImpl_ScalarVariable.cxx \ - SALOMEDSImpl_SimanStudy.cxx \ - \ SALOMEDSImpl_AttributeComment.hxx \ SALOMEDSImpl_AttributeDrawable.hxx \ SALOMEDSImpl_AttributeExpandable.hxx \ @@ -208,7 +206,6 @@ libSalomeDSImpl_la_SOURCES =\ SALOMEDSImpl_GenericAttribute.hxx \ SALOMEDSImpl_SComponent.hxx \ SALOMEDSImpl_SComponentIterator.hxx \ - SALOMEDSImpl_SimanStudy.hxx \ SALOMEDSImpl_SObject.hxx \ SALOMEDSImpl_StudyBuilder.hxx \ SALOMEDSImpl_StudyHandle.hxx \ @@ -220,29 +217,6 @@ libSalomeDSImpl_la_SOURCES =\ SALOMEDSImpl_GenericVariable.hxx \ SALOMEDSImpl_ScalarVariable.hxx -if WITH_SIMANIO - -COMMON_CPPFLAGS += -DWITH_SIMANIO @SIMANIO_CPPFLAGS@ -COMMON_LIBS += @SIMANIO_LIBS@ - -################################################################################################### -# VSR: these commands should be removed -# vvv -COMMON_CPPFLAGS += \ - -I$(top_builddir)/idl @CORBA_CXXFLAGS@ @CORBA_INCLUDES@ \ - -I$(srcdir)/../KernelHelpers -I$(srcdir)/../NamingService -I$(srcdir)/../LifeCycleCORBA -I$(srcdir)/../Utils \ - -I$(srcdir)/../Container -I$(srcdir)/../TOOLSDS - -COMMON_LIBS += \ - $(top_builddir)/idl/libSalomeIDLKernel.la \ - ../KernelHelpers/libSalomeKernelHelpers.la ../LifeCycleCORBA/libSalomeLifeCycleCORBA.la \ - ../Container/libSalomeContainer.la ../TOOLSDS/libTOOLSDS.la - -# ^^^ -################################################################################################### - -endif - libSalomeDSImpl_la_CPPFLAGS = $(COMMON_CPPFLAGS) libSalomeDSImpl_la_LDFLAGS = -no-undefined -version-info=0:0:0 libSalomeDSImpl_la_LIBADD = $(COMMON_LIBS) diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_SimanStudy.cxx b/src/SALOMEDSImpl/SALOMEDSImpl_SimanStudy.cxx deleted file mode 100644 index 923ec702b..000000000 --- a/src/SALOMEDSImpl/SALOMEDSImpl_SimanStudy.cxx +++ /dev/null @@ -1,312 +0,0 @@ -// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// 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. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -// File : SALOMEDSImpl_SimanStudy.cxx -// Author : Mikhail PONIKAROV -// Module : SALOME -// -#include "SALOMEDSImpl_SimanStudy.hxx" - -#ifdef WITH_SIMANIO -#include -#include -#include -#include -#include -#include -#include -#endif - -#include -#include CORBA_SERVER_HEADER(SALOME_Component) - -using namespace std; - -//============================================================================ -/*! Function : SALOMEDSImpl_SimanStudy - * Purpose : SALOMEDSImpl_SimanStudy constructor - */ -//============================================================================ -SALOMEDSImpl_SimanStudy::SALOMEDSImpl_SimanStudy() -{ - _study = 0; -#ifdef WITH_SIMANIO - _checkedOut = new SimanIO_Configuration; -#endif -} - -//============================================================================ -/*! Function : ~SALOMEDSImpl_SimanStudy - * Purpose : SALOMEDSImpl_SimanStudy destructor - */ -//============================================================================ -SALOMEDSImpl_SimanStudy::~SALOMEDSImpl_SimanStudy() -{ -#ifdef WITH_SIMANIO - if (_checkedOut) { - SimanIO_Configuration::ActivitiesIterator actIter(*_checkedOut); - for(; actIter.More(); actIter.Next()) { - SimanIO_Activity::DocumentsIterator aDocIter(actIter.Activity()); - for(; aDocIter.More(); aDocIter.Next()) { - const SimanIO_Document& aDoc = aDocIter.Document(); - SimanIO_Document::FilesIterator aFileIter(aDoc); - for(; aFileIter.More(); aFileIter.Next()) { - string aURL = aFileIter.URL(); - string aDir = Kernel_Utils::GetDirName(aURL); - aDir += "/"; - string aFileName = aURL.substr(aDir.size()); - SALOMEDS::ListOfFileNames aTmpFiles; - aTmpFiles.length(1); - aTmpFiles[0] = aFileName.c_str(); - // try to remove temporary directory that contains this file if directory becomes empty - SALOMEDS_Tool::RemoveTemporaryFiles(aDir, aTmpFiles, true); - } - } - } - delete _checkedOut; - } -#endif -} - -//============================================================================ -/*! Function : CheckOut - * Purpose : Fills the referenced study by the SIMAN data - */ -//============================================================================ -void SALOMEDSImpl_SimanStudy::CheckOut(SALOMEDSImpl_Study* theTarget) -{ - _study = theTarget; -#ifdef WITH_SIMANIO - int aLocked = _study->GetProperties()->IsLocked(); - if (aLocked) _study->GetProperties()->SetLocked(false); - - SimanIO_Link aLink(_studyId.c_str(), _scenarioId.c_str(), _userId.c_str()); - if (aLink.IsConnected()) { - // Set "C" locale temporarily to avoid possible localization problems - Kernel_Utils::Localizer loc; - *_checkedOut = aLink.RetrieveConf(); - SimanIO_Configuration::ActivitiesIterator actIter(*_checkedOut); - for(; actIter.More(); actIter.Next()) { - Engines::EngineComponent_var aComp = - KERNEL::getLifeCycleCORBA()->FindOrLoad_Component("FactoryServerPy", actIter.Activity().Module()); - if (CORBA::is_nil(aComp)) // it is not python container, try to find in C++ container - aComp = KERNEL::getLifeCycleCORBA()->FindOrLoad_Component("FactoryServer", actIter.Activity().Module()); - if (CORBA::is_nil(aComp)) { - MESSAGE("Checkout: component "<(); - const SimanIO_Document& aDoc = aDocIter.Document(); - SimanIO_Document::FilesIterator aFileIter(aDoc); - for(; aFileIter.More(); aFileIter.Next()) { - if (aFileIter.GetProcessing() == FILE_IMPORT) { - // files provided by SIMAN will be removed later, on study close - Engines::DataContainer_var aData = (new Engines_DataContainer_i( - aFileIter.URL(), aDoc.Name(), "", false))->_this(); - Engines::ListOfOptions anEmptyOpts; - Engines::ListOfIdentifiers_var anIds = aComp->importData(_study->StudyId(), aData, anEmptyOpts); - for(int anIdNum = 0; anIdNum < anIds->length(); anIdNum++) { - const char* anId = anIds[anIdNum]; - _filesId[aDocIter.DocId()][anId] = aFileIter.Id(); - } - } else { - cout<<"!!! File just downloaded, not imported:"<GetProperties()->SetLocked(true); - -#endif -} - -//============================================================================ -/*! Function : CheckIn - * Purpose : Fills the SIMAN by the SIMAN study data - */ -//============================================================================ -void SALOMEDSImpl_SimanStudy::CheckIn(const std::string theModuleName) -{ -#ifdef WITH_SIMANIO - if (!_study) { - MESSAGE("No siman study defined"); - return; - } - SimanIO_Link aLink(_studyId.c_str(), _scenarioId.c_str(), _userId.c_str()); - if (aLink.IsConnected()) { - // Set "C" locale temporarily to avoid possible localization problems - Kernel_Utils::Localizer loc; - SimanIO_Configuration aToStore; // here create and store data in this configuration to check in to SIMAN - string aTmpDir = SALOMEDS_Tool::GetTmpDir(); // temporary directory for checked in files - int aFileIndex = 0; // for unique file name generation - list aTemporaryFileNames; - SimanIO_Configuration::ActivitiesIterator actIter(*_checkedOut); - for(; actIter.More(); actIter.Next()) { - int aDocId = actIter.Activity().DocumentMaxID(); - //if (aDocId < 0) continue; // no documents => no check in - if (!theModuleName.empty() && theModuleName != actIter.Activity().Module()) { - continue; - } - Engines::EngineComponent_var aComp = - KERNEL::getLifeCycleCORBA()->FindOrLoad_Component("FactoryServerPy", actIter.Activity().Module()); - if (CORBA::is_nil(aComp)) // it is not python container, try to find in C++ container - aComp = KERNEL::getLifeCycleCORBA()->FindOrLoad_Component("FactoryServer", actIter.Activity().Module()); - if (CORBA::is_nil(aComp)) { - MESSAGE("Checkin: component "<getModifiedData(_study->StudyId()); - int aNumData = aList->length(); - for(int aDataIndex = 0; aDataIndex < aNumData; aDataIndex++) { - Engines::DataContainer_var aData = aList[aDataIndex]; - // store this in the configuration - SimanIO_Activity& aStoreActivity = aToStore.GetOrCreateActivity(actIter.ActivityId()); - aStoreActivity.SetName(actIter.Activity().Name()); - aStoreActivity.SetModule(actIter.Activity().Module()); - SimanIO_Document& aStoreDoc = aStoreActivity.GetOrCreateDocument(aDocId); - aStoreDoc.SetName(aDoc.Name()); - // prepare a file to store - SimanIO_File aStoreFile; - - stringstream aNumStore; - aNumStore<<"file"<<(++aFileIndex); - string aFileName(aNumStore.str()); - string anExtension(aData->extension()); - aFileName += "." + anExtension; - string aFullPath = aTmpDir + aFileName; - Engines::TMPFile* aFileStream = aData->get(); - const char *aBuffer = (const char*)aFileStream->NP_data(); -#ifdef WIN32 - std::ofstream aFile(aFullPath.c_str(), std::ios::binary); -#else - std::ofstream aFile(aFullPath.c_str()); -#endif - aFile.write(aBuffer, aFileStream->length()); - aFile.close(); - aTemporaryFileNames.push_back(aFileName); - - aStoreFile.url = aFullPath; - if (_filesId[aDocId].find(aData->identifier()) != _filesId[aDocId].end()) { // file is already exists - aStoreFile.id = _filesId[aDocId][aData->identifier()]; - aStoreFile.result = aDoc.File(aStoreFile.id).result; - } else { - aStoreFile.id = -1; // to be created as new - aStoreFile.result = true; // new is always result - } - - aStoreDoc.AddFile(aStoreFile); - } - } - } - aLink.StoreConf(aToStore); - // after files have been stored, remove them from the temporary directory - SALOMEDS::ListOfFileNames aTmpFiles; - aTmpFiles.length(aTemporaryFileNames.size()); - list::iterator aFilesIter = aTemporaryFileNames.begin(); - for(int a = 0; aFilesIter != aTemporaryFileNames.end(); aFilesIter++, a++) { - aTmpFiles[a] = aFilesIter->c_str(); - } - SALOMEDS_Tool::RemoveTemporaryFiles(aTmpDir, aTmpFiles, true); - } else { - MESSAGE("There is no connection to SIMAN!") - } -#endif -} - -//============================================================================ -/*! Function : getReferencedStudy - * Purpose : - */ -//============================================================================ -SALOMEDSImpl_Study* SALOMEDSImpl_SimanStudy::getReferencedStudy() -{ - return _study; -} - -//============================================================================ -/*! Function : StudyId - * Purpose : - */ -//============================================================================ -std::string SALOMEDSImpl_SimanStudy::StudyId() -{ - return _studyId; -} - -//============================================================================ -/*! Function : StudyId - * Purpose : - */ -//============================================================================ -void SALOMEDSImpl_SimanStudy::StudyId(const std::string theId) -{ - _studyId = theId; -} - -//============================================================================ -/*! Function : ScenarioId - * Purpose : - */ -//============================================================================ -std::string SALOMEDSImpl_SimanStudy::ScenarioId() -{ - return _scenarioId; -} - -//============================================================================ -/*! Function : ScenarioId - * Purpose : - */ -//============================================================================ -void SALOMEDSImpl_SimanStudy::ScenarioId(const std::string theId) -{ - _scenarioId = theId; -} - -//============================================================================ -/*! Function : UserId - * Purpose : - */ -//============================================================================ -std::string SALOMEDSImpl_SimanStudy::UserId() -{ - return _userId; -} - -//============================================================================ -/*! Function : UserId - * Purpose : - */ -//============================================================================ -void SALOMEDSImpl_SimanStudy::UserId(const std::string theId) -{ - _userId = theId; -} diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_SimanStudy.hxx b/src/SALOMEDSImpl/SALOMEDSImpl_SimanStudy.hxx deleted file mode 100644 index 27959f6c9..000000000 --- a/src/SALOMEDSImpl/SALOMEDSImpl_SimanStudy.hxx +++ /dev/null @@ -1,69 +0,0 @@ -// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// 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. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -// File : SALOMEDSImpl_SimanStudy.hxx -// Author : Mikhail PONIKAROV -// Module : SALOME -// -#ifndef __SALOMEDSIMPL_SIMANSTUDY_I_H__ -#define __SALOMEDSIMPL_SIMANSTUDY_I_H__ - -// std C++ headers -#include -#include - -//SALOMEDSImpl headers -#include "SALOMEDSImpl_Defines.hxx" -#include "SALOMEDSImpl_Study.hxx" - -class SimanIO_Configuration; - -class SALOMEDSIMPL_EXPORT SALOMEDSImpl_SimanStudy -{ -private: - SALOMEDSImpl_Study* _study; // referenced study - std::string _studyId; // SIMAN ID - std::string _scenarioId; // SIMAN ID - std::string _userId; // SIMAN ID - - SimanIO_Configuration* _checkedOut; // pointer to information about checked out data - std::map > _filesId; // map from document id to component identifiers to SIMAN file ID - -public: - - virtual void CheckOut(SALOMEDSImpl_Study* theTarget); - virtual void CheckIn(const std::string theModuleName); - virtual SALOMEDSImpl_Study* getReferencedStudy(); - virtual std::string StudyId(); - virtual void StudyId(const std::string theId); - virtual std::string ScenarioId(); - virtual void ScenarioId(const std::string theId); - virtual std::string UserId(); - virtual void UserId(const std::string theId); - - //! standard constructor - SALOMEDSImpl_SimanStudy(); - - //! standard destructor - virtual ~SALOMEDSImpl_SimanStudy(); -}; -#endif diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_StudyManager.cxx b/src/SALOMEDSImpl/SALOMEDSImpl_StudyManager.cxx index e3469514f..01a0e393f 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_StudyManager.cxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_StudyManager.cxx @@ -41,7 +41,6 @@ #include "SALOMEDSImpl_GenericAttribute.hxx" #include "SALOMEDSImpl_ScalarVariable.hxx" #include "SALOMEDSImpl_IParameters.hxx" -#include "SALOMEDSImpl_SimanStudy.hxx" #include @@ -106,7 +105,6 @@ SALOMEDSImpl_StudyManager::SALOMEDSImpl_StudyManager() _appli = new DF_Application(); _IDcounter = 0; _clipboard = _appli->NewDocument("SALOME_STUDY"); - _siman = 0; } //============================================================================ @@ -119,7 +117,6 @@ SALOMEDSImpl_StudyManager::~SALOMEDSImpl_StudyManager() _appli->Close(_clipboard); // Destroy application delete _appli; - if (_siman) delete _siman; } @@ -1570,15 +1567,3 @@ void ReadNoteBookVariables(SALOMEDSImpl_Study* theStudy, HDFgroup* theGroup) theGroup->CloseOnDisk(); } - -//============================================================================ -/*! Function : GetSimanStudy - * Purpose : Retruns the created or cashed SimanStudy - */ -//==================================================T========================== -SALOMEDSImpl_SimanStudy* SALOMEDSImpl_StudyManager::GetSimanStudy() -{ - if (_siman == 0) - _siman = new SALOMEDSImpl_SimanStudy(); - return _siman; -} diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_StudyManager.hxx b/src/SALOMEDSImpl/SALOMEDSImpl_StudyManager.hxx index c3d48aa66..f65863d88 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_StudyManager.hxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_StudyManager.hxx @@ -43,7 +43,6 @@ #include "DF_Document.hxx" class HDFgroup; -class SALOMEDSImpl_SimanStudy; class SALOMEDSIMPL_EXPORT SALOMEDSImpl_StudyManager { @@ -54,7 +53,6 @@ private: int _IDcounter; DF_Document* _clipboard; std::string _errorCode; - SALOMEDSImpl_SimanStudy* _siman; public: @@ -141,9 +139,6 @@ public: std::string GetErrorCode() { return _errorCode; } virtual bool IsError() { return _errorCode != ""; } - //! Retruns the created or cashed SimanStudy - virtual SALOMEDSImpl_SimanStudy* GetSimanStudy(); - }; #endif