Commit e2be07d6 by Antti Tönkyrä

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

2 parents 2366cd98 eca9d1d0
Showing with 527 additions and 329 deletions
...@@ -79,7 +79,7 @@ public class BootstrapBean implements BootstrapBeanLocal { ...@@ -79,7 +79,7 @@ public class BootstrapBean implements BootstrapBeanLocal {
dbUpdates.add(new String[] { dbUpdates.add(new String[] {
"alter table compos add hidden boolean default false not null" "alter table compos add hidden boolean default false not null"
}); });
dbUpdates.add(alterTables("ADD COLUMN meta json", dbUpdates.add(alterTables("ADD COLUMN meta json",
"account_events", "account_events",
"actionlog_message_responses", "actionlog_message_responses",
...@@ -151,49 +151,47 @@ public class BootstrapBean implements BootstrapBeanLocal { ...@@ -151,49 +151,47 @@ public class BootstrapBean implements BootstrapBeanLocal {
"user_notes", "user_notes",
"users")); "users"));
dbUpdates.add(new String[] { "CREATE TABLE network_associations (id SERIAL NOT NULL, create_time TIMESTAMPTZ NOT NULL, ip TEXT, mac TEXT, meta TEXT, modify_time TIMESTAMPTZ NOT NULL, status TEXT NOT NULL, event INTEGER, event_user INTEGER, place INTEGER, PRIMARY KEY (id))" });
dbUpdates.add(new String[]{"CREATE TABLE network_associations (id SERIAL NOT NULL, create_time TIMESTAMPTZ NOT NULL, ip TEXT, mac TEXT, meta TEXT, modify_time TIMESTAMPTZ NOT NULL, status TEXT NOT NULL, event INTEGER, event_user INTEGER, place INTEGER, PRIMARY KEY (id))"});
dbUpdates.add(new String[] { dbUpdates.add(new String[] {
"CREATE TABLE card_text_data (id SERIAL NOT NULL, font_name TEXT NOT NULL, font_style INTEGER NOT NULL, size INTEGER NOT NULL, text TEXT, text_alignment TEXT NOT NULL, card_text_data_type TEXT NOT NULL, x INTEGER NOT NULL, y INTEGER NOT NULL, z_index INTEGER NOT NULL, PRIMARY KEY (id));" "CREATE TABLE card_text_data (id SERIAL NOT NULL, font_name TEXT NOT NULL, font_style INTEGER NOT NULL, size INTEGER NOT NULL, text TEXT, text_alignment TEXT NOT NULL, card_text_data_type TEXT NOT NULL, x INTEGER NOT NULL, y INTEGER NOT NULL, z_index INTEGER NOT NULL, PRIMARY KEY (id));"
}); });
dbUpdates.add(new String[] { dbUpdates.add(new String[] {
"CREATE TABLE card_object_data (id SERIAL NOT NULL, card_object_data_type TEXT NOT NULL, size INTEGER NOT NULL, x INTEGER NOT NULL, y INTEGER NOT NULL, z_index INTEGER NOT NULL, PRIMARY KEY (id));" "CREATE TABLE card_object_data (id SERIAL NOT NULL, card_object_data_type TEXT NOT NULL, size INTEGER NOT NULL, x INTEGER NOT NULL, y INTEGER NOT NULL, z_index INTEGER NOT NULL, PRIMARY KEY (id));"
}); });
dbUpdates.add(new String[] { dbUpdates.add(new String[] {
"ALTER TABLE card_text_data ADD COLUMN card_templates_id integer REFERENCES card_templates(id) DEFAULT null;", "ALTER TABLE card_text_data ADD COLUMN card_templates_id integer REFERENCES card_templates(id) DEFAULT null;",
"ALTER TABLE card_object_data ADD COLUMN card_templates_id integer REFERENCES card_templates(id) DEFAULT null;" "ALTER TABLE card_object_data ADD COLUMN card_templates_id integer REFERENCES card_templates(id) DEFAULT null;"
}); });
dbUpdates.add(alterTables("ADD COLUMN meta json", dbUpdates.add(alterTables("ADD COLUMN meta json",
"card_text_data", "card_text_data",
"card_object_data" "card_object_data"
)); ));
dbUpdates.add(new String[] { dbUpdates.add(new String[] {
"ALTER TABLE card_text_data ADD COLUMN font_color_r integer DEFAULT 0;", "ALTER TABLE card_text_data ADD COLUMN font_color_r integer DEFAULT 0;",
"ALTER TABLE card_text_data ADD COLUMN font_color_g integer DEFAULT 0;", "ALTER TABLE card_text_data ADD COLUMN font_color_g integer DEFAULT 0;",
"ALTER TABLE card_text_data ADD COLUMN font_color_b integer DEFAULT 0;" "ALTER TABLE card_text_data ADD COLUMN font_color_b integer DEFAULT 0;"
}); });
dbUpdates.add(new String[] { dbUpdates.add(new String[] {
"ALTER TABLE card_text_data ALTER COLUMN size TYPE numeric(5,2);", "ALTER TABLE card_text_data ALTER COLUMN size TYPE numeric(5,2);",
"ALTER TABLE card_object_data ALTER COLUMN size TYPE numeric(5,2);" "ALTER TABLE card_object_data ALTER COLUMN size TYPE numeric(5,2);"
}); });
dbUpdates.add(new String[] { dbUpdates.add(new String[] {
"ALTER TABLE card_text_data DROP COLUMN font_style;", "ALTER TABLE card_text_data DROP COLUMN font_style;",
"ALTER TABLE card_text_data ADD COLUMN font_style TEXT NOT NULL DEFAULT 'PLAIN';" "ALTER TABLE card_text_data ADD COLUMN font_style TEXT NOT NULL DEFAULT 'PLAIN';"
}); });
dbUpdates.add(new String[] { dbUpdates.add(new String[] {
"ALTER TABLE event_log RENAME log_id TO id;" "ALTER TABLE event_log RENAME log_id TO id;"
}); });
dbUpdates.add(new String[] { dbUpdates.add(new String[] {
"ALTER TABLE network_associations ALTER COLUMN meta TYPE json USING (meta::json);" "ALTER TABLE network_associations ALTER COLUMN meta TYPE json USING (meta::json);"
}); });
dbUpdates.add(new String[] { "CREATE TABLE lecture_groups (id SERIAL NOT NULL, event_id integer NOT NULL, description TEXT, name TEXT, select_count INTEGER, meta json, PRIMARY KEY (id))",
dbUpdates.add(new String[] {"CREATE TABLE lecture_groups (id SERIAL NOT NULL, event_id integer NOT NULL, description TEXT, name TEXT, select_count INTEGER, meta json, PRIMARY KEY (id))",
"CREATE TABLE lectures (id SERIAL NOT NULL, description TEXT, hours numeric(10,2), max_participants_count INTEGER, name TEXT, start_time TIMESTAMPTZ, lecture_group_id INTEGER, meta json, PRIMARY KEY (id))", "CREATE TABLE lectures (id SERIAL NOT NULL, description TEXT, hours numeric(10,2), max_participants_count INTEGER, name TEXT, start_time TIMESTAMPTZ, lecture_group_id INTEGER, meta json, PRIMARY KEY (id))",
"CREATE TABLE lecture_roles (role_id INTEGER NOT NULL, lecture_id INTEGER NOT NULL, PRIMARY KEY (role_id, lecture_id))", "CREATE TABLE lecture_roles (role_id INTEGER NOT NULL, lecture_id INTEGER NOT NULL, PRIMARY KEY (role_id, lecture_id))",
"CREATE TABLE lecture_participants (eventuser_id INTEGER NOT NULL, lecture_id INTEGER NOT NULL, PRIMARY KEY (eventuser_id, lecture_id))", "CREATE TABLE lecture_participants (eventuser_id INTEGER NOT NULL, lecture_id INTEGER NOT NULL, PRIMARY KEY (eventuser_id, lecture_id))",
...@@ -201,9 +199,14 @@ public class BootstrapBean implements BootstrapBeanLocal { ...@@ -201,9 +199,14 @@ public class BootstrapBean implements BootstrapBeanLocal {
"ALTER TABLE lecture_roles ADD CONSTRAINT FK_lecture_roles_lecture_id FOREIGN KEY (lecture_id) REFERENCES lectures (id)", "ALTER TABLE lecture_roles ADD CONSTRAINT FK_lecture_roles_lecture_id FOREIGN KEY (lecture_id) REFERENCES lectures (id)",
"ALTER TABLE lecture_roles ADD CONSTRAINT FK_lecture_roles_role_id FOREIGN KEY (role_id) REFERENCES roles (id)", "ALTER TABLE lecture_roles ADD CONSTRAINT FK_lecture_roles_role_id FOREIGN KEY (role_id) REFERENCES roles (id)",
"ALTER TABLE lecture_participants ADD CONSTRAINT FK_lecture_participants_eventuser_id FOREIGN KEY (eventuser_id) REFERENCES event_users (id)", "ALTER TABLE lecture_participants ADD CONSTRAINT FK_lecture_participants_eventuser_id FOREIGN KEY (eventuser_id) REFERENCES event_users (id)",
"ALTER TABLE lecture_participants ADD CONSTRAINT FK_lecture_participants_lecture_id FOREIGN KEY (lecture_id) REFERENCES lectures (id)"}); "ALTER TABLE lecture_participants ADD CONSTRAINT FK_lecture_participants_lecture_id FOREIGN KEY (lecture_id) REFERENCES lectures (id)" });
dbUpdates.add(new String[] { "ALTER TABLE roles ADD COLUMN user_selectable_role boolean DEFAULT false;" }); dbUpdates.add(new String[] { "ALTER TABLE roles ADD COLUMN user_selectable_role boolean DEFAULT false;" });
dbUpdates.add(new String[] {
"ALTER TABLE group_memberships ADD COLUMN place_product INTEGER",
"ALTER TABLE group_memberships ADD CONSTRAINT FK_group_memberships_place_product FOREIGN KEY (place_product) REFERENCES products (id)"
});
} }
@EJB @EJB
......
...@@ -117,7 +117,9 @@ public class LectureBean implements LectureBeanLocal { ...@@ -117,7 +117,9 @@ public class LectureBean implements LectureBeanLocal {
lectureloop: for (Lecture l : lectureGroup.getLectures()) { lectureloop: for (Lecture l : lectureGroup.getLectures()) {
for (Role r : l.getOpenForRoles()) { for (Role r : l.getOpenForRoles()) {
if (userRoles.contains(r)) { if (userRoles.contains(r)) {
lectures.add(l); if(!user.getLectures().contains(l)) {
lectures.add(l);
}
continue lectureloop; continue lectureloop;
} }
} }
...@@ -214,4 +216,9 @@ public class LectureBean implements LectureBeanLocal { ...@@ -214,4 +216,9 @@ public class LectureBean implements LectureBeanLocal {
return false; return false;
} }
@Override
public Lecture getFirstLecture() {
return lectureFacade.findFirstLecture();
}
} }
...@@ -10,7 +10,6 @@ import java.util.ArrayList; ...@@ -10,7 +10,6 @@ import java.util.ArrayList;
import java.util.Calendar; import java.util.Calendar;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.Comparator;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
...@@ -42,6 +41,7 @@ import com.pdfjet.TextLine; ...@@ -42,6 +41,7 @@ import com.pdfjet.TextLine;
import fi.codecrew.moya.enums.apps.MapPermission; import fi.codecrew.moya.enums.apps.MapPermission;
import fi.codecrew.moya.enums.apps.SpecialPermission; import fi.codecrew.moya.enums.apps.SpecialPermission;
import fi.codecrew.moya.exceptions.BortalCatchableException; import fi.codecrew.moya.exceptions.BortalCatchableException;
import fi.codecrew.moya.facade.EventMapFacade;
import fi.codecrew.moya.facade.EventUserFacade; import fi.codecrew.moya.facade.EventUserFacade;
import fi.codecrew.moya.facade.GroupMembershipFacade; import fi.codecrew.moya.facade.GroupMembershipFacade;
import fi.codecrew.moya.facade.PlaceFacade; import fi.codecrew.moya.facade.PlaceFacade;
...@@ -107,6 +107,8 @@ public class PlaceBean implements PlaceBeanLocal { ...@@ -107,6 +107,8 @@ public class PlaceBean implements PlaceBeanLocal {
@EJB @EJB
private BarcodeBeanLocal barcodeBean; private BarcodeBeanLocal barcodeBean;
@EJB
private EventMapFacade eventMapFacade;
@Override @Override
@RolesAllowed(MapPermission.S_MANAGE_MAPS) @RolesAllowed(MapPermission.S_MANAGE_MAPS)
...@@ -626,9 +628,9 @@ public class PlaceBean implements PlaceBeanLocal { ...@@ -626,9 +628,9 @@ public class PlaceBean implements PlaceBeanLocal {
try { try {
List<Place> places = placeFacade.findAll(); List<Place> places = placeFacade.findAll();
Collections.sort(places); Collections.sort(places);
logger.info("sorting places etc."); logger.info("sorting places etc.");
return generatePlacesPdf(width, height, font1, font1, places); return generatePlacesPdf(width, height, font1, font1, places);
} catch (Exception e) { } catch (Exception e) {
logger.error("Exception from place pdf generation.", e); logger.error("Exception from place pdf generation.", e);
...@@ -637,4 +639,33 @@ public class PlaceBean implements PlaceBeanLocal { ...@@ -637,4 +639,33 @@ public class PlaceBean implements PlaceBeanLocal {
} }
} }
@Override
public Long selectablePlaceCount(EventMap map) {
return placeFacade.countSelectable(map);
}
@Override
public EventMap findMap(Integer mapId) {
return eventMapFacade.find(mapId);
}
@Override
public Long availablePlaceCount(EventMap map) {
return placeFacade.countAvailable(map);
}
@Override
public EventMap getActiveMap() {
LanEvent event = eventBean.getCurrentEvent();
logger.info("Current event: {}, maps {}", event, event.getEventMaps());
for (EventMap map : event.getEventMaps()) {
logger.info("Checking active map {}, is active {}", map, map.isActive());
if (map.isActive()) {
return map;
}
}
return null;
}
} }
package fi.codecrew.moya.beans;
import java.awt.image.BufferedImage;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.util.List;
import javax.ejb.EJB;
import javax.ejb.Stateless;
import javax.imageio.ImageIO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.pdfjet.CoreFont;
import com.pdfjet.Image;
import com.pdfjet.ImageType;
import com.pdfjet.PDF;
import com.pdfjet.Page;
import com.pdfjet.TextLine;
import fi.codecrew.moya.facade.EventMapFacade;
import fi.codecrew.moya.facade.PlaceFacade;
import fi.codecrew.moya.model.CardTemplate;
import fi.codecrew.moya.model.EventMap;
import fi.codecrew.moya.model.LanEvent;
import fi.codecrew.moya.model.Place;
import fi.codecrew.moya.model.PrintedCard;
import fi.codecrew.moya.util.MassPrintResult;
/**
* Session Bean implementation class PlaceMapBean
*/
@Stateless
public class PlaceMapBean implements PlaceMapBeanLocal {
/**
* Default constructor.
*/
public PlaceMapBean() {
// TODO Auto-generated constructor stub
}
@EJB
private PlaceFacade placeFacade;
@EJB
// private EventMapBean eventmapBean;
private EventMapFacade eventMapFacade;
@EJB
private EventBeanLocal eventbean;
private static final Logger logger = LoggerFactory.getLogger(PlaceMapBean.class);
@Override
public Long selectablePlaceCount(EventMap map) {
return eventMapFacade.countSelectable(map);
}
@Override
public EventMap findMap(Integer mapId) {
return eventMapFacade.find(mapId);
}
@Override
public Long availablePlaceCount(EventMap map) {
return eventMapFacade.countAvailable(map);
}
@Override
public EventMap getActiveMap() {
LanEvent event = eventbean.getCurrentEvent();
logger.info("Current event: {}, maps {}", event, event.getEventMaps());
for (EventMap map : event.getEventMaps()) {
logger.info("Checking active map {}, is active {}", map, map.isActive());
if (map.isActive()) {
return map;
}
}
return null;
}
}
...@@ -28,8 +28,11 @@ import fi.codecrew.moya.enums.apps.UserPermission; ...@@ -28,8 +28,11 @@ import fi.codecrew.moya.enums.apps.UserPermission;
import fi.codecrew.moya.facade.AccountEventFacade; import fi.codecrew.moya.facade.AccountEventFacade;
import fi.codecrew.moya.facade.BillLineFacade; import fi.codecrew.moya.facade.BillLineFacade;
import fi.codecrew.moya.facade.DiscountFacade; import fi.codecrew.moya.facade.DiscountFacade;
import fi.codecrew.moya.facade.EventMapFacade;
import fi.codecrew.moya.facade.EventUserFacade; import fi.codecrew.moya.facade.EventUserFacade;
import fi.codecrew.moya.facade.GroupMembershipFacade;
import fi.codecrew.moya.facade.InventoryEventFacade; import fi.codecrew.moya.facade.InventoryEventFacade;
import fi.codecrew.moya.facade.PlaceFacade;
import fi.codecrew.moya.facade.ProductFacade; import fi.codecrew.moya.facade.ProductFacade;
import fi.codecrew.moya.facade.UserFacade; import fi.codecrew.moya.facade.UserFacade;
import fi.codecrew.moya.model.AccountEvent; import fi.codecrew.moya.model.AccountEvent;
...@@ -107,6 +110,14 @@ public class ProductBean implements ProductBeanLocal { ...@@ -107,6 +110,14 @@ public class ProductBean implements ProductBeanLocal {
@EJB @EJB
private CardTemplateBean cardTemplateBean; private CardTemplateBean cardTemplateBean;
@EJB
private PlaceFacade placeFacade;
@EJB
private EventMapFacade mapfacade;
@EJB
private GroupMembershipFacade gmfacade;
private static final Logger logger = LoggerFactory.getLogger(ProductBean.class); private static final Logger logger = LoggerFactory.getLogger(ProductBean.class);
/** /**
...@@ -188,6 +199,15 @@ public class ProductBean implements ProductBeanLocal { ...@@ -188,6 +199,15 @@ public class ProductBean implements ProductBeanLocal {
return getPrivateProductLimit(product, user, prodCounts, userroles); return getPrivateProductLimit(product, user, prodCounts, userroles);
} }
/**
* Returns available products to be bought for the user.
*
* @param product
* @param user
* @param prodCounts
* @param userroles
* @return Number of buyable products
*/
private BigDecimal getPrivateProductLimit(Product product, EventUser user, Map<Integer, BigDecimal> prodCounts, Set<Role> userroles) private BigDecimal getPrivateProductLimit(Product product, EventUser user, Map<Integer, BigDecimal> prodCounts, Set<Role> userroles)
{ {
BigDecimal ret = null; BigDecimal ret = null;
...@@ -222,15 +242,26 @@ public class ProductBean implements ProductBeanLocal { ...@@ -222,15 +242,26 @@ public class ProductBean implements ProductBeanLocal {
switch (limit.getType()) switch (limit.getType())
{ {
case GLOBAL_BILLED: case PLACE: {
Long reserved = 0L;
Long available = 0L;
for (Product p : limit.getProducts()) {
reserved += gmfacade.findPlaceProductCount(p);
available += placeFacade.findCountForProduct(p);
}
ret = BigDecimal.valueOf(available - reserved).subtract(count);
break;
}
case GLOBAL_BILLED: {
BigDecimal globBillTot = BigDecimal.ZERO; BigDecimal globBillTot = BigDecimal.ZERO;
for (Product p : limit.getProducts()) { for (Product p : limit.getProducts()) {
BillSummary globBilledSummary = billLineFacade.getLineSummary(p, eventbean.getCurrentEvent()); BillSummary globBilledSummary = billLineFacade.getLineSummary(p, eventbean.getCurrentEvent());
globBillTot = globBillTot.add(globBilledSummary.getTotal()); globBillTot = globBillTot.add(globBilledSummary.getActive());
} }
count = count.add(globBillTot); count = count.add(globBillTot);
ret = limit.getUpperLimit().subtract(count); ret = limit.getUpperLimit().subtract(count);
break; break;
}
case GLOBAL_BILL_PAID: case GLOBAL_BILL_PAID:
BigDecimal globBillPaid = BigDecimal.ZERO; BigDecimal globBillPaid = BigDecimal.ZERO;
for (Product p : limit.getProducts()) { for (Product p : limit.getProducts()) {
...@@ -258,7 +289,7 @@ public class ProductBean implements ProductBeanLocal { ...@@ -258,7 +289,7 @@ public class ProductBean implements ProductBeanLocal {
BigDecimal userBillTot = BigDecimal.ZERO; BigDecimal userBillTot = BigDecimal.ZERO;
for (Product p : limit.getProducts()) { for (Product p : limit.getProducts()) {
BillSummary userBilledSummary = billLineFacade.getLineSummary(p, eventbean.getCurrentEvent(), user); BillSummary userBilledSummary = billLineFacade.getLineSummary(p, eventbean.getCurrentEvent(), user);
userBillTot = userBillTot.add(userBilledSummary.getTotal()); userBillTot = userBillTot.add(userBilledSummary.getActive());
} }
count = count.add(userBillTot); count = count.add(userBillTot);
ret = limit.getUpperLimit().subtract(count); ret = limit.getUpperLimit().subtract(count);
......
...@@ -2,13 +2,8 @@ package fi.codecrew.moya.facade; ...@@ -2,13 +2,8 @@ package fi.codecrew.moya.facade;
import javax.ejb.LocalBean; import javax.ejb.LocalBean;
import javax.ejb.Stateless; import javax.ejb.Stateless;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Root;
import fi.codecrew.moya.model.Place_;
import fi.codecrew.moya.model.EventMap; import fi.codecrew.moya.model.EventMap;
import fi.codecrew.moya.model.Place;
@Stateless @Stateless
@LocalBean @LocalBean
...@@ -18,43 +13,4 @@ public class EventMapFacade extends IntegerPkGenericFacade<EventMap> { ...@@ -18,43 +13,4 @@ public class EventMapFacade extends IntegerPkGenericFacade<EventMap> {
super(EventMap.class); super(EventMap.class);
} }
public Long countAvailable(EventMap map) {
CriteriaBuilder cb = getEm().getCriteriaBuilder();
CriteriaQuery<Long> cq = cb.createQuery(Long.class);
Root<Place> root = cq.from(Place.class);
cq.select(cb.count(root));
cq.where(
cb.equal(root.get(Place_.map), map),
cb.isFalse(root.get(Place_.disabled))
);
return getSingleNullableResult(getEm().createQuery(cq));
}
public Long countSelectable(EventMap map) {
if (map == null) {
return null;
}
CriteriaBuilder cb = getEm().getCriteriaBuilder();
CriteriaQuery<Long> cq = cb.createQuery(Long.class);
Root<Place> root = cq.from(Place.class);
cq.select(cb.count(root));
cq.where(
cb.equal(root.get(Place_.map), map),
cb.isNull(root.get(Place_.releaseTime)),
cb.isNull(root.get(Place_.group)),
cb.isFalse(root.get(Place_.disabled))
);
return getSingleNullableResult(getEm().createQuery(cq));
}
} }
...@@ -20,6 +20,7 @@ import fi.codecrew.moya.model.GroupMembership_; ...@@ -20,6 +20,7 @@ import fi.codecrew.moya.model.GroupMembership_;
import fi.codecrew.moya.model.PlaceGroup; import fi.codecrew.moya.model.PlaceGroup;
import fi.codecrew.moya.model.PlaceGroup_; import fi.codecrew.moya.model.PlaceGroup_;
import fi.codecrew.moya.model.Place_; import fi.codecrew.moya.model.Place_;
import fi.codecrew.moya.model.Product;
import fi.codecrew.moya.utilities.PasswordFunctions; import fi.codecrew.moya.utilities.PasswordFunctions;
@Stateless @Stateless
...@@ -65,13 +66,13 @@ public class GroupMembershipFacade extends IntegerPkGenericFacade<GroupMembershi ...@@ -65,13 +66,13 @@ public class GroupMembershipFacade extends IntegerPkGenericFacade<GroupMembershi
// q.setParameter("token", token); // q.setParameter("token", token);
return getSingleNullableResult(getEm().createQuery(cq)); return getSingleNullableResult(getEm().createQuery(cq));
} }
public List<GroupMembership> matchByToken(String token) { public List<GroupMembership> matchByToken(String token) {
CriteriaBuilder cb = getEm().getCriteriaBuilder(); CriteriaBuilder cb = getEm().getCriteriaBuilder();
CriteriaQuery<GroupMembership> cq = cb.createQuery(GroupMembership.class); CriteriaQuery<GroupMembership> cq = cb.createQuery(GroupMembership.class);
Root<GroupMembership> root = cq.from(GroupMembership.class); Root<GroupMembership> root = cq.from(GroupMembership.class);
cq.where(cb.like(root.get(GroupMembership_.inviteToken), "%"+token+"%"), cq.where(cb.like(root.get(GroupMembership_.inviteToken), "%" + token + "%"),
cb.equal(root.get(GroupMembership_.placeGroup).get(PlaceGroup_.event), eventbean.getCurrentEvent()) cb.equal(root.get(GroupMembership_.placeGroup).get(PlaceGroup_.event), eventbean.getCurrentEvent())
); );
...@@ -123,7 +124,7 @@ public class GroupMembershipFacade extends IntegerPkGenericFacade<GroupMembershi ...@@ -123,7 +124,7 @@ public class GroupMembershipFacade extends IntegerPkGenericFacade<GroupMembershi
// p.setParameter("user", user); // p.setParameter("user", user);
// return p.getResultList(); // return p.getResultList();
} }
public List<GroupMembership> findAllWithoutUser() { public List<GroupMembership> findAllWithoutUser() {
CriteriaBuilder cb = getEm().getCriteriaBuilder(); CriteriaBuilder cb = getEm().getCriteriaBuilder();
CriteriaQuery<GroupMembership> cq = cb.createQuery(GroupMembership.class); CriteriaQuery<GroupMembership> cq = cb.createQuery(GroupMembership.class);
...@@ -137,4 +138,16 @@ public class GroupMembershipFacade extends IntegerPkGenericFacade<GroupMembershi ...@@ -137,4 +138,16 @@ public class GroupMembershipFacade extends IntegerPkGenericFacade<GroupMembershi
return getEm().createQuery(cq).getResultList(); return getEm().createQuery(cq).getResultList();
} }
public Long findPlaceProductCount(Product product) {
CriteriaBuilder cb = getEm().getCriteriaBuilder();
CriteriaQuery<Long> cq = cb.createQuery(Long.class);
Root<GroupMembership> root = cq.from(GroupMembership.class);
cq.select(cb.count(root));
cq.where(cb.equal(root.get(GroupMembership_.placeProduct), product));
return super.getSingleNullableResult(getEm().createQuery(cq));
}
} }
package fi.codecrew.moya.facade; package fi.codecrew.moya.facade;
import javax.ejb.EJB;
import javax.ejb.LocalBean; import javax.ejb.LocalBean;
import javax.ejb.Stateless; import javax.ejb.Stateless;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Root;
import fi.codecrew.moya.model.EventUser; import fi.codecrew.moya.beans.EventBean;
import fi.codecrew.moya.model.Lecture; import fi.codecrew.moya.model.Lecture;
import fi.codecrew.moya.model.LectureGroup_;
import fi.codecrew.moya.model.Lecture_;
@Stateless @Stateless
@LocalBean @LocalBean
...@@ -12,4 +18,20 @@ public class LectureFacade extends IntegerPkGenericFacade<Lecture> { ...@@ -12,4 +18,20 @@ public class LectureFacade extends IntegerPkGenericFacade<Lecture> {
public LectureFacade() { public LectureFacade() {
super(Lecture.class); super(Lecture.class);
} }
@EJB
EventBean eventbean;
public Lecture findFirstLecture() {
CriteriaBuilder cb = getEm().getCriteriaBuilder();
CriteriaQuery<Lecture> cq = cb.createQuery(Lecture.class);
Root<Lecture> root = cq.from(Lecture.class);
cq.where(cb.equal(root.get(Lecture_.lectureGroup).get(LectureGroup_.event), eventbean.getCurrentEvent()));
cq.orderBy(cb.asc(root.get(Lecture_.startTime)));
return getSingleNullableResult(getEm().createQuery(cq).setMaxResults(1));
}
} }
...@@ -22,13 +22,14 @@ import fi.codecrew.moya.model.EventUser; ...@@ -22,13 +22,14 @@ import fi.codecrew.moya.model.EventUser;
import fi.codecrew.moya.model.LanEvent; import fi.codecrew.moya.model.LanEvent;
import fi.codecrew.moya.model.Place; import fi.codecrew.moya.model.Place;
import fi.codecrew.moya.model.Place_; import fi.codecrew.moya.model.Place_;
import fi.codecrew.moya.model.Product;
@Stateless @Stateless
@LocalBean @LocalBean
public class PlaceFacade extends IntegerPkGenericFacade<Place> { public class PlaceFacade extends IntegerPkGenericFacade<Place> {
private static final Logger logger = LoggerFactory.getLogger(PlaceFacade.class); private static final Logger logger = LoggerFactory.getLogger(PlaceFacade.class);
@EJB @EJB
EventBeanLocal eventBean; EventBeanLocal eventBean;
...@@ -127,18 +128,66 @@ public class PlaceFacade extends IntegerPkGenericFacade<Place> { ...@@ -127,18 +128,66 @@ public class PlaceFacade extends IntegerPkGenericFacade<Place> {
); );
return getSingleNullableResult(getEm().createQuery(cq)); return getSingleNullableResult(getEm().createQuery(cq));
} }
public List<Place> findAll() { public List<Place> findAll() {
CriteriaBuilder cb = getEm().getCriteriaBuilder(); CriteriaBuilder cb = getEm().getCriteriaBuilder();
CriteriaQuery<Place> cq = cb.createQuery(Place.class); CriteriaQuery<Place> cq = cb.createQuery(Place.class);
Root<Place> root = cq.from(Place.class); Root<Place> root = cq.from(Place.class);
cq.where( cb.equal(root.get(Place_.map).get(EventMap_.event), eventBean.getCurrentEvent())); 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(); return getEm().createQuery(cq).getResultList();
} }
}
public Long findCountForProduct(Product product) {
CriteriaBuilder cb = getEm().getCriteriaBuilder();
CriteriaQuery<Long> cq = cb.createQuery(Long.class);
Root<Place> root = cq.from(Place.class);
cq.select(cb.count(root));
cq.where(
cb.equal(root.get(Place_.product), product),
cb.isFalse(root.get(Place_.disabled))
);
return super.getSingleNullableResult(getEm().createQuery(cq));
}
public Long countAvailable(EventMap map) {
CriteriaBuilder cb = getEm().getCriteriaBuilder();
CriteriaQuery<Long> cq = cb.createQuery(Long.class);
Root<Place> root = cq.from(Place.class);
cq.select(cb.count(root));
cq.where(
cb.equal(root.get(Place_.map), map),
cb.isFalse(root.get(Place_.disabled))
);
return getSingleNullableResult(getEm().createQuery(cq));
}
public Long countSelectable(EventMap map) {
if (map == null) {
return null;
}
CriteriaBuilder cb = getEm().getCriteriaBuilder();
CriteriaQuery<Long> cq = cb.createQuery(Long.class);
Root<Place> root = cq.from(Place.class);
cq.select(cb.count(root));
cq.where(
cb.equal(root.get(Place_.map), map),
cb.isNull(root.get(Place_.releaseTime)),
cb.isNull(root.get(Place_.group)),
cb.isFalse(root.get(Place_.disabled))
);
return getSingleNullableResult(getEm().createQuery(cq));
}
}
...@@ -34,4 +34,6 @@ public interface LectureBeanLocal { ...@@ -34,4 +34,6 @@ public interface LectureBeanLocal {
public int userLectureSelects(LectureGroup group, EventUser user); public int userLectureSelects(LectureGroup group, EventUser user);
public boolean isUserCanParticipate(EventUser user); public boolean isUserCanParticipate(EventUser user);
public Lecture getFirstLecture();
} }
...@@ -72,4 +72,12 @@ public interface PlaceBeanLocal { ...@@ -72,4 +72,12 @@ public interface PlaceBeanLocal {
PlaceGroup reserveSelectedPlaces(EventUser eventuser) throws BortalCatchableException; PlaceGroup reserveSelectedPlaces(EventUser eventuser) throws BortalCatchableException;
public Long selectablePlaceCount(EventMap activeMap);
public EventMap findMap(Integer mapId);
public Long availablePlaceCount(EventMap activeMap);
public EventMap getActiveMap();
} }
package fi.codecrew.moya.beans;
import java.util.List;
import javax.ejb.Local;
import fi.codecrew.moya.model.EventMap;
import fi.codecrew.moya.model.Place;
@Local
public interface PlaceMapBeanLocal {
// public String getSelectPlaceMapUrl(EventMap activeMap, List<Place>
// selectedPlaces, User user);
public Long selectablePlaceCount(EventMap activeMap);
public EventMap findMap(Integer mapId);
public Long availablePlaceCount(EventMap activeMap);
public EventMap getActiveMap();
// wanha poistoon, see placebean
// public byte[] placeCodesPdf(List<Place> places);
// public List<Place> findSelectedPlaces(EventMap map);
// public EventMap findMap(int i);
}
...@@ -6,31 +6,40 @@ import fi.codecrew.moya.model.BillLine; ...@@ -6,31 +6,40 @@ import fi.codecrew.moya.model.BillLine;
public class BillSummary { public class BillSummary {
public BillSummary(String name) { public BillSummary(String name) {
this.name = name; this.name = name;
} }
private String name; private String name;
private BigDecimal total = BigDecimal.ZERO; private BigDecimal active = BigDecimal.ZERO;
private BigDecimal paid = BigDecimal.ZERO; private BigDecimal paid = BigDecimal.ZERO;
private BigDecimal expired = BigDecimal.ZERO;
public String getName() {
return name; public String getName() {
} return name;
}
public BigDecimal getTotal() {
return total; public BigDecimal getActive() {
} return active;
}
public void addLine(BillLine bl) {
total = getTotal().add(bl.getQuantity()); public void addLine(BillLine bl) {
if (bl.getBill().getPaidDate() != null) { if (bl.getBill().isExpired()) {
paid = getPaid().add(bl.getQuantity()); expired = getExpired().add(bl.getQuantity());
} } else {
} active = getActive().add(bl.getQuantity());
if (bl.getBill().getPaidDate() != null) {
public BigDecimal getPaid() { paid = getPaid().add(bl.getQuantity());
return paid; }
} }
}
public BigDecimal getPaid() {
return paid;
}
public BigDecimal getExpired() {
return expired;
}
} }
...@@ -4,7 +4,6 @@ ...@@ -4,7 +4,6 @@
*/ */
package fi.codecrew.moya.model; package fi.codecrew.moya.model;
import java.beans.Transient;
import java.util.Calendar; import java.util.Calendar;
import javax.persistence.CascadeType; import javax.persistence.CascadeType;
...@@ -54,8 +53,11 @@ public class GroupMembership extends GenericEntity { ...@@ -54,8 +53,11 @@ public class GroupMembership extends GenericEntity {
@JoinColumn(name = "place_reservation_id", referencedColumnName = "id", nullable = true, unique = true) @JoinColumn(name = "place_reservation_id", referencedColumnName = "id", nullable = true, unique = true)
private Place placeReservation; private Place placeReservation;
@ManyToOne
@JoinColumn(name = "place_product")
private Product placeProduct;
@JoinColumn(name = EVENTUSER_ID, referencedColumnName = EventUser.ID_COLUMN) @JoinColumn(name = EVENTUSER_ID, referencedColumnName = EventUser.ID_COLUMN)
@ManyToOne @ManyToOne
private EventUser user; private EventUser user;
...@@ -143,4 +145,12 @@ public class GroupMembership extends GenericEntity { ...@@ -143,4 +145,12 @@ public class GroupMembership extends GenericEntity {
public String getInviteToken() { public String getInviteToken() {
return inviteToken; return inviteToken;
} }
public Product getPlaceProduct() {
return placeProduct;
}
public void setPlaceProduct(Product placeProduct) {
this.placeProduct = placeProduct;
}
} }
...@@ -145,20 +145,22 @@ public class Lecture extends GenericEntity { ...@@ -145,20 +145,22 @@ public class Lecture extends GenericEntity {
this.startTime = startTime; this.startTime = startTime;
} }
/*
@Transient @Transient
public Calendar getEndTime() { public Date getEndTime() {
if (getStartTime() == null || getHours() == null) if (getStartTime() == null || getHours() == null)
return getStartTime(); return getStartTime();
Calendar endTime = (Calendar) getStartTime().clone(); Calendar endTime = Calendar.getInstance();
endTime.setTime((Date) getStartTime().clone());
endTime.add(Calendar.MINUTE, getHours().multiply(new BigDecimal(60)).intValue()); endTime.add(Calendar.MINUTE, getHours().multiply(new BigDecimal(60)).intValue());
return endTime; return endTime.getTime();
} }
/*
@Transient @Transient
public void setEndTime(Calendar endTime) { public void setEndTime(Calendar endTime) {
......
...@@ -5,8 +5,6 @@ ...@@ -5,8 +5,6 @@
package fi.codecrew.moya.model; package fi.codecrew.moya.model;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
...@@ -134,9 +132,9 @@ public class Product extends GenericEntity { ...@@ -134,9 +132,9 @@ public class Product extends GenericEntity {
} }
private Product(String string) { private Product(String name) {
super(); super();
name = "----"; this.name = name;
} }
public BigDecimal getSoldCash() { public BigDecimal getSoldCash() {
......
...@@ -2,5 +2,5 @@ package fi.codecrew.moya.model; ...@@ -2,5 +2,5 @@ package fi.codecrew.moya.model;
public enum ProductLimitationType { public enum ProductLimitationType {
GLOBAL_BILLED, GLOBAL_BILL_PAID, GLOBAL_ACCOUNTEVENTS, USER_BILLED, USER_BILL_PAID, USER_ACCOUNTEVENTS, GLOBAL_BILLED, GLOBAL_BILL_PAID, GLOBAL_ACCOUNTEVENTS, USER_BILLED, USER_BILL_PAID, USER_ACCOUNTEVENTS, PLACE
} }
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
<f:facet name="header"> <f:facet name="header">
<h:outputText value="${i18n['product.boughtTotal']}" /> <h:outputText value="${i18n['product.boughtTotal']}" />
</f:facet> </f:facet>
<h:outputText value="#{sumline.total}"> <h:outputText value="#{sumline.active}">
<f:convertNumber /> <f:convertNumber />
</h:outputText> </h:outputText>
</h:column> </h:column>
...@@ -32,6 +32,14 @@ ...@@ -32,6 +32,14 @@
<f:convertNumber /> <f:convertNumber />
</h:outputText> </h:outputText>
</h:column> </h:column>
<h:column>
<f:facet name="header">
<h:outputText value="${i18n['product.expired']}" />
</f:facet>
<h:outputText value="#{sumline.expired}">
<f:convertNumber />
</h:outputText>
</h:column>
</h:dataTable> </h:dataTable>
</ui:define> </ui:define>
</ui:composition> </ui:composition>
......
...@@ -7,16 +7,18 @@ ...@@ -7,16 +7,18 @@
<f:event type="preRenderView" listener="#{lectureUserView.initView()}" /> <f:event type="preRenderView" listener="#{lectureUserView.initView()}" />
</f:metadata> </f:metadata>
<ui:define rendered="#{lectureUserView.lectureGroupsVisible}" name="title"> <ui:define rendered="#{lectureUserView.lectureGroupsVisible}" name="title">
<h1>#{i18n['viewlectures.title']}</h1> <h1>#{i18n['viewlectures.title']}</h1>
</ui:define> </ui:define>
<ui:define name="content"> <ui:define name="content">
<h:form id="viewlecturesform"> <h:form id="viewlecturesform">
<p:outputPanel styleClass="messagebox" rendered="#{!lectureUserView.participateActive}"> <p:outputPanel styleClass="messagebox" rendered="#{!lectureUserView.participateActive}">
<h2><p:outputLabel value="#{i18n['lecture.participateNotActive.title']}" /></h2> <h2>
<p:outputLabel value="#{i18n['lecture.participateNotActive.title']}" />
</h2>
<p:outputLabel value="#{i18n['lecture.participateNotActive.message']}" /> <p:outputLabel value="#{i18n['lecture.participateNotActive.message']}" />
</p:outputPanel> </p:outputPanel>
...@@ -32,13 +34,13 @@ ...@@ -32,13 +34,13 @@
<h:outputText value="#{lectureGroup.selectCount}" /> <h:outputText value="#{lectureGroup.selectCount}" />
</p:column> </p:column>
<p:column> <p:column>
<p:commandButton value="#{i18n['lectureGroup.view']}" actionListener="#{lectureUserView.selectCurrentLectureGroup}" update=":viewlecturesform:participatedLectures :viewlecturesform:availableLectures :viewlecturesform:title" onerror="location.reload(true)" /> <p:commandButton value="#{i18n['lectureGroup.view']}" actionListener="#{lectureUserView.selectCurrentLectureGroup}" update=":viewlecturesform:availableLectures:lecturelist :viewlecturesform:availableLectures:schedule :viewlecturesform:participatedLectures :viewlecturesform:title" onerror="location.reload(true)" />
</p:column> </p:column>
</p:dataTable> </p:dataTable>
</p:fieldset> </p:fieldset>
<h1> <h1>
<h:outputText id="title" value="#{lectureUserView.currentLectureGroup.name}" /> <h:outputText id="title" value="#{lectureUserView.currentLectureGroup.name}" />
</h1> </h1>
...@@ -62,39 +64,94 @@ ...@@ -62,39 +64,94 @@
<h:outputText value="#{lecture.participantsCount}" /> / <h:outputText value="#{lecture.maxParticipantsCount}" /> <h:outputText value="#{lecture.participantsCount}" /> / <h:outputText value="#{lecture.maxParticipantsCount}" />
</p:column> </p:column>
<p:column style="width:110px"> <p:column style="width:110px">
<p:commandButton value="#{i18n['lecture.unparticipate']}" actionListener="#{lectureUserView.unParticipateCurrent}" update=":viewlecturesform:availableLectures :viewlecturesform:participatedLectures" onerror="location.reload(true)" /> <p:commandButton value="#{i18n['lecture.unparticipate']}" actionListener="#{lectureUserView.unParticipateCurrent}" update=":viewlecturesform:availableLectures:lecturelist :viewlecturesform:availableLectures:schedule :viewlecturesform:participatedLectures" onerror="location.reload(true)" />
</p:column>
</p:dataTable>
</p:fieldset>
<br /><br />
<p:fieldset id="availableLectures" legend="#{i18n['lecture.availableLectures']}" >
<p:dataTable value="#{lectureUserView.lectures}" var="lecture">
<p:column headerText="#{i18n['lecture.name']}" sortBy="#{lecture.name}" style="width:125px">
<h:outputText value="#{lecture.name}" />
</p:column>
<p:column headerText="#{i18n['lecture.description']}" sortBy="#{lecture.description}">
<h:outputText value="#{lecture.description}" />
</p:column>
<p:column headerText="#{i18n['lecture.hours']}" sortBy="#{lecture.hours}" style="width:110px">
<h:outputText value="#{lecture.hours}" />
</p:column>
<p:column headerText="#{i18n['lecture.startTime']}" sortBy="#{lecture.startTime}" style="width:110px">
<h:outputText value="#{lecture.startTime}">
<f:convertDateTime pattern="#{sessionHandler.datetimeFormat}" timeZone="#{sessionHandler.timezone}" />
</h:outputText>
</p:column>
<p:column headerText="#{i18n['lecture.participants']}" sortBy="#{lecture.participantsCount}" style="width:110px">
<h:outputText value="#{lecture.participantsCount}" /> / <h:outputText value="#{lecture.maxParticipantsCount}" />
</p:column>
<p:column style="width:80px">
<p:commandButton value="#{i18n['lecture.participate']}" rendered="#{!lectureUserView.currentGroupFull and !lecture.full and lectureUserView.participateActive}" actionListener="#{lectureUserView.participateCurrent}" update=":viewlecturesform:availableLectures :viewlecturesform:participatedLectures" onerror="location.reload(true)" />
<h:outputText value="#{i18n['lecture.full']}" rendered="#{lecture.full}" />
<h:outputText value="#{i18n['lecture.groupFull']}" rendered="#{lectureUserView.currentGroupFull}" />
</p:column> </p:column>
</p:dataTable> </p:dataTable>
</p:fieldset> </p:fieldset>
<br />
<br />
<h2>#{i18n['lecture.availableLectures']}</h2>
<p:tabView id="availableLectures">
<p:tab title="#{i18n['lecture.availableLecturesList']}">
<p:dataTable id="lecturelist" value="#{lectureUserView.lectures}" var="lecture">
<p:column headerText="#{i18n['lecture.name']}" sortBy="#{lecture.name}" style="width:125px">
<h:outputText value="#{lecture.name}" />
</p:column>
<p:column headerText="#{i18n['lecture.description']}" sortBy="#{lecture.description}">
<h:outputText value="#{lecture.description}" />
</p:column>
<p:column headerText="#{i18n['lecture.hours']}" sortBy="#{lecture.hours}" style="width:110px">
<h:outputText value="#{lecture.hours}" />
</p:column>
<p:column headerText="#{i18n['lecture.startTime']}" sortBy="#{lecture.startTime}" style="width:110px">
<h:outputText value="#{lecture.startTime}">
<f:convertDateTime pattern="#{sessionHandler.datetimeFormat}" timeZone="#{sessionHandler.timezone}" />
</h:outputText>
</p:column>
<p:column headerText="#{i18n['lecture.participants']}" sortBy="#{lecture.participantsCount}" style="width:110px">
<h:outputText value="#{lecture.participantsCount}" /> / <h:outputText value="#{lecture.maxParticipantsCount}" />
</p:column>
<p:column style="width:80px">
<p:commandButton value="#{i18n['lecture.participate']}" rendered="#{!lectureUserView.currentGroupFull and !lecture.full and lectureUserView.participateActive}" actionListener="#{lectureUserView.participateCurrent}" update=":viewlecturesform:availableLectures :viewlecturesform:participatedLectures" onerror="location.reload(true)" />
<h:outputText value="#{i18n['lecture.full']}" rendered="#{lecture.full}" />&nbsp;
<h:outputText value="#{i18n['lecture.groupFull']}" rendered="#{lectureUserView.currentGroupFull}" />
</p:column>
</p:dataTable>
</p:tab>
<p:tab title="#{i18n['lecture.availableLecturesCalendar']}">
<p:schedule id="schedule" axisFormat="H:mm" timeFormat="H:mm" timeZone="#{sessionHandler.timezone}" initialDate="#{lectureUserView.scheduleInitDate}" value="#{lectureUserView.coursesCalendar}" locale="#{sessionHandler.locale}" tooltip="true" draggable="false" resizable="false" view="agendaDay" allDaySlot="false">
<p:ajax event="eventSelect" listener="#{lectureUserView.onLecureCalendarEventSelect}" update=":viewlecturesform:participatedLectures :viewlecturesform:availableLectures:schedule" />
</p:schedule>
</p:tab>
</p:tabView>
</h:form> </h:form>
<script type="text/javascript">
PrimeFaces.locales['fi'] = {
closeText : 'Sulje',
prevText : 'Edellinen',
nextText : 'Seuraava',
currentText : 'Tänään',
monthNames : [ 'Tammikuu','Helmikuu','Maaliskuu','Huhtikuu','Toukokuu','Kesäkuu','Heinäkuu','Elokuu','Syyskuu','Lokakuu','Marraskuu', 'Joulukuu' ],
monthNamesShort : [ 'Tammikuu', 'Helmikuu','Maaliskuu','Huhtikuu','Toukokuu','Kesäkuu','Heinäkuu','Elokuu','Syyskuu','Lokakuu','Marraskuu','Joulukuu'],
dayNames : [ 'Sunnuntai','Maanantai','Tiistain','Keskiviikko','Torstai','Perjantai','Lauantai' ],
dayNamesShort : [ 'Su','Ma','Ti','Ke','To','Pe','La' ],
dayNamesMin : [ 'Su','Ma','Ti','Ke','To','Pe','La' ],
weekHeader : 'vk',
firstDay : 1,
isRTL : false,
showMonthAfterYear : false,
yearSuffix : '',
month : 'Kuukausi',
week : 'Viikko',
day : 'Päivä',
allDayText : 'Koko päivä'
};
PrimeFaces.locales['und'] = {
closeText : 'Sulje',
prevText : 'Edellinen',
nextText : 'Seuraava',
currentText : 'Tänään',
monthNames : [ 'Tammikuu','Helmikuu','Maaliskuu','Huhtikuu','Toukokuu','Kesäkuu','Heinäkuu','Elokuu','Syyskuu','Lokakuu','Marraskuu', 'Joulukuu' ],
monthNamesShort : [ 'Tammikuu', 'Helmikuu','Maaliskuu','Huhtikuu','Toukokuu','Kesäkuu','Heinäkuu','Elokuu','Syyskuu','Lokakuu','Marraskuu','Joulukuu'],
dayNames : [ 'Sunnuntai','Maanantai','Tiistain','Keskiviikko','Torstai','Perjantai','Lauantai' ],
dayNamesShort : [ 'Su','Ma','Ti','Ke','To','Pe','La' ],
dayNamesMin : [ 'Su','Ma','Ti','Ke','To','Pe','La' ],
weekHeader : 'vk',
firstDay : 1,
isRTL : false,
showMonthAfterYear : false,
yearSuffix : '',
month : 'Kuukausi',
week : 'Viikko',
day : 'Päivä',
allDayText : 'Koko päivä'
};
</script>
</ui:define> </ui:define>
......
...@@ -115,4 +115,31 @@ ...@@ -115,4 +115,31 @@
.success { .success {
color: #006600; color: #006600;
} }
\ No newline at end of file
.lectureCalendar,
.lectureCalendarParticipating,
.lectureCalendarDisabled {
border: 1px solid black;
padding: 3px;
font-size: 11px;
}
.lectureCalendarParticipating {
background-color: green;
}
.lectureCalendarDisabled {
background-color: gray;
}
.noBorders tr, .noBorders td {
background: none !important;
border: none !important;
}
.inlineRow > td {
padding: 0 !important;
margin: 0;
padding-left: 40px !important;
}
...@@ -218,3 +218,4 @@ th, td { ...@@ -218,3 +218,4 @@ th, td {
padding-right: 20px; padding-right: 20px;
padding-bottom: 20px; padding-bottom: 20px;
} }
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
<p>#{i18n['tournaments.admin.view_tournament_description_teamview_addition']}</p> <p>#{i18n['tournaments.admin.view_tournament_description_teamview_addition']}</p>
<h:form> <h:form>
<p:dataTable value="#{tournamentParticipantsView.tournament.participants}" var="participant"> <p:dataTable value="#{tournamentParticipantsView.tournament.participants}" var="participant">
<p:column style="width:2%"> <p:column style="width:20px">
<p:rowToggler /> <p:rowToggler />
</p:column> </p:column>
<p:column> <p:column>
...@@ -28,32 +28,40 @@ ...@@ -28,32 +28,40 @@
</f:facet> </f:facet>
<h:outputText value="#{participant.participator.nick}" /> <h:outputText value="#{participant.participator.nick}" />
</p:column> </p:column>
<p:rowExpansion> <p:rowExpansion styleClass="inlineRow">
<h:panelGrid id="display" columns="2" cellpadding="4" styleClass=" ui-widget-content grid"> <p:dataTable value="#{participant.teamMembers}" var="member">
<h:outputText value="#{i18n['tournament.team_members']}" /> <p:column>
<h:panelGroup> <f:facet name="header">
<ul> <h:outputText value="#{i18n['user.nick']}" />
<ui:repeat var="member" value="#{participant.teamMembers}"> </f:facet>
<li> <h:outputText value="#{member.eventUser.nick}" />
<h:outputText value="#{member.eventUser.nick}" /> </p:column>
<ul>
<li> <p:column>
<h:outputText value="#{tournamentParticipantsView.eventUserGameID[member.eventUser.id]}" /> <f:facet name="header">
</li> <h:outputText value="#{i18n['tournament.participant_gameid']}" />
<li> </f:facet>
<h:outputText value="#{member.eventUser.email}" /> <h:outputText value="#{tournamentParticipantsView.eventUserGameID[member.eventUser.id]}" />
</li> </p:column>
<li>
<ui:repeat rendered="#{not empty member.eventUser.groupMemberships}" var="groupMembership" value="#{member.eventUser.groupMemberships}"> <p:column>
<h:outputText value="#{groupMembership.placeReservation.name}" />&nbsp; <f:facet name="header">
</ui:repeat> <h:outputText value="#{i18n['user.email']}" />
</li> </f:facet>
</ul> <h:outputText value="#{member.eventUser.email}" />
</li> </p:column>
</ui:repeat>
</ul> <p:column>
</h:panelGroup> <f:facet name="header">
</h:panelGrid> <h:outputText value="#{i18n['place.code']}" />
</f:facet>
<ui:repeat rendered="#{not empty member.eventUser.groupMemberships}" var="groupMembership" value="#{member.eventUser.groupMemberships}">
<h:outputText value="#{groupMembership.placeReservation.name}" />&nbsp;
</ui:repeat>
</p:column>
</p:dataTable>
</p:rowExpansion> </p:rowExpansion>
</p:dataTable> </p:dataTable>
</h:form> </h:form>
......
...@@ -17,7 +17,8 @@ ...@@ -17,7 +17,8 @@
<p>#{i18n['tournaments.description']}</p> <p>#{i18n['tournaments.description']}</p>
<h2>#{i18n['tournaments.open_tournaments']}</h2> <h2>#{i18n['tournaments.open_tournaments']}</h2>
<p:dataTable value="#{tournamentListView.setupPhaseTournaments}" var="tournament"> <p:dataTable value="#{tournamentListView.setupPhaseTournaments}" var="tournament">
<p:column style="width:2%">
<p:column style="width:20px">
<p:rowToggler /> <p:rowToggler />
</p:column> </p:column>
<p:column> <p:column>
...@@ -96,7 +97,7 @@ ...@@ -96,7 +97,7 @@
</p:dataTable> </p:dataTable>
<h2>#{i18n['tournaments.setup_closed_tournaments']}</h2> <h2>#{i18n['tournaments.setup_closed_tournaments']}</h2>
<p:dataTable value="#{tournamentListView.setupClosedPhaseTournaments}" var="tournament"> <p:dataTable value="#{tournamentListView.setupClosedPhaseTournaments}" var="tournament">
<p:column style="width:2%"> <p:column style="width:20px">
<p:rowToggler /> <p:rowToggler />
</p:column> </p:column>
<p:column> <p:column>
......
...@@ -15,7 +15,6 @@ import javax.ws.rs.Produces; ...@@ -15,7 +15,6 @@ import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType; import javax.ws.rs.core.MediaType;
import fi.codecrew.moya.beans.PlaceGroupBeanLocal; import fi.codecrew.moya.beans.PlaceGroupBeanLocal;
import fi.codecrew.moya.beans.PlaceMapBeanLocal;
import fi.codecrew.moya.beans.ProductBeanLocal; import fi.codecrew.moya.beans.ProductBeanLocal;
import fi.codecrew.moya.model.AccountEvent; import fi.codecrew.moya.model.AccountEvent;
import fi.codecrew.moya.model.Product; import fi.codecrew.moya.model.Product;
...@@ -29,8 +28,6 @@ import fi.codecrew.moya.rest.highcharts.HcSeriesRoot; ...@@ -29,8 +28,6 @@ import fi.codecrew.moya.rest.highcharts.HcSeriesRoot;
public class AccountEventRestView { public class AccountEventRestView {
@EJB @EJB
private PlaceMapBeanLocal placemapbean;
@EJB
private PlaceGroupBeanLocal pgbean; private PlaceGroupBeanLocal pgbean;
@EJB @EJB
private ProductBeanLocal productBean; private ProductBeanLocal productBean;
......
...@@ -24,7 +24,6 @@ import fi.codecrew.moya.beans.EventBeanLocal; ...@@ -24,7 +24,6 @@ import fi.codecrew.moya.beans.EventBeanLocal;
import fi.codecrew.moya.beans.EventMapBeanLocal; import fi.codecrew.moya.beans.EventMapBeanLocal;
import fi.codecrew.moya.beans.PlaceBeanLocal; import fi.codecrew.moya.beans.PlaceBeanLocal;
import fi.codecrew.moya.beans.PlaceGroupBeanLocal; import fi.codecrew.moya.beans.PlaceGroupBeanLocal;
import fi.codecrew.moya.beans.PlaceMapBeanLocal;
import fi.codecrew.moya.beans.ProductBeanLocal; import fi.codecrew.moya.beans.ProductBeanLocal;
import fi.codecrew.moya.beans.UserBeanLocal; import fi.codecrew.moya.beans.UserBeanLocal;
import fi.codecrew.moya.exceptions.BortalCatchableException; import fi.codecrew.moya.exceptions.BortalCatchableException;
...@@ -46,8 +45,6 @@ public class MapAdminView { ...@@ -46,8 +45,6 @@ public class MapAdminView {
@EJB @EJB
private EventMapBeanLocal eventmapbean; private EventMapBeanLocal eventmapbean;
@EJB @EJB
private PlaceMapBeanLocal placemapbean;
@EJB
private PlaceGroupBeanLocal pgbean; private PlaceGroupBeanLocal pgbean;
@EJB @EJB
private EventBeanLocal eventbean; private EventBeanLocal eventbean;
...@@ -64,7 +61,7 @@ public class MapAdminView { ...@@ -64,7 +61,7 @@ public class MapAdminView {
@Path("/background/{mapId}") @Path("/background/{mapId}")
public Response getMapBg(@PathParam("mapId") Integer mapid) public Response getMapBg(@PathParam("mapId") Integer mapid)
{ {
EventMap map = placemapbean.findMap(mapid); EventMap map = placebean.findMap(mapid);
ByteArrayInputStream istream = new ByteArrayInputStream(map.getMapData()); ByteArrayInputStream istream = new ByteArrayInputStream(map.getMapData());
return Response.ok().entity(istream).type("image/jpeg").build(); return Response.ok().entity(istream).type("image/jpeg").build();
} }
...@@ -80,7 +77,7 @@ public class MapAdminView { ...@@ -80,7 +77,7 @@ public class MapAdminView {
@GET @GET
@Path("/places/{mapId}") @Path("/places/{mapId}")
public PlaceRoot getPlaces(@PathParam("mapId") Integer mapid) { public PlaceRoot getPlaces(@PathParam("mapId") Integer mapid) {
EventMap map = placemapbean.findMap(mapid); EventMap map = placebean.findMap(mapid);
PlaceRoot ret = new PlaceRoot(map); PlaceRoot ret = new PlaceRoot(map);
logger.info("returning map {} entity {}", mapid, ret); logger.info("returning map {} entity {}", mapid, ret);
return ret; return ret;
......
...@@ -13,8 +13,8 @@ import javax.ws.rs.Path; ...@@ -13,8 +13,8 @@ import javax.ws.rs.Path;
import javax.ws.rs.Produces; import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType; import javax.ws.rs.core.MediaType;
import fi.codecrew.moya.beans.PlaceBeanLocal;
import fi.codecrew.moya.beans.PlaceGroupBeanLocal; import fi.codecrew.moya.beans.PlaceGroupBeanLocal;
import fi.codecrew.moya.beans.PlaceMapBeanLocal;
import fi.codecrew.moya.model.EventMap; import fi.codecrew.moya.model.EventMap;
import fi.codecrew.moya.model.Place; import fi.codecrew.moya.model.Place;
import fi.codecrew.moya.model.PlaceGroup; import fi.codecrew.moya.model.PlaceGroup;
...@@ -26,14 +26,14 @@ import fi.codecrew.moya.model.PlaceGroup; ...@@ -26,14 +26,14 @@ import fi.codecrew.moya.model.PlaceGroup;
public class MapRestView { public class MapRestView {
@EJB @EJB
private PlaceMapBeanLocal placemapbean; private PlaceBeanLocal placebean;
@EJB @EJB
private PlaceGroupBeanLocal pgbean; private PlaceGroupBeanLocal pgbean;
@GET @GET
@Path("/dateJson") @Path("/dateJson")
public String getAllCards() { public String getAllCards() {
EventMap map = placemapbean.getActiveMap(); EventMap map = placebean.getActiveMap();
Map<Integer, Map<Integer, Map<Integer, Integer>>> counts = new HashMap<>(); Map<Integer, Map<Integer, Map<Integer, Integer>>> counts = new HashMap<>();
......
...@@ -30,7 +30,7 @@ import org.slf4j.LoggerFactory; ...@@ -30,7 +30,7 @@ import org.slf4j.LoggerFactory;
import fi.codecrew.moya.beans.LoggingBeanLocal; import fi.codecrew.moya.beans.LoggingBeanLocal;
import fi.codecrew.moya.beans.PermissionBeanLocal; import fi.codecrew.moya.beans.PermissionBeanLocal;
import fi.codecrew.moya.beans.PlaceMapBeanLocal; import fi.codecrew.moya.beans.PlaceBeanLocal;
import fi.codecrew.moya.beans.SecurityLogType; import fi.codecrew.moya.beans.SecurityLogType;
import fi.codecrew.moya.enums.apps.MapPermission; import fi.codecrew.moya.enums.apps.MapPermission;
import fi.codecrew.moya.model.EventMap; import fi.codecrew.moya.model.EventMap;
...@@ -49,7 +49,7 @@ public class PlaceMap extends HttpServlet { ...@@ -49,7 +49,7 @@ public class PlaceMap extends HttpServlet {
private static final long serialVersionUID = 8769688627918936258L; private static final long serialVersionUID = 8769688627918936258L;
@EJB @EJB
private transient PlaceMapBeanLocal placemapBean; private transient PlaceBeanLocal placeBean;
@EJB @EJB
private transient PermissionBeanLocal permbean; private transient PermissionBeanLocal permbean;
...@@ -87,7 +87,7 @@ public class PlaceMap extends HttpServlet { ...@@ -87,7 +87,7 @@ public class PlaceMap extends HttpServlet {
// Integer userId = getIntegerParameter(request, // Integer userId = getIntegerParameter(request,
// PARAMETER_CURRENT_USER_ID); Tämä saadaan beaneilta. // PARAMETER_CURRENT_USER_ID); Tämä saadaan beaneilta.
EventMap map = placemapBean.findMap(mapId); EventMap map = placeBean.findMap(mapId);
logger.debug("Mapid: {}", mapId); logger.debug("Mapid: {}", mapId);
ostream = response.getOutputStream(); ostream = response.getOutputStream();
......
...@@ -13,7 +13,6 @@ import org.slf4j.LoggerFactory; ...@@ -13,7 +13,6 @@ import org.slf4j.LoggerFactory;
import fi.codecrew.moya.beans.EventBeanLocal; import fi.codecrew.moya.beans.EventBeanLocal;
import fi.codecrew.moya.beans.PlaceBeanLocal; import fi.codecrew.moya.beans.PlaceBeanLocal;
import fi.codecrew.moya.beans.PlaceMapBeanLocal;
import fi.codecrew.moya.enums.apps.MapPermission; import fi.codecrew.moya.enums.apps.MapPermission;
import fi.codecrew.moya.model.EventMap; import fi.codecrew.moya.model.EventMap;
import fi.codecrew.moya.model.EventUser; import fi.codecrew.moya.model.EventUser;
...@@ -25,8 +24,6 @@ import fi.codecrew.moya.web.cdiview.GenericCDIView; ...@@ -25,8 +24,6 @@ import fi.codecrew.moya.web.cdiview.GenericCDIView;
public class MapView extends GenericCDIView { public class MapView extends GenericCDIView {
private static final long serialVersionUID = 2374905512998240551L; private static final long serialVersionUID = 2374905512998240551L;
@EJB
private transient PlaceMapBeanLocal placeMapBean;
@Inject @Inject
@SelectedUser @SelectedUser
...@@ -79,7 +76,7 @@ public class MapView extends GenericCDIView { ...@@ -79,7 +76,7 @@ public class MapView extends GenericCDIView {
} }
public Long getPlacesLeftToSelect() { public Long getPlacesLeftToSelect() {
Long ret = placeMapBean.selectablePlaceCount(getActiveMap()); Long ret = placeBean.selectablePlaceCount(getActiveMap());
logger.debug("Got {} places left for map {}", ret, getActiveMap()); logger.debug("Got {} places left for map {}", ret, getActiveMap());
return ret; return ret;
...@@ -88,7 +85,7 @@ public class MapView extends GenericCDIView { ...@@ -88,7 +85,7 @@ public class MapView extends GenericCDIView {
public Long getAvailablePlaces() public Long getAvailablePlaces()
{ {
Long ret = placeMapBean.availablePlaceCount(getActiveMap()); Long ret = placeBean.availablePlaceCount(getActiveMap());
logger.debug("Got {} availbale places for map {}", ret, getActiveMap()); logger.debug("Got {} availbale places for map {}", ret, getActiveMap());
return ret; return ret;
...@@ -98,7 +95,7 @@ public class MapView extends GenericCDIView { ...@@ -98,7 +95,7 @@ public class MapView extends GenericCDIView {
@Produces @Produces
public EventMap getActiveMap() { public EventMap getActiveMap() {
if (activeMap == null) { if (activeMap == null) {
activeMap = placeMapBean.getActiveMap(); activeMap = placeBean.getActiveMap();
} }
return activeMap; return activeMap;
......
...@@ -36,7 +36,7 @@ public class TournamentParticipantsView extends GenericCDIView { ...@@ -36,7 +36,7 @@ public class TournamentParticipantsView extends GenericCDIView {
if(gid != null) if(gid != null)
eventUserGameID.put(ttm.getEventUser().getId(), gid.getIdentifier()); eventUserGameID.put(ttm.getEventUser().getId(), gid.getIdentifier());
else else
eventUserGameID.put(ttm.getEventUser().getId(), "n/a"); eventUserGameID.put(ttm.getEventUser().getId(), ttm.getEventUser().getUser().getNick());
} }
} }
} }
......
package fi.codecrew.moya.web.lecture; package fi.codecrew.moya.web.lecture;
import java.util.Date;
import java.util.List; import java.util.List;
import javax.ejb.EJB; import javax.ejb.EJB;
...@@ -8,12 +9,17 @@ import javax.faces.model.ListDataModel; ...@@ -8,12 +9,17 @@ import javax.faces.model.ListDataModel;
import javax.inject.Inject; import javax.inject.Inject;
import javax.inject.Named; import javax.inject.Named;
import org.primefaces.event.SelectEvent;
import org.primefaces.model.DefaultScheduleEvent;
import org.primefaces.model.DefaultScheduleModel;
import org.primefaces.model.ScheduleModel;
import fi.codecrew.moya.beans.EventBeanLocal; import fi.codecrew.moya.beans.EventBeanLocal;
import fi.codecrew.moya.beans.LectureBeanLocal; import fi.codecrew.moya.beans.LectureBeanLocal;
import fi.codecrew.moya.beans.UserBeanLocal;
import fi.codecrew.moya.enums.apps.LecturePermission; import fi.codecrew.moya.enums.apps.LecturePermission;
import fi.codecrew.moya.model.Lecture; import fi.codecrew.moya.model.Lecture;
import fi.codecrew.moya.model.LectureGroup; import fi.codecrew.moya.model.LectureGroup;
import fi.codecrew.moya.utilities.I18n;
import fi.codecrew.moya.web.cdiview.GenericCDIView; import fi.codecrew.moya.web.cdiview.GenericCDIView;
import fi.codecrew.moya.web.cdiview.user.UserView; import fi.codecrew.moya.web.cdiview.user.UserView;
...@@ -32,26 +38,28 @@ public class LectureUserView extends GenericCDIView { ...@@ -32,26 +38,28 @@ public class LectureUserView extends GenericCDIView {
@EJB @EJB
EventBeanLocal eventBean; EventBeanLocal eventBean;
ListDataModel<LectureGroup> lectureGroups = null; ListDataModel<LectureGroup> lectureGroups = null;
ListDataModel<Lecture> lectures = null; ListDataModel<Lecture> lectures = null;
ListDataModel<Lecture> participatedLectures = null; ListDataModel<Lecture> participatedLectures = null;
LectureGroup currentLectureGroup; LectureGroup currentLectureGroup;
ScheduleModel coursesCalendar = null;
Date curDate = null;
public void initView() { public void initView() {
if (super.requirePermissions(LecturePermission.VIEW)) { if (super.requirePermissions(LecturePermission.VIEW)) {
super.beginConversation(); super.beginConversation();
} }
} }
public boolean isLectureGroupsVisible() { public boolean isLectureGroupsVisible() {
if(lectureBean.getLectureGroups().size() <= 1) if (lectureBean.getLectureGroups().size() <= 1)
return false; return false;
return true; return true;
} }
public boolean isParticipateActive() { public boolean isParticipateActive() {
return lectureBean.isUserCanParticipate(userView.getCurrentUser()); return lectureBean.isUserCanParticipate(userView.getCurrentUser());
} }
...@@ -84,7 +92,7 @@ public class LectureUserView extends GenericCDIView { ...@@ -84,7 +92,7 @@ public class LectureUserView extends GenericCDIView {
if (currentLectureGroup == null) if (currentLectureGroup == null)
return new ListDataModel<Lecture>(); return new ListDataModel<Lecture>();
if(lectures == null) if (lectures == null)
lectures = new ListDataModel<Lecture>(lectureBean.findAvailableLectures(getCurrentLectureGroup(), userView.getCurrentUser())); lectures = new ListDataModel<Lecture>(lectureBean.findAvailableLectures(getCurrentLectureGroup(), userView.getCurrentUser()));
return lectures; return lectures;
...@@ -96,21 +104,91 @@ public class LectureUserView extends GenericCDIView { ...@@ -96,21 +104,91 @@ public class LectureUserView extends GenericCDIView {
return participatedLectures; return participatedLectures;
} }
public ScheduleModel getCoursesCalendar() {
if (coursesCalendar == null) {
coursesCalendar = new DefaultScheduleModel();
for (Lecture lecture : lectureBean.findAvailableLectures(getCurrentLectureGroup(), userView.getCurrentUser())) {
String altinfo = "\n" + lecture.getDescription() + "\n";
if (lecture.isFull())
altinfo += "\n" + I18n.get("lecture.full");
if (isCurrentGroupFull())
altinfo += "\n" + I18n.get("lecture.groupFull");
DefaultScheduleEvent event = new DefaultScheduleEvent(lecture.getName() + altinfo, lecture.getStartTime(), lecture.getEndTime(), lecture);
event.setDescription(lecture.getDescription());
if (lecture.isFull() || isCurrentGroupFull()) {
event.setStyleClass("lectureCalendarDisabled");
} else {
event.setStyleClass("lectureCalendar");
}
coursesCalendar.addEvent(event);
}
for (Lecture lecture : lectureBean.getParticipatedLectures(userView.getCurrentUser())) {
String altinfo = "\n" + lecture.getDescription() + "\n\n" + I18n.get("lecture.participating");
DefaultScheduleEvent event = new DefaultScheduleEvent(lecture.getName() + altinfo, lecture.getStartTime(), lecture.getEndTime(), lecture);
event.setDescription(lecture.getDescription());
event.setStyleClass("lectureCalendarParticipating");
coursesCalendar.addEvent(event);
}
}
return coursesCalendar;
}
public void onLecureCalendarEventSelect(SelectEvent selectEvent) {
Lecture lecture = (Lecture) ((DefaultScheduleEvent) selectEvent.getObject()).getData();
lectureBean.participate(userView.getCurrentUser(), lecture);
// super.addFaceMessage("lecture.participated");
curDate = lecture.getStartTime();
this.lectures = null;
this.coursesCalendar = null;
}
public void onLecureCalendarDateSelect(SelectEvent selectEvent) {
}
public Date getScheduleInitDate() {
if (curDate != null)
return curDate;
Lecture lecture = lectureBean.getFirstLecture();
if (lecture == null)
return null;
return lecture.getStartTime();
}
public void participateCurrent() { public void participateCurrent() {
if(!isParticipateActive()) { if (!isParticipateActive()) {
return; return;
} }
if (lectures != null && lectures.isRowAvailable()) { if (lectures != null && lectures.isRowAvailable()) {
Lecture lecture = lectures.getRowData(); Lecture lecture = lectures.getRowData();
lectureBean.participate(userView.getCurrentUser(), lecture); lectureBean.participate(userView.getCurrentUser(), lecture);
super.addFaceMessage("lecture.participated"); super.addFaceMessage("lecture.participated");
this.lectures = null; this.lectures = null;
this.coursesCalendar = null;
} }
} }
...@@ -118,20 +196,20 @@ public class LectureUserView extends GenericCDIView { ...@@ -118,20 +196,20 @@ public class LectureUserView extends GenericCDIView {
if (participatedLectures != null && participatedLectures.isRowAvailable()) { if (participatedLectures != null && participatedLectures.isRowAvailable()) {
Lecture lecture = participatedLectures.getRowData(); Lecture lecture = participatedLectures.getRowData();
lectureBean.unparticipate(userView.getCurrentUser(), lecture); lectureBean.unparticipate(userView.getCurrentUser(), lecture);
super.addFaceMessage("lecture.unparticipated"); super.addFaceMessage("lecture.unparticipated");
this.lectures = null; this.lectures = null;
this.coursesCalendar = null;
} }
} }
public boolean isCurrentGroupFull() { public boolean isCurrentGroupFull() {
return (lectureBean.userLectureSelectsLeft(getCurrentLectureGroup(), userView.getCurrentUser()) <= 0); return (lectureBean.userLectureSelectsLeft(getCurrentLectureGroup(), userView.getCurrentUser()) <= 0);
} }
public int getCurrentGroupParticipateCount() { public int getCurrentGroupParticipateCount() {
return lectureBean.userLectureSelects(getCurrentLectureGroup(), userView.getCurrentUser()); return lectureBean.userLectureSelects(getCurrentLectureGroup(), userView.getCurrentUser());
} }
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!