Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Linnea Samila
/
Moya
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit b35272de
authored
May 09, 2010
by
Juho Juopperi
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of dev.intra.insomnia.fi:/data/bortal
2 parents
86601d14
47c09beb
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
129 additions
and
37 deletions
code/LanBortalBeans/ejbModule/fi/insomnia/bortal/beans/PlaceBean.java
code/LanBortalBeans/ejbModule/fi/insomnia/bortal/beans/PlaceMapBean.java
code/LanBortalBeansClient/ejbModule/fi/insomnia/bortal/beans/PlaceBeanLocal.java
code/LanBortalDatabase/src/fi/insomnia/bortal/model/EventMap.java
code/LanBortalDatabase/src/fi/insomnia/bortal/model/Place.java
code/LanBortalWeb/src/fi/insomnia/bortal/servlet/PlaceMap.java
code/LanBortalWeb/src/fi/insomnia/bortal/view/MapView.java
code/LanBortalBeans/ejbModule/fi/insomnia/bortal/beans/PlaceBean.java
0 → 100644
View file @
b35272d
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package
fi
.
insomnia
.
bortal
.
beans
;
import
fi.insomnia.bortal.facade.PlaceFacade
;
import
fi.insomnia.bortal.model.Place
;
import
javax.ejb.EJB
;
import
javax.ejb.Stateless
;
/**
*
* @author tuukka
*/
@Stateless
public
class
PlaceBean
implements
PlaceBeanLocal
{
@EJB
private
PlaceFacade
placeFacade
;
public
void
mergeChanges
(
Place
place
)
{
placeFacade
.
merge
(
place
);
}
}
code/LanBortalBeans/ejbModule/fi/insomnia/bortal/beans/PlaceMapBean.java
View file @
b35272d
...
@@ -95,12 +95,21 @@ public class PlaceMapBean implements PlaceMapBeanLocal {
...
@@ -95,12 +95,21 @@ public class PlaceMapBean implements PlaceMapBeanLocal {
}
}
public
String
getSelectPlaceMapUrl
(
EventMap
activeMap
,
List
<
Place
>
selectedPlace
,
User
user
)
{
public
String
getSelectPlaceMapUrl
(
EventMap
activeMap
,
List
<
Place
>
selectedPlace
s
,
User
user
)
{
String
parameters
=
"?"
;
String
parameters
=
"?"
;
if
(
selectedPlace
!=
null
)
{
if
(
selectedPlaces
!=
null
&&
selectedPlaces
.
size
()
>
0
)
{
// parameters += "placeid=" + selectedPlace.getId().getId();
parameters
+=
"placeid="
;
for
(
Place
place
:
selectedPlaces
)
{
parameters
+=
place
.
getId
().
getId
()
+
","
;
}
if
(
parameters
.
endsWith
(
","
))
{
parameters
.
substring
(
parameters
.
length
()
-
1
);
}
}
else
{
}
else
{
parameters
+=
"mapid="
+
activeMap
.
getId
().
getId
();
parameters
+=
"mapid="
+
activeMap
.
getId
().
getId
();
}
}
...
...
code/LanBortalBeansClient/ejbModule/fi/insomnia/bortal/beans/PlaceBeanLocal.java
0 → 100644
View file @
b35272d
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package
fi
.
insomnia
.
bortal
.
beans
;
import
fi.insomnia.bortal.model.Place
;
import
javax.ejb.Local
;
/**
*
* @author tuukka
*/
@Local
public
interface
PlaceBeanLocal
{
public
void
mergeChanges
(
Place
place
);
}
code/LanBortalDatabase/src/fi/insomnia/bortal/model/EventMap.java
View file @
b35272d
...
@@ -25,8 +25,6 @@ import javax.persistence.OneToMany;
...
@@ -25,8 +25,6 @@ import javax.persistence.OneToMany;
import
javax.persistence.Table
;
import
javax.persistence.Table
;
import
javax.persistence.Version
;
import
javax.persistence.Version
;
import
org.eclipse.persistence.annotations.Cache
;
import
org.eclipse.persistence.annotations.CacheType
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
...
...
code/LanBortalDatabase/src/fi/insomnia/bortal/model/Place.java
View file @
b35272d
...
@@ -8,6 +8,7 @@ import java.awt.Color;
...
@@ -8,6 +8,7 @@ import java.awt.Color;
import
java.awt.Graphics2D
;
import
java.awt.Graphics2D
;
import
java.awt.Rectangle
;
import
java.awt.Rectangle
;
import
java.awt.image.BufferedImage
;
import
java.awt.image.BufferedImage
;
import
java.util.Calendar
;
import
javax.persistence.Column
;
import
javax.persistence.Column
;
import
javax.persistence.EmbeddedId
;
import
javax.persistence.EmbeddedId
;
...
@@ -20,10 +21,10 @@ import javax.persistence.NamedQueries;
...
@@ -20,10 +21,10 @@ import javax.persistence.NamedQueries;
import
javax.persistence.NamedQuery
;
import
javax.persistence.NamedQuery
;
import
javax.persistence.OneToOne
;
import
javax.persistence.OneToOne
;
import
javax.persistence.Table
;
import
javax.persistence.Table
;
import
javax.persistence.Temporal
;
import
javax.persistence.TemporalType
;
import
javax.persistence.Version
;
import
javax.persistence.Version
;
import
org.eclipse.persistence.annotations.Cache
;
import
org.eclipse.persistence.annotations.CacheType
;
/**
/**
...
@@ -32,14 +33,13 @@ import org.eclipse.persistence.annotations.CacheType;
...
@@ -32,14 +33,13 @@ import org.eclipse.persistence.annotations.CacheType;
@Entity
@Entity
@Table
(
name
=
"places"
)
@Table
(
name
=
"places"
)
@NamedQueries
({
@NamedQueries
({
@NamedQuery
(
name
=
"Place.findAll"
,
query
=
"SELECT p FROM Place p"
),
@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.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.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.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.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.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"
)
})
@NamedQuery
(
name
=
"Place.findByCode"
,
query
=
"SELECT p FROM Place p WHERE p.code = :code"
)})
public
class
Place
implements
EventChildInterface
{
public
class
Place
implements
EventChildInterface
{
private
static
final
long
serialVersionUID
=
1L
;
private
static
final
long
serialVersionUID
=
1L
;
...
@@ -58,37 +58,35 @@ public class Place implements EventChildInterface {
...
@@ -58,37 +58,35 @@ public class Place implements EventChildInterface {
private
Integer
width
;
private
Integer
width
;
@Column
(
name
=
"height"
)
@Column
(
name
=
"height"
)
private
Integer
height
;
private
Integer
height
;
@Column
(
name
=
"release_time"
)
@Temporal
(
TemporalType
.
TIMESTAMP
)
private
Calendar
releaseTime
;
@Column
(
name
=
"place_details"
)
@Column
(
name
=
"place_details"
)
@Lob
@Lob
private
String
details
;
private
String
details
;
@Column
(
name
=
"place_code"
)
@Column
(
name
=
"place_code"
)
private
String
code
;
private
String
code
;
@OneToOne
(
mappedBy
=
"placeReservation"
)
@OneToOne
(
mappedBy
=
"placeReservation"
)
private
GroupMembership
placeReserver
;
private
GroupMembership
placeReserver
;
/**
/**
* Which group has bought the place
* Which group has bought the place
*/
*/
@JoinColumns
({
@JoinColumns
({
@JoinColumn
(
name
=
"group_id"
,
referencedColumnName
=
"id"
,
updatable
=
true
,
insertable
=
true
),
@JoinColumn
(
name
=
"group_id"
,
referencedColumnName
=
"id"
,
updatable
=
true
,
insertable
=
true
),
@JoinColumn
(
name
=
"event_id"
,
referencedColumnName
=
"event_id"
,
nullable
=
false
,
updatable
=
false
,
insertable
=
false
)
})
@JoinColumn
(
name
=
"event_id"
,
referencedColumnName
=
"event_id"
,
nullable
=
false
,
updatable
=
false
,
insertable
=
false
)
})
@ManyToOne
@ManyToOne
private
PlaceGroup
group
;
private
PlaceGroup
group
;
@JoinColumns
({
@JoinColumns
({
@JoinColumn
(
name
=
"map_id"
,
referencedColumnName
=
"id"
,
nullable
=
false
,
updatable
=
true
,
insertable
=
true
),
@JoinColumn
(
name
=
"map_id"
,
referencedColumnName
=
"id"
,
nullable
=
false
,
updatable
=
true
,
insertable
=
true
),
@JoinColumn
(
name
=
"event_id"
,
referencedColumnName
=
"event_id"
,
nullable
=
false
,
updatable
=
false
,
insertable
=
false
)
})
@JoinColumn
(
name
=
"event_id"
,
referencedColumnName
=
"event_id"
,
nullable
=
false
,
updatable
=
false
,
insertable
=
false
)
})
@ManyToOne
(
optional
=
false
)
@ManyToOne
(
optional
=
false
)
private
EventMap
map
;
private
EventMap
map
;
/**
/**
* Which ticket type is this place sold as
* Which ticket type is this place sold as
*/
*/
@JoinColumns
({
@JoinColumns
({
@JoinColumn
(
name
=
"products_id"
,
referencedColumnName
=
"id"
),
@JoinColumn
(
name
=
"products_id"
,
referencedColumnName
=
"id"
),
@JoinColumn
(
name
=
"event_id"
,
referencedColumnName
=
"event_id"
,
nullable
=
false
,
updatable
=
false
,
insertable
=
false
)
})
@JoinColumn
(
name
=
"event_id"
,
referencedColumnName
=
"event_id"
,
nullable
=
false
,
updatable
=
false
,
insertable
=
false
)
})
@ManyToOne
()
@ManyToOne
()
private
Product
product
;
private
Product
product
;
/**
/**
...
@@ -209,11 +207,12 @@ public class Place implements EventChildInterface {
...
@@ -209,11 +207,12 @@ public class Place implements EventChildInterface {
public
boolean
equals
(
Object
object
)
{
public
boolean
equals
(
Object
object
)
{
// TODO: Warning - this method won't work in the case the id fields are
// TODO: Warning - this method won't work in the case the id fields are
// not set
// not set
if
(
object
==
null
||
!(
object
instanceof
Place
))
{
if
(!(
object
instanceof
Place
))
{
return
false
;
return
false
;
}
}
Place
other
=
(
Place
)
object
;
Place
other
=
(
Place
)
object
;
if
((
this
.
getId
()
==
null
&&
other
.
getId
()
!=
null
)
||
(
this
.
getId
()
!=
null
&&
!
this
.
getId
().
equals
(
other
.
id
)))
{
if
((
this
.
getId
()
==
null
&&
other
.
getId
()
!=
null
)
||
(
this
.
getId
()
!=
null
&&
!
this
.
id
.
equals
(
other
.
id
)))
{
return
false
;
return
false
;
}
}
return
true
;
return
true
;
...
@@ -306,7 +305,6 @@ public class Place implements EventChildInterface {
...
@@ -306,7 +305,6 @@ public class Place implements EventChildInterface {
return
false
;
return
false
;
}
}
private
static
final
Color
NORMAL_COLOR
=
Color
.
BLUE
;
private
static
final
Color
NORMAL_COLOR
=
Color
.
BLUE
;
private
static
final
Color
RESERVED_COLOR
=
Color
.
RED
;
private
static
final
Color
RESERVED_COLOR
=
Color
.
RED
;
private
static
final
Color
SELECTED_COLOR
=
Color
.
GREEN
;
private
static
final
Color
SELECTED_COLOR
=
Color
.
GREEN
;
...
@@ -315,7 +313,7 @@ public class Place implements EventChildInterface {
...
@@ -315,7 +313,7 @@ public class Place implements EventChildInterface {
public
void
drawPlace
(
BufferedImage
targetImage
)
{
public
void
drawPlace
(
BufferedImage
targetImage
)
{
Graphics2D
g
=
targetImage
.
createGraphics
();
Graphics2D
g
=
targetImage
.
createGraphics
();
if
(
group
!=
null
)
{
if
(
isReserved
()
)
{
g
.
setColor
(
RESERVED_COLOR
);
g
.
setColor
(
RESERVED_COLOR
);
g
.
fill
(
new
Rectangle
(
mapX
,
mapY
,
width
,
height
));
g
.
fill
(
new
Rectangle
(
mapX
,
mapY
,
width
,
height
));
}
else
{
}
else
{
...
@@ -337,4 +335,34 @@ public class Place implements EventChildInterface {
...
@@ -337,4 +335,34 @@ public class Place implements EventChildInterface {
g
.
fill
(
new
Rectangle
(
mapX
,
mapY
,
width
,
height
));
g
.
fill
(
new
Rectangle
(
mapX
,
mapY
,
width
,
height
));
}
}
public
boolean
isReserved
()
{
if
(
releaseTime
!=
null
)
{
if
(
System
.
currentTimeMillis
()
>
releaseTime
.
getTimeInMillis
())
{
setReserved
(
false
);
}
else
{
return
true
;
}
}
if
(
group
!=
null
)
{
return
true
;
}
return
false
;
}
public
static
final
long
RESERVE_TIME
=
1000
*
60
*
20
;
// 20min.
public
void
setReserved
(
boolean
reserved
)
{
if
(
reserved
)
{
releaseTime
=
Calendar
.
getInstance
();
releaseTime
.
setTimeInMillis
(
System
.
currentTimeMillis
()+
RESERVE_TIME
);
}
else
{
releaseTime
=
null
;
}
}
}
}
code/LanBortalWeb/src/fi/insomnia/bortal/servlet/PlaceMap.java
View file @
b35272d
...
@@ -68,9 +68,9 @@ public class PlaceMap extends HttpServlet {
...
@@ -68,9 +68,9 @@ public class PlaceMap extends HttpServlet {
Integer
userId
=
getIntegerParameter
(
request
,
PARAMETER_CURRENT_USER_ID
);
Integer
userId
=
getIntegerParameter
(
request
,
PARAMETER_CURRENT_USER_ID
);
response
.
setContentType
(
"image/
gif
"
);
response
.
setContentType
(
"image/
jpeg
"
);
placemapBean
.
printPlaceMapToStream
(
ostream
,
"
gif
"
,
getEvent
(
request
),
mapId
,
userId
,
placeIds
);
placemapBean
.
printPlaceMapToStream
(
ostream
,
"
jpeg
"
,
getEvent
(
request
),
mapId
,
userId
,
placeIds
);
/*
/*
* TODO output your page here out.println("<html>");
* TODO output your page here out.println("<html>");
...
...
code/LanBortalWeb/src/fi/insomnia/bortal/view/MapView.java
View file @
b35272d
...
@@ -4,6 +4,7 @@
...
@@ -4,6 +4,7 @@
*/
*/
package
fi
.
insomnia
.
bortal
.
view
;
package
fi
.
insomnia
.
bortal
.
view
;
import
fi.insomnia.bortal.beans.PlaceBeanLocal
;
import
fi.insomnia.bortal.beans.PlaceMapBeanLocal
;
import
fi.insomnia.bortal.beans.PlaceMapBeanLocal
;
import
fi.insomnia.bortal.handler.SessionHandler
;
import
fi.insomnia.bortal.handler.SessionHandler
;
import
fi.insomnia.bortal.model.EventMap
;
import
fi.insomnia.bortal.model.EventMap
;
...
@@ -30,8 +31,14 @@ import org.slf4j.LoggerFactory;
...
@@ -30,8 +31,14 @@ import org.slf4j.LoggerFactory;
public
class
MapView
{
public
class
MapView
{
private
Logger
logger
=
LoggerFactory
.
getLogger
(
MapView
.
class
);
private
Logger
logger
=
LoggerFactory
.
getLogger
(
MapView
.
class
);
@EJB
@EJB
private
PlaceMapBeanLocal
placeMapBean
;
private
PlaceMapBeanLocal
placeMapBean
;
@EJB
private
PlaceBeanLocal
placeBean
;
@ManagedProperty
(
"#{sessionHandler}"
)
@ManagedProperty
(
"#{sessionHandler}"
)
private
SessionHandler
sessionHandler
;
private
SessionHandler
sessionHandler
;
private
EventMap
activeMap
=
null
;
private
EventMap
activeMap
=
null
;
...
@@ -51,12 +58,17 @@ public class MapView {
...
@@ -51,12 +58,17 @@ public class MapView {
Place
place
=
getActiveMap
().
findPlace
(
x
,
y
);
Place
place
=
getActiveMap
().
findPlace
(
x
,
y
);
if
(
selectedPlaces
.
contains
(
place
))
{
if
(
place
!=
null
)
{
selectedPlaces
.
remove
(
place
);
if
(
selectedPlaces
.
contains
(
place
))
{
}
else
{
selectedPlaces
.
remove
(
place
);
selectedPlaces
.
add
(
place
);
place
.
setReserved
(
false
);
placeBean
.
mergeChanges
(
place
);
}
else
{
selectedPlaces
.
add
(
place
);
place
.
setReserved
(
true
);
placeBean
.
mergeChanges
(
place
);
}
}
}
}
}
public
String
getSelectPlaceMapUrl
()
{
public
String
getSelectPlaceMapUrl
()
{
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment