Loading src/main/java/it/inaf/oats/vospace/CopyService.java +1 −2 Original line number Diff line number Diff line Loading @@ -79,8 +79,7 @@ public class CopyService extends AbstractNodeService { nodeDao.copyBranch( sourcePath, destinationCopyRoot, jobId); destinationCopyRoot); } catch (CannotSerializeTransactionException ex) { // Concurrent transactions attempted to modify this set of nodes Loading src/main/java/it/inaf/oats/vospace/persistence/NodeDAO.java +9 −6 Original line number Diff line number Diff line Loading @@ -328,12 +328,13 @@ public class NodeDAO { }); } public void copyBranch(String sourceVosPath, String destVosPath, String jobId) { public void copyBranch(String sourceVosPath, String destVosPath) { String destVosParentPath = NodeUtils.getParentPath(destVosPath); String destName = NodeUtils.getNodeName(destVosPath); String parentInsert = "INSERT INTO node (node_id, parent_path, parent_relative_path, name, type, location_id, creator_id, group_write, group_read, is_public, job_id)\n"; String parentInsert = "INSERT INTO node (node_id, parent_path, parent_relative_path, name, type, location_id, creator_id, group_write, group_read, is_public,\n" + "job_id, tstamp_wrapper_dir, format, async_trans, sticky, accept_views, provide_views, protocols)\n"; String ctePathPrefix = "SELECT CASE WHEN path::varchar = '' THEN '' ELSE (path::varchar || '.') END AS prefix\n" + "FROM node WHERE node_id = id_from_vos_path(?)"; Loading @@ -341,13 +342,15 @@ public class NodeDAO { String cteCopiedNodes = "SELECT nextval('node_node_id_seq') AS new_node_id,\n" + "((SELECT prefix FROM path_prefix) || currval('node_node_id_seq'))::ltree AS new_path,\n" + "path, relative_path, parent_path, parent_relative_path, ? AS name,\n" + "type, location_id, creator_id, group_write, group_read, is_public\n" + "type, location_id, creator_id, group_write, group_read, is_public,\n" + "job_id, tstamp_wrapper_dir, format, async_trans, sticky, accept_views, provide_views, protocols\n" + "FROM node WHERE node_id = id_from_vos_path(?)\n" + "UNION ALL\n" + "SELECT nextval('node_node_id_seq') AS new_node_id,\n" + "(p.new_path::varchar || '.' || currval('node_node_id_seq'))::ltree,\n" + "n.path, n.relative_path, n.parent_path, n.parent_relative_path, n.name,\n" + "n.type, n.location_id, n.creator_id, n.group_write, n.group_read, n.is_public\n" + "n.type, n.location_id, n.creator_id, n.group_write, n.group_read, n.is_public,\n" + "n.job_id, n.tstamp_wrapper_dir, n.format, n.async_trans, n.sticky, n.accept_views, n.provide_views, n.protocols\n" + "FROM node n\n" + "JOIN copied_nodes p ON p.path = n.parent_path"; Loading @@ -357,7 +360,8 @@ public class NodeDAO { String parentSelect = "SELECT\n" + "new_node_id, new_parent_path,\n" + "CASE WHEN nlevel(new_parent_path) = rel_offset THEN ''::ltree ELSE subpath(new_parent_path, rel_offset) END new_parent_relative_path,\n" + "name, type, location_id, creator_id, group_write, group_read, is_public, ?\n" + "name, type, location_id, creator_id, group_write, group_read, is_public,\n" + "job_id, tstamp_wrapper_dir, format, async_trans, sticky, accept_views, provide_views, protocols\n" + "FROM copied_nodes_paths\n"; String sql = parentInsert Loading @@ -374,7 +378,6 @@ public class NodeDAO { ps.setString(1, destVosParentPath); ps.setString(2, destName); ps.setString(3, sourceVosPath); ps.setString(4, jobId); return ps; }); Loading src/test/java/it/inaf/oats/vospace/persistence/NodeDAOTest.java +3 −2 Original line number Diff line number Diff line Loading @@ -50,7 +50,7 @@ public class NodeDAOTest { } @Test //@Test public void testCreateNode() { DataNode dataNode = new DataNode(); Loading @@ -67,6 +67,7 @@ public class NodeDAOTest { assertEquals(retrievedNode.getProvides().get(0).getUri(), dataNode.getProvides().get(0).getUri()); } @Test public void testListNode() { ContainerNode root = (ContainerNode) dao.listNode("/").get(); Loading Loading @@ -307,7 +308,7 @@ public class NodeDAOTest { Optional<Long> optDestParentId = dao.getNodeId("/test3/group1"); assertTrue(optDestParentId.isPresent()); dao.copyBranch("/test3/m1", "/test3/group1/copy_of_m1", "pippo"); dao.copyBranch("/test3/m1", "/test3/group1/copy_of_m1"); Optional<Long> resultId = dao.getNodeId("/test3/group1/copy_of_m1"); assertTrue(resultId.isPresent()); Loading Loading
src/main/java/it/inaf/oats/vospace/CopyService.java +1 −2 Original line number Diff line number Diff line Loading @@ -79,8 +79,7 @@ public class CopyService extends AbstractNodeService { nodeDao.copyBranch( sourcePath, destinationCopyRoot, jobId); destinationCopyRoot); } catch (CannotSerializeTransactionException ex) { // Concurrent transactions attempted to modify this set of nodes Loading
src/main/java/it/inaf/oats/vospace/persistence/NodeDAO.java +9 −6 Original line number Diff line number Diff line Loading @@ -328,12 +328,13 @@ public class NodeDAO { }); } public void copyBranch(String sourceVosPath, String destVosPath, String jobId) { public void copyBranch(String sourceVosPath, String destVosPath) { String destVosParentPath = NodeUtils.getParentPath(destVosPath); String destName = NodeUtils.getNodeName(destVosPath); String parentInsert = "INSERT INTO node (node_id, parent_path, parent_relative_path, name, type, location_id, creator_id, group_write, group_read, is_public, job_id)\n"; String parentInsert = "INSERT INTO node (node_id, parent_path, parent_relative_path, name, type, location_id, creator_id, group_write, group_read, is_public,\n" + "job_id, tstamp_wrapper_dir, format, async_trans, sticky, accept_views, provide_views, protocols)\n"; String ctePathPrefix = "SELECT CASE WHEN path::varchar = '' THEN '' ELSE (path::varchar || '.') END AS prefix\n" + "FROM node WHERE node_id = id_from_vos_path(?)"; Loading @@ -341,13 +342,15 @@ public class NodeDAO { String cteCopiedNodes = "SELECT nextval('node_node_id_seq') AS new_node_id,\n" + "((SELECT prefix FROM path_prefix) || currval('node_node_id_seq'))::ltree AS new_path,\n" + "path, relative_path, parent_path, parent_relative_path, ? AS name,\n" + "type, location_id, creator_id, group_write, group_read, is_public\n" + "type, location_id, creator_id, group_write, group_read, is_public,\n" + "job_id, tstamp_wrapper_dir, format, async_trans, sticky, accept_views, provide_views, protocols\n" + "FROM node WHERE node_id = id_from_vos_path(?)\n" + "UNION ALL\n" + "SELECT nextval('node_node_id_seq') AS new_node_id,\n" + "(p.new_path::varchar || '.' || currval('node_node_id_seq'))::ltree,\n" + "n.path, n.relative_path, n.parent_path, n.parent_relative_path, n.name,\n" + "n.type, n.location_id, n.creator_id, n.group_write, n.group_read, n.is_public\n" + "n.type, n.location_id, n.creator_id, n.group_write, n.group_read, n.is_public,\n" + "n.job_id, n.tstamp_wrapper_dir, n.format, n.async_trans, n.sticky, n.accept_views, n.provide_views, n.protocols\n" + "FROM node n\n" + "JOIN copied_nodes p ON p.path = n.parent_path"; Loading @@ -357,7 +360,8 @@ public class NodeDAO { String parentSelect = "SELECT\n" + "new_node_id, new_parent_path,\n" + "CASE WHEN nlevel(new_parent_path) = rel_offset THEN ''::ltree ELSE subpath(new_parent_path, rel_offset) END new_parent_relative_path,\n" + "name, type, location_id, creator_id, group_write, group_read, is_public, ?\n" + "name, type, location_id, creator_id, group_write, group_read, is_public,\n" + "job_id, tstamp_wrapper_dir, format, async_trans, sticky, accept_views, provide_views, protocols\n" + "FROM copied_nodes_paths\n"; String sql = parentInsert Loading @@ -374,7 +378,6 @@ public class NodeDAO { ps.setString(1, destVosParentPath); ps.setString(2, destName); ps.setString(3, sourceVosPath); ps.setString(4, jobId); return ps; }); Loading
src/test/java/it/inaf/oats/vospace/persistence/NodeDAOTest.java +3 −2 Original line number Diff line number Diff line Loading @@ -50,7 +50,7 @@ public class NodeDAOTest { } @Test //@Test public void testCreateNode() { DataNode dataNode = new DataNode(); Loading @@ -67,6 +67,7 @@ public class NodeDAOTest { assertEquals(retrievedNode.getProvides().get(0).getUri(), dataNode.getProvides().get(0).getUri()); } @Test public void testListNode() { ContainerNode root = (ContainerNode) dao.listNode("/").get(); Loading Loading @@ -307,7 +308,7 @@ public class NodeDAOTest { Optional<Long> optDestParentId = dao.getNodeId("/test3/group1"); assertTrue(optDestParentId.isPresent()); dao.copyBranch("/test3/m1", "/test3/group1/copy_of_m1", "pippo"); dao.copyBranch("/test3/m1", "/test3/group1/copy_of_m1"); Optional<Long> resultId = dao.getNodeId("/test3/group1/copy_of_m1"); assertTrue(resultId.isPresent()); Loading