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 5cc92394
authored
Jun 12, 2014
by
Tuukka Kivilahti
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin' into user_selectable_groups
2 parents
715d68ad
9366fc3c
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
181 additions
and
157 deletions
code/MoyaBeans/ejbModule/fi/codecrew/moya/beans/CardTemplateBean.java
code/MoyaBeans/ejbModule/fi/codecrew/moya/beans/LectureBean.java
code/MoyaBeans/ejbModule/fi/codecrew/moya/beans/NetworkAssociationBean.java
code/MoyaBeans/ejbModule/fi/codecrew/moya/beans/ReaderBean.java
code/MoyaDatabase/src/fi/codecrew/moya/model/Lecture.java
code/MoyaDatabase/src/fi/codecrew/moya/model/LectureGroup.java
code/MoyaWeb/WebContent/admin/adduser/update.xhtml
code/MoyaWeb/src/fi/codecrew/moya/web/cdiview/user/AuthView.java
code/MoyaWeb/src/fi/codecrew/moya/web/cdiview/user/UserView.java
code/MoyaBeans/ejbModule/fi/codecrew/moya/beans/CardTemplateBean.java
View file @
5cc9239
...
...
@@ -50,6 +50,10 @@ import fi.codecrew.moya.util.MailMessage;
@DeclareRoles
({
UserPermission
.
S_WRITE_ROLES
})
public
class
CardTemplateBean
implements
CardTemplateBeanLocal
{
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
CardTemplateBean
.
class
);
/**
...
...
code/MoyaBeans/ejbModule/fi/codecrew/moya/beans/LectureBean.java
View file @
5cc9239
...
...
@@ -38,7 +38,9 @@ public class LectureBean implements LectureBeanLocal {
@Override
public
List
<
Lecture
>
getLecturesByLectureGroup
(
LectureGroup
group
)
{
return
new
ArrayList
<
Lecture
>();
LectureGroup
sourceGroup
=
lectureGroupFacade
.
reload
(
group
);
return
sourceGroup
.
getLectures
();
}
@Override
...
...
@@ -55,7 +57,7 @@ public class LectureBean implements LectureBeanLocal {
if
(
group
.
getEvent
()
==
null
)
group
.
setEvent
(
eventBean
.
getCurrentEvent
());
group
=
lectureGroupFacade
.
create
(
group
);
lectureGroupFacade
.
create
(
group
);
}
else
{
group
=
lectureGroupFacade
.
merge
(
group
);
...
...
@@ -83,7 +85,7 @@ public class LectureBean implements LectureBeanLocal {
lecture
.
setLectureGroup
(
group
);
if
(
lecture
.
getId
()
==
null
)
{
lecture
=
lecture
Facade
.
create
(
lecture
);
lectureFacade
.
create
(
lecture
);
if
(!
lecture
.
getLectureGroup
().
getLectures
().
contains
(
lecture
))
lecture
.
getLectureGroup
().
getLectures
().
add
(
lecture
);
...
...
@@ -133,7 +135,7 @@ public class LectureBean implements LectureBeanLocal {
lecture
.
getParticipants
().
add
(
targetUser
);
lectureFacade
.
merge
(
lecture
);
lecture
=
lecture
Facade
.
merge
(
lecture
);
targetUser
.
getLectures
().
add
(
lecture
);
...
...
@@ -148,7 +150,7 @@ public class LectureBean implements LectureBeanLocal {
lecture
.
getParticipants
().
remove
(
targetUser
);
targetUser
.
getLectures
().
remove
(
lecture
);
lectureFacade
.
merge
(
lecture
);
lecture
=
lecture
Facade
.
merge
(
lecture
);
return
lecture
;
...
...
code/MoyaBeans/ejbModule/fi/codecrew/moya/beans/NetworkAssociationBean.java
View file @
5cc9239
...
...
@@ -261,7 +261,7 @@ public class NetworkAssociationBean implements NetworkAssociationBeanLocal {
}
// Finally persist the association and return
n
a
=
n
etworkAssociationFacade
.
create
(
na
);
networkAssociationFacade
.
create
(
na
);
return
na
;
}
...
...
code/MoyaBeans/ejbModule/fi/codecrew/moya/beans/ReaderBean.java
View file @
5cc9239
...
...
@@ -172,10 +172,18 @@ public class ReaderBean implements ReaderBeanLocal {
@Override
public
ReaderEvent
assocCodeToCard
(
ReaderEvent
readerEvent
,
PrintedCard
card
)
{
// you can select between this and flushCache.
card
=
cardfacade
.
reload
(
card
);
CardCode
code
=
new
CardCode
(
card
,
readerEvent
.
getReader
().
getType
(),
readerEvent
.
getValue
(),
eventbean
.
getCurrentEvent
());
CardCode
code
=
new
CardCode
(
card
,
readerEvent
.
getReader
().
getType
(),
readerEvent
.
getValue
());
cardCodeFacade
.
create
(
code
);
card
.
getCardCodes
().
add
(
code
);
return
readerEvent
;
}
...
...
code/MoyaDatabase/src/fi/codecrew/moya/model/Lecture.java
View file @
5cc9239
...
...
@@ -25,80 +25,71 @@ import org.eclipse.persistence.annotations.OptimisticLocking;
import
org.eclipse.persistence.annotations.OptimisticLockingType
;
/**
* Group for lectures, so you can set limits how many of these the user can choose
* Group for lectures, so you can set limits how many of these the user can
* choose
*/
@Entity
@Table
(
name
=
"lectures"
)
@OptimisticLocking
(
type
=
OptimisticLockingType
.
CHANGED_COLUMNS
)
public
class
Lecture
extends
GenericEntity
{
private
static
final
long
serialVersionUID
=
3L
;
private
static
final
long
serialVersionUID
=
3L
;
@Column
(
name
=
"name"
)
private
String
name
;
@Lob
@Column
(
name
=
"description"
)
private
String
description
;
@ManyToOne
@JoinColumn
(
name
=
"lecture_group_id"
,
referencedColumnName
=
LectureGroup
.
ID_COLUMN
)
private
LectureGroup
lectureGroup
;
@ManyToMany
()
@JoinTable
(
name
=
"lecture_participants"
,
joinColumns
=
{
@JoinColumn
(
name
=
"lecture_id"
,
referencedColumnName
=
Lecture
.
ID_COLUMN
)
},
inverseJoinColumns
=
{
@JoinColumn
(
name
=
"eventuser_id"
,
referencedColumnName
=
EventUser
.
ID_COLUMN
)
})
private
List
<
EventUser
>
participants
;
@ManyToMany
()
@JoinTable
(
name
=
"lecture_roles"
,
joinColumns
=
{
@JoinColumn
(
name
=
"lecture_id"
,
referencedColumnName
=
Lecture
.
ID_COLUMN
)
},
inverseJoinColumns
=
{
@JoinColumn
(
name
=
"role_id"
,
referencedColumnName
=
Role
.
ID_COLUMN
)
})
private
List
<
Role
>
openForRoles
;
@Column
(
name
=
"max_participants_count"
)
private
Integer
maxParticipantsCount
;
@Temporal
(
TemporalType
.
TIMESTAMP
)
@Column
(
name
=
"start_time"
)
private
Calendar
startTime
;
@Column
(
name
=
"hours"
,
precision
=
10
,
scale
=
2
)
private
BigDecimal
hours
;
public
Lecture
()
{
super
();
}
public
Lecture
(
LectureGroup
group
)
{
this
();
setLectureGroup
(
group
);
}
@Column
(
name
=
"name"
)
private
String
name
;
@Lob
@Column
(
name
=
"description"
)
private
String
description
;
@ManyToOne
@JoinColumn
(
name
=
"lecture_group_id"
,
referencedColumnName
=
LectureGroup
.
ID_COLUMN
)
private
LectureGroup
lectureGroup
;
@ManyToMany
()
@JoinTable
(
name
=
"lecture_participants"
,
joinColumns
=
{
@JoinColumn
(
name
=
"lecture_id"
,
referencedColumnName
=
Lecture
.
ID_COLUMN
)
},
inverseJoinColumns
=
{
@JoinColumn
(
name
=
"eventuser_id"
,
referencedColumnName
=
EventUser
.
ID_COLUMN
)
})
private
List
<
EventUser
>
participants
;
@ManyToMany
()
@JoinTable
(
name
=
"lecture_roles"
,
joinColumns
=
{
@JoinColumn
(
name
=
"lecture_id"
,
referencedColumnName
=
Lecture
.
ID_COLUMN
)
},
inverseJoinColumns
=
{
@JoinColumn
(
name
=
"role_id"
,
referencedColumnName
=
Role
.
ID_COLUMN
)
})
private
List
<
Role
>
openForRoles
;
@Column
(
name
=
"max_participants_count"
)
private
Integer
maxParticipantsCount
;
@Temporal
(
TemporalType
.
TIMESTAMP
)
@Column
(
name
=
"start_time"
)
private
Calendar
startTime
;
@Column
(
name
=
"hours"
,
precision
=
10
,
scale
=
2
)
private
BigDecimal
hours
;
public
Lecture
()
{
super
();
}
public
Lecture
(
LectureGroup
group
)
{
this
();
setLectureGroup
(
group
);
}
public
String
getName
()
{
return
name
;
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
public
String
getDescription
()
{
return
description
;
}
public
void
setDescription
(
String
description
)
{
this
.
description
=
description
;
}
...
...
@@ -112,9 +103,9 @@ public class Lecture extends GenericEntity {
}
public
List
<
EventUser
>
getParticipants
()
{
if
(
participants
==
null
)
if
(
participants
==
null
)
participants
=
new
ArrayList
<
EventUser
>();
return
participants
;
}
...
...
@@ -123,10 +114,10 @@ public class Lecture extends GenericEntity {
}
public
List
<
Role
>
getOpenForRoles
()
{
if
(
openForRoles
==
null
)
if
(
openForRoles
==
null
)
openForRoles
=
new
ArrayList
<
Role
>();
return
openForRoles
;
}
...
...
@@ -143,7 +134,7 @@ public class Lecture extends GenericEntity {
}
public
Calendar
getStartTime
()
{
if
(
startTime
==
null
)
{
if
(
startTime
==
null
)
{
startTime
=
Calendar
.
getInstance
();
}
return
startTime
;
...
...
@@ -154,30 +145,25 @@ public class Lecture extends GenericEntity {
}
public
Calendar
getEndTime
()
{
if
(
getStartTime
()
==
null
||
getHours
()
==
null
)
if
(
getStartTime
()
==
null
||
getHours
()
==
null
)
return
getStartTime
();
Calendar
endTime
=
(
Calendar
)
getStartTime
().
clone
();
Calendar
endTime
=
(
Calendar
)
getStartTime
().
clone
();
endTime
.
add
(
Calendar
.
MINUTE
,
getHours
().
multiply
(
new
BigDecimal
(
60
)).
intValue
());
return
endTime
;
}
public
void
setEndTime
(
Calendar
endTime
)
{
if
(
endTime
==
null
||
getStartTime
()
==
null
)
{
if
(
endTime
==
null
||
getStartTime
()
==
null
)
{
hours
=
BigDecimal
.
ZERO
;
}
setHours
(
new
BigDecimal
((
int
)
endTime
.
compareTo
(
getStartTime
())
/
1000
/
60
/
60
));
}
public
BigDecimal
getHours
()
{
return
hours
;
...
...
@@ -193,44 +179,30 @@ public class Lecture extends GenericEntity {
@Override
public
Object
clone
()
{
Lecture
newLecture
=
new
Lecture
(
this
.
getLectureGroup
());
newLecture
.
setDescription
(
getDescription
());
newLecture
.
setName
(
getName
());
newLecture
.
setHours
(
getHours
());
newLecture
.
setMaxParticipantsCount
(
getMaxParticipantsCount
());
newLecture
.
setStartTime
(
getStartTime
());
newLecture
.
setOpenForRoles
(
getOpenForRoles
());
return
newLecture
;
}
@Transient
public
boolean
isFull
()
{
if
(
getMaxParticipantsCount
()
<=
0
)
{
if
(
getMaxParticipantsCount
()
<=
0
)
{
return
false
;
}
return
(
getParticipants
().
size
()
>=
getMaxParticipantsCount
());
}
@Transient
public
int
getParticipantsCount
()
{
return
getParticipants
().
size
();
}
}
}
code/MoyaDatabase/src/fi/codecrew/moya/model/LectureGroup.java
View file @
5cc9239
...
...
@@ -20,51 +20,42 @@ import org.eclipse.persistence.annotations.OptimisticLocking;
import
org.eclipse.persistence.annotations.OptimisticLockingType
;
/**
* Group for lectures, so you can set limits how many of these the user can choose
* Group for lectures, so you can set limits how many of these the user can
* choose
*/
@Entity
@Table
(
name
=
"lecture_groups"
)
@OptimisticLocking
(
type
=
OptimisticLockingType
.
CHANGED_COLUMNS
)
public
class
LectureGroup
extends
GenericEntity
{
private
static
final
long
serialVersionUID
=
4L
;
private
static
final
long
serialVersionUID
=
4L
;
@ManyToOne
()
@JoinColumn
(
name
=
"event_id"
,
nullable
=
false
)
private
LanEvent
event
;
@Column
(
name
=
"select_count"
)
private
Integer
selectCount
;
@Column
(
name
=
"name"
)
private
String
name
;
@Lob
@Column
(
name
=
"description"
)
private
String
description
;
@OneToMany
(
mappedBy
=
"lectureGroup"
,
cascade
=
CascadeType
.
ALL
)
private
List
<
Lecture
>
lectures
;
public
LectureGroup
()
{
super
();
}
public
LectureGroup
(
LanEvent
event
)
{
this
();
this
.
event
=
event
;
}
@ManyToOne
()
@JoinColumn
(
name
=
"event_id"
,
nullable
=
false
)
private
LanEvent
event
;
@Column
(
name
=
"select_count"
)
private
Integer
selectCount
;
@Column
(
name
=
"name"
)
private
String
name
;
@Lob
@Column
(
name
=
"description"
)
private
String
description
;
@OneToMany
(
mappedBy
=
"lectureGroup"
,
cascade
=
CascadeType
.
ALL
)
private
List
<
Lecture
>
lectures
;
public
LectureGroup
()
{
super
();
}
public
LectureGroup
(
LanEvent
event
)
{
this
();
this
.
event
=
event
;
}
public
Integer
getSelectCount
()
{
return
selectCount
;
...
...
@@ -74,22 +65,18 @@ public class LectureGroup extends GenericEntity {
this
.
selectCount
=
selectCount
;
}
public
String
getName
()
{
return
name
;
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
public
String
getDescription
()
{
return
description
;
}
public
void
setDescription
(
String
description
)
{
this
.
description
=
description
;
}
...
...
@@ -110,5 +97,4 @@ public class LectureGroup extends GenericEntity {
this
.
lectures
=
lectures
;
}
}
code/MoyaWeb/WebContent/admin/adduser/update.xhtml
View file @
5cc9239
...
...
@@ -8,17 +8,25 @@
<f:metadata>
<f:viewParam
name=
"userid"
value=
"#{userView.userid}"
/>
<f:event
type=
"preRenderView"
listener=
"#{userView.initView}"
/>
<f:event
type=
"preRenderView"
listener=
"#{userView.setCaptureForwardUrl('/admin/adduser/capturesuccess')}"
/>
<f:event
type=
"preRenderView"
listener=
"#{userView.setCaptureForwardUrl('/admin/adduser/update')}"
/>
</f:metadata>
<ui:define
name=
"topbar"
>
<h:link
styleClass=
"userbackbutton"
outcome=
"/admin/adduser/index"
>
<div>
#{i18n['adduser.back']}
</div>
</h:link>
<h:form>
<h:commandLink
styleClass=
"userbackbutton"
action=
"#{userView.incomingPhotoReady}"
value=
"Valmis"
>
<div>
#{i18n['adduser.back']}
</div>
</h:commandLink>
</h:form>
</ui:define>
<ui:define
name=
"content"
>
<div
style=
"text-align: center;"
>
<h:form
styleClass=
"captureForm"
>
<h:panelGrid
columns=
"2"
>
...
...
@@ -31,28 +39,42 @@
</a>
</h:panelGroup>
<h:panelGroup>
<div
id=
"webcamcontainer"
>
<p:photoCam
widgetVar=
"pc"
listener=
"#{userView.oncapture}"
/>
<p:commandButton
type=
"button"
value=
"Capture"
onclick=
"PF('pc').capture()"
/>
<div
id=
"count"
/>
<p:photoCam
widgetVar=
"pc"
listener=
"#{userView.oncapture}"
update=
"@all"
/>
<!-- <p:commandButton type="button" value="Capture" onclick="dophoto(pc)" />
-->
</div>
</h:panelGroup>
</h:panelGrid>
</h:form>
</div>
<div
style=
""
>
<h:link
style=
"margin: 0 auto; font-size: 3em;"
outcome=
"/admin/adduser/index"
value=
"Valmis"
/>
<h:form
id=
"incomingpictureform"
>
<h:commandLink
rendered=
"#{!empty userView.selectedUser.currentImage}"
style=
"margin: 0 auto; font-size: 3em;"
action=
"#{userView.incomingPhotoReady}"
value=
"Valmis"
/>
<br
/>
<p:fragment
rendered=
"#{!empty userView.selectedUser.currentImage}"
>
<p:graphicImage
value=
"/dydata/userimage/#{userView.selectedUser.currentImage.id}.img"
alt=
"image"
/>
</p:fragment>
</h:form>
</div>
<script>
function
dophoto
(
pc
)
{
docount
(
5
,
pc
);
docount
(
5
,
pc
);
}
function
docount
(
count
,
pc
)
{
function
docount
(
count
,
pc
)
{
$
(
'#count'
).
html
(
count
);
$
(
'#count'
).
css
(
"opacity"
,
1
);
$
(
'#count'
).
css
(
"font-size"
,
"28pt"
);
...
...
@@ -63,9 +85,9 @@
},
1500
,
function
()
{
if
(
count
>
1
)
docount
(
count
-
1
,
pc
);
if
(
count
==
1
)
{
if
(
count
==
1
)
{
pc
.
capture
();
}
}
});
}
...
...
code/MoyaWeb/src/fi/codecrew/moya/web/cdiview/user/AuthView.java
View file @
5cc9239
...
...
@@ -84,6 +84,22 @@ public class AuthView extends GenericCDIView {
return
"/frontpage"
;
}
public
void
executeLogoutNoRedirect
()
{
HttpServletRequest
req
=
getRequest
();
if
(
permbean
.
isLoggedIn
())
{
try
{
req
.
logout
();
}
catch
(
ServletException
e
)
{
logger
.
warn
(
"Error executing logout"
,
e
);
}
}
req
.
getSession
().
invalidate
();
}
public
void
executeLogin
()
{
executeLogin
(
null
);
...
...
code/MoyaWeb/src/fi/codecrew/moya/web/cdiview/user/UserView.java
View file @
5cc9239
...
...
@@ -154,6 +154,12 @@ public class UserView extends GenericCDIView {
}
/**
* This is the user we are currently editing, if that is not found we user
* current user
...
...
@@ -395,7 +401,7 @@ public class UserView extends GenericCDIView {
public
String
createUserAdduserView
()
{
userbean
.
createNewUser
(
user
,
getPassword
());
//
authView.executeAdduserAutoLogin(user, getPassword());
authView
.
executeAdduserAutoLogin
(
user
,
getPassword
());
return
"/admin/adduser/update"
;
}
...
...
@@ -404,6 +410,14 @@ public class UserView extends GenericCDIView {
canSave
=
permbean
.
hasPermission
(
UserPermission
.
MODIFY
);
return
"/useradmin/edit"
;
}
// /admin/adduser/index
public
String
incomingPhotoReady
()
{
authView
.
executeLogoutNoRedirect
();
navihandler
.
forward
(
"/admin/adduser/index?faces-redirect=true"
);
return
"/admin/adduser/index"
;
}
public
void
setUserid
(
Integer
userid
)
{
this
.
userid
=
userid
;
...
...
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