Permalink
Browse files

Doorlist

  • Loading branch information...
1 parent 1ca1269 commit 98530221f779ee5b837f5beae4d8646edfbdfd5c @gmoore gmoore committed Sep 18, 2011
View
4 components/tix/pom.xml
@@ -323,6 +323,10 @@
<groupId>org.fracturedatlas.athena.helper</groupId>
<artifactId>ticketfactory</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.fracturedatlas.athena.plugin</groupId>
+ <artifactId>doorlist</artifactId>
+ </dependency>
<dependency>
<groupId>org.fracturedatlas.athena.plugin</groupId>
<artifactId>available-tickets</artifactId>
View
9 core/client/src/main/java/org/fracturedatlas/athena/model/Ticket.java
@@ -22,6 +22,7 @@
import java.text.ParseException;
import java.util.ArrayList;
import java.util.List;
+import java.util.Set;
import org.fracturedatlas.athena.client.PTicket;
import org.fracturedatlas.athena.util.date.DateUtil;
import org.joda.time.DateTime;
@@ -73,6 +74,14 @@ public Ticket(PTicket section, PTicket performance, PTicket event, String state)
this.organizationId = performance.get("organizationId");
}
+ public static List<Ticket> fromSet(Set<PTicket> pTickets) {
+ List<Ticket> tickets = new ArrayList<Ticket>();
+ for(PTicket pTicket : pTickets) {
+ tickets.add(new Ticket(pTicket));
+ }
+ return tickets;
+ }
+
public static List<Ticket> fromCollection(List<PTicket> pTickets) {
List<Ticket> tickets = new ArrayList<Ticket>();
for(PTicket pTicket : pTickets) {
View
18 helpers/doorlist/pom.xml
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <artifactId>helpers</artifactId>
+ <groupId>org.fracturedatlas.athena</groupId>
+ <version>1.3.0-beta-00-SNAPSHOT</version>
+ </parent>
+ <groupId>org.fracturedatlas.athena.plugin</groupId>
+ <artifactId>doorlist</artifactId>
+ <version>1.3.0-beta-00-SNAPSHOT</version>
+ <name>doorlist</name>
+ <url>http://maven.apache.org</url>
+ <dependencies>
+
+ </dependencies>
+</project>
+
View
71 ...doorlist/src/main/java/org/fracturedatlas/athena/plugin/doorlist/DoorlistSubResource.java
@@ -0,0 +1,71 @@
+/*
+
+ATHENA Project: Management Tools for the Cultural Sector
+Copyright (C) 2010, Fractured Atlas
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see <http://www.gnu.org/licenses/
+
+ */
+package org.fracturedatlas.athena.plugin.doorlist;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import org.fracturedatlas.athena.client.PTicket;
+import org.fracturedatlas.athena.id.IdAdapter;
+import org.fracturedatlas.athena.model.Ticket;
+import org.fracturedatlas.athena.search.AthenaSearch;
+import org.fracturedatlas.athena.search.Operator;
+import org.fracturedatlas.athena.web.manager.AbstractAthenaSubResource;
+import org.fracturedatlas.athena.web.manager.RecordManager;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+@Component
+public class DoorlistSubResource extends AbstractAthenaSubResource {
+
+ @Autowired
+ RecordManager recordManager;
+
+ Logger logger = LoggerFactory.getLogger(this.getClass().getName());
+
+ @Override
+ public List<PTicket> find(String parentType,
+ Object parentId,
+ String subResourceType,
+ Map<String, List<String>> queryParams,
+ String username) {
+
+ AthenaSearch search = new AthenaSearch.Builder()
+ .type("ticket")
+ .and("performanceId", Operator.EQUALS, IdAdapter.toString(parentId))
+ .build();
+
+ List<Ticket> tickets = Ticket.fromSet(recordManager.findRecords("ticket", search));
+ List<PTicket> doorListRows = new ArrayList<PTicket>();
+
+ //for each ticket, if sold
+ for(Ticket ticket : tickets) {
+ if("sold".equals(ticket.getState())) {
+ PTicket doorListRow = recordManager.getRecord("person", ticket.getBuyerId());
+ doorListRow.put("price", Integer.toString(ticket.getPrice()));
+ doorListRow.put("section", ticket.getSection());
+ doorListRows.add(doorListRow);
+ }
+ }
+ return doorListRows;
+ }
+}
View
13 helpers/doorlist/src/test/resources/log4j.properties
@@ -0,0 +1,13 @@
+# Set root logger level to TRACE and its only appender to CONSOLE.
+log4j.rootLogger=DEBUG, CONSOLE
+
+# A1 is set to be a ConsoleAppender.
+log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
+
+# A1 uses PatternLayout.
+log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
+log4j.appender.CONSOLE.layout.ConversionPattern=[%t] %-5p %c{2} %x - %m%n
+
+log4j.logger.org.hibernate=FATAL
+log4j.logger.org.springframework=ERROR
+log4j.logger.org.fracturedatlas=DEBUG
View
1 helpers/pom.xml
@@ -22,6 +22,7 @@
<module>available-tickets</module>
<module>tags-sub-collection</module>
<module>health-check</module>
+ <module>doorlist</module>
</modules>
<dependencies>
View
5 pom.xml
@@ -101,6 +101,11 @@
</dependency>
<dependency>
<groupId>org.fracturedatlas.athena.plugin</groupId>
+ <artifactId>doorlist</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.fracturedatlas.athena.plugin</groupId>
<artifactId>tags-sub-collection</artifactId>
<version>${project.version}</version>
</dependency>

0 comments on commit 9853022

Please sign in to comment.