Java Code Examples for org.springframework.samples.petclinic.model.Owner#getId()

The following examples show how to use org.springframework.samples.petclinic.model.Owner#getId() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: OwnerController.java    From DevOps-for-Web-Development with MIT License 6 votes vote down vote up
@RequestMapping(value = "/owners", method = RequestMethod.GET)
public String processFindForm(Owner owner, BindingResult result, Map<String, Object> model) {

    // allow parameterless GET request for /owners to return all records
    if (owner.getLastName() == null) {
        owner.setLastName(""); // empty string signifies broadest possible search
    }

    // find owners by last name
    Collection<Owner> results = this.clinicService.findOwnerByLastName(owner.getLastName());
    if (results.isEmpty()) {
        // no owners found
        result.rejectValue("lastName", "notFound", "not found");
        return "owners/findOwners";
    } else if (results.size() == 1) {
        // 1 owner found
        owner = results.iterator().next();
        return "redirect:/owners/" + owner.getId();
    } else {
        // multiple owners found
        model.put("selections", results);
        return "owners/ownersList";
    }
}
 
Example 2
Source File: OwnerController.java    From DevOps-for-Web-Development with MIT License 6 votes vote down vote up
@RequestMapping(value = "/owners", method = RequestMethod.GET)
public String processFindForm(Owner owner, BindingResult result, Map<String, Object> model) {

    // allow parameterless GET request for /owners to return all records
    if (owner.getLastName() == null) {
        owner.setLastName(""); // empty string signifies broadest possible search
    }

    // find owners by last name
    Collection<Owner> results = this.clinicService.findOwnerByLastName(owner.getLastName());
    if (results.isEmpty()) {
        // no owners found
        result.rejectValue("lastName", "notFound", "not found");
        return "owners/findOwners";
    } else if (results.size() == 1) {
        // 1 owner found
        owner = results.iterator().next();
        return "redirect:/owners/" + owner.getId();
    } else {
        // multiple owners found
        model.put("selections", results);
        return "owners/ownersList";
    }
}
 
Example 3
Source File: OwnerController.java    From docker-workflow-plugin with MIT License 6 votes vote down vote up
@RequestMapping(value = "/owners", method = RequestMethod.GET)
public String processFindForm(Owner owner, BindingResult result, Map<String, Object> model) {

    // allow parameterless GET request for /owners to return all records
    if (owner.getLastName() == null) {
        owner.setLastName(""); // empty string signifies broadest possible search
    }

    // find owners by last name
    Collection<Owner> results = this.clinicService.findOwnerByLastName(owner.getLastName());
    if (results.isEmpty()) {
        // no owners found
        result.rejectValue("lastName", "notFound", "not found");
        return "owners/findOwners";
    }
    else if (results.size() == 1) {
	// 1 owner found
	owner = results.iterator().next();
	return "redirect:/owners/" + owner.getId();
    }
    else {
        // multiple owners found
        model.put("selections", results);
        return "owners/ownersList";
    }
}
 
Example 4
Source File: OwnerController.java    From audit4j-demo with Apache License 2.0 6 votes vote down vote up
@RequestMapping(value = "/owners", method = RequestMethod.GET)
public String processFindForm(Owner owner, BindingResult result, Map<String, Object> model) {

    // allow parameterless GET request for /owners to return all records
    if (owner.getLastName() == null) {
        owner.setLastName(""); // empty string signifies broadest possible search
    }

    // find owners by last name
    Collection<Owner> results = this.clinicService.findOwnerByLastName(owner.getLastName());
    if (results.isEmpty()) {
        // no owners found
        result.rejectValue("lastName", "notFound", "not found");
        return "owners/findOwners";
    }
    else if (results.size() == 1) {
	// 1 owner found
	owner = results.iterator().next();
	return "redirect:/owners/" + owner.getId();
    }
    else {
        // multiple owners found
        model.put("selections", results);
        return "owners/ownersList";
    }
}
 
Example 5
Source File: OwnerController.java    From DevOps-for-Web-Development with MIT License 5 votes vote down vote up
@RequestMapping(value = "/owners/new", method = RequestMethod.POST)
public String processCreationForm(@Valid Owner owner, BindingResult result) {
    if (result.hasErrors()) {
        return "owners/createOrUpdateOwnerForm";
    } else {
        this.clinicService.saveOwner(owner);
        return "redirect:/owners/" + owner.getId();
    }
}
 
Example 6
Source File: JpaOwnerRepositoryImpl.java    From DevOps-for-Web-Development with MIT License 5 votes vote down vote up
@Override
public void save(Owner owner) {
    if (owner.getId() == null) {
        this.em.persist(owner);
    } else {
        this.em.merge(owner);
    }

}
 
Example 7
Source File: OwnerController.java    From DevOps-for-Web-Development with MIT License 5 votes vote down vote up
@RequestMapping(value = "/owners/new", method = RequestMethod.POST)
public String processCreationForm(@Valid Owner owner, BindingResult result) {
    if (result.hasErrors()) {
        return VIEWS_OWNER_CREATE_OR_UPDATE_FORM;
    } else {
        this.clinicService.saveOwner(owner);
        return "redirect:/owners/" + owner.getId();
    }
}
 
Example 8
Source File: JpaOwnerRepositoryImpl.java    From DevOps-for-Web-Development with MIT License 5 votes vote down vote up
@Override
public void save(Owner owner) {
    if (owner.getId() == null) {
        this.em.persist(owner);
    } else {
        this.em.merge(owner);
    }

}
 
Example 9
Source File: OwnerController.java    From docker-workflow-plugin with MIT License 5 votes vote down vote up
@RequestMapping(value = "/owners/new", method = RequestMethod.POST)
public String processCreationForm(@Valid Owner owner, BindingResult result, SessionStatus status) {
    if (result.hasErrors()) {
        return "owners/createOrUpdateOwnerForm";
    } else {
        this.clinicService.saveOwner(owner);
        status.setComplete();
        return "redirect:/owners/" + owner.getId();
    }
}
 
Example 10
Source File: JpaOwnerRepositoryImpl.java    From docker-workflow-plugin with MIT License 5 votes vote down vote up
@Override
public void save(Owner owner) {
	if (owner.getId() == null) {
		this.em.persist(owner);     		
	}
	else {
		this.em.merge(owner);    
	}

}
 
Example 11
Source File: OwnerController.java    From audit4j-demo with Apache License 2.0 5 votes vote down vote up
@RequestMapping(value = "/owners/new", method = RequestMethod.POST)
public String processCreationForm(@Valid Owner owner, BindingResult result, SessionStatus status) {
    if (result.hasErrors()) {
        return "owners/createOrUpdateOwnerForm";
    } else {
        this.clinicService.saveOwner(owner);
        status.setComplete();
        return "redirect:/owners/" + owner.getId();
    }
}
 
Example 12
Source File: JpaOwnerRepositoryImpl.java    From audit4j-demo with Apache License 2.0 5 votes vote down vote up
@Override
public void save(Owner owner) {
	if (owner.getId() == null) {
		this.em.persist(owner);     		
	}
	else {
		this.em.merge(owner);    
	}

}