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 e5ec612a
authored
Jun 11, 2014
by
Tuukka Kivilahti
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lecturestuff
1 parent
ef91de45
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
106 additions
and
146 deletions
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/MoyaBeans/ejbModule/fi/codecrew/moya/beans/LectureBean.java
View file @
e5ec612
...
@@ -38,7 +38,9 @@ public class LectureBean implements LectureBeanLocal {
...
@@ -38,7 +38,9 @@ public class LectureBean implements LectureBeanLocal {
@Override
@Override
public
List
<
Lecture
>
getLecturesByLectureGroup
(
LectureGroup
group
)
{
public
List
<
Lecture
>
getLecturesByLectureGroup
(
LectureGroup
group
)
{
return
new
ArrayList
<
Lecture
>();
LectureGroup
sourceGroup
=
lectureGroupFacade
.
reload
(
group
);
return
sourceGroup
.
getLectures
();
}
}
@Override
@Override
...
@@ -55,7 +57,7 @@ public class LectureBean implements LectureBeanLocal {
...
@@ -55,7 +57,7 @@ public class LectureBean implements LectureBeanLocal {
if
(
group
.
getEvent
()
==
null
)
if
(
group
.
getEvent
()
==
null
)
group
.
setEvent
(
eventBean
.
getCurrentEvent
());
group
.
setEvent
(
eventBean
.
getCurrentEvent
());
group
=
lectureGroupFacade
.
create
(
group
);
lectureGroupFacade
.
create
(
group
);
}
else
{
}
else
{
group
=
lectureGroupFacade
.
merge
(
group
);
group
=
lectureGroupFacade
.
merge
(
group
);
...
@@ -83,7 +85,7 @@ public class LectureBean implements LectureBeanLocal {
...
@@ -83,7 +85,7 @@ public class LectureBean implements LectureBeanLocal {
lecture
.
setLectureGroup
(
group
);
lecture
.
setLectureGroup
(
group
);
if
(
lecture
.
getId
()
==
null
)
{
if
(
lecture
.
getId
()
==
null
)
{
lecture
=
lecture
Facade
.
create
(
lecture
);
lectureFacade
.
create
(
lecture
);
if
(!
lecture
.
getLectureGroup
().
getLectures
().
contains
(
lecture
))
if
(!
lecture
.
getLectureGroup
().
getLectures
().
contains
(
lecture
))
lecture
.
getLectureGroup
().
getLectures
().
add
(
lecture
);
lecture
.
getLectureGroup
().
getLectures
().
add
(
lecture
);
...
@@ -133,7 +135,7 @@ public class LectureBean implements LectureBeanLocal {
...
@@ -133,7 +135,7 @@ public class LectureBean implements LectureBeanLocal {
lecture
.
getParticipants
().
add
(
targetUser
);
lecture
.
getParticipants
().
add
(
targetUser
);
lectureFacade
.
merge
(
lecture
);
lecture
=
lecture
Facade
.
merge
(
lecture
);
targetUser
.
getLectures
().
add
(
lecture
);
targetUser
.
getLectures
().
add
(
lecture
);
...
@@ -148,7 +150,7 @@ public class LectureBean implements LectureBeanLocal {
...
@@ -148,7 +150,7 @@ public class LectureBean implements LectureBeanLocal {
lecture
.
getParticipants
().
remove
(
targetUser
);
lecture
.
getParticipants
().
remove
(
targetUser
);
targetUser
.
getLectures
().
remove
(
lecture
);
targetUser
.
getLectures
().
remove
(
lecture
);
lectureFacade
.
merge
(
lecture
);
lecture
=
lecture
Facade
.
merge
(
lecture
);
return
lecture
;
return
lecture
;
...
...
code/MoyaBeans/ejbModule/fi/codecrew/moya/beans/NetworkAssociationBean.java
View file @
e5ec612
...
@@ -261,7 +261,7 @@ public class NetworkAssociationBean implements NetworkAssociationBeanLocal {
...
@@ -261,7 +261,7 @@ public class NetworkAssociationBean implements NetworkAssociationBeanLocal {
}
}
// Finally persist the association and return
// Finally persist the association and return
n
a
=
n
etworkAssociationFacade
.
create
(
na
);
networkAssociationFacade
.
create
(
na
);
return
na
;
return
na
;
}
}
...
...
code/MoyaBeans/ejbModule/fi/codecrew/moya/beans/ReaderBean.java
View file @
e5ec612
...
@@ -173,7 +173,7 @@ public class ReaderBean implements ReaderBeanLocal {
...
@@ -173,7 +173,7 @@ public class ReaderBean implements ReaderBeanLocal {
@Override
@Override
public
ReaderEvent
assocCodeToCard
(
ReaderEvent
readerEvent
,
PrintedCard
card
)
{
public
ReaderEvent
assocCodeToCard
(
ReaderEvent
readerEvent
,
PrintedCard
card
)
{
CardCode
code
=
new
CardCode
(
card
,
readerEvent
.
getReader
().
getType
(),
readerEvent
.
getValue
());
CardCode
code
=
new
CardCode
(
card
,
readerEvent
.
getReader
().
getType
(),
readerEvent
.
getValue
()
,
eventbean
.
getCurrentEvent
()
);
cardCodeFacade
.
create
(
code
);
cardCodeFacade
.
create
(
code
);
...
...
code/MoyaDatabase/src/fi/codecrew/moya/model/Lecture.java
View file @
e5ec612
...
@@ -25,80 +25,71 @@ import org.eclipse.persistence.annotations.OptimisticLocking;
...
@@ -25,80 +25,71 @@ import org.eclipse.persistence.annotations.OptimisticLocking;
import
org.eclipse.persistence.annotations.OptimisticLockingType
;
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
@Entity
@Table
(
name
=
"lectures"
)
@Table
(
name
=
"lectures"
)
@OptimisticLocking
(
type
=
OptimisticLockingType
.
CHANGED_COLUMNS
)
@OptimisticLocking
(
type
=
OptimisticLockingType
.
CHANGED_COLUMNS
)
public
class
Lecture
extends
GenericEntity
{
public
class
Lecture
extends
GenericEntity
{
private
static
final
long
serialVersionUID
=
3L
;
private
static
final
long
serialVersionUID
=
3L
;
@Column
(
name
=
"name"
)
private
String
name
;
@Column
(
name
=
"name"
)
private
String
name
;
@Lob
@Column
(
name
=
"description"
)
private
String
description
;
@Lob
@Column
(
name
=
"description"
)
@ManyToOne
private
String
description
;
@JoinColumn
(
name
=
"lecture_group_id"
,
referencedColumnName
=
LectureGroup
.
ID_COLUMN
)
private
LectureGroup
lectureGroup
;
@ManyToOne
@ManyToMany
()
@JoinColumn
(
name
=
"lecture_group_id"
,
referencedColumnName
=
LectureGroup
.
ID_COLUMN
)
@JoinTable
(
name
=
"lecture_participants"
,
private
LectureGroup
lectureGroup
;
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_participants"
,
@ManyToMany
()
joinColumns
=
{
@JoinColumn
(
name
=
"lecture_id"
,
referencedColumnName
=
Lecture
.
ID_COLUMN
)
},
@JoinTable
(
name
=
"lecture_roles"
,
inverseJoinColumns
=
{
@JoinColumn
(
name
=
"eventuser_id"
,
referencedColumnName
=
EventUser
.
ID_COLUMN
)
})
joinColumns
=
{
@JoinColumn
(
name
=
"lecture_id"
,
referencedColumnName
=
Lecture
.
ID_COLUMN
)
},
private
List
<
EventUser
>
participants
;
inverseJoinColumns
=
{
@JoinColumn
(
name
=
"role_id"
,
referencedColumnName
=
Role
.
ID_COLUMN
)
})
private
List
<
Role
>
openForRoles
;
@ManyToMany
()
@Column
(
name
=
"max_participants_count"
)
@JoinTable
(
name
=
"lecture_roles"
,
private
Integer
maxParticipantsCount
;
joinColumns
=
{
@JoinColumn
(
name
=
"lecture_id"
,
referencedColumnName
=
Lecture
.
ID_COLUMN
)
},
inverseJoinColumns
=
{
@JoinColumn
(
name
=
"role_id"
,
referencedColumnName
=
Role
.
ID_COLUMN
)
})
@Temporal
(
TemporalType
.
TIMESTAMP
)
private
List
<
Role
>
openForRoles
;
@Column
(
name
=
"start_time"
)
private
Calendar
startTime
;
@Column
(
name
=
"max_participants_count"
)
private
Integer
maxParticipantsCount
;
@Column
(
name
=
"hours"
,
precision
=
10
,
scale
=
2
)
private
BigDecimal
hours
;
@Temporal
(
TemporalType
.
TIMESTAMP
)
public
Lecture
()
{
@Column
(
name
=
"start_time"
)
super
();
private
Calendar
startTime
;
}
@Column
(
name
=
"hours"
,
precision
=
10
,
scale
=
2
)
public
Lecture
(
LectureGroup
group
)
{
private
BigDecimal
hours
;
this
();
setLectureGroup
(
group
);
public
Lecture
()
{
}
super
();
}
public
Lecture
(
LectureGroup
group
)
{
this
();
setLectureGroup
(
group
);
}
public
String
getName
()
{
public
String
getName
()
{
return
name
;
return
name
;
}
}
public
void
setName
(
String
name
)
{
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
this
.
name
=
name
;
}
}
public
String
getDescription
()
{
public
String
getDescription
()
{
return
description
;
return
description
;
}
}
public
void
setDescription
(
String
description
)
{
public
void
setDescription
(
String
description
)
{
this
.
description
=
description
;
this
.
description
=
description
;
}
}
...
@@ -112,9 +103,9 @@ public class Lecture extends GenericEntity {
...
@@ -112,9 +103,9 @@ public class Lecture extends GenericEntity {
}
}
public
List
<
EventUser
>
getParticipants
()
{
public
List
<
EventUser
>
getParticipants
()
{
if
(
participants
==
null
)
if
(
participants
==
null
)
participants
=
new
ArrayList
<
EventUser
>();
participants
=
new
ArrayList
<
EventUser
>();
return
participants
;
return
participants
;
}
}
...
@@ -123,10 +114,10 @@ public class Lecture extends GenericEntity {
...
@@ -123,10 +114,10 @@ public class Lecture extends GenericEntity {
}
}
public
List
<
Role
>
getOpenForRoles
()
{
public
List
<
Role
>
getOpenForRoles
()
{
if
(
openForRoles
==
null
)
if
(
openForRoles
==
null
)
openForRoles
=
new
ArrayList
<
Role
>();
openForRoles
=
new
ArrayList
<
Role
>();
return
openForRoles
;
return
openForRoles
;
}
}
...
@@ -143,7 +134,7 @@ public class Lecture extends GenericEntity {
...
@@ -143,7 +134,7 @@ public class Lecture extends GenericEntity {
}
}
public
Calendar
getStartTime
()
{
public
Calendar
getStartTime
()
{
if
(
startTime
==
null
)
{
if
(
startTime
==
null
)
{
startTime
=
Calendar
.
getInstance
();
startTime
=
Calendar
.
getInstance
();
}
}
return
startTime
;
return
startTime
;
...
@@ -154,30 +145,25 @@ public class Lecture extends GenericEntity {
...
@@ -154,30 +145,25 @@ public class Lecture extends GenericEntity {
}
}
public
Calendar
getEndTime
()
{
public
Calendar
getEndTime
()
{
if
(
getStartTime
()
==
null
||
getHours
()
==
null
)
if
(
getStartTime
()
==
null
||
getHours
()
==
null
)
return
getStartTime
();
return
getStartTime
();
Calendar
endTime
=
(
Calendar
)
getStartTime
().
clone
();
Calendar
endTime
=
(
Calendar
)
getStartTime
().
clone
();
endTime
.
add
(
Calendar
.
MINUTE
,
getHours
().
multiply
(
new
BigDecimal
(
60
)).
intValue
());
endTime
.
add
(
Calendar
.
MINUTE
,
getHours
().
multiply
(
new
BigDecimal
(
60
)).
intValue
());
return
endTime
;
return
endTime
;
}
}
public
void
setEndTime
(
Calendar
endTime
)
{
public
void
setEndTime
(
Calendar
endTime
)
{
if
(
endTime
==
null
||
getStartTime
()
==
null
)
{
if
(
endTime
==
null
||
getStartTime
()
==
null
)
{
hours
=
BigDecimal
.
ZERO
;
hours
=
BigDecimal
.
ZERO
;
}
}
setHours
(
new
BigDecimal
((
int
)
endTime
.
compareTo
(
getStartTime
())
/
1000
/
60
/
60
));
setHours
(
new
BigDecimal
((
int
)
endTime
.
compareTo
(
getStartTime
())
/
1000
/
60
/
60
));
}
}
public
BigDecimal
getHours
()
{
public
BigDecimal
getHours
()
{
return
hours
;
return
hours
;
...
@@ -193,44 +179,30 @@ public class Lecture extends GenericEntity {
...
@@ -193,44 +179,30 @@ public class Lecture extends GenericEntity {
@Override
@Override
public
Object
clone
()
{
public
Object
clone
()
{
Lecture
newLecture
=
new
Lecture
(
this
.
getLectureGroup
());
Lecture
newLecture
=
new
Lecture
(
this
.
getLectureGroup
());
newLecture
.
setDescription
(
getDescription
());
newLecture
.
setDescription
(
getDescription
());
newLecture
.
setName
(
getName
());
newLecture
.
setName
(
getName
());
newLecture
.
setHours
(
getHours
());
newLecture
.
setHours
(
getHours
());
newLecture
.
setMaxParticipantsCount
(
getMaxParticipantsCount
());
newLecture
.
setMaxParticipantsCount
(
getMaxParticipantsCount
());
newLecture
.
setStartTime
(
getStartTime
());
newLecture
.
setStartTime
(
getStartTime
());
newLecture
.
setOpenForRoles
(
getOpenForRoles
());
newLecture
.
setOpenForRoles
(
getOpenForRoles
());
return
newLecture
;
return
newLecture
;
}
}
@Transient
@Transient
public
boolean
isFull
()
{
public
boolean
isFull
()
{
if
(
getMaxParticipantsCount
()
<=
0
)
{
if
(
getMaxParticipantsCount
()
<=
0
)
{
return
false
;
return
false
;
}
}
return
(
getParticipants
().
size
()
>=
getMaxParticipantsCount
());
return
(
getParticipants
().
size
()
>=
getMaxParticipantsCount
());
}
}
@Transient
@Transient
public
int
getParticipantsCount
()
{
public
int
getParticipantsCount
()
{
return
getParticipants
().
size
();
return
getParticipants
().
size
();
}
}
}
}
code/MoyaDatabase/src/fi/codecrew/moya/model/LectureGroup.java
View file @
e5ec612
...
@@ -20,51 +20,42 @@ import org.eclipse.persistence.annotations.OptimisticLocking;
...
@@ -20,51 +20,42 @@ import org.eclipse.persistence.annotations.OptimisticLocking;
import
org.eclipse.persistence.annotations.OptimisticLockingType
;
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
@Entity
@Table
(
name
=
"lecture_groups"
)
@Table
(
name
=
"lecture_groups"
)
@OptimisticLocking
(
type
=
OptimisticLockingType
.
CHANGED_COLUMNS
)
@OptimisticLocking
(
type
=
OptimisticLockingType
.
CHANGED_COLUMNS
)
public
class
LectureGroup
extends
GenericEntity
{
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
;
@ManyToOne
()
@JoinColumn
(
name
=
"event_id"
,
nullable
=
false
)
@Column
(
name
=
"select_count"
)
private
LanEvent
event
;
private
Integer
selectCount
;
@Column
(
name
=
"name"
)
@Column
(
name
=
"select_count"
)
private
String
name
;
private
Integer
selectCount
;
@Lob
@Column
(
name
=
"description"
)
@Column
(
name
=
"name"
)
private
String
description
;
private
String
name
;
@OneToMany
(
mappedBy
=
"lectureGroup"
,
cascade
=
CascadeType
.
ALL
)
private
List
<
Lecture
>
lectures
;
@Lob
@Column
(
name
=
"description"
)
public
LectureGroup
()
{
private
String
description
;
super
();
}
@OneToMany
(
mappedBy
=
"lectureGroup"
,
cascade
=
CascadeType
.
ALL
)
public
LectureGroup
(
LanEvent
event
)
{
private
List
<
Lecture
>
lectures
;
this
();
this
.
event
=
event
;
}
public
LectureGroup
()
{
super
();
}
public
LectureGroup
(
LanEvent
event
)
{
this
();
this
.
event
=
event
;
}
public
Integer
getSelectCount
()
{
public
Integer
getSelectCount
()
{
return
selectCount
;
return
selectCount
;
...
@@ -74,22 +65,18 @@ public class LectureGroup extends GenericEntity {
...
@@ -74,22 +65,18 @@ public class LectureGroup extends GenericEntity {
this
.
selectCount
=
selectCount
;
this
.
selectCount
=
selectCount
;
}
}
public
String
getName
()
{
public
String
getName
()
{
return
name
;
return
name
;
}
}
public
void
setName
(
String
name
)
{
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
this
.
name
=
name
;
}
}
public
String
getDescription
()
{
public
String
getDescription
()
{
return
description
;
return
description
;
}
}
public
void
setDescription
(
String
description
)
{
public
void
setDescription
(
String
description
)
{
this
.
description
=
description
;
this
.
description
=
description
;
}
}
...
@@ -110,5 +97,4 @@ public class LectureGroup extends GenericEntity {
...
@@ -110,5 +97,4 @@ public class LectureGroup extends GenericEntity {
this
.
lectures
=
lectures
;
this
.
lectures
=
lectures
;
}
}
}
}
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