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
25221c02
Commit
25221c02
authored
9 years ago
by
juanf
Browse files
Options
Downloads
Patches
Plain Diff
SSDM-2904 : Support creation of datasets with auto-generated codes (Working prototype)
SVN: 35336
parent
1570004a
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/executor/dataset/CreateDataSetExecutor.java
+35
-21
35 additions, 21 deletions
...server/api/v3/executor/dataset/CreateDataSetExecutor.java
with
35 additions
and
21 deletions
openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/executor/dataset/CreateDataSetExecutor.java
+
35
−
21
View file @
25221c02
...
...
@@ -95,22 +95,10 @@ public class CreateDataSetExecutor extends AbstractCreateEntityExecutor<DataSetC
@Autowired
private
IVerifyDataSetExecutor
verifyDataSetExecutor
;
@Override
protected
void
checkData
(
IOperationContext
context
,
DataSetCreation
creation
)
{
if
(
creation
.
getTypeId
()
==
null
)
{
throw
new
UserFailureException
(
"Type id cannot be null."
);
}
if
(
creation
.
getExperimentId
()
==
null
&&
creation
.
getSampleId
()
==
null
)
{
throw
new
UserFailureException
(
"Experiment id and sample id cannot be both null."
);
}
}
@Override
protected
List
<
DataPE
>
createEntities
(
IOperationContext
context
,
Collection
<
DataSetCreation
>
creations
)
{
// Get Types
Collection
<
IEntityTypeId
>
typeIds
=
new
HashSet
<
IEntityTypeId
>();
for
(
DataSetCreation
creation
:
creations
)
...
...
@@ -119,6 +107,13 @@ public class CreateDataSetExecutor extends AbstractCreateEntityExecutor<DataSetC
}
Map
<
IEntityTypeId
,
EntityTypePE
>
types
=
mapEntityTypeByIdExecutor
.
map
(
context
,
EntityKind
.
DATA_SET
,
typeIds
);
// Validate DataSet creations
for
(
DataSetCreation
creation
:
creations
)
{
checkData
(
context
,
creation
,
types
.
get
(
creation
.
getTypeId
()));
}
IPermIdDAO
codeGenerator
=
daoFactory
.
getPermIdDAO
();
List
<
DataPE
>
dataSets
=
new
LinkedList
<
DataPE
>();
...
...
@@ -126,14 +121,8 @@ public class CreateDataSetExecutor extends AbstractCreateEntityExecutor<DataSetC
{
DataSetTypePE
type
=
(
DataSetTypePE
)
types
.
get
(
creation
.
getTypeId
());
if
(
type
==
null
)
{
throw
new
ObjectNotFoundException
(
creation
.
getTypeId
());
}
else
if
(
StringUtils
.
isEmpty
(
creation
.
getCode
())
&&
false
==
creation
.
isAutoGeneratedCode
())
{
throw
new
UserFailureException
(
"Code cannot be empty for a non auto generated code."
);
}
else
if
(
false
==
StringUtils
.
isEmpty
(
creation
.
getCode
())
&&
creation
.
isAutoGeneratedCode
())
{
throw
new
UserFailureException
(
"Code should be empty when auto generated code is selected."
);
}
else
if
(
creation
.
getCode
()
==
null
)
{
//Create code if is not present
if
(
StringUtils
.
isEmpty
(
creation
.
getCode
()))
{
creation
.
setCode
(
codeGenerator
.
createPermId
());
}
...
...
@@ -166,6 +155,31 @@ public class CreateDataSetExecutor extends AbstractCreateEntityExecutor<DataSetC
return
dataSets
;
}
private
void
checkData
(
IOperationContext
context
,
DataSetCreation
creation
,
EntityTypePE
type
)
{
if
(
type
==
null
)
{
throw
new
ObjectNotFoundException
(
creation
.
getTypeId
());
}
else
if
(
StringUtils
.
isEmpty
(
creation
.
getCode
())
&&
false
==
creation
.
isAutoGeneratedCode
())
{
throw
new
UserFailureException
(
"Code cannot be empty for a non auto generated code."
);
}
else
if
(
false
==
StringUtils
.
isEmpty
(
creation
.
getCode
())
&&
creation
.
isAutoGeneratedCode
())
{
throw
new
UserFailureException
(
"Code should be empty when auto generated code is selected."
);
}
}
@Override
protected
void
checkData
(
IOperationContext
context
,
DataSetCreation
creation
)
{
if
(
creation
.
getTypeId
()
==
null
)
{
throw
new
UserFailureException
(
"Type id cannot be null."
);
}
if
(
creation
.
getExperimentId
()
==
null
&&
creation
.
getSampleId
()
==
null
)
{
throw
new
UserFailureException
(
"Experiment id and sample id cannot be both null."
);
}
}
@Override
protected
DataSetPermId
createPermId
(
IOperationContext
context
,
DataPE
entity
)
{
...
...
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