Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Antti Väyrynen
/
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 2cd8a858
authored
May 11, 2013
by
Antti Tönkyrä
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tournament stuffing
1 parent
fd37dc10
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
332 additions
and
11 deletions
code/MoyaBeans/ejbModule/fi/codecrew/moya/facade/TournamentFacade.java
code/MoyaDatabase/src/fi/codecrew/moya/model/Tournament.java
code/MoyaDatabase/src/fi/codecrew/moya/model/TournamentGame.java
code/MoyaDatabase/src/fi/codecrew/moya/model/Match.java → code/MoyaDatabase/src/fi/codecrew/moya/model/TournamentMatch.java
code/MoyaDatabase/src/fi/codecrew/moya/model/MatchResult.java → code/MoyaDatabase/src/fi/codecrew/moya/model/TournamentMatchResult.java
code/MoyaDatabase/src/fi/codecrew/moya/model/TournamentRule.java
code/MoyaUtilities/src/fi/codecrew/moya/enums/MatchStatus.java
code/MoyaUtilities/src/fi/codecrew/moya/enums/TournamentStatus.java
code/MoyaBeans/ejbModule/fi/codecrew/moya/facade/TournamentFacade.java
0 → 100644
View file @
2cd8a85
package
fi
.
codecrew
.
moya
.
facade
;
import
java.util.List
;
import
javax.ejb.EJB
;
import
javax.ejb.LocalBean
;
import
javax.ejb.Stateless
;
import
javax.persistence.TypedQuery
;
import
javax.persistence.criteria.CriteriaBuilder
;
import
javax.persistence.criteria.CriteriaQuery
;
import
javax.persistence.criteria.Root
;
import
fi.codecrew.moya.model.PrintedCard_
;
import
fi.codecrew.moya.beans.EventBeanLocal
;
import
fi.codecrew.moya.model.EventUser
;
import
fi.codecrew.moya.model.LanEvent
;
import
fi.codecrew.moya.model.PrintedCard
;
@Stateless
@LocalBean
public
class
TournamentFacade
extends
IntegerPkGenericFacade
<
PrintedCard
>
{
public
TournamentFacade
()
{
super
(
PrintedCard
.
class
);
}
@EJB
private
EventBeanLocal
eventbean
;
public
PrintedCard
findByRfid
(
String
uid
)
{
CriteriaBuilder
cb
=
getEm
().
getCriteriaBuilder
();
CriteriaQuery
<
PrintedCard
>
cq
=
cb
.
createQuery
(
PrintedCard
.
class
);
Root
<
PrintedCard
>
root
=
cq
.
from
(
PrintedCard
.
class
);
cq
.
where
(
cb
.
equal
(
root
.
get
(
PrintedCard_
.
rfidUid
),
uid
),
cb
.
equal
(
root
.
get
(
PrintedCard_
.
event
),
eventbean
.
getCurrentEvent
()));
return
getSingleNullableResult
(
getEm
().
createQuery
(
cq
));
}
public
PrintedCard
findByBarcode
(
String
barcode
)
{
CriteriaBuilder
cb
=
getEm
().
getCriteriaBuilder
();
CriteriaQuery
<
PrintedCard
>
cq
=
cb
.
createQuery
(
PrintedCard
.
class
);
Root
<
PrintedCard
>
root
=
cq
.
from
(
PrintedCard
.
class
);
cq
.
where
(
cb
.
equal
(
root
.
get
(
PrintedCard_
.
barcode
),
barcode
),
cb
.
equal
(
root
.
get
(
PrintedCard_
.
event
),
eventbean
.
getCurrentEvent
()));
return
getSingleNullableResult
(
getEm
().
createQuery
(
cq
));
}
public
List
<
PrintedCard
>
findAllEnabled
(
LanEvent
currentEvent
)
{
CriteriaBuilder
cb
=
getEm
().
getCriteriaBuilder
();
CriteriaQuery
<
PrintedCard
>
cq
=
cb
.
createQuery
(
PrintedCard
.
class
);
Root
<
PrintedCard
>
root
=
cq
.
from
(
PrintedCard
.
class
);
cq
.
where
(
cb
.
isTrue
(
root
.
get
(
PrintedCard_
.
enabled
)),
cb
.
equal
(
root
.
get
(
PrintedCard_
.
event
),
eventbean
.
getCurrentEvent
()));
return
getEm
().
createQuery
(
cq
).
getResultList
();
}
public
List
<
PrintedCard
>
getCards
(
EventUser
user
)
{
CriteriaBuilder
cb
=
getEm
().
getCriteriaBuilder
();
CriteriaQuery
<
PrintedCard
>
cq
=
cb
.
createQuery
(
PrintedCard
.
class
);
Root
<
PrintedCard
>
root
=
cq
.
from
(
PrintedCard
.
class
);
cq
.
where
(
cb
.
equal
(
root
.
get
(
PrintedCard_
.
user
),
user
),
cb
.
equal
(
root
.
get
(
PrintedCard_
.
event
),
eventbean
.
getCurrentEvent
()));
return
getEm
().
createQuery
(
cq
).
getResultList
();
}
public
PrintedCard
findLatestByRfidFromAny
(
String
uid
)
{
CriteriaBuilder
cb
=
getEm
().
getCriteriaBuilder
();
CriteriaQuery
<
PrintedCard
>
cq
=
cb
.
createQuery
(
PrintedCard
.
class
);
Root
<
PrintedCard
>
root
=
cq
.
from
(
PrintedCard
.
class
);
cq
.
where
(
cb
.
equal
(
root
.
get
(
PrintedCard_
.
rfidUid
),
uid
));
cq
.
orderBy
(
cb
.
desc
(
root
.
get
(
PrintedCard_
.
printTime
)));
TypedQuery
<
PrintedCard
>
q
=
getEm
().
createQuery
(
cq
);
q
.
setMaxResults
(
1
);
return
getSingleNullableResult
(
q
);
}
}
code/MoyaDatabase/src/fi/codecrew/moya/model/Tournament.java
View file @
2cd8a85
package
fi
.
codecrew
.
moya
.
model
;
import
fi.codecrew.moya.enums.TournamentStatus
;
import
fi.codecrew.moya.enums.TournamentType
;
import
fi.codecrew.moya.model.GenericEntity
;
import
java.io.Serializable
;
...
...
@@ -24,23 +25,43 @@ public class Tournament extends GenericEntity implements Serializable {
@Column
(
name
=
"talyn_tournament_id"
,
nullable
=
true
)
private
Integer
talynTournamentId
;
@Column
(
name
=
"event_id"
,
nullable
=
false
)
private
LanEvent
lanEvent
;
@Column
(
name
=
"tournament_name"
)
private
String
tournamentName
;
@Column
(
name
=
"registration_opens_at"
)
@Temporal
(
TemporalType
.
TIMESTAMP
)
private
Date
registrationOpensAt
;
@Column
(
name
=
"registration_closes_at"
)
@Temporal
(
TemporalType
.
TIMESTAMP
)
private
Date
registrationClosesAt
;
@Column
(
name
=
"begins_at"
)
@Temporal
(
TemporalType
.
TIMESTAMP
)
private
Date
beginsAt
;
@Column
(
name
=
"tournament_type"
)
@Enumerated
(
EnumType
.
STRING
)
private
TournamentType
tournamentType
;
@Column
(
name
=
"tournament_status"
)
@Enumerated
(
EnumType
.
STRING
)
private
TournamentStatus
tournamentStatus
;
@JoinColumn
(
name
=
"tournament_root"
)
private
Match
tournamentRoot
;
private
TournamentMatch
tournamentRoot
;
@Column
(
name
=
"players_per_match"
)
private
Integer
playersPerMatch
;
@Column
(
name
=
"players_per_team"
)
private
Integer
playersPerTeam
;
@OneToMany
@OneToMany
@OrderBy
(
"id ASC"
)
private
List
<
Tournament
>
subTournaments
;
public
Tournament
()
{
super
();
}
...
...
code/MoyaDatabase/src/fi/codecrew/moya/model/TournamentGame.java
0 → 100644
View file @
2cd8a85
package
fi
.
codecrew
.
moya
.
model
;
import
static
javax
.
persistence
.
FetchType
.
LAZY
;
import
fi.codecrew.moya.enums.TournamentType
;
import
fi.codecrew.moya.model.GenericEntity
;
import
java.io.Serializable
;
import
java.util.Date
;
import
java.util.List
;
import
javax.persistence.*
;
import
org.eclipse.persistence.annotations.OptimisticLocking
;
import
org.eclipse.persistence.annotations.OptimisticLockingType
;
/**
* Entity implementation class for Entity: Tournament
*
*/
@Entity
@Table
(
name
=
"tournament_games"
)
@OptimisticLocking
(
type
=
OptimisticLockingType
.
CHANGED_COLUMNS
)
public
class
TournamentGame
extends
GenericEntity
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
@Column
(
name
=
"name"
)
private
String
name
;
@Column
(
name
=
"description"
)
private
String
description
;
@Lob
@Column
(
name
=
"game_image"
)
@Basic
(
fetch
=
LAZY
)
private
byte
[]
gameImage
;
@Column
(
name
=
"expected_single_game_duration"
)
private
Integer
expectedSingleGameDuration
;
@Column
(
name
=
"event_id"
,
nullable
=
false
)
private
LanEvent
lanEvent
;
@OneToMany
private
List
<
TournamentRule
>
availableRules
;
public
TournamentGame
()
{
super
();
}
public
String
getName
()
{
return
name
;
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
public
List
<
TournamentRule
>
getAvailableRules
()
{
return
availableRules
;
}
public
void
setAvailableRules
(
List
<
TournamentRule
>
availableRules
)
{
this
.
availableRules
=
availableRules
;
}
}
code/MoyaDatabase/src/fi/codecrew/moya/model/Match.java
→
code/MoyaDatabase/src/fi/codecrew/moya/model/
Tournament
Match.java
View file @
2cd8a85
package
fi
.
codecrew
.
moya
.
model
;
import
fi.codecrew.moya.enums.MatchStatus
;
import
fi.codecrew.moya.model.GenericEntity
;
import
java.io.Serializable
;
import
java.util.Date
;
import
java.util.List
;
import
javax.persistence.*
;
...
...
@@ -16,22 +18,60 @@ import org.eclipse.persistence.annotations.OptimisticLockingType;
@Entity
@Table
(
name
=
"matches"
)
@OptimisticLocking
(
type
=
OptimisticLockingType
.
CHANGED_COLUMNS
)
public
class
Match
extends
GenericEntity
implements
Serializable
{
public
class
Tournament
Match
extends
GenericEntity
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
@OneToMany
private
List
<
Match
>
sourceMatches
;
private
List
<
Tournament
Match
>
sourceMatches
;
@ManyToMany
private
List
<
TournamentParticipant
>
matchParticipants
;
@Column
(
name
=
"play_count_max"
)
private
Integer
playCountMax
=
1
;
@Column
(
name
=
"play_count"
)
private
Integer
playCount
;
@Column
(
name
=
"match_status"
)
@Enumerated
(
EnumType
.
STRING
)
private
MatchStatus
matchStatus
;
@Temporal
(
TemporalType
.
TIMESTAMP
)
private
Date
startTime
;
@Temporal
(
TemporalType
.
TIMESTAMP
)
private
Date
endTime
;
@OneToMany
@OrderBy
(
"ranking"
)
private
List
<
MatchResult
>
matchResults
;
private
List
<
Tournament
MatchResult
>
matchResults
;
public
Match
()
{
public
Tournament
Match
()
{
super
();
}
public
List
<
TournamentMatch
>
getSourceMatches
()
{
return
sourceMatches
;
}
public
void
setSourceMatches
(
List
<
TournamentMatch
>
sourceMatches
)
{
this
.
sourceMatches
=
sourceMatches
;
}
public
List
<
TournamentParticipant
>
getMatchParticipants
()
{
return
matchParticipants
;
}
public
void
setMatchParticipants
(
List
<
TournamentParticipant
>
matchParticipants
)
{
this
.
matchParticipants
=
matchParticipants
;
}
public
List
<
TournamentMatchResult
>
getMatchResults
()
{
return
matchResults
;
}
public
void
setMatchResults
(
List
<
TournamentMatchResult
>
matchResults
)
{
this
.
matchResults
=
matchResults
;
}
}
code/MoyaDatabase/src/fi/codecrew/moya/model/MatchResult.java
→
code/MoyaDatabase/src/fi/codecrew/moya/model/
Tournament
MatchResult.java
View file @
2cd8a85
...
...
@@ -13,7 +13,7 @@ import org.eclipse.persistence.annotations.OptimisticLockingType;
@Entity
@Table
(
name
=
"match_results"
)
@OptimisticLocking
(
type
=
OptimisticLockingType
.
CHANGED_COLUMNS
)
public
class
MatchResult
extends
GenericEntity
implements
Serializable
{
public
class
Tournament
MatchResult
extends
GenericEntity
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
@Column
(
name
=
"score"
)
...
...
@@ -25,7 +25,33 @@ public class MatchResult extends GenericEntity implements Serializable {
@JoinColumn
(
name
=
"tournament_participant"
)
private
TournamentParticipant
tournamentParticipant
;
public
MatchResult
()
{
public
Tournament
MatchResult
()
{
super
();
}
public
Integer
getScore
()
{
return
score
;
}
public
void
setScore
(
Integer
score
)
{
this
.
score
=
score
;
}
public
Integer
getRank
()
{
return
rank
;
}
public
void
setRank
(
Integer
rank
)
{
this
.
rank
=
rank
;
}
public
TournamentParticipant
getTournamentParticipant
()
{
return
tournamentParticipant
;
}
public
void
setTournamentParticipant
(
TournamentParticipant
tournamentParticipant
)
{
this
.
tournamentParticipant
=
tournamentParticipant
;
}
}
code/MoyaDatabase/src/fi/codecrew/moya/model/TournamentRule.java
0 → 100644
View file @
2cd8a85
package
fi
.
codecrew
.
moya
.
model
;
import
static
javax
.
persistence
.
FetchType
.
LAZY
;
import
fi.codecrew.moya.enums.TournamentType
;
import
fi.codecrew.moya.model.GenericEntity
;
import
java.io.Serializable
;
import
java.util.Date
;
import
java.util.List
;
import
javax.persistence.*
;
import
org.eclipse.persistence.annotations.OptimisticLocking
;
import
org.eclipse.persistence.annotations.OptimisticLockingType
;
/**
* Entity implementation class for Entity: Tournament
*
*/
@Entity
@Table
(
name
=
"tournament_rules"
)
@OptimisticLocking
(
type
=
OptimisticLockingType
.
CHANGED_COLUMNS
)
public
class
TournamentRule
extends
GenericEntity
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
@Column
(
name
=
"name"
)
private
String
name
;
@Lob
@Column
(
name
=
"description"
)
private
String
description
;
@Lob
@Column
(
name
=
"rules"
)
private
String
rules
;
@ManyToOne
@JoinColumn
(
name
=
"tournament_game_id"
)
private
TournamentGame
tournamentGame
;
public
TournamentRule
()
{
super
();
}
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
;
}
public
String
getRules
()
{
return
rules
;
}
public
void
setRules
(
String
rules
)
{
this
.
rules
=
rules
;
}
}
code/MoyaUtilities/src/fi/codecrew/moya/enums/MatchStatus.java
0 → 100644
View file @
2cd8a85
package
fi
.
codecrew
.
moya
.
enums
;
public
enum
MatchStatus
{
UNFINISHED
,
FINISHED
}
code/MoyaUtilities/src/fi/codecrew/moya/enums/TournamentStatus.java
0 → 100644
View file @
2cd8a85
package
fi
.
codecrew
.
moya
.
enums
;
public
enum
TournamentStatus
{
SETUP
,
IN_PROGRESS
,
COMPLETED
}
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