Package uk.org.woodcraft.bookings.datamodel

Examples of uk.org.woodcraft.bookings.datamodel.Unit


      }
    }
   
    if(unitKey != null && unitKey.length() > 0)
    {
      Unit currentUnit = (Unit)sessionData.get(SessionConstants.CURRENT_UNIT);
      if (!currentUnit.getWebKey().equals(unitKey))
      {
        Unit newUnit = CannedQueries.unitByKey(KeyFactory.stringToKey(unitKey));
        if(newUnit == null)
          throw new IllegalArgumentException("Unit matching key "+unitKey+" not found");
       
        // Will throw if not permissioned
        SecurityModel.checkAllowed(Operation.READ, newUnit);
View Full Code Here


    Event event = CannedQueries.eventByName( TestConstants.EVENT1_NAME);
    Map<String, Object> session = new HashMap<String, Object>();
    ApplyCoCampDiscountsAction action = createNewAction(clock, event, session);
   
    Organisation testOrg = CannedQueries.orgByName(TestConstants.ORG1_NAME);
    Unit testUnit = CannedQueries.unitByName(TestConstants.UNIT1_NAME, testOrg);
   
    Map<Key, List<Booking>> bookings = action.getRelevantBookings(event);
   
    // Should have filtered out "Person booked after earlybird"
    TestUtils.assertNames(bookings.get(testUnit.getKeyCheckNotNull()), "Test person", "Test person 2");
   
    Unit testUnit2 = CannedQueries.unitByName(TestConstants.UNIT2_NAME, testOrg);
    TestUtils.assertNames(bookings.get(testUnit2.getKeyCheckNotNull()), "Test person in unit 2", "Second person in unit 2");
  }
View Full Code Here

    Event event = CannedQueries.eventByName( TestConstants.EVENT1_NAME);
    Map<String, Object> session = new HashMap<String, Object>();
    ApplyCoCampDiscountsAction action = createNewAction(clock, event, session);
   
    Organisation testOrg = CannedQueries.orgByName(TestConstants.ORG1_NAME);
    Unit testUnit = CannedQueries.unitByName(TestConstants.UNIT1_NAME, testOrg);
   
    Map<Unit, List<Transaction>> transactions = action.getRelevantTransactions(event);
   
    // Should have filtered out "Person booked after earlybird"
    TestUtils.assertNames(transactions.get(testUnit), "Payment 1", "Payment 2", "Payment 3","Refund 1", "Discount for early payment");
    Unit testUnit2 = CannedQueries.unitByName(TestConstants.UNIT2_NAME, testOrg);
    TestUtils.assertNames(transactions.get(testUnit2), "Unit 2 payment");
  }
View Full Code Here

        if(checkOrg != null && checkOrg.equals(user.getOrganisation())) permitted = true;
        if(checkUnit != null && checkUnit.getOrganisationKey().equals(user.getOrganisationKey())) permitted = true;
        if(checkUser != null && checkUser.getOrganisationKey().equals(user.getOrganisationKey())) permitted = true;
        if(checkBooking != null)
        {
          Unit unit= CannedQueries.unitByKey(checkBooking.getUnitKey());
          if (unit.getOrganisationKey().equals(user.getOrganisationKey())) permitted = true;
        }
      case UNIT_ADMIN:
        if(user.getUnit().equals(checkUnit)) permitted = true;
        if(checkUser != null && checkUser.getUnitKey().equals(user.getUnitKey())) permitted = true;
        if(checkBooking != null && checkBooking.getUnitKey().equals(user.getUnitKey())) permitted = true;
View Full Code Here

  {
    Organisation currentOrg = (Organisation)getSessionObject(SessionConstants.SIGNUP_ORG);
   
    Collection<Unit> units = new ArrayList<Unit>();
    if (currentOrg != null) units = CannedQueries.unitsForOrg(currentOrg.getKey(), false, false);
    Unit userAddedUnit = (Unit)getSessionObject(SessionConstants.SIGNUP_ADDED_UNIT);
    if (userAddedUnit != null && currentOrg != null && userAddedUnit.getOrganisationKey().equals(currentOrg.getKey())) {
      units.add(userAddedUnit);
    }
    return units;
  }
View Full Code Here

     
      Organisation selectedOrg = (Organisation)getSessionObject(SessionConstants.SIGNUP_ORG);
      if (selectedOrg != null)
        user.setOrganisationKey(selectedOrg.getKey());
     
      Unit selectedUnit = (Unit)getSessionObject(SessionConstants.SIGNUP_UNIT);
      if (selectedUnit != null)
        user.setUnitKey(selectedUnit.getKey());
     
      setModel(user);
    }
  }
View Full Code Here

  }
 
  @SkipValidation
  public String signupUnit() {
    if (unitKey == null) return INPUT;
    Unit unit = CannedQueries.unitByKey(unitKey);
    if (unit == null) return INPUT;
   
    setSessionObject(SessionConstants.SIGNUP_UNIT, unit);
   
    return SUCCESS;
View Full Code Here

  @Test
  public void testUnitByName() {
   
    Organisation org = CannedQueries.orgByName("Woodcraft Folk");   
    Unit unit = CannedQueries.unitByName("Unit 1", org);
    assertEquals("Unit 1", unit.getName());
    assertDetached(unit);
  }
View Full Code Here

  }

  @Test
  public void testBookingsForUnitAllEvents() {
    Organisation org = CannedQueries.orgByName("Woodcraft Folk");   
    Unit unit = CannedQueries.unitByName("Unit 1", org);
   
    Collection<Booking> bookings = CannedQueries.bookingsForUnitAllEvents(unit);
    TestUtils.assertNames(bookings, "Test person", "Test person 2", "Person booked after earlybird", "Test person in other event");
    assertDetached(bookings);
  }
View Full Code Here

  }
 
  @Test
  public void testBookingsForUnit() {
    Organisation org = CannedQueries.orgByName("Woodcraft Folk");   
    Unit unit = CannedQueries.unitByName("Unit 1", org);
    Event event1 = CannedQueries.eventByName(TestConstants.EVENT1_NAME);
   
    Collection<Booking> bookings = CannedQueries.bookingsForUnit(unit, event1);
    TestUtils.assertNames(bookings, "Test person", "Test person 2","Person booked after earlybird");
    assertDetached(bookings);
View Full Code Here

TOP

Related Classes of uk.org.woodcraft.bookings.datamodel.Unit

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.