-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
381 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
package bioGUI; | ||
|
||
import java.lang.reflect.Array; | ||
import java.text.SimpleDateFormat; | ||
import java.util.ArrayList; | ||
import java.util.Collections; | ||
import java.util.Date; | ||
|
||
/** | ||
* Created by joppich on 10/4/16. | ||
*/ | ||
public class TemplateRequest { | ||
|
||
private int type, timestamp; | ||
private boolean anonym; | ||
private String displayname, typeStr, omictoolslink; | ||
|
||
public void setOmictoolslink(String omictoolslink) { | ||
this.omictoolslink = omictoolslink; | ||
} | ||
public String getOmictoolslink() { | ||
return this.omictoolslink; | ||
} | ||
|
||
public String getDisplayname() { | ||
return displayname; | ||
} | ||
|
||
public void setDisplayname(String displayname) { | ||
this.displayname = displayname; | ||
} | ||
|
||
public int getTimestamp() { | ||
return timestamp; | ||
} | ||
public void setTimestamp(int timestamp) { | ||
this.timestamp = timestamp; | ||
} | ||
|
||
public String getTypeStr() { | ||
return "" + this.type; | ||
} | ||
|
||
public void setType(int type) { | ||
this.type = type; | ||
|
||
this.typeStr = "" + type; | ||
} | ||
|
||
public void setTypeStr(String type) { | ||
|
||
this.setType( Integer.parseInt(type) ); | ||
} | ||
|
||
public String getTemplateTypeDescr() | ||
{ | ||
switch( type ) | ||
{ | ||
|
||
case 0: return "Template"; | ||
case 1: return "Install Template"; | ||
|
||
default: | ||
return null; | ||
} | ||
} | ||
|
||
|
||
private String template; | ||
|
||
private User user = null; | ||
|
||
public User getUser() | ||
{ | ||
return user; | ||
} | ||
|
||
public void setUser(User oUser) | ||
{ | ||
this.user = oUser; | ||
} | ||
|
||
public TemplateRequest() | ||
{ | ||
this.displayname = ""; | ||
this.template = ""; | ||
this.user = new User(); | ||
} | ||
|
||
public TemplateRequest(String sDisplayname, int iType, String sTemplate, int iTimestamp, boolean bAnonym, String sOmicTools) { | ||
|
||
this.displayname = sDisplayname; | ||
|
||
this.setType(iType); | ||
this.user = new User(); | ||
this.template = sTemplate; | ||
this.timestamp = iTimestamp; | ||
this.anonym = bAnonym; | ||
this.omictoolslink = sOmicTools; | ||
|
||
} | ||
|
||
public String toMailText() throws RuntimeException { | ||
|
||
String sDispName = this.getDisplayname(); | ||
if (sDispName == null) | ||
{ | ||
throw new RuntimeException("no display name"); | ||
} | ||
|
||
String sOmicLink = this.getOmictoolslink(); | ||
if (sOmicLink == null) | ||
{ | ||
sOmicLink = ""; | ||
} | ||
|
||
StringBuilder oSB = new StringBuilder(); | ||
|
||
oSB.append( "New bioGUI Template Request" + "\n\n" ); | ||
oSB.append( "" + "\n" ); | ||
oSB.append( "Submitter Name: " + this.user.getName() + "\n" ); | ||
oSB.append( "Submitter eMail: " + this.user.getEmail() + "\n" ); | ||
oSB.append( "" + "\n" ); | ||
oSB.append( "Requested Template Name: " + sDispName + "\n" ); | ||
oSB.append( "Omictools Link: " + sOmicLink + "\n" ); | ||
oSB.append( "Template Type: " + this.getTemplateTypeDescr() + "\n" ); | ||
oSB.append( "" + "\n" ); | ||
oSB.append( "This is an automatically generated eMail from the bioGUI repository." + "\n" ); | ||
|
||
return oSB.toString(); | ||
} | ||
} |
98 changes: 98 additions & 0 deletions
98
java_server/src/main/java/bioGUI/TemplateRequestManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
package bioGUI; | ||
|
||
import org.zkoss.bind.annotation.*; | ||
import org.zkoss.zk.ui.Component; | ||
import org.zkoss.zk.ui.event.CheckEvent; | ||
import org.zkoss.zk.ui.event.Event; | ||
import org.zkoss.zk.ui.select.Selectors; | ||
import org.zkoss.zk.ui.select.annotation.Wire; | ||
import org.zkoss.zk.ui.select.annotation.WireVariable; | ||
import org.zkoss.zul.*; | ||
|
||
import java.util.ArrayList; | ||
import java.util.HashSet; | ||
import java.util.List; | ||
|
||
import java.util.*; | ||
import javax.mail.*; | ||
import javax.mail.internet.*; | ||
import javax.activation.*; | ||
|
||
public class TemplateRequestManager { | ||
|
||
|
||
private TemplateRequest templatecreation = new TemplateRequest(); | ||
|
||
@Init | ||
public void init() { | ||
|
||
} | ||
|
||
public TemplateRequest getTemplatecreation() { | ||
return templatecreation; | ||
} | ||
|
||
public void setTemplatecreation(TemplateRequest templatecreation) { | ||
this.templatecreation = templatecreation; | ||
} | ||
|
||
@Command | ||
@NotifyChange({"templatecreation"}) | ||
public void processRequest() | ||
{ | ||
int iSecsSince0 = (int) (System.currentTimeMillis() / 1000L); | ||
templatecreation.setTimestamp(iSecsSince0); | ||
|
||
String to = "joppich@bio.ifi.lmu.de"; | ||
String from = templatecreation.getUser().getEmail(); | ||
|
||
if ((from == null) || (from.length() == 0)) | ||
{ | ||
Messagebox.show("You must submit your email address."); | ||
return; | ||
} | ||
|
||
if (templatecreation.getDisplayname() == null) | ||
{ | ||
Messagebox.show("You must enter a Template Name."); | ||
return; | ||
} | ||
|
||
String sTempName = templatecreation.getDisplayname(); | ||
|
||
String host = "localhost"; | ||
Properties properties = System.getProperties(); | ||
properties.setProperty("mail.smtp.host", host); | ||
|
||
// Get the default Session object. | ||
Session session = Session.getDefaultInstance(properties); | ||
try { | ||
// Create a default MimeMessage object. | ||
MimeMessage message = new MimeMessage(session); | ||
message.setFrom(new InternetAddress(from)); | ||
message.addRecipient(Message.RecipientType.TO, new InternetAddress(to)); | ||
message.addRecipient(Message.RecipientType.CC, new InternetAddress(from)); | ||
|
||
message.setSubject("New bioGUI template request!"); | ||
message.setText( templatecreation.toMailText() ); | ||
|
||
|
||
Transport.send(message); | ||
|
||
templatecreation = new TemplateRequest(); | ||
|
||
} catch (MessagingException mex) { | ||
mex.printStackTrace(); | ||
|
||
Messagebox.show("Error Sending Request"); | ||
} | ||
Messagebox.show("Template request for " + sTempName + " sent!"); | ||
|
||
} | ||
|
||
@AfterCompose | ||
public void afterCompose(@ContextParam(ContextType.VIEW) Component view){ | ||
Selectors.wireComponents(view, this, false); | ||
} | ||
|
||
} |
Oops, something went wrong.