Package com.scooterframework.orm.activerecord

Examples of com.scooterframework.orm.activerecord.ActiveRecord


   
    /**
     * <tt>update</tt> method updates an existing <tt>entry</tt> record.
     */
    public String update() {
        ActiveRecord entry = null;
        try {
            entry = Entry.findById(p("id"));
            if (entry != null) {
                entry.setData(params());
                entry.update();
                flash("notice", "Entry was successfully updated.");
            }
            else {
                flash("notice", "There is no entry record with primary key id as " + p("id") + ".");
            }
View Full Code Here


   
    /**
     * <tt>delete</tt> method deletes a <tt>entry</tt> record.
     */
    public String delete() {
        ActiveRecord entry = Entry.findById(p("id"));
        if (entry != null) {
            entry.delete();
            flash("notice", "Entry was successfully deleted.");
        }
        else {
            flash("notice", "There is no entry record with primary key id as " + p("id") + ".");
        }
View Full Code Here

    /**
     * <tt>show</tt> method returns a <tt>pet</tt> record.
     */
    public String show() {
        ActiveRecord pet = Pet.where("id=" + p("id")).includes("owner").getRecord();
        if (pet == null) {
            flash("notice", "There is no pet record with primary key as " + p("id"));
        }
        else {
            setViewData("pet", pet);
View Full Code Here

    /**
     * <tt>create</tt> method creates a new <tt>pet</tt> record.
     */
    public String create() {
      ActiveRecord owner = (ActiveRecord)getFromRequestData("owner");
        ActiveRecord newPet = null;
        try {
            newPet = Pet.newRecord();
            newPet.setData(params());
            newPet.save();
            flash("notice", "Pet was successfully created.");

            return redirectTo(R.resourceRecordPath("owners", owner));
        }
        catch(Exception ex) {
View Full Code Here

    /**
     * <tt>update</tt> method updates an existing <tt>pet</tt> record.
     */
    public String update() {
        ActiveRecord pet = null;
        try {
            pet = Pet.where("id=" + p("id")).includes("owner").getRecord();
            if (pet != null) {
                pet.setData(params());
                pet.update();
                flash("notice", "Pet was successfully updated.");

                return redirectTo(R.resourceRecordPath("owners", pet.associated("owner").getRecord()));
            }
            else {
                flash("notice", "There is no pet record with primary key as " + p("id") + ".");
            }
        }
View Full Code Here

    /**
     * <tt>create</tt> method creates a new <tt>visit</tt> record.
     */
    public String create() {
      ActiveRecord owner = Owner.where("id=" + p("owner_id")).getRecord();
        ActiveRecord newVisit = null;
        try {
            newVisit = Visit.newRecord();
            newVisit.setData(params());
            newVisit.save();
            flash("notice", "Visit was successfully created.");

            return redirectTo(R.resourceRecordPath("owners", owner));
        }
        catch(Exception ex) {
View Full Code Here

            setViewData("owners", owners);
            return renderView("index");
          }
          else if (owners.size() == 1) {
            //1 owner found
            ActiveRecord owner = (ActiveRecord)owners.iterator().next();
            setViewData("owner", owner);
            return redirectTo(R.resourceRecordPath("owners", owner));
          }
        }
View Full Code Here

    /**
     * <tt>show</tt> method returns a <tt>owner</tt> record.
     */
    public String show() {
        ActiveRecord owner = Owner.where("owners.id=" + p("id")).includes("pets=>visits, pets=>type").getRecord();
        if (owner == null) {
            flash("notice", "There is no owner record with primary key as " + p("id"));
        }
        else {
            setViewData("owner", owner);
View Full Code Here

    /**
     * <tt>create</tt> method creates a new <tt>owner</tt> record.
     */
    public String create() {
        ActiveRecord newOwner = null;
        try {
            newOwner = Owner.newRecord();
            newOwner.setData(params());
            newOwner.save();
            flash("notice", "Owner was successfully created.");

            return redirectTo(R.resourcePath("owners"));
        }
        catch(Exception ex) {
View Full Code Here

    /**
     * followings_tweets method
     */
    public String followings_tweets() {
        ActiveRecord loginUser = LoginHelper.loginUser();
        if (loginUser != null) {
            List tweets = loginUser.allAssociated("followings_tweets", "include:account").getRecords();
            setViewData("followings_tweets", tweets);
            setViewData("username", loginUser.getField("username"));
            setViewData("user", loginUser);
        }
      return null;
    }
View Full Code Here

TOP

Related Classes of com.scooterframework.orm.activerecord.ActiveRecord

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.