Commit 5bcf444a authored by Sonia Zorba's avatar Sonia Zorba
Browse files

Bugfix init data; Added OS path view

parent 68d7151f
Loading
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -2,7 +2,7 @@
   Initialization test for vospace Node table; for now ownerID and groupID are set equal to the rapID
*/

INSERT INTO Node (parentPath, name, type, ownerID, creatorID) VALUES ('NULL', '', 'container', '3354', '3354');       -- /
INSERT INTO Node (parentPath, name, type, ownerID, creatorID) VALUES (NULL, '', 'container', '3354', '3354');       -- /
INSERT INTO Node (parentPath, name, type, ownerID, creatorID) VALUES ('', 'home', 'container', '3354', '3354');       -- /home
INSERT INTO Node (parentPath, name, type, ownerID, creatorID) VALUES ('2', 'curban', 'container', '3354', '3354');    -- /home/curban
INSERT INTO Node (parentPath, name, type, ownerID, creatorID) VALUES ('2.3', 'store', 'container', '3354', '3354');   -- /home/curban/store 
+13 −0
Original line number Diff line number Diff line
CREATE VIEW node_os_path AS
SELECT nodeid, '/' FROM node WHERE path = ''
UNION
SELECT nodeid, '/' || string_agg(name, '/') AS os_path
FROM (
    SELECT name, p.nodeid
    FROM node n
    JOIN (
        SELECT UNNEST(string_to_array(path::varchar, '.')) AS rel_id, nodeid
        FROM node
    ) AS p ON n.nodeid::varchar = p.rel_id
    ORDER BY p.nodeid, nlevel(n.path)
) AS j GROUP BY nodeid;