mirror of
https://github.com/apache/struts.git
synced 2026-08-11 09:36:57 +00:00
WW-1353 Move the MailReader iBATIS code to the sandbox, until it is ready.
git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/trunk@433103 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
@@ -1,230 +0,0 @@
|
||||
package mailreader2;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p/>
|
||||
* Provide properties to transfer data values between
|
||||
* the view and model layers (data transfer object).
|
||||
* </p>
|
||||
*
|
||||
* @version $Revision: 1.0 $ $Date: Jul 30, 2006 9:29:50 AM $
|
||||
*/
|
||||
public class AppData {
|
||||
|
||||
private boolean nominal;
|
||||
|
||||
private String locale_key;
|
||||
private String locale_code;
|
||||
private String locale_name;
|
||||
private List locale_list;
|
||||
|
||||
private String registration_key;
|
||||
private String username;
|
||||
private String password;
|
||||
private String password2;
|
||||
private String fullname;
|
||||
private String email_from;
|
||||
private String email_replyto;
|
||||
|
||||
private String protocol_key;
|
||||
private String protocol_code;
|
||||
private String protocol_name;
|
||||
|
||||
private String subscription_key;
|
||||
private String subscription_host;
|
||||
private String host_user;
|
||||
private String host_pass;
|
||||
private Integer host_auto;
|
||||
|
||||
/**
|
||||
* <p>Adapt internal Integer value to external boolean value. </p>
|
||||
*
|
||||
* @return False if host_auto==0, True otherwise
|
||||
*/
|
||||
public boolean isHost_auto_checkbox() {
|
||||
Integer _host_auto = getHost_auto();
|
||||
if (_host_auto == null) _host_auto = Constants.DB_FALSE;
|
||||
return (_host_auto == Constants.DB_TRUE);
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Adapt internal Integer value to external boolean value. </p>
|
||||
*/
|
||||
public void setHost_auto_checkbox(boolean host_auto_checkbox) {
|
||||
if (host_auto_checkbox)
|
||||
setHost_auto(Constants.DB_TRUE);
|
||||
else setHost_auto(Constants.DB_FALSE);
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Return true if a logic or state test passed,
|
||||
* such as whether a record already exists.</p>
|
||||
*
|
||||
* @return True if a business logic test passed.
|
||||
*/
|
||||
public boolean isNominal() {
|
||||
return nominal;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Record outcome of a logic or state test,
|
||||
* such as whether a record already exists.</p>
|
||||
*/
|
||||
public void setNominal(boolean nominal) {
|
||||
this.nominal = nominal;
|
||||
}
|
||||
|
||||
public String getLocale_key() {
|
||||
return locale_key;
|
||||
}
|
||||
|
||||
public void setLocale_key(String locale_key) {
|
||||
this.locale_key = locale_key;
|
||||
}
|
||||
|
||||
public String getLocale_code() {
|
||||
return locale_code;
|
||||
}
|
||||
|
||||
public void setLocale_code(String locale_code) {
|
||||
this.locale_code = locale_code;
|
||||
}
|
||||
|
||||
public String getLocale_name() {
|
||||
return locale_name;
|
||||
}
|
||||
|
||||
public void setLocale_name(String locale_name) {
|
||||
this.locale_name = locale_name;
|
||||
}
|
||||
|
||||
public List getLocale_list() {
|
||||
return locale_list;
|
||||
}
|
||||
|
||||
public void setLocale_list(List locale_list) {
|
||||
this.locale_list = locale_list;
|
||||
}
|
||||
|
||||
public String getRegistration_key() {
|
||||
return registration_key;
|
||||
}
|
||||
|
||||
public void setRegistration_key(String registration_key) {
|
||||
this.registration_key = registration_key;
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public String getPassword2() {
|
||||
return password2;
|
||||
}
|
||||
|
||||
public void setPassword2(String password2) {
|
||||
this.password2 = password2;
|
||||
}
|
||||
|
||||
public String getFullname() {
|
||||
return fullname;
|
||||
}
|
||||
|
||||
public void setFullname(String fullname) {
|
||||
this.fullname = fullname;
|
||||
}
|
||||
|
||||
public String getEmail_from() {
|
||||
return email_from;
|
||||
}
|
||||
|
||||
public void setEmail_from(String email_from) {
|
||||
this.email_from = email_from;
|
||||
}
|
||||
|
||||
public String getEmail_replyto() {
|
||||
return email_replyto;
|
||||
}
|
||||
|
||||
public void setEmail_replyto(String email_replyto) {
|
||||
this.email_replyto = email_replyto;
|
||||
}
|
||||
|
||||
public String getProtocol_key() {
|
||||
return protocol_key;
|
||||
}
|
||||
|
||||
public void setProtocol_key(String protocol_key) {
|
||||
this.protocol_key = protocol_key;
|
||||
}
|
||||
|
||||
public String getProtocol_code() {
|
||||
return protocol_code;
|
||||
}
|
||||
|
||||
public void setProtocol_code(String protocol_code) {
|
||||
this.protocol_code = protocol_code;
|
||||
}
|
||||
|
||||
public String getSubscription_key() {
|
||||
return subscription_key;
|
||||
}
|
||||
|
||||
public void setSubscription_key(String subscription_key) {
|
||||
this.subscription_key = subscription_key;
|
||||
}
|
||||
|
||||
public String getSubscription_host() {
|
||||
return subscription_host;
|
||||
}
|
||||
|
||||
public void setSubscription_host(String subscription_host) {
|
||||
this.subscription_host = subscription_host;
|
||||
}
|
||||
|
||||
public String getHost_user() {
|
||||
return host_user;
|
||||
}
|
||||
|
||||
public void setHost_user(String host_user) {
|
||||
this.host_user = host_user;
|
||||
}
|
||||
|
||||
public String getHost_pass() {
|
||||
return host_pass;
|
||||
}
|
||||
|
||||
public void setHost_pass(String host_pass) {
|
||||
this.host_pass = host_pass;
|
||||
}
|
||||
|
||||
public String getProtocol_name() {
|
||||
return protocol_name;
|
||||
}
|
||||
|
||||
public void setProtocol_name(String protocol_name) {
|
||||
this.protocol_name = protocol_name;
|
||||
}
|
||||
|
||||
public Integer getHost_auto() {
|
||||
return host_auto;
|
||||
}
|
||||
|
||||
public void setHost_auto(Integer host_auto) {
|
||||
this.host_auto = host_auto;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
package mailreader2;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface AppService {
|
||||
|
||||
public List getLocaleList() throws Exception;
|
||||
|
||||
public void insertUser(AppData data) throws Exception;
|
||||
|
||||
}
|
||||
@@ -51,32 +51,7 @@ import java.util.Map;
|
||||
* avoids creating unnecessary local properties. Pick your poison.</p>
|
||||
*/
|
||||
public class MailreaderSupport extends ActionSupport
|
||||
implements SessionAware, ApplicationAware, ModelDriven {
|
||||
|
||||
private AppService appService;
|
||||
|
||||
public AppService getAppService() {
|
||||
return appService;
|
||||
}
|
||||
|
||||
public void setAppService(AppService appService) {
|
||||
this.appService = appService;
|
||||
}
|
||||
|
||||
private AppData appData = new AppData();
|
||||
|
||||
public Object getModel() {
|
||||
return appData;
|
||||
}
|
||||
|
||||
public void setAppData(AppData appData) {
|
||||
this.appData = appData;
|
||||
}
|
||||
|
||||
public AppData getAppData() {
|
||||
return appData;
|
||||
}
|
||||
|
||||
implements SessionAware, ApplicationAware {
|
||||
|
||||
/**
|
||||
* Return CANCEL so apropriate result can be selected.
|
||||
|
||||
@@ -7,12 +7,7 @@ import java.util.List;
|
||||
/**
|
||||
* Verify that essential resources are available.
|
||||
*/
|
||||
public class Welcome extends MailreaderSupport implements Preparable {
|
||||
|
||||
public void prepare() throws Exception {
|
||||
List value = getAppService().getLocaleList();
|
||||
getAppData().setLocale_list(value);
|
||||
}
|
||||
public class Welcome extends MailreaderSupport {
|
||||
|
||||
public String execute() {
|
||||
|
||||
@@ -33,5 +28,4 @@ public class Welcome extends MailreaderSupport implements Preparable {
|
||||
return SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,99 +0,0 @@
|
||||
package mailreader2.service;
|
||||
|
||||
import com.ibatis.common.resources.Resources;
|
||||
import com.ibatis.common.jdbc.ScriptRunner;
|
||||
import com.ibatis.sqlmap.client.SqlMapClient;
|
||||
import com.ibatis.sqlmap.client.SqlMapClientBuilder;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
import java.sql.Connection;
|
||||
import java.io.Reader;
|
||||
import java.util.Properties;
|
||||
|
||||
public class SqlMapAppConfig {
|
||||
|
||||
// ---- TEST MODE SETUP ----
|
||||
|
||||
protected void runScript(String script) throws Exception {
|
||||
DataSource ds = getSqlMap().getDataSource();
|
||||
|
||||
Connection conn = ds.getConnection();
|
||||
|
||||
Reader reader = Resources.getResourceAsReader(script);
|
||||
|
||||
ScriptRunner runner = new ScriptRunner(conn, false, false);
|
||||
runner.setLogWriter(null);
|
||||
runner.setErrorLogWriter(null);
|
||||
|
||||
runner.runScript(reader);
|
||||
conn.commit();
|
||||
conn.close();
|
||||
reader.close();
|
||||
}
|
||||
|
||||
final static String[] CONFIG_SCRIPTS =
|
||||
{"sql/mailreader-schema.sql","sql/mailreader-sample.sql"};
|
||||
|
||||
private boolean testMode = true;
|
||||
|
||||
public boolean isTestMode() {
|
||||
return testMode;
|
||||
}
|
||||
|
||||
public void setTestMode(boolean testMode) {
|
||||
this.testMode = testMode;
|
||||
}
|
||||
|
||||
// ---- SQL MAP SETUP ----
|
||||
|
||||
final static String CONFIG_FILE = "sql-map-config.xml";
|
||||
|
||||
protected String configFile;
|
||||
|
||||
public String getConfigFile() {
|
||||
if (configFile==null) return CONFIG_FILE;
|
||||
return configFile;
|
||||
}
|
||||
|
||||
public void setConfigFile(String configFile) {
|
||||
this.configFile = configFile;
|
||||
}
|
||||
|
||||
protected Properties configProps;
|
||||
|
||||
public Properties getConfigProps() {
|
||||
return configProps;
|
||||
}
|
||||
|
||||
public void setConfigProps(Properties configProps) {
|
||||
this.configProps = configProps;
|
||||
}
|
||||
|
||||
private SqlMapClient sqlMap;
|
||||
|
||||
public SqlMapClient getSqlMap() {
|
||||
return sqlMap;
|
||||
}
|
||||
|
||||
public void setSqlMap(SqlMapClient sqlMap) {
|
||||
this.sqlMap = sqlMap;
|
||||
}
|
||||
|
||||
public SqlMapAppConfig() {
|
||||
try {
|
||||
Reader reader =
|
||||
Resources.getResourceAsReader(getConfigFile());
|
||||
setSqlMap(SqlMapClientBuilder.buildSqlMapClient(reader,
|
||||
getConfigProps()));
|
||||
reader.close();
|
||||
|
||||
if (isTestMode())
|
||||
for (String script : CONFIG_SCRIPTS) {
|
||||
runScript(script);
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
package mailreader2.service;
|
||||
|
||||
import mailreader2.AppService;
|
||||
import mailreader2.Constants;
|
||||
import mailreader2.AppData;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class SqlMapAppService extends SqlMapAppConfig implements AppService {
|
||||
|
||||
// ---- APPSERVICE IMPLEMENTATION ----
|
||||
|
||||
public List getLocaleList() throws Exception {
|
||||
return getSqlMap().queryForList(Constants.LOCALE_LIST, null);
|
||||
}
|
||||
|
||||
public void insertUser(AppData data) throws Exception {
|
||||
getSqlMap().insert(Constants.REGISTRATION_INSERT, data);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user