Examples of Pet


Examples of org.plugtree.examples.model.Pet


        // Create a Person
        Person person = new Person("Salaboy!");
        // Create a Pet
        Pet pet = new Pet("mittens", "on a limb", Pet.PetType.CAT);
        // Set the Pet to the Person
        person.setPet(pet);

        // Now we will insert the Pet and the Person into the KnowledgeSession
        ksession.insert(pet);
        ksession.insert(person);

        // We will fire all the rules that were activated
        ksession.fireAllRules();
       
        Assert.assertEquals(pet.getPosition(), "on the street");
       
        //Dispose the knowledge session
        ksession.dispose();

    }
View Full Code Here

Examples of org.springframework.beans.Pet

    colours.add(Colour.BLUE);
    colours.add(Colour.RED);
    colours.add(Colour.GREEN);

    List pets = new ArrayList();
    pets.add(new Pet("Rudiger"));
    pets.add(new Pet("Spot"));
    pets.add(new Pet("Fluffy"));
    pets.add(new Pet("Mufty"));

    Set someObjects = new HashSet();
    someObjects.add(new ItemPet("PET1"));
    someObjects.add(new ItemPet("PET2"));
   
View Full Code Here

Examples of org.springframework.samples.petclinic.Pet

        pt1.setName("Cat");
        pt2.setName("Dog");
        pt1 = (PetType) system.save(pt1);
        pt2 = (PetType) system.save(pt2);
       
        Pet p1 = new Pet();
        Pet p2 = new Pet();
        p1.setName("Jack");
        p1.setBirthDate(new Date());
        p1.setType(pt1);
        p2.setName("Camilla");
        p2.setBirthDate(new Date());
        p2.setType(pt2);
        p1 = (Pet) system.save(p1);
        p2 = (Pet) system.save(p2);
       
        Owner owner = new Owner();
        owner.setFirstName("Tom");
View Full Code Here

Examples of org.springframework.samples.petclinic.Pet

    setSessionForm(true);
  }

  /** Method creates a new <code>Visit</code> with the correct <code>Pet</code> info */
  protected Object formBackingObject(HttpServletRequest request) throws ServletException {
    Pet pet = getClinic().loadPet(RequestUtils.getRequiredIntParameter(request, "petId"));
    Visit visit = new Visit();
    pet.addVisit(visit);
    return visit;
  }
View Full Code Here

Examples of org.springframework.samples.petclinic.Pet

    // get the Pet referred to by id in the request
    return getClinic().loadPet(RequestUtils.getRequiredIntParameter(request, "petId"));
  }

  protected void onBind(HttpServletRequest request, Object command) throws ServletException {
    Pet pet = (Pet) command;
    int typeId = RequestUtils.getRequiredIntParameter(request, "typeId");
    pet.setType((PetType) EntityUtils.getById(getClinic().getPetTypes(), PetType.class, typeId));
  }
View Full Code Here

Examples of org.springframework.samples.petclinic.Pet

    pet.setType((PetType) EntityUtils.getById(getClinic().getPetTypes(), PetType.class, typeId));
  }

  /** Method updates an existing Pet */
  protected ModelAndView onSubmit(Object command) throws ServletException {
    Pet pet = (Pet) command;
    // delegate the update to the business layer
    getClinic().storePet(pet);
    return new ModelAndView(getSuccessView(), "ownerId", pet.getOwner().getId());
  }
View Full Code Here

Examples of org.springframework.samples.petclinic.Pet

    return refData;
  }

  protected Object formBackingObject(HttpServletRequest request) throws ServletException {
    Owner owner = getClinic().loadOwner(RequestUtils.getRequiredIntParameter(request, "ownerId"));
    Pet pet = new Pet();
    owner.addPet(pet);
    return pet;
  }
View Full Code Here

Examples of org.springframework.samples.petclinic.Pet

    owner.addPet(pet);
    return pet;
  }

  protected void onBind(HttpServletRequest request, Object command) {
    Pet pet = (Pet) command;
    int typeId = Integer.parseInt(request.getParameter("typeId"));
    pet.setType((PetType) EntityUtils.getById(getClinic().getPetTypes(), PetType.class, typeId));
  }
View Full Code Here

Examples of org.springframework.samples.petclinic.Pet

    pet.setType((PetType) EntityUtils.getById(getClinic().getPetTypes(), PetType.class, typeId));
  }

  /** Method inserts a new Pet */
  protected ModelAndView onSubmit(Object command) throws ServletException {
    Pet pet = (Pet) command;
    // delegate the insert to the Business layer
    getClinic().storePet(pet);
    return new ModelAndView(getSuccessView(), "ownerId", pet.getOwner().getId());
  }
View Full Code Here

Examples of org.springframework.samples.petclinic.Pet

  public boolean supports(Class clazz) {
    return Pet.class.isAssignableFrom(clazz);
  }

  public void validate(Object obj, Errors errors) {
    Pet pet = (Pet) obj;

    String name = pet.getName();
    if (!StringUtils.hasLength(name)) {
      errors.rejectValue("name", "required", "required");
    }
    else if (pet.isNew() && pet.getOwner().getPet(name, true) != null) {
      errors.rejectValue("name", "duplicate", "already exists");
    }
  }
View Full Code Here
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.