Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
V
vospace-rest
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Redmine
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
VOSpace INAF
vospace-rest
Commits
9e8f0926
Commit
9e8f0926
authored
4 years ago
by
Sonia Zorba
Browse files
Options
Downloads
Patches
Plain Diff
Used job_id instead of busy_state
parent
9226fe7e
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/main/java/it/inaf/oats/vospace/persistence/NodeDAO.java
+16
-8
16 additions, 8 deletions
src/main/java/it/inaf/oats/vospace/persistence/NodeDAO.java
src/test/resources/test-data.sql
+1
-1
1 addition, 1 deletion
src/test/resources/test-data.sql
with
17 additions
and
9 deletions
src/main/java/it/inaf/oats/vospace/persistence/NodeDAO.java
+
16
−
8
View file @
9e8f0926
...
...
@@ -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"
;
...
...
This diff is collapsed.
Click to expand it.
src/test/resources/test-data.sql
+
1
−
1
View file @
9e8f0926
...
...
@@ -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
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment