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
bf9e4106
Commit
bf9e4106
authored
15 years ago
by
buczekp
Browse files
Options
Downloads
Patches
Plain Diff
[LMS-1264] added usage of properties
SVN: 13475
parent
efa65fb8
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
deep_sequencing_unit/source/java/ch/ethz/bsse/cisd/dsu/tracking/EntityTrackingEmailGenerator.java
+132
-1
132 additions, 1 deletion
.../bsse/cisd/dsu/tracking/EntityTrackingEmailGenerator.java
with
132 additions
and
1 deletion
deep_sequencing_unit/source/java/ch/ethz/bsse/cisd/dsu/tracking/EntityTrackingEmailGenerator.java
+
132
−
1
View file @
bf9e4106
...
...
@@ -17,14 +17,39 @@
package
ch.ethz.bsse.cisd.dsu.tracking
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.Collection
;
import
java.util.List
;
import
java.util.Properties
;
import
ch.systemsx.cisd.common.utilities.PropertyUtils
;
import
ch.systemsx.cisd.openbis.generic.shared.basic.dto.ExternalData
;
import
ch.systemsx.cisd.openbis.generic.shared.basic.dto.IEntityProperty
;
import
ch.systemsx.cisd.openbis.generic.shared.basic.dto.Sample
;
/**
* @author Piotr Buczek
*/
public
class
EntityTrackingEmailGenerator
implements
IEntityTrackingEmailGenerator
{
private
static
final
String
NOTIFICATION_EMAIL_SUBJECT
=
"notification-email-subject"
;
private
static
final
String
NOTIFICATION_EMAIL_FROM
=
"notification-email-from"
;
private
static
final
String
NOTIFICATION_EMAIL_REPLY_TO
=
"notification-email-reply-to"
;
private
final
String
subject
;
private
final
String
from
;
private
final
String
replyTo
;
public
EntityTrackingEmailGenerator
(
Properties
properties
)
{
subject
=
PropertyUtils
.
getMandatoryProperty
(
properties
,
NOTIFICATION_EMAIL_SUBJECT
);
from
=
PropertyUtils
.
getMandatoryProperty
(
properties
,
NOTIFICATION_EMAIL_FROM
);
replyTo
=
PropertyUtils
.
getMandatoryProperty
(
properties
,
NOTIFICATION_EMAIL_REPLY_TO
);
}
public
List
<
Email
>
generateEmails
(
TrackedEntities
trackedEntities
)
{
...
...
@@ -42,8 +67,114 @@ public class EntityTrackingEmailGenerator implements IEntityTrackingEmailGenerat
private
Email
createEmail
(
EntityTrackingEmailData
emailData
)
{
String
content
=
EmailContentGenerator
.
generate
(
emailData
);
String
recipient
=
emailData
.
getRecipient
();
return
new
Email
(
subject
,
content
,
replyTo
,
from
,
recipient
);
}
/**
* Helper class for generation of email content.
*
* @author Piotr Buczek
*/
private
static
final
class
EmailContentGenerator
{
private
static
final
char
NEW_LINE
=
'\n'
;
private
static
final
int
SEPARATOR_LINE_WIDTH
=
100
;
private
static
final
char
SECTION_SEPARATOR_CHAR
=
'#'
;
private
static
final
char
SUBSECTION_SEPARATOR_CHAR
=
'-'
;
private
static
final
String
SECTION_SEPARATOR_LINE
=
createSeparatorLine
(
SECTION_SEPARATOR_CHAR
);
private
static
final
String
SUBSECTION_SEPARATOR_LINE
=
createSeparatorLine
(
SUBSECTION_SEPARATOR_CHAR
);
private
static
final
String
PERMLINK_LABEL
=
"Permlink"
;
private
static
String
createSeparatorLine
(
char
separatorChar
)
{
char
[]
line
=
new
char
[
SEPARATOR_LINE_WIDTH
];
Arrays
.
fill
(
line
,
separatorChar
);
return
new
String
(
line
);
}
// TODO 2009-11-23, Piotr Buczek: implement
return
null
;
public
static
String
generate
(
EntityTrackingEmailData
emailData
)
{
StringBuilder
sb
=
new
StringBuilder
();
appendDataSetsInfo
(
sb
,
emailData
.
getDataSets
());
return
null
;
}
private
static
void
appendDataSetsInfo
(
StringBuilder
sb
,
List
<
ExternalData
>
dataSets
)
{
appendln
(
sb
,
SECTION_SEPARATOR_LINE
);
appendln
(
sb
,
SUBSECTION_SEPARATOR_LINE
);
appendln
(
sb
,
String
.
format
(
"Tracked creation of %s data set(s) connected with Flow Lane samples."
,
dataSets
.
size
()));
appendln
(
sb
,
SUBSECTION_SEPARATOR_LINE
);
for
(
ExternalData
dataSet
:
dataSets
)
{
appendDataSetInfo
(
sb
,
dataSet
);
appendln
(
sb
,
SUBSECTION_SEPARATOR_LINE
);
}
}
private
static
void
appendDataSetInfo
(
StringBuilder
sb
,
ExternalData
dataSet
)
{
// basic data set info
appendAttribute
(
sb
,
PERMLINK_LABEL
,
dataSet
.
getPermlink
());
appendNewline
(
sb
);
// basic flow lane and sequencing sample info
Sample
flowLaneSample
=
dataSet
.
getSample
();
assert
flowLaneSample
!=
null
;
Sample
sequencingSample
=
flowLaneSample
.
getGeneratedFrom
();
assert
sequencingSample
!=
null
;
appendAttribute
(
sb
,
"Flow Lane sample"
,
String
.
format
(
"'%s'\n %s"
,
flowLaneSample
.
getCode
(),
flowLaneSample
.
getPermlink
()));
appendAttribute
(
sb
,
"Sequencing sample"
,
String
.
format
(
"'%s'\n %s"
,
sequencingSample
.
getCode
(),
sequencingSample
.
getPermlink
()));
// data set properties
// no information about assigned properties - cannot put information about empty
// List<DataSetTypePropertyType> assignedProperties =
// dataSet.getDataSetType().getAssignedPropertyTypes();
for
(
IEntityProperty
property
:
dataSet
.
getProperties
())
{
appendProperty
(
sb
,
property
);
}
}
private
static
void
appendProperty
(
StringBuilder
sb
,
IEntityProperty
property
)
{
final
String
label
=
property
.
getPropertyType
().
getLabel
();
final
String
value
=
property
.
getValue
();
appendAttribute
(
sb
,
label
,
value
);
}
private
static
void
appendAttribute
(
StringBuilder
sb
,
String
name
,
String
value
)
{
appendln
(
sb
,
String
.
format
(
"- %s:\n %s"
,
name
,
value
==
null
?
"(empty)"
:
value
));
}
private
static
void
appendln
(
StringBuilder
sb
,
String
string
)
{
sb
.
append
(
string
);
appendNewline
(
sb
);
}
private
static
void
appendNewline
(
StringBuilder
sb
)
{
sb
.
append
(
NEW_LINE
);
}
}
}
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