- // set object value to the study: if object is external, then put it with
- // help of the specific component - owner
- if (p->IsIOR()) {
- // get according component driver for result object
- SALOME_LifeCycleCORBA aLCC(myNService);
- SUPERV_FNode aFNode = SUPERV::FNode::_narrow(p->Node());
- if (!aFNode->_is_nil()) {
- Engines::Component_var aComponent = aLCC.FindOrLoad_Component(aFNode->GetContainer(),
- aFNode->GetComponentName());
- SALOMEDS::Driver_var aDriver = SALOMEDS::Driver::_narrow(aComponent);
- if (!CORBA::is_nil(aDriver)) { // if driver was found, publish object
- CORBA::Object_ptr anObject = new CORBA::Object();
- CORBA::Any* anAny = p->ToAny();
- (*anAny) >>= anObject;
+
+ // check if the port and its node are good
+ if ( CORBA::is_nil( p ) || CORBA::is_nil( p->Node() ) ) {
+ MESSAGE( "putInStudy ERROR: port or node are NULL!" );
+ isIn = false;
+ return false;
+ }
+
+ // open new command. Commit or Abort it depending on aDoneSomething variable or error
+ aBuilder->NewCommand();
+
+ // Find or create "Supervisor -> aNewDataflow_1" SObjects in the study
+ SALOMEDS::SObject_var aSO = createDataflowSObj( study, dataflow, aBuilder, aDoneSomething );
+
+ if ( CORBA::is_nil( aSO ) ) {
+ MESSAGE( "ERROR: putDataStudy() could not find or create dataflow SObject" );
+ aBuilder->AbortCommand();
+ isIn = false;
+ return false;
+ }
+
+ // Create "Run -> Time and date, etc." SObjects
+ if ( p->State() == SUPERV::ReadyState ) { // if port contains valid computed value
+
+ aSO = SearchOrCreateSOWithName( aStudy, aBuilder, aSO, QString("Run ") + myRunTime.toString(), &aDoneSomething ); // get run time SO
+ aSO = SearchOrCreateSOWithName( aStudy, aBuilder, aSO, p->Node()->Name(), &aDoneSomething ); // get node SO
+ aSO = SearchOrCreateSOWithName( aStudy, aBuilder, aSO, inout, &aDoneSomething ); // get in/out SO
+ aSO = SearchOrCreateSOWithName( aStudy, aBuilder, aSO, p->Name(), &aDoneSomething ); // get port SO
+
+ // create IOR attribute for port SObject (usually with "return" name)
+ anAttr = aBuilder->FindOrCreateAttribute(aSO, "AttributeIOR");
+ anIORAttr = SALOMEDS::AttributeIOR::_narrow(anAttr);
+
+ // if we have not created anything (all SObject already existed) and we have the same IORAttribute
+ // on the needed SObject -> then don't do anything! it's already there!
+ if ( !aDoneSomething && strcmp(anIORAttr->Value(), p->ToString()) == 0 ) {
+ aBuilder->AbortCommand();
+ isIn = false;
+ return true;
+ }
+
+ aDoneSomething = true; // going to set some value to anIORAttr any way from this point..
+
+ // set object value to the study: if object is external, then put it with
+ // help of the specific component - owner
+ if ( p->IsIOR() ) {
+ // get according component driver for result object
+ SALOME_LifeCycleCORBA aLCC( myNService );
+ SUPERV_FNode aFNode = SUPERV::FNode::_narrow( p->Node() );
+ if ( !aFNode->_is_nil() ) {
+ Engines::Component_var aComponent = aLCC.FindOrLoad_Component( aFNode->GetContainer(), aFNode->GetComponentName() );
+ SALOMEDS::Driver_var aDriver = SALOMEDS::Driver::_narrow( aComponent );
+ if ( !CORBA::is_nil( aDriver ) ) { // if driver was found, publish object
+ CORBA::Object_ptr anObject = new CORBA::Object();
+ CORBA::Any* anAny = p->ToAny();
+ (*anAny) >>= anObject;