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 99af43cc
authored
Jun 07, 2010
by
Tuomas Riihimäki
Browse files
Options
Browse Files
Download
Plain Diff
some changes
2 parents
38d217be
b35272de
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
182 additions
and
45 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/LanBortalBeansClient/ejbModule/fi/insomnia/bortal/enums/BeanRole.java
code/LanBortalDatabase/src/fi/insomnia/bortal/model/EventMap.java
code/LanBortalDatabase/src/fi/insomnia/bortal/model/Place.java
code/LanBortalWeb/WebContent/index.xhtml
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 @
99af43c
/*
* 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 @
99af43c
...
...
@@ -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
=
"?"
;
if
(
selectedPlace
!=
null
)
{
// parameters += "placeid=" + selectedPlace.getId().getId();
if
(
selectedPlaces
!=
null
&&
selectedPlaces
.
size
()
>
0
)
{
parameters
+=
"placeid="
;
for
(
Place
place
:
selectedPlaces
)
{
parameters
+=
place
.
getId
().
getId
()
+
","
;
}
if
(
parameters
.
endsWith
(
","
))
{
parameters
.
substring
(
parameters
.
length
()
-
1
);
}
}
else
{
parameters
+=
"mapid="
+
activeMap
.
getId
().
getId
();
}
...
...
code/LanBortalBeansClient/ejbModule/fi/insomnia/bortal/beans/PlaceBeanLocal.java
0 → 100644
View file @
99af43c
/*
* 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/LanBortalBeansClient/ejbModule/fi/insomnia/bortal/enums/BeanRole.java
View file @
99af43c
package
fi
.
insomnia
.
bortal
.
enums
;
public
enum
BeanRole
{
USER_BASE
(
true
),
// Logged in user
ADMIN_BASE
(
true
),
SUPERADMIN
(
false
)
// Admin for this event
import
java.util.HashSet
;
import
java.util.Set
;
public
enum
Role
{
// Bean level access
ANONYMOUS
,
// Unauthenticated web user
USER_BASE
,
// JAAS access for logged in user
ADMIN_BASE
(
USER_BASE
),
// JAAS access to administrative beans
// Admin for the whole system (JAAS, boolean in User)
SUPERADMIN
(
false
,
ADMIN_BASE
),
ORGANIZATION_ROOT
(
ADMIN_BASE
),
// E.g. Vectorama organisation admin
;
private
boolean
inDatabase
;
private
Set
<
Role
>
parents
=
new
HashSet
<
Role
>();
Role
()
{
}
/**
* Default (on-demand create time) parents for the role
*
* @param parent
*/
Role
(
Role
...
parent
)
{
for
(
Role
role
:
parent
)
{
parents
.
add
(
role
);
}
}
BeanRole
(
boolean
inDb
)
{
inDatabase
=
inDb
;
/**
* Is the role stored in the database (default true) or is it a magic role
* like superadmin (stored as boolean in User).
*
* @param inDb
* stored in roles-table
* @param parent
* default (create time) parent roles
*/
Role
(
boolean
inDb
,
Role
...
parent
)
{
this
(
parent
);
this
.
inDatabase
=
inDb
;
}
public
boolean
isInDatabase
()
{
return
inDatabase
;
}
/**
* Default parent roles (when creating role on first use)
*
* @return
*/
public
Set
<
Role
>
getParents
()
{
return
parents
;
}
}
code/LanBortalDatabase/src/fi/insomnia/bortal/model/EventMap.java
View file @
99af43c
...
...
@@ -25,8 +25,6 @@ import javax.persistence.OneToMany;
import
javax.persistence.Table
;
import
javax.persistence.Version
;
import
org.eclipse.persistence.annotations.Cache
;
import
org.eclipse.persistence.annotations.CacheType
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
...
...
code/LanBortalDatabase/src/fi/insomnia/bortal/model/Place.java
View file @
99af43c
...
...
@@ -8,6 +8,7 @@ import java.awt.Color;
import
java.awt.Graphics2D
;
import
java.awt.Rectangle
;
import
java.awt.image.BufferedImage
;
import
java.util.Calendar
;
import
javax.persistence.Column
;
import
javax.persistence.EmbeddedId
;
...
...
@@ -20,10 +21,10 @@ import javax.persistence.NamedQueries;
import
javax.persistence.NamedQuery
;
import
javax.persistence.OneToOne
;
import
javax.persistence.Table
;
import
javax.persistence.Temporal
;
import
javax.persistence.TemporalType
;
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;
@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"
)
})
@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
;
...
...
@@ -58,37 +58,35 @@ public class Place implements EventChildInterface {
private
Integer
width
;
@Column
(
name
=
"height"
)
private
Integer
height
;
@Column
(
name
=
"release_time"
)
@Temporal
(
TemporalType
.
TIMESTAMP
)
private
Calendar
releaseTime
;
@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
=
"group_id"
,
referencedColumnName
=
"id"
,
updatable
=
true
,
insertable
=
true
),
@JoinColumn
(
name
=
"event_id"
,
referencedColumnName
=
"event_id"
,
nullable
=
false
,
updatable
=
false
,
insertable
=
false
)
})
@JoinColumn
(
name
=
"group_id"
,
referencedColumnName
=
"id"
,
updatable
=
true
,
insertable
=
true
),
@JoinColumn
(
name
=
"event_id"
,
referencedColumnName
=
"event_id"
,
nullable
=
false
,
updatable
=
false
,
insertable
=
false
)
})
@ManyToOne
private
PlaceGroup
group
;
@JoinColumns
({
@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
=
"map_id"
,
referencedColumnName
=
"id"
,
nullable
=
false
,
updatable
=
true
,
insertable
=
true
),
@JoinColumn
(
name
=
"event_id"
,
referencedColumnName
=
"event_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
=
"id"
),
@JoinColumn
(
name
=
"event_id"
,
referencedColumnName
=
"event_id"
,
nullable
=
false
,
updatable
=
false
,
insertable
=
false
)
})
@JoinColumn
(
name
=
"products_id"
,
referencedColumnName
=
"id"
),
@JoinColumn
(
name
=
"event_id"
,
referencedColumnName
=
"event_id"
,
nullable
=
false
,
updatable
=
false
,
insertable
=
false
)
})
@ManyToOne
()
private
Product
product
;
/**
...
...
@@ -209,11 +207,12 @@ public class Place implements EventChildInterface {
public
boolean
equals
(
Object
object
)
{
// TODO: Warning - this method won't work in the case the id fields are
// not set
if
(
object
==
null
||
!(
object
instanceof
Place
))
{
if
(!(
object
instanceof
Place
))
{
return
false
;
}
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
true
;
...
...
@@ -306,7 +305,6 @@ public class Place implements EventChildInterface {
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
;
...
...
@@ -315,7 +313,7 @@ public class Place implements EventChildInterface {
public
void
drawPlace
(
BufferedImage
targetImage
)
{
Graphics2D
g
=
targetImage
.
createGraphics
();
if
(
group
!=
null
)
{
if
(
isReserved
()
)
{
g
.
setColor
(
RESERVED_COLOR
);
g
.
fill
(
new
Rectangle
(
mapX
,
mapY
,
width
,
height
));
}
else
{
...
...
@@ -337,4 +335,34 @@ public class Place implements EventChildInterface {
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/WebContent/index.xhtml
View file @
99af43c
...
...
@@ -16,6 +16,9 @@
<ul>
<li><h:commandLink
action=
"generateTestData"
>
Generate test data
</h:commandLink></li>
<li><h:commandLink
action=
"user/list"
>
List users
</h:commandLink></li>
<li><h:commandLink
action=
"user/create"
>
Create user
</h:commandLink></li>
<li><h:commandLink
action=
"tests/placemap"
>
Placemap test
</h:commandLink></li>
<li><h:commandLink
action=
"PlaceMap?mapid=1"
>
Show map 1
</h:commandLink></li>
</ul>
</h:form>
</ui:define>
...
...
code/LanBortalWeb/src/fi/insomnia/bortal/servlet/PlaceMap.java
View file @
99af43c
...
...
@@ -68,9 +68,9 @@ public class PlaceMap extends HttpServlet {
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>");
...
...
code/LanBortalWeb/src/fi/insomnia/bortal/view/MapView.java
View file @
99af43c
...
...
@@ -4,6 +4,7 @@
*/
package
fi
.
insomnia
.
bortal
.
view
;
import
fi.insomnia.bortal.beans.PlaceBeanLocal
;
import
fi.insomnia.bortal.beans.PlaceMapBeanLocal
;
import
fi.insomnia.bortal.handler.SessionHandler
;
import
fi.insomnia.bortal.model.EventMap
;
...
...
@@ -30,8 +31,14 @@ import org.slf4j.LoggerFactory;
public
class
MapView
{
private
Logger
logger
=
LoggerFactory
.
getLogger
(
MapView
.
class
);
@EJB
private
PlaceMapBeanLocal
placeMapBean
;
@EJB
private
PlaceBeanLocal
placeBean
;
@ManagedProperty
(
"#{sessionHandler}"
)
private
SessionHandler
sessionHandler
;
private
EventMap
activeMap
=
null
;
...
...
@@ -51,12 +58,17 @@ public class MapView {
Place
place
=
getActiveMap
().
findPlace
(
x
,
y
);
if
(
selectedPlaces
.
contains
(
place
))
{
selectedPlaces
.
remove
(
place
);
}
else
{
selectedPlaces
.
add
(
place
);
if
(
place
!=
null
)
{
if
(
selectedPlaces
.
contains
(
place
))
{
selectedPlaces
.
remove
(
place
);
place
.
setReserved
(
false
);
placeBean
.
mergeChanges
(
place
);
}
else
{
selectedPlaces
.
add
(
place
);
place
.
setReserved
(
true
);
placeBean
.
mergeChanges
(
place
);
}
}
}
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