@@ -238,6 +238,10 @@ qx.Class.define("osparc.data.model.Node", {
238238 "progress" , // !! not a property but goes into the model
239239 ] ,
240240
241+ getProperties : function ( ) {
242+ return Object . keys ( qx . util . PropertyUtil . getProperties ( osparc . data . model . Node ) ) ;
243+ } ,
244+
241245 isFrontend : function ( metadata ) {
242246 return ( metadata && metadata . key && metadata . key . includes ( "/frontend/" ) ) ;
243247 } ,
@@ -1306,7 +1310,7 @@ qx.Class.define("osparc.data.model.Node", {
13061310
13071311 listenToChanges : function ( ) {
13081312 const nodeId = this . getNodeId ( ) ;
1309- const propertyKeys = Object . keys ( qx . util . PropertyUtil . getProperties ( osparc . data . model . Node ) ) ;
1313+ const nodePropertyKeys = this . self ( ) . getProperties ( ) ;
13101314 this . self ( ) . ListenChangesProps . forEach ( key => {
13111315 switch ( key ) {
13121316 case "inputs" :
@@ -1400,7 +1404,7 @@ qx.Class.define("osparc.data.model.Node", {
14001404 }
14011405 break ;
14021406 default :
1403- if ( propertyKeys . includes ( key ) ) {
1407+ if ( nodePropertyKeys . includes ( key ) ) {
14041408 this . addListener ( "change" + qx . lang . String . firstUp ( key ) , e => {
14051409 const data = e . getData ( ) ;
14061410 this . fireDataEvent ( "projectDocumentChanged" , {
@@ -1418,6 +1422,36 @@ qx.Class.define("osparc.data.model.Node", {
14181422 } ) ;
14191423 } ,
14201424
1425+ updateNodeFromPatch : function ( nodePatches ) {
1426+ console . log ( nodePatches ) ;
1427+ const nodePropertyKeys = this . self ( ) . getProperties ( ) ;
1428+ nodePatches . forEach ( patch => {
1429+ const op = patch . op ;
1430+ const path = patch . path ;
1431+ const value = patch . value ;
1432+ const nodeProperty = path . split ( "/" ) [ 3 ] ;
1433+ switch ( nodeProperty ) {
1434+ case "inputs" :
1435+ case "inputsUnits" :
1436+ case "inputNodes" :
1437+ case "inputsRequired" :
1438+ case "outputs" :
1439+ case "progress" :
1440+ console . warn ( `To be implemented: patching ${ nodeProperty } is not supported yet` ) ;
1441+ default :
1442+ if ( nodePropertyKeys . includes ( nodeProperty ) ) {
1443+ const setter = "set" + qx . lang . String . firstUp ( nodeProperty ) ;
1444+ if ( this [ setter ] ) {
1445+ this [ setter ] ( value ) ;
1446+ } else {
1447+ console . warn ( `Property "${ nodeProperty } " does not have a setter in osparc.data.model.Node` ) ;
1448+ }
1449+ }
1450+ break ;
1451+ }
1452+ } ) ;
1453+ } ,
1454+
14211455 serialize : function ( ) {
14221456 // node generic
14231457 let nodeEntry = {
0 commit comments