Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Antti Väyrynen
/
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 611a31e5
authored
May 09, 2010
by
Tuukka Kivilahti
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Just some testing stuff, nothing to see here..
...really.
1 parent
f1b25329
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
143 additions
and
21 deletions
code/LanBortalBeans/ejbModule/fi/insomnia/bortal/beans/PlaceMapBean.java
code/LanBortalBeans/ejbModule/fi/insomnia/bortal/beans/TestDataBean.java
code/LanBortalBeansClient/ejbModule/fi/insomnia/bortal/beans/PlaceMapBeanLocal.java
code/LanBortalBeansClient/ejbModule/fi/insomnia/bortal/beans/TestDataBeanLocal.java
code/LanBortalDatabase/src/fi/insomnia/bortal/model/EventMap.java
code/LanBortalWeb/WebContent/generateTestData.xhtml
code/LanBortalWeb/WebContent/resources/tools/map/placeSelect.xhtml
code/LanBortalWeb/WebContent/tests/placemap.xhtml
code/LanBortalWeb/src/fi/insomnia/bortal/handler/SessionHandler.java
code/LanBortalWeb/src/fi/insomnia/bortal/servlet/PlaceMap.java
code/LanBortalWeb/src/fi/insomnia/bortal/view/MapView.java
code/LanBortalWeb/src/fi/insomnia/bortal/view/TestDataView.java
code/LanBortalBeans/ejbModule/fi/insomnia/bortal/beans/PlaceMapBean.java
View file @
611a31e
...
...
@@ -17,7 +17,6 @@ import fi.insomnia.bortal.facade.PlaceFacade;
import
fi.insomnia.bortal.facade.UserFacade
;
import
fi.insomnia.bortal.model.Event
;
import
fi.insomnia.bortal.model.EventMap
;
import
fi.insomnia.bortal.model.EventPk
;
import
fi.insomnia.bortal.model.Place
;
import
fi.insomnia.bortal.model.PlaceGroup
;
import
fi.insomnia.bortal.model.User
;
...
...
@@ -55,13 +54,16 @@ public class PlaceMapBean implements PlaceMapBeanLocal {
}
logger
.
info
(
"Got event {}, mapid {}"
,
event
,
mapId
);
if
(
place
!=
null
)
{
map
=
place
.
getMap
();
}
else
{
map
=
eventMapFacade
.
find
(
eventId
,
mapId
);
}
List
<
Place
>
places
=
map
.
getPlaces
();
logger
.
info
(
"Places: from map {}"
,
places
.
size
());
BufferedImage
image
=
map
.
getMapWithPlaces
();
if
(
userId
!=
null
)
{
...
...
@@ -70,7 +72,9 @@ public class PlaceMapBean implements PlaceMapBeanLocal {
if
(
user
!=
null
)
{
for
(
PlaceGroup
uplacegroup
:
user
.
getPlaceGroups
())
{
for
(
Place
uplace
:
uplacegroup
.
getPlaces
())
{
uplace
.
drawOwnedPlace
(
image
);
if
(
uplace
.
getMap
().
equals
(
map
))
{
uplace
.
drawOwnedPlace
(
image
);
}
}
}
}
...
...
@@ -84,5 +88,22 @@ public class PlaceMapBean implements PlaceMapBeanLocal {
}
public
String
getSelectPlaceMapUrl
(
EventMap
activeMap
,
Place
selectedPlace
,
User
user
)
{
String
parameters
=
"?"
;
if
(
selectedPlace
!=
null
)
{
parameters
+=
"placeid="
+
selectedPlace
.
getId
().
getId
();
}
else
{
parameters
+=
"mapid="
+
activeMap
.
getId
().
getId
();
}
if
(
user
!=
null
)
{
parameters
+=
"&userid="
+
user
.
getId
();
}
return
"/LanBortalWeb/PlaceMap"
+
parameters
;
// TODO: do something.
}
}
code/LanBortalBeans/ejbModule/fi/insomnia/bortal/beans/TestDataBean.java
View file @
611a31e
...
...
@@ -12,25 +12,23 @@ import javax.ejb.Stateless;
import
org.slf4j.LoggerFactory
;
import
fi.insomnia.bortal.facade.EventFacade
;
import
fi.insomnia.bortal.facade.EventMapFacade
;
import
fi.insomnia.bortal.facade.EventOrganiserFacade
;
import
fi.insomnia.bortal.facade.PlaceFacade
;
import
fi.insomnia.bortal.facade.UserFacade
;
import
fi.insomnia.bortal.model.Event
;
import
fi.insomnia.bortal.model.EventMap
;
import
fi.insomnia.bortal.model.EventOrganiser
;
import
fi.insomnia.bortal.model.EventStatus
;
import
fi.insomnia.bortal.model.Place
;
import
fi.insomnia.bortal.model.User
;
import
java.util.List
;
/**
* Session Bean implementation class TestDataBean
*/
@Stateless
public
class
TestDataBean
implements
TestDataBeanLocal
{
public
static
final
String
TEST_MAP_IMAGE_NAME
=
"testmap.png"
;
public
static
final
String
TEST_MAP_IMAGE_NAME
=
"testmap.png"
;
private
static
final
org
.
slf4j
.
Logger
logger
=
LoggerFactory
.
getLogger
(
TestDataBean
.
class
);
@EJB
private
EventMapFacade
eventMapFacade
;
...
...
@@ -38,7 +36,6 @@ public class TestDataBean implements TestDataBeanLocal {
private
EventStatusBeanLocal
eventStatusBean
;
@EJB
private
EventOrganiserFacade
eventOrganiserFacade
;
@EJB
private
EventBeanLocal
eventBean
;
@EJB
...
...
@@ -98,7 +95,6 @@ public class TestDataBean implements TestDataBeanLocal {
/**
* Generate all metashit, ex. events.
*/
private
User
generateUser
()
{
User
user
=
new
User
();
...
...
@@ -122,9 +118,17 @@ public class TestDataBean implements TestDataBeanLocal {
place
.
setWidth
(
50
);
place
.
setHeight
(
50
);
// map.getPlaces().add(place);
placeFacade
.
create
(
place
);
placeFacade
.
create
(
place
);
}
}
}
public
void
printPlacesInfo
()
{
List
<
Place
>
places
=
placeFacade
.
findAll
();
logger
.
info
(
"Printing info from places"
);
for
(
Place
place
:
places
)
{
logger
.
info
(
"Place id: {}. Event Map id: {}."
,
place
.
getId
().
getId
(),
place
.
getMap
().
getId
().
getId
());
}
}
}
code/LanBortalBeansClient/ejbModule/fi/insomnia/bortal/beans/PlaceMapBeanLocal.java
View file @
611a31e
package
fi
.
insomnia
.
bortal
.
beans
;
import
fi.insomnia.bortal.model.EventMap
;
import
fi.insomnia.bortal.model.Place
;
import
fi.insomnia.bortal.model.User
;
import
java.io.IOException
;
import
java.io.OutputStream
;
import
javax.ejb.Local
;
import
fi.insomnia.bortal.model.Event
;
import
fi.insomnia.bortal.model.Place
;
@Local
public
interface
PlaceMapBeanLocal
{
void
printPlaceMapToStream
(
OutputStream
outputStream
,
String
filetype
,
Event
event
,
Integer
mapId
,
Integer
userId
,
Integer
placeId
)
throws
IOException
;
public
String
getSelectPlaceMapUrl
(
EventMap
activeMap
,
Place
selectedPlace
,
User
user
);
}
code/LanBortalBeansClient/ejbModule/fi/insomnia/bortal/beans/TestDataBeanLocal.java
View file @
611a31e
...
...
@@ -12,4 +12,7 @@ public interface TestDataBeanLocal {
void
generateTestPlaces
(
EventMap
map
);
public
void
printPlacesInfo
();
}
code/LanBortalDatabase/src/fi/insomnia/bortal/model/EventMap.java
View file @
611a31e
...
...
@@ -39,7 +39,6 @@ import org.slf4j.LoggerFactory;
public
class
EventMap
implements
EventChildInterface
{
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
EventMap
.
class
);
private
static
final
long
serialVersionUID
=
1L
;
@EmbeddedId
private
EventPk
id
;
...
...
@@ -171,8 +170,8 @@ public class EventMap implements EventChildInterface {
BufferedImage
image
=
ImageIO
.
read
(
new
ByteArrayInputStream
(
getMapData
()));
List
<
Place
>
myplaces
=
getPlaces
();
logger
.
info
(
"Getting places in Event map {}, found {}"
,
this
,
myplaces
.
size
());
for
(
Place
place
:
myplaces
)
{
logger
.
info
(
"Drawing place {}"
,
place
);
for
(
Place
place
:
myplaces
)
{
place
.
drawPlace
(
image
);
}
...
...
code/LanBortalWeb/WebContent/generateTestData.xhtml
View file @
611a31e
...
...
@@ -9,6 +9,11 @@
<h:form>
<!-- todo: remember to remove this :) -->
<h:commandButton
value=
"generate the data"
action=
"#{TestDataView.generateData}"
/>
<br
/>
<br
/>
<h:commandButton
value=
"print places debug info"
action=
"#{TestDataView.printPlacesInfo}"
/>
</h:form>
</h:body>
</html>
...
...
code/LanBortalWeb/WebContent/resources/tools/map/placeSelect.xhtml
View file @
611a31e
...
...
@@ -19,6 +19,7 @@
<h:form>
<h:commandButton
image=
"#{mapView.selectPlaceMapUrl}"
actionListener=
"#{mapView.placeSelectActionListener}"
/>
</h:form>
...
...
code/LanBortalWeb/WebContent/tests/placemap.xhtml
0 → 100644
View file @
611a31e
<!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:ui=
"http://java.sun.com/jsf/facelets"
xmlns:h=
"http://java.sun.com/jsf/html"
xmlns:f=
"http://java.sun.com/jsf/core"
xmlns:map=
"http://java.sun.com/jsf/composite/tools/map"
>
<h:head>
<title></title>
</h:head>
<h:body>
<ui:composition
template=
"/layout/default-template.xhtml"
>
<ui:define
name=
"title"
>
Omnia
</ui:define>
<ui:define
name=
"header"
>
Paikkakartta
</ui:define>
<ui:define
name=
"content"
>
<map:placeSelect
/>
</ui:define>
<ui:define
name=
"footer"
>
Valitse kartta
</ui:define>
</ui:composition>
</h:body>
</html>
\ No newline at end of file
code/LanBortalWeb/src/fi/insomnia/bortal/handler/SessionHandler.java
View file @
611a31e
...
...
@@ -78,7 +78,6 @@ public class SessionHandler {
throw
new
RuntimeException
(
"Empty target"
);
}
return
handlerbean
.
hasPermission
(
Permission
.
getPermission
(
target
),
getUser
(),
permission
);
}
...
...
code/LanBortalWeb/src/fi/insomnia/bortal/servlet/PlaceMap.java
View file @
611a31e
...
...
@@ -37,6 +37,7 @@ public class PlaceMap extends HttpServlet {
@EJB
private
PlaceMapBeanLocal
placemapBean
;
@EJB
private
EventBeanLocal
eventBean
;
...
...
code/LanBortalWeb/src/fi/insomnia/bortal/view/MapView.java
View file @
611a31e
...
...
@@ -4,13 +4,20 @@
*/
package
fi
.
insomnia
.
bortal
.
view
;
import
fi.insomnia.bortal.beans.PlaceMapBeanLocal
;
import
fi.insomnia.bortal.handler.SessionHandler
;
import
fi.insomnia.bortal.model.EventMap
;
import
fi.insomnia.bortal.model.Place
;
import
fi.insomnia.bortal.model.User
;
import
java.util.Map
;
import
javax.ejb.EJB
;
import
javax.faces.bean.ManagedBean
;
import
javax.faces.bean.ManagedProperty
;
import
javax.faces.bean.SessionScoped
;
import
javax.faces.context.FacesContext
;
import
javax.faces.event.ActionEvent
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
/**
*
...
...
@@ -20,7 +27,13 @@ import javax.faces.event.ActionEvent;
@SessionScoped
public
class
MapView
{
private
EventMap
activeMap
;
private
Logger
logger
=
LoggerFactory
.
getLogger
(
MapView
.
class
);
@EJB
private
PlaceMapBeanLocal
placeMapBean
;
@ManagedProperty
(
"#{sessionHandler}"
)
private
SessionHandler
sessionHandler
;
private
EventMap
activeMap
=
null
;
private
Place
selectedPlace
=
null
;
/** Creates a new instance of MapView */
public
MapView
()
{
...
...
@@ -34,18 +47,32 @@ public class MapView {
int
y
=
new
Integer
((
String
)
requestParams
.
get
(
clientId
+
".y"
)).
intValue
();
Place
place
=
getActiveMap
().
findPlace
(
x
,
y
);
throw
new
UnsupportedOperationException
(
"We got place, but are doing nothing with it"
);
selectedPlace
=
place
;
//throw new UnsupportedOperationException("We got place, but are doing nothing with it");
}
public
String
getSelectPlaceMapUrl
()
{
throw
new
UnsupportedOperationException
(
"Return map url"
);
User
user
=
sessionHandler
.
getUser
();
EventMap
map
=
getActiveMap
();
if
(
map
==
null
)
{
return
""
;
}
return
placeMapBean
.
getSelectPlaceMapUrl
(
getActiveMap
(),
selectedPlace
,
user
);
}
/**
* @return the activeMap
* @return the activeMap
, if it's not setted, return events first map. If this event does not have map, return null.
*/
public
EventMap
getActiveMap
()
{
if
(
activeMap
==
null
)
{
if
(
sessionHandler
.
getCurrentEvent
().
getEventMaps
().
size
()
>=
1
)
{
activeMap
=
sessionHandler
.
getCurrentEvent
().
getEventMaps
().
get
(
0
);
}
}
return
activeMap
;
}
...
...
@@ -56,4 +83,31 @@ public class MapView {
this
.
activeMap
=
activeMap
;
}
/**
* @return the selectedPlace
*/
public
Place
getSelectedPlace
()
{
return
selectedPlace
;
}
/**
* @param selectedPlace the selectedPlace to set
*/
public
void
setSelectedPlace
(
Place
selectedPlace
)
{
this
.
selectedPlace
=
selectedPlace
;
}
/**
* @return the sessionHandler
*/
public
SessionHandler
getSessionHandler
()
{
return
sessionHandler
;
}
/**
* @param sessionHandler the sessionHandler to set
*/
public
void
setSessionHandler
(
SessionHandler
sessionHandler
)
{
this
.
sessionHandler
=
sessionHandler
;
}
}
code/LanBortalWeb/src/fi/insomnia/bortal/view/TestDataView.java
View file @
611a31e
...
...
@@ -53,4 +53,11 @@ public class TestDataView {
return
sessionhandler
;
}
public
String
printPlacesInfo
()
{
testdatabean
.
printPlacesInfo
();
return
null
;
}
}
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