Skip to content
Snippets Groups Projects
Commit 51d3079d authored by Sonia Zorba's avatar Sonia Zorba
Browse files

Changed DAO after db structure update

parent e2d21f4e
No related branches found
No related tags found
No related merge requests found
...@@ -45,10 +45,10 @@ public class NodeDAO { ...@@ -45,10 +45,10 @@ public class NodeDAO {
public Node listNode(String path) { public Node listNode(String path) {
String sql = "SELECT os.os_path, n.node_id, type, async_trans, owner_id, group_read, group_write, is_public, content_length, created_on, last_modified from node n\n" String sql = "SELECT os.vos_path, n.node_id, type, async_trans, owner_id, group_read, group_write, is_public, content_length, created_on, last_modified from node n\n"
+ "JOIN node_os_path os ON n.node_id = os.node_id\n" + "JOIN node_vos_path os ON n.node_id = os.node_id\n"
+ "WHERE n.path ~ (" + getFirstLevelChildrenSelector(path) + ")::lquery\n" + "WHERE n.path ~ (" + getFirstLevelChildrenSelector(path) + ")::lquery\n"
+ "OR os.os_path = ? ORDER BY os_path"; + "OR os.vos_path = ? ORDER BY vos_path";
List<Node> parentAndChildren = jdbcTemplate.query(conn -> { List<Node> parentAndChildren = jdbcTemplate.query(conn -> {
PreparedStatement ps = conn.prepareStatement(sql); PreparedStatement ps = conn.prepareStatement(sql);
...@@ -74,7 +74,7 @@ public class NodeDAO { ...@@ -74,7 +74,7 @@ public class NodeDAO {
} }
private String getFirstLevelChildrenSelector(String path) { private String getFirstLevelChildrenSelector(String path) {
String select = "(SELECT path FROM node WHERE node_id = (SELECT node_id FROM node_os_path WHERE os_path = ?))::varchar || '"; String select = "(SELECT path FROM node WHERE node_id = (SELECT node_id FROM node_vos_path WHERE vos_path = ?))::varchar || '";
if (!"/".equals(path)) { if (!"/".equals(path)) {
select += "."; select += ".";
...@@ -86,7 +86,7 @@ public class NodeDAO { ...@@ -86,7 +86,7 @@ public class NodeDAO {
private Node getNodeFromResultSet(ResultSet rs) throws SQLException { private Node getNodeFromResultSet(ResultSet rs) throws SQLException {
Node node = getTypedNode(rs.getString("type")); Node node = getTypedNode(rs.getString("type"));
node.setUri(getUri(rs.getString("os_path"))); node.setUri(getUri(rs.getString("vos_path")));
return node; return node;
} }
......
...@@ -74,7 +74,7 @@ public class DataSourceConfig { ...@@ -74,7 +74,7 @@ public class DataSourceConfig {
File currentDir = new File(DataSourceConfig.class.getClassLoader().getResource(".").getFile()); File currentDir = new File(DataSourceConfig.class.getClassLoader().getResource(".").getFile());
Path scriptDir = currentDir.toPath().resolve(scriptPath); Path scriptDir = currentDir.toPath().resolve(scriptPath);
List<String> scripts = Arrays.asList("00-init.sql", "01-pgsql_path.sql", "03-indexes.sql", "05-data.sql", "06-os_path_view.sql"); List<String> scripts = Arrays.asList("00-init.sql", "01-pgsql_path.sql", "02-indexes.sql", "03-os_path_view.sql", "05-data.sql");
for (String script : scripts) { for (String script : scripts) {
ByteArrayResource scriptResource = replaceDollarQuoting(scriptDir.resolve(script)); ByteArrayResource scriptResource = replaceDollarQuoting(scriptDir.resolve(script));
......
...@@ -28,6 +28,6 @@ public class NodeDAOTest { ...@@ -28,6 +28,6 @@ public class NodeDAOTest {
@Test @Test
public void testListNode() { public void testListNode() {
ContainerNode root = (ContainerNode) dao.listNode("/"); ContainerNode root = (ContainerNode) dao.listNode("/");
assertEquals(1, root.getNodes().size()); assertEquals(4, root.getNodes().size());
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment