Commit aa8d22d8 by Tuomas Riihimäki

Merge branch 'master' of dev.intra.insomnia.fi:/data/bortal

2 parents b80955bc 7031e766
Showing with 648 additions and 105 deletions
deploy.ant.properties.file=/home/tuukka/.netbeans/6.8/gfv3-913352158.properties
deploy.ant.properties.file=/home/tuukka/.netbeans/6.8/gfv3307033442.properties
j2ee.appclient.tool.jvmoptions=-Djava.endorsed.dirs="/usr/local/sges-v3/glassfish/lib/endorsed":"/usr/local/sges-v3/glassfish/modules/endorsed" -javaagent:"/usr/local/sges-v3/glassfish/modules/gf-client.jar"=mode=acscript,arg=-configxml,arg="/home/tuukka/.netbeans/6.8/GlassFish_v3/config/sun-acc.xml",client=jar=
j2ee.appclient.tool.mainclass=org.glassfish.appclient.client.AppClientFacade
j2ee.appclient.tool.runtime=
j2ee.platform.classpath=/usr/local/sges-v3/glassfish/modules/endorsed/jaxb-api-osgi.jar:/usr/local/sges-v3/glassfish/modules/endorsed/webservices-api-osgi.jar:/usr/local/sges-v3/glassfish/modules/javax.security.jacc.jar:/usr/local/sges-v3/glassfish/modules/javax.resource.jar:/usr/local/sges-v3/glassfish/modules/javax.transaction.jar:/usr/local/sges-v3/glassfish/modules/mail.jar:/usr/local/sges-v3/glassfish/modules/javax.persistence.jar:/usr/local/sges-v3/glassfish/modules/javax.enterprise.deploy.jar:/usr/local/sges-v3/glassfish/modules/bean-validator.jar:/usr/local/sges-v3/glassfish/modules/jsr311-api.jar:/usr/local/sges-v3/glassfish/modules/jsf-api.jar:/usr/local/sges-v3/glassfish/modules/weld-osgi-bundle.jar:/usr/local/sges-v3/glassfish/modules/jstl-impl.jar:/usr/local/sges-v3/glassfish/modules/javax.servlet.jsp.jstl.jar:/usr/local/sges-v3/glassfish/modules/javax.management.j2ee.jar:/usr/local/sges-v3/glassfish/modules/javax.security.auth.message.jar:/usr/local/sges-v3/glassfish/modules/javax.ejb.jar:/usr/local/sges-v3/glassfish/modules/javax.servlet.jsp.jar:/usr/local/sges-v3/glassfish/modules/javax.jms.jar:/usr/local/sges-v3/glassfish/modules/endorsed/javax.annotation.jar:/usr/local/sges-v3/glassfish/modules/javax.servlet.jar:/usr/local/sges-v3/glassfish/modules/jsf-impl.jar
j2ee.server.instance=[/usr/local/sges-v3/glassfish]deployer:gfv3ee6:localhost:36570
j2ee.server.instance=[/usr/local/sges-v3/glassfish]deployer:gfv3ee6:localhost:28892
netbeans.user=/home/tuukka/.netbeans/6.8
wa.copy.client.jar.from=/home/tuukka/.netbeans/6.8/GlassFish_v3/generated/xml
......@@ -8,7 +8,7 @@ import fi.insomnia.bortal.model.Event;
@Stateless
@LocalBean
public class EventFacade extends IntegerPkGenericFacade<Event> {
public class EventFacade extends GenericFacade<Integer, Event> {
@PersistenceContext
private EntityManager em;
......
......@@ -8,7 +8,7 @@ import fi.insomnia.bortal.model.EventSettings;
@Stateless
@LocalBean
public class EventSettingsFacade extends EventChildGenericFacade<EventSettings> {
public class EventSettingsFacade extends GenericFacade<Integer, EventSettings> {
@PersistenceContext
private EntityManager em;
......
......@@ -8,7 +8,7 @@ import fi.insomnia.bortal.model.EventStatus;
@Stateless
@LocalBean
public class EventStatusFacade extends EventChildGenericFacade<EventStatus> {
public class EventStatusFacade extends GenericFacade<Integer, EventStatus> {
@PersistenceContext
private EntityManager em;
......
......@@ -10,7 +10,7 @@ import fi.insomnia.bortal.model.User;
@Stateless
@LocalBean
public class UserFacade extends IntegerPkGenericFacade<User> {
public class UserFacade extends GenericFacade<Integer, User> {
public static final String DEFAULT_USER_LOGIN = "ANONYMOUS";
......@@ -26,10 +26,11 @@ public class UserFacade extends IntegerPkGenericFacade<User> {
}
public User findByLogin(String login) {
//TODO: Bug in glassfish.... change when fixed...
// TypedQuery<User> q = em.createNamedQuery("User.findByLogin", User.class);
// q.setParameter("login", login);
// return q.getSingleResult();
// TODO: Bug in glassfish.... change when fixed...
// TypedQuery<User> q = em.createNamedQuery("User.findByLogin",
// User.class);
// q.setParameter("login", login);
// return q.getSingleResult();
TypedQuery<User> q = em.createQuery("SELECT u FROM User u WHERE u.login = :login", User.class);
q.setParameter("login", login);
return getSingleNullableResult(q);
......
deploy.ant.properties.file=/home/tuukka/.netbeans/6.8/gfv3-913352158.properties
deploy.ant.properties.file=/home/tuukka/.netbeans/6.8/gfv3307033442.properties
j2ee.platform.classpath=/usr/local/sges-v3/glassfish/modules/endorsed/jaxb-api-osgi.jar:/usr/local/sges-v3/glassfish/modules/endorsed/webservices-api-osgi.jar:/usr/local/sges-v3/glassfish/modules/javax.security.jacc.jar:/usr/local/sges-v3/glassfish/modules/javax.resource.jar:/usr/local/sges-v3/glassfish/modules/javax.transaction.jar:/usr/local/sges-v3/glassfish/modules/mail.jar:/usr/local/sges-v3/glassfish/modules/javax.persistence.jar:/usr/local/sges-v3/glassfish/modules/javax.enterprise.deploy.jar:/usr/local/sges-v3/glassfish/modules/bean-validator.jar:/usr/local/sges-v3/glassfish/modules/jsr311-api.jar:/usr/local/sges-v3/glassfish/modules/jsf-api.jar:/usr/local/sges-v3/glassfish/modules/weld-osgi-bundle.jar:/usr/local/sges-v3/glassfish/modules/jstl-impl.jar:/usr/local/sges-v3/glassfish/modules/javax.servlet.jsp.jstl.jar:/usr/local/sges-v3/glassfish/modules/javax.management.j2ee.jar:/usr/local/sges-v3/glassfish/modules/javax.security.auth.message.jar:/usr/local/sges-v3/glassfish/modules/javax.ejb.jar:/usr/local/sges-v3/glassfish/modules/javax.servlet.jsp.jar:/usr/local/sges-v3/glassfish/modules/javax.jms.jar:/usr/local/sges-v3/glassfish/modules/endorsed/javax.annotation.jar:/usr/local/sges-v3/glassfish/modules/javax.servlet.jar:/usr/local/sges-v3/glassfish/modules/jsf-impl.jar
j2ee.platform.embeddableejb.classpath=/usr/local/sges-v3/glassfish/lib/embedded/glassfish-embedded-static-shell.jar
j2ee.platform.wsgen.classpath=/usr/local/sges-v3/glassfish/modules/webservices-osgi.jar:/usr/local/sges-v3/glassfish/modules/endorsed/webservices-api-osgi.jar:/usr/local/sges-v3/glassfish/modules/jaxb-osgi.jar:/usr/local/sges-v3/glassfish/modules/endorsed/jaxb-api-osgi.jar
j2ee.platform.wsimport.classpath=/usr/local/sges-v3/glassfish/modules/webservices-osgi.jar:/usr/local/sges-v3/glassfish/modules/endorsed/webservices-api-osgi.jar:/usr/local/sges-v3/glassfish/modules/jaxb-osgi.jar:/usr/local/sges-v3/glassfish/modules/endorsed/jaxb-api-osgi.jar
j2ee.platform.wsit.classpath=
j2ee.server.instance=[/usr/local/sges-v3/glassfish]deployer:gfv3ee6:localhost:36570
j2ee.server.instance=[/usr/local/sges-v3/glassfish]deployer:gfv3ee6:localhost:28892
javac.debug=true
javadoc.preview=true
jaxbwiz.endorsed.dirs=/usr/local/netbeans-6.8/ide12/modules/ext/jaxb/api
......
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog" prefer="system">
<nextCatalog catalog="nbproject/private/retriever/catalog.xml"/>
</catalog>
......@@ -3,7 +3,7 @@
<persistence-unit name="BortalDb" transaction-type="JTA">
<jta-data-source>jdbc/bortal</jta-data-source>
<properties>
<property name="eclipselink.ddl-generation" value="create-tables"/>
<property name="eclipselink.ddl-generation" value="drop-and-create-tables"/>
<property name="eclipselink.ddl-generation.output-mode" value="database"/>
</properties>
</persistence-unit>
......
......@@ -59,23 +59,17 @@ public class Event implements ModelInterface<Integer> {
@Column(name = "referer")
private String referer;
@JoinColumns({
@JoinColumn(name = "event_id", referencedColumnName = "entity_id", nullable = false, updatable = false, insertable = false),
@JoinColumn(name="event_event_id",referencedColumnName = "events_pk_id", nullable = false, updatable = false, insertable = false)
})
@JoinColumn(name = "event_settings_id", referencedColumnName = "event_settings_id", nullable = false, updatable = false)
@ManyToOne(optional = false)
private EventSettings settings;
@JoinColumns({
@JoinColumn(name = "event_status_id", referencedColumnName = "entity_id", nullable = false, updatable = false, insertable = false),
@JoinColumn(name="event_status_event_id",referencedColumnName = "events_pk_id", nullable = false, updatable = false, insertable = false)
})
@JoinColumn(name = "event_status_id", referencedColumnName = "event_status_id", nullable = false)
@ManyToOne(optional = false)
private EventStatus status;
@JoinColumns({
@JoinColumn(name = "default_role_id", referencedColumnName = "entity_id", nullable = false, updatable = false, insertable = false),
@JoinColumn(name="default_role_event_id",referencedColumnName = "events_pk_id", nullable = false, updatable = false, insertable = false)
})
@JoinColumns( {
@JoinColumn(name = "default_role_id", referencedColumnName = "id"),
@JoinColumn(name = "events_id", referencedColumnName = "events_pk_id", nullable = false, updatable = false, insertable = false) })
@OneToOne
private Role defaultRole;
......@@ -94,10 +88,10 @@ public class Event implements ModelInterface<Integer> {
@Version
@Column(nullable = false)
private int jpaVersionField;
@OneToMany(mappedBy = "event")
private List<Bill> bills;
@OneToMany(mappedBy = "event")
private List<Reader> readers;
......@@ -270,7 +264,8 @@ public class Event implements ModelInterface<Integer> {
}
/**
* @param bills the bills to set
* @param bills
* the bills to set
*/
public void setBills(List<Bill> bills) {
this.bills = bills;
......@@ -284,7 +279,8 @@ public class Event implements ModelInterface<Integer> {
}
/**
* @param readers the readers to set
* @param readers
* the readers to set
*/
public void setReaders(List<Reader> readers) {
this.readers = readers;
......
......@@ -11,7 +11,7 @@ import java.io.Serializable;
*
* @author tuukka
*/
public interface EventChildInterface extends ModelInterface<EventPk>, Serializable {
public interface EventChildInterface extends ModelInterface<EventPk> {
public EventPk getId();
public void setId(EventPk id);
......
......@@ -4,7 +4,11 @@
*/
package fi.insomnia.bortal.model;
import java.awt.image.BufferedImage;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.util.List;
import javax.imageio.ImageIO;
import javax.persistence.CascadeType;
import javax.persistence.Column;
......@@ -167,4 +171,20 @@ public class EventMap implements EventChildInterface{
public void setReaders(List<Reader> readers) {
this.readers = readers;
}
public BufferedImage getMapWithPlaces() throws IOException {
BufferedImage image = ImageIO.read(new ByteArrayInputStream(getMapData()));
for(Place place : getPlaces()) {
place.drawPlace(image);
}
return image;
}
}
......@@ -11,12 +11,11 @@ import javax.persistence.*;
public class EventPk implements Serializable {
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "entity_id", nullable = false)
@Column(name = "id", nullable = false)
private Integer id;
@Column(name = "events_pk_id", nullable = false, updatable = false)
private Integer eventId;
private static final long serialVersionUID = 1L;
......@@ -24,8 +23,6 @@ public class EventPk implements Serializable {
super();
}
public void setId(Integer id) {
this.id = id;
}
......@@ -34,30 +31,27 @@ public class EventPk implements Serializable {
return id;
}
public void setEventId(Integer eventId) {
this.eventId = eventId;
}
public Integer getEventId() {
return eventId;
}
public int hashCode() {
return id.hashCode()+eventId.hashCode();
return id.hashCode() + eventId.hashCode();
}
public boolean equals(Object obj) {
if (obj == null) return false;
if (obj == this) return true;
if (!(obj instanceof EventPk)) return false;
if (obj == null)
return false;
if (obj == this)
return true;
if (!(obj instanceof EventPk))
return false;
EventPk pk = (EventPk) obj;
return pk.id == this.id && pk.eventId == this.eventId;
}
}
......@@ -10,6 +10,9 @@ import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
......@@ -25,13 +28,14 @@ import javax.persistence.Version;
@Table(name = "event_settings")
@NamedQueries( {
@NamedQuery(name = "EventSettings.findAll", query = "SELECT e FROM EventSettings e"),
@NamedQuery(name = "EventSettings.findByBundleCountry", query = "SELECT e FROM EventSettings e WHERE e.bundleCountry = :bundleCountry")
})
public class EventSettings implements EventChildInterface{
@NamedQuery(name = "EventSettings.findByBundleCountry", query = "SELECT e FROM EventSettings e WHERE e.bundleCountry = :bundleCountry") })
public class EventSettings implements ModelInterface<Integer> {
private static final long serialVersionUID = 1L;
@EmbeddedId
private EventPk id;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "event_settings_id", nullable = false)
private Integer id;
@Column(name = "organisation")
private String organisation;
......@@ -42,7 +46,6 @@ public class EventSettings implements EventChildInterface{
@OneToMany(cascade = CascadeType.ALL, mappedBy = "settings")
private List<Event> events;
@ManyToOne
@JoinColumn(name = "users_id", referencedColumnName = "users_id", nullable = false)
private User admin;
......@@ -54,10 +57,6 @@ public class EventSettings implements EventChildInterface{
public EventSettings() {
}
public EventSettings(EventPk eventSettingsId) {
this.id = eventSettingsId;
}
public List<Event> getEvents() {
return events;
}
......@@ -97,7 +96,7 @@ public class EventSettings implements EventChildInterface{
* @return the id
*/
@Override
public EventPk getId() {
public Integer getId() {
return id;
}
......@@ -106,7 +105,7 @@ public class EventSettings implements EventChildInterface{
* the id to set
*/
@Override
public void setId(EventPk id) {
public void setId(Integer id) {
this.id = id;
}
......@@ -135,7 +134,8 @@ public class EventSettings implements EventChildInterface{
}
/**
* @param organisation the organisation to set
* @param organisation
* the organisation to set
*/
public void setOrganisation(String organisation) {
this.organisation = organisation;
......@@ -149,7 +149,8 @@ public class EventSettings implements EventChildInterface{
}
/**
* @param bundleCountry the bundleCountry to set
* @param bundleCountry
* the bundleCountry to set
*/
public void setBundleCountry(String bundleCountry) {
this.bundleCountry = bundleCountry;
......@@ -163,7 +164,8 @@ public class EventSettings implements EventChildInterface{
}
/**
* @param admin the admin to set
* @param admin
* the admin to set
*/
public void setAdmin(User admin) {
this.admin = admin;
......
......@@ -10,6 +10,9 @@ import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
......@@ -26,12 +29,14 @@ import javax.persistence.Version;
@NamedQuery(name = "EventStatus.findAll", query = "SELECT e FROM EventStatus e"),
@NamedQuery(name = "EventStatus.findByStatusName", query = "SELECT e FROM EventStatus e WHERE e.statusName = :statusName") })
public class EventStatus implements EventChildInterface{
public class EventStatus implements ModelInterface<Integer> {
private static final long serialVersionUID = 1L;
@EmbeddedId
private EventPk id;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "event_status_id", nullable = false)
private Integer id;
@Column(name = "status_name", nullable = false)
private String statusName;
......@@ -46,12 +51,7 @@ public class EventStatus implements EventChildInterface{
public EventStatus() {
}
public EventStatus(EventPk eventStatusId) {
this.id = eventStatusId;
}
public EventStatus(EventPk eventStatusId, String statusName) {
this.id = eventStatusId;
public EventStatus(String statusName) {
this.statusName = statusName;
}
......@@ -102,7 +102,7 @@ public class EventStatus implements EventChildInterface{
* @return the id
*/
@Override
public EventPk getId() {
public Integer getId() {
return id;
}
......@@ -111,7 +111,7 @@ public class EventStatus implements EventChildInterface{
* the id to set
*/
@Override
public void setId(EventPk id) {
public void setId(Integer id) {
this.id = id;
}
......
package fi.insomnia.bortal.model;
public interface ModelInterface<T> {
import java.io.Serializable;
public interface ModelInterface<T> extends Serializable {
public T getId();
public void setId(T id);
......
......@@ -4,6 +4,10 @@
*/
package fi.insomnia.bortal.model;
import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.Rectangle;
import java.awt.image.BufferedImage;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
......@@ -22,15 +26,15 @@ import javax.persistence.Version;
*/
@Entity
@Table(name = "places")
@NamedQueries( {
@NamedQuery(name = "Place.findAll", query = "SELECT p FROM Place p"),
@NamedQuery(name = "Place.findByDescription", query = "SELECT p FROM Place p WHERE p.description = :description"),
@NamedQuery(name = "Place.findByName", query = "SELECT p FROM Place p WHERE p.name = :name"),
@NamedQuery(name = "Place.findByMapX", query = "SELECT p FROM Place p WHERE p.mapX = :mapX"),
@NamedQuery(name = "Place.findByMapY", query = "SELECT p FROM Place p WHERE p.mapY = :mapY"),
@NamedQuery(name = "Place.findByDetails", query = "SELECT p FROM Place p WHERE p.details = :details"),
@NamedQuery(name = "Place.findByCode", query = "SELECT p FROM Place p WHERE p.code = :code") })
public class Place implements EventChildInterface{
@NamedQueries({
@NamedQuery(name = "Place.findAll", query = "SELECT p FROM Place p"),
@NamedQuery(name = "Place.findByDescription", query = "SELECT p FROM Place p WHERE p.description = :description"),
@NamedQuery(name = "Place.findByName", query = "SELECT p FROM Place p WHERE p.name = :name"),
@NamedQuery(name = "Place.findByMapX", query = "SELECT p FROM Place p WHERE p.mapX = :mapX"),
@NamedQuery(name = "Place.findByMapY", query = "SELECT p FROM Place p WHERE p.mapY = :mapY"),
@NamedQuery(name = "Place.findByDetails", query = "SELECT p FROM Place p WHERE p.details = :details"),
@NamedQuery(name = "Place.findByCode", query = "SELECT p FROM Place p WHERE p.code = :code")})
public class Place implements EventChildInterface {
private static final long serialVersionUID = 1L;
@EmbeddedId
......@@ -44,44 +48,41 @@ public class Place implements EventChildInterface{
private Integer mapX;
@Column(name = "map_y")
private Integer mapY;
@Column(name = "width")
private Integer width;
@Column(name = "height")
private Integer height;
@Column(name = "place_details")
@Lob
private String details;
@Column(name = "place_code")
private String code;
@OneToOne(mappedBy = "placeReservation")
private GroupMembership placeReserver;
/**
* Which group has bought the place
*/
@JoinColumns({
@JoinColumn(name = "groups_id", referencedColumnName = "entity_id", nullable = false, updatable = false, insertable = false),
@JoinColumn(name="groups_event_id",referencedColumnName = "events_pk_id", nullable = false, updatable = false, insertable = false)
@JoinColumn(name = "groups_event_id", referencedColumnName = "events_pk_id", nullable = false, updatable = false, insertable = false)
})
@ManyToOne
private PlaceGroup placeGroup;
@JoinColumns({
@JoinColumn(name = "maps_id", referencedColumnName = "entity_id", nullable = false, updatable = false, insertable = false),
@JoinColumn(name="maps_event_id",referencedColumnName = "events_pk_id", nullable = false, updatable = false, insertable = false)
@JoinColumn(name = "maps_event_id", referencedColumnName = "events_pk_id", nullable = false, updatable = false, insertable = false)
})
@ManyToOne(optional = false)
private EventMap map;
/**
* Which ticket type is this place sold as
*/
@JoinColumns({
@JoinColumn(name = "products_id", referencedColumnName = "entity_id", nullable = false, updatable = false, insertable = false),
@JoinColumn(name="products_event_id",referencedColumnName = "events_pk_id", nullable = false, updatable = false, insertable = false)
@JoinColumn(name = "products_event_id", referencedColumnName = "events_pk_id", nullable = false, updatable = false, insertable = false)
})
@ManyToOne(optional = false)
private Product product;
/**
* Who is the current currentUser (mapped with code printed on the place) of
* the place. Used in Vectorama currentUser tracking.
......@@ -89,7 +90,6 @@ public class Place implements EventChildInterface{
@JoinColumn(name = "users_id", referencedColumnName = "users_id")
@ManyToOne
private User currentUser;
@Version
@Column(nullable = false)
private int jpaVersionField;
......@@ -249,4 +249,73 @@ public class Place implements EventChildInterface{
public GroupMembership getPlaceReserver() {
return placeReserver;
}
/**
* @return the height
*/
public Integer getHeight() {
return height;
}
/**
* @param height the height to set
*/
public void setHeight(Integer height) {
this.height = height;
}
/**
* @return the width
*/
public Integer getWidth() {
return width;
}
/**
* @param width the width to set
*/
public void setWidth(Integer width) {
this.width = width;
}
public boolean isCoordinateInPlace(int x, int y) {
if (x > mapX
&& x < (mapX + width)
&& y > mapY
&& y < (mapY + height)) {
return true;
}
return false;
}
private static final Color NORMAL_COLOR = Color.BLUE;
private static final Color RESERVED_COLOR = Color.RED;
private static final Color SELECTED_COLOR = Color.GREEN;
private static final Color OWNED_COLOR = Color.GREEN;
public void drawPlace(BufferedImage targetImage) {
Graphics2D g = targetImage.createGraphics();
if (placeGroup != null) {
g.setColor(RESERVED_COLOR);
g.fill(new Rectangle(mapX, mapY, width, height));
} else {
g.setColor(NORMAL_COLOR);
g.draw(new Rectangle(mapX, mapY, width, height));
}
}
public void drawSelectedPlace(BufferedImage targetImage) {
Graphics2D g = targetImage.createGraphics();
g.setColor(SELECTED_COLOR);
g.fill(new Rectangle(mapX, mapY, width, height));
}
public void drawOwnedPlace(BufferedImage targetImage) {
Graphics2D g = targetImage.createGraphics();
g.setColor(OWNED_COLOR);
g.fill(new Rectangle(mapX, mapY, width, height));
}
}
......@@ -27,8 +27,8 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fi.insomnia.bortal.utilities.PasswordFunctions;
import java.io.Serializable;
import sun.reflect.generics.reflectiveObjects.NotImplementedException;
/**
*
......
<?xml version="1.0" encoding="UTF-8"?>
<!-- You may freely edit this file. See commented blocks below for -->
<!-- some examples of how to customize the build. -->
<!-- (If you delete it and reopen the project it will be recreated.) -->
<!-- By default, only the Clean and Build commands use this build script. -->
<!-- Commands such as Run, Debug, and Test only use this build script if -->
<!-- the Compile on Save feature is turned off for the project. -->
<!-- You can turn off the Compile on Save (or Deploy on Save) setting -->
<!-- in the project's Project Properties dialog box.-->
<project name="LanBortalUtilities" default="default" basedir=".">
<description>Builds, tests, and runs the project LanBortalUtilities.</description>
<import file="nbproject/build-impl.xml"/>
<!--
There exist several targets which are by default empty and which can be
used for execution of your tasks. These targets are usually executed
before and after some main targets. They are:
-pre-init: called before initialization of project properties
-post-init: called after initialization of project properties
-pre-compile: called before javac compilation
-post-compile: called after javac compilation
-pre-compile-single: called before javac compilation of single file
-post-compile-single: called after javac compilation of single file
-pre-compile-test: called before javac compilation of JUnit tests
-post-compile-test: called after javac compilation of JUnit tests
-pre-compile-test-single: called before javac compilation of single JUnit test
-post-compile-test-single: called after javac compilation of single JUunit test
-pre-jar: called before JAR building
-post-jar: called after JAR building
-post-clean: called after cleaning build products
(Targets beginning with '-' are not intended to be called on their own.)
Example of inserting an obfuscator after compilation could look like this:
<target name="-post-compile">
<obfuscate>
<fileset dir="${build.classes.dir}"/>
</obfuscate>
</target>
For list of available properties check the imported
nbproject/build-impl.xml file.
Another way to customize the build is by overriding existing main targets.
The targets of interest are:
-init-macrodef-javac: defines macro for javac compilation
-init-macrodef-junit: defines macro for junit execution
-init-macrodef-debug: defines macro for class debugging
-init-macrodef-java: defines macro for class execution
-do-jar-with-manifest: JAR building (if you are using a manifest)
-do-jar-without-manifest: JAR building (if you are not using a manifest)
run: execution of project
-javadoc-build: Javadoc generation
test-report: JUnit report generation
An example of overriding the target for project execution could look like this:
<target name="run" depends="LanBortalUtilities-impl.jar">
<exec dir="bin" executable="launcher.exe">
<arg file="${dist.jar}"/>
</exec>
</target>
Notice that the overridden target depends on the jar target and not only on
the compile target as the regular run target does. Again, for a list of available
properties which you can use, check the target you are overriding in the
nbproject/build-impl.xml file.
-->
</project>
Manifest-Version: 1.0
X-COMMENT: Main-Class will be added automatically by build
......@@ -2,6 +2,7 @@
<persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
<persistence-unit name="BortalDb" transaction-type="JTA">
<jta-data-source>jdbc/bortal</jta-data-source>
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<properties>
<property name="eclipselink.ddl-generation" value="create-tables"/>
<property name="eclipselink.ddl-generation.output-mode" value="database"/>
......
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
<display-name>LanBortalWeb</display-name>
<context-param>
<web-app id="WebApp_ID" version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<display-name>LanBortalWeb</display-name>
<context-param>
<param-name>javax.faces.FACELETS_SKIP_COMMENTS</param-name>
<param-value>true</param-value>
</context-param>
<servlet-mapping>
<servlet-name>PlaceMap</servlet-name>
<url-pattern>/PlaceMap</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
......@@ -58,4 +61,4 @@
</auth-constraint>
</security-constraint>
</web-app>
\ No newline at end of file
</web-app>
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html">
<h:head>
<title>Facelet Title</title>
</h:head>
<h:body>
<h:form>
<!-- todo: remember to remove this :) -->
<h:commandButton value="generate the data" action="#{TestDataView.generateData}" />
</h:form>
</h:body>
</html>
......@@ -14,8 +14,8 @@
<ui:define name="title">Omnia</ui:define>
<ui:define name="header">Lippukauppa</ui:define>
<ui:define name="content">
</ui:define>
<shop:productlist />
</ui:define>
<ui:define name="footer">Osta liput</ui:define>
</ui:composition>
</h:body>
......
......@@ -16,6 +16,7 @@
<ui:define name="header">Edit user</ui:define>
<ui:define name="content">
<h:outputText value="productlist"/>
<users:list />
</ui:define>
......
deploy.ant.properties.file=/home/tuukka/.netbeans/6.8/gfv3-913352158.properties
deploy.ant.properties.file=/home/tuukka/.netbeans/6.8/gfv3307033442.properties
j2ee.platform.classpath=/usr/local/sges-v3/glassfish/modules/endorsed/jaxb-api-osgi.jar:/usr/local/sges-v3/glassfish/modules/endorsed/webservices-api-osgi.jar:/usr/local/sges-v3/glassfish/modules/javax.security.jacc.jar:/usr/local/sges-v3/glassfish/modules/javax.resource.jar:/usr/local/sges-v3/glassfish/modules/javax.transaction.jar:/usr/local/sges-v3/glassfish/modules/mail.jar:/usr/local/sges-v3/glassfish/modules/javax.persistence.jar:/usr/local/sges-v3/glassfish/modules/javax.enterprise.deploy.jar:/usr/local/sges-v3/glassfish/modules/bean-validator.jar:/usr/local/sges-v3/glassfish/modules/jsr311-api.jar:/usr/local/sges-v3/glassfish/modules/jsf-api.jar:/usr/local/sges-v3/glassfish/modules/weld-osgi-bundle.jar:/usr/local/sges-v3/glassfish/modules/jstl-impl.jar:/usr/local/sges-v3/glassfish/modules/javax.servlet.jsp.jstl.jar:/usr/local/sges-v3/glassfish/modules/javax.management.j2ee.jar:/usr/local/sges-v3/glassfish/modules/javax.security.auth.message.jar:/usr/local/sges-v3/glassfish/modules/javax.ejb.jar:/usr/local/sges-v3/glassfish/modules/javax.servlet.jsp.jar:/usr/local/sges-v3/glassfish/modules/javax.jms.jar:/usr/local/sges-v3/glassfish/modules/endorsed/javax.annotation.jar:/usr/local/sges-v3/glassfish/modules/javax.servlet.jar:/usr/local/sges-v3/glassfish/modules/jsf-impl.jar
j2ee.platform.embeddableejb.classpath=/usr/local/sges-v3/glassfish/lib/embedded/glassfish-embedded-static-shell.jar
j2ee.platform.is.jsr109=true
j2ee.platform.wsgen.classpath=/usr/local/sges-v3/glassfish/modules/webservices-osgi.jar:/usr/local/sges-v3/glassfish/modules/endorsed/webservices-api-osgi.jar:/usr/local/sges-v3/glassfish/modules/jaxb-osgi.jar:/usr/local/sges-v3/glassfish/modules/endorsed/jaxb-api-osgi.jar
j2ee.platform.wsimport.classpath=/usr/local/sges-v3/glassfish/modules/webservices-osgi.jar:/usr/local/sges-v3/glassfish/modules/endorsed/webservices-api-osgi.jar:/usr/local/sges-v3/glassfish/modules/jaxb-osgi.jar:/usr/local/sges-v3/glassfish/modules/endorsed/jaxb-api-osgi.jar
j2ee.platform.wsit.classpath=
j2ee.server.instance=[/usr/local/sges-v3/glassfish]deployer:gfv3ee6:localhost:36570
j2ee.server.instance=[/usr/local/sges-v3/glassfish]deployer:gfv3ee6:localhost:28892
javac.debug=true
javadoc.preview=true
jaxbwiz.endorsed.dirs=/usr/local/netbeans-6.8/ide12/modules/ext/jaxb/api
......
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package fi.insomnia.bortal.servlet;
import fi.insomnia.bortal.facade.EventMapFacade;
import fi.insomnia.bortal.facade.PlaceFacade;
import fi.insomnia.bortal.facade.UserFacade;
import fi.insomnia.bortal.model.EventMap;
import fi.insomnia.bortal.model.Place;
import fi.insomnia.bortal.model.User;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.io.PrintWriter;
import javax.ejb.EJB;
import javax.imageio.ImageIO;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
*
* @author tuukka
*/
public class PlaceMap extends HttpServlet {
public static final String PARAMETER_EVENT_MAP_ID = "mapid";
public static final String PARAMETER_SELECTED_PLACE_ID = "placeid";
public static final String PARAMETER_CURRENT_USER_ID = "userid";
@EJB
private PlaceFacade placeFacade;
@EJB
private EventMapFacade eventMapFacade;
@EJB
private UserFacade userFacade;
/**
* Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods.
* @param request servlet request
* @param response servlet response
* @throws ServletException if a servlet-specific error occurs
* @throws IOException if an I/O error occurs
*/
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
PrintWriter out = response.getWriter();
try {
Integer placeId = getIntegerParameter(request, PARAMETER_SELECTED_PLACE_ID);
Integer mapId = getIntegerParameter(request, PARAMETER_EVENT_MAP_ID);
Integer userId = getIntegerParameter(request, PARAMETER_CURRENT_USER_ID);
Place place = null;
EventMap map = null;
if (placeId != null) {
place = placeFacade.find(placeId);
}
if (place != null) {
map = place.getMap();
} else {
map = getEventMapFacade().find(mapId);
}
BufferedImage image = map.getMapWithPlaces();
if (userId != null) {
User user = userFacade.find(userId);
if(user != null) {
place.drawOwnedPlace(image);
}
}
if (place != null) {
place.drawSelectedPlace(image);
}
response.setContentType("image/png");
ImageIO.write(image, "png", response.getOutputStream());
/* TODO output your page here
out.println("<html>");
out.println("<head>");
out.println("<title>Servlet PlaceMap</title>");
out.println("</head>");
out.println("<body>");
out.println("<h1>Servlet PlaceMap at " + request.getContextPath () + "</h1>");
out.println("</body>");
out.println("</html>");
*/
} finally {
out.close();
}
}
public void addPlacesToMap() {
}
/***
* Convert request parameter into integer
* @param request
* @param parameter
* @return
*/
private static Integer getIntegerParameter(HttpServletRequest request, String parameter) {
try {
String valueString = request.getParameter(parameter);
Integer value = Integer.parseInt(valueString);
return value;
} catch (NumberFormatException nfe) {
}
return null;
}
// <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
/**
* Handles the HTTP <code>GET</code> method.
* @param request servlet request
* @param response servlet response
* @throws ServletException if a servlet-specific error occurs
* @throws IOException if an I/O error occurs
*/
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
}
/**
* Handles the HTTP <code>POST</code> method.
* @param request servlet request
* @param response servlet response
* @throws ServletException if a servlet-specific error occurs
* @throws IOException if an I/O error occurs
*/
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
}
/**
* Returns a short description of the servlet.
* @return a String containing servlet description
*/
@Override
public String getServletInfo() {
return "Short description";
}// </editor-fold>
/**
* @return the placeFacade
*/
public PlaceFacade getPlaceFacade() {
return placeFacade;
}
/**
* @param placeFacade the placeFacade to set
*/
public void setPlaceFacade(PlaceFacade placeFacade) {
this.placeFacade = placeFacade;
}
/**
* @return the eventMapFacade
*/
public EventMapFacade getEventMapFacade() {
return eventMapFacade;
}
/**
* @param eventMapFacade the eventMapFacade to set
*/
public void setEventMapFacade(EventMapFacade eventMapFacade) {
this.eventMapFacade = eventMapFacade;
}
/**
* @return the userFacade
*/
public UserFacade getUserFacade() {
return userFacade;
}
/**
* @param userFacade the userFacade to set
*/
public void setUserFacade(UserFacade userFacade) {
this.userFacade = userFacade;
}
}
......@@ -29,9 +29,6 @@ import org.slf4j.LoggerFactory;
@SessionScoped
public class ProductView {
@ManagedProperty("#{sessionHandler}")
private SessionHandler sessionhandler;
@EJB
private ProductBeanLocal productBean;
private static final Logger logger = LoggerFactory.getLogger(ProductView.class);
......
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package fi.insomnia.bortal.view;
import fi.insomnia.bortal.facade.EventFacade;
import fi.insomnia.bortal.facade.EventMapFacade;
import fi.insomnia.bortal.facade.PlaceFacade;
import fi.insomnia.bortal.model.Event;
import fi.insomnia.bortal.model.EventMap;
import fi.insomnia.bortal.model.Place;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.net.URISyntaxException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
/**
*
* @author tuukka
*/
@ManagedBean(name = "TestDataView")
@RequestScoped
public class TestDataView {
public static final String TEST_MAP_IMAGE_NAME = "testmap.png";
@EJB
private EventMapFacade eventMapFacade;
@EJB
private EventFacade eventFacade;
private PlaceFacade placeFacade;
public void generateData() {
Event event = generateMetaData();
EventMap map = generateTestMap(event);
generateTestPlaces(map);
}
private EventMap generateTestMap(Event event) {
try {
EventMap map = new EventMap();
map.setEvent(event);
InputStream stream = getClass().getResourceAsStream(TEST_MAP_IMAGE_NAME);
File file = new File(getClass().getResource(TEST_MAP_IMAGE_NAME).toURI());
long length = file.length();
// Create the byte array to hold the data
byte[] bytes = new byte[(int) length];
// Read in the bytes
int offset = 0;
int numRead = 0;
while (offset < bytes.length
&& (numRead = stream.read(bytes, offset, bytes.length - offset)) >= 0) {
offset += numRead;
}
// Ensure all the bytes have been read in
if (offset < bytes.length) {
throw new IOException("Could not completely read file " + file.getName());
}
stream.close();
map.setMapData(bytes);
eventMapFacade.create(map);
return map;
} catch (URISyntaxException ex) {
Logger.getLogger(TestDataView.class.getName()).log(Level.SEVERE, null, ex);
} catch (IOException ex) {
Logger.getLogger(TestDataView.class.getName()).log(Level.SEVERE, null, ex);
}
return null;
}
/**
* Generate all metashit, ex. events.
*/
private Event generateMetaData() {
Event event = new Event();
event.setName("testEvent");
eventFacade.create(event);
return event;
}
private void generateTestPlaces(EventMap map) {
for (int x = 5; x < 400; x += 50) {
for (int y = 5; y < 150; y += 50) {
Place place = new Place();
place.setMap(map);
place.setMapX(x);
place.setMapY(y);
placeFacade.create(place);
}
}
}
/** Creates a new instance of TestDataView */
public TestDataView() {
}
/**
* @return the eventMapFacade
*/
public EventMapFacade getEventMapFacade() {
return eventMapFacade;
}
/**
* @param eventMapFacade the eventMapFacade to set
*/
public void setEventMapFacade(EventMapFacade eventMapFacade) {
this.eventMapFacade = eventMapFacade;
}
/**
* @return the eventFacade
*/
public EventFacade getEventFacade() {
return eventFacade;
}
/**
* @param eventFacade the eventFacade to set
*/
public void setEventFacade(EventFacade eventFacade) {
this.eventFacade = eventFacade;
}
/**
* @return the placeFacade
*/
public PlaceFacade getPlaceFacade() {
return placeFacade;
}
/**
* @param placeFacade the placeFacade to set
*/
public void setPlaceFacade(PlaceFacade placeFacade) {
this.placeFacade = placeFacade;
}
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!