@@ -24,40 +24,6 @@ qx.Class.define("osparc.data.Converters", {
2424 type : "static" ,
2525
2626 statics : {
27- __mergeFileTreeChildren : function ( one , two ) {
28- let newDir = true ;
29- for ( let i = 0 ; i < one . length ; i ++ ) {
30- if ( one [ i ] . path === two . path ) {
31- newDir = false ;
32- if ( "children" in two ) {
33- this . __mergeFileTreeChildren ( one [ i ] . children , two . children [ 0 ] ) ;
34- }
35- }
36- }
37- if ( one . length === 0 || "fileId" in two || newDir ) {
38- one . push ( two ) ;
39- }
40- } ,
41-
42- sortFiles : function ( children ) {
43- if ( children && children . length ) {
44- children . sort ( ( a , b ) => {
45- if ( a [ "label" ] > b [ "label" ] ) {
46- return 1 ;
47- }
48- if ( a [ "label" ] < b [ "label" ] ) {
49- return - 1 ;
50- }
51- return 0 ;
52- } ) ;
53- children . forEach ( child => {
54- if ( "children" in child ) {
55- this . sortFiles ( child [ "children" ] ) ;
56- }
57- } ) ;
58- }
59- } ,
60-
6127 sortModelByLabel : function ( model ) {
6228 model . getChildren ( ) . sort ( ( a , b ) => {
6329 if ( a . getLabel ( ) > b . getLabel ( ) ) {
@@ -70,59 +36,6 @@ qx.Class.define("osparc.data.Converters", {
7036 } ) ;
7137 } ,
7238
73- fromDSMToVirtualTreeModel : function ( datasetId , files ) {
74- let children = [ ] ;
75- for ( let i = 0 ; i < files . length ; i ++ ) {
76- const file = files [ i ] ;
77- let fileInTree = this . createDirEntry (
78- file [ "location" ] ,
79- file [ "location_id" ] ,
80- ""
81- ) ;
82- const isSimcore = file [ "location_id" ] === 0 || file [ "location_id" ] === "0" ;
83-
84- const splitted = file [ "file_uuid" ] . split ( "/" ) ;
85- if ( isSimcore && splitted . length < 3 ) {
86- continue ;
87- }
88-
89- // create directories
90- let parent = fileInTree ;
91- for ( let j = 0 ; j < splitted . length - 1 ; j ++ ) {
92- let label = "Unknown" ;
93- if ( isSimcore && j === 0 ) {
94- label = file [ "project_name" ] ;
95- } else if ( isSimcore && j === 1 ) {
96- label = file [ "node_name" ] ;
97- } else {
98- label = splitted [ j ] ;
99- }
100- const newItem = this . createDirEntry (
101- label ,
102- file [ "location_id" ] ,
103- parent . path === "" ? splitted [ j ] : parent . path + "/" + splitted [ j ]
104- ) ;
105- parent . children . push ( newItem ) ;
106- parent = newItem ;
107- }
108-
109- // create file
110- const fileInfo = this . __createFileEntry (
111- splitted [ splitted . length - 1 ] ,
112- file [ "location_id" ] ,
113- datasetId ,
114- file [ "file_id" ] ,
115- file [ "last_modified" ] ,
116- file [ "file_size" ]
117- ) ;
118- parent . children . push ( fileInfo ) ;
119- this . __mergeFileTreeChildren ( children , fileInTree ) ;
120- }
121-
122- this . sortFiles ( children ) ;
123- return children ;
124- } ,
125-
12639 createDirEntry : function ( displayPath , location , path ) {
12740 if ( displayPath === null || displayPath === undefined || displayPath === "" ) {
12841 displayPath = "Unknown label" ;
@@ -150,33 +63,6 @@ qx.Class.define("osparc.data.Converters", {
15063 } ;
15164 } ,
15265
153- __createFileEntry : function ( label , location , datasetId , fileId , lastModified , size ) {
154- if ( label === undefined ) {
155- label = "Unknown label" ;
156- }
157- if ( location === undefined ) {
158- location = "Unknown location" ;
159- }
160- if ( fileId === undefined ) {
161- fileId = "Unknown fileId" ;
162- }
163- if ( lastModified === undefined ) {
164- lastModified = ( Math . floor ( Math . random ( ) * 1000000 ) + 1 ) . toString ( ) ;
165- }
166- if ( size === undefined ) {
167- size = 0 ;
168- }
169- return {
170- label,
171- location,
172- datasetId,
173- fileId,
174- itemId : fileId ,
175- lastModified,
176- size
177- } ;
178- } ,
179-
18066 fromTypeToIcon : function ( type ) {
18167 // Introduce further mappings here
18268 switch ( type ) {
0 commit comments