just cosmetic changes - comments etc...

This commit is contained in:
Vitaliy Fedoriv 2016-11-12 23:04:58 +02:00
parent 7b310b1a6e
commit 056c1dfb94
30 changed files with 564 additions and 20 deletions

View file

@ -1,3 +1,19 @@
/*
* Copyright 2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.samples.petclinic.repository; package org.springframework.samples.petclinic.repository;
import java.util.Collection; import java.util.Collection;
@ -5,6 +21,11 @@ import java.util.Collection;
import org.springframework.dao.DataAccessException; import org.springframework.dao.DataAccessException;
import org.springframework.samples.petclinic.model.Owner; import org.springframework.samples.petclinic.model.Owner;
/**
* @author Vitaliy Fedoriv
*
*/
public interface OwnerRepositoryExt extends OwnerRepository { public interface OwnerRepositoryExt extends OwnerRepository {
Collection<Owner> findAll() throws DataAccessException; Collection<Owner> findAll() throws DataAccessException;

View file

@ -1,3 +1,19 @@
/*
* Copyright 2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.samples.petclinic.repository; package org.springframework.samples.petclinic.repository;
import java.util.Collection; import java.util.Collection;
@ -5,6 +21,11 @@ import java.util.Collection;
import org.springframework.dao.DataAccessException; import org.springframework.dao.DataAccessException;
import org.springframework.samples.petclinic.model.Pet; import org.springframework.samples.petclinic.model.Pet;
/**
* @author Vitaliy Fedoriv
*
*/
public interface PetRepositoryExt extends PetRepository { public interface PetRepositoryExt extends PetRepository {
Collection<Pet> findAll() throws DataAccessException; Collection<Pet> findAll() throws DataAccessException;

View file

@ -1,3 +1,19 @@
/*
* Copyright 2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.samples.petclinic.repository; package org.springframework.samples.petclinic.repository;
import java.util.Collection; import java.util.Collection;
@ -5,6 +21,11 @@ import java.util.Collection;
import org.springframework.dao.DataAccessException; import org.springframework.dao.DataAccessException;
import org.springframework.samples.petclinic.model.PetType; import org.springframework.samples.petclinic.model.PetType;
/**
* @author Vitaliy Fedoriv
*
*/
public interface PetTypeRepositoryExt { public interface PetTypeRepositoryExt {
PetType findById(int id) throws DataAccessException; PetType findById(int id) throws DataAccessException;

View file

@ -1,3 +1,19 @@
/*
* Copyright 2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.samples.petclinic.repository; package org.springframework.samples.petclinic.repository;
import java.util.Collection; import java.util.Collection;
@ -5,6 +21,11 @@ import java.util.Collection;
import org.springframework.dao.DataAccessException; import org.springframework.dao.DataAccessException;
import org.springframework.samples.petclinic.model.Specialty; import org.springframework.samples.petclinic.model.Specialty;
/**
* @author Vitaliy Fedoriv
*
*/
public interface SpecialtyRepositoryExt { public interface SpecialtyRepositoryExt {
Specialty findById(int id) throws DataAccessException; Specialty findById(int id) throws DataAccessException;

View file

@ -1,3 +1,19 @@
/*
* Copyright 2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.samples.petclinic.repository; package org.springframework.samples.petclinic.repository;
import java.util.Collection; import java.util.Collection;
@ -5,6 +21,11 @@ import java.util.Collection;
import org.springframework.dao.DataAccessException; import org.springframework.dao.DataAccessException;
import org.springframework.samples.petclinic.model.Vet; import org.springframework.samples.petclinic.model.Vet;
/**
* @author Vitaliy Fedoriv
*
*/
public interface VetRepositoryExt extends VetRepository { public interface VetRepositoryExt extends VetRepository {
Vet findById(int id) throws DataAccessException; Vet findById(int id) throws DataAccessException;

View file

@ -1,3 +1,19 @@
/*
* Copyright 2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.samples.petclinic.repository; package org.springframework.samples.petclinic.repository;
import java.util.Collection; import java.util.Collection;
@ -5,6 +21,11 @@ import java.util.Collection;
import org.springframework.dao.DataAccessException; import org.springframework.dao.DataAccessException;
import org.springframework.samples.petclinic.model.Visit; import org.springframework.samples.petclinic.model.Visit;
/**
* @author Vitaliy Fedoriv
*
*/
public interface VisitRepositoryExt extends VisitRepository { public interface VisitRepositoryExt extends VisitRepository {
Visit findById(int id) throws DataAccessException; Visit findById(int id) throws DataAccessException;

View file

@ -1,3 +1,19 @@
/*
* Copyright 2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.samples.petclinic.repository.jdbc; package org.springframework.samples.petclinic.repository.jdbc;
import java.util.Collection; import java.util.Collection;
@ -19,6 +35,11 @@ import org.springframework.samples.petclinic.model.Specialty;
import org.springframework.samples.petclinic.repository.SpecialtyRepositoryExt; import org.springframework.samples.petclinic.repository.SpecialtyRepositoryExt;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
/**
* @author Vitaliy Fedoriv
*
*/
@Repository @Repository
@Qualifier("SpecialtyRepositoryExt") @Qualifier("SpecialtyRepositoryExt")
public class JdbcSpecialtyRepositoryExtImpl implements SpecialtyRepositoryExt { public class JdbcSpecialtyRepositoryExtImpl implements SpecialtyRepositoryExt {
@ -77,6 +98,7 @@ public class JdbcSpecialtyRepositoryExtImpl implements SpecialtyRepositoryExt {
public void delete(Specialty specialty) throws DataAccessException { public void delete(Specialty specialty) throws DataAccessException {
Map<String, Object> params = new HashMap<>(); Map<String, Object> params = new HashMap<>();
params.put("id", specialty.getId()); params.put("id", specialty.getId());
this.namedParameterJdbcTemplate.update("DELETE FROM vet_specialties WHERE specialty_id=:id", params);
this.namedParameterJdbcTemplate.update("DELETE FROM specialties WHERE id=:id", params); this.namedParameterJdbcTemplate.update("DELETE FROM specialties WHERE id=:id", params);
} }

View file

@ -1,3 +1,19 @@
/*
* Copyright 2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.samples.petclinic.repository.jdbc; package org.springframework.samples.petclinic.repository.jdbc;
import java.sql.ResultSet; import java.sql.ResultSet;
@ -20,6 +36,11 @@ import org.springframework.samples.petclinic.model.Visit;
import org.springframework.samples.petclinic.repository.VisitRepositoryExt; import org.springframework.samples.petclinic.repository.VisitRepositoryExt;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
/**
* @author Vitaliy Fedoriv
*
*/
@Repository @Repository
@Qualifier("VisitRepositoryExt") @Qualifier("VisitRepositoryExt")
public class JdbcVisitRepositoryExtImpl extends JdbcVisitRepositoryImpl implements VisitRepositoryExt { public class JdbcVisitRepositoryExtImpl extends JdbcVisitRepositoryImpl implements VisitRepositoryExt {

View file

@ -1,3 +1,19 @@
/*
* Copyright 2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.samples.petclinic.repository.jpa; package org.springframework.samples.petclinic.repository.jpa;
import java.util.Collection; import java.util.Collection;
@ -12,6 +28,11 @@ import org.springframework.samples.petclinic.model.Owner;
import org.springframework.samples.petclinic.repository.OwnerRepositoryExt; import org.springframework.samples.petclinic.repository.OwnerRepositoryExt;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
/**
* @author Vitaliy Fedoriv
*
*/
@Repository @Repository
@Qualifier("OwnerRepositoryExt") @Qualifier("OwnerRepositoryExt")
public class JpaOwnerRepositoryExtImpl extends JpaOwnerRepositoryImpl implements OwnerRepositoryExt { public class JpaOwnerRepositoryExtImpl extends JpaOwnerRepositoryImpl implements OwnerRepositoryExt {

View file

@ -1,3 +1,19 @@
/*
* Copyright 2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.samples.petclinic.repository.jpa; package org.springframework.samples.petclinic.repository.jpa;
import java.util.Collection; import java.util.Collection;
@ -11,6 +27,11 @@ import org.springframework.samples.petclinic.model.Vet;
import org.springframework.samples.petclinic.repository.VetRepositoryExt; import org.springframework.samples.petclinic.repository.VetRepositoryExt;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
/**
* @author Vitaliy Fedoriv
*
*/
@Repository @Repository
@Qualifier("VetRepositoryExt") @Qualifier("VetRepositoryExt")
public class JpaVetRepositoryExtImpl extends JpaVetRepositoryImpl implements VetRepositoryExt { public class JpaVetRepositoryExtImpl extends JpaVetRepositoryImpl implements VetRepositoryExt {

View file

@ -1,7 +1,28 @@
/*
* Copyright 2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.samples.petclinic.repository.springdatajpa; package org.springframework.samples.petclinic.repository.springdatajpa;
import org.springframework.samples.petclinic.model.Pet; import org.springframework.samples.petclinic.model.Pet;
/**
* @author Vitaliy Fedoriv
*
*/
public interface PetRepositoryExtOverride { public interface PetRepositoryExtOverride {
public void delete(Pet pet); public void delete(Pet pet);

View file

@ -1,3 +1,19 @@
/*
* Copyright 2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.samples.petclinic.repository.springdatajpa; package org.springframework.samples.petclinic.repository.springdatajpa;
import java.util.Collection; import java.util.Collection;
@ -9,6 +25,11 @@ import org.springframework.data.repository.query.Param;
import org.springframework.samples.petclinic.model.Owner; import org.springframework.samples.petclinic.model.Owner;
import org.springframework.samples.petclinic.repository.OwnerRepositoryExt; import org.springframework.samples.petclinic.repository.OwnerRepositoryExt;
/**
* @author Vitaliy Fedoriv
*
*/
@Qualifier("OwnerRepositoryExt") @Qualifier("OwnerRepositoryExt")
public interface SpringDataOwnerRepositoryExt extends OwnerRepositoryExt, Repository<Owner, Integer> { public interface SpringDataOwnerRepositoryExt extends OwnerRepositoryExt, Repository<Owner, Integer> {

View file

@ -1,3 +1,19 @@
/*
* Copyright 2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.samples.petclinic.repository.springdatajpa; package org.springframework.samples.petclinic.repository.springdatajpa;
import java.util.List; import java.util.List;
@ -10,6 +26,11 @@ import org.springframework.samples.petclinic.model.Pet;
import org.springframework.samples.petclinic.model.PetType; import org.springframework.samples.petclinic.model.PetType;
import org.springframework.samples.petclinic.repository.PetRepositoryExt; import org.springframework.samples.petclinic.repository.PetRepositoryExt;
/**
* @author Vitaliy Fedoriv
*
*/
@Qualifier("PetRepositoryExt") @Qualifier("PetRepositoryExt")
public interface SpringDataPetRepositoryExt extends PetRepositoryExt, Repository<Pet, Integer>, PetRepositoryExtOverride { public interface SpringDataPetRepositoryExt extends PetRepositoryExt, Repository<Pet, Integer>, PetRepositoryExtOverride {

View file

@ -1,3 +1,19 @@
/*
* Copyright 2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.samples.petclinic.repository.springdatajpa; package org.springframework.samples.petclinic.repository.springdatajpa;
import javax.persistence.EntityManager; import javax.persistence.EntityManager;
@ -5,6 +21,11 @@ import javax.persistence.PersistenceContext;
import org.springframework.samples.petclinic.model.Pet; import org.springframework.samples.petclinic.model.Pet;
/**
* @author Vitaliy Fedoriv
*
*/
public class SpringDataPetRepositoryExtImpl implements PetRepositoryExtOverride { public class SpringDataPetRepositoryExtImpl implements PetRepositoryExtOverride {
@PersistenceContext @PersistenceContext

View file

@ -1,3 +1,19 @@
/*
* Copyright 2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.samples.petclinic.repository.springdatajpa; package org.springframework.samples.petclinic.repository.springdatajpa;
import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.annotation.Qualifier;
@ -5,6 +21,11 @@ import org.springframework.data.repository.Repository;
import org.springframework.samples.petclinic.model.Vet; import org.springframework.samples.petclinic.model.Vet;
import org.springframework.samples.petclinic.repository.VetRepositoryExt; import org.springframework.samples.petclinic.repository.VetRepositoryExt;
/**
* @author Vitaliy Fedoriv
*
*/
@Qualifier("VetRepositoryExt") @Qualifier("VetRepositoryExt")
public interface SpringDataVetRepositoryExt extends VetRepositoryExt, Repository<Vet, Integer> { public interface SpringDataVetRepositoryExt extends VetRepositoryExt, Repository<Vet, Integer> {

View file

@ -1,3 +1,19 @@
/*
* Copyright 2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.samples.petclinic.repository.springdatajpa; package org.springframework.samples.petclinic.repository.springdatajpa;
import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.annotation.Qualifier;
@ -5,6 +21,11 @@ import org.springframework.data.repository.Repository;
import org.springframework.samples.petclinic.model.Visit; import org.springframework.samples.petclinic.model.Visit;
import org.springframework.samples.petclinic.repository.VisitRepositoryExt; import org.springframework.samples.petclinic.repository.VisitRepositoryExt;
/**
* @author Vitaliy Fedoriv
*
*/
@Qualifier("VisitRepositoryExt") @Qualifier("VisitRepositoryExt")
public interface SpringDataVisitRepositoryExt extends VisitRepositoryExt, Repository<Visit, Integer>, VisitRepositoryExtOverride { public interface SpringDataVisitRepositoryExt extends VisitRepositoryExt, Repository<Visit, Integer>, VisitRepositoryExtOverride {

View file

@ -1,3 +1,19 @@
/*
* Copyright 2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.samples.petclinic.repository.springdatajpa; package org.springframework.samples.petclinic.repository.springdatajpa;
import javax.persistence.EntityManager; import javax.persistence.EntityManager;
@ -6,6 +22,11 @@ import javax.persistence.PersistenceContext;
import org.springframework.dao.DataAccessException; import org.springframework.dao.DataAccessException;
import org.springframework.samples.petclinic.model.Visit; import org.springframework.samples.petclinic.model.Visit;
/**
* @author Vitaliy Fedoriv
*
*/
public class SpringDataVisitRepositoryExtImpl implements VisitRepositoryExtOverride { public class SpringDataVisitRepositoryExtImpl implements VisitRepositoryExtOverride {
@PersistenceContext @PersistenceContext

View file

@ -1,7 +1,28 @@
/*
* Copyright 2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.samples.petclinic.repository.springdatajpa; package org.springframework.samples.petclinic.repository.springdatajpa;
import org.springframework.samples.petclinic.model.Visit; import org.springframework.samples.petclinic.model.Visit;
/**
* @author Vitaliy Fedoriv
*
*/
public interface VisitRepositoryExtOverride { public interface VisitRepositoryExtOverride {
public void delete(Visit visit); public void delete(Visit visit);

View file

@ -1,9 +1,30 @@
/*
* Copyright 2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.samples.petclinic.rest; package org.springframework.samples.petclinic.rest;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ControllerAdvice; import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.ExceptionHandler;
/**
* @author Vitaliy Fedoriv
*
*/
@ControllerAdvice @ControllerAdvice
public class ExceptionControllerAdvice { public class ExceptionControllerAdvice {

View file

@ -71,7 +71,8 @@ public class OwnerRestController {
@RequestMapping(value = "/{ownerId}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE) @RequestMapping(value = "/{ownerId}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public ResponseEntity<Owner> getOwner(@PathVariable("ownerId") int ownerId){ public ResponseEntity<Owner> getOwner(@PathVariable("ownerId") int ownerId){
Owner owner = this.clinicService.findOwnerById(ownerId); Owner owner = null;
owner = this.clinicService.findOwnerById(ownerId);
if(owner == null){ if(owner == null){
return new ResponseEntity<Owner>(HttpStatus.NOT_FOUND); return new ResponseEntity<Owner>(HttpStatus.NOT_FOUND);
} }
@ -115,7 +116,6 @@ public class OwnerRestController {
return new ResponseEntity<Void>(HttpStatus.NOT_FOUND); return new ResponseEntity<Void>(HttpStatus.NOT_FOUND);
} }
this.clinicService.deleteOwner(owner); this.clinicService.deleteOwner(owner);
// TODO delete error - FK etc.
return new ResponseEntity<Void>(HttpStatus.NO_CONTENT); return new ResponseEntity<Void>(HttpStatus.NO_CONTENT);
} }

View file

@ -81,7 +81,6 @@ public class PetTypeRestController {
return new ResponseEntity<Void>(HttpStatus.NOT_FOUND); return new ResponseEntity<Void>(HttpStatus.NOT_FOUND);
} }
this.clinicService.deletePetType(petType); this.clinicService.deletePetType(petType);
// TODO delete error - FK etc.
return new ResponseEntity<Void>(HttpStatus.NO_CONTENT); return new ResponseEntity<Void>(HttpStatus.NO_CONTENT);
} }

View file

@ -1,3 +1,19 @@
/*
* Copyright 2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.samples.petclinic.rest; package org.springframework.samples.petclinic.rest;
import java.util.ArrayList; import java.util.ArrayList;
@ -21,6 +37,11 @@ import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.util.UriComponentsBuilder; import org.springframework.web.util.UriComponentsBuilder;
/**
* @author Vitaliy Fedoriv
*
*/
@RestController @RestController
@RequestMapping("api/specialties") @RequestMapping("api/specialties")
public class SpecialtyRestController { public class SpecialtyRestController {
@ -81,7 +102,6 @@ public class SpecialtyRestController {
return new ResponseEntity<Void>(HttpStatus.NOT_FOUND); return new ResponseEntity<Void>(HttpStatus.NOT_FOUND);
} }
this.clinicService.deleteSpecialty(specialty); this.clinicService.deleteSpecialty(specialty);
// TODO delete error - FK etc.
return new ResponseEntity<Void>(HttpStatus.NO_CONTENT); return new ResponseEntity<Void>(HttpStatus.NO_CONTENT);
} }

View file

@ -102,7 +102,6 @@ public class VetRestController {
return new ResponseEntity<Void>(HttpStatus.NOT_FOUND); return new ResponseEntity<Void>(HttpStatus.NOT_FOUND);
} }
this.clinicService.deleteVet(vet); this.clinicService.deleteVet(vet);
// TODO delete error - FK etc.
return new ResponseEntity<Void>(HttpStatus.NO_CONTENT); return new ResponseEntity<Void>(HttpStatus.NO_CONTENT);
} }

View file

@ -1,3 +1,19 @@
/*
* Copyright 2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.samples.petclinic.rest; package org.springframework.samples.petclinic.rest;
import java.util.ArrayList; import java.util.ArrayList;
@ -21,6 +37,11 @@ import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.util.UriComponentsBuilder; import org.springframework.web.util.UriComponentsBuilder;
/**
* @author Vitaliy Fedoriv
*
*/
@RestController @RestController
@RequestMapping("api/visits") @RequestMapping("api/visits")
public class VisitRestController { public class VisitRestController {
@ -83,7 +104,6 @@ public class VisitRestController {
return new ResponseEntity<Void>(HttpStatus.NOT_FOUND); return new ResponseEntity<Void>(HttpStatus.NOT_FOUND);
} }
this.clinicService.deleteVisit(visit); this.clinicService.deleteVisit(visit);
// TODO delete error - FK etc.
return new ResponseEntity<Void>(HttpStatus.NO_CONTENT); return new ResponseEntity<Void>(HttpStatus.NO_CONTENT);
} }

View file

@ -1,3 +1,19 @@
/*
* Copyright 2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.samples.petclinic.service; package org.springframework.samples.petclinic.service;
import java.util.Collection; import java.util.Collection;
@ -10,37 +26,49 @@ import org.springframework.samples.petclinic.model.Specialty;
import org.springframework.samples.petclinic.model.Vet; import org.springframework.samples.petclinic.model.Vet;
import org.springframework.samples.petclinic.model.Visit; import org.springframework.samples.petclinic.model.Visit;
/**
* Used as a facade so all (incl.extended) controllers have a single point of entry
*
* @author Vitaliy Fedoriv
*/
public interface ClinicServiceExt extends ClinicService { public interface ClinicServiceExt extends ClinicService {
// Pet findPetById(int id) throws DataAccessException; // ----- Pet -----
// (in ClinicService) Pet findPetById(int id) throws DataAccessException;
Collection<Pet> findAllPets() throws DataAccessException; Collection<Pet> findAllPets() throws DataAccessException;
// void savePet(Pet pet) throws DataAccessException; // (in ClinicService) void savePet(Pet pet) throws DataAccessException;
void deletePet(Pet pet) throws DataAccessException; void deletePet(Pet pet) throws DataAccessException;
// Collection<Visit> findVisitsByPetId(int petId); // ----- Visit -----
// (in ClinicService) Collection<Visit> findVisitsByPetId(int petId);
Visit findVisitById(int visitId) throws DataAccessException; Visit findVisitById(int visitId) throws DataAccessException;
Collection<Visit> findAllVisits() throws DataAccessException; Collection<Visit> findAllVisits() throws DataAccessException;
// void saveVisit(Visit visit) throws DataAccessException; // (in ClinicService) void saveVisit(Visit visit) throws DataAccessException;
void deleteVisit(Visit visit) throws DataAccessException; void deleteVisit(Visit visit) throws DataAccessException;
// ----- Vet -----
Vet findVetById(int id) throws DataAccessException; Vet findVetById(int id) throws DataAccessException;
// Collection<Vet> findVets() throws DataAccessException; // (in ClinicService) Collection<Vet> findVets() throws DataAccessException;
Collection<Vet> findAllVets() throws DataAccessException; Collection<Vet> findAllVets() throws DataAccessException;
void saveVet(Vet vet) throws DataAccessException; void saveVet(Vet vet) throws DataAccessException;
void deleteVet(Vet vet) throws DataAccessException; void deleteVet(Vet vet) throws DataAccessException;
// Owner findOwnerById(int id) throws DataAccessException; // ----- Owner -----
// (in ClinicService) Owner findOwnerById(int id) throws DataAccessException;
Collection<Owner> findAllOwners() throws DataAccessException; Collection<Owner> findAllOwners() throws DataAccessException;
// void saveOwner(Owner owner) throws DataAccessException; // (in ClinicService) void saveOwner(Owner owner) throws DataAccessException;
void deleteOwner(Owner owner) throws DataAccessException; void deleteOwner(Owner owner) throws DataAccessException;
// Collection<Owner> findOwnerByLastName(String lastName) throws DataAccessException; // (in ClinicService) Collection<Owner> findOwnerByLastName(String lastName) throws DataAccessException;
// ----- PetType -----
PetType findPetTypeById(int petTypeId); PetType findPetTypeById(int petTypeId);
Collection<PetType> findAllPetTypes() throws DataAccessException; Collection<PetType> findAllPetTypes() throws DataAccessException;
// Collection<PetType> findPetTypes() throws DataAccessException; // (in ClinicService) Collection<PetType> findPetTypes() throws DataAccessException;
void savePetType(PetType petType) throws DataAccessException; void savePetType(PetType petType) throws DataAccessException;
void deletePetType(PetType petType) throws DataAccessException; void deletePetType(PetType petType) throws DataAccessException;
// ----- Specialty -----
Specialty findSpecialtyById(int specialtyId); Specialty findSpecialtyById(int specialtyId);
Collection<Specialty> findAllSpecialties() throws DataAccessException; Collection<Specialty> findAllSpecialties() throws DataAccessException;
void saveSpecialty(Specialty specialty) throws DataAccessException; void saveSpecialty(Specialty specialty) throws DataAccessException;

View file

@ -1,3 +1,19 @@
/*
* Copyright 2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.samples.petclinic.rest; package org.springframework.samples.petclinic.rest;
import static org.mockito.BDDMockito.given; import static org.mockito.BDDMockito.given;

View file

@ -1,3 +1,19 @@
/*
* Copyright 2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.samples.petclinic.rest; package org.springframework.samples.petclinic.rest;
import static org.mockito.BDDMockito.given; import static org.mockito.BDDMockito.given;

View file

@ -1,3 +1,19 @@
/*
* Copyright 2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.samples.petclinic.rest; package org.springframework.samples.petclinic.rest;
import static org.mockito.BDDMockito.given; import static org.mockito.BDDMockito.given;

View file

@ -1,3 +1,19 @@
/*
* Copyright 2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.samples.petclinic.rest; package org.springframework.samples.petclinic.rest;
import static org.mockito.BDDMockito.given; import static org.mockito.BDDMockito.given;
@ -27,12 +43,12 @@ import org.springframework.test.web.servlet.setup.MockMvcBuilders;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
/** /**
* Test class for {@link VetRestController} * Test class for {@link VetRestController}
* *
* @author Vitaliy Fedoriv * @author Vitaliy Fedoriv
*/ */
@RunWith(SpringJUnit4ClassRunner.class) @RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration({"classpath:spring/mvc-test-config.xml", "classpath:spring/mvc-core-config.xml"}) @ContextConfiguration({"classpath:spring/mvc-test-config.xml", "classpath:spring/mvc-core-config.xml"})
@WebAppConfiguration @WebAppConfiguration
@ -94,8 +110,6 @@ public class VetRestControllerTests {
@Test @Test
public void testGetAllVetsSuccess() throws Exception { public void testGetAllVetsSuccess() throws Exception {
//vets.remove(2);
//vets.remove(1);
given(this.clinicService.findAllVets()).willReturn(vets); given(this.clinicService.findAllVets()).willReturn(vets);
this.mockMvc.perform(get("/api/vets/") this.mockMvc.perform(get("/api/vets/")
.accept(MediaType.APPLICATION_JSON)) .accept(MediaType.APPLICATION_JSON))

View file

@ -1,3 +1,19 @@
/*
* Copyright 2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.samples.petclinic.rest; package org.springframework.samples.petclinic.rest;
import static org.mockito.BDDMockito.given; import static org.mockito.BDDMockito.given;
@ -31,12 +47,12 @@ import org.springframework.test.web.servlet.setup.MockMvcBuilders;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
/** /**
* Test class for {@link VisitRestController} * Test class for {@link VisitRestController}
* *
* @author Vitaliy Fedoriv * @author Vitaliy Fedoriv
*/ */
@RunWith(SpringJUnit4ClassRunner.class) @RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration({"classpath:spring/mvc-test-config.xml", "classpath:spring/mvc-core-config.xml"}) @ContextConfiguration({"classpath:spring/mvc-test-config.xml", "classpath:spring/mvc-core-config.xml"})
@WebAppConfiguration @WebAppConfiguration