Package uk.org.woodcraft.bookings.dev

Source Code of uk.org.woodcraft.bookings.dev.CreateTestDataAction

package uk.org.woodcraft.bookings.dev;

import javax.jdo.PersistenceManager;
import javax.jdo.Query;

import uk.org.woodcraft.bookings.auth.SecurityModel;
import uk.org.woodcraft.bookings.datamodel.Booking;
import uk.org.woodcraft.bookings.datamodel.Event;
import uk.org.woodcraft.bookings.datamodel.Organisation;
import uk.org.woodcraft.bookings.datamodel.Unit;
import uk.org.woodcraft.bookings.datamodel.Village;
import uk.org.woodcraft.bookings.persistence.PMF;
import uk.org.woodcraft.bookings.test.TestFixture;

import com.opensymphony.xwork2.ActionSupport;

public class CreateTestDataAction extends ActionSupport {
  private static final long serialVersionUID = 1L;

  @SuppressWarnings("rawtypes")
  public String execute(){
   
    SecurityModel.checkIsDevMode();
   
    PersistenceManager pm = PMF.get().getPersistenceManager();
   
    // Wipe out old data
    Class[] classesToDelete = new Class[]{
        Event.class, Organisation.class, Unit.class, Village.class, Booking.class
    };
   
    for(Class clazz: classesToDelete)
    {
      Query query = pm.newQuery(clazz);
        query.deletePersistentAll();
    }
   
 
    // Insert new data
    TestFixture.BASIC_DATA.setUp();
    addActionMessage("Successfully created test data");
    return SUCCESS;
  }
}
TOP

Related Classes of uk.org.woodcraft.bookings.dev.CreateTestDataAction

TOP
Copyright © 2018 www.massapi.com. 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.