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
35921098
Commit
35921098
authored
13 years ago
by
kaloyane
Browse files
Options
Downloads
Patches
Plain Diff
add: sending of emails
SVN: 21942
parent
54fd86f0
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
sanofi/dist/etc/sanofi-dropbox/sanofi-dropbox.py
+53
-12
53 additions, 12 deletions
sanofi/dist/etc/sanofi-dropbox/sanofi-dropbox.py
sanofi/sourceTest/java/ch/systemsx/cisd/sanofi/dss/test/SanofiDropboxJythonTest.java
+20
-0
20 additions, 0 deletions
...ystemsx/cisd/sanofi/dss/test/SanofiDropboxJythonTest.java
with
73 additions
and
12 deletions
sanofi/dist/etc/sanofi-dropbox/sanofi-dropbox.py
+
53
−
12
View file @
35921098
import
ch.systemsx.cisd.openbis.dss.generic.shared.api.internal.v1.MaterialIdentifierCollection
as
MaterialIdentifierCollection
import
ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.SearchCriteria
as
SearchCriteria
import
ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.SearchCriteria.MatchClause
as
MatchClause
import
ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.SearchCriteria.MatchClauseAttribute
as
MatchClauseAttribute
import
ch.systemsx.cisd.openbis.plugin.screening.shared.basic.dto.ScreeningConstants
as
ScreeningConstants
from
ch.systemsx.cisd.common.mail
import
From
from
ch.systemsx.cisd.openbis.generic.shared.api.v1.dto
import
SearchCriteria
from
ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.SearchCriteria
import
MatchClause
,
MatchClauseAttribute
from
ch.systemsx.cisd.openbis.dss.generic.shared.api.internal.v1
import
MaterialIdentifierCollection
from
ch.systemsx.cisd.openbis.plugin.screening.shared.basic.dto
import
ScreeningConstants
PLATE_TYPE
=
"
PLATE
"
DATA_SET_TYPE
=
"
HCS_IMAGE_RAW
"
DATA_SET_BATCH_PROPNAME
=
"
ACQUISITION_BATCH
"
registeredDataSets
=
[]
OPENBIS_URL
=
"
https://bwl27.sanofi-aventis.com:8443/openbis
"
EXPERIMENT_RECIPIENTS_PROPNAME
=
"
EMAIL_RECIPIENTS
"
DEFAULT_RECIPIENT_LIST
=
"
Matthew.Smicker@sanofi-aventis.com
"
def
rollback_transaction
(
service
,
transaction
,
runner
,
ex
):
plateLink
=
createPlateLink
(
OPENBIS_URL
,
plate
.
getCode
())
errorMessage
=
ex
.
getMessage
()
sendEmail
(
"
openBIS: Data registration failed
"
,
"""
Dear Mr./Mrs.
Registering new data for plate %(plateLink)s has failed with error
'
%(errorMessage)s
'
.
openBIS
"""
%
vars
())
def
commit_transaction
(
service
,
transaction
):
plateLink
=
createPlateLink
(
OPENBIS_URL
,
plate
.
getCode
())
sendEmail
(
"
openBIS: New data registered
"
,
"""
Dear Mr./Mrs.
New data for the plate %(plateLink)s has been registered.
Have a nice day!
openBIS
"""
%
vars
())
def
rollback_transaction
(
service
,
tr
,
runner
,
ex
):
pass
def
sendEmail
(
title
,
content
):
if
experiment
is
not
None
:
recipientsProp
=
experiment
.
getPropertyValue
(
EXPERIMENT_RECIPIENTS_PROPNAME
)
if
not
recipientsProp
:
recipientsProp
=
DEFAULT_RECIPIENT_LIST
recipients
=
[
email
.
strip
()
for
email
in
recipientsProp
.
split
(
"
,
"
)
]
fromAddress
=
From
(
"
openbis@sanofi-aventis.com
"
)
replyTo
=
None
state
.
mailClient
.
sendMessage
(
title
,
content
,
replyTo
,
fromAddress
,
recipients
)
def
c
ommit_transaction
(
service
,
tr
):
pass
def
c
reatePlateLink
(
openbisUrl
,
code
):
return
"
<a href=
'
%(openbisUrl)s#entity=SAMPLE&sample_type=PLATE&action=SEARCH&code=%(code)s
'
>%(code)s</a>
"
%
vars
()
def
findPlateByCode
(
code
):
"""
...
...
@@ -105,8 +144,6 @@ class PlateInitializer:
"
Plate geometry (width=%i) does not agree with LIBRARY_TEMPLATE (line=%i,width=%i).
"
%
(
plateWidth
,
i
,
len
(
csvLists
[
i
]))
def
parseLibraryTemplate
(
self
):
experimentId
=
plate
.
getExperiment
().
getExperimentIdentifier
()
experiment
=
transaction
.
getExperiment
(
experimentId
)
template
=
experiment
.
getPropertyValue
(
self
.
LIBRARY_TEMPLATE_PROPNAME
)
csvLists
=
[
line
.
split
(
"
,
"
)
for
line
in
template
.
splitlines
()
]
...
...
@@ -231,6 +268,8 @@ dataSet = transaction.createNewDataSet(DATA_SET_TYPE)
(
batchName
,
barCode
)
=
parseIncomingDirname
(
incoming
.
getName
())
dataSet
.
setPropertyValue
(
DATA_SET_BATCH_PROPNAME
,
batchName
)
plate
=
findPlateByCode
(
barCode
)
experimentId
=
plate
.
getExperiment
().
getExperimentIdentifier
()
experiment
=
transaction
.
getExperiment
(
experimentId
)
if
len
(
plate
.
getContainedSamples
())
==
0
:
plateInitializer
=
PlateInitializer
(
plate
)
...
...
@@ -238,3 +277,5 @@ if len(plate.getContainedSamples()) == 0:
dataSet
.
setSample
(
plate
)
transaction
.
moveFile
(
incoming
.
getAbsolutePath
(),
dataSet
)
commit_transaction
(
None
,
None
)
\ No newline at end of file
This diff is collapsed.
Click to expand it.
sanofi/sourceTest/java/ch/systemsx/cisd/sanofi/dss/test/SanofiDropboxJythonTest.java
+
20
−
0
View file @
35921098
...
...
@@ -28,12 +28,15 @@ import java.util.Map;
import
java.util.Properties
;
import
org.apache.commons.io.FileUtils
;
import
org.apache.commons.lang.StringUtils
;
import
org.jmock.Expectations
;
import
org.testng.annotations.BeforeMethod
;
import
org.testng.annotations.Test
;
import
ch.systemsx.cisd.common.eodsql.MockDataSet
;
import
ch.systemsx.cisd.common.filesystem.FileUtilities
;
import
ch.systemsx.cisd.common.mail.From
;
import
ch.systemsx.cisd.common.test.AssertionUtil
;
import
ch.systemsx.cisd.common.test.RecordingMatcher
;
import
ch.systemsx.cisd.etlserver.registrator.AbstractJythonDataSetHandlerTest
;
import
ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.SearchCriteria
;
...
...
@@ -72,6 +75,11 @@ public class SanofiDropboxJythonTest extends AbstractJythonDataSetHandlerTest
private
static
final
String
LIBRARY_TEMPLATE_PROPNAME
=
"LIBRARY_TEMPLATE"
;
private
static
final
String
EXPERIMENT_RECIPIENTS_PROPNAME
=
"EMAIL_RECIPIENTS"
;
private
static
final
String
[]
EXPERIMENT_RECIPIENTS
=
new
String
[]
{
"admin@sanofi.com"
,
"mickey@mouse.org"
};
private
static
final
String
MATERIAL_TYPE
=
"COMPOUND_BATCH"
;
private
static
final
String
POSITIVE_CONTROL_TYPE
=
"POSITIVE_CONTROL"
;
...
...
@@ -123,6 +131,7 @@ public class SanofiDropboxJythonTest extends AbstractJythonDataSetHandlerTest
new
RecordingMatcher
<
ch
.
systemsx
.
cisd
.
openbis
.
generic
.
shared
.
dto
.
AtomicEntityOperationDetails
>();
final
RecordingMatcher
<
ListMaterialCriteria
>
materialCriteria
=
new
RecordingMatcher
<
ListMaterialCriteria
>();
final
RecordingMatcher
<
String
>
email
=
new
RecordingMatcher
<
String
>();
context
.
checking
(
new
Expectations
()
{
{
...
...
@@ -153,6 +162,10 @@ public class SanofiDropboxJythonTest extends AbstractJythonDataSetHandlerTest
one
(
openBisService
).
performEntityOperations
(
with
(
atomicatOperationDetails
));
will
(
returnValue
(
new
AtomicEntityOperationResult
()));
one
(
mailClient
).
sendMessage
(
with
(
any
(
String
.
class
)),
with
(
email
),
with
(
aNull
(
String
.
class
)),
with
(
any
(
From
.
class
)),
with
(
equal
(
EXPERIMENT_RECIPIENTS
)));
}
});
...
...
@@ -182,6 +195,11 @@ public class SanofiDropboxJythonTest extends AbstractJythonDataSetHandlerTest
assertEquals
(
DATA_SET_CODE
,
dataSet
.
getCode
());
assertEquals
(
DATA_SET_TYPE
,
dataSet
.
getDataSetType
());
AssertionUtil
.
assertContains
(
"New data for the plate <a href='https://bwl27.sanofi-aventis.com:8443/openbis#entity=SAMPLE"
+
"&sample_type=PLATE&action=SEARCH&code=TEST-PLATE'>TEST-PLATE</a> has been registered."
,
email
.
recordedObject
());
context
.
assertIsSatisfied
();
}
...
...
@@ -291,6 +309,8 @@ public class SanofiDropboxJythonTest extends AbstractJythonDataSetHandlerTest
ExperimentBuilder
experimentBuilder
=
new
ExperimentBuilder
();
experimentBuilder
.
identifier
(
EXPERIMENT_IDENTIFIER
);
experimentBuilder
.
property
(
LIBRARY_TEMPLATE_PROPNAME
,
libraryTemplate
);
String
recipients
=
StringUtils
.
join
(
Arrays
.
asList
(
EXPERIMENT_RECIPIENTS
),
","
);
experimentBuilder
.
property
(
EXPERIMENT_RECIPIENTS_PROPNAME
,
recipients
);
SampleBuilder
sampleBuilder
=
new
SampleBuilder
();
sampleBuilder
.
experiment
(
experimentBuilder
.
getExperiment
());
...
...
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