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
bf2d385e
Commit
bf2d385e
authored
12 years ago
by
jakubs
Browse files
Options
Downloads
Patches
Plain Diff
BIS-201 SP-277 do the sample creation in batches ordered by dependencies
SVN: 26843
parent
9cae71ae
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
openbis/source/java/ch/systemsx/cisd/openbis/generic/server/ETLService.java
+75
-34
75 additions, 34 deletions
...a/ch/systemsx/cisd/openbis/generic/server/ETLService.java
with
75 additions
and
34 deletions
openbis/source/java/ch/systemsx/cisd/openbis/generic/server/ETLService.java
+
75
−
34
View file @
bf2d385e
...
...
@@ -22,6 +22,7 @@ import java.util.Collections;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.HashSet
;
import
java.util.LinkedList
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map.Entry
;
...
...
@@ -29,12 +30,11 @@ import java.util.Set;
import
javax.servlet.http.HttpServletRequest
;
import
org.apache.commons.lang.StringUtils
;
import
ch.systemsx.cisd.authentication.DefaultSessionManager
;
import
ch.systemsx.cisd.authentication.DummyAuthenticationService
;
import
ch.systemsx.cisd.authentication.IAuthenticationService
;
import
ch.systemsx.cisd.authentication.ISessionManager
;
import
ch.systemsx.cisd.common.collections.GroupingDAG
;
import
ch.systemsx.cisd.common.conversation.context.ServiceConversationsThreadContext
;
import
ch.systemsx.cisd.common.conversation.progress.IServiceConversationProgressListener
;
import
ch.systemsx.cisd.common.exceptions.ConfigurationFailureException
;
...
...
@@ -1662,19 +1662,81 @@ public class ETLService extends AbstractCommonServer<IETLLIMSService> implements
IServiceConversationProgressListener
progress
,
boolean
authorize
)
{
List
<
NewSample
>
newSamples
=
operationDetails
.
getSampleRegistrations
();
List
<
NewSample
>
containerSamples
=
new
ArrayList
<
NewSample
>();
List
<
NewSample
>
containedSamples
=
new
ArrayList
<
NewSample
>();
List
<
NewSample
>
instanceSamples
=
new
ArrayList
<
NewSample
>();
List
<
NewSample
>
spaceSamples
=
new
ArrayList
<
NewSample
>();
for
(
NewSample
newSample
:
newSamples
)
if
(
authorize
)
{
if
(
StringUtils
.
isEmpty
(
newSample
.
getContainerIdentifierForNewSample
()))
authorizeSampleCreation
(
session
,
newSamples
);
}
String
userIdOrNull
=
operationDetails
.
tryUserIdOrNull
();
PersonPE
registratorOrNull
=
tryFindPersonForUserIdOrEmail
(
userIdOrNull
);
final
ISampleTable
sampleTable
=
businessObjectFactory
.
createSampleTable
(
session
);
List
<
List
<
NewSample
>>
sampleGroups
=
splitIntoDependencyGroups
(
newSamples
);
for
(
List
<
NewSample
>
groupOfSamples
:
sampleGroups
)
{
BatchOperationExecutor
.
executeInBatches
(
new
SampleBatchRegistration
(
sampleTable
,
groupOfSamples
,
registratorOrNull
),
getBatchSize
(
operationDetails
),
progress
,
"createContainerSamples"
);
}
return
newSamples
.
size
();
}
/**
* Splits the samples using the grouping dag into groups, that can be executed in batches one
* after another, that samples in later batches depend only on the samples from earlier batches
*/
private
List
<
List
<
NewSample
>>
splitIntoDependencyGroups
(
List
<
NewSample
>
newSamples
)
{
HashMap
<
String
,
NewSample
>
identifierToSample
=
new
HashMap
<
String
,
NewSample
>();
HashMap
<
String
,
Collection
<
String
>>
adjacencyGraph
=
new
HashMap
<
String
,
Collection
<
String
>>();
for
(
NewSample
sample
:
newSamples
)
{
identifierToSample
.
put
(
sample
.
getIdentifier
(),
sample
);
adjacencyGraph
.
put
(
sample
.
getIdentifier
(),
new
LinkedList
<
String
>());
}
for
(
NewSample
sample
:
newSamples
)
{
if
(
sample
.
getContainerIdentifier
()
!=
null
)
{
containerSamples
.
add
(
newSample
);
}
else
adjacencyGraph
.
get
(
sample
.
getContainerIdentifier
()).
add
(
sample
.
getIdentifier
());
}
String
[]
parents
=
sample
.
getParentsOrNull
();
if
(
parents
!=
null
)
{
containedSamples
.
add
(
newSample
);
for
(
String
parent
:
parents
)
{
adjacencyGraph
.
get
(
parent
).
add
(
sample
.
getIdentifier
());
}
}
}
List
<
List
<
String
>>
identifierGroups
=
GroupingDAG
.
groupByDepencies
(
adjacencyGraph
);
List
<
List
<
NewSample
>>
sampleGroups
=
new
LinkedList
<
List
<
NewSample
>>();
for
(
List
<
String
>
listOfIdentifiers
:
identifierGroups
)
{
List
<
NewSample
>
listOfSamples
=
new
LinkedList
<
NewSample
>();
for
(
String
identifier
:
listOfIdentifiers
)
{
listOfSamples
.
add
(
identifierToSample
.
get
(
identifier
));
}
sampleGroups
.
add
(
listOfSamples
);
}
return
sampleGroups
;
}
private
void
authorizeSampleCreation
(
Session
session
,
List
<
NewSample
>
newSamples
)
{
List
<
NewSample
>
instanceSamples
=
new
ArrayList
<
NewSample
>();
List
<
NewSample
>
spaceSamples
=
new
ArrayList
<
NewSample
>();
for
(
NewSample
newSample
:
newSamples
)
{
SampleIdentifier
sampleIdentifier
=
SampleIdentifierFactory
.
parse
(
newSample
);
if
(
sampleIdentifier
.
isDatabaseInstanceLevel
())
{
...
...
@@ -1685,29 +1747,8 @@ public class ETLService extends AbstractCommonServer<IETLLIMSService> implements
}
}
if
(
authorize
)
{
checkInstanceSampleCreationAllowed
(
session
,
instanceSamples
);
checkSpaceSampleCreationAllowed
(
session
,
spaceSamples
);
}
String
userIdOrNull
=
operationDetails
.
tryUserIdOrNull
();
PersonPE
registratorOrNull
=
tryFindPersonForUserIdOrEmail
(
userIdOrNull
);
final
ISampleTable
sampleTable
=
businessObjectFactory
.
createSampleTable
(
session
);
// in the first pass register samples without container to avoid dependency inversion
BatchOperationExecutor
.
executeInBatches
(
new
SampleBatchRegistration
(
sampleTable
,
containerSamples
,
registratorOrNull
),
getBatchSize
(
operationDetails
),
progress
,
"createContainerSamples"
);
// register samples with a container identifier
// (container should have been created in the first pass)
BatchOperationExecutor
.
executeInBatches
(
new
SampleBatchRegistration
(
sampleTable
,
containedSamples
,
registratorOrNull
),
getBatchSize
(
operationDetails
),
progress
,
"createContainedSamples"
);
return
newSamples
.
size
();
checkInstanceSampleCreationAllowed
(
session
,
instanceSamples
);
checkSpaceSampleCreationAllowed
(
session
,
spaceSamples
);
}
private
void
checkInstanceSampleCreationAllowed
(
Session
session
,
List
<
NewSample
>
instanceSamples
)
...
...
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