Commit baf18e5a by Antti Tönkyrä

Merge branch 'master' of gitlab.codecrew.fi:codecrew/moya into networkassociation

2 parents 97900ed7 9025e382
Showing with 428 additions and 79 deletions
......@@ -244,10 +244,6 @@ public class BillBean implements BillBeanLocal {
if (prod != null && prod.getProductFlags().contains(ProductFlag.PREPAID_INSTANT_CREATE)) {
logger.debug("Creating Bill prepaidInstant product {}, {}", prod.getName(), bl.getQuantity());
if (prod.getProductFlags().contains(ProductFlag.RESERVE_PLACE_WHEN_BOUGHT)
|| prod.getProductFlags().contains(ProductFlag.CREATE_NEW_PLACE_WHEN_BOUGHT)) {
placebean.lockPlaceProduct(bill.getUser(), prod, bl.getQuantity());
}
AccountEvent ac2 = productPBean.createAccountEvent(prod, bl.getQuantity(), user, bill.getSentDate(), bl.getFoodwave());
logger.info("Created ac from product. {}, userproducts {}", ac2, user.getAccountEvents().size());
......@@ -320,8 +316,6 @@ public class BillBean implements BillBeanLocal {
@Override
public Bill addProductToBill(Bill bill, Product product, BigDecimal count, FoodWave foodwave) {
// If bill number > 0 bill has been sent and extra privileges are needed
// to modify.
// if (!iscurrent || billnr != null) {
......@@ -342,7 +336,4 @@ public class BillBean implements BillBeanLocal {
return bill;
}
}
......@@ -23,6 +23,25 @@ public class BootstrapBean implements BootstrapBeanLocal {
public BootstrapBean() {
}
/**
* Runs a "ALTER TABLE
* <table>
* <statement>" for each of tables.
*
* @param alterStatement
* e.g. "ADD meta json"
* @param tables
* table name strings
* @return1
*/
private static final String[] alterTables(String alterStatement, String... tables) {
String[] strings = new String[tables.length];
for (int i = 0; i < tables.length; i++) {
strings[i] = "ALTER TABLE \"" + tables[i] + "\" " + alterStatement;
}
return strings;
}
private static final List<String[]> dbUpdates = new ArrayList<String[]>();
static {
// {"Query1","Query2",...}
......@@ -60,7 +79,76 @@ public class BootstrapBean implements BootstrapBeanLocal {
dbUpdates.add(new String[] {
"alter table compos add hidden boolean default false not null"
});
dbUpdates.add(alterTables("ADD COLUMN meta json",
"account_events",
"actionlog_message_responses",
"actionlog_message_tags",
"actionlog_messages",
"api_application_instances",
"api_applications",
"application_permissions",
"approvals",
"bill_lines",
"bills",
"card_code",
"card_templates",
"compo_entries",
"compo_entry_files",
"compo_entry_participations",
"compo_votes",
"compos",
"discount_instances",
"discounts",
"event_domains",
"event_log",
"event_log_types",
"event_organiser",
"event_private_properties",
"event_properties",
"event_users",
"events",
"feedback",
"food_wave_templates",
"food_waves",
"game_ids",
"group_memberships",
"groups",
"inventory_events",
"licensetargets",
"licensecodes",
"locations",
"maps",
"match_results",
"matches",
"menu_navigation",
"menuitem",
"news",
"news_groups",
"org_roles",
"places",
"poll",
"poll_answer",
"poll_question",
"possible_answer",
"printed_cards",
"product_limitations",
"products",
"reader_events",
"readers",
"roles",
"sales_entity",
"salespoint",
"site_page_content",
"site_pages",
"tournament_games",
"tournament_participants",
"tournament_rules",
"tournament_team_members",
"tournaments",
"user_approvals",
"user_images",
"user_notes",
"users"));
}
@EJB
......
......@@ -122,16 +122,24 @@ public class CardTemplateBean implements CardTemplateBeanLocal {
List<PrintedCard> myCards = printedcardfacade.getCards(user);
PrintedCard biggestCard = null;
PrintedCard smallestCard = null;
// PrintedCard smallestCard = null;
for (PrintedCard card : myCards) {
logger.info("Checking card {}", card);
// logger.info("Checking card {}", card);
if (card.getEnabled()) {
if (biggestCard == null || biggestCard.getTemplate().getPower() < card.getTemplate().getPower()) {
biggestCard = card;
// The biggest card should be the only one enabled.
if (biggestCard != null) {
biggestCard.setEnabled(false);
}
if (smallestCard == null || smallestCard.getTemplate().getPower() > card.getTemplate().getPower()) {
smallestCard = card;
biggestCard = card;
biggestCard.setEnabled(true);
}
// if (smallestCard == null ||
// smallestCard.getTemplate().getPower() >
// card.getTemplate().getPower()) {
// smallestCard = card;
// }
}
}
......
......@@ -315,6 +315,10 @@ public class PlaceBean implements PlaceBeanLocal {
logger.info("Associating buyer {} to place {}", user, gm);
associatedToPlace = true;
gm.setUser(user);
if (user.getGroupMemberships() == null) {
user.setGroupMemberships(new ArrayList<GroupMembership>());
}
user.getGroupMemberships().add(gm);
}
}
......@@ -346,7 +350,9 @@ public class PlaceBean implements PlaceBeanLocal {
freePlace = new Place();
freePlace.setProduct(prod);
freePlace.setProvidesRole(prod.getProvides());
freePlace.setName("-");
placeFacade.create(freePlace);
} else if (prod.getPlaces() != null) {
for (Place p : prod.getPlaces()) {
if (!p.isTaken()) {
......@@ -359,11 +365,16 @@ public class PlaceBean implements PlaceBeanLocal {
throw new EJBException("Could find a place to be reserved....");
}
GroupMembership gm = buy(freePlace, pg);
if (!associatedToPlace)
{
logger.info("Associating buyer {} to place {}", user, gm);
associatedToPlace = true;
gm.setUser(user);
if (user.getGroupMemberships() == null) {
user.setGroupMemberships(new ArrayList<GroupMembership>());
}
user.getGroupMemberships().add(gm);
}
}
......
......@@ -14,12 +14,14 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fi.codecrew.moya.facade.AccountEventFacade;
import fi.codecrew.moya.facade.ProductFacade;
import fi.codecrew.moya.model.AccountEvent;
import fi.codecrew.moya.model.Discount;
import fi.codecrew.moya.model.DiscountInstance;
import fi.codecrew.moya.model.EventUser;
import fi.codecrew.moya.model.FoodWave;
import fi.codecrew.moya.model.Product;
import fi.codecrew.moya.model.ProductFlag;
/**
* Session Bean implementation class ProductPBean
......@@ -35,6 +37,13 @@ public class ProductPBean {
private DiscountBean discountBean;
@EJB
private AccountEventFacade accounteventfacade;
@EJB
private PlaceBean placebean;
@EJB
private ProductFacade productFacade;
private static final Logger logger = LoggerFactory
.getLogger(ProductPBean.class);
......@@ -70,9 +79,12 @@ public class ProductPBean {
BigDecimal quantity, EventUser user, Calendar date,
FoodWave foodwave) {
if (!accounteventfacade.isAttached(product)) {
product = productFacade.reload(product);
}
if (!product.getEvent().equals(user.getEvent())) {
throw new EJBException(
"Trying to create accountevent for different event in user and product");
throw new EJBException("Trying to create accountevent for different event in user and product");
}
BigDecimal unitPrice = product.getPrice().negate();
......@@ -94,12 +106,21 @@ public class ProductPBean {
foodwave.getAccountEvents().add(ret);
}
if (product.getProductFlags().contains(ProductFlag.RESERVE_PLACE_WHEN_BOUGHT)
|| product.getProductFlags().contains(ProductFlag.CREATE_NEW_PLACE_WHEN_BOUGHT)) {
placebean.lockPlaceProduct(user, product, quantity);
}
List<DiscountInstance> accEventdiscounts = ret.getDiscountInstances();
for (Discount d : discounts) {
// discountsArray.add(discInst);
// discountinstancefacade.create(discInst);
accEventdiscounts.add(new DiscountInstance(ret, d));
}
if (product.getAccountEvents() == null) {
product.setAccountEvents(new ArrayList<AccountEvent>());
}
product.getAccountEvents().add(ret);
user.addAccountevent(ret);
accounteventfacade.create(ret);
......
......@@ -192,7 +192,7 @@ public class TournamentBean implements TournamentBeanLocal {
for (TournamentParticipant tp : tournament.getParticipants()) {
for (TournamentTeamMember tm : tp.getTeamMembers()) {
EventUser eu = tm.getEventUser();
System.out.println(eu.getNick());
if (eu.equals(currentUser)) {
return true;
}
......
......@@ -190,4 +190,9 @@ public class VotingBean implements VotingBeanLocal {
compoEntryFileFacade.create(cef);
}
@Override
public List<CompoEntry> getEntriesForCurrentUser() {
EventUser user = permissionBean.getCurrentUser();
return compoEntryFacade.findUsersEntries(user);
}
}
package fi.codecrew.moya.facade;
import java.util.List;
import javax.ejb.LocalBean;
import javax.ejb.Stateless;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Root;
import fi.codecrew.moya.model.CompoEntry;
import fi.codecrew.moya.model.CompoEntry_;
import fi.codecrew.moya.model.EventUser;
@Stateless
@LocalBean
......@@ -14,4 +21,11 @@ public class CompoEntryFacade extends IntegerPkGenericFacade<CompoEntry> {
super(CompoEntry.class);
}
public List<CompoEntry> findUsersEntries(EventUser user) {
CriteriaBuilder cb = getEm().getCriteriaBuilder();
CriteriaQuery<CompoEntry> cq = cb.createQuery(CompoEntry.class);
Root<CompoEntry> root = cq.from(CompoEntry.class);
cq.where(cb.equal(root.get(CompoEntry_.creator), user));
return getEm().createQuery(cq).getResultList();
}
}
......@@ -13,7 +13,6 @@ import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import javax.persistence.criteria.Subquery;
import fi.codecrew.moya.beans.EventBeanLocal;
import fi.codecrew.moya.enums.CardState;
......@@ -37,7 +36,6 @@ public class PrintedCardFacade extends IntegerPkGenericFacade<PrintedCard> {
@EJB
private EventBeanLocal eventbean;
public PrintedCard findByCode(String code) {
CriteriaBuilder cb = getEm().getCriteriaBuilder();
......@@ -49,7 +47,7 @@ public class PrintedCardFacade extends IntegerPkGenericFacade<PrintedCard> {
CardCode cardcode = getSingleNullableResult(getEm().createQuery(cq));
return (cardcode == null)?null : cardcode.getPrintedCard();
return (cardcode == null) ? null : cardcode.getPrintedCard();
}
public List<PrintedCard> findAllEnabled(LanEvent currentEvent) {
......@@ -71,6 +69,7 @@ public class PrintedCardFacade extends IntegerPkGenericFacade<PrintedCard> {
cq.where(cb.equal(root.get(PrintedCard_.user), user),
cb.equal(root.get(PrintedCard_.event), eventbean.getCurrentEvent()));
cq.orderBy(cb.asc(root.get(PrintedCard_.template).get(CardTemplate_.power)));
return getEm().createQuery(cq).getResultList();
}
......@@ -113,7 +112,7 @@ public class PrintedCardFacade extends IntegerPkGenericFacade<PrintedCard> {
List<PrintedCard> pcl = getEm().createQuery(cq).getResultList();
HashMap<Integer, PrintedCard> pch = new HashMap<>();
for(PrintedCard pc : pcl) {
for (PrintedCard pc : pcl) {
pch.put(pc.getUser().getId(), pc);
}
......
......@@ -38,11 +38,10 @@ public class EventUserCardStateFilter implements FacadeCallback<EventUser> {
logger.debug("Requiring states {}", states);
Path<Integer> rootId = root.get(EventUser_.id);
Subquery<Integer> subq = cq.subquery(Integer.class);
Root<PrintedCard> subroot = subq.from(PrintedCard.class);
subq.select(subroot.join(PrintedCard_.user).get(EventUser_.id));
subq.where(subroot.get(PrintedCard_.cardState).in(states));
subq.where(subroot.get(PrintedCard_.cardState).in(states), cb.isTrue(subroot.get(PrintedCard_.enabled)));
predicates.add(rootId.in(subq));
}
......
......@@ -39,4 +39,6 @@ public interface VotingBeanLocal {
public void create(CompoEntryFile cef);
public List<CompoEntry> getEntriesForCurrentUser();
}
......@@ -57,5 +57,10 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>9.3-1100-jdbc41</version>
</dependency>
</dependencies>
</project>
\ No newline at end of file
......@@ -8,7 +8,7 @@
<property name="eclipselink.ddl-generation" value="create-tables" />
<property name="eclipselink.cache.size.default" value="16384" />
<property name="eclipselink.ddl-generation.output-mode"
value="database" />
value="sql-script" />
<property name="eclipselink.logging.logger" value="ServerLogger" />
<property name="eclipselink.jdbc.uppercase-columns" value="false" />
<property name="eclipselink.target-database"
......@@ -17,6 +17,8 @@
value="org.ancoron.postgresql.jpa.eclipselink.ConverterInitializer" />
<property name="eclipselink.descriptor.customizer"
value="fi.codecrew.moya.database.MoyaDescriptorCustomizer" />
<property name="eclipselink.create-ddl-jdbc-file-name" value="moyaCreateDDL.sql"/>
<property name="eclipselink.drop-ddl-jdbc-file-name" value="moyaDropDDL.sql"/>
</properties>
</persistence-unit>
......
......@@ -15,6 +15,7 @@ public class MoyaPostgreSQLPlatform extends PostgreSQLPlatform {
map.put(String.class, new FieldTypeDefinition("TEXT", false));
map.put(java.sql.Timestamp.class, new FieldTypeDefinition("TIMESTAMPTZ", false));
map.put(javax.json.JsonObject.class, new FieldTypeDefinition("JSON", false));
return map;
}
......
......@@ -4,22 +4,44 @@ import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import fi.codecrew.moya.utilities.jpa.ModelInterface;
@Entity
@Table(name = "db_models")
public class DBModel extends GenericEntity {
private static final long serialVersionUID = 5073284536090477220L;
public class DBModel implements ModelInterface {
private static final long serialVersionUID = 5073284536090477221L;
public static final String ID_COLUMN = "id";
@Column(name="revision", nullable=false)
@Id
@Column(name = ID_COLUMN, nullable = false)
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
@Column(name = "revision", nullable = false)
private Integer revision;
@Column(name="applied_at")
@Column(name = "applied_at")
@Temporal(TemporalType.TIMESTAMP)
private Date appliedAt = new Date();
@Override
public final Integer getId() {
return id;
}
@Override
public final void setId(Integer id) {
this.id = id;
}
public Date getAppliedAt() {
return appliedAt;
}
......
package fi.codecrew.moya.model;
import javax.json.JsonObject;
/**
* Entities that have a JSON meta data column implement this interface.
*
* Meta data can be just about anything that is not deemed to be essential
* enough to have it's own column. Including people's shirt sizes etc.
*
* @author jkj
*/
public interface EntityMeta {
/**
* Get JSON metadata associated with the entity.
*
* @return JsonObject from meta column in DB.
*/
public JsonObject getMeta();
/**
* Associate JSON metadata to entity.
*
* @param meta
* JsonObject that goes into meta column in DB.
*/
public void setMeta(JsonObject meta);
}
package fi.codecrew.moya.model;
import javax.json.JsonObject;
import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
......@@ -10,7 +11,7 @@ import fi.codecrew.moya.utilities.jpa.EntityEquals;
import fi.codecrew.moya.utilities.jpa.ModelInterface;
@MappedSuperclass
public class GenericEntity extends EntityEquals implements ModelInterface {
public class GenericEntity extends EntityEquals implements ModelInterface, EntityMeta {
private static final long serialVersionUID = -9041737052951021560L;
public static final String ID_COLUMN = "id";
......@@ -20,6 +21,8 @@ public class GenericEntity extends EntityEquals implements ModelInterface {
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
private JsonObject meta;
@Override
public final Integer getId() {
return id;
......@@ -30,4 +33,14 @@ public class GenericEntity extends EntityEquals implements ModelInterface {
this.id = id;
}
@Override
public JsonObject getMeta() {
return meta;
}
@Override
public void setMeta(JsonObject meta) {
this.meta = meta;
}
}
......@@ -22,7 +22,7 @@ import org.eclipse.persistence.annotations.OptimisticLockingType;
*
*/
@Entity
@Table(name = "licenseTargets")
@Table(name = "licensetargets")
@OptimisticLocking(type = OptimisticLockingType.CHANGED_COLUMNS)
public class LicenseTarget extends GenericEntity {
......
......@@ -184,22 +184,6 @@ public class ReaderEvent extends GenericEntity {
@Transient
public String getSeenSince() {
return "" + ((getUpdatetime().getTime() / 1000) / 60) +" min." ;
return "" + ((System.currentTimeMillis() - getUpdatetime().getTime()) / 1000 / 60) + " min.";
}
}
package fi.codecrew.moya.model.converters;
import java.io.StringReader;
import java.sql.SQLException;
import javax.json.Json;
import javax.json.JsonObject;
import javax.json.JsonReader;
import javax.persistence.AttributeConverter;
import javax.persistence.Converter;
import org.postgresql.util.PGobject;
@Converter(autoApply = true)
public class JsonAttributeConverter implements AttributeConverter<JsonObject, PGobject> {
public PGobject convertToDatabaseColumn(JsonObject attribute) {
if (attribute == null) {
return null;
}
final PGobject dataValue = new PGobject();
dataValue.setType("json");
try {
dataValue.setValue(attribute.toString());
} catch (SQLException e) {
// This will never run because PGobject.setValue() cannot really
// throw an SQLException. There is nothing but setting a property.
throw new RuntimeException("THIS SHOULD NEVER HAPPEN", e);
}
return dataValue;
}
public JsonObject convertToEntityAttribute(PGobject dbData) {
// Has any?
if (dbData == null) {
return null;
}
// Correct type of object?
if (dbData.getType().equals("json") == false) {
throw new RuntimeException("Expected JSON object from database");
}
// Read as JSON object
final StringReader stringReader = new StringReader(dbData.getValue());
final JsonReader jsonReader = Json.createReader(stringReader);
return jsonReader.readObject();
}
}
......@@ -26,6 +26,9 @@
<dependent-module archiveName="org.ancoron.postgresql.jpa-9.1.901.jdbc4.1-rc9.jar" deploy-path="/lib" handle="module:/classpath/var/M2_REPO/org/ancoron/postgresql/org.ancoron.postgresql.jpa/9.1.901.jdbc4.1-rc9/org.ancoron.postgresql.jpa-9.1.901.jdbc4.1-rc9.jar">
<dependency-type>uses</dependency-type>
</dependent-module>
<dependent-module archiveName="postgresql-9.3-1100-jdbc41.jar" deploy-path="/lib" handle="module:/classpath/var/M2_REPO/org/postgresql/postgresql/9.3-1100-jdbc41/postgresql-9.3-1100-jdbc41.jar">
<dependency-type>uses</dependency-type>
</dependent-module>
<dependent-module archiveName="pdfjet-0.0.0-2013-08-19.jar" deploy-path="/lib" handle="module:/classpath/var/M2_REPO/fi/iudex/pdfjet/pdfjet/0.0.0-2013-08-19/pdfjet-0.0.0-2013-08-19.jar">
<dependency-type>uses</dependency-type>
</dependent-module>
......
......@@ -289,4 +289,9 @@ public abstract class GenericFacade<C extends ModelInterface> {
public void evict(C entity) {
getEm().getEntityManagerFactory().getCache().evict(getEntityClass(), entity.getId());
}
public boolean isAttached(ModelInterface entity) {
return getEm().contains(entity);
}
}
......@@ -33,13 +33,13 @@
</h:panelGroup>
<h:panelGroup>
<h:panelGroup >
<reader:codefield selectaction="#{productShopView.readCode}" selectvalue="#{i18n['shop.readBarcode']}" />
<br />
<p:dataTable id="prods" value="#{productShopView.boughtItems}" var="prods">
<p:dataTable id="prods" value="#{productShopView.boughtItems}" var="prods" style="width:500px;">
<p:column headerText="#{i18n['shop.count']}">
<p:inputText value="#{prods.count}" size="2">
<f:ajax render="@form" listener="#{productShopView.countBoughtChangeListener}" />
......
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:h="http://java.sun.com/jsf/html" xmlns:tools="http://java.sun.com/jsf/composite/tools"
xmlns:products="http://java.sun.com/jsf/composite/cditools/products" xmlns:f="http://java.sun.com/jsf/core" xmlns:p="http://primefaces.org/ui">
<h:body>
<ui:composition template="#{sessionHandler.template}">
<f:metadata>
<f:viewParam name="reader" value="#{rfidListenerView.reader}" />
<f:viewParam name="tag" value="#{rfidListenerView.tag}" />
<f:event type="preRenderView" listener="#{rfidListenerView.cardRead()}" />
</f:metadata>
<ui:define name="title">
<h1>#{i18n['page.product.createBill.header']}</h1>
</ui:define>
<ui:define name="content">
Hi.
</ui:define>
</ui:composition>
</h:body>
</html>
\ No newline at end of file
......@@ -19,7 +19,7 @@
<h:messages errorClass="error" />
<h:panelGroup rendered="#{tournamentCreateView.tournamentGames.isEmpty() eq false}">
<h2>#{i18n['tournaments.admin.select_a_game']}</h2>
<h:selectOneMenu value="#{userGameIDView.gameToAddIdTo}" converter="#{tournamentGameConverter}">
<h:selectOneMenu value="#{tournamentCreateView.game}" converter="#{tournamentGameConverter}">
<f:selectItems var="game" itemLabel="#{game.name}" value="#{tournamentCreateView.tournamentGames}" itemValue="#{game}" />
</h:selectOneMenu>
</h:panelGroup>
......
......@@ -7,14 +7,14 @@
<h:body>
<ui:composition template="#{sessionHandler.template}">
<f:metadata>
<f:event type="preRenderView" listener="#{userView.initView}" />
<f:event type="preRenderView" listener="#{voteListView.initView}" />
</f:metadata>
<ui:define name="content">
<h1>My entries</h1>
<h:form>
<h:dataTable styleClass="bordertable" rowClasses="roweven,rowodd" id="compolisttable" value="#{userView.user.compoEntries}" var="entry">
<h:dataTable styleClass="bordertable" rowClasses="roweven,rowodd" id="compolisttable" value="#{voteListView.entries}" var="entry">
<h:column>
<f:facet name="header">
<h:outputText value="Title" />
......
......@@ -81,7 +81,7 @@
<dependency>
<groupId>org.primefaces</groupId>
<artifactId>primefaces</artifactId>
<version>5.0.RC2</version>
<version>5.0</version>
</dependency>
</dependencies>
</project>
\ No newline at end of file
......@@ -9,7 +9,6 @@ import java.util.zip.CRC32;
import javax.enterprise.context.RequestScoped;
import javax.faces.context.FacesContext;
import javax.inject.Inject;
import javax.inject.Named;
import javax.servlet.http.HttpServletRequest;
......@@ -29,8 +28,8 @@ public class ErrorPageView implements Serializable {
// private static final long serialVersionUID = -2179309061036632342L;
String trace;
@Inject
private transient FacesContext context;
// @Inject
// private transient FacesContext context;
@SuppressWarnings("unused")
private static final Logger logger = LoggerFactory.getLogger(ErrorPageView.class);
......@@ -70,16 +69,11 @@ public class ErrorPageView implements Serializable {
}
public String getTrail() {
HttpServletRequest req = (HttpServletRequest) getContext().getExternalContext().getRequest();
FacesContext context = FacesContext.getCurrentInstance();
HttpServletRequest req = (HttpServletRequest) context.getExternalContext().getRequest();
Object trail = req.getSession().getAttribute(HostnameFilter.HTTP_TRAIL_NAME);
return trail != null ? trail.toString() : "";
}
public FacesContext getContext() {
return context;
}
public void setContext(FacesContext context) {
this.context = context;
}
}
\ No newline at end of file
......@@ -9,7 +9,6 @@ import java.util.Map;
import javax.ejb.EJB;
import javax.enterprise.context.RequestScoped;
import javax.faces.context.FacesContext;
import javax.faces.event.ValueChangeEvent;
import javax.inject.Inject;
import javax.inject.Named;
......@@ -41,9 +40,6 @@ public class MenuView {
@Inject
private transient SessionStore sessionstore;
@Inject
private transient FacesContext context;
@EJB
private transient MenuBeanLocal menubean;
......@@ -63,8 +59,8 @@ public class MenuView {
public List<PageContent> getPagecontent(String pagekey)
{
String key = new StringBuilder(layoutview.getPagepath()).append(":").append(pagekey).toString();
// Removed by tkfftk, enought is enought
// logger.debug("Getting pagecontent for key {}. Matches: {}", key, contents.containsKey(key));
// Removed by tkfftk, enought is enought
// logger.debug("Getting pagecontent for key {}. Matches: {}", key, contents.containsKey(key));
if (!contents.containsKey(key)) {
contents.put(key, pagebean.findContentsForUser(key, sessionstore.getLocale()));
......@@ -234,10 +230,6 @@ public class MenuView {
return ret;
}
public void setContext(FacesContext context) {
this.context = context;
}
public LayoutView getLayoutview() {
return layoutview;
}
......
package fi.codecrew.moya.web.cdiview.reader;
import javax.ejb.EJB;
import javax.enterprise.context.ConversationScoped;
import javax.inject.Named;
import fi.codecrew.moya.beans.ReaderBeanLocal;
import fi.codecrew.moya.web.cdiview.GenericCDIView;
@Named
@ConversationScoped
public class RfidListenerView extends GenericCDIView {
@EJB
private ReaderBeanLocal readerbean;
private String reader;
private String tag;
public void cardRead()
{
readerbean.checkCode(reader, tag);
}
public String getReader() {
return reader;
}
public void setReader(String reader) {
this.reader = reader;
}
public String getTag() {
return tag;
}
public void setTag(String tag) {
this.tag = tag;
}
}
......@@ -104,7 +104,6 @@ public class TournamentCreateView extends GenericCDIView {
}
tournamentRules = tournamentBean.getRulesByGame(game);
System.out.println(tournamentRules);
break;
case "selectRuleset":
if (rulesetName != null && rulesetName.length() > 0) {
......
package fi.codecrew.moya.web.cdiview.voting;
import java.util.List;
import javax.ejb.EJB;
import javax.enterprise.context.RequestScoped;
import javax.inject.Named;
import fi.codecrew.moya.beans.VotingBeanLocal;
import fi.codecrew.moya.enums.apps.CompoPermission;
import fi.codecrew.moya.model.CompoEntry;
import fi.codecrew.moya.web.cdiview.GenericCDIView;
@Named
@RequestScoped
public class VoteListView extends GenericCDIView {
private static final long serialVersionUID = 4166316634472472472L;
@EJB
private VotingBeanLocal votebean;
private List<CompoEntry> entries;
public void initView()
{
if (super.requirePermissions(CompoPermission.SUBMIT_ENTRY))
setEntries(votebean.getEntriesForCurrentUser());
}
public List<CompoEntry> getEntries() {
return entries;
}
public void setEntries(List<CompoEntry> entries) {
this.entries = entries;
}
}
......@@ -38,8 +38,6 @@ public class LayoutView implements Serializable {
*
*/
private static final long serialVersionUID = 4468645109141859301L;
@Inject
private FacesContext context;
private ResourceBundle rb;
private String pagename;
@EJB
......@@ -106,6 +104,7 @@ public class LayoutView implements Serializable {
}
public String getPagepath() {
FacesContext context = FacesContext.getCurrentInstance();
if (pagename == null &&
context != null &&
context.getExternalContext() != null &&
......@@ -140,6 +139,8 @@ public class LayoutView implements Serializable {
}
private ResourceBundle getResourcebundle() {
FacesContext context = FacesContext.getCurrentInstance();
if (rb == null) {
rb = context.getApplication().getResourceBundle(context, "i18n");
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!