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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
VOSpace INAF
vospace-rest
Commits
5157ea1f
Commit
5157ea1f
authored
4 years ago
by
Sonia Zorba
Browse files
Options
Downloads
Patches
Plain Diff
Fixed relative path issue in NodeDAO
parent
7380d68c
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/it/inaf/oats/vospace/persistence/NodeDAO.java
+15
-14
15 additions, 14 deletions
src/main/java/it/inaf/oats/vospace/persistence/NodeDAO.java
with
15 additions
and
14 deletions
src/main/java/it/inaf/oats/vospace/persistence/NodeDAO.java
+
15
−
14
View file @
5157ea1f
...
@@ -41,30 +41,30 @@ public class NodeDAO {
...
@@ -41,30 +41,30 @@ public class NodeDAO {
String
path
=
nodeURI
.
replaceAll
(
"vos://[^/]+"
,
""
);
String
path
=
nodeURI
.
replaceAll
(
"vos://[^/]+"
,
""
);
String
parentPath
=
getParentPath
(
path
);
String
parentPath
=
getParentPath
(
path
);
String
sql
=
"SELECT path from "
String
sql
=
"SELECT path
, relative_path
from "
+
"node n join node_vos_path p on n.node_id = p.node_id "
+
"node n join node_vos_path p on n.node_id = p.node_id "
+
"where p.vos_path = ?"
;
+
"where p.vos_path = ?"
;
List
<
String
>
ltreeParentP
aths
=
jdbcTemplate
.
query
(
conn
->
{
List
<
NodePaths
>
p
aths
=
jdbcTemplate
.
query
(
conn
->
{
PreparedStatement
ps
=
conn
.
prepareStatement
(
sql
);
PreparedStatement
ps
=
conn
.
prepareStatement
(
sql
);
ps
.
setString
(
1
,
parentPath
);
ps
.
setString
(
1
,
parentPath
);
return
ps
;
return
ps
;
},
(
row
,
index
)
->
{
},
(
row
,
index
)
->
{
return
row
.
getString
(
"path"
);
return
getPathsFromResultSet
(
row
);
});
});
if
(
ltreeParentP
aths
.
isEmpty
())
{
if
(
p
aths
.
isEmpty
())
{
throw
new
IllegalStateException
(
"Unable to find parent node during node creation"
);
throw
new
IllegalStateException
(
"Unable to find parent node during node creation"
);
}
}
if
(
ltreeParentP
aths
.
size
()
>
1
)
{
if
(
p
aths
.
size
()
>
1
)
{
throw
new
IllegalStateException
(
"Multiple ltree parent paths found for "
+
parentPath
);
throw
new
IllegalStateException
(
"Multiple ltree parent paths found for "
+
parentPath
);
}
}
StringBuilder
sb
=
new
StringBuilder
();
StringBuilder
sb
=
new
StringBuilder
();
sb
.
append
(
"INSERT INTO node"
);
sb
.
append
(
"INSERT INTO node"
);
sb
.
append
(
" (name, busy_state, owner_id, creator_id, group_read, group_write,"
);
sb
.
append
(
" (name, busy_state, owner_id, creator_id, group_read, group_write,"
);
sb
.
append
(
" is_public,
parent_path, type)"
);
sb
.
append
(
" is_public, parent
_path, parent_relative
_path, type)"
);
sb
.
append
(
" VALUES (?, ?, ?, ?, ?, ?, ?, ?, ? )"
);
sb
.
append
(
" VALUES (?, ?, ?, ?, ?, ?, ?, ?,
?,
? )"
);
jdbcTemplate
.
update
(
conn
->
{
jdbcTemplate
.
update
(
conn
->
{
PreparedStatement
ps
=
conn
.
prepareStatement
(
sb
.
toString
());
PreparedStatement
ps
=
conn
.
prepareStatement
(
sb
.
toString
());
...
@@ -75,8 +75,9 @@ public class NodeDAO {
...
@@ -75,8 +75,9 @@ public class NodeDAO {
ps
.
setArray
(
5
,
fromPropertyToArray
(
ps
,
getProperty
(
myNode
,
getPropertyURI
(
"groupread"
))));
ps
.
setArray
(
5
,
fromPropertyToArray
(
ps
,
getProperty
(
myNode
,
getPropertyURI
(
"groupread"
))));
ps
.
setArray
(
6
,
fromPropertyToArray
(
ps
,
getProperty
(
myNode
,
getPropertyURI
(
"groupwrite"
))));
ps
.
setArray
(
6
,
fromPropertyToArray
(
ps
,
getProperty
(
myNode
,
getPropertyURI
(
"groupwrite"
))));
ps
.
setBoolean
(
7
,
Boolean
.
valueOf
(
getProperty
(
myNode
,
getPropertyURI
(
"publicread"
))));
ps
.
setBoolean
(
7
,
Boolean
.
valueOf
(
getProperty
(
myNode
,
getPropertyURI
(
"publicread"
))));
ps
.
setObject
(
8
,
ltreeParentPaths
.
get
(
0
),
Types
.
OTHER
);
ps
.
setObject
(
8
,
paths
.
get
(
0
).
path
,
Types
.
OTHER
);
ps
.
setObject
(
9
,
getDbNodeType
(
myNode
),
Types
.
OTHER
);
ps
.
setObject
(
9
,
paths
.
get
(
0
).
relativePath
,
Types
.
OTHER
);
ps
.
setObject
(
10
,
getDbNodeType
(
myNode
),
Types
.
OTHER
);
return
ps
;
return
ps
;
});
});
...
@@ -283,18 +284,18 @@ public class NodeDAO {
...
@@ -283,18 +284,18 @@ public class NodeDAO {
private
class
NodePaths
{
private
class
NodePaths
{
private
String
path
;
private
final
String
path
;
private
String
parent
Path
;
private
final
String
relative
Path
;
public
NodePaths
(
String
myPath
,
String
my
Parent
Path
)
{
public
NodePaths
(
String
myPath
,
String
my
Relative
Path
)
{
this
.
path
=
myPath
;
this
.
path
=
myPath
;
this
.
parent
Path
=
my
Parent
Path
;
this
.
relative
Path
=
my
Relative
Path
;
}
}
@Override
@Override
public
String
toString
()
{
public
String
toString
()
{
return
parent
Path
+
" "
+
path
;
return
relative
Path
+
" "
+
path
;
}
}
}
}
}
}
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