Skip to main content
summaryrefslogtreecommitdiffstats
blob: 03413bce4ea971309199347c46dc62a269cd716c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
/*******************************************************************************
 * Copyright (c) 2010 Boeing.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     Boeing - initial API and implementation
 *******************************************************************************/
package org.eclipse.osee.ats.notify;

import java.util.HashSet;
import java.util.Set;
import org.eclipse.osee.ats.core.client.workflow.AbstractWorkflowArtifact;
import org.eclipse.osee.framework.core.util.Result;
import org.eclipse.osee.framework.jdk.core.util.Strings;
import org.eclipse.osee.framework.skynet.core.artifact.Artifact;

/**
 * @author Donald G. Dunne
 */
public class EmailActionsData {

   public static enum EmailRecipient {
      Originator,
      Assignees
   }

   private String subject;
   private String body;
   private final Set<Artifact> workflows = new HashSet<Artifact>(5);
   private EmailRecipient emailRecipient = null;

   public String getSubject() {
      return subject;
   }

   public void setSubject(String subject) {
      this.subject = subject;
   }

   public String getBody() {
      return body;
   }

   public void setBody(String body) {
      this.body = body;
   }

   public Set<Artifact> getGroups() {
      return workflows;
   }

   public Result isValid() {
      if (!Strings.isValid(getSubject())) {
         return new Result("Must enter subject");
      }
      if (!Strings.isValid(getBody())) {
         return new Result("Must enter body");
      }
      if (getEmailRecipient() == null) {
         return new Result("Must select Email Recipient");
      }
      if (workflows.isEmpty()) {
         return new Result("No workflows dropped");
      }
      for (Artifact workflow : workflows) {
         if (!(workflow instanceof AbstractWorkflowArtifact)) {
            return new Result("Only valid for Workflow Artifacts, not [%s]", workflow.getArtifactTypeName());
         }
      }
      return Result.TrueResult;
   }

   public String getHtmlResult() {
      StringBuilder html = new StringBuilder();

      html.append("<pre>");
      html.append(body);
      html.append("</pre>");

      return html.toString();
   }

   public Set<Artifact> getWorkflows() {
      return workflows;
   }

   public EmailRecipient getEmailRecipient() {
      return emailRecipient;
   }

   public void setEmailRecipient(EmailRecipient emailRecipient) {
      this.emailRecipient = emailRecipient;
   }
}

Back to the top