Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Codecrew
/
Moya
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
30
Merge Requests
2
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit f591cc15
authored
Apr 09, 2017
by
Tuomas Riihimäki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Error handlin, etc
1 parent
3631ff43
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
92 additions
and
36 deletions
code/moya-beans-client/ejbModule/fi/codecrew/moya/exceptions/PlaceAlreadyTakenException.java
code/moya-beans/ejbModule/fi/codecrew/moya/beans/PlaceBean.java
code/moya-utils/src/main/java/fi/codecrew/moya/enums/apps/MapPermission.java
code/moya-web/WebContent/neomap/moveplaces.xhtml
code/moya-web/WebContent/place/adminGroups.xhtml
code/moya-web/src/main/java/fi/codecrew/moya/web/cdiview/map/MapPlacechangeView.java
code/moya-web/src/main/resources/fi/codecrew/moya/resources/i18n.properties
code/moya-web/src/main/resources/fi/codecrew/moya/resources/i18n_en.properties
code/moya-web/src/main/resources/fi/codecrew/moya/resources/i18n_fi.properties
code/moya-beans-client/ejbModule/fi/codecrew/moya/exceptions/PlaceAlreadyTakenException.java
0 → 100644
View file @
f591cc1
package
fi
.
codecrew
.
moya
.
exceptions
;
import
fi.codecrew.moya.model.Place
;
import
javax.ejb.EJBException
;
public
class
PlaceAlreadyTakenException
extends
EJBException
{
public
PlaceAlreadyTakenException
(
Place
p
)
{
super
(
"Place "
+
(
p
!=
null
?
p
.
toString
():
""
)
+
"already taken"
);
this
.
place
=
p
;
}
private
final
Place
place
;
public
Place
getPlace
()
{
return
place
;
}
}
code/moya-beans/ejbModule/fi/codecrew/moya/beans/PlaceBean.java
View file @
f591cc1
...
...
@@ -49,6 +49,8 @@ import javax.ejb.Stateless;
import
javax.ejb.Timeout
;
import
javax.ejb.Timer
;
import
javax.ejb.TimerService
;
import
fi.codecrew.moya.exceptions.PlaceAlreadyTakenException
;
import
fi.codecrew.moya.facade.*
;
import
fi.codecrew.moya.model.*
;
...
...
@@ -869,7 +871,7 @@ public class PlaceBean implements PlaceBeanLocal {
throw
new
EJBAccessException
(
"Trying to move places for another user without permissions!"
);
}
if
(!
dst
.
isBuyable
()
||
dst
.
isTaken
())
{
throw
new
EJBException
(
"Place already taken!!"
);
throw
new
PlaceAlreadyTakenException
(
dst
);
}
// Store values we want to store to the destination place
...
...
code/moya-utils/src/main/java/fi/codecrew/moya/enums/apps/MapPermission.java
View file @
f591cc1
...
...
@@ -25,6 +25,7 @@ public enum MapPermission implements IAppPermission {
BUY_PLACES
,
// ("Reserve and buy places from map"),
VIEW
,
// ("View maps"),
MANAGE_MAPS
,
MOVE_PLACES
,
//RELEASE_PLACE, // ("Create and modify maps")
;
...
...
code/moya-web/WebContent/neomap/moveplaces.xhtml
View file @
f591cc1
...
...
@@ -10,25 +10,23 @@
xmlns:p=
"http://primefaces.org/ui"
>
<h:body>
<ui:composition
template=
"#{sessionHandler.template}"
>
<f:metadata>
<f:event
type=
"preRenderView"
listener=
"#{mapPlacechangeView.initView()}"
/>
<f:viewParam
name=
"userId"
value=
"#{mapPlacechangeView.userId}"
/>
<f:event
type=
"preRenderView"
listener=
"#{mapPlacechangeView.initView()}"
/>
</f:metadata>
<ui:define
name=
"content"
>
<h:outputScript
target=
"head"
library=
"seatjs"
name=
"d3.min.js"
/>
<h:outputScript
target=
"head"
library=
"seatjs"
name=
"d3-tip.js"
/>
<h:outputScript
target=
"head"
library=
"seatjs"
name=
"seatmap.js"
/>
<h:outputStylesheet
library=
"seatjs"
name=
"placemap.css"
/>
<h:outputScript
target=
"head"
library=
"seatjs"
name=
"d3.min.js"
/>
<h:outputScript
target=
"head"
library=
"seatjs"
name=
"d3-tip.js"
/>
<h:outputScript
target=
"head"
library=
"seatjs"
name=
"seatmap.js"
/>
<h:outputStylesheet
library=
"seatjs"
name=
"placemap.css"
/>
<!-- Place slot count -->
<h3>
<h:outputText
value=
"#{i18n['placemove.header']}"
/>
<h:outputText
value=
"#{i18n['placemove.header']}"
/>
</h3>
<p:fragment
id=
"placeselector"
>
<h:form>
...
...
@@ -38,25 +36,25 @@
<!-- rowStyleClass="#{mapPlacechangeView.srcPlace.contains(slot.place) ? 'selected' : 'unselected'}" -->
<p:column
headerText=
"#{i18n['placemove.productname']}"
>
<h:outputText
value=
"#{slot.src.product.name}"
/>
<h:outputText
value=
"#{slot.src.product.name}"
/>
</p:column>
<p:column
headerText=
"#{i18n['placemove.placename']}"
>
<h:outputText
renderer=
"#{!empty slot.src.place}"
value=
"#{slot.src.place.name}"
/>
value=
"#{slot.src.place.name}"
/>
</p:column>
<p:column
headerText=
"#{i18n['placemove.placeuser']}"
>
<h:outputText
rendered=
"#{!empty slot.src.place.currentUser}"
value=
"#{slot.src.place.currentUser.wholeNmae}"
/>
value=
"#{slot.src.place.currentUser.wholeNmae}"
/>
<h:outputText
rendered=
"#{empty slot.src.place.currentUser}"
value=
"-"
/>
value=
"-"
/>
</p:column>
<p:column
headerText=
"#{i18n['placemove.dstplace']}"
>
<div
style=
"padding: 0.3em 0;"
>
<h:outputText
renderer=
"#{!empty slot.dst}"
value=
"#{slot.dst.name}"
/>
value=
"#{slot.dst.name}"
/>
</div>
</p:column>
...
...
@@ -66,11 +64,11 @@
actionListener=
"#{mapPlacechangeView.selectSlot}"
rendered=
"#{!slot.isMoving()}"
value=
"#{i18n['placemove.selectSlotForMove']}"
update=
"placeselector"
/>
update=
"placeselector"
/>
<p:commandButton
actionListener=
"#{mapPlacechangeView.unselectSlot}"
rendered=
"#{slot.moving}"
value=
"#{i18n['placemove.deselect']}"
update=
"placeselector"
/>
update=
"placeselector"
/>
</ui:fragment>
</p:column>
...
...
@@ -78,9 +76,8 @@
</h:form>
<script
type=
"text/javascript"
>
toggleSuccess
=
#
{
mapPlacechangeView
.
toggleSuccess
};
var
toggleSuccess
=
#
{
mapPlacechangeView
.
toggleSuccess
};
</script>
</p:fragment>
<div
style=
"padding: 1em 0;"
>
<h:form
id=
"placemove"
>
...
...
@@ -88,20 +85,19 @@
disabled=
"#{!mapPlacechangeView.isReadyForCommit()}"
rendered=
"#{ajaxMapView.canUserBuy()}"
value=
"#{i18n['placemove.commitMove']}"
action=
"#{mapPlacechangeView.commitMove()}"
ajax=
"false"
/>
action=
"#{mapPlacechangeView.commitMove()}"
ajax=
"false"
/>
</h:form>
</div>
</p:fragment>
<svg
id=
"seatmap"
style=
"margin: auto; border: 1px solid black;"
width=
"#{ajaxMapView.map.width}px"
height=
"#{ajaxMapView.map.height}px"
/>
height=
"#{ajaxMapView.map.height}px"
/>
<h:form>
<p:remoteCommand
name=
"toggleDstPlace"
action=
"#{mapPlacechangeView.toggleDstPlace()}"
update=
"placeselector"
oncomplete=
"afterToggle()"
></p:remoteCommand
>
update=
"placeselector"
oncomplete=
"afterToggle()"
/
>
</h:form>
<script
type=
"text/javascript"
>
...
...
@@ -112,26 +108,26 @@
moyaurl
:
"#{request.contextPath}"
,
map_id
:
#
{
ajaxMapView
.
map
.
id
},
});
px
.
toggleaction
=
function
(
d
)
{
px
.
toggleaction
=
function
(
d
)
{
latestPlace
=
d
;
toggleDstPlace
([{
name
:
"placeId"
,
value
:
d
.
id
}
])
toggleDstPlace
([{
name
:
"placeId"
,
value
:
d
.
id
}
])
};
function
afterToggle
(){
if
(
toggleSuccess
)
{
if
(
latestPlace
.
state
===
"F"
)
{
function
afterToggle
()
{
if
(
toggleSuccess
)
{
if
(
latestPlace
.
state
===
"F"
)
{
latestPlace
.
state
=
"T"
;
}
else
{
}
else
{
latestPlace
.
state
=
"F"
;
}
px
.
update_placeobj
([
latestPlace
]);
}
}
// ]]>
// ]]>
</script>
<map:legend
/>
<map:legend
/>
</ui:define>
</ui:composition>
...
...
code/moya-web/WebContent/place/adminGroups.xhtml
View file @
f591cc1
...
...
@@ -20,6 +20,10 @@
</ui:define>
<ui:define
name=
"content"
>
<h:link
outcome=
"/neomap/moveplaces"
value=
"#{i18n['placegroupview.moveUsersPlaces']}"
>
<f:param
name=
"userId"
value=
"#{userView.user.user.id}"
/>
</h:link>
<h:outputText
rendered=
"#{empty placeGroupView.groupMemberships}"
value=
"#{i18n['placegroupview.noMemberships']}"
/>
<h:form
rendered=
"#{!empty placeGroupView.groupMemberships}"
id=
"placelistform"
>
<h:dataTable
value=
"#{placeGroupView.groupMemberships}"
var=
"member"
>
...
...
code/moya-web/src/main/java/fi/codecrew/moya/web/cdiview/map/MapPlacechangeView.java
View file @
f591cc1
...
...
@@ -11,6 +11,7 @@ import javax.faces.context.FacesContext;
import
javax.faces.model.ListDataModel
;
import
javax.inject.Named
;
import
fi.codecrew.moya.exceptions.PlaceAlreadyTakenException
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
...
...
@@ -80,18 +81,29 @@ public class MapPlacechangeView extends GenericCDIView {
}
public
boolean
isReadyForCommit
()
{
// If anything is not selected for commit, we are not ready..
boolean
movingAny
=
false
;
for
(
MoveContainer
mc
:
moveContainers
)
{
if
(
mc
.
isMoving
()
&&
mc
.
getDst
()
==
null
)
{
// If we are moving, but destination is not selected, we are not ready..
if
(
mc
.
isMoving
())
{
movingAny
=
true
;
if
(
mc
.
getDst
()
==
null
)
{
return
false
;
}
}
return
true
;
}
return
movingAny
;
}
public
void
initView
()
{
// If we are overriding user, check permission.
if
(
getSlots
()
==
null
)
{
if
(
super
.
requirePermissions
(
super
.
hasPermission
(
MapPermission
.
MOVE_PLACES
)
||
super
.
hasPermission
(
MapPermission
.
MANAGE_MAPS
)
)
&&
getSlots
()
==
null
)
{
if
(
userId
!=
null
&&
super
.
requirePermissions
(
MapPermission
.
MANAGE_OTHERS
))
{
user
=
userbean
.
findByUserId
(
userId
,
false
);
}
else
if
(
super
.
requirePermissions
(
MapPermission
.
BUY_PLACES
))
{
...
...
@@ -102,7 +114,7 @@ public class MapPlacechangeView extends GenericCDIView {
super
.
beginConversation
();
moveContainers
=
MoveContainer
.
init
(
placebean
.
getPlaceslots
(
user
));
slots
=
new
ListDataModel
<
MoveContainer
>(
moveContainers
);
slots
=
new
ListDataModel
<
>(
moveContainers
);
}
}
...
...
@@ -115,8 +127,22 @@ public class MapPlacechangeView extends GenericCDIView {
change
.
put
(
s
.
getSrc
().
getPlace
(),
s
.
getDst
());
}
}
try
{
placebean
.
movePlaces
(
change
);
}
catch
(
PlaceAlreadyTakenException
pt
)
{
String
placename
=
""
;
if
(
pt
.
getPlace
()
!=
null
)
{
placename
=
pt
.
getPlace
().
getName
();
for
(
MoveContainer
mv
:
slots
)
{
if
(
pt
.
getPlace
().
equals
(
mv
.
getDst
()))
{
mv
.
setDst
(
null
);
}
}
}
super
.
addFaceMessage
(
"placemove.alreadyTaken"
,
placename
);
return
null
;
}
// slots = null;
// initView();
return
"/place/myGroups?faces_redirect=true"
;
...
...
code/moya-web/src/main/resources/fi/codecrew/moya/resources/i18n.properties
View file @
f591cc1
...
...
@@ -1598,3 +1598,5 @@ reservequeue.reservingTimeIsUpAlert=Timeslot for your place reservation has time
mapView.reserveTimeLeft
=
Time to reserve places
queuemgmt.queueEnabled
=
Queue is ENABLED
queuemgmt.queueDisabled
=
Queue is DISABLED (enable from Edit event -page)
placemove.alreadyTaken
=
placegroupview.moveUsersPlaces
=
code/moya-web/src/main/resources/fi/codecrew/moya/resources/i18n_en.properties
View file @
f591cc1
...
...
@@ -1876,3 +1876,5 @@ reservequeue.reservingTimeIsUpAlert=Timeslot for your place reservation has time
mapView.reserveTimeLeft
=
Time to reserve places
queuemgmt.queueEnabled
=
Queue is ENABLED
queuemgmt.queueDisabled
=
Queue is DISABLED (enable from Edit event -page)
placemove.alreadyTaken
=
Moving the places was cancelled because place {0} was already taken.
placegroupview.moveUsersPlaces
=
Move users places
code/moya-web/src/main/resources/fi/codecrew/moya/resources/i18n_fi.properties
View file @
f591cc1
...
...
@@ -1863,3 +1863,5 @@ reservequeue.reservingTimeIsUpAlert=Sinulle varattu varausauka on kulunut loppuu
mapView.reserveTimeLeft
=
Aikaa varata paikkasi
queuemgmt.queueEnabled
=
Varausjono ON k
\u
00E4yt
\u
00F6ss
\u
00E4
queuemgmt.queueDisabled
=
K
\u
00E4ytt
\u
00E4j
\u
00E4jono EI OLE k
\u
00E4yt
\u
00F6ss
\u
00E4 (ota k
\u
00E4yttoon tapahtuman tiedot -sivulta)
placemove.alreadyTaken
=
Paikkojen siirto peruuntui koska paikka {0} oli jo varattu.
placegroupview.moveUsersPlaces
=
Siirrä käyttäjän paikkoja
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