diff --git a/src/main/java/org/olat/course/nodes/en/EnrollmentManager.java b/src/main/java/org/olat/course/nodes/en/EnrollmentManager.java index 4179d7b3db1edb4b25f63d254277e68a063e6f16..42ebb442d57a1e545bbb69db13af89b4bc5e609b 100644 --- a/src/main/java/org/olat/course/nodes/en/EnrollmentManager.java +++ b/src/main/java/org/olat/course/nodes/en/EnrollmentManager.java @@ -108,7 +108,7 @@ public class EnrollmentManager extends BasicManager { //reservation has the highest priority over max participant ResourceReservation reservation = acService.getReservation(identity, reloadedGroup.getResource()); logInfo("doEnroll - participantsCounter: " + participantsCounter + ", reservations: " + reservations + " maxParticipants: " + reloadedGroup.getMaxParticipants().intValue(), identity.getName()); - if (reservation == null || (participantsCounter + reservations) >= reloadedGroup.getMaxParticipants().intValue()) { + if (reservation == null && (participantsCounter + reservations) >= reloadedGroup.getMaxParticipants().intValue()) { // already full, show error and updated choose page again if (!reloadedGroup.getWaitingListEnabled().booleanValue()) { // No Waiting List => List is full diff --git a/src/main/resources/database/mysql/setupDatabase.sql b/src/main/resources/database/mysql/setupDatabase.sql index ae904ee0124b468ef7e4113b578de9a1fc7438ea..86744e93cd3f3d021bb6ff7fcd1b0908e233ae1c 100644 --- a/src/main/resources/database/mysql/setupDatabase.sql +++ b/src/main/resources/database/mysql/setupDatabase.sql @@ -933,6 +933,16 @@ create table if not exists o_ac_transaction ( primary key (transaction_id) ); +create table if not exists o_ac_reservation ( + reservation_id bigint NOT NULL, + creationdate datetime, + lastmodified datetime, + version mediumint unsigned not null, + fk_identity bigint not null, + fk_resource bigint not null, + primary key (reservation_id) +); + create table if not exists o_ac_paypal_transaction ( transaction_id int8 not null, version int8 not null, @@ -1297,6 +1307,7 @@ alter table o_ac_order ENGINE = InnoDB; alter table o_ac_order_part ENGINE = InnoDB; alter table o_ac_order_line ENGINE = InnoDB; alter table o_ac_transaction ENGINE = InnoDB; +alter table o_ac_offer ENGINE = InnoDB; alter table o_ac_paypal_transaction ENGINE = InnoDB; alter table o_as_eff_statement ENGINE = InnoDB; alter table o_as_user_course_infos ENGINE = InnoDB; diff --git a/src/main/resources/database/postgresql/alter_8_1_x_to_8_2_0.sql b/src/main/resources/database/postgresql/alter_8_1_x_to_8_2_0.sql index 7dbba80081dad3de73886a8ded3ad0efbfe7851f..1cabe48a32d7ae29ff8ed6c61475a9a9e7eb5043 100644 --- a/src/main/resources/database/postgresql/alter_8_1_x_to_8_2_0.sql +++ b/src/main/resources/database/postgresql/alter_8_1_x_to_8_2_0.sql @@ -159,27 +159,41 @@ create table o_ac_paypal_transaction ( order_part_id int8 not null, method_id int8 not null, success_uuid varchar(32) not null, - cancel_uuid varchar(32) not null, - amount_amount DECIMAL, - amount_currency_code VARCHAR(3), + cancel_uuid varchar(32) not null, + amount_amount DECIMAL, + amount_currency_code VARCHAR(3), pay_response_date timestamp, pay_key varchar(255), - ack varchar(255), - build varchar(255), - coorelation_id varchar(255), - payment_exec_status varchar(255), - ipn_transaction_id varchar(255), - ipn_transaction_status varchar(255), - ipn_sender_transaction_id varchar(255), - ipn_sender_transaction_status varchar(255), - ipn_sender_email varchar(255), - ipn_verify_sign varchar(255), - ipn_pending_reason varchar(255), - trx_status VARCHAR(32) not null default 'NEW', - trx_amount DECIMAL, - trx_currency_code VARCHAR(3), + ack varchar(255), + build varchar(255), + coorelation_id varchar(255), + payment_exec_status varchar(255), + ipn_transaction_id varchar(255), + ipn_transaction_status varchar(255), + ipn_sender_transaction_id varchar(255), + ipn_sender_transaction_status varchar(255), + ipn_sender_email varchar(255), + ipn_verify_sign varchar(255), + ipn_pending_reason varchar(255), + trx_status VARCHAR(32) not null default 'NEW', + trx_amount DECIMAL, + trx_currency_code VARCHAR(3), primary key (transaction_id) ); create index paypal_pay_key_idx on o_ac_paypal_transaction (pay_key); create index paypal_pay_trx_id_idx on o_ac_paypal_transaction (ipn_transaction_id); create index paypal_pay_s_trx_id_idx on o_ac_paypal_transaction (ipn_sender_transaction_id); + +create table if not exists o_ac_reservation ( + reservation_id int8 NOT NULL, + creationdate timestamp, + lastmodified timestamp, + version int4 not null, + fk_identity int8 not null, + fk_resource int8 not null, + primary key (reservation_id) +); + + + + diff --git a/src/main/resources/database/postgresql/setupDatabase.sql b/src/main/resources/database/postgresql/setupDatabase.sql index 141062171c5fe0efa54762a97f11bd3603c9d1f6..94a02dff1c118cde436f7e108f38bf5e97bbd1f7 100644 --- a/src/main/resources/database/postgresql/setupDatabase.sql +++ b/src/main/resources/database/postgresql/setupDatabase.sql @@ -797,6 +797,16 @@ create table o_ac_transaction ( primary key (transaction_id) ); +create table if not exists o_ac_reservation ( + reservation_id bigint NOT NULL, + creationdate datetime, + lastmodified datetime, + version mediumint unsigned not null, + fk_identity bigint not null, + fk_resource bigint not null, + primary key (reservation_id) +); + create table o_ac_paypal_transaction ( transaction_id int8 not null, version int8 not null, diff --git a/src/test/java/org/olat/group/test/BusinessGroupDAOTest.java b/src/test/java/org/olat/group/test/BusinessGroupDAOTest.java index a717207ea1862f00b8653010885d431d4c605576..8aa247b6a6e184e1fd3f65e95b81420ff081df88 100644 --- a/src/test/java/org/olat/group/test/BusinessGroupDAOTest.java +++ b/src/test/java/org/olat/group/test/BusinessGroupDAOTest.java @@ -22,6 +22,7 @@ package org.olat.group.test; import static org.junit.Assert.assertNotNull; import java.util.ArrayList; +import java.util.Calendar; import java.util.Collections; import java.util.Date; import java.util.List; @@ -924,6 +925,44 @@ public class BusinessGroupDAOTest extends OlatTestCase { } } + @Test + public void findPublicGroupsLimitedDate() { + //create a group with an access control limited by a valid date + BusinessGroup groupVisible = businessGroupDao.createAndPersist(null, "access-grp-2", "access-grp-2-desc", 0, 5, true, false, true, false, false); + //create and save an offer + Offer offer = acService.createOffer(groupVisible.getResource(), "TestBGWorkflow"); + + Calendar cal = Calendar.getInstance(); + cal.add(Calendar.HOUR_OF_DAY, -1); + offer.setValidFrom(cal.getTime()); + cal.add(Calendar.HOUR_OF_DAY, 2); + offer.setValidTo(cal.getTime()); + assertNotNull(offer); + acService.save(offer); + + //create a group with an access control limited by dates in the past + BusinessGroup oldGroup = businessGroupDao.createAndPersist(null, "access-grp-3", "access-grp-3-desc", 0, 5, true, false, true, false, false); + //create and save an offer + Offer oldOffer = acService.createOffer(oldGroup.getResource(), "TestBGWorkflow"); + cal.add(Calendar.HOUR_OF_DAY, -5); + oldOffer.setValidFrom(cal.getTime()); + cal.add(Calendar.HOUR_OF_DAY, -5); + oldOffer.setValidTo(cal.getTime()); + assertNotNull(oldOffer); + acService.save(oldOffer); + + dbInstance.commitAndCloseSession(); + + //retrieve the offer + SearchBusinessGroupParams paramsAll = new SearchBusinessGroupParams(); + paramsAll.setPublicGroups(Boolean.TRUE); + List<BusinessGroup> accessGroups = businessGroupDao.findBusinessGroups(paramsAll, null, 0, 0); + Assert.assertNotNull(accessGroups); + Assert.assertTrue(accessGroups.size() >= 1); + Assert.assertTrue(accessGroups.contains(groupVisible)); + Assert.assertFalse(accessGroups.contains(oldGroup)); + } + @Test public void findBusinessGroupsWithResources() { //create a group attach to a resource diff --git a/src/test/java/org/olat/test/AllTestsJunit4.java b/src/test/java/org/olat/test/AllTestsJunit4.java index c734890e47059f0f6bb8a40a5d30a4cb4dba9d0a..e0d2f333dfff480ecc9b8f9c73b8e67e81470963 100644 --- a/src/test/java/org/olat/test/AllTestsJunit4.java +++ b/src/test/java/org/olat/test/AllTestsJunit4.java @@ -155,6 +155,7 @@ import org.junit.runners.Suite; org.olat.resource.accesscontrol.ACOfferManagerTest.class, org.olat.resource.accesscontrol.ACOrderManagerTest.class, org.olat.resource.accesscontrol.ACTransactionManagerTest.class, + org.olat.resource.accesscontrol.ACReservationDAOTest.class, org.olat.core.util.vfs.VersionManagerTest.class, /** * Pure JUnit test without need of framework