Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Riina Antikainen
/
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 96f6e6d1
authored
May 11, 2013
by
Antti Tönkyrä
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Facades
1 parent
2cd8a858
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
79 additions
and
81 deletions
code/MoyaBeans/ejbModule/fi/codecrew/moya/facade/TournamentFacade.java
code/MoyaBeans/ejbModule/fi/codecrew/moya/facade/TournamentGameFacade.java
code/MoyaBeans/ejbModule/fi/codecrew/moya/facade/TournamentMatchFacade.java
code/MoyaBeans/ejbModule/fi/codecrew/moya/facade/TournamentMatchResultFacade.java
code/MoyaBeans/ejbModule/fi/codecrew/moya/facade/TournamentParticipantFacade.java
code/MoyaBeans/ejbModule/fi/codecrew/moya/facade/TournamentRuleFacade.java
code/MoyaBeans/ejbModule/fi/codecrew/moya/facade/TournamentFacade.java
View file @
96f6e6d
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
;
import
fi.codecrew.moya.model.Tournament
;
@Stateless
@LocalBean
public
class
TournamentFacade
extends
IntegerPkGenericFacade
<
PrintedCard
>
{
public
class
TournamentFacade
extends
IntegerPkGenericFacade
<
Tournament
>
{
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
);
super
(
Tournament
.
class
);
}
}
code/MoyaBeans/ejbModule/fi/codecrew/moya/facade/TournamentGameFacade.java
0 → 100644
View file @
96f6e6d
package
fi
.
codecrew
.
moya
.
facade
;
import
javax.ejb.LocalBean
;
import
javax.ejb.Stateless
;
import
fi.codecrew.moya.model.TournamentGame
;
@Stateless
@LocalBean
public
class
TournamentGameFacade
extends
IntegerPkGenericFacade
<
TournamentGame
>
{
public
TournamentGameFacade
()
{
super
(
TournamentGame
.
class
);
}
}
code/MoyaBeans/ejbModule/fi/codecrew/moya/facade/TournamentMatchFacade.java
0 → 100644
View file @
96f6e6d
package
fi
.
codecrew
.
moya
.
facade
;
import
javax.ejb.LocalBean
;
import
javax.ejb.Stateless
;
import
fi.codecrew.moya.model.TournamentMatch
;
@Stateless
@LocalBean
public
class
TournamentMatchFacade
extends
IntegerPkGenericFacade
<
TournamentMatch
>
{
public
TournamentMatchFacade
()
{
super
(
TournamentMatch
.
class
);
}
}
\ No newline at end of file
code/MoyaBeans/ejbModule/fi/codecrew/moya/facade/TournamentMatchResultFacade.java
0 → 100644
View file @
96f6e6d
package
fi
.
codecrew
.
moya
.
facade
;
import
javax.ejb.LocalBean
;
import
javax.ejb.Stateless
;
import
fi.codecrew.moya.model.TournamentMatchResult
;
@Stateless
@LocalBean
public
class
TournamentMatchResultFacade
extends
IntegerPkGenericFacade
<
TournamentMatchResult
>
{
public
TournamentMatchResultFacade
()
{
super
(
TournamentMatchResult
.
class
);
}
}
\ No newline at end of file
code/MoyaBeans/ejbModule/fi/codecrew/moya/facade/TournamentParticipantFacade.java
0 → 100644
View file @
96f6e6d
package
fi
.
codecrew
.
moya
.
facade
;
import
javax.ejb.LocalBean
;
import
javax.ejb.Stateless
;
import
fi.codecrew.moya.model.TournamentParticipant
;
@Stateless
@LocalBean
public
class
TournamentParticipantFacade
extends
IntegerPkGenericFacade
<
TournamentParticipant
>
{
public
TournamentParticipantFacade
()
{
super
(
TournamentParticipant
.
class
);
}
}
code/MoyaBeans/ejbModule/fi/codecrew/moya/facade/TournamentRuleFacade.java
0 → 100644
View file @
96f6e6d
package
fi
.
codecrew
.
moya
.
facade
;
import
javax.ejb.LocalBean
;
import
javax.ejb.Stateless
;
import
fi.codecrew.moya.model.TournamentRule
;
@Stateless
@LocalBean
public
class
TournamentRuleFacade
extends
IntegerPkGenericFacade
<
TournamentRule
>
{
public
TournamentRuleFacade
()
{
super
(
TournamentRule
.
class
);
}
}
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