Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

changes to billbuzz back end to accomodate for bbsignup modifications…

… and the adoption of services module data
  • Loading branch information...
commit 19778f1209e47107380cce180ce3f8b55d2f5202 1 parent 2660e92
Jared Williams authored
View
14 BBSignup/.classpath
@@ -1,21 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jdk1.6.0_21"/>
<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.module.container"/>
<classpathentry kind="con" path="org.eclipse.jst.server.core.container/org.eclipse.jst.server.tomcat.runtimeTarget/Apache Tomcat v6.0 (2)"/>
- <classpathentry kind="lib" path="WebContent/WEB-INF/lib/jasypt-1.6.jar"/>
- <classpathentry kind="lib" path="WebContent/WEB-INF/lib/mail.jar"/>
- <classpathentry kind="lib" path="WebContent/WEB-INF/lib/commons-codec-1.4.jar"/>
- <classpathentry kind="lib" path="WebContent/WEB-INF/lib/commons-httpclient-3.1.jar"/>
- <classpathentry kind="lib" path="WebContent/WEB-INF/lib/commons-lang-2.5.jar"/>
- <classpathentry kind="lib" path="WebContent/WEB-INF/lib/commons-logging-1.1.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/asm-3.1.jar"/>
+ <classpathentry kind="lib" path="WebContent/WEB-INF/lib/commons-codec-1.4.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/commons-collections-3.1.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/commons-dbcp-1.2.1.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/commons-fileupload-1.2.1.jar"/>
+ <classpathentry kind="lib" path="WebContent/WEB-INF/lib/commons-httpclient-3.1.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/commons-io-1.4.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/commons-lang-2.2.jar"/>
+ <classpathentry kind="lib" path="WebContent/WEB-INF/lib/commons-lang-2.5.jar"/>
+ <classpathentry kind="lib" path="WebContent/WEB-INF/lib/commons-logging-1.1.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/commons-logging.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/commons-pool-1.2.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/datanucleus-cache-2.0.0-release.jar"/>
@@ -38,9 +36,11 @@
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/datanucleus-xmltypeoracle-2.0.0-release.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/httpclient-4.0.3.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/httpmime-4.0.3.jar"/>
+ <classpathentry kind="lib" path="WebContent/WEB-INF/lib/jasypt-1.6.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/jdo2-api-2.3-ec.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/log4j-1.2.14.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/log4j-1.2.16.jar"/>
+ <classpathentry kind="lib" path="WebContent/WEB-INF/lib/mail.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/mysql-connector-java-3.1.7-bin.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/slf4j-api-1.5.6.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/ws-commons-util-1.0.2.jar"/>
View
2  BBSignup/WebContent/authenticate.jsp
@@ -51,4 +51,4 @@
%>
</center>
</div>
-<%@ include file="nfooter.jsp"%>
+<%@ include file="footer.jsp"%>
View
126 BBSignup/WebContent/css/nys.css
@@ -0,0 +1,126 @@
+html,body,div,ul,li {
+ margin: 0px;
+ padding: 0px;
+}
+
+html,body {
+ width: 100%;
+}
+
+.clear {
+ clear: both;
+}
+
+body {
+ color: #012849;
+ /*font-family: Times New Roman, serif;*/
+ font-family: helvetica, arial;
+ font-size: 89.5%; /* 10px */
+
+ background:url(http://www.nysenate.gov/sites/all/themes/nys/images/nyss_bg.png) top left repeat-x;
+}
+
+#page {
+ width: 877px;
+ margin: 0 auto;
+ background: #E2DED5;
+}
+
+#header {
+ background:
+ url(http://www.nysenate.gov/sites/all/themes/nys/images/header.png)
+ top left no-repeat;
+ padding: 16px 0px 0px 0px;
+ height: 77px;
+}
+
+#logo {
+ width: 250px;
+ height: 55px;
+ margin-top: 16px 0px 0px 5px;
+ border: 0px;
+}
+
+#welcome {
+ color: white;
+ font-weight: bold;
+}
+
+#nav_bar {
+ color: white;
+ background:
+ url(http://www.nysenate.gov/sites/all/themes/nys/images/nyss_menu_bg.png)
+ top left repeat-x;
+ line-height: 30px;
+ font-family: Helvetica, Arial, sans-serif;
+}
+
+#nav_bar a:link {
+ color: white;
+ font-weight: bold;
+ text-decoration: none;
+}
+
+#nav_bar a:visited {
+ color: white;
+ font-weight: bold;
+ text-decoration: none;
+}
+
+#nav_bar a:hover {
+ text-decoration: underline;
+}
+
+#nav_bar a:focus {
+
+}
+
+#nav_bar a:active {
+
+}
+
+#nav_bar ul {
+ display: inline;
+ list-icon-style: none;
+ padding-left: 10px;
+}
+
+#nav_bar li {
+ display: inline;
+}
+
+.sep {
+ padding: 0px 10px;
+ display: inline;
+}
+
+#error {
+ text-align: center;
+ color: red;
+}
+
+.entity_button {
+ display: inline;
+}
+
+.entity_title {
+ display: inline;
+ font-weight: bold;
+}
+
+
+#main {
+ margin-top: 5px;
+ margin: 20px;
+ padding: 20px;
+ padding-top: 5px;
+ background: #ffffff
+ url(http://www.nysenate.gov/sites/all/themes/nys/images/nyss_block_footer_bg.png)
+ repeat-x bottom left;
+}
+
+h2 {
+ font-family: arial, serif;
+ text-transform: uppercase;
+ text-align: left;
+}
View
35 BBSignup/WebContent/css/style.css
@@ -0,0 +1,35 @@
+
+.bad {
+ color:black;
+ border:1px solid #FF3300;
+ margin:1em auto;
+ border-collapse:collapse;
+ background-color: #FECCBF;
+}
+
+.foot {
+ border-collapse:collapse;
+ font-size:85%;
+ align:center;
+}
+
+.good {
+ border-collapse:collapse;
+ border:1px solid #009999;
+ background-color: #BFFFFE;
+}
+
+.bb_main {
+ border-collapse:collapse;
+ border:1px solid #B2A100;
+ background-color: #FEF9BF;
+ width:800px;
+ position:75px;
+ left:15%;
+}
+
+A:visited {
+ color: blue;
+}
+
+
View
2  BBSignup/WebContent/delete.jsp
@@ -38,4 +38,4 @@
</center>
</div>
-<%@ include file="nfooter.jsp"%>
+<%@ include file="footer.jsp"%>
View
50 BBSignup/WebContent/footer.jsp
@@ -1,30 +1,22 @@
-<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
- pageEncoding="ISO-8859-1"
- import="java.util.*,bbsignup.src.*,bbsignup.model.*,javax.jdo.*"
- %>
-
-<br/><br/>
-<div class="foot">
- <table>
- <tr>
- <td>Already Subscribed?</td>
- <td><a href="update.jsp">Update</a> or </td>
- <td><a href="unsubscribe.jsp">Unsubscribe</a></td>
- </tr>
- </table>
- <table cellpadding=5>
- <tr>
- <td>
- <a href="index.jsp">Home</a>
+ </div>
+ <center><div class="foot">
+ <table cellpadding=5>
+ <tr>
+ <td>
+ <a href="index.jsp">Home</a>
+
+ </td>
+ <td align="center">
+ <a href="http://www.nysenate.gov">NYSenate.gov</a>
- </td>
- <td align="center">
- <a href="http://www.nysenate.gov">NYSenate.gov</a>
-
- </td>
- <td align = "right">
- <a href="mailto:billbuzz@nysenate.gov">Contact</a>
- </td>
- </tr>
- </table>
-</div>
+ </td>
+ <td align = "right">
+ <a href="mailto:billbuzz@nysenate.gov">Contact</a>
+ </td>
+ </tr>
+ </table>
+ </div></center>
+ </body>
+</html>
+
+
View
6 BBSignup/WebContent/header.jsp
@@ -5,10 +5,10 @@
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>NYSS BillBuzz</title>
- <link rel="stylesheet" type="text/css" href="style.css" />
- <link rel="stylesheet" type="text/css" href="nys.css" />
+ <link rel="stylesheet" type="text/css" href="/BBSignup/css/style.css" />
+ <link rel="stylesheet" type="text/css" href="/BBSignup/css/nys.css" />
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
- <script type="text/javascript" src="js.js"></script>
+ <script type="text/javascript" src="/BBSignup/js/js.js"></script>
</head>
<body>
<div id="page">
View
4 BBSignup/WebContent/index.jsp
@@ -163,7 +163,7 @@
}
}
%>
- <div class="senator"><input type="checkbox"
+ <div class="senator"><input class="sen_" type="checkbox"
name="<%=s.getOpenLegName()%>"
<%=((tog == true) ? "checked=\"yes\"" : "")%>></input></div>
<%
@@ -204,4 +204,4 @@
</div>
</center>
-<%@ include file="nfooter.jsp"%>
+<%@ include file="footer.jsp"%>
View
91 BBSignup/WebContent/js/js.js
@@ -0,0 +1,91 @@
+function addError(message, msg) {
+ if(message == "") {
+ return msg;
+ }
+ else {
+ return message += "<br>" + msg;
+ }
+}
+$(document).ready(function() {
+ reset = function() {
+ $('.cb_').each(function() {
+ if($(this).is(':checked')) {
+ doCheck(this, $(this).attr('party'));
+ }
+ });
+ };
+
+ doCheck = function(curSelector, party) {
+ if($('#cb_all').is(':checked') && !$(this).is(':checked')) {
+ $('#cb_all').attr('checked',false);
+ }
+
+ $('.senator').each(function(index) {
+ var parties = $($('.party').get(index)).html();
+
+ var check = $(this).children("INPUT[type='checkbox']");
+
+ var re = new RegExp('(\\(|\\- )' + party
+ + '(\\)| \\-)');
+ if (parties.match(re)) {
+ $(check).attr('checked',
+ $(curSelector).is(':checked'));
+ }
+ });
+ };
+
+ clearAll = function() {
+ $("INPUT[type='checkbox']").attr('checked', false);
+ };
+
+ $('#cb_all').change(
+ function() {
+ $("INPUT[type='checkbox']").attr('checked',
+ $('#cb_all').is(':checked'));
+ });
+
+ $('.cb_').change(function() {
+ doCheck(this, $(this).attr('party'));
+ reset();
+ });
+
+ $('.sen_').change(function() {
+ if($('#cb_all').is(':checked') && !$(this).is(':checked')) {
+ $('#cb_all').attr('checked',false);
+ }
+ });
+
+ $('#process').click(function(event) {
+ message = "";
+ e1 = document.forms.senators.email1.value;
+ e2 = document.forms.senators.email2.value;
+ fn = document.forms.senators.firstname.value;
+ ln = document.forms.senators.lastname.value;
+
+ if(!fn){
+ message = addError(message, "Enter your first name");
+ }
+ if(!ln) {
+ message = addError(message, "Enter your last name");
+ }
+ if(e1 == null || e2 == null || e1 != e2) {
+ message = addError(message, "Your email addresses must match!");
+ }
+ else {
+ if(!e1.match(/.*?@.*?\..*?/)) {
+ message = addError(message, "Enter a valid email address");
+ }
+ }
+
+ if(message != "") {
+ $("#error").html(message);
+ $("#error").css({'display' : 'inherit'});
+ $('html,body').animate({
+ scrollTop:$("#error").offset().top}, 500);
+ return false;
+ }
+ else {
+ return true;
+ }
+ });
+});
View
2  BBSignup/WebContent/message.jsp
@@ -19,4 +19,4 @@
</center>
</div>
-<%@ include file="nfooter.jsp"%>
+<%@ include file="footer.jsp"%>
View
2  BBSignup/WebContent/notice.jsp
@@ -79,4 +79,4 @@
%>
</center>
</div>
-<%@ include file="nfooter.jsp"%>
+<%@ include file="footer.jsp"%>
View
2  BBSignup/WebContent/unsubscribe.jsp
@@ -70,4 +70,4 @@
%>
</div>
</center>
-<%@ include file="nfooter.jsp"%>
+<%@ include file="footer.jsp"%>
View
2  BBSignup/WebContent/update.jsp
@@ -91,4 +91,4 @@
</div>
</center>
-<%@ include file="nfooter.jsp"%>
+<%@ include file="footer.jsp"%>
View
4 BBSignup/src/bbsignup/src/Controller.java
@@ -25,6 +25,10 @@
public String WEBLINK = "http://billbuzz.nysenate.gov/";
+ public static void main(String[] args) {
+
+ }
+
public Controller() {
}
View
24 BBSignup/src/bbsignup/src/PMF.java
@@ -1,6 +1,7 @@
package bbsignup.src;
import java.util.Collection;
+import java.util.List;
import javax.jdo.Extent;
import javax.jdo.JDOHelper;
@@ -213,4 +214,27 @@ public static boolean deleteObjects(Class<?>[] clazz, String[] key, String[] id)
return true;
}
+
+ public static void deleteObjects(Class<?> clazz) {
+ PersistenceManager pm = getPersistenceManager();
+ Transaction tx = pm.currentTransaction();
+
+ try {
+ tx.begin();
+
+ Collection<?> objs = getObjects(pm, clazz);
+
+ for(Object o:objs) {
+ pm.deletePersistent(o);
+ }
+
+ tx.commit();
+ }
+ finally {
+ if(tx.isActive()) {
+ tx.rollback();
+ }
+ pm.close();
+ }
+ }
}
View
16 BBSignup/src/collect/NYSenateServices.java
@@ -25,7 +25,21 @@ public static void index() throws Exception {
}
public static void main(String[] args) throws Exception {
- index();
+
+ if(args.length == 0) {
+ System.out.println("please indicate either 'index' or 'truncate'");
+ }
+ else {
+ if(args[0].equals("index")) {
+ index();
+ }
+ else if(args[0].equals("truncate")) {
+ PMF.deleteObjects(Senator.class);
+ }
+ else {
+ System.out.println("please indicate either 'index' or 'truncate'");
+ }
+ }
}
public static List<Senator> getSenators() throws Exception {
View
112 BillBuzz/src/gov/nysenate/billbuzz/BillBuzz.java
@@ -22,10 +22,15 @@
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
+import org.apache.log4j.Logger;
+
import gov.nysenate.billbuzz.persist.Controller;
import gov.nysenate.billbuzz.persist.User;
public class BillBuzz {
+
+ private static Logger logger = Logger.getLogger(BillBuzz.class);
+
private static String _billRegExp = "[BJRbjr][\\d]*[a-zA-Z]*";
private static final String SMTP_HOST_NAME = Resource.get("hostname");
@@ -33,8 +38,9 @@
private static final String SMTP_ACCOUNT_USER = Resource.get("user");
private static final String SMTP_ACCOUNT_PASS = Resource.get("pass");
+
- Map<String,String> _sep;
+ Map<String,gov.nysenate.billbuzz.persist.Senator> _sep;
/**
@@ -50,7 +56,7 @@ public BillBuzz() throws Exception{
runBillBuzz(setDateForRead());
}
public void runBillBuzz(String date) throws Exception {
-
+ logger.info("running billbuzz for date:" + date.toString());
_sep = senatorMap();
List<Senator> senators = getSenatorUpdates(date);
@@ -67,6 +73,8 @@ public void sendToSubscribers(Map<String,Senator> m) throws Exception {
List<User> users = Controller.getUsers();
for(User u:users) {
+ logger.info("compiling message for user:" + u.getEmail());
+
String name = u.getFirstName();
String email = u.getEmail();
@@ -81,22 +89,6 @@ public void sendToSubscribers(Map<String,Senator> m) throws Exception {
}
}
else {
- if (subs.contains("dem")) {
- for(Senator s:col) {
- if(s.getParty().equals("d")) {
- senators.add(s);
- }
- }
- subs.remove("dem");
- }
- else if (subs.contains("rep")) {
- for(Senator s:col) {
- if(s.getParty().equals("r")) {
- senators.add(s);
- }
- }
- subs.remove("rep");
- }
for(String s:subs) {
Senator temp = null;
if((temp = m.get(s)) != null) {
@@ -121,7 +113,7 @@ else if (subs.contains("rep")) {
for(Senator s:senators) {
- m.put(s.getName(), s);
+ m.put(s.getName().toUpperCase(), s);
}
@@ -131,22 +123,23 @@ else if (subs.contains("rep")) {
-
- public Map<String,String> senatorMap() throws Exception {
- Map<String,String> m = new HashMap<String,String>();
+ /**
+ * creates a map of senators from database
+ */
+ public Map<String,gov.nysenate.billbuzz.persist.Senator> senatorMap() throws Exception {
+ logger.info("creating senator map");
+ Map<String,gov.nysenate.billbuzz.persist.Senator> m = new HashMap<String,gov.nysenate.billbuzz.persist.Senator>();
List<gov.nysenate.billbuzz.persist.Senator> lst = Controller.getSenators();
for(gov.nysenate.billbuzz.persist.Senator sen:lst) {
- String n = sen.getName();
- String e = sen.getName();
-
- String p = sen.getParty();
- m.put(n, e + ":" + p);
+ String n = sen.getOpenLegName().toUpperCase();
+
+ m.put(n, sen);
}
-
+
return m;
}
@@ -234,6 +227,7 @@ protected PasswordAuthentication getPasswordAuthentication() {
* @throws Exception if it can't connect to the network
*/
public List<Senator> getSenatorUpdates(String date) throws Exception{
+ logger.info("getting list of updated threads");
ThreadMod tm = new ThreadMod();
List<ThreadDescription> td = tm.getApprovedThreads(date);
@@ -241,27 +235,30 @@ protected PasswordAuthentication getPasswordAuthentication() {
List<Senator> sen = new ArrayList<Senator>();
for(ThreadDescription thread : td) {
-
BillInfo bill = thread.getBill();
//if it's the correct bill format
if(!bill.getSenateId().matches(_billRegExp)) {
+ logger.info("reading updates for billno: " + bill.getBillId() + " and threadid: " + thread.getID());
- List<String> toWho = getToWho(thread);
-
+ List<String> toWho = getToWho(thread);
+
thread.setURL(correctURL(bill.getSenateId()));
//add thread for everyone associated with it
- for(String email : toWho) {
+ for(String oLName : toWho) {
if(sen.isEmpty()) {
- Senator s = new Senator(bill.getSponsor().toUpperCase(), email);
- s.setParty(getParty(s.getName()));
+ Senator s = new Senator(oLName);
s.addThread(thread);
if(_sep.get(s.getName()) != null) {
+ logger.info("creating senator: " + s.getName() +", adding thread: " + thread.getID());
sen.add(s);
}
+ else {
+ logger.info("senator " + s.getName() + " does not exist in _sep map");
+ }
} else {
@@ -272,61 +269,62 @@ protected PasswordAuthentication getPasswordAuthentication() {
while (senItr.hasNext()) {
Senator curSen = senItr.next();
//if the senator already exists
- if (curSen.getName().compareTo(bill.getSponsor()) == 0) {
+ if (curSen.getName().compareTo(oLName) == 0) {
+ logger.info("adding threadid: " + thread.getID() + " to senator: " + curSen.getName());
curSen.addThread(thread);
break;
}
//if the senator wasn't found in the list this adds the new senators info
if (!senItr.hasNext()) {
- s = new Senator(bill.getSponsor().toUpperCase(), email);
- s.setParty(getParty(s.getName()));
- s.addThread(thread);
+ s = new Senator(oLName);
+ s.addThread(thread);
}
}
//if a new senator is being added
- if (s != null) {
- if(_sep.get(s.getName()) != null) {
- sen.add(s);
- }
+
+ if(s != null && _sep.get(s.getName()) != null) {
+ logger.info("creating senator: " + s.getName() + ", adding thread: " + thread.getID());
+ sen.add(s);
+ }
+ else {
+ logger.info("skipping billno: " + bill.getBillId() + ", senator: "
+ + oLName + ", threadid: " + thread.getID());
}
}
}
}
+ else {
+ logger.info("skipping billno: " + bill.getBillId());
+ }
}
return sen;
}
-
- public String getParty(String name) {
- String s;
- if((s = _sep.get(name)) != null) {
- return s.split(":")[1];
- }
- return "";
- }
-
/**
* This function compiles the list of Senators that are included in a Thread
* @param td is a ThreadDescription
* @returns a List<String> of senators' email address' who are associated with the Thread
*/
public List<String> getToWho(ThreadDescription td) {
+ logger.info("getting senators for threadid: " + td.getID());
List<String> ret = new ArrayList<String>();
BillInfo b = td.getBill();
- String email = getParty(b.getSponsor());
+ //String oLName = .getOpenLegName();//getParty(b.getSponsor());
//if the given senator has a listed email address
- if(email != null) {
- ret.add(email);
+ if(_sep.get(b.getSponsor()) != null) {
+ logger.info("adding senator " + _sep.get(b.getSponsor()).getOpenLegName().toUpperCase() + " to thread");
+ ret.add(_sep.get(b.getSponsor()).getOpenLegName().toUpperCase());
}
//if there is a same as thread
if(td.getSameAsThread() != null) {
List<String> cosp = td.getSameAsThread().getBill().getCosponsors();
//read through people associated with assembly thread
for(String s:cosp) {
- email = getParty(s);
//if there is a valid email and it isn't in the list
- if(email != null && !ret.contains(email)) {
- ret.add(email);
+ gov.nysenate.billbuzz.persist.Senator perSen = _sep.get(s);
+ if(perSen != null && !ret.contains(perSen.getOpenLegName().toUpperCase())) {
+ logger.info("adding senator " + perSen.getOpenLegName().toUpperCase() + "to thread (from sameas)");
+ ret.add(perSen.getOpenLegName().toUpperCase());
}
}
}
View
4 BillBuzz/src/gov/nysenate/billbuzz/Disqus.java
@@ -30,8 +30,10 @@
public class Disqus {
private static String _website = Resource.get("website");
private static String _api = Resource.get("api");
- private static String _dateDivide = "[\\-T:]";
private static String _key = Resource.get("key");
+
+ private static String _dateDivide = "[\\-T:]";
+
public Disqus() {
}
View
2  BillBuzz/src/gov/nysenate/billbuzz/Main.java
@@ -18,7 +18,7 @@ else if(args[0].compareTo("-m") == 0) {
else {
System.out.println("Invalid paramters, correct usage is: BillBuzz or BillBuzz -m \"YYYY-MM-DD\"");
}
-// new BillBuzz("2010-07-01T00:00");
+// new BillBuzz("2010-12-01T00:00");
}
}
View
17 BillBuzz/src/gov/nysenate/billbuzz/model/Senator.java
@@ -7,7 +7,6 @@
public class Senator {
private String name;
private String email;
- private String party;
private List<ThreadDescription> threads;
public Senator() { };
public Senator(String name, String email, List<ThreadDescription> threads) {
@@ -28,31 +27,19 @@ public Senator(String name) {
public Senator(gov.nysenate.billbuzz.persist.Senator ps) {
name = ps.getName();
email = "";
- party = ps.getParty();
this.threads = new ArrayList<ThreadDescription>();
}
public void setName(String name) {
this.name = name;
- }
- public void setEmail(String email) {
- this.email = email;
- }
- public void setParty(String party) {
- this.party = party;
- }
+ }
public void setThreads(List<ThreadDescription> threads) {
this.threads = threads;
}
public String getName() {
return name;
}
- public String getEmail() {
- return email;
- }
- public String getParty() {
- return party;
- }
+
public List<ThreadDescription> getThreads() {
return threads;
}
View
163 BillBuzz/src/gov/nysenate/billbuzz/persist/Senator.java
@@ -1,66 +1,145 @@
package gov.nysenate.billbuzz.persist;
-import java.io.Serializable;
-
-import javax.jdo.annotations.*;
+import javax.jdo.annotations.PersistenceCapable;
@PersistenceCapable
-public class Senator implements Serializable {
+public class Senator {
+ String name;
+ String url;
+ String openLegName;
- /**
- *
- */
- private static final long serialVersionUID = 1L;
-
+ boolean democrat;
+ boolean republican;
+ boolean conservative;
+ boolean workingFamilies; //WF
+ boolean independentParty; //I
+ boolean independenceParty; //IP
+ boolean independent; //ind
- @Persistent
- @PrimaryKey
- @Column(name="name")
- private String name;
-
-
- @Persistent
- @Column(name="url")
- private String url;
-
- @Persistent
- @Column(name="party")
- private String party;
-
-
-
-
-
public Senator() {
-
- }
-
- public Senator(String name, String url, String party) {
- this.name = name;
- this.url = url;
- this.party = party;
-
+ democrat = false;
+ republican = false;
+ conservative = false;
+ workingFamilies = false;
+ independentParty = false;
+ independenceParty = false;
+ independent = false;
}
-
-
+
public String getName() {
return name;
}
+
public String getUrl() {
return url;
}
- public String getParty() {
- return party;
+
+ public String getOpenLegName() {
+ return openLegName;
}
-
+
+ public boolean isDemocrat() {
+ return democrat;
+ }
+
+ public boolean isRepublican() {
+ return republican;
+ }
+
+ public boolean isConservative() {
+ return conservative;
+ }
+
+ public boolean isWorkingFamilies() {
+ return workingFamilies;
+ }
+
+ public boolean isIndependentParty() {
+ return independentParty;
+ }
+
+ public boolean isIndependenceParty() {
+ return independenceParty;
+ }
+
+ public boolean isIndependent() {
+ return independent;
+ }
+
public void setName(String name) {
this.name = name;
}
+
public void setUrl(String url) {
this.url = url;
}
- public void setParty(String party) {
- this.party = party;
+
+ public void setOpenLegName(String openLegName) {
+ this.openLegName = openLegName;
+ }
+
+ public void setDemocrat(boolean democrat) {
+ this.democrat = democrat;
+ }
+
+ public void setRepublican(boolean republican) {
+ this.republican = republican;
+ }
+
+ public void setConservative(boolean conservative) {
+ this.conservative = conservative;
}
+
+ public void setWorkingFamilies(boolean workingFamilies) {
+ this.workingFamilies = workingFamilies;
+ }
+
+ public void setIndependentParty(boolean independentParty) {
+ this.independentParty = independentParty;
+ }
+
+ public void setIndependenceParty(boolean independanceParty) {
+ this.independenceParty = independanceParty;
+ }
+
+ public void setIndependent(boolean independent) {
+ this.independent = independent;
+ }
+
+ public String getParty() {
+
+ String ret = "";
+ if(democrat) {
+ ret = "d";
+ }
+ else if(republican) {
+ ret = "r";
+ }
+ if(independentParty) {
+ ret = getPartyHelper(ret,"i");
+ }
+ if(independenceParty) {
+ ret = getPartyHelper(ret,"ip");
+ }
+ if(independent) {
+ ret = getPartyHelper(ret,"ind");
+ }
+ if(conservative) {
+ ret = getPartyHelper(ret,"c");
+ }
+ if(workingFamilies) {
+ ret = getPartyHelper(ret,"wf");
+ }
+
+ return ret;
+ }
+
+ public String getPartyHelper(String parties, String party) {
+ if(parties.equals("")) {
+ return party;
+ }
+ return parties + " - " + party;
+ }
+
}
View
13 BillBuzz/src/log4j.xml
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd" >
+<log4j:configuration>
+ <appender name="stdout" class="org.apache.log4j.ConsoleAppender">
+ <layout class="org.apache.log4j.PatternLayout">
+ <param name="ConversionPattern" value="%d{ABSOLUTE} %5p %c{1}:%L - %m%n"/>
+ </layout>
+ </appender>
+ <root>
+ <priority value="fatal"></priority>
+ <appender-ref ref="stdout"/>
+ </root>
+</log4j:configuration>
Please sign in to comment.
Something went wrong with that request. Please try again.