Commit f7709320 by Tuukka Kivilahti

Merge remote-tracking branch 'origin' into kioskifixi

2 parents 70890659 8a452fa5
......@@ -8,3 +8,4 @@
.metadata
/code/*/target/
/code/*/test-output/
moya-git.properties
......@@ -2,7 +2,6 @@ package fi.codecrew.moya.beans;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import javax.annotation.security.DeclareRoles;
......@@ -10,13 +9,10 @@ import javax.annotation.security.RolesAllowed;
import javax.ejb.EJB;
import javax.ejb.Stateless;
import fi.codecrew.moya.facade.ActionLogFacade;
import fi.codecrew.moya.facade.ActionLogMessageTagFacade;
import fi.codecrew.moya.beans.ActionLogBeanLocal;
import fi.codecrew.moya.beans.PermissionBeanLocal;
import fi.codecrew.moya.beans.RoleBeanLocal;
import fi.codecrew.moya.enums.ActionLogMessageState;
import fi.codecrew.moya.enums.apps.ContentPermission;
import fi.codecrew.moya.facade.ActionLogFacade;
import fi.codecrew.moya.facade.ActionLogMessageTagFacade;
import fi.codecrew.moya.model.ActionLogMessage;
import fi.codecrew.moya.model.ActionLogMessageResponse;
import fi.codecrew.moya.model.ActionLogMessageTag;
......@@ -79,7 +75,7 @@ public class ActionLogBean implements ActionLogBeanLocal {
@Override
@RolesAllowed(ContentPermission.S_MANAGE_ACTIONLOG)
public List<ActionLogMessage> getAllActionLogEventsByFilter(List<ActionLogMessageTag> filterTags) {
if(filterTags.size() == 0)
if (filterTags.size() == 0)
return actionLogFacade.getAllSortedByTimestamp(permissionBean.getCurrentUser().getEvent());
else
return actionLogFacade.getAllSortedByTimestampFiltered(permissionBean.getCurrentUser().getEvent(), filterTags);
......@@ -92,7 +88,8 @@ public class ActionLogBean implements ActionLogBeanLocal {
@RolesAllowed(ContentPermission.S_MANAGE_ACTIONLOG)
public List<ActionLogMessageResponse> getActionLogMessageResponses(ActionLogMessage alm) {
if(!alm.getLanEvent().equals(permissionBean.getCurrentUser().getEvent())) return null;
if (!alm.getLanEvent().equals(permissionBean.getCurrentUser().getEvent()))
return null;
return actionLogFacade.getActionLogMessageResponses(alm);
}
......@@ -104,7 +101,8 @@ public class ActionLogBean implements ActionLogBeanLocal {
@RolesAllowed(ContentPermission.S_MANAGE_ACTIONLOG)
public void addActionLogMessageResponse(ActionLogMessage alm, String message, ActionLogMessageState state) {
if(!alm.getLanEvent().equals(permissionBean.getCurrentUser().getEvent())) return;
if (!alm.getLanEvent().equals(permissionBean.getCurrentUser().getEvent()))
return;
if (alm.getState() != state && state != null) {
alm = actionLogFacade.merge(alm);
......@@ -124,8 +122,10 @@ public class ActionLogBean implements ActionLogBeanLocal {
@RolesAllowed(ContentPermission.S_MANAGE_ACTIONLOG)
public ActionLogMessage find(Integer id) {
ActionLogMessage alm = actionLogFacade.find(id);
if(!alm.getLanEvent().equals(permissionBean.getCurrentUser().getEvent())) return null;
else return alm;
if (!alm.getLanEvent().equals(permissionBean.getCurrentUser().getEvent()))
return null;
else
return alm;
}
private ArrayList<ActionLogMessageTag> resolveTags(String message) {
......@@ -134,14 +134,14 @@ public class ActionLogBean implements ActionLogBeanLocal {
boolean rflag = false;
char ch;
for(int i=0; i < message.length(); i++) {
if(rflag) {
if((ch = message.charAt(i)) != ' ') {
for (int i = 0; i < message.length(); i++) {
if (rflag) {
if ((ch = message.charAt(i)) != ' ') {
sb.append(ch);
} else {
if(sb.length() > 0) {
if (sb.length() > 0) {
ActionLogMessageTag almt = getActionLogMessageTagByString(sb.toString());
if(!almts.contains(almt)) {
if (!almts.contains(almt)) {
almts.add(almt);
}
}
......@@ -149,17 +149,17 @@ public class ActionLogBean implements ActionLogBeanLocal {
rflag = false;
sb = null;
}
} else if(!rflag) {
if(message.charAt(i) == '#') {
rflag=true;
sb=new StringBuilder();
} else if (!rflag) {
if (message.charAt(i) == '#') {
rflag = true;
sb = new StringBuilder();
}
}
}
if(sb != null && sb.length() > 0) {
if (sb != null && sb.length() > 0) {
ActionLogMessageTag almt = getActionLogMessageTagByString(sb.toString());
if(!almts.contains(almt)) {
if (!almts.contains(almt)) {
almts.add(almt);
}
}
......@@ -173,18 +173,17 @@ public class ActionLogBean implements ActionLogBeanLocal {
s = s.toLowerCase();
ActionLogMessageTag almt = null;
if((almt = actionLogMessageTagFacade.findByTagStringInEvent(s, eventBean.getCurrentEvent())) == null) {
if ((almt = actionLogMessageTagFacade.findByTagStringInEvent(s, eventBean.getCurrentEvent())) == null) {
almt = new ActionLogMessageTag();
almt.setEvent(eventBean.getCurrentEvent());
almt.setTag(s);
almt = actionLogMessageTagFacade.create(almt);
System.out.println("creating tag: "+s);
actionLogMessageTagFacade.create(almt);
System.out.println("creating tag: " + s);
return almt;
} else {
System.out.println("re-using tag: "+s);
System.out.println("re-using tag: " + s);
return almt;
}
}
}
\ No newline at end of file
......@@ -274,18 +274,20 @@ public class CardTemplateBean implements CardTemplateBeanLocal {
@Override
public CardTextData save(CardTextData textData) {
if (textData.getId() != null && textData.getId() != 0)
return ctdFacade.merge(textData);
textData = ctdFacade.merge(textData);
else
return ctdFacade.create(textData);
ctdFacade.create(textData);
return textData;
}
@RolesAllowed(UserPermission.S_WRITE_ROLES)
@Override
public CardObjectData save(CardObjectData objectData) {
if (objectData.getId() != null && objectData.getId() != 0)
return codFacade.merge(objectData);
objectData = codFacade.merge(objectData);
else
return codFacade.create(objectData);
codFacade.create(objectData);
return objectData;
}
@Override
......@@ -375,12 +377,11 @@ public class CardTemplateBean implements CardTemplateBeanLocal {
card.setCardState(CardState.DELIVERED);
} else {
logger.info("Not marking card to delivered: " + card.getCardState() + " : " + card.getId());
}
}
if (markUserPlacesDelivered) {
for (GroupMembership membership : gmFacade.findMemberships(user)) {
membership.setEnteredEvent(Calendar.getInstance());
gmFacade.merge(membership);
}
}
......@@ -389,12 +390,13 @@ public class CardTemplateBean implements CardTemplateBeanLocal {
@Override
public void removeCardCode(CardCode code) {
code = cardCodeFacade.merge(code);
code = cardCodeFacade.reload(code);
if(code.getPrintedCard().getCardCodes().contains(code)) {
code.getPrintedCard().getCardCodes().remove(code);
cardCodeFacade.remove(code);
}
cardCodeFacade.remove(code);
}
......
......@@ -35,6 +35,9 @@ import fi.codecrew.moya.model.MenuNavigation;
/**
*
* HUOM! JOS POISTAT SIVUN, PITÄÄ VIITTAUS POISTAA MYÖS KANNASTA! MUUTEN
* GALAKSIT RÄJÄHTÄÄ! (jsf ei löydä viittausta sivuun ja heittää poikkeuksen)
*
* Kaikki sivut pitää olla jossain menussa, muuten menu häviää näkyvistä ko.
* sivulla kokonaan. Älä siis poista sivua vaaan aseta sivu näkymättömäksi:
* .setVisible(false).
......@@ -154,7 +157,6 @@ public class MenuBean implements MenuBeanLocal {
MenuNavigation createuser = usermenu.addPage(null, null);
createuser.setKey("topnavi.createuser");
createuser.addPage(menuitemfacade.findOrCreate("/user/create"), UserPermission.CREATE_NEW).setVisible(false);
;
navifacade.create(usermenu);
......@@ -168,7 +170,8 @@ public class MenuBean implements MenuBeanLocal {
MenuNavigation adminuser = adminmenu.addPage(null, null);
adminuser.setKey("topnavi.usermgmt");
adminuser.addPage(menuitemfacade.findOrCreate("/useradmin/list"), UserPermission.VIEW_ALL);
adminuser.addPage(menuitemfacade.findOrCreate("/useradmin/overview"), UserPermission.VIEW_ALL).setVisible(false);;
adminuser.addPage(menuitemfacade.findOrCreate("/useradmin/overview"), UserPermission.VIEW_ALL).setVisible(false);
adminuser.addPage(menuitemfacade.findOrCreate("/useradmin/create"), UserPermission.VIEW_ALL);
adminuser.addPage(menuitemfacade.findOrCreate("/useradmin/sendPicture"), UserPermission.VIEW_ALL).setVisible(false);
adminuser.addPage(menuitemfacade.findOrCreate("/place/adminGroups"), UserPermission.VIEW_ALL).setVisible(false);
......
......@@ -164,7 +164,7 @@ public class ReaderBean implements ReaderBeanLocal {
}
}
event = readerEventFacade.create(event);
readerEventFacade.create(event);
return event;
......@@ -173,13 +173,9 @@ public class ReaderBean implements ReaderBeanLocal {
@Override
public ReaderEvent assocCodeToCard(ReaderEvent readerEvent, PrintedCard card) {
card = cardfacade.reload(card);
CardCode code = new CardCode(card, readerEvent.getReader().getType(), readerEvent.getValue(), eventbean.getCurrentEvent());
CardCode code = new CardCode(card, readerEvent.getReader().getType(), readerEvent.getValue());
code = cardCodeFacade.create(code);
card.getCardCodes().add(code);
card = cardfacade.merge(card);
cardCodeFacade.create(code);
return readerEvent;
}
......
......@@ -70,13 +70,15 @@ public class TournamentBean implements TournamentBeanLocal {
@Override
@RolesAllowed(TournamentPermission.S_MANAGE_ALL)
public TournamentGame createGame(TournamentGame tg) {
return tournamentGameFacade.create(tg);
tournamentGameFacade.create(tg);
return tg;
}
@Override
@RolesAllowed(TournamentPermission.S_MANAGE_ALL)
public TournamentRule createRule(TournamentRule tr) {
return tournamentRuleFacade.create(tr);
tournamentRuleFacade.create(tr);
return tr;
}
@Override
......@@ -105,7 +107,7 @@ public class TournamentBean implements TournamentBeanLocal {
@RolesAllowed(TournamentPermission.S_MANAGE_ALL)
public void updateTournamentRules(TournamentRule tr) throws Exception {
// Assert correct event
if(eventBean.getCurrentEvent().equals(tr.getTournamentGame().getLanEvent())) {
if (eventBean.getCurrentEvent().equals(tr.getTournamentGame().getLanEvent())) {
tournamentRuleFacade.merge(tr);
} else {
throw new Exception("tournament.invalid_event");
......@@ -115,8 +117,8 @@ public class TournamentBean implements TournamentBeanLocal {
@Override
@RolesAllowed(TournamentPermission.S_VIEW)
public List<Tournament> getTournamentsInStatus(TournamentStatus status, boolean useTimeConstraints, boolean invertMatch) {
if(useTimeConstraints)
if(!invertMatch)
if (useTimeConstraints)
if (!invertMatch)
return tournamentFacade.getTournamentsInStatusWithParticipationTimeIn(status, eventBean.getCurrentEvent());
else
return tournamentFacade.getTournamentsInStatusWithParticipationTimeNotIn(status, eventBean.getCurrentEvent());
......@@ -170,7 +172,7 @@ public class TournamentBean implements TournamentBeanLocal {
// Assert team has the correct number of players for a match
if (tournamentParticipant.getTeamMembers().size() >= tournamentParticipant.getTournament().getPlayersPerMatch()) {
tournamentParticipant = tournamentParticipantFacade.create(tournamentParticipant);
tournamentParticipantFacade.create(tournamentParticipant);
t.getParticipants().add(tournamentParticipant);
} else {
throw new Exception("tournament.not_enough_players");
......@@ -233,18 +235,18 @@ public class TournamentBean implements TournamentBeanLocal {
// Assert we have permission to remove participant
// TODO: this will include check for remove any participation too!
if(!permissionBean.hasPermission(TournamentPermission.REMOVE_OWN_PARTICIPATION) || !tp.getParticipator().equals(executor)) {
if (!permissionBean.hasPermission(TournamentPermission.REMOVE_OWN_PARTICIPATION) || !tp.getParticipator().equals(executor)) {
throw new Exception("tournaments.can_only_remove_own_participations");
}
// Assert that tournament has not closed participation
// TODO: admin exception!
if(!tp.getTournament().getRegistrationClosesAt().after(new Date())) {
if (!tp.getTournament().getRegistrationClosesAt().after(new Date())) {
throw new Exception("tournaments.cannot_remove_participation_from_closed_tournament");
}
// All ok, do nukage
for(TournamentTeamMember ttm : tp.getTeamMembers()) {
for (TournamentTeamMember ttm : tp.getTeamMembers()) {
tournamentTeamMemberFacade.remove(ttm);
}
......
......@@ -339,10 +339,10 @@ public class UserBean implements UserBeanLocal {
int sourceCenterY = sourceHeight / 2;
int sourceTop, sourceLeft, sourceRight, sourceBottom;
double sourceRatio = (double)sourceWidth / (double)sourceHeight;
double sourceRatio = (double) sourceWidth / (double) sourceHeight;
if (sourceRatio > targetRatio) {
// the pic is too wide - reduce width
targetWidth = (int)((double)sourceHeight * targetRatio);
targetWidth = (int) ((double) sourceHeight * targetRatio);
targetHeight = sourceHeight;
// crop box coords - calculate left and right
......@@ -353,7 +353,7 @@ public class UserBean implements UserBeanLocal {
} else {
// the pic is too tall - reduce height
targetWidth = sourceWidth;
targetHeight = (int)((double)sourceWidth / targetRatio);
targetHeight = (int) ((double) sourceWidth / targetRatio);
// crop box coords - calculate top and bottom
sourceLeft = 0;
......@@ -478,27 +478,27 @@ public class UserBean implements UserBeanLocal {
public PrintedCard rejectPrintedCard(PrintedCard card, MailMessage mail) {
if(card != null) {
if (card != null) {
card.setCardState(CardState.REJECTED);
card = printedcardfacade.merge(card);
logger.info("rejectPrintedCard(): Rejected card {}, state {}", card, card.getCardState() );
logger.info("rejectPrintedCard(): Rejected card {}, state {}", card, card.getCardState());
User user = null;
if(card.getUser() != null && card.getUser().getUser() != null)
if (card.getUser() != null && card.getUser().getUser() != null)
user = card.getUser().getUser();
LanEvent event = card.getEvent();
if(mail != null) {
if(!utilbean.sendMail(mail)) {
if (mail != null) {
if (!utilbean.sendMail(mail)) {
logger.info("Sending mail failed");
} else
logger.info("Sending mail succeeded");
} else {
if(user == null)
if (user == null)
logger.info("user is null");
if(event == null)
if (event == null)
logger.info("event is null");
}
}
......@@ -663,7 +663,7 @@ public class UserBean implements UserBeanLocal {
gid.setGame(game);
gid.setUser(u);
gid = gameIDFacade.create(gid);
gameIDFacade.create(gid);
u.getGameIDs().add(gid);
}
......@@ -952,14 +952,15 @@ public class UserBean implements UserBeanLocal {
String hex = Integer.toHexString(user.getId());
logger.info("Hex code {} for id {}", hex, user.getId());
//padding hex string to 5 characters by adding Xs to the beginning
if(hex.length() < 5) {
// padding hex string to 5 characters by adding Xs to the beginning
if (hex.length() < 5) {
logger.info("Padding hex ({}) with X.", hex.length());
for(int i = 0; i < 5; i++) {
if(hex.length() < 5) {
for (int i = 0; i < 5; i++) {
if (hex.length() < 5) {
hex = "X" + hex;
}
else break;
else
break;
}
} else
logger.info("Hex string too long ({}), no padding needed", hex.length());
......@@ -971,16 +972,17 @@ public class UserBean implements UserBeanLocal {
byte[] array = md.digest(hex.getBytes());
hash = new String(Hex.encodeHex(array));
logger.info("Hash {}", hash);
}catch(NoSuchAlgorithmException ex) {
} catch (NoSuchAlgorithmException ex) {
logger.info("Catched exeption {}", ex.getMessage());
}
if(hash != "" && hash.length() > 2) {
//Generating code by concatenating hex string and first 3 characters from hash
if (hash != "" && hash.length() > 2) {
// Generating code by concatenating hex string and first 3
// characters from hash
code = code.concat(hex);
code = code.concat(hash.substring(0, 3));
logger.info("Code for user is {}", code);
}else
} else
logger.info("No code generated: hash.length() {}", hash.length());
return code.toUpperCase();
......@@ -992,7 +994,7 @@ public class UserBean implements UserBeanLocal {
logger.info("getUser({})", authcode);
EventUser user = null;
if(authcode.length() == 8) {
if (authcode.length() == 8) {
logger.info("authcode length is 8");
// First 5 characters are the hex
String paddedHex = authcode.substring(0, 5);
......@@ -1004,28 +1006,28 @@ public class UserBean implements UserBeanLocal {
int id = 0;
try {
id = Integer.decode("0x"+ hex.toLowerCase());
}catch(NumberFormatException ex) {
id = Integer.decode("0x" + hex.toLowerCase());
} catch (NumberFormatException ex) {
logger.info("NumberFormatException was thrown");
}
logger.info("Id {}", id);
if(id != 0) {
if (id != 0) {
user = eventUserFacade.find(id);
}
if(user != null) {
if (user != null) {
// Testing if the user is correct
logger.info("User {} found with id {}", user, id);
String testCode = getAuthCode(user);
logger.info("Testcode {}", testCode);
if(testCode == null || testCode.equals("") || !authcode.equals(testCode)) {
if (testCode == null || testCode.equals("") || !authcode.equals(testCode)) {
user = null;
logger.info("User set to null, test code not the same as user that was found.");
}
} else
logger.info("User not found with id {}", id);
}else
} else
logger.info("authcode length not 8!, length {}", authcode.length());
return user;
......
......@@ -134,7 +134,7 @@ public class PlaceFacade extends IntegerPkGenericFacade<Place> {
CriteriaQuery<Place> cq = cb.createQuery(Place.class);
Root<Place> root = cq.from(Place.class);
cq.where( cb.equal(root.get(Place_.map).get(EventMap_.event), eventBean.getCurrentEvent()));
//cq.orderBy(cb.asc(root.get(Place_.name)));
cq.orderBy(cb.asc(root.get(Place_.name)));
return getEm().createQuery(cq).getResultList();
}
}
......
......@@ -89,12 +89,6 @@ public class UserFacade extends IntegerPkGenericFacade<User> {
// }
@Override
public User create(User user) {
user.setLogin(user.getLogin().toLowerCase().trim());
return super.create(user);
}
@Override
public User merge(User user) {
user.setLogin(user.getLogin().toLowerCase().trim());
return super.merge(user);
......
......@@ -8,6 +8,28 @@
<plugins>
<plugin>
<groupId>pl.project13.maven</groupId>
<artifactId>git-commit-id-plugin</artifactId>
<version>2.1.10</version>
<executions>
<execution>
<goals>
<goal>revision</goal>
</goals>
</execution>
</executions>
<configuration>
<!-- this is false by default, forces the plugin to generate the git.properties
file -->
<generateGitPropertiesFile>true</generateGitPropertiesFile>
<!-- The path for the to be generated properties file, it's relative
to ${project.basedir} -->
<generateGitPropertiesFilename>src/main/java/moya-git.properties</generateGitPropertiesFilename>
<dotGitDirectory>${project.basedir}/../../.git</dotGitDirectory>
</configuration>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
......
package fi.codecrew.moya.utilities;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
public class GitRepositoryState {
private static GitRepositoryState gitRepositoryState;
public static GitRepositoryState getGitRepositoryState() throws IOException
{
if (gitRepositoryState == null) {
gitRepositoryState = new GitRepositoryState();
}
return gitRepositoryState;
}
private final String branch;
private final String describe;
private final String describeShort;
private final String commitId;
private final String buildUserName;
private final String buildUserEmail;
private final String buildTime;
private final String commitUserName;
private final String commitUserEmail;
private final String commitMessageShort;
private final String commitMessageFull;
private final String commitTime;
private GitRepositoryState() throws IOException
{
InputStream resource = getClass().getClassLoader().getResourceAsStream("moya-git.properties");
if (resource == null)
{
throw new IOException("ResourceFile not found");
}
Properties properties = new Properties();
properties.load(resource);
this.branch = properties.get("git.branch").toString();
this.describe = properties.get("git.commit.id.describe").toString();
this.describeShort = properties.get("git.commit.id.describe-short").toString();
this.commitId = properties.get("git.commit.id").toString();
this.buildUserName = properties.get("git.build.user.name").toString();
this.buildUserEmail = properties.get("git.build.user.email").toString();
this.buildTime = properties.get("git.build.time").toString();
this.commitUserName = properties.get("git.commit.user.name").toString();
this.commitUserEmail = properties.get("git.commit.user.email").toString();
this.commitMessageShort = properties.get("git.commit.message.short").toString();
this.commitMessageFull = properties.get("git.commit.message.full").toString();
this.commitTime = properties.get("git.commit.time").toString();
}
public String getBranch() {
return branch;
}
public String getDescribe() {
return describe;
}
public String getDescribeShort() {
return describeShort;
}
public String getCommitId() {
return commitId;
}
public String getBuildUserName() {
return buildUserName;
}
public String getBuildUserEmail() {
return buildUserEmail;
}
public String getBuildTime() {
return buildTime;
}
public String getCommitUserName() {
return commitUserName;
}
public String getCommitUserEmail() {
return commitUserEmail;
}
public String getCommitMessageShort() {
return commitMessageShort;
}
public String getCommitMessageFull() {
return commitMessageFull;
}
public String getCommitTime() {
return commitTime;
}
}
......@@ -38,10 +38,19 @@ public abstract class GenericFacade<C extends ModelInterface> {
protected abstract EntityManager getEm();
public C create(C entity) {
/*
* This function does not need to return the persisted entity. All changes are made to the parameter.
*
*/
/**
* Persists the entity into database. After calling this function the entity
* is attached and all changes are persisted to database
*
* @param entity
* Entity to be created and attached to database.
*/
public void create(C entity) {
getEm().persist(entity);
return entity;
}
public void remove(C entity) {
......@@ -49,11 +58,28 @@ public abstract class GenericFacade<C extends ModelInterface> {
getEm().remove(entity);
}
/**
* Merge changes from a detached entity to the database.
*
* This function does nothing if entity is already attached.
*
* @param entity
* Detached entity to be merged into database
* @return Attached entity with changes merged
*/
public C merge(C entity) {
return getEm().merge(entity);
}
/**
* Refresh the state of the instance from the database, overwriting changes
* made to the entity, if any.
*
* ENTITY MUST BE ATTACHED!
*
* @param entity
*/
public void refresh(C entity) {
getEm().refresh(entity);
}
......@@ -282,14 +308,31 @@ public abstract class GenericFacade<C extends ModelInterface> {
// return q.getResultList();
// }
/**
* Synchronize the persistence context to the underlying database.
*
* This gives to newly created entities ID, etc.
*/
public void flush() {
getEm().flush();
}
/**
* Remove the given entity from cache.
*
* @param entity
*/
public void evict(C entity) {
getEm().getEntityManagerFactory().getCache().evict(getEntityClass(), entity.getId());
}
/**
* Tells wether the entity is attached to this transaction. ie. Changes to
* this object are automatically propagated to the database
*
* @param entity
* @return
*/
public boolean isAttached(ModelInterface entity) {
return getEm().contains(entity);
}
......
......@@ -18,68 +18,44 @@
<compo:editCompo commitAction="#{compoMgmtView.saveCompo}" commitValue="#{i18n['voting.create.saveCompo']}" />
<h2>#{i18n['compoMgmtView.compo.entries']}</h2>
<h2>#{i18n['compoMgmtView.compo.entries']}</h2>
<h:form>
<h:dataTable styleClass="bordertable" rowClasses="roweven,rowodd" id="compolisttable" value="#{compoMgmtView.entries}" var="entry">
<h:column>
<f:facet name="header">
<h:outputText value="Title" />
</f:facet>
<p:dataTable styleClass="bordertable" rowClasses="roweven,rowodd" id="compolisttable" value="#{compoMgmtView.entries}" var="entry">
<p:column headerText="Title">
<h:outputText value="#{entry.title}" />
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="Author" />
</f:facet>
</p:column>
<p:column headerText="Author">
<h:outputText value="#{entry.author}" />
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="notes" />
</f:facet>
</p:column>
<p:column headerText="Notes">
<h:outputText value="#{entry.notes}" />
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="screenmessage" />
</f:facet>
</p:column>
<p:column headerText="Screenmessage">
<h:outputText value="#{entry.screenMessage}" />
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="creator" />
</f:facet>
</p:column>
<p:column headerText="creator">
<h:link outcome="/useradmin/edit" value="#{entry.creator.user.nick}">
<f:param name="userid" value="#{entry.creator.user.id}" />
</h:link>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="sort" />
</f:facet>
</p:column>
<p:column headerText="Sort">
<h:inputText value="#{entry.sort}" size="4" />
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="Vote total" />
</f:facet>
</p:column>
<p:column headerText="Vote total">
<h:outputText value="#{entry.votetotal}" />
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="Vote count" />
</f:facet>
</p:column>
<p:column headerText="Vote count">
<h:outputText value="#{entry.votes.size()}" />
</h:column>
</p:column>
<h:column>
<p:column>
<h:link outcome="/voting/submitEntry" value="#{i18n['entry.edit']}">
<f:param name="entryId" value="#{entry.id}" />
</h:link>
</h:column>
</p:column>
</h:dataTable>
</p:dataTable>
<h:commandButton action="#{compoMgmtView.saveSort}" value="#{i18n['compo.savesort']}" />
</h:form>
......
package fi.codecrew.moya.web.flow;
import javax.enterprise.context.SessionScoped;
import javax.inject.Named;
import fi.codecrew.moya.web.cdiview.GenericCDIView;
/**
* Place to store userid between pageloads
* @author tuukka
*
*/
@Named
@SessionScoped
public class FlowUserContainer extends GenericCDIView {
private static final long serialVersionUID = 802344850073689859L;
private Integer userId;
/**
* Get current userid, remember to clear this, so there is no weird bugs
* @return
*/
public Integer getUserId() {
return userId;
}
public void setUserId(Integer userId) {
this.userId = userId;
}
}
......@@ -57,6 +57,10 @@ public class IncomingView extends GenericCDIView {
@Inject
private ReaderNameContainer namecontainer;
@Inject
private FlowUserContainer flowUserContainer;
@EJB
private BarcodeBeanLocal barcodeBean;
......@@ -127,6 +131,14 @@ public class IncomingView extends GenericCDIView {
if (!initialized) {
logger.debug("INITIALIZING!!!!");
if(flowUserContainer.getUserId() != null && flowUserContainer.getUserId() > 0) {
userview.setUserid(flowUserContainer.getUserId());
}
flowUserContainer.setUserId(null);
// initializePoller();
initialized = true;
super.beginConversation();
......
......@@ -45,6 +45,9 @@ public class flowShopView extends GenericCDIView {
@Inject
private ReaderView readerView;
@Inject
private FlowUserContainer flowUserContainer;
public void initView() {
if(userId == null || userId == 0) {
......@@ -68,8 +71,10 @@ public class flowShopView extends GenericCDIView {
public void changeUser(SelectEvent event) {
if (infoView.getMultiSearchUser() != null) {
flowUserContainer.setUserId(infoView.getMultiSearchUser().getUser().getId());
super.navihandler.redirectNavigation("shop.jsf?userid=" + infoView.getMultiSearchUser().getUser().getId());
infoView.setMultiSearchUser(null);
}
}
......@@ -89,6 +94,7 @@ public class flowShopView extends GenericCDIView {
if (!user.equals(userView.getUser())) {
logger.info("found user {}, redirecting", user.getNick());
userView.setUser(user);
flowUserContainer.setUserId(user.getUser().getId());
super.navihandler.redirectNavigation("shop.jsf?userid=" + user.getUser().getId());
}
......
......@@ -14,10 +14,10 @@ import fi.codecrew.moya.web.cdiview.GenericCDIView;
@Named
@SessionScoped
public class fieldsetView extends GenericCDIView {
public class FieldsetView extends GenericCDIView {
private static final Logger logger = LoggerFactory.getLogger(fieldsetView.class);
private static final Logger logger = LoggerFactory.getLogger(FieldsetView.class);
private static final long serialVersionUID = 5L;
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!