Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Linnea Samila
/
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 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 {
@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,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 @
e5ec612
...
...
@@ -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
;
}
}
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