Permalink
Browse files

Play app.

  • Loading branch information...
0 parents commit 63c824cda4d67e8d88d7129a28369e3c0a0d37c4 Matt Conway committed Jul 3, 2012
@@ -0,0 +1,5 @@
+.#*
+#*#
+*~
+tmp/*
+db/*
@@ -0,0 +1,16 @@
+package controllers;
+
+import play.*;
+import play.mvc.*;
+
+import java.util.*;
+
+import models.*;
+
+public class Application extends Controller {
+
+ public static void index() {
+ render();
+ }
+
+}
@@ -0,0 +1,8 @@
+package controllers;
+
+import play.*;
+import play.mvc.*;
+import models.*;
+
+public class GtfsFeeds extends CRUD {
+}
@@ -0,0 +1,7 @@
+package controllers;
+
+import play.*;
+import play.mvc.*;
+
+public class MetroAreas extends CRUD {
+}
@@ -0,0 +1,9 @@
+package controllers;
+
+import play.*;
+import play.mvc.*;
+import models.*;
+
+@CRUD.For(NtdAgency.class)
+public class NtdAgencies extends CRUD {
+}
@@ -0,0 +1,84 @@
+package models;
+
+import javax.persistence.*;
+import java.util.*;
+
+import play.db.jpa.*;
+import play.data.validation.*;
+
+@Entity
+public class GtfsFeed extends Model {
+
+ /** The human-readable area description, from Data Exchange, generally */
+ public String areaDescription;
+
+ /** The country where this agency operates. */
+ // TODO: should we use some sort of stable identifier, like internet country code
+ public String country;
+
+ /** The GTFS Data Exchange ID */
+ public String dataExchangeId;
+
+ /** The GTFS Data Exchange URL */
+ @URL
+ public String dataExchangeUrl;
+
+ // TODO: on these dates, should they be relative to GTFS Data Exchange or to this site?
+ /** The date added to Data Exchange */
+ public Date dateAdded;
+
+ /** The date this feed was last updated */
+ public Date dateUpdated;
+
+ /**
+ * The URL where this feed may be found. This may be the feed itself, or may be a
+ * developer site (e.g. http://developer.metro.net).
+ */
+ @URL
+ public String feedBaseUrl;
+
+ /** Is this feed a feed officially provided by the transit agency? */
+ @Required
+ public boolean official;
+
+ /** The URL of the license for this feed */
+ @URL
+ public String licenseUrl;
+
+ // TODO: this should probably use abbreviations to avoid spelling variations
+ // e.g. Hawaii v. Hawai'i
+ /** The US state of this feed */
+ public String state;
+
+ /**
+ * The URL of the agency producing this feed. This should be the stable URL, not a marketing
+ * URL (e.g., http://wmata.com not http://metroopensdoors.com)
+ */
+ @Required
+ @URL
+ public String agencyWebsite;
+
+ // TODO: time period
+ /** The number of trips in this GTFS */
+ public int trips;
+
+ /** The expiration date of this feed */
+ //@Required
+ public Date expirationDate;
+
+ // TODO: what exactly does this mean
+ /** The number of trips per calendar, on average */
+ public int tripsPerCalendar;
+
+ // TODO: what do the different cascade types do?
+ @ManyToMany(cascade=CascadeType.PERSIST)
+ // TODO: why is a set used here?
+ public Set<NtdAgency> agencies;
+
+ public String toString () {
+ if (dataExchangeId != null && !dataExchangeId.equals(""))
+ return dataExchangeId;
+ else
+ return "GTFS for " + agencyWebsite;
+ }
+}
@@ -0,0 +1,47 @@
+package models;
+
+import javax.persistence.*;
+import java.util.*;
+
+import play.db.jpa.*;
+import play.data.validation.*;
+
+@Entity
+public class MetroArea extends Model {
+
+ /**
+ * The name of this Metro area. Should take the form
+ * City 1-City 2-City 3, State 1-State 2-State 3
+ */
+ public String name;
+ // note that this ID is not serial, because we don't want
+ // to have trouble if we add more GTFS to an urban area; they
+ // id should stay the same.
+ /** The ID of this area */
+ /*@Required
+ @Unique
+ @Id
+ public int id;*/
+
+ // TODO: geometry
+
+ // TODO: cascade?
+ @OneToMany(mappedBy="metroArea")
+ public List<NtdAgency> ntdAgencies;
+
+ /**
+ * Return the string used in the admin interface
+ */
+ public String toString () {
+ if (name != null && !name.equals("")) {
+ return name;
+ }
+ else if (ntdAgencies.size() != 0) {
+ return "Metro including " + ntdAgencies.get(0).name;
+ }
+ else {
+ return "Empty metro area";
+ }
+ }
+}
+
@@ -0,0 +1,48 @@
+package models;
+
+import javax.persistence.*;
+import java.util.*;
+
+import play.db.jpa.*;
+import play.data.validation.*;
+
+@Entity
+public class NtdAgency extends Model {
+
+ /** Human-readable agency name */
+ @Required
+ public String name;
+
+ /** This agency's primary location on the WWW */
+ @Required
+ @URL
+ public String website;
+
+ /** This agency's ID in the National Transit Database */
+ public String ntdId;
+
+ /** Service area population */
+ public int population;
+
+ /** Annual unlinked passenger trips */
+ public int ridership;
+
+ /** Annual passenger miles */
+ public int passengerMiles;
+
+ // TODO: geometry
+
+ @ManyToOne
+ public MetroArea metroArea;
+
+ @ManyToMany(mappedBy="agencies")
+ public Set<GtfsFeed> feeds;
+
+ /**
+ * Convert to a human-readable string. This is exposed in the admin interface, so it should be
+ * correct.
+ */
+ public String toString () {
+ return name;
+ }
+}
@@ -0,0 +1,4 @@
+#{extends 'main.html' /}
+#{set title:'Home' /}
+
+#{welcome /}
@@ -0,0 +1,19 @@
+<!DOCTYPE html>
+
+<html>
+ <head>
+ <title>Not found</title>
+ <meta http-equiv="Content-Type" content="text/html; charset=${_response_encoding}"/>
+ </head>
+ <body>
+ #{if play.mode.name() == 'DEV'}
+ #{404 result /}
+ #{/if}
+ #{else}
+ <h1>Not found</h1>
+ <p>
+ ${result.message}
+ </p>
+ #{/else}
+ </body>
+</html>
@@ -0,0 +1,21 @@
+<!DOCTYPE html>
+
+<html>
+ <head>
+ <title>Application error</title>
+ <meta http-equiv="Content-Type" content="text/html; charset=${_response_encoding}"/>
+ </head>
+ <body>
+ #{if play.mode.name() == 'DEV'}
+ #{500 exception /}
+ #{/if}
+ #{else}
+ <h1>Oops, an error occured</h1>
+ #{if exception instanceof play.exceptions.PlayException}
+ <p>
+ This exception has been logged with id <strong>${exception.id}</strong>.
+ </p>
+ #{/if}
+ #{/else}
+ </body>
+</html>
@@ -0,0 +1,16 @@
+<!DOCTYPE html>
+
+<html>
+ <head>
+ <title>#{get 'title' /}</title>
+ <meta charset="${_response_encoding}">
+ <link rel="stylesheet" media="screen" href="@{'/public/stylesheets/main.css'}">
+ #{get 'moreStyles' /}
+ <link rel="shortcut icon" type="image/png" href="@{'/public/images/favicon.png'}">
+ <script src="@{'/public/javascripts/jquery-1.6.4.min.js'}" type="text/javascript" charset="${_response_encoding}"></script>
+ #{get 'moreScripts' /}
+ </head>
+ <body>
+ #{doLayout /}
+ </body>
+</html>
Oops, something went wrong.

0 comments on commit 63c824c

Please sign in to comment.