File tree Expand file tree Collapse file tree 4 files changed +45
-4
lines changed
services/static-webserver/client/source/class/osparc Expand file tree Collapse file tree 4 files changed +45
-4
lines changed Original file line number Diff line number Diff line change @@ -312,7 +312,19 @@ qx.Class.define("osparc.data.model.Node", {
312312 return outputs [ outputKey ] [ "value" ] ;
313313 }
314314 return null ;
315- }
315+ } ,
316+
317+ getLinkedNodeIds : function ( nodeData ) {
318+ const linkedNodeIds = new Set ( [ ] ) ;
319+ if ( "inputs" in nodeData ) {
320+ Object . values ( nodeData [ "inputs" ] ) . forEach ( link => {
321+ if ( link && typeof link === "object" && "nodeUuid" in link ) {
322+ linkedNodeIds . add ( link [ "nodeUuid" ] ) ;
323+ }
324+ } ) ;
325+ }
326+ return Array . from ( linkedNodeIds ) ;
327+ } ,
316328 } ,
317329
318330 members : {
Original file line number Diff line number Diff line change @@ -345,7 +345,18 @@ qx.Class.define("osparc.data.model.Study", {
345345 "STARTED" ,
346346 "RETRY"
347347 ] . includes ( state ) ;
348- }
348+ } ,
349+
350+ __isAnyLinkedNodeMissing : function ( studyData ) {
351+ const existingNodeIds = Object . keys ( studyData [ "workbench" ] ) ;
352+ const linkedNodeIds = osparc . data . model . Workbench . getLinkedNodeIds ( studyData [ "workbench" ] ) ;
353+ const allExist = linkedNodeIds . every ( linkedNodeId => existingNodeIds . includes ( linkedNodeId ) ) ;
354+ return ! allExist ;
355+ } ,
356+
357+ isCorrupt : function ( studyData ) {
358+ return this . __isAnyLinkedNodeMissing ( studyData ) ;
359+ } ,
349360 } ,
350361
351362 members : {
Original file line number Diff line number Diff line change @@ -78,7 +78,16 @@ qx.Class.define("osparc.data.model.Workbench", {
7878
7979 statics : {
8080 CANT_ADD_NODE : qx . locale . Manager . tr ( "Nodes can't be added while the pipeline is running" ) ,
81- CANT_DELETE_NODE : qx . locale . Manager . tr ( "Nodes can't be deleted while the pipeline is running" )
81+ CANT_DELETE_NODE : qx . locale . Manager . tr ( "Nodes can't be deleted while the pipeline is running" ) ,
82+
83+ getLinkedNodeIds : function ( workbenchData ) {
84+ const linkedNodeIDs = new Set ( [ ] ) ;
85+ Object . values ( workbenchData ) . forEach ( nodeData => {
86+ const linkedNodes = osparc . data . model . Node . getLinkedNodeIds ( nodeData ) ;
87+ linkedNodes . forEach ( linkedNodeID => linkedNodeIDs . add ( linkedNodeID ) )
88+ } ) ;
89+ return Array . from ( linkedNodeIDs ) ;
90+ } ,
8291 } ,
8392
8493 members : {
Original file line number Diff line number Diff line change @@ -85,20 +85,29 @@ qx.Class.define("osparc.desktop.MainPageHandler", {
8585 } ,
8686
8787 loadStudy : function ( studyData ) {
88+ const studyAlias = osparc . product . Utils . getStudyAlias ( { firstUpperCase : true } ) ;
89+ // check if it's locked
8890 let locked = false ;
8991 let lockedBy = false ;
9092 if ( "state" in studyData && "locked" in studyData [ "state" ] ) {
9193 locked = studyData [ "state" ] [ "locked" ] [ "value" ] ;
9294 lockedBy = studyData [ "state" ] [ "locked" ] [ "owner" ] ;
9395 }
9496 if ( locked && lockedBy [ "user_id" ] !== osparc . auth . Data . getInstance ( ) . getUserId ( ) ) {
95- const msg = `${ qx . locale . Manager . tr ( "Study is already open by " ) } ${
97+ const msg = `${ studyAlias } ${ qx . locale . Manager . tr ( "is already open by" ) } ${
9698 "first_name" in lockedBy && lockedBy [ "first_name" ] != null ?
9799 lockedBy [ "first_name" ] :
98100 qx . locale . Manager . tr ( "another user." )
99101 } `;
100102 throw new Error ( msg ) ;
101103 }
104+
105+ // check if it's corrupt
106+ if ( osparc . data . model . Study . isCorrupt ( studyData ) ) {
107+ const msg = `${ qx . locale . Manager . tr ( "We encountered an issue with the" ) } ${ studyAlias } <br>${ qx . locale . Manager . tr ( "Please contact support." ) } ` ;
108+ throw new Error ( msg ) ;
109+ }
110+
102111 this . setLoadingPageHeader ( qx . locale . Manager . tr ( "Loading " ) + studyData . name ) ;
103112 this . showLoadingPage ( ) ;
104113 const inaccessibleServices = osparc . study . Utils . getInaccessibleServices ( studyData [ "workbench" ] )
You can’t perform that action at this time.
0 commit comments