Commit 216a3cd9 authored by Sonia Zorba's avatar Sonia Zorba
Browse files

Used job_id instead of busy_state

parent 77cdc04e
Loading
Loading
Loading
Loading
Loading
+16 −8
Original line number Diff line number Diff line
@@ -51,7 +51,11 @@ public class NodeDAO {
        jdbcTemplate = new JdbcTemplate(dataSource);
    }

    public void createNode(Node myNode) {
    public void createNode(Node node) {
        createNode(node, null);
    }

    public void createNode(Node myNode, String jobId) {

        String nodeURI = myNode.getUri();

@@ -63,7 +67,7 @@ public class NodeDAO {

        StringBuilder sb = new StringBuilder();
        sb.append("INSERT INTO node");
        sb.append(" (name, busy_state, creator_id, group_read, group_write,");
        sb.append(" (name, job_id, creator_id, group_read, group_write,");
        sb.append(" is_public, parent_path, parent_relative_path, type, accept_views, provide_views)");
        sb.append(" VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");

@@ -71,7 +75,11 @@ public class NodeDAO {
            PreparedStatement ps = conn.prepareStatement(sb.toString());
            int i = 0;
            ps.setString(++i, NodeUtils.getNodeName(myNode));
            ps.setBoolean(++i, NodeUtils.getIsBusy(myNode));
            if (jobId == null) {
                ps.setNull(++i, Types.VARCHAR);
            } else {
                ps.setString(++i, jobId);
            }
            ps.setString(++i, NodeProperties.getStandardNodePropertyByName(myNode, "creator"));
            ps.setArray(++i, fromPropertyToArray(ps, NodeProperties.getStandardNodePropertyByName(myNode, "groupread")));
            ps.setArray(++i, fromPropertyToArray(ps, NodeProperties.getStandardNodePropertyByName(myNode, "groupwrite")));
@@ -88,7 +96,7 @@ public class NodeDAO {
    public Optional<Node> listNode(String path) {

        String sql = "SELECT (CASE WHEN c.path = n.path THEN ? ELSE (? || ? || c.name) END) AS vos_path, c.node_id, c.name,\n"
                + "c.type, c.async_trans, c.sticky, c.busy_state, c.creator_id, c.group_read, c.group_write,\n"
                + "c.type, c.async_trans, c.sticky, c.job_id IS NOT NULL AS busy_state, c.creator_id, c.group_read, c.group_write,\n"
                + "c.is_public, c.content_length, c.created_on, c.last_modified, c.accept_views, c.provide_views\n"
                + "FROM node n\n"
                + "JOIN node c ON c.path ~ (n.path::varchar || ? || '*{1}')::lquery OR c.path = n.path\n"
@@ -240,7 +248,7 @@ public class NodeDAO {
                + "((SELECT COUNT(*) FROM (SELECT UNNEST(?) INTERSECT SELECT UNNEST(n.group_write)) AS allowed_groups ) = 0 AND\n"
                + "n.creator_id <> ?) AS is_permission_denied,\n"
                + "n.type = 'container' AS is_container,\n"
                + "n.busy_state\n"
                + "n.job_id IS NOT NULL AS busy_state\n"
                + "FROM node n \n"
                + "JOIN node_vos_path p ON n.node_id = p.node_id \n"
                + "LEFT JOIN location loc ON loc.location_id = n.location_id\n"
@@ -315,7 +323,7 @@ public class NodeDAO {
        String sql = "SELECT COUNT(c.node_id) > 0 "
                + "FROM node n "
                + "JOIN node c ON c.path <@ n.path "
                + "WHERE n.node_id = ? AND c.busy_state";
                + "WHERE n.node_id = ? AND c.job_id IS NOT NULL";

        return jdbcTemplate.queryForObject(sql, new Object[]{parentNodeId}, new int[]{Types.BIGINT}, Boolean.class);
    }
@@ -365,7 +373,7 @@ public class NodeDAO {
        String insertSql = "INSERT INTO deleted_node "
                + "(node_id, parent_path, parent_relative_path, "
                + "name, os_name, tstamp_wrapper_dir, type, location_id, format, "
                + "async_trans, busy_state, creator_id, group_read, "
                + "async_trans, job_id, creator_id, group_read, "
                + "group_write, is_public, delta, content_type, content_encoding, "
                + "content_length, content_md5, created_on, last_modified, "
                + "accept_views, provide_views, protocols, sticky)\n";
@@ -377,7 +385,7 @@ public class NodeDAO {
                + "RETURNING\n"
                + "n.node_id, n.parent_path, n.parent_relative_path, "
                + "n.name, n.os_name, n.tstamp_wrapper_dir, n.type, n.location_id, n.format, "
                + "n.async_trans, n.busy_state, n.creator_id, n.group_read, "
                + "n.async_trans, n.job_id, n.creator_id, n.group_read, "
                + "n.group_write, n.is_public, n.delta, n.content_type, n.content_encoding, "
                + "n.content_length, n.content_md5, n.created_on, n.last_modified, "
                + "n.accept_views, n.provide_views, n.protocols, n.sticky\n";
+1 −1
Original line number Diff line number Diff line
@@ -30,7 +30,7 @@ INSERT INTO node (parent_path, parent_relative_path, name, type, creator_id, is_
INSERT INTO node (parent_path, parent_relative_path, name, type, creator_id, is_public, location_id) VALUES ('', NULL, 'test4', 'container', 'user3', false, 3);      -- /test4

INSERT INTO node (parent_path, parent_relative_path, name, sticky, type, creator_id, is_public, location_id) VALUES ('9', '', 'mstick', true, 'container', 'user3', false, 3);      -- /test3/mstick
INSERT INTO node (parent_path, parent_relative_path, name, busy_state, type, creator_id, is_public, location_id) VALUES ('9', '', 'mbusy', true, 'container', 'user3', false, 3);      -- /test3/mbusy
INSERT INTO node (parent_path, parent_relative_path, name, job_id, type, creator_id, is_public, location_id) VALUES ('9', '', 'mbusy', 'job1234', 'container', 'user3', false, 3);      -- /test3/mbusy
INSERT INTO node (parent_path, parent_relative_path, name, async_trans, type, creator_id, is_public, location_id) VALUES ('9', '', 'masynctrans', true, 'container', 'user3', false, 3);      -- /test3/masynctrans
INSERT INTO node (parent_path, parent_relative_path, name, type, creator_id, is_public, location_id) VALUES ('9', '', 'asyncloc', 'container', 'user3', false, 1);      -- /test3/asyncloc
INSERT INTO node (parent_path, parent_relative_path, name, type, creator_id, group_write, is_public, location_id) VALUES ('9', '', 'group1', 'container', 'user3','{"group1"}', false, 3);      -- /test3/group1