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
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
19 additions
and
59 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 {
@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 @
e5ec612
...
...
@@ -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 @
e5ec612
...
...
@@ -173,7 +173,7 @@ public class ReaderBean implements ReaderBeanLocal {
@Override
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
);
...
...
code/MoyaDatabase/src/fi/codecrew/moya/model/Lecture.java
View file @
e5ec612
...
...
@@ -25,37 +25,33 @@ 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
;
@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
)
},
...
...
@@ -65,7 +61,6 @@ public class Lecture extends GenericEntity {
@Column
(
name
=
"max_participants_count"
)
private
Integer
maxParticipantsCount
;
@Temporal
(
TemporalType
.
TIMESTAMP
)
@Column
(
name
=
"start_time"
)
private
Calendar
startTime
;
...
...
@@ -73,7 +68,6 @@ public class Lecture extends GenericEntity {
@Column
(
name
=
"hours"
,
precision
=
10
,
scale
=
2
)
private
BigDecimal
hours
;
public
Lecture
()
{
super
();
}
...
...
@@ -88,17 +82,14 @@ public class Lecture extends GenericEntity {
return
name
;
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
public
String
getDescription
()
{
return
description
;
}
public
void
setDescription
(
String
description
)
{
this
.
description
=
description
;
}
...
...
@@ -112,7 +103,7 @@ public class Lecture extends GenericEntity {
}
public
List
<
EventUser
>
getParticipants
()
{
if
(
participants
==
null
)
if
(
participants
==
null
)
participants
=
new
ArrayList
<
EventUser
>();
return
participants
;
...
...
@@ -124,7 +115,7 @@ 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
;
...
...
@@ -155,14 +146,11 @@ 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
();
endTime
.
add
(
Calendar
.
MINUTE
,
getHours
().
multiply
(
new
BigDecimal
(
60
)).
intValue
());
return
endTime
;
...
...
@@ -170,15 +158,13 @@ public class Lecture extends GenericEntity {
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
;
}
...
...
@@ -194,8 +180,6 @@ public class Lecture extends GenericEntity {
public
Object
clone
()
{
Lecture
newLecture
=
new
Lecture
(
this
.
getLectureGroup
());
newLecture
.
setDescription
(
getDescription
());
newLecture
.
setName
(
getName
());
newLecture
.
setHours
(
getHours
());
...
...
@@ -209,11 +193,10 @@ public class Lecture extends GenericEntity {
@Transient
public
boolean
isFull
()
{
if
(
getMaxParticipantsCount
()
<=
0
)
{
if
(
getMaxParticipantsCount
()
<=
0
)
{
return
false
;
}
return
(
getParticipants
().
size
()
>=
getMaxParticipantsCount
());
}
...
...
@@ -223,14 +206,3 @@ public class Lecture extends GenericEntity {
}
}
code/MoyaDatabase/src/fi/codecrew/moya/model/LectureGroup.java
View file @
e5ec612
...
...
@@ -20,42 +20,33 @@ 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
;
@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
();
}
...
...
@@ -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
;
}
}
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