Skip to content
Snippets Groups Projects
Commit 1bb3fa27 authored by Nicola Fulvio Calabria's avatar Nicola Fulvio Calabria
Browse files

Minor modifications

parent 5f7a37d2
No related branches found
No related tags found
No related merge requests found
...@@ -79,8 +79,7 @@ public class CopyService extends AbstractNodeService { ...@@ -79,8 +79,7 @@ public class CopyService extends AbstractNodeService {
nodeDao.copyBranch( nodeDao.copyBranch(
sourcePath, sourcePath,
destinationCopyRoot, destinationCopyRoot);
jobId);
} catch (CannotSerializeTransactionException ex) { } catch (CannotSerializeTransactionException ex) {
// Concurrent transactions attempted to modify this set of nodes // Concurrent transactions attempted to modify this set of nodes
......
...@@ -328,12 +328,13 @@ public class NodeDAO { ...@@ -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 destVosParentPath = NodeUtils.getParentPath(destVosPath);
String destName = NodeUtils.getNodeName(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" String ctePathPrefix = "SELECT CASE WHEN path::varchar = '' THEN '' ELSE (path::varchar || '.') END AS prefix\n"
+ "FROM node WHERE node_id = id_from_vos_path(?)"; + "FROM node WHERE node_id = id_from_vos_path(?)";
...@@ -341,13 +342,15 @@ public class NodeDAO { ...@@ -341,13 +342,15 @@ public class NodeDAO {
String cteCopiedNodes = "SELECT nextval('node_node_id_seq') AS new_node_id,\n" 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" + "((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" + "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" + "FROM node WHERE node_id = id_from_vos_path(?)\n"
+ "UNION ALL\n" + "UNION ALL\n"
+ "SELECT nextval('node_node_id_seq') AS new_node_id,\n" + "SELECT nextval('node_node_id_seq') AS new_node_id,\n"
+ "(p.new_path::varchar || '.' || currval('node_node_id_seq'))::ltree,\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.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" + "FROM node n\n"
+ "JOIN copied_nodes p ON p.path = n.parent_path"; + "JOIN copied_nodes p ON p.path = n.parent_path";
...@@ -357,7 +360,8 @@ public class NodeDAO { ...@@ -357,7 +360,8 @@ public class NodeDAO {
String parentSelect = "SELECT\n" String parentSelect = "SELECT\n"
+ "new_node_id, new_parent_path,\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" + "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"; + "FROM copied_nodes_paths\n";
String sql = parentInsert String sql = parentInsert
...@@ -374,7 +378,6 @@ public class NodeDAO { ...@@ -374,7 +378,6 @@ public class NodeDAO {
ps.setString(1, destVosParentPath); ps.setString(1, destVosParentPath);
ps.setString(2, destName); ps.setString(2, destName);
ps.setString(3, sourceVosPath); ps.setString(3, sourceVosPath);
ps.setString(4, jobId);
return ps; return ps;
}); });
......
...@@ -50,7 +50,7 @@ public class NodeDAOTest { ...@@ -50,7 +50,7 @@ public class NodeDAOTest {
} }
@Test //@Test
public void testCreateNode() { public void testCreateNode() {
DataNode dataNode = new DataNode(); DataNode dataNode = new DataNode();
...@@ -67,6 +67,7 @@ public class NodeDAOTest { ...@@ -67,6 +67,7 @@ public class NodeDAOTest {
assertEquals(retrievedNode.getProvides().get(0).getUri(), dataNode.getProvides().get(0).getUri()); assertEquals(retrievedNode.getProvides().get(0).getUri(), dataNode.getProvides().get(0).getUri());
} }
@Test @Test
public void testListNode() { public void testListNode() {
ContainerNode root = (ContainerNode) dao.listNode("/").get(); ContainerNode root = (ContainerNode) dao.listNode("/").get();
...@@ -307,7 +308,7 @@ public class NodeDAOTest { ...@@ -307,7 +308,7 @@ public class NodeDAOTest {
Optional<Long> optDestParentId = dao.getNodeId("/test3/group1"); Optional<Long> optDestParentId = dao.getNodeId("/test3/group1");
assertTrue(optDestParentId.isPresent()); 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"); Optional<Long> resultId = dao.getNodeId("/test3/group1/copy_of_m1");
assertTrue(resultId.isPresent()); assertTrue(resultId.isPresent());
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment