From 056c1dfb94c15fb54f607ef4c043413d98e5eac0 Mon Sep 17 00:00:00 2001 From: Vitaliy Fedoriv Date: Sat, 12 Nov 2016 23:04:58 +0200 Subject: [PATCH] just cosmetic changes - comments etc... --- .../repository/OwnerRepositoryExt.java | 21 ++++++++ .../repository/PetRepositoryExt.java | 21 ++++++++ .../repository/PetTypeRepositoryExt.java | 21 ++++++++ .../repository/SpecialtyRepositoryExt.java | 21 ++++++++ .../repository/VetRepositoryExt.java | 21 ++++++++ .../repository/VisitRepositoryExt.java | 21 ++++++++ .../jdbc/JdbcSpecialtyRepositoryExtImpl.java | 22 +++++++++ .../jdbc/JdbcVisitRepositoryExtImpl.java | 21 ++++++++ .../jpa/JpaOwnerRepositoryExtImpl.java | 21 ++++++++ .../jpa/JpaVetRepositoryExtImpl.java | 21 ++++++++ .../PetRepositoryExtOverride.java | 21 ++++++++ .../SpringDataOwnerRepositoryExt.java | 21 ++++++++ .../SpringDataPetRepositoryExt.java | 21 ++++++++ .../SpringDataPetRepositoryExtImpl.java | 21 ++++++++ .../SpringDataVetRepositoryExt.java | 21 ++++++++ .../SpringDataVisitRepositoryExt.java | 21 ++++++++ .../SpringDataVisitRepositoryExtImpl.java | 21 ++++++++ .../VisitRepositoryExtOverride.java | 21 ++++++++ .../rest/ExceptionControllerAdvice.java | 21 ++++++++ .../petclinic/rest/OwnerRestController.java | 4 +- .../petclinic/rest/PetTypeRestController.java | 1 - .../rest/SpecialtyRestController.java | 22 ++++++++- .../petclinic/rest/VetRestController.java | 1 - .../petclinic/rest/VisitRestController.java | 22 ++++++++- .../petclinic/service/ClinicServiceExt.java | 48 +++++++++++++++---- .../rest/OwnerRestControllerTests.java | 16 +++++++ .../rest/PetRestControllerTests.java | 16 +++++++ .../rest/PetTypeRestControllerTests.java | 16 +++++++ .../rest/VetRestControllerTests.java | 20 ++++++-- .../rest/VisitRestControllerTests.java | 18 ++++++- 30 files changed, 564 insertions(+), 20 deletions(-) diff --git a/src/main/java/org/springframework/samples/petclinic/repository/OwnerRepositoryExt.java b/src/main/java/org/springframework/samples/petclinic/repository/OwnerRepositoryExt.java index f2a93b460..2d6359ac1 100644 --- a/src/main/java/org/springframework/samples/petclinic/repository/OwnerRepositoryExt.java +++ b/src/main/java/org/springframework/samples/petclinic/repository/OwnerRepositoryExt.java @@ -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; import java.util.Collection; @@ -5,6 +21,11 @@ import java.util.Collection; import org.springframework.dao.DataAccessException; import org.springframework.samples.petclinic.model.Owner; +/** + * @author Vitaliy Fedoriv + * + */ + public interface OwnerRepositoryExt extends OwnerRepository { Collection findAll() throws DataAccessException; diff --git a/src/main/java/org/springframework/samples/petclinic/repository/PetRepositoryExt.java b/src/main/java/org/springframework/samples/petclinic/repository/PetRepositoryExt.java index 90a3508d4..5f65699e9 100644 --- a/src/main/java/org/springframework/samples/petclinic/repository/PetRepositoryExt.java +++ b/src/main/java/org/springframework/samples/petclinic/repository/PetRepositoryExt.java @@ -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; import java.util.Collection; @@ -5,6 +21,11 @@ import java.util.Collection; import org.springframework.dao.DataAccessException; import org.springframework.samples.petclinic.model.Pet; +/** + * @author Vitaliy Fedoriv + * + */ + public interface PetRepositoryExt extends PetRepository { Collection findAll() throws DataAccessException; diff --git a/src/main/java/org/springframework/samples/petclinic/repository/PetTypeRepositoryExt.java b/src/main/java/org/springframework/samples/petclinic/repository/PetTypeRepositoryExt.java index 0657dedca..14c6e6648 100644 --- a/src/main/java/org/springframework/samples/petclinic/repository/PetTypeRepositoryExt.java +++ b/src/main/java/org/springframework/samples/petclinic/repository/PetTypeRepositoryExt.java @@ -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; import java.util.Collection; @@ -5,6 +21,11 @@ import java.util.Collection; import org.springframework.dao.DataAccessException; import org.springframework.samples.petclinic.model.PetType; +/** + * @author Vitaliy Fedoriv + * + */ + public interface PetTypeRepositoryExt { PetType findById(int id) throws DataAccessException; diff --git a/src/main/java/org/springframework/samples/petclinic/repository/SpecialtyRepositoryExt.java b/src/main/java/org/springframework/samples/petclinic/repository/SpecialtyRepositoryExt.java index e7a560aec..009715a25 100644 --- a/src/main/java/org/springframework/samples/petclinic/repository/SpecialtyRepositoryExt.java +++ b/src/main/java/org/springframework/samples/petclinic/repository/SpecialtyRepositoryExt.java @@ -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; import java.util.Collection; @@ -5,6 +21,11 @@ import java.util.Collection; import org.springframework.dao.DataAccessException; import org.springframework.samples.petclinic.model.Specialty; +/** + * @author Vitaliy Fedoriv + * + */ + public interface SpecialtyRepositoryExt { Specialty findById(int id) throws DataAccessException; diff --git a/src/main/java/org/springframework/samples/petclinic/repository/VetRepositoryExt.java b/src/main/java/org/springframework/samples/petclinic/repository/VetRepositoryExt.java index d52778493..7848f30a6 100644 --- a/src/main/java/org/springframework/samples/petclinic/repository/VetRepositoryExt.java +++ b/src/main/java/org/springframework/samples/petclinic/repository/VetRepositoryExt.java @@ -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; import java.util.Collection; @@ -5,6 +21,11 @@ import java.util.Collection; import org.springframework.dao.DataAccessException; import org.springframework.samples.petclinic.model.Vet; +/** + * @author Vitaliy Fedoriv + * + */ + public interface VetRepositoryExt extends VetRepository { Vet findById(int id) throws DataAccessException; diff --git a/src/main/java/org/springframework/samples/petclinic/repository/VisitRepositoryExt.java b/src/main/java/org/springframework/samples/petclinic/repository/VisitRepositoryExt.java index ecc9a6556..76fb1587d 100644 --- a/src/main/java/org/springframework/samples/petclinic/repository/VisitRepositoryExt.java +++ b/src/main/java/org/springframework/samples/petclinic/repository/VisitRepositoryExt.java @@ -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; import java.util.Collection; @@ -5,6 +21,11 @@ import java.util.Collection; import org.springframework.dao.DataAccessException; import org.springframework.samples.petclinic.model.Visit; +/** + * @author Vitaliy Fedoriv + * + */ + public interface VisitRepositoryExt extends VisitRepository { Visit findById(int id) throws DataAccessException; diff --git a/src/main/java/org/springframework/samples/petclinic/repository/jdbc/JdbcSpecialtyRepositoryExtImpl.java b/src/main/java/org/springframework/samples/petclinic/repository/jdbc/JdbcSpecialtyRepositoryExtImpl.java index 25dc8e216..c05d0caf7 100644 --- a/src/main/java/org/springframework/samples/petclinic/repository/jdbc/JdbcSpecialtyRepositoryExtImpl.java +++ b/src/main/java/org/springframework/samples/petclinic/repository/jdbc/JdbcSpecialtyRepositoryExtImpl.java @@ -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; 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.stereotype.Repository; +/** + * @author Vitaliy Fedoriv + * + */ + @Repository @Qualifier("SpecialtyRepositoryExt") public class JdbcSpecialtyRepositoryExtImpl implements SpecialtyRepositoryExt { @@ -77,6 +98,7 @@ public class JdbcSpecialtyRepositoryExtImpl implements SpecialtyRepositoryExt { public void delete(Specialty specialty) throws DataAccessException { Map params = new HashMap<>(); 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); } diff --git a/src/main/java/org/springframework/samples/petclinic/repository/jdbc/JdbcVisitRepositoryExtImpl.java b/src/main/java/org/springframework/samples/petclinic/repository/jdbc/JdbcVisitRepositoryExtImpl.java index a5ea29629..7ecdd475f 100644 --- a/src/main/java/org/springframework/samples/petclinic/repository/jdbc/JdbcVisitRepositoryExtImpl.java +++ b/src/main/java/org/springframework/samples/petclinic/repository/jdbc/JdbcVisitRepositoryExtImpl.java @@ -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; 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.stereotype.Repository; +/** + * @author Vitaliy Fedoriv + * + */ + @Repository @Qualifier("VisitRepositoryExt") public class JdbcVisitRepositoryExtImpl extends JdbcVisitRepositoryImpl implements VisitRepositoryExt { diff --git a/src/main/java/org/springframework/samples/petclinic/repository/jpa/JpaOwnerRepositoryExtImpl.java b/src/main/java/org/springframework/samples/petclinic/repository/jpa/JpaOwnerRepositoryExtImpl.java index 86b17eb8e..94a0bc263 100644 --- a/src/main/java/org/springframework/samples/petclinic/repository/jpa/JpaOwnerRepositoryExtImpl.java +++ b/src/main/java/org/springframework/samples/petclinic/repository/jpa/JpaOwnerRepositoryExtImpl.java @@ -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; 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.stereotype.Repository; +/** + * @author Vitaliy Fedoriv + * + */ + @Repository @Qualifier("OwnerRepositoryExt") public class JpaOwnerRepositoryExtImpl extends JpaOwnerRepositoryImpl implements OwnerRepositoryExt { diff --git a/src/main/java/org/springframework/samples/petclinic/repository/jpa/JpaVetRepositoryExtImpl.java b/src/main/java/org/springframework/samples/petclinic/repository/jpa/JpaVetRepositoryExtImpl.java index fc2f15fee..4fbf5d20f 100644 --- a/src/main/java/org/springframework/samples/petclinic/repository/jpa/JpaVetRepositoryExtImpl.java +++ b/src/main/java/org/springframework/samples/petclinic/repository/jpa/JpaVetRepositoryExtImpl.java @@ -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; 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.stereotype.Repository; +/** + * @author Vitaliy Fedoriv + * + */ + @Repository @Qualifier("VetRepositoryExt") public class JpaVetRepositoryExtImpl extends JpaVetRepositoryImpl implements VetRepositoryExt { diff --git a/src/main/java/org/springframework/samples/petclinic/repository/springdatajpa/PetRepositoryExtOverride.java b/src/main/java/org/springframework/samples/petclinic/repository/springdatajpa/PetRepositoryExtOverride.java index d6e2eb2ec..a101584a7 100644 --- a/src/main/java/org/springframework/samples/petclinic/repository/springdatajpa/PetRepositoryExtOverride.java +++ b/src/main/java/org/springframework/samples/petclinic/repository/springdatajpa/PetRepositoryExtOverride.java @@ -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; import org.springframework.samples.petclinic.model.Pet; +/** + * @author Vitaliy Fedoriv + * + */ + public interface PetRepositoryExtOverride { public void delete(Pet pet); diff --git a/src/main/java/org/springframework/samples/petclinic/repository/springdatajpa/SpringDataOwnerRepositoryExt.java b/src/main/java/org/springframework/samples/petclinic/repository/springdatajpa/SpringDataOwnerRepositoryExt.java index 12b65157b..1a69642ad 100644 --- a/src/main/java/org/springframework/samples/petclinic/repository/springdatajpa/SpringDataOwnerRepositoryExt.java +++ b/src/main/java/org/springframework/samples/petclinic/repository/springdatajpa/SpringDataOwnerRepositoryExt.java @@ -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; 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.repository.OwnerRepositoryExt; +/** + * @author Vitaliy Fedoriv + * + */ + @Qualifier("OwnerRepositoryExt") public interface SpringDataOwnerRepositoryExt extends OwnerRepositoryExt, Repository { diff --git a/src/main/java/org/springframework/samples/petclinic/repository/springdatajpa/SpringDataPetRepositoryExt.java b/src/main/java/org/springframework/samples/petclinic/repository/springdatajpa/SpringDataPetRepositoryExt.java index 13d8e31d7..235e48164 100644 --- a/src/main/java/org/springframework/samples/petclinic/repository/springdatajpa/SpringDataPetRepositoryExt.java +++ b/src/main/java/org/springframework/samples/petclinic/repository/springdatajpa/SpringDataPetRepositoryExt.java @@ -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; 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.repository.PetRepositoryExt; +/** + * @author Vitaliy Fedoriv + * + */ + @Qualifier("PetRepositoryExt") public interface SpringDataPetRepositoryExt extends PetRepositoryExt, Repository, PetRepositoryExtOverride { diff --git a/src/main/java/org/springframework/samples/petclinic/repository/springdatajpa/SpringDataPetRepositoryExtImpl.java b/src/main/java/org/springframework/samples/petclinic/repository/springdatajpa/SpringDataPetRepositoryExtImpl.java index 60add2073..6e4343911 100644 --- a/src/main/java/org/springframework/samples/petclinic/repository/springdatajpa/SpringDataPetRepositoryExtImpl.java +++ b/src/main/java/org/springframework/samples/petclinic/repository/springdatajpa/SpringDataPetRepositoryExtImpl.java @@ -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; import javax.persistence.EntityManager; @@ -5,6 +21,11 @@ import javax.persistence.PersistenceContext; import org.springframework.samples.petclinic.model.Pet; +/** + * @author Vitaliy Fedoriv + * + */ + public class SpringDataPetRepositoryExtImpl implements PetRepositoryExtOverride { @PersistenceContext diff --git a/src/main/java/org/springframework/samples/petclinic/repository/springdatajpa/SpringDataVetRepositoryExt.java b/src/main/java/org/springframework/samples/petclinic/repository/springdatajpa/SpringDataVetRepositoryExt.java index ad880c807..c0b87e101 100644 --- a/src/main/java/org/springframework/samples/petclinic/repository/springdatajpa/SpringDataVetRepositoryExt.java +++ b/src/main/java/org/springframework/samples/petclinic/repository/springdatajpa/SpringDataVetRepositoryExt.java @@ -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; 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.repository.VetRepositoryExt; +/** + * @author Vitaliy Fedoriv + * + */ + @Qualifier("VetRepositoryExt") public interface SpringDataVetRepositoryExt extends VetRepositoryExt, Repository { diff --git a/src/main/java/org/springframework/samples/petclinic/repository/springdatajpa/SpringDataVisitRepositoryExt.java b/src/main/java/org/springframework/samples/petclinic/repository/springdatajpa/SpringDataVisitRepositoryExt.java index ff11bab5c..224edd3bc 100644 --- a/src/main/java/org/springframework/samples/petclinic/repository/springdatajpa/SpringDataVisitRepositoryExt.java +++ b/src/main/java/org/springframework/samples/petclinic/repository/springdatajpa/SpringDataVisitRepositoryExt.java @@ -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; 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.repository.VisitRepositoryExt; +/** + * @author Vitaliy Fedoriv + * + */ + @Qualifier("VisitRepositoryExt") public interface SpringDataVisitRepositoryExt extends VisitRepositoryExt, Repository, VisitRepositoryExtOverride { diff --git a/src/main/java/org/springframework/samples/petclinic/repository/springdatajpa/SpringDataVisitRepositoryExtImpl.java b/src/main/java/org/springframework/samples/petclinic/repository/springdatajpa/SpringDataVisitRepositoryExtImpl.java index d61f0972a..ac7e0b25d 100644 --- a/src/main/java/org/springframework/samples/petclinic/repository/springdatajpa/SpringDataVisitRepositoryExtImpl.java +++ b/src/main/java/org/springframework/samples/petclinic/repository/springdatajpa/SpringDataVisitRepositoryExtImpl.java @@ -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; import javax.persistence.EntityManager; @@ -6,6 +22,11 @@ import javax.persistence.PersistenceContext; import org.springframework.dao.DataAccessException; import org.springframework.samples.petclinic.model.Visit; +/** + * @author Vitaliy Fedoriv + * + */ + public class SpringDataVisitRepositoryExtImpl implements VisitRepositoryExtOverride { @PersistenceContext diff --git a/src/main/java/org/springframework/samples/petclinic/repository/springdatajpa/VisitRepositoryExtOverride.java b/src/main/java/org/springframework/samples/petclinic/repository/springdatajpa/VisitRepositoryExtOverride.java index 975657649..34006e8a7 100644 --- a/src/main/java/org/springframework/samples/petclinic/repository/springdatajpa/VisitRepositoryExtOverride.java +++ b/src/main/java/org/springframework/samples/petclinic/repository/springdatajpa/VisitRepositoryExtOverride.java @@ -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; import org.springframework.samples.petclinic.model.Visit; +/** + * @author Vitaliy Fedoriv + * + */ + public interface VisitRepositoryExtOverride { public void delete(Visit visit); diff --git a/src/main/java/org/springframework/samples/petclinic/rest/ExceptionControllerAdvice.java b/src/main/java/org/springframework/samples/petclinic/rest/ExceptionControllerAdvice.java index d4475e903..70e5ca1eb 100644 --- a/src/main/java/org/springframework/samples/petclinic/rest/ExceptionControllerAdvice.java +++ b/src/main/java/org/springframework/samples/petclinic/rest/ExceptionControllerAdvice.java @@ -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; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.ControllerAdvice; import org.springframework.web.bind.annotation.ExceptionHandler; +/** + * @author Vitaliy Fedoriv + * + */ + @ControllerAdvice public class ExceptionControllerAdvice { diff --git a/src/main/java/org/springframework/samples/petclinic/rest/OwnerRestController.java b/src/main/java/org/springframework/samples/petclinic/rest/OwnerRestController.java index a19339589..4d7e41fbf 100644 --- a/src/main/java/org/springframework/samples/petclinic/rest/OwnerRestController.java +++ b/src/main/java/org/springframework/samples/petclinic/rest/OwnerRestController.java @@ -71,7 +71,8 @@ public class OwnerRestController { @RequestMapping(value = "/{ownerId}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE) public ResponseEntity getOwner(@PathVariable("ownerId") int ownerId){ - Owner owner = this.clinicService.findOwnerById(ownerId); + Owner owner = null; + owner = this.clinicService.findOwnerById(ownerId); if(owner == null){ return new ResponseEntity(HttpStatus.NOT_FOUND); } @@ -115,7 +116,6 @@ public class OwnerRestController { return new ResponseEntity(HttpStatus.NOT_FOUND); } this.clinicService.deleteOwner(owner); - // TODO delete error - FK etc. return new ResponseEntity(HttpStatus.NO_CONTENT); } diff --git a/src/main/java/org/springframework/samples/petclinic/rest/PetTypeRestController.java b/src/main/java/org/springframework/samples/petclinic/rest/PetTypeRestController.java index b7f1ada08..8f3cd4b62 100644 --- a/src/main/java/org/springframework/samples/petclinic/rest/PetTypeRestController.java +++ b/src/main/java/org/springframework/samples/petclinic/rest/PetTypeRestController.java @@ -81,7 +81,6 @@ public class PetTypeRestController { return new ResponseEntity(HttpStatus.NOT_FOUND); } this.clinicService.deletePetType(petType); - // TODO delete error - FK etc. return new ResponseEntity(HttpStatus.NO_CONTENT); } diff --git a/src/main/java/org/springframework/samples/petclinic/rest/SpecialtyRestController.java b/src/main/java/org/springframework/samples/petclinic/rest/SpecialtyRestController.java index 81ec29801..ac8a7d575 100644 --- a/src/main/java/org/springframework/samples/petclinic/rest/SpecialtyRestController.java +++ b/src/main/java/org/springframework/samples/petclinic/rest/SpecialtyRestController.java @@ -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; 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.util.UriComponentsBuilder; +/** + * @author Vitaliy Fedoriv + * + */ + @RestController @RequestMapping("api/specialties") public class SpecialtyRestController { @@ -81,7 +102,6 @@ public class SpecialtyRestController { return new ResponseEntity(HttpStatus.NOT_FOUND); } this.clinicService.deleteSpecialty(specialty); - // TODO delete error - FK etc. return new ResponseEntity(HttpStatus.NO_CONTENT); } diff --git a/src/main/java/org/springframework/samples/petclinic/rest/VetRestController.java b/src/main/java/org/springframework/samples/petclinic/rest/VetRestController.java index 7ca8145fb..91da9ded1 100644 --- a/src/main/java/org/springframework/samples/petclinic/rest/VetRestController.java +++ b/src/main/java/org/springframework/samples/petclinic/rest/VetRestController.java @@ -102,7 +102,6 @@ public class VetRestController { return new ResponseEntity(HttpStatus.NOT_FOUND); } this.clinicService.deleteVet(vet); - // TODO delete error - FK etc. return new ResponseEntity(HttpStatus.NO_CONTENT); } diff --git a/src/main/java/org/springframework/samples/petclinic/rest/VisitRestController.java b/src/main/java/org/springframework/samples/petclinic/rest/VisitRestController.java index 9983561c2..94aec867e 100644 --- a/src/main/java/org/springframework/samples/petclinic/rest/VisitRestController.java +++ b/src/main/java/org/springframework/samples/petclinic/rest/VisitRestController.java @@ -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; 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.util.UriComponentsBuilder; +/** + * @author Vitaliy Fedoriv + * + */ + @RestController @RequestMapping("api/visits") public class VisitRestController { @@ -83,7 +104,6 @@ public class VisitRestController { return new ResponseEntity(HttpStatus.NOT_FOUND); } this.clinicService.deleteVisit(visit); - // TODO delete error - FK etc. return new ResponseEntity(HttpStatus.NO_CONTENT); } diff --git a/src/main/java/org/springframework/samples/petclinic/service/ClinicServiceExt.java b/src/main/java/org/springframework/samples/petclinic/service/ClinicServiceExt.java index eb46803dc..86ea32da3 100644 --- a/src/main/java/org/springframework/samples/petclinic/service/ClinicServiceExt.java +++ b/src/main/java/org/springframework/samples/petclinic/service/ClinicServiceExt.java @@ -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; 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.Visit; +/** + * Used as a facade so all (incl.extended) controllers have a single point of entry + * + * @author Vitaliy Fedoriv + */ + public interface ClinicServiceExt extends ClinicService { -// Pet findPetById(int id) throws DataAccessException; + // ----- Pet ----- + // (in ClinicService) Pet findPetById(int id) throws DataAccessException; Collection findAllPets() throws DataAccessException; -// void savePet(Pet pet) throws DataAccessException; + // (in ClinicService) void savePet(Pet pet) throws DataAccessException; void deletePet(Pet pet) throws DataAccessException; -// Collection findVisitsByPetId(int petId); + // ----- Visit ----- + // (in ClinicService) Collection findVisitsByPetId(int petId); Visit findVisitById(int visitId) throws DataAccessException; Collection findAllVisits() throws DataAccessException; -// void saveVisit(Visit visit) throws DataAccessException; + // (in ClinicService) void saveVisit(Visit visit) throws DataAccessException; void deleteVisit(Visit visit) throws DataAccessException; + // ----- Vet ----- Vet findVetById(int id) throws DataAccessException; -// Collection findVets() throws DataAccessException; + // (in ClinicService) Collection findVets() throws DataAccessException; Collection findAllVets() throws DataAccessException; void saveVet(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 findAllOwners() throws DataAccessException; -// void saveOwner(Owner owner) throws DataAccessException; + // (in ClinicService) void saveOwner(Owner owner) throws DataAccessException; void deleteOwner(Owner owner) throws DataAccessException; -// Collection findOwnerByLastName(String lastName) throws DataAccessException; + // (in ClinicService) Collection findOwnerByLastName(String lastName) throws DataAccessException; + // ----- PetType ----- PetType findPetTypeById(int petTypeId); Collection findAllPetTypes() throws DataAccessException; -// Collection findPetTypes() throws DataAccessException; + // (in ClinicService) Collection findPetTypes() throws DataAccessException; void savePetType(PetType petType) throws DataAccessException; void deletePetType(PetType petType) throws DataAccessException; + // ----- Specialty ----- Specialty findSpecialtyById(int specialtyId); Collection findAllSpecialties() throws DataAccessException; void saveSpecialty(Specialty specialty) throws DataAccessException; diff --git a/src/test/java/org/springframework/samples/petclinic/rest/OwnerRestControllerTests.java b/src/test/java/org/springframework/samples/petclinic/rest/OwnerRestControllerTests.java index 0a99f1b4e..dad095fed 100644 --- a/src/test/java/org/springframework/samples/petclinic/rest/OwnerRestControllerTests.java +++ b/src/test/java/org/springframework/samples/petclinic/rest/OwnerRestControllerTests.java @@ -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; import static org.mockito.BDDMockito.given; diff --git a/src/test/java/org/springframework/samples/petclinic/rest/PetRestControllerTests.java b/src/test/java/org/springframework/samples/petclinic/rest/PetRestControllerTests.java index bf83357ba..476be9b24 100644 --- a/src/test/java/org/springframework/samples/petclinic/rest/PetRestControllerTests.java +++ b/src/test/java/org/springframework/samples/petclinic/rest/PetRestControllerTests.java @@ -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; import static org.mockito.BDDMockito.given; diff --git a/src/test/java/org/springframework/samples/petclinic/rest/PetTypeRestControllerTests.java b/src/test/java/org/springframework/samples/petclinic/rest/PetTypeRestControllerTests.java index d98a125bc..20b5c909e 100644 --- a/src/test/java/org/springframework/samples/petclinic/rest/PetTypeRestControllerTests.java +++ b/src/test/java/org/springframework/samples/petclinic/rest/PetTypeRestControllerTests.java @@ -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; import static org.mockito.BDDMockito.given; diff --git a/src/test/java/org/springframework/samples/petclinic/rest/VetRestControllerTests.java b/src/test/java/org/springframework/samples/petclinic/rest/VetRestControllerTests.java index 1878ccac7..4ab952aca 100644 --- a/src/test/java/org/springframework/samples/petclinic/rest/VetRestControllerTests.java +++ b/src/test/java/org/springframework/samples/petclinic/rest/VetRestControllerTests.java @@ -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; import static org.mockito.BDDMockito.given; @@ -27,12 +43,12 @@ import org.springframework.test.web.servlet.setup.MockMvcBuilders; import com.fasterxml.jackson.databind.ObjectMapper; - /** * Test class for {@link VetRestController} * * @author Vitaliy Fedoriv */ + @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration({"classpath:spring/mvc-test-config.xml", "classpath:spring/mvc-core-config.xml"}) @WebAppConfiguration @@ -94,8 +110,6 @@ public class VetRestControllerTests { @Test public void testGetAllVetsSuccess() throws Exception { - //vets.remove(2); - //vets.remove(1); given(this.clinicService.findAllVets()).willReturn(vets); this.mockMvc.perform(get("/api/vets/") .accept(MediaType.APPLICATION_JSON)) diff --git a/src/test/java/org/springframework/samples/petclinic/rest/VisitRestControllerTests.java b/src/test/java/org/springframework/samples/petclinic/rest/VisitRestControllerTests.java index dc7a2601a..8da9e51de 100644 --- a/src/test/java/org/springframework/samples/petclinic/rest/VisitRestControllerTests.java +++ b/src/test/java/org/springframework/samples/petclinic/rest/VisitRestControllerTests.java @@ -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; import static org.mockito.BDDMockito.given; @@ -31,12 +47,12 @@ import org.springframework.test.web.servlet.setup.MockMvcBuilders; import com.fasterxml.jackson.databind.ObjectMapper; - /** * Test class for {@link VisitRestController} * * @author Vitaliy Fedoriv */ + @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration({"classpath:spring/mvc-test-config.xml", "classpath:spring/mvc-core-config.xml"}) @WebAppConfiguration