Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
openbis
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
sispub
openbis
Commits
e0a88a82
Commit
e0a88a82
authored
1 year ago
by
Adam Laskowski
Browse files
Options
Downloads
Patches
Plain Diff
SSDM-55: Fixed handling multivalue array properties
parent
a1e2f9b3
No related branches found
No related tags found
1 merge request
!40
SSDM-13578 : 2PT : Database and V3 Implementation - include the new AFS "free"...
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
server-application-server/source/java/ch/systemsx/cisd/openbis/generic/server/dataaccess/EntityPropertiesConverter.java
+30
-12
30 additions, 12 deletions
.../generic/server/dataaccess/EntityPropertiesConverter.java
with
30 additions
and
12 deletions
server-application-server/source/java/ch/systemsx/cisd/openbis/generic/server/dataaccess/EntityPropertiesConverter.java
+
30
−
12
View file @
e0a88a82
...
...
@@ -313,30 +313,43 @@ public final class EntityPropertiesConverter implements IEntityPropertiesConvert
}
private
Serializable
translateProperty
(
PropertyTypePE
propertyType
,
Serializable
value
)
{
final
String
regex
=
"(?<!\\\\)"
+
Pattern
.
quote
(
SEPARATOR
);
if
(
value
==
null
||
!
value
.
getClass
().
equals
(
String
.
class
))
{
//Nothing to translate
return
value
;
if
(
propertyType
.
isMultiValue
()
&&
ARRAY_TYPES
.
contains
(
propertyType
.
getType
().
getCode
()))
{
Serializable
[]
array
=
(
Serializable
[])
value
;
List
<
Serializable
>
values
=
new
ArrayList
<>();
for
(
Serializable
element
:
array
)
{
if
(
element
.
getClass
().
equals
(
String
.
class
))
{
values
.
add
(
stripBracketsIfPresent
((
String
)
element
).
split
(
regex
));
}
else
{
// value is properly serialized already, nothing to do here
return
value
;
}
}
return
values
.
toArray
(
Serializable
[]::
new
);
}
else
{
//Nothing to translate
return
value
;
}
}
String
regex
=
"(?<!\\\\)"
+
Pattern
.
quote
(
SEPARATOR
);
String
propertyValue
=
value
.
toString
().
trim
();
if
(
propertyValue
.
isEmpty
())
{
return
null
;
}
if
(
propertyType
.
isMultiValue
())
{
if
(
propertyValue
.
startsWith
(
"["
))
{
propertyValue
=
propertyValue
.
substring
(
1
,
propertyValue
.
length
()-
1
).
trim
();
}
propertyValue
=
stripBracketsIfPresent
(
propertyValue
);
if
(
propertyValue
.
isEmpty
())
{
return
null
;
}
if
(
ARRAY_TYPES
.
contains
(
propertyType
.
getType
().
getCode
()))
{
// Multi-value array properties
String
multiArrayRegex
=
"\\],\\s*\\["
;
if
(
propertyValue
.
startsWith
(
"["
))
{
propertyValue
=
propertyValue
.
substring
(
1
,
propertyValue
.
length
()-
1
).
trim
();
}
propertyValue
=
stripBracketsIfPresent
(
propertyValue
);
return
Arrays
.
stream
(
propertyValue
.
split
(
multiArrayRegex
))
.
map
(
String:
:
trim
)
.
map
(
x
->
Arrays
.
stream
(
x
.
split
(
regex
))
...
...
@@ -350,9 +363,7 @@ public final class EntityPropertiesConverter implements IEntityPropertiesConvert
}
}
else
{
if
(
ARRAY_TYPES
.
contains
(
propertyType
.
getType
().
getCode
()))
{
if
(
propertyValue
.
startsWith
(
"["
))
{
propertyValue
=
propertyValue
.
substring
(
1
,
propertyValue
.
length
()-
1
);
}
propertyValue
=
stripBracketsIfPresent
(
propertyValue
);
return
Arrays
.
stream
(
propertyValue
.
split
(
regex
))
.
map
(
String:
:
trim
)
.
toArray
(
String
[]::
new
);
...
...
@@ -362,6 +373,13 @@ public final class EntityPropertiesConverter implements IEntityPropertiesConvert
}
}
private
String
stripBracketsIfPresent
(
String
value
)
{
if
(
value
.
startsWith
(
"["
))
{
value
=
value
.
substring
(
1
,
value
.
length
()-
1
).
trim
();
}
return
value
;
}
private
Serializable
getPropertyValue
(
final
IEntityProperty
property
)
{
Serializable
result
=
property
.
getValue
();
if
(
result
!=
null
)
{
...
...
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