1 // File : SALOMEDSImpl_StudyManager.cxx
2 // Author : Sergey RUIN
5 #include "SALOMEDSImpl_StudyManager.hxx"
9 #include <CDF_Session.hxx>
10 #include <CDF_DirectoryIterator.hxx>
11 #include <TDF_Label.hxx>
12 #include <TDF_Tool.hxx>
13 #include <TDF_Data.hxx>
14 #include <TDF_RelocationTable.hxx>
15 #include <TDF_ChildIterator.hxx>
16 #include <TDF_AttributeIterator.hxx>
17 #include <TColStd_HSequenceOfReal.hxx>
18 #include <TColStd_HSequenceOfInteger.hxx>
19 #include <TColStd_HArray1OfCharacter.hxx>
20 #include <TColStd_HSequenceOfAsciiString.hxx>
21 #include <TColStd_HSequenceOfExtendedString.hxx>
22 #include <TCollection_ExtendedString.hxx>
23 #include <OSD_Process.hxx>
24 #include <Quantity_Date.hxx>
25 #include "HDFexplorer.hxx"
27 #include "SALOMEDSImpl_Attributes.hxx"
28 #include "SALOMEDSImpl_Tool.hxx"
29 #include "SALOMEDSImpl_SComponent.hxx"
36 IMPLEMENT_STANDARD_HANDLE( SALOMEDSImpl_StudyManager, MMgt_TShared )
37 IMPLEMENT_STANDARD_RTTIEXT( SALOMEDSImpl_StudyManager, MMgt_TShared )
39 #define USE_CASE_LABEL_ID "0:2"
40 #define AUTO_SAVE_GUID "128268A3-71C9-4036-89B1-F81BD6A4FCF2"
41 #define AUTO_SAVE_TAG "0:8"
42 #define AUTO_SAVE_TIME_OUT_IN_SECONDS 1200
44 static void SaveAttributes(Handle(SALOMEDSImpl_SObject) SO, HDFgroup *hdf_group_sobject);
45 static void ReadAttributes(const Handle(SALOMEDSImpl_Study)&, const Handle(SALOMEDSImpl_SObject)&, HDFdataset* );
46 static void BuildTree (const Handle(SALOMEDSImpl_Study)&, HDFgroup*);
47 static void Translate_IOR_to_persistentID (const Handle(SALOMEDSImpl_SObject)&,
48 SALOMEDSImpl_Driver*, bool isMultiFile, bool isASCII);
50 //============================================================================
51 /*! Function : SALOMEDSImpl_StudyManager
52 * Purpose : SALOMEDSImpl_StudyManager constructor
54 //============================================================================
55 SALOMEDSImpl_StudyManager::SALOMEDSImpl_StudyManager()
58 _OCAFApp = new SALOMEDSImpl_OCAFApplication();
60 _OCAFApp->NewDocument("SALOME_STUDY", _clipboard);
63 //============================================================================
64 /*! Function : ~SALOMEDSImpl_StudyManager
65 * Purpose : SALOMEDSImpl_StudyManager destructor
67 //============================================================================
68 SALOMEDSImpl_StudyManager::~SALOMEDSImpl_StudyManager()
70 // Destroy OCAF application
75 //============================================================================
76 /*! Function : NewStudy
77 * Purpose : Create a New Study of name study_name
79 //==================================================T==========================
80 Handle(SALOMEDSImpl_Study) SALOMEDSImpl_StudyManager::NewStudy(const TCollection_AsciiString& study_name)
84 Handle(TDocStd_Document) Doc;
85 _OCAFApp->NewDocument("SALOME_STUDY",Doc);
87 Handle(SALOMEDSImpl_Study) Study = new SALOMEDSImpl_Study(Doc, study_name);
90 Study->StudyId( _IDcounter );
92 // set Study properties
93 Handle(SALOMEDSImpl_AttributeStudyProperties) aProp = Study->GetProperties();
95 Quantity_Date aDate = aProcess.SystemDate();
96 aProp->SetModification(aProcess.UserName().ToCString(),
97 aDate.Minute(), aDate.Hour(), aDate.Day(), aDate.Month(), aDate.Year());
98 aProp->SetCreationMode(1); //"from scratch"
103 //============================================================================
105 * Purpose : Open a Study from it's persistent reference
107 //============================================================================
108 Handle(SALOMEDSImpl_Study) SALOMEDSImpl_StudyManager::Open(const TCollection_AsciiString& aUrl)
113 HDFfile *hdf_file =0;
114 HDFgroup *hdf_group_study_structure =0;
117 TCollection_AsciiString aHDFUrl;
118 bool isASCII = false;
119 if (HDFascii::isASCII(aUrl.ToCString())) {
121 char* aResultPath = HDFascii::ConvertFromASCIIToHDF(aUrl.ToCString());
122 aC_HDFUrl = new char[strlen(aResultPath) + 19];
123 sprintf(aC_HDFUrl, "%shdf_from_ascii.hdf", aResultPath);
131 hdf_file = new HDFfile((char*)aHDFUrl.ToCString());
133 hdf_file->OpenOnDisk(HDF_RDONLY);// mpv: was RDWR, but opened file can be write-protected too
138 char eStr[strlen(aUrl.ToCString())+17];
141 eStr = new char[strlen(aUrl.ToCString())+17];
143 sprintf(eStr,"Can't open file %s",aUrl.ToCString());
147 _errorCode = TCollection_AsciiString(eStr);
151 // Temporary aStudyUrl in place of study name
152 Handle(TDocStd_Document) Doc;
153 _OCAFApp->NewDocument("SALOME_STUDY",Doc);
155 Handle(SALOMEDSImpl_Study) Study = new SALOMEDSImpl_Study(Doc, aUrl);
158 Study->StudyId( _IDcounter );
160 // Assign the value of the URL in the study object
163 SALOMEDSImpl_AttributePersistentRef::Set(Doc->Main(), aUrl);
165 if (!hdf_file->ExistInternalObject("STUDY_STRUCTURE")) {
166 _errorCode = "Study is empty";
170 //Create the Structure of the OCAF Document
171 hdf_group_study_structure = new HDFgroup("STUDY_STRUCTURE",hdf_file);
173 Handle(TDF_Data) DF = Doc->GetData();
175 BuildTree (Study, hdf_group_study_structure);
180 char eStr[strlen(aUrl.ToCString())+17];
182 char *eStr = new char [strlen(aUrl.ToCString())+17];
184 sprintf(eStr,"Can't open file %s", aUrl.ToCString());
185 _errorCode = TCollection_AsciiString(eStr);
189 hdf_file->CloseOnDisk();
192 Handle(TColStd_HSequenceOfAsciiString) aFilesToRemove = new TColStd_HSequenceOfAsciiString;
193 aFilesToRemove->Append(aHDFUrl);
194 SALOMEDSImpl_Tool::RemoveTemporaryFiles(SALOMEDSImpl_Tool::GetDirFromPath(aHDFUrl), aFilesToRemove, true);
197 delete hdf_file; // all related hdf objects will be deleted
204 //============================================================================
206 * Purpose : Close a study.
207 * If the study hasn't been saved, ask the user to confirm the
208 * close action without saving
211 //============================================================================
212 void SALOMEDSImpl_StudyManager::Close(const Handle(SALOMEDSImpl_Study)& aStudy)
216 if(aStudy.IsNull()) {
217 _errorCode = "Study is null";
224 //============================================================================
226 * Purpose : Save a Study to it's persistent reference
228 //============================================================================
229 bool SALOMEDSImpl_StudyManager::Save(const Handle(SALOMEDSImpl_Study)& aStudy,
230 SALOMEDSImpl_DriverFactory* aFactory,
235 TCollection_AsciiString url = aStudy->URL();
237 _errorCode = "No path specified to save the study. Nothing done";
241 return Impl_SaveAs(url,aStudy, aFactory, theMultiFile, false);
247 bool SALOMEDSImpl_StudyManager::SaveASCII(const Handle(SALOMEDSImpl_Study)& aStudy,
248 SALOMEDSImpl_DriverFactory* aFactory,
253 TCollection_AsciiString url = aStudy->URL();
255 _errorCode = "No path specified to save the study. Nothing done";
259 return Impl_SaveAs(url,aStudy, aFactory, theMultiFile, true);
265 //=============================================================================
266 /*! Function : SaveAs
267 * Purpose : Save a study to the persistent reference aUrl
269 //============================================================================
270 bool SALOMEDSImpl_StudyManager::SaveAs(const TCollection_AsciiString& aUrl,
271 const Handle(SALOMEDSImpl_Study)& aStudy,
272 SALOMEDSImpl_DriverFactory* aFactory,
276 return Impl_SaveAs(aUrl,aStudy, aFactory, theMultiFile, false);
279 bool SALOMEDSImpl_StudyManager::SaveAsASCII(const TCollection_AsciiString& aUrl,
280 const Handle(SALOMEDSImpl_Study)& aStudy,
281 SALOMEDSImpl_DriverFactory* aFactory,
285 return Impl_SaveAs(aUrl,aStudy, aFactory, theMultiFile, true);
288 //============================================================================
289 /*! Function : GetOpenStudies
290 * Purpose : Get name list of open studies in the session
292 //============================================================================
293 Handle(TColStd_HSequenceOfTransient) SALOMEDSImpl_StudyManager::GetOpenStudies()
296 Handle(TColStd_HSequenceOfTransient) aList = new TColStd_HSequenceOfTransient;
298 int nbDocs = _OCAFApp->NbDocuments();
301 _errorCode = "No active study in this session";
305 Handle(SALOMEDSImpl_Study) aStudy;
306 Handle(CDF_Session) S = CDF_Session::CurrentSession();
307 CDF_DirectoryIterator it (S->Directory());
308 for (;it.MoreDocument();it.NextDocument()) {
309 Handle(TDocStd_Document) D = Handle(TDocStd_Document)::DownCast(it.Document());
310 if(D == _clipboard) continue;
311 aStudy = SALOMEDSImpl_Study::GetStudy(D->Main());
312 if(aStudy.IsNull()) continue;
313 aList->Append(aStudy);
320 //============================================================================
321 /*! Function : GetStudyByName
322 * Purpose : Get a study from its name
324 //============================================================================
325 Handle(SALOMEDSImpl_Study) SALOMEDSImpl_StudyManager::GetStudyByName
326 (const TCollection_AsciiString& aStudyName)
329 int nbDocs = _OCAFApp->NbDocuments();
332 _errorCode = "No active study in this session";
336 Handle(SALOMEDSImpl_Study) aStudy;
337 Handle(CDF_Session) S = CDF_Session::CurrentSession();
338 CDF_DirectoryIterator it (S->Directory());
339 for (; it.MoreDocument(); it.NextDocument()) {
340 Handle(TDocStd_Document) D = Handle(TDocStd_Document)::DownCast(it.Document());
341 if (D == _clipboard) continue;
342 aStudy = SALOMEDSImpl_Study::GetStudy(D->Main());
343 if (aStudy.IsNull()) continue;
344 if (aStudy->Name() == aStudyName) return aStudy;
348 _errorCode = TCollection_AsciiString("Found no study with the name ") + aStudyName;
352 //============================================================================
353 /*! Function : GetStudyByID
354 * Purpose : Get a study from its ID
356 //============================================================================
357 Handle(SALOMEDSImpl_Study) SALOMEDSImpl_StudyManager::GetStudyByID(int aStudyID)
360 int nbDocs = _OCAFApp->NbDocuments();
363 _errorCode = "No active study in this session";
367 Handle(SALOMEDSImpl_Study) aStudy;
368 Handle(CDF_Session) S = CDF_Session::CurrentSession();
369 CDF_DirectoryIterator it (S->Directory());
370 for (; it.MoreDocument(); it.NextDocument()) {
371 Handle(TDocStd_Document) D = Handle(TDocStd_Document)::DownCast(it.Document());
372 if (D == _clipboard) continue;
373 aStudy = SALOMEDSImpl_Study::GetStudy(D->Main());
374 if (aStudy.IsNull()) continue;
375 if (aStudy->StudyId() == aStudyID) return aStudy;
379 _errorCode = "Found no study with the given ID";
383 //=============================================================================
384 /*! Function : _SaveProperties
385 * Purpose : save the study properties in HDF file
387 //============================================================================
388 bool SALOMEDSImpl_StudyManager::Impl_SaveProperties(const Handle(SALOMEDSImpl_Study)& aStudy,
393 HDFdataset *hdf_dataset = 0;
397 // add modifications list (user and date of save)
398 Handle(SALOMEDSImpl_AttributeStudyProperties) aProp = aStudy->GetProperties();
399 Handle(SALOMEDSImpl_StudyBuilder) SB= aStudy->NewBuilder();
400 int aLocked = aProp->IsLocked();
401 if (aLocked) aProp->SetLocked(Standard_False);
403 OSD_Process aProcess;
404 Quantity_Date aDate = aProcess.SystemDate();
405 aProp->SetModification(aProcess.UserName().ToCString(),
406 aDate.Minute(), aDate.Hour(), aDate.Day(), aDate.Month(), aDate.Year());
408 if (aLocked) aProp->SetLocked(Standard_True);
410 Handle(TColStd_HSequenceOfExtendedString) aNames;
411 Handle(TColStd_HSequenceOfInteger) aMinutes, aHours, aDays, aMonths, aYears;
413 aProp->GetModifications(aNames, aMinutes, aHours, aDays, aMonths, aYears);
415 int aLength = 0, anIndex, i;
416 for(i=1; i<=aNames->Length(); i++)
417 aLength += aNames->Value(i).Length() + 1;
419 //string length: 1 byte = locked flag, 1 byte = modified flag, (12 + name length + 1) for each name and date, "zero" byte
420 char* aProperty = new char[3 + aLength + 12 * aNames->Length()];
423 sprintf(aProperty,"%c%c", (char)aProp->GetCreationMode(), (aProp->IsLocked())?'l':'u');
425 aLength = aNames->Length();
427 for(anIndex = 1; anIndex <= aLength; anIndex++) {
428 sprintf(&(aProperty[a]),"%2d%2d%2d%2d%4d%s",
429 (int)(aMinutes->Value(anIndex)),
430 (int)(aHours->Value(anIndex)),
431 (int)(aDays->Value(anIndex)),
432 (int)(aMonths->Value(anIndex)),
433 (int)(aYears->Value(anIndex)),
434 TCollection_AsciiString(aNames->Value(anIndex)).ToCString());
435 a = strlen(aProperty);
440 name_len = (hdf_int32) a;
441 size[0] = name_len + 1 ;
442 hdf_dataset = new HDFdataset("AttributeStudyProperties",hdf_group,HDF_STRING,size,1);
443 hdf_dataset->CreateOnDisk();
444 hdf_dataset->WriteOnDisk(aProperty);
445 hdf_dataset->CloseOnDisk();
446 hdf_dataset=0; //will be deleted by hdf_sco_group destructor
449 aProp->SetModified(0);
453 //=============================================================================
454 /*! Function : _SaveAs
455 * Purpose : save the study in HDF file
457 //============================================================================
458 bool SALOMEDSImpl_StudyManager::Impl_SaveAs(const TCollection_AsciiString& aUrl,
459 const Handle(SALOMEDSImpl_Study)& aStudy,
460 SALOMEDSImpl_DriverFactory* aFactory,
464 // HDF File will be composed of differents part :
465 // * For each ComponentDataType, all data created by the component
466 // Informations in data group hdf_group_datacomponent
467 // * Study Structure -> Exactly what is contained in OCAF document
468 // Informations in data group hdf_group_study_structure
473 HDFgroup *hdf_group_study_structure =0;
474 HDFgroup *hdf_sco_group =0;
475 HDFgroup *hdf_sco_group2 =0;
477 HDFgroup *hdf_group_datacomponent =0;
478 HDFdataset *hdf_dataset =0;
480 hdf_int32 name_len = 0;
481 char *component_name = 0;
483 int aLocked = aStudy->GetProperties()->IsLocked();
484 if (aLocked) aStudy->GetProperties()->SetLocked(false);
486 Handle(SALOMEDSImpl_StudyBuilder) SB= aStudy->NewBuilder();
487 map<char*, SALOMEDSImpl_Driver*> aMapTypeDriver;
489 if(aStudy.IsNull()) {
490 _errorCode = "Study is null";
496 // mpv 15.12.2003: for saving components we have to load all data from all modules
497 SALOMEDSImpl_SComponentIterator itcomponent1 = aStudy->NewComponentIterator();
498 for (; itcomponent1.More(); itcomponent1.Next())
500 Handle(SALOMEDSImpl_SComponent) sco = itcomponent1.Value();
502 // if there is an associated Engine call its method for saving
503 TCollection_AsciiString IOREngine;
505 if (!sco->ComponentIOR(IOREngine)) {
506 TCollection_AsciiString aCompType = sco->GetComment();
507 if (!aCompType.IsEmpty()) {
509 SALOMEDSImpl_Driver* aDriver = aFactory->GetDriverByType(aCompType);
510 aMapTypeDriver[aCompType.ToCString()] = aDriver;
512 if (aDriver != NULL) {
513 if(!SB->LoadWith(sco, aDriver)) {
514 _errorCode = SB->GetErrorCode();
521 _errorCode = "Can not restore information to resave it";
526 TCollection_AsciiString anOldName = aStudy->Name();
529 // To change for Save
530 // Do not have to do a new file but just a Open??? Rewrite all informations after erasing evrything??
531 hdf_file = new HDFfile(aUrl.ToCString());
532 hdf_file->CreateOnDisk();
534 //-----------------------------------------------------------------------
535 // 1 - Create a groupe for each SComponent and Update the PersistanceRef
536 //-----------------------------------------------------------------------
537 hdf_group_datacomponent = new HDFgroup("DATACOMPONENT",hdf_file);
538 hdf_group_datacomponent->CreateOnDisk();
540 SALOMEDSImpl_SComponentIterator itcomponent = aStudy->NewComponentIterator();
542 //SRN: Added 17 Nov, 2003
543 Handle(SALOMEDSImpl_SObject) anAutoSaveSO = aStudy->FindObjectID(AUTO_SAVE_TAG);
545 for (; itcomponent.More(); itcomponent.Next())
547 Handle(SALOMEDSImpl_SComponent) sco = itcomponent.Value();
549 TCollection_AsciiString scoid = sco->GetID();
550 hdf_sco_group = new HDFgroup(scoid.ToCString(), hdf_group_datacomponent);
551 hdf_sco_group->CreateOnDisk();
553 TCollection_AsciiString componentDataType = sco->ComponentDataType();
555 //SRN: Added 17 Nov 2003: If there is a specified attribute, the component peforms a special save
556 if(!anAutoSaveSO.IsNull() && SB->IsGUID(sco, AUTO_SAVE_GUID)) {
558 Handle(SALOMEDSImpl_AttributeTableOfString) aTable;
559 if(anAutoSaveSO->GetLabel().FindAttribute(SALOMEDSImpl_AttributeTableOfString::GetID(), aTable)) {
560 Standard_Integer nbRows = aTable->GetNbRows(), k, aTimeOut = 0;
561 if(nbRows > 0 && aTable->GetNbColumns() > 1) {
563 Handle(TColStd_HSequenceOfExtendedString) aRow;
564 for(k=1; k<=nbRows; k++) {
565 aRow = aTable->GetRowData(k);
566 if (aRow->Value(1) == componentDataType) {
567 TCollection_AsciiString anEntry = TCollection_AsciiString(aRow->Value(2));
568 Handle(SALOMEDSImpl_SObject) aCompSpecificSO = aStudy->FindObjectID(anEntry);
569 if(!aCompSpecificSO.IsNull()) {
570 Handle(SALOMEDSImpl_AttributeInteger) anInteger;
571 if(aCompSpecificSO->GetLabel().FindAttribute(SALOMEDSImpl_AttributeInteger::GetID(), anInteger)) {
572 anInteger->SetValue(-1);
573 while(anInteger->Value() < 0) {
579 if(++aTimeOut > AUTO_SAVE_TIME_OUT_IN_SECONDS)
582 } // if(aCompSpecificSO->FindAttribute(anInteger, "AttributeInteger"))
583 } // if(!CORBA::is_nil(aCompSpecificSO))
584 } // if (strcmp(aRow[0], componentDataType) == 0)
587 } // if(nbRows > 0 && aTable->GetNbColumns() > 1)
589 } // if(anAutoSaveSO->FindAttribute(aTable, "AttributeTableOfString")
591 } // if(SB->IsGUID(AUTO_SAVE_GUID)
594 TCollection_AsciiString IOREngine;
595 if (sco->ComponentIOR(IOREngine))
597 SALOMEDSImpl_Driver* Engine = NULL;
598 if(aMapTypeDriver.find(componentDataType.ToCString()) != aMapTypeDriver.end()) {
599 // we have found the associated engine to write the data
600 Engine = aMapTypeDriver[componentDataType.ToCString()];
603 Engine = aFactory->GetDriverByIOR(IOREngine);
608 unsigned char* aStream;
611 if (theASCII) aStream = Engine->SaveASCII(sco,
612 SALOMEDSImpl_Tool::GetDirFromPath(aUrl),
615 else aStream = Engine->Save(sco,
616 SALOMEDSImpl_Tool::GetDirFromPath(aUrl),
619 HDFdataset *hdf_dataset;
620 hdf_size aHDFSize[1];
621 if(length > 0) { //The component saved some auxiliary files, then put them into HDF file
623 aHDFSize[0] = length;
625 HDFdataset *hdf_dataset = new HDFdataset("FILE_STREAM", hdf_sco_group, HDF_STRING, aHDFSize, 1);
626 hdf_dataset->CreateOnDisk();
627 hdf_dataset->WriteOnDisk(aStream); //Save the stream in the HDF file
628 hdf_dataset->CloseOnDisk();
631 // store multifile state
633 hdf_dataset = new HDFdataset("MULTIFILE_STATE", hdf_sco_group, HDF_STRING, aHDFSize, 1);
634 hdf_dataset->CreateOnDisk();
635 hdf_dataset->WriteOnDisk((void*)(theMultiFile?"M":"S")); // save: multi or single
636 hdf_dataset->CloseOnDisk();
637 hdf_dataset=0; //will be deleted by hdf_sco_AuxFiles destructor
640 hdf_dataset = new HDFdataset("ASCII_STATE", hdf_sco_group, HDF_STRING, aHDFSize, 1);
641 hdf_dataset->CreateOnDisk();
642 hdf_dataset->WriteOnDisk((void*)(theASCII?"A":"B")); // save: ASCII or BINARY
643 hdf_dataset->CloseOnDisk();
644 hdf_dataset=0; //will be deleted by hdf_sco_AuxFiles destructor
645 // Creation of the persistance reference attribute
646 Translate_IOR_to_persistentID (sco, Engine, theMultiFile, theASCII);
648 if(aStream != NULL) delete [] aStream;
651 hdf_sco_group->CloseOnDisk();
652 hdf_sco_group=0; // will be deleted by hdf_group_datacomponent destructor
654 hdf_group_datacomponent->CloseOnDisk();
655 hdf_group_datacomponent =0; // will be deleted by hdf_file destructor
657 //-----------------------------------------------------------------------
658 //3 - Write the Study Structure
659 //-----------------------------------------------------------------------
660 hdf_group_study_structure = new HDFgroup("STUDY_STRUCTURE",hdf_file);
661 hdf_group_study_structure->CreateOnDisk();
662 // save component attributes
663 SALOMEDSImpl_SComponentIterator itcomp = aStudy->NewComponentIterator();
664 for (; itcomp.More(); itcomp.Next())
666 Handle(SALOMEDSImpl_SComponent) SC = itcomp.Value();
667 TCollection_AsciiString scid = SC->GetID();
668 hdf_sco_group2 = new HDFgroup(scid.ToCString(), hdf_group_study_structure);
669 hdf_sco_group2->CreateOnDisk();
670 SaveAttributes(SC, hdf_sco_group2);
671 // ComponentDataType treatment
672 component_name = SC->ComponentDataType().ToCString();
673 name_len = (hdf_int32)strlen(component_name);
674 size[0] = name_len +1 ;
675 hdf_dataset = new HDFdataset("COMPONENTDATATYPE",hdf_sco_group2,HDF_STRING,size,1);
676 hdf_dataset->CreateOnDisk();
677 hdf_dataset->WriteOnDisk(component_name);
678 hdf_dataset->CloseOnDisk();
679 hdf_dataset=0; //will be deleted by hdf_sco_group destructor
680 Impl_SaveObject(SC, hdf_sco_group2);
681 hdf_sco_group2->CloseOnDisk();
682 hdf_sco_group2=0; // will be deleted by hdf_group_study_structure destructor
685 //-----------------------------------------------------------------------
686 //4 - Write the Study UseCases Structure
687 //-----------------------------------------------------------------------
688 Handle(SALOMEDSImpl_SObject) aSO = aStudy->FindObjectID(USE_CASE_LABEL_ID);
690 HDFgroup *hdf_soo_group = new HDFgroup(USE_CASE_LABEL_ID,hdf_group_study_structure);
691 hdf_soo_group->CreateOnDisk();
692 SaveAttributes(aSO, hdf_soo_group);
693 Impl_SaveObject(aSO, hdf_soo_group);
694 hdf_soo_group->CloseOnDisk();
695 hdf_soo_group=0; // will be deleted by hdf_group_study_structure destructor
698 if (aLocked) aStudy->GetProperties()->SetLocked(true);
699 //-----------------------------------------------------------------------
700 //5 - Write the Study Properties
701 //-----------------------------------------------------------------------
702 name_len = (hdf_int32) aStudy->Name().Length();
703 size[0] = name_len +1 ;
704 hdf_dataset = new HDFdataset("STUDY_NAME",hdf_group_study_structure,HDF_STRING,size,1);
705 hdf_dataset->CreateOnDisk();
706 char* studid = aStudy->Name().ToCString();
707 hdf_dataset->WriteOnDisk(studid);
708 hdf_dataset->CloseOnDisk();
709 hdf_dataset=0; // will be deleted by hdf_group_study_structure destructor
711 Impl_SaveProperties(aStudy, hdf_group_study_structure);
713 hdf_group_study_structure->CloseOnDisk();
714 hdf_file->CloseOnDisk();
716 aStudy->IsSaved(true);
717 hdf_group_study_structure =0; // will be deleted by hdf_file destructor
718 delete hdf_file; // recursively deletes all hdf objects...
722 _errorCode = "HDFexception ! ";
725 if (theASCII) { // save file in ASCII format
726 HDFascii::ConvertFromHDFToASCII(aUrl.ToCString(), true);
732 //============================================================================
733 /*! Function : Impl_SaveObject
736 //============================================================================
737 bool SALOMEDSImpl_StudyManager::Impl_SaveObject(const Handle(SALOMEDSImpl_SObject)& SC,
738 HDFgroup *hdf_group_datatype)
742 // Write in group hdf_group_datatype all informations of SObject SC
743 // Iterative function to parse all SObjects under a SComponent
745 HDFgroup *hdf_group_sobject = 0;
747 TDF_ChildIterator itchild(SC->GetLabel());
748 for (; itchild.More(); itchild.Next())
751 // mpv: don't save empty labels
752 TDF_AttributeIterator AI1(itchild.Value());
753 if (!AI1.More()) { //No attributes on the label
754 TDF_ChildIterator subchild(SC->GetLabel());
755 if (!subchild.More()) {
758 subchild.Initialize(SC->GetLabel(), true);
760 for (; subchild.More() && anEmpty; subchild.Next()) {
761 TDF_AttributeIterator AI2(subchild.Value());
762 if (AI2.More()) anEmpty = false; //There are attributes on the child label
764 if (anEmpty) continue;
767 Handle(SALOMEDSImpl_SObject) SO = SALOMEDSImpl_Study::SObject(itchild.Value());
769 char* scoid = (char*) SO->GetID().ToCString();
770 hdf_group_sobject = new HDFgroup(scoid, hdf_group_datatype);
771 hdf_group_sobject->CreateOnDisk();
772 SaveAttributes(SO, hdf_group_sobject);
773 Impl_SaveObject(SO, hdf_group_sobject);
774 hdf_group_sobject->CloseOnDisk();
775 hdf_group_sobject =0; // will be deleted by father hdf object destructor
781 //============================================================================
782 /*! Function : Impl_SubstituteSlash
785 //============================================================================
786 TCollection_AsciiString SALOMEDSImpl_StudyManager::Impl_SubstituteSlash(const TCollection_AsciiString& aUrl)
790 TCollection_ExtendedString theUrl(aUrl);
791 Standard_ExtCharacter val1 = ToExtCharacter('/');
792 Standard_ExtCharacter val2 = ToExtCharacter(':');
793 theUrl.ChangeAll(val1,val2);
797 //============================================================================
798 /*! Function : GetDocumentOfStudy
801 //============================================================================
802 Handle(TDocStd_Document) SALOMEDSImpl_StudyManager::GetDocumentOfStudy(const Handle(SALOMEDSImpl_Study)& theStudy)
805 return theStudy->_doc;
808 //============================================================================
809 /*! Function : CanCopy
812 //============================================================================
813 bool SALOMEDSImpl_StudyManager::CanCopy(const Handle(SALOMEDSImpl_SObject)& theObject,
814 SALOMEDSImpl_Driver* theEngine)
817 Handle(SALOMEDSImpl_SComponent) aComponent = theObject->GetFatherComponent();
818 if (aComponent.IsNull()) return false;
819 if (aComponent->GetLabel() == theObject->GetLabel()) return false;
820 TCollection_AsciiString IOREngine;
821 if (!aComponent->ComponentIOR(IOREngine)) return false;
822 if (theEngine == NULL) return false;
823 return theEngine->CanCopy(theObject);
826 //============================================================================
827 /*! Function : CopyLabel
830 //============================================================================
831 bool SALOMEDSImpl_StudyManager::CopyLabel(const Handle(SALOMEDSImpl_Study)& theSourceStudy,
832 SALOMEDSImpl_Driver* theEngine,
833 const Standard_Integer theSourceStartDepth,
834 const TDF_Label& theSource,
835 const TDF_Label& theDestinationMain)
840 TDF_Label aTargetLabel = theDestinationMain;
841 TDF_Label aAuxTargetLabel = theDestinationMain.Father().FindChild(2);
842 for(a = theSource.Depth() - theSourceStartDepth; a > 0 ; a--) {
843 TDF_Label aSourceLabel = theSource;
844 for(int aNbFather = 1; aNbFather < a; aNbFather++) aSourceLabel = aSourceLabel.Father();
845 aTargetLabel = aTargetLabel.FindChild(aSourceLabel.Tag());
846 aAuxTargetLabel = aAuxTargetLabel.FindChild(aSourceLabel.Tag());
848 // iterate attributes
849 TDF_AttributeIterator anAttrIterator(theSource);
850 Handle(TDF_RelocationTable) aRT = new TDF_RelocationTable();
851 for(; anAttrIterator.More(); anAttrIterator.Next()) {
852 Handle(TDF_Attribute) anAttr = anAttrIterator.Value();
853 if (!Handle(SALOMEDSImpl_AttributeTreeNode)::DownCast(anAttr).IsNull()) continue; // never copy tree node attribute
854 if (!Handle(SALOMEDSImpl_AttributeTarget)::DownCast(anAttr).IsNull()) continue; // and target attribute
856 if (!Handle(SALOMEDSImpl_AttributeReference)::DownCast(anAttr).IsNull()) { // reference copied as Comment in aux tree
857 TDF_Label aReferenced = Handle(SALOMEDSImpl_AttributeReference)::DownCast(anAttr)->Get();
858 TCollection_AsciiString anEntry;
859 TDF_Tool::Entry(aReferenced, anEntry);
860 // store the value of name attribute of referenced label
861 Handle(SALOMEDSImpl_AttributeName) aNameAttribute;
862 if (aReferenced.FindAttribute(SALOMEDSImpl_AttributeName::GetID(), aNameAttribute)) {
864 anEntry += aNameAttribute->Value();
866 SALOMEDSImpl_AttributeComment::Set(aAuxTargetLabel, TCollection_ExtendedString(anEntry));
870 if (!Handle(SALOMEDSImpl_AttributeIOR)::DownCast(anAttr).IsNull()) { // IOR => ID and TMPFile of Engine
871 TCollection_AsciiString anEntry;
872 TDF_Tool::Entry(theSource, anEntry);
873 Handle(SALOMEDSImpl_SObject) aSO = theSourceStudy->FindObjectID(anEntry.ToCString());
876 unsigned char* aStream = theEngine->CopyFrom(aSO, anObjID, aLen);
877 TCollection_ExtendedString aResStr("");
878 for(a = 0; a < aLen; a++) {
879 aResStr += TCollection_ExtendedString(ToExtCharacter((Standard_Character)aStream[a]));
881 if(aStream != NULL) delete [] aStream;
882 SALOMEDSImpl_AttributeInteger::Set(aAuxTargetLabel, anObjID);
883 SALOMEDSImpl_AttributeName::Set(aAuxTargetLabel, aResStr);
886 Handle(TDF_Attribute) aNewAttribute = anAttr->NewEmpty();
887 aTargetLabel.AddAttribute(aNewAttribute);
888 anAttr->Paste(aNewAttribute, aRT);
894 //============================================================================
898 //============================================================================
899 bool SALOMEDSImpl_StudyManager::Copy(const Handle(SALOMEDSImpl_SObject)& theObject,
900 SALOMEDSImpl_Driver* theEngine)
904 // adoptation for alliances datamodel copy: without IOR attributes !!!
905 bool aStructureOnly; // copy only SObjects and attributes without component help
906 aStructureOnly = !theObject->GetLabel().IsAttribute(SALOMEDSImpl_AttributeIOR::GetID());
908 // get component-engine
909 Handle(SALOMEDSImpl_Study) aStudy = theObject->GetStudy();
911 // CAF document of current study usage
912 Handle(TDocStd_Document) aDocument = GetDocumentOfStudy(aStudy);
913 if (aDocument.IsNull()) {
914 _errorCode = "OCAF document is null";
918 //Clear the clipboard
919 _clipboard->Main().Root().ForgetAllAttributes(Standard_True);
920 _OCAFApp->Close(_clipboard);
921 Handle(TDocStd_Document) aDoc;
922 _OCAFApp->NewDocument("SALOME_STUDY", aDoc);
925 // set component data type to the name attribute of root label
926 if (!aStructureOnly) {
927 SALOMEDSImpl_AttributeComment::Set(_clipboard->Main().Root(),
928 TCollection_ExtendedString(theEngine->ComponentDataType()));
930 // set to the Root label integer attribute: study id
931 SALOMEDSImpl_AttributeInteger::Set(_clipboard->Main().Root(), aStudy->StudyId());
932 // iterate all theObject's label children
933 TDF_Label aStartLabel = theObject->GetLabel();
934 Standard_Integer aSourceStartDepth = aStartLabel.Depth();
936 // copy main source label
937 CopyLabel(aStudy, theEngine, aSourceStartDepth, aStartLabel, _clipboard->Main());
939 // copy all subchildren of the main source label (all levels)
940 TDF_ChildIterator anIterator(aStartLabel, Standard_True);
941 for(; anIterator.More(); anIterator.Next()) {
942 CopyLabel(aStudy, theEngine, aSourceStartDepth, anIterator.Value(), _clipboard->Main());
947 //============================================================================
948 /*! Function : CanPaste
951 //============================================================================
952 bool SALOMEDSImpl_StudyManager::CanPaste(const Handle(SALOMEDSImpl_SObject)& theObject,
953 SALOMEDSImpl_Driver* theEngine)
957 if (_clipboard.IsNull()) {
958 _errorCode = "Clipboard is null";
962 Handle(SALOMEDSImpl_AttributeComment) aCompName;
963 if (!_clipboard->Main().Root().FindAttribute(SALOMEDSImpl_AttributeComment::GetID(), aCompName)) {
964 _errorCode = "Clipboard has no component type";
967 Handle(SALOMEDSImpl_AttributeInteger) anObjID;
968 if (!_clipboard->Main().Father().FindChild(2).FindAttribute(SALOMEDSImpl_AttributeInteger::GetID(), anObjID)) {
969 _errorCode = "Clipboard has no object id";
972 Handle(SALOMEDSImpl_SComponent) aComponent = theObject->GetFatherComponent();
973 if (aComponent.IsNull()) {
974 _errorCode = "Object doesn't belong to component";
978 TCollection_AsciiString IOREngine;
979 if (!aComponent->ComponentIOR(IOREngine)) {
980 _errorCode = "component has no IOR";
983 return theEngine->CanPaste(aCompName->Value(), anObjID->Value());
986 //============================================================================
987 /*! Function : PasteLabel
990 //============================================================================
991 TDF_Label SALOMEDSImpl_StudyManager::PasteLabel(const Handle(SALOMEDSImpl_Study)& theDestinationStudy,
992 SALOMEDSImpl_Driver* theEngine,
993 const TDF_Label& theSource,
994 const TDF_Label& theDestinationStart,
995 const int theCopiedStudyID,
996 const bool isFirstElement)
1000 // get corresponding source, target and auxiliary labels
1001 TDF_Label aTargetLabel = theDestinationStart;
1003 TDF_Label aAuxSourceLabel = theSource.Root().FindChild(2);
1005 if (!isFirstElement) {
1006 for(a = theSource.Depth() - 1; a > 0 ; a--) {
1007 TDF_Label aSourceLabel = theSource;
1008 for(int aNbFather = 1; aNbFather < a; aNbFather++) aSourceLabel = aSourceLabel.Father();
1009 aTargetLabel = aTargetLabel.FindChild(aSourceLabel.Tag());
1010 aAuxSourceLabel = aAuxSourceLabel.FindChild(aSourceLabel.Tag());
1014 // check auxiliary label for TMPFile => IOR
1015 Handle(SALOMEDSImpl_AttributeName) aNameAttribute;
1016 if (aAuxSourceLabel.FindAttribute(SALOMEDSImpl_AttributeName::GetID(), aNameAttribute)) {
1017 Handle(SALOMEDSImpl_AttributeInteger) anObjID;
1019 aAuxSourceLabel.FindAttribute(SALOMEDSImpl_AttributeInteger::GetID(), anObjID);
1020 Handle(SALOMEDSImpl_AttributeComment) aComponentName;
1021 theSource.Root().FindAttribute(SALOMEDSImpl_AttributeComment::GetID(), aComponentName);
1022 TCollection_AsciiString aCompName = aComponentName->Value();
1024 if (theEngine->CanPaste(aCompName, anObjID->Value())) {
1025 TCollection_ExtendedString aTMPStr = aNameAttribute->Value();
1026 int aLen = aTMPStr.Length();
1027 unsigned char* aStream = NULL;
1029 aStream = new unsigned char[aLen+10];
1030 for(a = 0; a < aLen; a++) {
1031 aStream[a] = ToCharacter(aTMPStr.Value(a+1));
1035 TCollection_AsciiString anEntry;
1036 TDF_Tool::Entry(aTargetLabel, anEntry);
1037 Handle(SALOMEDSImpl_SObject) aPastedSO = theDestinationStudy->FindObjectID(anEntry);
1039 if (isFirstElement) {
1040 TCollection_AsciiString aDestEntry = theEngine->PasteInto(aStream,
1043 aPastedSO->GetFatherComponent());
1044 TDF_Tool::Label(theDestinationStart.Data(), aDestEntry, aTargetLabel);
1046 theEngine->PasteInto(aStream, aLen, anObjID->Value(), aPastedSO);
1048 if(aStream != NULL) delete []aStream;
1052 // iterate attributes
1053 TDF_AttributeIterator anAttrIterator(theSource);
1054 Handle(TDF_RelocationTable) aRT = new TDF_RelocationTable();
1055 for(; anAttrIterator.More(); anAttrIterator.Next()) {
1056 Handle(TDF_Attribute) anAttr = anAttrIterator.Value();
1057 if (aTargetLabel.FindAttribute(anAttr->ID(), anAttr)) {
1058 aTargetLabel.ForgetAttribute(anAttr->ID());
1059 anAttr = anAttrIterator.Value();
1061 Handle(TDF_Attribute) aNewAttribute = anAttr->NewEmpty();
1062 aTargetLabel.AddAttribute(aNewAttribute);
1063 anAttr->Paste(aNewAttribute, aRT);
1066 // check auxiliary label for Comment => reference or name attribute of the referenced object
1067 Handle(SALOMEDSImpl_AttributeComment) aCommentAttribute;
1068 if (aAuxSourceLabel.FindAttribute(SALOMEDSImpl_AttributeComment::GetID(), aCommentAttribute)) {
1069 char * anEntry = new char[aCommentAttribute->Value().Length() + 1];
1070 strcpy(anEntry, TCollection_AsciiString(aCommentAttribute->Value()).ToCString());
1071 char* aNameStart = strchr(anEntry, ' ');
1076 if (theCopiedStudyID == theDestinationStudy->StudyId()) { // if copy to the same study, reanimate reference
1077 TDF_Label aRefLabel;
1078 TDF_Tool::Label(aTargetLabel.Data(), anEntry, aRefLabel);
1079 SALOMEDSImpl_AttributeReference::Set(aTargetLabel, aRefLabel);
1080 // target attributes structure support
1081 SALOMEDSImpl_AttributeTarget::Set(aRefLabel)->Add(SALOMEDSImpl_Study::SObject(aTargetLabel));
1083 if (aNameStart) SALOMEDSImpl_AttributeName::Set(aTargetLabel, aNameStart);
1084 else SALOMEDSImpl_AttributeName::Set(aTargetLabel, TCollection_ExtendedString("Reference to:")+anEntry);
1089 return aTargetLabel;
1092 //============================================================================
1093 /*! Function : Paste
1096 //============================================================================
1097 Handle(SALOMEDSImpl_SObject) SALOMEDSImpl_StudyManager::Paste(const Handle(SALOMEDSImpl_SObject)& theObject,
1098 SALOMEDSImpl_Driver* theEngine)
1102 Handle(SALOMEDSImpl_Study) aStudy = theObject->GetStudy();
1104 // if study is locked, then paste can't be done
1105 if (aStudy->GetProperties()->IsLocked()) {
1106 _errorCode = "LockProtection";
1107 throw LockProtection("LockProtection");
1110 // if there is no component name, then paste only SObjects and attributes: without component help
1111 Handle(SALOMEDSImpl_AttributeComment) aComponentName;
1112 bool aStructureOnly = !_clipboard->Main().Root().FindAttribute(SALOMEDSImpl_AttributeComment::GetID(), aComponentName);
1114 // get copied study ID
1115 Handle(SALOMEDSImpl_AttributeInteger) aStudyIDAttribute;
1116 if (!_clipboard->Main().Root().FindAttribute(SALOMEDSImpl_AttributeInteger::GetID(), aStudyIDAttribute)) {
1117 _errorCode = "No study ID was found";
1120 int aCStudyID = aStudyIDAttribute->Value();
1122 // CAF document of current study usage
1123 Handle(TDocStd_Document) aDocument = GetDocumentOfStudy(aStudy);
1124 if (aDocument.IsNull()) {
1125 _errorCode = "OCAF document is null";
1129 Handle(SALOMEDSImpl_SComponent) aComponent = theObject->GetFatherComponent();
1131 // fill root inserted SObject
1132 TDF_Label aStartLabel;
1133 if (aStructureOnly) {
1134 TDF_Label anObjectLabel;
1135 TDF_Tool::Label(aDocument->GetData(), theObject->GetID(), anObjectLabel);
1136 aStartLabel = PasteLabel(aStudy, theEngine, _clipboard->Main(), anObjectLabel, aCStudyID, false);
1138 TDF_Label aComponentLabel;
1139 TDF_Tool::Label(aDocument->GetData(), aComponent->GetID(), aComponentLabel);
1140 aStartLabel = PasteLabel(aStudy, theEngine, _clipboard->Main(), aComponentLabel, aCStudyID, true);
1143 // paste all sublebels
1144 TDF_ChildIterator anIterator(_clipboard->Main(), Standard_True);
1145 for(; anIterator.More(); anIterator.Next()) {
1146 PasteLabel(aStudy, theEngine, anIterator.Value(), aStartLabel, aCStudyID, false);
1149 return SALOMEDSImpl_Study::SObject(aStartLabel);
1152 //#######################################################################################################
1153 //# STATIC PRIVATE FUNCTIONS
1154 //#######################################################################################################
1156 //============================================================================
1157 /*! Function : SaveAttributes
1158 * Purpose : Save attributes for object
1160 //============================================================================
1161 static void SaveAttributes(Handle(SALOMEDSImpl_SObject) aSO, HDFgroup *hdf_group_sobject)
1164 TDF_AttributeIterator Itr(aSO->GetLabel());
1165 Handle(TDF_Attribute) anAttr;
1166 for(; Itr.More(); Itr.Next()) {
1167 anAttr = Itr.Value();
1168 //The following attributes are not supposed to be written to the file
1169 if(anAttr->DynamicType() == STANDARD_TYPE(SALOMEDSImpl_AttributeIOR)) continue; //IOR attribute is not saved
1170 Handle(SALOMEDSImpl_GenericAttribute) ga = Handle(SALOMEDSImpl_GenericAttribute)::DownCast(anAttr);
1171 TCollection_AsciiString aSaveStr = ga->Save();
1172 //cout << "Saving: " << aSO->GetID() << " "<< ga->Type() << " value: " << aSaveStr << endl;
1173 size[0] = (hdf_int32) strlen(aSaveStr.ToCString()) + 1;
1174 HDFdataset *hdf_dataset = new HDFdataset((char*)ga->Type().ToCString(), hdf_group_sobject,HDF_STRING,size,1);
1175 hdf_dataset->CreateOnDisk();
1176 hdf_dataset->WriteOnDisk((char*)aSaveStr.ToCString());
1177 hdf_dataset->CloseOnDisk();
1178 hdf_dataset=0; //will be deleted by hdf_sco_group destructor
1182 //===========================================================================
1183 //Function : ReadAttributes
1184 //===========================================================================
1185 static void ReadAttributes(const Handle(SALOMEDSImpl_Study)& theStudy,
1186 const Handle(SALOMEDSImpl_SObject)& aSO,
1187 HDFdataset* hdf_dataset)
1189 hdf_dataset->OpenOnDisk();
1191 Handle(TDF_Attribute) anAttr;
1193 char* current_string = new char[hdf_dataset->GetSize()];
1194 hdf_dataset->ReadFromDisk(current_string);
1196 if (!strcmp(hdf_dataset->GetName(),"COMPONENTDATATYPE")) {
1197 anAttr = theStudy->NewBuilder()->FindOrCreateAttribute(aSO, "AttributeComment");
1198 } else if (!strcmp(hdf_dataset->GetName(),"AttributeReference")) {
1199 theStudy->NewBuilder()->Addreference(aSO, theStudy->CreateObjectID(current_string));
1200 delete(current_string);
1201 hdf_dataset->CloseOnDisk();
1204 anAttr = theStudy->NewBuilder()->FindOrCreateAttribute(aSO, hdf_dataset->GetName());
1207 if (!anAttr.IsNull()) {
1209 Handle(SALOMEDSImpl_GenericAttribute) ga = Handle(SALOMEDSImpl_GenericAttribute)::DownCast(anAttr);
1210 ga->Load(current_string);
1211 //cout << "Reading: " << aSO->GetID() << " "<< ga->Type() << " value: " << current_string << endl;
1214 delete(current_string);
1215 hdf_dataset->CloseOnDisk();
1218 //============================================================================
1219 //Function : BuildlTree
1220 //============================================================================
1221 static void BuildTree (const Handle(SALOMEDSImpl_Study)& theStudy, HDFgroup* hdf_current_group)
1223 hdf_current_group->OpenOnDisk();
1224 Handle(SALOMEDSImpl_SObject) aSO;
1225 char* Entry = hdf_current_group->GetName();
1226 if (strcmp(Entry,"STUDY_STRUCTURE") == 0) {
1227 aSO = theStudy->CreateObjectID("0:1");
1230 aSO = theStudy->CreateObjectID(Entry);
1233 char name[HDF_NAME_MAX_LEN+1];
1234 Standard_Integer nbsons = hdf_current_group->nInternalObjects();
1235 for (Standard_Integer i=0; i<nbsons; i++) {
1236 hdf_current_group->InternalObjectIndentify(i,name);
1237 if (strncmp(name, "INTERNAL_COMPLEX",16) == 0) continue;
1238 hdf_object_type type = hdf_current_group->InternalObjectType(name);
1240 if (type == HDF_DATASET) {
1241 HDFdataset* new_dataset = new HDFdataset(name,hdf_current_group);
1242 ReadAttributes(theStudy,aSO,new_dataset);
1243 new_dataset = 0; // will be deleted by father destructor
1246 else if (type == HDF_GROUP) {
1247 HDFgroup* new_group = new HDFgroup(name,hdf_current_group);
1248 BuildTree (theStudy, new_group);
1249 new_group = 0; // will be deleted by father destructor
1252 hdf_current_group->CloseOnDisk();
1256 //============================================================================
1257 //Function : Translate_IOR_to_persistentID
1258 //============================================================================
1259 static void Translate_IOR_to_persistentID (const Handle(SALOMEDSImpl_SObject)& so,
1260 SALOMEDSImpl_Driver* engine,
1264 TDF_ChildIterator itchild(so->GetLabel());
1265 TCollection_AsciiString ior_string, persistent_string, curid;
1267 for (; itchild.More(); itchild.Next()) {
1268 Handle(SALOMEDSImpl_SObject) current = SALOMEDSImpl_Study::SObject(itchild.Value());
1269 Handle(SALOMEDSImpl_AttributeIOR) IOR;
1270 if (current->GetLabel().FindAttribute(SALOMEDSImpl_AttributeIOR::GetID(), IOR)) {
1271 ior_string = IOR->Value();
1273 persistent_string = engine->IORToLocalPersistentID (current, ior_string, isMultiFile, isASCII);
1274 SALOMEDSImpl_AttributePersistentRef::Set(current->GetLabel(), persistent_string);
1276 Translate_IOR_to_persistentID (current, engine, isMultiFile, isASCII);