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 f2cc64c0
authored
Apr 07, 2015
by
Tuomas Riihimäki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Copy map places to a map from existing map possibly from other event
1 parent
cfc74206
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
128 additions
and
14 deletions
code/moya-beans-client/ejbModule/fi/codecrew/moya/beans/PlaceBeanLocal.java
code/moya-beans/ejbModule/fi/codecrew/moya/beans/PlaceBean.java
code/moya-beans/ejbModule/fi/codecrew/moya/facade/EventMapFacade.java
code/moya-database/src/main/java/fi/codecrew/moya/model/Place.java
code/moya-database/src/main/java/fi/codecrew/moya/model/Product.java
code/moya-web/WebContent/map/edit.xhtml
code/moya-web/src/main/java/fi/codecrew/moya/web/cdiview/map/MapManageView.java
code/moya-beans-client/ejbModule/fi/codecrew/moya/beans/PlaceBeanLocal.java
View file @
f2cc64c
...
...
@@ -129,4 +129,8 @@ public interface PlaceBeanLocal {
boolean
releaseSlot
(
PlaceSlot
row
);
List
<
EventMap
>
getOrganisationsMaps
();
EventMap
copyMap
(
EventMap
sourceMap
,
EventMap
map
);
}
code/moya-beans/ejbModule/fi/codecrew/moya/beans/PlaceBean.java
View file @
f2cc64c
...
...
@@ -764,4 +764,42 @@ public class PlaceBean implements PlaceBeanLocal {
return
true
;
}
@Override
public
List
<
EventMap
>
getOrganisationsMaps
()
{
return
eventMapFacade
.
findOrganisationMaps
();
}
@RolesAllowed
(
MapPermission
.
S_MANAGE_MAPS
)
public
EventMap
copyMap
(
EventMap
src
,
EventMap
dst
)
{
src
=
eventMapFacade
.
reload
(
src
);
dst
=
eventMapFacade
.
reload
(
dst
);
if
(
dst
.
getPlaces
()
!=
null
&&
!
dst
.
getPlaces
().
isEmpty
())
{
throw
new
EJBException
(
"Destination can not have existing places!"
);
}
Map
<
Product
,
Product
>
prodmapping
=
new
HashMap
<>();
dst
.
setPlaces
(
new
ArrayList
<>());
for
(
Place
p
:
src
.
getPlaces
())
{
Place
np
=
new
Place
(
p
,
dst
);
Product
product
=
prodmapping
.
get
(
p
.
getProduct
());
if
(
product
==
null
)
{
Product
nprod
=
new
Product
(
p
.
getProduct
(),
dst
.
getEvent
());
productBean
.
create
(
nprod
);
prodmapping
.
put
(
p
.
getProduct
(),
nprod
);
}
np
.
setProduct
(
product
);
dst
.
getPlaces
().
add
(
np
);
placeFacade
.
create
(
np
);
}
dst
.
setActive
(
true
);
dst
.
setHeight
(
src
.
getHeight
());
dst
.
setWidth
(
src
.
getWidth
());
dst
.
setMapData
(
src
.
getMapData
());
dst
.
setMimeType
(
src
.
getMimeType
());
// dst.setName("Copy of " + src.getName());
dst
.
setNotes
(
src
.
getNotes
());
return
dst
;
}
}
code/moya-beans/ejbModule/fi/codecrew/moya/facade/EventMapFacade.java
View file @
f2cc64c
...
...
@@ -19,6 +19,7 @@
package
fi
.
codecrew
.
moya
.
facade
;
import
java.util.List
;
import
javax.ejb.EJBAccessException
;
import
javax.ejb.EJB
;
import
javax.ejb.LocalBean
;
...
...
@@ -28,8 +29,13 @@ import javax.persistence.criteria.CriteriaQuery;
import
javax.persistence.criteria.Root
;
import
fi.codecrew.moya.beans.EventBeanLocal
;
import
fi.codecrew.moya.beans.PermissionBeanLocal
;
import
fi.codecrew.moya.enums.apps.MapPermission
;
import
fi.codecrew.moya.model.EventMap
;
import
fi.codecrew.moya.model.EventMap_
;
import
fi.codecrew.moya.model.EventOrganiser
;
import
fi.codecrew.moya.model.LanEvent
;
import
fi.codecrew.moya.model.LanEvent_
;
@Stateless
@LocalBean
...
...
@@ -41,6 +47,8 @@ public class EventMapFacade extends IntegerPkGenericFacade<EventMap> {
@EJB
private
EventBeanLocal
eventbean
;
@EJB
private
PermissionBeanLocal
permbean
;
public
List
<
EventMap
>
getMaps
()
{
...
...
@@ -56,11 +64,23 @@ public class EventMapFacade extends IntegerPkGenericFacade<EventMap> {
@Override
public
EventMap
find
(
Integer
id
)
{
EventMap
ret
=
super
.
find
(
id
);
if
(
ret
!=
null
&&
!
ret
.
getEvent
().
equals
(
eventbean
.
getCurrentEvent
()))
{
if
(
ret
!=
null
&&
!
ret
.
getEvent
().
equals
(
eventbean
.
getCurrentEvent
())
&&
!
permbean
.
hasPermission
(
MapPermission
.
MANAGE_MAPS
)
)
{
throw
new
EJBAccessException
(
"Trying to find map from wrong event!"
);
}
return
ret
;
}
public
List
<
EventMap
>
findOrganisationMaps
()
{
EventOrganiser
org
=
eventbean
.
getCurrentEvent
().
getOrganiser
();
CriteriaBuilder
cb
=
getEm
().
getCriteriaBuilder
();
CriteriaQuery
<
EventMap
>
cq
=
cb
.
createQuery
(
EventMap
.
class
);
Root
<
EventMap
>
root
=
cq
.
from
(
EventMap
.
class
);
cq
.
where
(
cb
.
equal
(
root
.
get
(
EventMap_
.
event
).
get
(
LanEvent_
.
organiser
),
org
),
cb
.
isTrue
(
root
.
get
(
EventMap_
.
active
)));
return
getEm
().
createQuery
(
cq
).
getResultList
();
}
}
code/moya-database/src/main/java/fi/codecrew/moya/model/Place.java
View file @
f2cc64c
...
...
@@ -156,6 +156,20 @@ public class Place extends GenericEntity implements Comparable<Place> {
this
.
map
=
eventMap
;
}
// Copy constructor
public
Place
(
Place
p
,
EventMap
dst
)
{
this
.
map
=
dst
;
this
.
buyable
=
p
.
buyable
;
this
.
description
=
p
.
description
;
this
.
details
=
p
.
details
;
this
.
disabled
=
p
.
disabled
;
this
.
height
=
p
.
height
;
this
.
width
=
p
.
width
;
this
.
mapX
=
p
.
mapX
;
this
.
mapY
=
p
.
mapY
;
this
.
name
=
p
.
name
;
}
public
String
getDescription
()
{
return
description
;
}
...
...
code/moya-database/src/main/java/fi/codecrew/moya/model/Product.java
View file @
f2cc64c
...
...
@@ -144,6 +144,21 @@ public class Product extends GenericEntity {
this
.
name
=
name
;
}
public
Product
(
Product
src
,
LanEvent
event
)
{
super
();
this
.
event
=
event
;
this
.
barcode
=
src
.
barcode
;
this
.
buyInPrice
=
src
.
buyInPrice
;
this
.
color
=
src
.
color
;
this
.
description
=
src
.
description
;
this
.
name
=
src
.
name
;
this
.
price
=
src
.
price
;
this
.
productFlags
=
new
HashSet
<>(
src
.
getProductFlags
());
this
.
sort
=
src
.
sort
;
this
.
unitName
=
src
.
unitName
;
this
.
vat
=
src
.
vat
;
}
public
BigDecimal
getSoldCash
()
{
BigDecimal
tot
=
BigDecimal
.
ZERO
;
for
(
AccountEvent
ac
:
this
.
getAccountEvents
())
{
...
...
code/moya-web/WebContent/map/edit.xhtml
View file @
f2cc64c
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.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/cditools/map"
xmlns:
tools=
"http://java.sun.com/jsf/composite/cditools"
xmlns:c=
"http://java.sun.com/jsp/jstl/core"
xmlns:p=
"http://primefaces.org/ui"
>
<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/cditools/map"
xmlns:tools=
"http://java.sun.com/jsf/composite/cditools"
xmlns:c=
"http://java.sun.com/jsp/jstl/core"
xmlns:p=
"http://primefaces.org/ui"
>
<h:body>
<ui:composition
template=
"#{sessionHandler.template}"
>
<f:metadata>
...
...
@@ -13,8 +13,19 @@
<ui:define
name=
"content"
>
<map:edit
commitaction=
"#{mapManageView.saveMap()}"
commitvalue=
"#{i18n['mapedit.save']}"
/>
<ui:fragment
rendered=
"#{empty mapManageView.map.places}"
>
<h:form>
<p:selectOneMenu
value=
"#{mapManageView.sourceMap}"
converter=
"#{eventMapConverter}"
>
<f:selectItems
value=
"#{mapManageView.oldMaps}"
var=
"m"
itemLabel=
"#{m.event.name} - #{m.name}"
/>
</p:selectOneMenu>
<h:commandButton
action=
"#{mapManageView.copyMap}"
value=
"#{i18n['mapEdit.copyMap']}"
/>
</h:form>
</ui:fragment>
<map:setBuyable
/>
<h:form>
<h:commandButton
styleClass=
"imgcenter"
id=
"commandbutton"
image=
"/PlaceMap?mapid=#{mapView.activeMap.id}"
actionListener=
"#{mapManageView.mapClick}"
/>
</h:form>
...
...
@@ -30,7 +41,7 @@
</h:form>
<h:form>
<p:commandButton
id=
"downloadLink"
actionListener=
"mapManageView.generatePlacePdf"
value=
"koodipdf"
ajax=
"false"
>
<p:commandButton
id=
"downloadLink"
actionListener=
"mapManageView.generatePlacePdf"
value=
"koodipdf"
ajax=
"false"
>
<p:fileDownload
value=
"#{mapManageView.streamedFile}"
/>
</p:commandButton>
</h:form>
...
...
code/moya-web/src/main/java/fi/codecrew/moya/web/cdiview/map/MapManageView.java
View file @
f2cc64c
...
...
@@ -98,7 +98,7 @@ public class MapManageView extends GenericCDIView {
private
StreamedContent
streamedFile
;
private
LanEvent
copyEvent
;
private
EventMap
sourceMap
;
public
void
initCreate
()
{
if
(
super
.
requirePermissions
(
MapPermission
.
MANAGE_MAPS
))
{
...
...
@@ -119,6 +119,19 @@ public class MapManageView extends GenericCDIView {
}
public
List
<
EventMap
>
getOldMaps
()
{
List
<
EventMap
>
ret
=
placebean
.
getOrganisationsMaps
();
if
(
map
!=
null
)
{
ret
.
remove
(
map
);
}
return
ret
;
}
public
String
copyMap
()
{
map
=
placebean
.
copyMap
(
sourceMap
,
map
);
return
null
;
}
public
String
submitBg
()
{
...
...
@@ -147,7 +160,6 @@ public class MapManageView extends GenericCDIView {
addFaceMessage
(
"map.upload.failed"
);
}
return
null
;
}
...
...
@@ -379,14 +391,6 @@ public class MapManageView extends GenericCDIView {
return
productlist
;
}
public
LanEvent
getCopyEvent
()
{
return
copyEvent
;
}
public
void
setCopyEvent
(
LanEvent
copyEvent
)
{
this
.
copyEvent
=
copyEvent
;
}
public
UploadedFile
getBgFile
()
{
return
bgFile
;
}
...
...
@@ -402,4 +406,12 @@ public class MapManageView extends GenericCDIView {
return
streamedFile
;
}
public
EventMap
getSourceMap
()
{
return
sourceMap
;
}
public
void
setSourceMap
(
EventMap
sourceMap
)
{
this
.
sourceMap
=
sourceMap
;
}
}
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