Cognitive Complexity, explained
Where every point of the entry point complexity score comes from. Cognitive Complexity charges +1 for each break in the linear reading order and +1 more per level of nesting it sits in; shorthand a reader takes in at a glance is free — a switch costs 1 however many cases it has, and else costs 1 with no nesting penalty. Add the annotations down the right-hand gutter and you get the number in the header.
HTTP / REST APIs
GET /api/owners 16 methods cost something, out of 71 in the flow 22
OwnerMapperImpl.toOwnerDtoCollection(List) generated+2
| 60 | public List<OwnerDto> toOwnerDtoCollection(List<Owner> ownerCollection) { | ||
| 61 | if ( ownerCollection == null ) { | if +1 | 1 |
| 62 | return null; | ||
| 63 | } | ||
| 64 | |||
| 65 | List<OwnerDto> list = new ArrayList<OwnerDto>( ownerCollection.size() ); | ||
| 66 | for ( Owner owner : ownerCollection ) { | for-each +1 | 2 |
| 67 | list.add( toOwnerDto( owner ) ); | ||
| 68 | } | ||
| 69 | |||
| 70 | return list; | ||
| 71 | } |
PetMapperImpl.toPetsDto(List) generated+2
| 49 | public List<PetDto> toPetsDto(List<Pet> pets) { | ||
| 50 | if ( pets == null ) { | if +1 | 3 |
| 51 | return null; | ||
| 52 | } | ||
| 53 | |||
| 54 | List<PetDto> list = new ArrayList<PetDto>( pets.size() ); | ||
| 55 | for ( Pet pet : pets ) { | for-each +1 | 4 |
| 56 | list.add( toPetDto( pet ) ); | ||
| 57 | } | ||
| 58 | |||
| 59 | return list; | ||
| 60 | } |
VisitMapperImpl.toVisitsDto(List) generated+2
| 76 | public List<VisitDto> toVisitsDto(List<Visit> visits) { | ||
| 77 | if ( visits == null ) { | if +1 | 5 |
| 78 | return null; | ||
| 79 | } | ||
| 80 | |||
| 81 | List<VisitDto> list = new ArrayList<VisitDto>( visits.size() ); | ||
| 82 | for ( Visit visit : visits ) { | for-each +1 | 6 |
| 83 | list.add( toVisitDto( visit ) ); | ||
| 84 | } | ||
| 85 | |||
| 86 | return list; | ||
| 87 | } |
VisitMapperImpl.visitPetOwnerFirstName(Visit) generated+2
| 129 | private String visitPetOwnerFirstName(Visit visit) { | ||
| 130 | Pet pet = visit.getPet(); | ||
| 131 | if ( pet == null ) { | if +1 | 7 |
| 132 | return null; | ||
| 133 | } | ||
| 134 | Owner owner = pet.getOwner(); | ||
| 135 | if ( owner == null ) { | if +1 | 8 |
| 136 | return null; | ||
| 137 | } | ||
| 138 | return owner.getFirstName(); | ||
| 139 | } |
VisitMapperImpl.visitPetOwnerId(Visit) generated+2
| 117 | private Integer visitPetOwnerId(Visit visit) { | ||
| 118 | Pet pet = visit.getPet(); | ||
| 119 | if ( pet == null ) { | if +1 | 9 |
| 120 | return null; | ||
| 121 | } | ||
| 122 | Owner owner = pet.getOwner(); | ||
| 123 | if ( owner == null ) { | if +1 | 10 |
| 124 | return null; | ||
| 125 | } | ||
| 126 | return owner.getId(); | ||
| 127 | } |
VisitMapperImpl.visitPetOwnerLastName(Visit) generated+2
| 141 | private String visitPetOwnerLastName(Visit visit) { | ||
| 142 | Pet pet = visit.getPet(); | ||
| 143 | if ( pet == null ) { | if +1 | 11 |
| 144 | return null; | ||
| 145 | } | ||
| 146 | Owner owner = pet.getOwner(); | ||
| 147 | if ( owner == null ) { | if +1 | 12 |
| 148 | return null; | ||
| 149 | } | ||
| 150 | return owner.getLastName(); | ||
| 151 | } |
OwnerMapperImpl.toOwnerDto(Owner) generated+1
| 24 | public OwnerDto toOwnerDto(Owner owner) { | ||
| 25 | if ( owner == null ) { | if +1 | 13 |
| 26 | return null; | ||
| 27 | } | ||
| 28 | |||
| 29 | OwnerDto ownerDto = new OwnerDto(); | ||
| 30 | |||
| 31 | ownerDto.setId( owner.getId() ); | ||
| 32 | ownerDto.setFirstName( owner.getFirstName() ); | ||
| 33 | ownerDto.setLastName( owner.getLastName() ); | ||
| 34 | ownerDto.setAddress( owner.getAddress() ); | ||
| 35 | ownerDto.setCity( owner.getCity() ); | ||
| 36 | ownerDto.setTelephone( owner.getTelephone() ); | ||
| 37 | ownerDto.setPets( petMapper.toPetsDto( owner.getPets() ) ); | ||
| 38 | |||
| 39 | return ownerDto; | ||
| 40 | } |
PetMapperImpl.petOwnerId(Pet) generated+1
| 151 | private Integer petOwnerId(Pet pet) { | ||
| 152 | Owner owner = pet.getOwner(); | ||
| 153 | if ( owner == null ) { | if +1 | 14 |
| 154 | return null; | ||
| 155 | } | ||
| 156 | return owner.getId(); | ||
| 157 | } |
PetMapperImpl.toPetDto(Pet) generated+1
| 31 | public PetDto toPetDto(Pet pet) { | ||
| 32 | if ( pet == null ) { | if +1 | 15 |
| 33 | return null; | ||
| 34 | } | ||
| 35 | |||
| 36 | PetDto petDto = new PetDto(); | ||
| 37 | |||
| 38 | petDto.setOwnerId( petOwnerId( pet ) ); | ||
| 39 | petDto.setVisits( visitMapper.toVisitsDto( pet.getVisitsSortedByDate() ) ); | ||
| 40 | petDto.setName( pet.getName() ); | ||
| 41 | petDto.setBirthDate( pet.getBirthDate() ); | ||
| 42 | petDto.setType( toPetTypeDto( pet.getType() ) ); | ||
| 43 | petDto.setId( pet.getId() ); | ||
| 44 | |||
| 45 | return petDto; | ||
| 46 | } |
PetMapperImpl.toPetTypeDto(PetType) generated+1
| 110 | public PetTypeDto toPetTypeDto(PetType petType) { | ||
| 111 | if ( petType == null ) { | if +1 | 16 |
| 112 | return null; | ||
| 113 | } | ||
| 114 | |||
| 115 | PetTypeDto petTypeDto = new PetTypeDto(); | ||
| 116 | |||
| 117 | petTypeDto.setName( petType.getName() ); | ||
| 118 | petTypeDto.setId( petType.getId() ); | ||
| 119 | |||
| 120 | return petTypeDto; | ||
| 121 | } |
VisitMapperImpl.toVisitDto(Visit) generated+1
| 53 | public VisitDto toVisitDto(Visit visit) { | ||
| 54 | if ( visit == null ) { | if +1 | 17 |
| 55 | return null; | ||
| 56 | } | ||
| 57 | |||
| 58 | VisitDto visitDto = new VisitDto(); | ||
| 59 | |||
| 60 | visitDto.setPetId( visitPetId( visit ) ); | ||
| 61 | visitDto.setPetName( visitPetName( visit ) ); | ||
| 62 | visitDto.setOwnerId( visitPetOwnerId( visit ) ); | ||
| 63 | visitDto.setOwnerFirstName( visitPetOwnerFirstName( visit ) ); | ||
| 64 | visitDto.setOwnerLastName( visitPetOwnerLastName( visit ) ); | ||
| 65 | visitDto.setVetId( visitVetId( visit ) ); | ||
| 66 | visitDto.setVetFirstName( visitVetFirstName( visit ) ); | ||
| 67 | visitDto.setVetLastName( visitVetLastName( visit ) ); | ||
| 68 | visitDto.setDate( visit.getDate() ); | ||
| 69 | visitDto.setDescription( visit.getDescription() ); | ||
| 70 | visitDto.setId( visit.getId() ); | ||
| 71 | |||
| 72 | return visitDto; | ||
| 73 | } |
VisitMapperImpl.visitPetId(Visit) generated+1
| 101 | private Integer visitPetId(Visit visit) { | ||
| 102 | Pet pet = visit.getPet(); | ||
| 103 | if ( pet == null ) { | if +1 | 18 |
| 104 | return null; | ||
| 105 | } | ||
| 106 | return pet.getId(); | ||
| 107 | } |
VisitMapperImpl.visitPetName(Visit) generated+1
| 109 | private String visitPetName(Visit visit) { | ||
| 110 | Pet pet = visit.getPet(); | ||
| 111 | if ( pet == null ) { | if +1 | 19 |
| 112 | return null; | ||
| 113 | } | ||
| 114 | return pet.getName(); | ||
| 115 | } |
VisitMapperImpl.visitVetFirstName(Visit) generated+1
| 161 | private String visitVetFirstName(Visit visit) { | ||
| 162 | Vet vet = visit.getVet(); | ||
| 163 | if ( vet == null ) { | if +1 | 20 |
| 164 | return null; | ||
| 165 | } | ||
| 166 | return vet.getFirstName(); | ||
| 167 | } |
VisitMapperImpl.visitVetId(Visit) generated+1
| 153 | private Integer visitVetId(Visit visit) { | ||
| 154 | Vet vet = visit.getVet(); | ||
| 155 | if ( vet == null ) { | if +1 | 21 |
| 156 | return null; | ||
| 157 | } | ||
| 158 | return vet.getId(); | ||
| 159 | } |
VisitMapperImpl.visitVetLastName(Visit) generated+1
| 169 | private String visitVetLastName(Visit visit) { | ||
| 170 | Vet vet = visit.getVet(); | ||
| 171 | if ( vet == null ) { | if +1 | 22 |
| 172 | return null; | ||
| 173 | } | ||
| 174 | return vet.getLastName(); | ||
| 175 | } |
GET /api/owners/{ownerId} 15 methods cost something, out of 70 in the flow 20
PetMapperImpl.toPetsDto(List) generated+2
| 49 | public List<PetDto> toPetsDto(List<Pet> pets) { | ||
| 50 | if ( pets == null ) { | if +1 | 1 |
| 51 | return null; | ||
| 52 | } | ||
| 53 | |||
| 54 | List<PetDto> list = new ArrayList<PetDto>( pets.size() ); | ||
| 55 | for ( Pet pet : pets ) { | for-each +1 | 2 |
| 56 | list.add( toPetDto( pet ) ); | ||
| 57 | } | ||
| 58 | |||
| 59 | return list; | ||
| 60 | } |
VisitMapperImpl.toVisitsDto(List) generated+2
| 76 | public List<VisitDto> toVisitsDto(List<Visit> visits) { | ||
| 77 | if ( visits == null ) { | if +1 | 3 |
| 78 | return null; | ||
| 79 | } | ||
| 80 | |||
| 81 | List<VisitDto> list = new ArrayList<VisitDto>( visits.size() ); | ||
| 82 | for ( Visit visit : visits ) { | for-each +1 | 4 |
| 83 | list.add( toVisitDto( visit ) ); | ||
| 84 | } | ||
| 85 | |||
| 86 | return list; | ||
| 87 | } |
VisitMapperImpl.visitPetOwnerFirstName(Visit) generated+2
| 129 | private String visitPetOwnerFirstName(Visit visit) { | ||
| 130 | Pet pet = visit.getPet(); | ||
| 131 | if ( pet == null ) { | if +1 | 5 |
| 132 | return null; | ||
| 133 | } | ||
| 134 | Owner owner = pet.getOwner(); | ||
| 135 | if ( owner == null ) { | if +1 | 6 |
| 136 | return null; | ||
| 137 | } | ||
| 138 | return owner.getFirstName(); | ||
| 139 | } |
VisitMapperImpl.visitPetOwnerId(Visit) generated+2
| 117 | private Integer visitPetOwnerId(Visit visit) { | ||
| 118 | Pet pet = visit.getPet(); | ||
| 119 | if ( pet == null ) { | if +1 | 7 |
| 120 | return null; | ||
| 121 | } | ||
| 122 | Owner owner = pet.getOwner(); | ||
| 123 | if ( owner == null ) { | if +1 | 8 |
| 124 | return null; | ||
| 125 | } | ||
| 126 | return owner.getId(); | ||
| 127 | } |
VisitMapperImpl.visitPetOwnerLastName(Visit) generated+2
| 141 | private String visitPetOwnerLastName(Visit visit) { | ||
| 142 | Pet pet = visit.getPet(); | ||
| 143 | if ( pet == null ) { | if +1 | 9 |
| 144 | return null; | ||
| 145 | } | ||
| 146 | Owner owner = pet.getOwner(); | ||
| 147 | if ( owner == null ) { | if +1 | 10 |
| 148 | return null; | ||
| 149 | } | ||
| 150 | return owner.getLastName(); | ||
| 151 | } |
OwnerMapperImpl.toOwnerDto(Owner) generated+1
| 24 | public OwnerDto toOwnerDto(Owner owner) { | ||
| 25 | if ( owner == null ) { | if +1 | 11 |
| 26 | return null; | ||
| 27 | } | ||
| 28 | |||
| 29 | OwnerDto ownerDto = new OwnerDto(); | ||
| 30 | |||
| 31 | ownerDto.setId( owner.getId() ); | ||
| 32 | ownerDto.setFirstName( owner.getFirstName() ); | ||
| 33 | ownerDto.setLastName( owner.getLastName() ); | ||
| 34 | ownerDto.setAddress( owner.getAddress() ); | ||
| 35 | ownerDto.setCity( owner.getCity() ); | ||
| 36 | ownerDto.setTelephone( owner.getTelephone() ); | ||
| 37 | ownerDto.setPets( petMapper.toPetsDto( owner.getPets() ) ); | ||
| 38 | |||
| 39 | return ownerDto; | ||
| 40 | } |
PetMapperImpl.petOwnerId(Pet) generated+1
| 151 | private Integer petOwnerId(Pet pet) { | ||
| 152 | Owner owner = pet.getOwner(); | ||
| 153 | if ( owner == null ) { | if +1 | 12 |
| 154 | return null; | ||
| 155 | } | ||
| 156 | return owner.getId(); | ||
| 157 | } |
PetMapperImpl.toPetDto(Pet) generated+1
| 31 | public PetDto toPetDto(Pet pet) { | ||
| 32 | if ( pet == null ) { | if +1 | 13 |
| 33 | return null; | ||
| 34 | } | ||
| 35 | |||
| 36 | PetDto petDto = new PetDto(); | ||
| 37 | |||
| 38 | petDto.setOwnerId( petOwnerId( pet ) ); | ||
| 39 | petDto.setVisits( visitMapper.toVisitsDto( pet.getVisitsSortedByDate() ) ); | ||
| 40 | petDto.setName( pet.getName() ); | ||
| 41 | petDto.setBirthDate( pet.getBirthDate() ); | ||
| 42 | petDto.setType( toPetTypeDto( pet.getType() ) ); | ||
| 43 | petDto.setId( pet.getId() ); | ||
| 44 | |||
| 45 | return petDto; | ||
| 46 | } |
PetMapperImpl.toPetTypeDto(PetType) generated+1
| 110 | public PetTypeDto toPetTypeDto(PetType petType) { | ||
| 111 | if ( petType == null ) { | if +1 | 14 |
| 112 | return null; | ||
| 113 | } | ||
| 114 | |||
| 115 | PetTypeDto petTypeDto = new PetTypeDto(); | ||
| 116 | |||
| 117 | petTypeDto.setName( petType.getName() ); | ||
| 118 | petTypeDto.setId( petType.getId() ); | ||
| 119 | |||
| 120 | return petTypeDto; | ||
| 121 | } |
VisitMapperImpl.toVisitDto(Visit) generated+1
| 53 | public VisitDto toVisitDto(Visit visit) { | ||
| 54 | if ( visit == null ) { | if +1 | 15 |
| 55 | return null; | ||
| 56 | } | ||
| 57 | |||
| 58 | VisitDto visitDto = new VisitDto(); | ||
| 59 | |||
| 60 | visitDto.setPetId( visitPetId( visit ) ); | ||
| 61 | visitDto.setPetName( visitPetName( visit ) ); | ||
| 62 | visitDto.setOwnerId( visitPetOwnerId( visit ) ); | ||
| 63 | visitDto.setOwnerFirstName( visitPetOwnerFirstName( visit ) ); | ||
| 64 | visitDto.setOwnerLastName( visitPetOwnerLastName( visit ) ); | ||
| 65 | visitDto.setVetId( visitVetId( visit ) ); | ||
| 66 | visitDto.setVetFirstName( visitVetFirstName( visit ) ); | ||
| 67 | visitDto.setVetLastName( visitVetLastName( visit ) ); | ||
| 68 | visitDto.setDate( visit.getDate() ); | ||
| 69 | visitDto.setDescription( visit.getDescription() ); | ||
| 70 | visitDto.setId( visit.getId() ); | ||
| 71 | |||
| 72 | return visitDto; | ||
| 73 | } |
VisitMapperImpl.visitPetId(Visit) generated+1
| 101 | private Integer visitPetId(Visit visit) { | ||
| 102 | Pet pet = visit.getPet(); | ||
| 103 | if ( pet == null ) { | if +1 | 16 |
| 104 | return null; | ||
| 105 | } | ||
| 106 | return pet.getId(); | ||
| 107 | } |
VisitMapperImpl.visitPetName(Visit) generated+1
| 109 | private String visitPetName(Visit visit) { | ||
| 110 | Pet pet = visit.getPet(); | ||
| 111 | if ( pet == null ) { | if +1 | 17 |
| 112 | return null; | ||
| 113 | } | ||
| 114 | return pet.getName(); | ||
| 115 | } |
VisitMapperImpl.visitVetFirstName(Visit) generated+1
| 161 | private String visitVetFirstName(Visit visit) { | ||
| 162 | Vet vet = visit.getVet(); | ||
| 163 | if ( vet == null ) { | if +1 | 18 |
| 164 | return null; | ||
| 165 | } | ||
| 166 | return vet.getFirstName(); | ||
| 167 | } |
VisitMapperImpl.visitVetId(Visit) generated+1
| 153 | private Integer visitVetId(Visit visit) { | ||
| 154 | Vet vet = visit.getVet(); | ||
| 155 | if ( vet == null ) { | if +1 | 19 |
| 156 | return null; | ||
| 157 | } | ||
| 158 | return vet.getId(); | ||
| 159 | } |
VisitMapperImpl.visitVetLastName(Visit) generated+1
| 169 | private String visitVetLastName(Visit visit) { | ||
| 170 | Vet vet = visit.getVet(); | ||
| 171 | if ( vet == null ) { | if +1 | 20 |
| 172 | return null; | ||
| 173 | } | ||
| 174 | return vet.getLastName(); | ||
| 175 | } |
GET /api/pets 14 methods cost something, out of 57 in the flow 19
PetMapperImpl.toPetsDto(List) generated+2
| 49 | public List<PetDto> toPetsDto(List<Pet> pets) { | ||
| 50 | if ( pets == null ) { | if +1 | 1 |
| 51 | return null; | ||
| 52 | } | ||
| 53 | |||
| 54 | List<PetDto> list = new ArrayList<PetDto>( pets.size() ); | ||
| 55 | for ( Pet pet : pets ) { | for-each +1 | 2 |
| 56 | list.add( toPetDto( pet ) ); | ||
| 57 | } | ||
| 58 | |||
| 59 | return list; | ||
| 60 | } |
VisitMapperImpl.toVisitsDto(List) generated+2
| 76 | public List<VisitDto> toVisitsDto(List<Visit> visits) { | ||
| 77 | if ( visits == null ) { | if +1 | 3 |
| 78 | return null; | ||
| 79 | } | ||
| 80 | |||
| 81 | List<VisitDto> list = new ArrayList<VisitDto>( visits.size() ); | ||
| 82 | for ( Visit visit : visits ) { | for-each +1 | 4 |
| 83 | list.add( toVisitDto( visit ) ); | ||
| 84 | } | ||
| 85 | |||
| 86 | return list; | ||
| 87 | } |
VisitMapperImpl.visitPetOwnerFirstName(Visit) generated+2
| 129 | private String visitPetOwnerFirstName(Visit visit) { | ||
| 130 | Pet pet = visit.getPet(); | ||
| 131 | if ( pet == null ) { | if +1 | 5 |
| 132 | return null; | ||
| 133 | } | ||
| 134 | Owner owner = pet.getOwner(); | ||
| 135 | if ( owner == null ) { | if +1 | 6 |
| 136 | return null; | ||
| 137 | } | ||
| 138 | return owner.getFirstName(); | ||
| 139 | } |
VisitMapperImpl.visitPetOwnerId(Visit) generated+2
| 117 | private Integer visitPetOwnerId(Visit visit) { | ||
| 118 | Pet pet = visit.getPet(); | ||
| 119 | if ( pet == null ) { | if +1 | 7 |
| 120 | return null; | ||
| 121 | } | ||
| 122 | Owner owner = pet.getOwner(); | ||
| 123 | if ( owner == null ) { | if +1 | 8 |
| 124 | return null; | ||
| 125 | } | ||
| 126 | return owner.getId(); | ||
| 127 | } |
VisitMapperImpl.visitPetOwnerLastName(Visit) generated+2
| 141 | private String visitPetOwnerLastName(Visit visit) { | ||
| 142 | Pet pet = visit.getPet(); | ||
| 143 | if ( pet == null ) { | if +1 | 9 |
| 144 | return null; | ||
| 145 | } | ||
| 146 | Owner owner = pet.getOwner(); | ||
| 147 | if ( owner == null ) { | if +1 | 10 |
| 148 | return null; | ||
| 149 | } | ||
| 150 | return owner.getLastName(); | ||
| 151 | } |
PetMapperImpl.petOwnerId(Pet) generated+1
| 151 | private Integer petOwnerId(Pet pet) { | ||
| 152 | Owner owner = pet.getOwner(); | ||
| 153 | if ( owner == null ) { | if +1 | 11 |
| 154 | return null; | ||
| 155 | } | ||
| 156 | return owner.getId(); | ||
| 157 | } |
PetMapperImpl.toPetDto(Pet) generated+1
| 31 | public PetDto toPetDto(Pet pet) { | ||
| 32 | if ( pet == null ) { | if +1 | 12 |
| 33 | return null; | ||
| 34 | } | ||
| 35 | |||
| 36 | PetDto petDto = new PetDto(); | ||
| 37 | |||
| 38 | petDto.setOwnerId( petOwnerId( pet ) ); | ||
| 39 | petDto.setVisits( visitMapper.toVisitsDto( pet.getVisitsSortedByDate() ) ); | ||
| 40 | petDto.setName( pet.getName() ); | ||
| 41 | petDto.setBirthDate( pet.getBirthDate() ); | ||
| 42 | petDto.setType( toPetTypeDto( pet.getType() ) ); | ||
| 43 | petDto.setId( pet.getId() ); | ||
| 44 | |||
| 45 | return petDto; | ||
| 46 | } |
PetMapperImpl.toPetTypeDto(PetType) generated+1
| 110 | public PetTypeDto toPetTypeDto(PetType petType) { | ||
| 111 | if ( petType == null ) { | if +1 | 13 |
| 112 | return null; | ||
| 113 | } | ||
| 114 | |||
| 115 | PetTypeDto petTypeDto = new PetTypeDto(); | ||
| 116 | |||
| 117 | petTypeDto.setName( petType.getName() ); | ||
| 118 | petTypeDto.setId( petType.getId() ); | ||
| 119 | |||
| 120 | return petTypeDto; | ||
| 121 | } |
VisitMapperImpl.toVisitDto(Visit) generated+1
| 53 | public VisitDto toVisitDto(Visit visit) { | ||
| 54 | if ( visit == null ) { | if +1 | 14 |
| 55 | return null; | ||
| 56 | } | ||
| 57 | |||
| 58 | VisitDto visitDto = new VisitDto(); | ||
| 59 | |||
| 60 | visitDto.setPetId( visitPetId( visit ) ); | ||
| 61 | visitDto.setPetName( visitPetName( visit ) ); | ||
| 62 | visitDto.setOwnerId( visitPetOwnerId( visit ) ); | ||
| 63 | visitDto.setOwnerFirstName( visitPetOwnerFirstName( visit ) ); | ||
| 64 | visitDto.setOwnerLastName( visitPetOwnerLastName( visit ) ); | ||
| 65 | visitDto.setVetId( visitVetId( visit ) ); | ||
| 66 | visitDto.setVetFirstName( visitVetFirstName( visit ) ); | ||
| 67 | visitDto.setVetLastName( visitVetLastName( visit ) ); | ||
| 68 | visitDto.setDate( visit.getDate() ); | ||
| 69 | visitDto.setDescription( visit.getDescription() ); | ||
| 70 | visitDto.setId( visit.getId() ); | ||
| 71 | |||
| 72 | return visitDto; | ||
| 73 | } |
VisitMapperImpl.visitPetId(Visit) generated+1
| 101 | private Integer visitPetId(Visit visit) { | ||
| 102 | Pet pet = visit.getPet(); | ||
| 103 | if ( pet == null ) { | if +1 | 15 |
| 104 | return null; | ||
| 105 | } | ||
| 106 | return pet.getId(); | ||
| 107 | } |
VisitMapperImpl.visitPetName(Visit) generated+1
| 109 | private String visitPetName(Visit visit) { | ||
| 110 | Pet pet = visit.getPet(); | ||
| 111 | if ( pet == null ) { | if +1 | 16 |
| 112 | return null; | ||
| 113 | } | ||
| 114 | return pet.getName(); | ||
| 115 | } |
VisitMapperImpl.visitVetFirstName(Visit) generated+1
| 161 | private String visitVetFirstName(Visit visit) { | ||
| 162 | Vet vet = visit.getVet(); | ||
| 163 | if ( vet == null ) { | if +1 | 17 |
| 164 | return null; | ||
| 165 | } | ||
| 166 | return vet.getFirstName(); | ||
| 167 | } |
VisitMapperImpl.visitVetId(Visit) generated+1
| 153 | private Integer visitVetId(Visit visit) { | ||
| 154 | Vet vet = visit.getVet(); | ||
| 155 | if ( vet == null ) { | if +1 | 18 |
| 156 | return null; | ||
| 157 | } | ||
| 158 | return vet.getId(); | ||
| 159 | } |
VisitMapperImpl.visitVetLastName(Visit) generated+1
| 169 | private String visitVetLastName(Visit visit) { | ||
| 170 | Vet vet = visit.getVet(); | ||
| 171 | if ( vet == null ) { | if +1 | 19 |
| 172 | return null; | ||
| 173 | } | ||
| 174 | return vet.getLastName(); | ||
| 175 | } |
GET /api/owners/{ownerId}/pets/{petId} 13 methods cost something, out of 58 in the flow 17
VisitMapperImpl.toVisitsDto(List) generated+2
| 76 | public List<VisitDto> toVisitsDto(List<Visit> visits) { | ||
| 77 | if ( visits == null ) { | if +1 | 1 |
| 78 | return null; | ||
| 79 | } | ||
| 80 | |||
| 81 | List<VisitDto> list = new ArrayList<VisitDto>( visits.size() ); | ||
| 82 | for ( Visit visit : visits ) { | for-each +1 | 2 |
| 83 | list.add( toVisitDto( visit ) ); | ||
| 84 | } | ||
| 85 | |||
| 86 | return list; | ||
| 87 | } |
VisitMapperImpl.visitPetOwnerFirstName(Visit) generated+2
| 129 | private String visitPetOwnerFirstName(Visit visit) { | ||
| 130 | Pet pet = visit.getPet(); | ||
| 131 | if ( pet == null ) { | if +1 | 3 |
| 132 | return null; | ||
| 133 | } | ||
| 134 | Owner owner = pet.getOwner(); | ||
| 135 | if ( owner == null ) { | if +1 | 4 |
| 136 | return null; | ||
| 137 | } | ||
| 138 | return owner.getFirstName(); | ||
| 139 | } |
VisitMapperImpl.visitPetOwnerId(Visit) generated+2
| 117 | private Integer visitPetOwnerId(Visit visit) { | ||
| 118 | Pet pet = visit.getPet(); | ||
| 119 | if ( pet == null ) { | if +1 | 5 |
| 120 | return null; | ||
| 121 | } | ||
| 122 | Owner owner = pet.getOwner(); | ||
| 123 | if ( owner == null ) { | if +1 | 6 |
| 124 | return null; | ||
| 125 | } | ||
| 126 | return owner.getId(); | ||
| 127 | } |
VisitMapperImpl.visitPetOwnerLastName(Visit) generated+2
| 141 | private String visitPetOwnerLastName(Visit visit) { | ||
| 142 | Pet pet = visit.getPet(); | ||
| 143 | if ( pet == null ) { | if +1 | 7 |
| 144 | return null; | ||
| 145 | } | ||
| 146 | Owner owner = pet.getOwner(); | ||
| 147 | if ( owner == null ) { | if +1 | 8 |
| 148 | return null; | ||
| 149 | } | ||
| 150 | return owner.getLastName(); | ||
| 151 | } |
PetMapperImpl.petOwnerId(Pet) generated+1
| 151 | private Integer petOwnerId(Pet pet) { | ||
| 152 | Owner owner = pet.getOwner(); | ||
| 153 | if ( owner == null ) { | if +1 | 9 |
| 154 | return null; | ||
| 155 | } | ||
| 156 | return owner.getId(); | ||
| 157 | } |
PetMapperImpl.toPetDto(Pet) generated+1
| 31 | public PetDto toPetDto(Pet pet) { | ||
| 32 | if ( pet == null ) { | if +1 | 10 |
| 33 | return null; | ||
| 34 | } | ||
| 35 | |||
| 36 | PetDto petDto = new PetDto(); | ||
| 37 | |||
| 38 | petDto.setOwnerId( petOwnerId( pet ) ); | ||
| 39 | petDto.setVisits( visitMapper.toVisitsDto( pet.getVisitsSortedByDate() ) ); | ||
| 40 | petDto.setName( pet.getName() ); | ||
| 41 | petDto.setBirthDate( pet.getBirthDate() ); | ||
| 42 | petDto.setType( toPetTypeDto( pet.getType() ) ); | ||
| 43 | petDto.setId( pet.getId() ); | ||
| 44 | |||
| 45 | return petDto; | ||
| 46 | } |
PetMapperImpl.toPetTypeDto(PetType) generated+1
| 110 | public PetTypeDto toPetTypeDto(PetType petType) { | ||
| 111 | if ( petType == null ) { | if +1 | 11 |
| 112 | return null; | ||
| 113 | } | ||
| 114 | |||
| 115 | PetTypeDto petTypeDto = new PetTypeDto(); | ||
| 116 | |||
| 117 | petTypeDto.setName( petType.getName() ); | ||
| 118 | petTypeDto.setId( petType.getId() ); | ||
| 119 | |||
| 120 | return petTypeDto; | ||
| 121 | } |
VisitMapperImpl.toVisitDto(Visit) generated+1
| 53 | public VisitDto toVisitDto(Visit visit) { | ||
| 54 | if ( visit == null ) { | if +1 | 12 |
| 55 | return null; | ||
| 56 | } | ||
| 57 | |||
| 58 | VisitDto visitDto = new VisitDto(); | ||
| 59 | |||
| 60 | visitDto.setPetId( visitPetId( visit ) ); | ||
| 61 | visitDto.setPetName( visitPetName( visit ) ); | ||
| 62 | visitDto.setOwnerId( visitPetOwnerId( visit ) ); | ||
| 63 | visitDto.setOwnerFirstName( visitPetOwnerFirstName( visit ) ); | ||
| 64 | visitDto.setOwnerLastName( visitPetOwnerLastName( visit ) ); | ||
| 65 | visitDto.setVetId( visitVetId( visit ) ); | ||
| 66 | visitDto.setVetFirstName( visitVetFirstName( visit ) ); | ||
| 67 | visitDto.setVetLastName( visitVetLastName( visit ) ); | ||
| 68 | visitDto.setDate( visit.getDate() ); | ||
| 69 | visitDto.setDescription( visit.getDescription() ); | ||
| 70 | visitDto.setId( visit.getId() ); | ||
| 71 | |||
| 72 | return visitDto; | ||
| 73 | } |
VisitMapperImpl.visitPetId(Visit) generated+1
| 101 | private Integer visitPetId(Visit visit) { | ||
| 102 | Pet pet = visit.getPet(); | ||
| 103 | if ( pet == null ) { | if +1 | 13 |
| 104 | return null; | ||
| 105 | } | ||
| 106 | return pet.getId(); | ||
| 107 | } |
VisitMapperImpl.visitPetName(Visit) generated+1
| 109 | private String visitPetName(Visit visit) { | ||
| 110 | Pet pet = visit.getPet(); | ||
| 111 | if ( pet == null ) { | if +1 | 14 |
| 112 | return null; | ||
| 113 | } | ||
| 114 | return pet.getName(); | ||
| 115 | } |
VisitMapperImpl.visitVetFirstName(Visit) generated+1
| 161 | private String visitVetFirstName(Visit visit) { | ||
| 162 | Vet vet = visit.getVet(); | ||
| 163 | if ( vet == null ) { | if +1 | 15 |
| 164 | return null; | ||
| 165 | } | ||
| 166 | return vet.getFirstName(); | ||
| 167 | } |
VisitMapperImpl.visitVetId(Visit) generated+1
| 153 | private Integer visitVetId(Visit visit) { | ||
| 154 | Vet vet = visit.getVet(); | ||
| 155 | if ( vet == null ) { | if +1 | 16 |
| 156 | return null; | ||
| 157 | } | ||
| 158 | return vet.getId(); | ||
| 159 | } |
VisitMapperImpl.visitVetLastName(Visit) generated+1
| 169 | private String visitVetLastName(Visit visit) { | ||
| 170 | Vet vet = visit.getVet(); | ||
| 171 | if ( vet == null ) { | if +1 | 17 |
| 172 | return null; | ||
| 173 | } | ||
| 174 | return vet.getLastName(); | ||
| 175 | } |
GET /api/pets/{petId} 13 methods cost something, out of 56 in the flow 17
VisitMapperImpl.toVisitsDto(List) generated+2
| 76 | public List<VisitDto> toVisitsDto(List<Visit> visits) { | ||
| 77 | if ( visits == null ) { | if +1 | 1 |
| 78 | return null; | ||
| 79 | } | ||
| 80 | |||
| 81 | List<VisitDto> list = new ArrayList<VisitDto>( visits.size() ); | ||
| 82 | for ( Visit visit : visits ) { | for-each +1 | 2 |
| 83 | list.add( toVisitDto( visit ) ); | ||
| 84 | } | ||
| 85 | |||
| 86 | return list; | ||
| 87 | } |
VisitMapperImpl.visitPetOwnerFirstName(Visit) generated+2
| 129 | private String visitPetOwnerFirstName(Visit visit) { | ||
| 130 | Pet pet = visit.getPet(); | ||
| 131 | if ( pet == null ) { | if +1 | 3 |
| 132 | return null; | ||
| 133 | } | ||
| 134 | Owner owner = pet.getOwner(); | ||
| 135 | if ( owner == null ) { | if +1 | 4 |
| 136 | return null; | ||
| 137 | } | ||
| 138 | return owner.getFirstName(); | ||
| 139 | } |
VisitMapperImpl.visitPetOwnerId(Visit) generated+2
| 117 | private Integer visitPetOwnerId(Visit visit) { | ||
| 118 | Pet pet = visit.getPet(); | ||
| 119 | if ( pet == null ) { | if +1 | 5 |
| 120 | return null; | ||
| 121 | } | ||
| 122 | Owner owner = pet.getOwner(); | ||
| 123 | if ( owner == null ) { | if +1 | 6 |
| 124 | return null; | ||
| 125 | } | ||
| 126 | return owner.getId(); | ||
| 127 | } |
VisitMapperImpl.visitPetOwnerLastName(Visit) generated+2
| 141 | private String visitPetOwnerLastName(Visit visit) { | ||
| 142 | Pet pet = visit.getPet(); | ||
| 143 | if ( pet == null ) { | if +1 | 7 |
| 144 | return null; | ||
| 145 | } | ||
| 146 | Owner owner = pet.getOwner(); | ||
| 147 | if ( owner == null ) { | if +1 | 8 |
| 148 | return null; | ||
| 149 | } | ||
| 150 | return owner.getLastName(); | ||
| 151 | } |
PetMapperImpl.petOwnerId(Pet) generated+1
| 151 | private Integer petOwnerId(Pet pet) { | ||
| 152 | Owner owner = pet.getOwner(); | ||
| 153 | if ( owner == null ) { | if +1 | 9 |
| 154 | return null; | ||
| 155 | } | ||
| 156 | return owner.getId(); | ||
| 157 | } |
PetMapperImpl.toPetDto(Pet) generated+1
| 31 | public PetDto toPetDto(Pet pet) { | ||
| 32 | if ( pet == null ) { | if +1 | 10 |
| 33 | return null; | ||
| 34 | } | ||
| 35 | |||
| 36 | PetDto petDto = new PetDto(); | ||
| 37 | |||
| 38 | petDto.setOwnerId( petOwnerId( pet ) ); | ||
| 39 | petDto.setVisits( visitMapper.toVisitsDto( pet.getVisitsSortedByDate() ) ); | ||
| 40 | petDto.setName( pet.getName() ); | ||
| 41 | petDto.setBirthDate( pet.getBirthDate() ); | ||
| 42 | petDto.setType( toPetTypeDto( pet.getType() ) ); | ||
| 43 | petDto.setId( pet.getId() ); | ||
| 44 | |||
| 45 | return petDto; | ||
| 46 | } |
PetMapperImpl.toPetTypeDto(PetType) generated+1
| 110 | public PetTypeDto toPetTypeDto(PetType petType) { | ||
| 111 | if ( petType == null ) { | if +1 | 11 |
| 112 | return null; | ||
| 113 | } | ||
| 114 | |||
| 115 | PetTypeDto petTypeDto = new PetTypeDto(); | ||
| 116 | |||
| 117 | petTypeDto.setName( petType.getName() ); | ||
| 118 | petTypeDto.setId( petType.getId() ); | ||
| 119 | |||
| 120 | return petTypeDto; | ||
| 121 | } |
VisitMapperImpl.toVisitDto(Visit) generated+1
| 53 | public VisitDto toVisitDto(Visit visit) { | ||
| 54 | if ( visit == null ) { | if +1 | 12 |
| 55 | return null; | ||
| 56 | } | ||
| 57 | |||
| 58 | VisitDto visitDto = new VisitDto(); | ||
| 59 | |||
| 60 | visitDto.setPetId( visitPetId( visit ) ); | ||
| 61 | visitDto.setPetName( visitPetName( visit ) ); | ||
| 62 | visitDto.setOwnerId( visitPetOwnerId( visit ) ); | ||
| 63 | visitDto.setOwnerFirstName( visitPetOwnerFirstName( visit ) ); | ||
| 64 | visitDto.setOwnerLastName( visitPetOwnerLastName( visit ) ); | ||
| 65 | visitDto.setVetId( visitVetId( visit ) ); | ||
| 66 | visitDto.setVetFirstName( visitVetFirstName( visit ) ); | ||
| 67 | visitDto.setVetLastName( visitVetLastName( visit ) ); | ||
| 68 | visitDto.setDate( visit.getDate() ); | ||
| 69 | visitDto.setDescription( visit.getDescription() ); | ||
| 70 | visitDto.setId( visit.getId() ); | ||
| 71 | |||
| 72 | return visitDto; | ||
| 73 | } |
VisitMapperImpl.visitPetId(Visit) generated+1
| 101 | private Integer visitPetId(Visit visit) { | ||
| 102 | Pet pet = visit.getPet(); | ||
| 103 | if ( pet == null ) { | if +1 | 13 |
| 104 | return null; | ||
| 105 | } | ||
| 106 | return pet.getId(); | ||
| 107 | } |
VisitMapperImpl.visitPetName(Visit) generated+1
| 109 | private String visitPetName(Visit visit) { | ||
| 110 | Pet pet = visit.getPet(); | ||
| 111 | if ( pet == null ) { | if +1 | 14 |
| 112 | return null; | ||
| 113 | } | ||
| 114 | return pet.getName(); | ||
| 115 | } |
VisitMapperImpl.visitVetFirstName(Visit) generated+1
| 161 | private String visitVetFirstName(Visit visit) { | ||
| 162 | Vet vet = visit.getVet(); | ||
| 163 | if ( vet == null ) { | if +1 | 15 |
| 164 | return null; | ||
| 165 | } | ||
| 166 | return vet.getFirstName(); | ||
| 167 | } |
VisitMapperImpl.visitVetId(Visit) generated+1
| 153 | private Integer visitVetId(Visit visit) { | ||
| 154 | Vet vet = visit.getVet(); | ||
| 155 | if ( vet == null ) { | if +1 | 16 |
| 156 | return null; | ||
| 157 | } | ||
| 158 | return vet.getId(); | ||
| 159 | } |
VisitMapperImpl.visitVetLastName(Visit) generated+1
| 169 | private String visitVetLastName(Visit visit) { | ||
| 170 | Vet vet = visit.getVet(); | ||
| 171 | if ( vet == null ) { | if +1 | 17 |
| 172 | return null; | ||
| 173 | } | ||
| 174 | return vet.getLastName(); | ||
| 175 | } |
POST /api/users 7 methods cost something, out of 34 in the flow 15
UserRestController.addUser(UserDto)+7
| 27 | public ResponseEntity<UserDto> addUser(@RequestBody @Validated UserDto userDto) { | ||
| 28 | User user = userMapper.toUser(userDto); | ||
| 29 | |||
| 30 | if (user.getRoles() == null || user.getRoles().isEmpty()) { | if +1|| +1 | 2 |
| 31 | throw new IllegalArgumentException("User must have at least a role set!"); | ||
| 32 | } | ||
| 33 | |||
| 34 | for (Role role : user.getRoles()) { | for-each +1 | 3 |
| 35 | if (!role.getName().startsWith("ROLE_")) { | if +2 · nesting 1 | 5 |
| 36 | role.setName("ROLE_" + role.getName()); | ||
| 37 | } | ||
| 38 | |||
| 39 | if (role.getUser() == null) { | if +2 · nesting 1 | 7 |
| 40 | role.setUser(user); | ||
| 41 | } | ||
| 42 | } | ||
| 43 | |||
| 44 | userRepository.save(user); | ||
| 45 | return ResponseEntity.created(UriComponentsBuilder.fromPath("/api/users/{username}") | ||
| 46 | .buildAndExpand(user.getUsername()).toUri()) | ||
| 47 | .body(userMapper.toUserDto(user)); | ||
| 48 | } |
UserMapperImpl.roleDtoListToRoleSet(List) generated+2
| 66 | protected Set<Role> roleDtoListToRoleSet(List<RoleDto> list) { | ||
| 67 | if ( list == null ) { | if +1 | 8 |
| 68 | return null; | ||
| 69 | } | ||
| 70 | |||
| 71 | Set<Role> set = LinkedHashSet.newLinkedHashSet( list.size() ); | ||
| 72 | for ( RoleDto roleDto : list ) { | for-each +1 | 9 |
| 73 | set.add( roleDtoToRole( roleDto ) ); | ||
| 74 | } | ||
| 75 | |||
| 76 | return set; | ||
| 77 | } |
UserMapperImpl.roleSetToRoleDtoList(Set) generated+2
| 91 | protected List<RoleDto> roleSetToRoleDtoList(Set<Role> set) { | ||
| 92 | if ( set == null ) { | if +1 | 10 |
| 93 | return null; | ||
| 94 | } | ||
| 95 | |||
| 96 | List<RoleDto> list = new ArrayList<RoleDto>( set.size() ); | ||
| 97 | for ( Role role : set ) { | for-each +1 | 11 |
| 98 | list.add( roleToRoleDto( role ) ); | ||
| 99 | } | ||
| 100 | |||
| 101 | return list; | ||
| 102 | } |
UserMapperImpl.roleDtoToRole(RoleDto) generated+1
| 54 | protected Role roleDtoToRole(RoleDto roleDto) { | ||
| 55 | if ( roleDto == null ) { | if +1 | 12 |
| 56 | return null; | ||
| 57 | } | ||
| 58 | |||
| 59 | Role role = new Role(); | ||
| 60 | |||
| 61 | role.setName( roleDto.getName() ); | ||
| 62 | |||
| 63 | return role; | ||
| 64 | } |
UserMapperImpl.roleToRoleDto(Role) generated+1
| 79 | protected RoleDto roleToRoleDto(Role role) { | ||
| 80 | if ( role == null ) { | if +1 | 13 |
| 81 | return null; | ||
| 82 | } | ||
| 83 | |||
| 84 | RoleDto roleDto = new RoleDto(); | ||
| 85 | |||
| 86 | roleDto.setName( role.getName() ); | ||
| 87 | |||
| 88 | return roleDto; | ||
| 89 | } |
UserMapperImpl.toUser(UserDto) generated+1
| 23 | public User toUser(UserDto userDto) { | ||
| 24 | if ( userDto == null ) { | if +1 | 14 |
| 25 | return null; | ||
| 26 | } | ||
| 27 | |||
| 28 | User user = new User(); | ||
| 29 | |||
| 30 | user.setUsername( userDto.getUsername() ); | ||
| 31 | user.setPassword( userDto.getPassword() ); | ||
| 32 | user.setEnabled( userDto.getEnabled() ); | ||
| 33 | user.setRoles( roleDtoListToRoleSet( userDto.getRoles() ) ); | ||
| 34 | |||
| 35 | return user; | ||
| 36 | } |
UserMapperImpl.toUserDto(User) generated+1
| 39 | public UserDto toUserDto(User user) { | ||
| 40 | if ( user == null ) { | if +1 | 15 |
| 41 | return null; | ||
| 42 | } | ||
| 43 | |||
| 44 | UserDto userDto = new UserDto(); | ||
| 45 | |||
| 46 | userDto.setUsername( user.getUsername() ); | ||
| 47 | userDto.setPassword( user.getPassword() ); | ||
| 48 | userDto.setEnabled( user.getEnabled() ); | ||
| 49 | userDto.setRoles( roleSetToRoleDtoList( user.getRoles() ) ); | ||
| 50 | |||
| 51 | return userDto; | ||
| 52 | } |
GET /api/visits 10 methods cost something, out of 38 in the flow 14
VisitMapperImpl.toVisitsDto(List) generated+2
| 76 | public List<VisitDto> toVisitsDto(List<Visit> visits) { | ||
| 77 | if ( visits == null ) { | if +1 | 1 |
| 78 | return null; | ||
| 79 | } | ||
| 80 | |||
| 81 | List<VisitDto> list = new ArrayList<VisitDto>( visits.size() ); | ||
| 82 | for ( Visit visit : visits ) { | for-each +1 | 2 |
| 83 | list.add( toVisitDto( visit ) ); | ||
| 84 | } | ||
| 85 | |||
| 86 | return list; | ||
| 87 | } |
VisitMapperImpl.visitPetOwnerFirstName(Visit) generated+2
| 129 | private String visitPetOwnerFirstName(Visit visit) { | ||
| 130 | Pet pet = visit.getPet(); | ||
| 131 | if ( pet == null ) { | if +1 | 3 |
| 132 | return null; | ||
| 133 | } | ||
| 134 | Owner owner = pet.getOwner(); | ||
| 135 | if ( owner == null ) { | if +1 | 4 |
| 136 | return null; | ||
| 137 | } | ||
| 138 | return owner.getFirstName(); | ||
| 139 | } |
VisitMapperImpl.visitPetOwnerId(Visit) generated+2
| 117 | private Integer visitPetOwnerId(Visit visit) { | ||
| 118 | Pet pet = visit.getPet(); | ||
| 119 | if ( pet == null ) { | if +1 | 5 |
| 120 | return null; | ||
| 121 | } | ||
| 122 | Owner owner = pet.getOwner(); | ||
| 123 | if ( owner == null ) { | if +1 | 6 |
| 124 | return null; | ||
| 125 | } | ||
| 126 | return owner.getId(); | ||
| 127 | } |
VisitMapperImpl.visitPetOwnerLastName(Visit) generated+2
| 141 | private String visitPetOwnerLastName(Visit visit) { | ||
| 142 | Pet pet = visit.getPet(); | ||
| 143 | if ( pet == null ) { | if +1 | 7 |
| 144 | return null; | ||
| 145 | } | ||
| 146 | Owner owner = pet.getOwner(); | ||
| 147 | if ( owner == null ) { | if +1 | 8 |
| 148 | return null; | ||
| 149 | } | ||
| 150 | return owner.getLastName(); | ||
| 151 | } |
VisitMapperImpl.toVisitDto(Visit) generated+1
| 53 | public VisitDto toVisitDto(Visit visit) { | ||
| 54 | if ( visit == null ) { | if +1 | 9 |
| 55 | return null; | ||
| 56 | } | ||
| 57 | |||
| 58 | VisitDto visitDto = new VisitDto(); | ||
| 59 | |||
| 60 | visitDto.setPetId( visitPetId( visit ) ); | ||
| 61 | visitDto.setPetName( visitPetName( visit ) ); | ||
| 62 | visitDto.setOwnerId( visitPetOwnerId( visit ) ); | ||
| 63 | visitDto.setOwnerFirstName( visitPetOwnerFirstName( visit ) ); | ||
| 64 | visitDto.setOwnerLastName( visitPetOwnerLastName( visit ) ); | ||
| 65 | visitDto.setVetId( visitVetId( visit ) ); | ||
| 66 | visitDto.setVetFirstName( visitVetFirstName( visit ) ); | ||
| 67 | visitDto.setVetLastName( visitVetLastName( visit ) ); | ||
| 68 | visitDto.setDate( visit.getDate() ); | ||
| 69 | visitDto.setDescription( visit.getDescription() ); | ||
| 70 | visitDto.setId( visit.getId() ); | ||
| 71 | |||
| 72 | return visitDto; | ||
| 73 | } |
VisitMapperImpl.visitPetId(Visit) generated+1
| 101 | private Integer visitPetId(Visit visit) { | ||
| 102 | Pet pet = visit.getPet(); | ||
| 103 | if ( pet == null ) { | if +1 | 10 |
| 104 | return null; | ||
| 105 | } | ||
| 106 | return pet.getId(); | ||
| 107 | } |
VisitMapperImpl.visitPetName(Visit) generated+1
| 109 | private String visitPetName(Visit visit) { | ||
| 110 | Pet pet = visit.getPet(); | ||
| 111 | if ( pet == null ) { | if +1 | 11 |
| 112 | return null; | ||
| 113 | } | ||
| 114 | return pet.getName(); | ||
| 115 | } |
VisitMapperImpl.visitVetFirstName(Visit) generated+1
| 161 | private String visitVetFirstName(Visit visit) { | ||
| 162 | Vet vet = visit.getVet(); | ||
| 163 | if ( vet == null ) { | if +1 | 12 |
| 164 | return null; | ||
| 165 | } | ||
| 166 | return vet.getFirstName(); | ||
| 167 | } |
VisitMapperImpl.visitVetId(Visit) generated+1
| 153 | private Integer visitVetId(Visit visit) { | ||
| 154 | Vet vet = visit.getVet(); | ||
| 155 | if ( vet == null ) { | if +1 | 13 |
| 156 | return null; | ||
| 157 | } | ||
| 158 | return vet.getId(); | ||
| 159 | } |
VisitMapperImpl.visitVetLastName(Visit) generated+1
| 169 | private String visitVetLastName(Visit visit) { | ||
| 170 | Vet vet = visit.getVet(); | ||
| 171 | if ( vet == null ) { | if +1 | 14 |
| 172 | return null; | ||
| 173 | } | ||
| 174 | return vet.getLastName(); | ||
| 175 | } |
GET /api/visits/{visitId} 9 methods cost something, out of 37 in the flow 12
VisitMapperImpl.visitPetOwnerFirstName(Visit) generated+2
| 129 | private String visitPetOwnerFirstName(Visit visit) { | ||
| 130 | Pet pet = visit.getPet(); | ||
| 131 | if ( pet == null ) { | if +1 | 1 |
| 132 | return null; | ||
| 133 | } | ||
| 134 | Owner owner = pet.getOwner(); | ||
| 135 | if ( owner == null ) { | if +1 | 2 |
| 136 | return null; | ||
| 137 | } | ||
| 138 | return owner.getFirstName(); | ||
| 139 | } |
VisitMapperImpl.visitPetOwnerId(Visit) generated+2
| 117 | private Integer visitPetOwnerId(Visit visit) { | ||
| 118 | Pet pet = visit.getPet(); | ||
| 119 | if ( pet == null ) { | if +1 | 3 |
| 120 | return null; | ||
| 121 | } | ||
| 122 | Owner owner = pet.getOwner(); | ||
| 123 | if ( owner == null ) { | if +1 | 4 |
| 124 | return null; | ||
| 125 | } | ||
| 126 | return owner.getId(); | ||
| 127 | } |
VisitMapperImpl.visitPetOwnerLastName(Visit) generated+2
| 141 | private String visitPetOwnerLastName(Visit visit) { | ||
| 142 | Pet pet = visit.getPet(); | ||
| 143 | if ( pet == null ) { | if +1 | 5 |
| 144 | return null; | ||
| 145 | } | ||
| 146 | Owner owner = pet.getOwner(); | ||
| 147 | if ( owner == null ) { | if +1 | 6 |
| 148 | return null; | ||
| 149 | } | ||
| 150 | return owner.getLastName(); | ||
| 151 | } |
VisitMapperImpl.toVisitDto(Visit) generated+1
| 53 | public VisitDto toVisitDto(Visit visit) { | ||
| 54 | if ( visit == null ) { | if +1 | 7 |
| 55 | return null; | ||
| 56 | } | ||
| 57 | |||
| 58 | VisitDto visitDto = new VisitDto(); | ||
| 59 | |||
| 60 | visitDto.setPetId( visitPetId( visit ) ); | ||
| 61 | visitDto.setPetName( visitPetName( visit ) ); | ||
| 62 | visitDto.setOwnerId( visitPetOwnerId( visit ) ); | ||
| 63 | visitDto.setOwnerFirstName( visitPetOwnerFirstName( visit ) ); | ||
| 64 | visitDto.setOwnerLastName( visitPetOwnerLastName( visit ) ); | ||
| 65 | visitDto.setVetId( visitVetId( visit ) ); | ||
| 66 | visitDto.setVetFirstName( visitVetFirstName( visit ) ); | ||
| 67 | visitDto.setVetLastName( visitVetLastName( visit ) ); | ||
| 68 | visitDto.setDate( visit.getDate() ); | ||
| 69 | visitDto.setDescription( visit.getDescription() ); | ||
| 70 | visitDto.setId( visit.getId() ); | ||
| 71 | |||
| 72 | return visitDto; | ||
| 73 | } |
VisitMapperImpl.visitPetId(Visit) generated+1
| 101 | private Integer visitPetId(Visit visit) { | ||
| 102 | Pet pet = visit.getPet(); | ||
| 103 | if ( pet == null ) { | if +1 | 8 |
| 104 | return null; | ||
| 105 | } | ||
| 106 | return pet.getId(); | ||
| 107 | } |
VisitMapperImpl.visitPetName(Visit) generated+1
| 109 | private String visitPetName(Visit visit) { | ||
| 110 | Pet pet = visit.getPet(); | ||
| 111 | if ( pet == null ) { | if +1 | 9 |
| 112 | return null; | ||
| 113 | } | ||
| 114 | return pet.getName(); | ||
| 115 | } |
VisitMapperImpl.visitVetFirstName(Visit) generated+1
| 161 | private String visitVetFirstName(Visit visit) { | ||
| 162 | Vet vet = visit.getVet(); | ||
| 163 | if ( vet == null ) { | if +1 | 10 |
| 164 | return null; | ||
| 165 | } | ||
| 166 | return vet.getFirstName(); | ||
| 167 | } |
VisitMapperImpl.visitVetId(Visit) generated+1
| 153 | private Integer visitVetId(Visit visit) { | ||
| 154 | Vet vet = visit.getVet(); | ||
| 155 | if ( vet == null ) { | if +1 | 11 |
| 156 | return null; | ||
| 157 | } | ||
| 158 | return vet.getId(); | ||
| 159 | } |
VisitMapperImpl.visitVetLastName(Visit) generated+1
| 169 | private String visitVetLastName(Visit visit) { | ||
| 170 | Vet vet = visit.getVet(); | ||
| 171 | if ( vet == null ) { | if +1 | 12 |
| 172 | return null; | ||
| 173 | } | ||
| 174 | return vet.getLastName(); | ||
| 175 | } |
GET /api/vets 4 methods cost something, out of 22 in the flow 6
SpecialtyMapperImpl.toSpecialtyDtos(List) generated+2
| 49 | public List<SpecialtyDto> toSpecialtyDtos(List<Specialty> specialties) { | ||
| 50 | if ( specialties == null ) { | if +1 | 1 |
| 51 | return null; | ||
| 52 | } | ||
| 53 | |||
| 54 | List<SpecialtyDto> list = new ArrayList<SpecialtyDto>( specialties.size() ); | ||
| 55 | for ( Specialty specialty : specialties ) { | for-each +1 | 2 |
| 56 | list.add( toSpecialtyDto( specialty ) ); | ||
| 57 | } | ||
| 58 | |||
| 59 | return list; | ||
| 60 | } |
VetMapperImpl.toVetDtos(List) generated+2
| 71 | public List<VetDto> toVetDtos(List<Vet> vets) { | ||
| 72 | if ( vets == null ) { | if +1 | 3 |
| 73 | return null; | ||
| 74 | } | ||
| 75 | |||
| 76 | List<VetDto> list = new ArrayList<VetDto>( vets.size() ); | ||
| 77 | for ( Vet vet : vets ) { | for-each +1 | 4 |
| 78 | list.add( toVetDto( vet ) ); | ||
| 79 | } | ||
| 80 | |||
| 81 | return list; | ||
| 82 | } |
SpecialtyMapperImpl.toSpecialtyDto(Specialty) generated+1
| 34 | public SpecialtyDto toSpecialtyDto(Specialty specialty) { | ||
| 35 | if ( specialty == null ) { | if +1 | 5 |
| 36 | return null; | ||
| 37 | } | ||
| 38 | |||
| 39 | SpecialtyDto specialtyDto = new SpecialtyDto(); | ||
| 40 | |||
| 41 | specialtyDto.setId( specialty.getId() ); | ||
| 42 | specialtyDto.setName( specialty.getName() ); | ||
| 43 | specialtyDto.setDescription( specialty.getDescription() ); | ||
| 44 | |||
| 45 | return specialtyDto; | ||
| 46 | } |
VetMapperImpl.toVetDto(Vet) generated+1
| 55 | public VetDto toVetDto(Vet vet) { | ||
| 56 | if ( vet == null ) { | if +1 | 6 |
| 57 | return null; | ||
| 58 | } | ||
| 59 | |||
| 60 | VetDto vetDto = new VetDto(); | ||
| 61 | |||
| 62 | vetDto.setFirstName( vet.getFirstName() ); | ||
| 63 | vetDto.setLastName( vet.getLastName() ); | ||
| 64 | vetDto.setSpecialties( specialtyMapper.toSpecialtyDtos( vet.getSpecialties() ) ); | ||
| 65 | vetDto.setId( vet.getId() ); | ||
| 66 | |||
| 67 | return vetDto; | ||
| 68 | } |
POST /api/vets 4 methods cost something, out of 27 in the flow 5
SpecialtyMapperImpl.toSpecialty(List) generated+2
| 63 | public List<Specialty> toSpecialty(List<SpecialtyDto> specialties) { | ||
| 64 | if ( specialties == null ) { | if +1 | 1 |
| 65 | return null; | ||
| 66 | } | ||
| 67 | |||
| 68 | List<Specialty> list = new ArrayList<Specialty>( specialties.size() ); | ||
| 69 | for ( SpecialtyDto specialtyDto : specialties ) { | for-each +1 | 2 |
| 70 | list.add( toSpecialty( specialtyDto ) ); | ||
| 71 | } | ||
| 72 | |||
| 73 | return list; | ||
| 74 | } |
SpecialtyMapperImpl.toSpecialty(SpecialtyDto) generated+1
| 19 | public Specialty toSpecialty(SpecialtyDto specialtyDto) { | ||
| 20 | if ( specialtyDto == null ) { | if +1 | 3 |
| 21 | return null; | ||
| 22 | } | ||
| 23 | |||
| 24 | Specialty specialty = new Specialty(); | ||
| 25 | |||
| 26 | specialty.setId( specialtyDto.getId() ); | ||
| 27 | specialty.setName( specialtyDto.getName() ); | ||
| 28 | specialty.setDescription( specialtyDto.getDescription() ); | ||
| 29 | |||
| 30 | return specialty; | ||
| 31 | } |
VetMapperImpl.toVet(VetDto) generated+1
| 24 | public Vet toVet(VetDto vetDto) { | ||
| 25 | if ( vetDto == null ) { | if +1 | 4 |
| 26 | return null; | ||
| 27 | } | ||
| 28 | |||
| 29 | Vet vet = new Vet(); | ||
| 30 | |||
| 31 | vet.setId( vetDto.getId() ); | ||
| 32 | vet.setFirstName( vetDto.getFirstName() ); | ||
| 33 | vet.setLastName( vetDto.getLastName() ); | ||
| 34 | vet.setSpecialties( specialtyMapper.toSpecialty( vetDto.getSpecialties() ) ); | ||
| 35 | |||
| 36 | return vet; | ||
| 37 | } |
VetRestController.updateSpecialties(Vet)+1
| 76 | private void updateSpecialties(Vet currentVet) { | ||
| 77 | if (currentVet.getNrOfSpecialties() > 0) { | if +1 | 5 |
| 78 | Set<String> names = currentVet.getSpecialties().stream().map(Specialty::getName) | ||
| 79 | .collect(Collectors.toSet()); | ||
| 80 | List<Specialty> vetSpecialities = specialtyRepository.findSpecialtiesByNameIn(names); | ||
| 81 | currentVet.setSpecialties(vetSpecialities); | ||
| 82 | } | ||
| 83 | vetRepository.save(currentVet); | ||
| 84 | } |
PUT /api/vets/{vetId} 4 methods cost something, out of 25 in the flow 5
SpecialtyMapperImpl.toSpecialty(List) generated+2
| 63 | public List<Specialty> toSpecialty(List<SpecialtyDto> specialties) { | ||
| 64 | if ( specialties == null ) { | if +1 | 1 |
| 65 | return null; | ||
| 66 | } | ||
| 67 | |||
| 68 | List<Specialty> list = new ArrayList<Specialty>( specialties.size() ); | ||
| 69 | for ( SpecialtyDto specialtyDto : specialties ) { | for-each +1 | 2 |
| 70 | list.add( toSpecialty( specialtyDto ) ); | ||
| 71 | } | ||
| 72 | |||
| 73 | return list; | ||
| 74 | } |
SpecialtyMapperImpl.toSpecialty(SpecialtyDto) generated+1
| 19 | public Specialty toSpecialty(SpecialtyDto specialtyDto) { | ||
| 20 | if ( specialtyDto == null ) { | if +1 | 3 |
| 21 | return null; | ||
| 22 | } | ||
| 23 | |||
| 24 | Specialty specialty = new Specialty(); | ||
| 25 | |||
| 26 | specialty.setId( specialtyDto.getId() ); | ||
| 27 | specialty.setName( specialtyDto.getName() ); | ||
| 28 | specialty.setDescription( specialtyDto.getDescription() ); | ||
| 29 | |||
| 30 | return specialty; | ||
| 31 | } |
VetRestController.updateSpecialties(Vet)+1
| 76 | private void updateSpecialties(Vet currentVet) { | ||
| 77 | if (currentVet.getNrOfSpecialties() > 0) { | if +1 | 4 |
| 78 | Set<String> names = currentVet.getSpecialties().stream().map(Specialty::getName) | ||
| 79 | .collect(Collectors.toSet()); | ||
| 80 | List<Specialty> vetSpecialities = specialtyRepository.findSpecialtiesByNameIn(names); | ||
| 81 | currentVet.setSpecialties(vetSpecialities); | ||
| 82 | } | ||
| 83 | vetRepository.save(currentVet); | ||
| 84 | } |
VetRestController.updateVet(int, VetDto)+1
| 65 | public void updateVet(@PathVariable int vetId, @RequestBody VetDto vetDto) { | ||
| 66 | Vet currentVet = vetRepository.findById(vetId).orElseThrow(); | ||
| 67 | currentVet.setFirstName(vetDto.getFirstName()); | ||
| 68 | currentVet.setLastName(vetDto.getLastName()); | ||
| 69 | currentVet.clearSpecialties(); | ||
| 70 | for (Specialty spec : specialtyMapper.toSpecialty(vetDto.getSpecialties())) { | for-each +1 | 5 |
| 71 | currentVet.addSpecialty(spec); | ||
| 72 | } | ||
| 73 | updateSpecialties(currentVet); | ||
| 74 | } |
GET /api/vets/{vetId} 3 methods cost something, out of 21 in the flow 4
SpecialtyMapperImpl.toSpecialtyDtos(List) generated+2
| 49 | public List<SpecialtyDto> toSpecialtyDtos(List<Specialty> specialties) { | ||
| 50 | if ( specialties == null ) { | if +1 | 1 |
| 51 | return null; | ||
| 52 | } | ||
| 53 | |||
| 54 | List<SpecialtyDto> list = new ArrayList<SpecialtyDto>( specialties.size() ); | ||
| 55 | for ( Specialty specialty : specialties ) { | for-each +1 | 2 |
| 56 | list.add( toSpecialtyDto( specialty ) ); | ||
| 57 | } | ||
| 58 | |||
| 59 | return list; | ||
| 60 | } |
SpecialtyMapperImpl.toSpecialtyDto(Specialty) generated+1
| 34 | public SpecialtyDto toSpecialtyDto(Specialty specialty) { | ||
| 35 | if ( specialty == null ) { | if +1 | 3 |
| 36 | return null; | ||
| 37 | } | ||
| 38 | |||
| 39 | SpecialtyDto specialtyDto = new SpecialtyDto(); | ||
| 40 | |||
| 41 | specialtyDto.setId( specialty.getId() ); | ||
| 42 | specialtyDto.setName( specialty.getName() ); | ||
| 43 | specialtyDto.setDescription( specialty.getDescription() ); | ||
| 44 | |||
| 45 | return specialtyDto; | ||
| 46 | } |
VetMapperImpl.toVetDto(Vet) generated+1
| 55 | public VetDto toVetDto(Vet vet) { | ||
| 56 | if ( vet == null ) { | if +1 | 4 |
| 57 | return null; | ||
| 58 | } | ||
| 59 | |||
| 60 | VetDto vetDto = new VetDto(); | ||
| 61 | |||
| 62 | vetDto.setFirstName( vet.getFirstName() ); | ||
| 63 | vetDto.setLastName( vet.getLastName() ); | ||
| 64 | vetDto.setSpecialties( specialtyMapper.toSpecialtyDtos( vet.getSpecialties() ) ); | ||
| 65 | vetDto.setId( vet.getId() ); | ||
| 66 | |||
| 67 | return vetDto; | ||
| 68 | } |
POST /api/visits 4 methods cost something, out of 22 in the flow 4
VetRepository.getByIdOrNull(Integer)+1
| 29 | default Vet getByIdOrNull(@Nullable Integer vetId) { | ||
| 30 | if (vetId == null) { | if +1 | 1 |
| 31 | return null; | ||
| 32 | } | ||
| 33 | return findByIdWithoutSpecialties(vetId).orElseThrow(); | ||
| 34 | } |
VisitMapperImpl.toVisit(VisitDto) generated+1
| 23 | public Visit toVisit(VisitDto visitDto) { | ||
| 24 | if ( visitDto == null ) { | if +1 | 2 |
| 25 | return null; | ||
| 26 | } | ||
| 27 | |||
| 28 | Visit visit = new Visit(); | ||
| 29 | |||
| 30 | visit.setPet( visitDtoToPet( visitDto ) ); | ||
| 31 | visit.setId( visitDto.getId() ); | ||
| 32 | visit.setDate( visitDto.getDate() ); | ||
| 33 | visit.setDescription( visitDto.getDescription() ); | ||
| 34 | |||
| 35 | return visit; | ||
| 36 | } |
VisitMapperImpl.visitDtoToPet(VisitDto) generated+1
| 89 | protected Pet visitDtoToPet(VisitDto visitDto) { | ||
| 90 | if ( visitDto == null ) { | if +1 | 3 |
| 91 | return null; | ||
| 92 | } | ||
| 93 | |||
| 94 | Pet pet = new Pet(); | ||
| 95 | |||
| 96 | pet.setId( visitDto.getPetId() ); | ||
| 97 | |||
| 98 | return pet; | ||
| 99 | } |
VisitRestController.resolveVet(Integer)+1
| 89 | private Vet resolveVet(Integer vetId) { | ||
| 90 | try { | ||
| 91 | return vetRepository.getByIdOrNull(vetId); | ||
| 92 | } catch (NoSuchElementException e) { | catch +1 | 4 |
| 93 | log.warn("Rejecting visit: attending vet id {} does not exist", vetId); | ||
| 94 | throw e; | ||
| 95 | } | ||
| 96 | } |
POST /api/owners/{ownerId}/pets/{petId}/visits 3 methods cost something, out of 17 in the flow 3
OwnerRestController.resolveVet(Integer)+1
| 168 | private Vet resolveVet(Integer vetId) { | ||
| 169 | try { | ||
| 170 | return vetRepository.getByIdOrNull(vetId); | ||
| 171 | } catch (NoSuchElementException e) { | catch +1 | 1 |
| 172 | log.warn("Rejecting visit: attending vet id {} does not exist", vetId); | ||
| 173 | throw e; | ||
| 174 | } | ||
| 175 | } |
VetRepository.getByIdOrNull(Integer)+1
| 29 | default Vet getByIdOrNull(@Nullable Integer vetId) { | ||
| 30 | if (vetId == null) { | if +1 | 2 |
| 31 | return null; | ||
| 32 | } | ||
| 33 | return findByIdWithoutSpecialties(vetId).orElseThrow(); | ||
| 34 | } |
VisitMapperImpl.toVisit(VisitFieldsDto) generated+1
| 39 | public Visit toVisit(VisitFieldsDto visitFieldsDto) { | ||
| 40 | if ( visitFieldsDto == null ) { | if +1 | 3 |
| 41 | return null; | ||
| 42 | } | ||
| 43 | |||
| 44 | Visit visit = new Visit(); | ||
| 45 | |||
| 46 | visit.setDate( visitFieldsDto.getDate() ); | ||
| 47 | visit.setDescription( visitFieldsDto.getDescription() ); | ||
| 48 | |||
| 49 | return visit; | ||
| 50 | } |
GET /api/pettypes 2 methods cost something, out of 9 in the flow 3
PetTypeMapperImpl.toPetTypeDtos(List) generated+2
| 60 | public List<PetTypeDto> toPetTypeDtos(List<PetType> petTypes) { | ||
| 61 | if ( petTypes == null ) { | if +1 | 1 |
| 62 | return null; | ||
| 63 | } | ||
| 64 | |||
| 65 | List<PetTypeDto> list = new ArrayList<PetTypeDto>( petTypes.size() ); | ||
| 66 | for ( PetType petType : petTypes ) { | for-each +1 | 2 |
| 67 | list.add( toPetTypeDto( petType ) ); | ||
| 68 | } | ||
| 69 | |||
| 70 | return list; | ||
| 71 | } |
PetTypeMapperImpl.toPetTypeDto(PetType) generated+1
| 33 | public PetTypeDto toPetTypeDto(PetType petType) { | ||
| 34 | if ( petType == null ) { | if +1 | 3 |
| 35 | return null; | ||
| 36 | } | ||
| 37 | |||
| 38 | PetTypeDto petTypeDto = new PetTypeDto(); | ||
| 39 | |||
| 40 | petTypeDto.setName( petType.getName() ); | ||
| 41 | petTypeDto.setId( petType.getId() ); | ||
| 42 | |||
| 43 | return petTypeDto; | ||
| 44 | } |
GET /api/specialties 2 methods cost something, out of 11 in the flow 3
SpecialtyMapperImpl.toSpecialtyDtos(List) generated+2
| 49 | public List<SpecialtyDto> toSpecialtyDtos(List<Specialty> specialties) { | ||
| 50 | if ( specialties == null ) { | if +1 | 1 |
| 51 | return null; | ||
| 52 | } | ||
| 53 | |||
| 54 | List<SpecialtyDto> list = new ArrayList<SpecialtyDto>( specialties.size() ); | ||
| 55 | for ( Specialty specialty : specialties ) { | for-each +1 | 2 |
| 56 | list.add( toSpecialtyDto( specialty ) ); | ||
| 57 | } | ||
| 58 | |||
| 59 | return list; | ||
| 60 | } |
SpecialtyMapperImpl.toSpecialtyDto(Specialty) generated+1
| 34 | public SpecialtyDto toSpecialtyDto(Specialty specialty) { | ||
| 35 | if ( specialty == null ) { | if +1 | 3 |
| 36 | return null; | ||
| 37 | } | ||
| 38 | |||
| 39 | SpecialtyDto specialtyDto = new SpecialtyDto(); | ||
| 40 | |||
| 41 | specialtyDto.setId( specialty.getId() ); | ||
| 42 | specialtyDto.setName( specialty.getName() ); | ||
| 43 | specialtyDto.setDescription( specialty.getDescription() ); | ||
| 44 | |||
| 45 | return specialtyDto; | ||
| 46 | } |
POST /api/owners/{ownerId}/pets 2 methods cost something, out of 23 in the flow 2
PetMapperImpl.toPet(PetFieldsDto) generated+1
| 95 | public Pet toPet(PetFieldsDto petFieldsDto) { | ||
| 96 | if ( petFieldsDto == null ) { | if +1 | 1 |
| 97 | return null; | ||
| 98 | } | ||
| 99 | |||
| 100 | Pet pet = new Pet(); | ||
| 101 | |||
| 102 | pet.setName( petFieldsDto.getName() ); | ||
| 103 | pet.setBirthDate( petFieldsDto.getBirthDate() ); | ||
| 104 | pet.setType( toPetType( petFieldsDto.getType() ) ); | ||
| 105 | |||
| 106 | return pet; | ||
| 107 | } |
PetMapperImpl.toPetType(PetTypeDto) generated+1
| 124 | public PetType toPetType(PetTypeDto petTypeDto) { | ||
| 125 | if ( petTypeDto == null ) { | if +1 | 2 |
| 126 | return null; | ||
| 127 | } | ||
| 128 | |||
| 129 | PetType petType = new PetType(); | ||
| 130 | |||
| 131 | petType.setId( petTypeDto.getId() ); | ||
| 132 | petType.setName( petTypeDto.getName() ); | ||
| 133 | |||
| 134 | return petType; | ||
| 135 | } |
PUT /api/visits/{visitId} 2 methods cost something, out of 12 in the flow 2
VetRepository.getByIdOrNull(Integer)+1
| 29 | default Vet getByIdOrNull(@Nullable Integer vetId) { | ||
| 30 | if (vetId == null) { | if +1 | 1 |
| 31 | return null; | ||
| 32 | } | ||
| 33 | return findByIdWithoutSpecialties(vetId).orElseThrow(); | ||
| 34 | } |
VisitRestController.resolveVet(Integer)+1
| 89 | private Vet resolveVet(Integer vetId) { | ||
| 90 | try { | ||
| 91 | return vetRepository.getByIdOrNull(vetId); | ||
| 92 | } catch (NoSuchElementException e) { | catch +1 | 2 |
| 93 | log.warn("Rejecting visit: attending vet id {} does not exist", vetId); | ||
| 94 | throw e; | ||
| 95 | } | ||
| 96 | } |
POST /api/owners 1 method costs something, out of 15 in the flow 1
OwnerMapperImpl.toOwner(OwnerFieldsDto) generated+1
| 43 | public Owner toOwner(OwnerFieldsDto ownerDto) { | ||
| 44 | if ( ownerDto == null ) { | if +1 | 1 |
| 45 | return null; | ||
| 46 | } | ||
| 47 | |||
| 48 | Owner owner = new Owner(); | ||
| 49 | |||
| 50 | owner.setFirstName( ownerDto.getFirstName() ); | ||
| 51 | owner.setLastName( ownerDto.getLastName() ); | ||
| 52 | owner.setAddress( ownerDto.getAddress() ); | ||
| 53 | owner.setCity( ownerDto.getCity() ); | ||
| 54 | owner.setTelephone( ownerDto.getTelephone() ); | ||
| 55 | |||
| 56 | return owner; | ||
| 57 | } |
PUT /api/pets/{petId} 1 method costs something, out of 14 in the flow 1
PetMapperImpl.toPetType(PetTypeDto) generated+1
| 124 | public PetType toPetType(PetTypeDto petTypeDto) { | ||
| 125 | if ( petTypeDto == null ) { | if +1 | 1 |
| 126 | return null; | ||
| 127 | } | ||
| 128 | |||
| 129 | PetType petType = new PetType(); | ||
| 130 | |||
| 131 | petType.setId( petTypeDto.getId() ); | ||
| 132 | petType.setName( petTypeDto.getName() ); | ||
| 133 | |||
| 134 | return petType; | ||
| 135 | } |
POST /api/pettypes 1 method costs something, out of 7 in the flow 1
PetTypeMapperImpl.toPetType(PetTypeFieldsDto) generated+1
| 20 | public PetType toPetType(PetTypeFieldsDto petTypeFieldsDto) { | ||
| 21 | if ( petTypeFieldsDto == null ) { | if +1 | 1 |
| 22 | return null; | ||
| 23 | } | ||
| 24 | |||
| 25 | PetType petType = new PetType(); | ||
| 26 | |||
| 27 | petType.setName( petTypeFieldsDto.getName() ); | ||
| 28 | |||
| 29 | return petType; | ||
| 30 | } |
GET /api/pettypes/{petTypeId} 1 method costs something, out of 8 in the flow 1
PetTypeMapperImpl.toPetTypeDto(PetType) generated+1
| 33 | public PetTypeDto toPetTypeDto(PetType petType) { | ||
| 34 | if ( petType == null ) { | if +1 | 1 |
| 35 | return null; | ||
| 36 | } | ||
| 37 | |||
| 38 | PetTypeDto petTypeDto = new PetTypeDto(); | ||
| 39 | |||
| 40 | petTypeDto.setName( petType.getName() ); | ||
| 41 | petTypeDto.setId( petType.getId() ); | ||
| 42 | |||
| 43 | return petTypeDto; | ||
| 44 | } |
DELETE /api/pettypes/{petTypeId} 1 method costs something, out of 3 in the flow 1
PetTypeRestController.deletePetType(int)+1
| 70 | public ResponseEntity<Void> deletePetType(@PathVariable int petTypeId) { | ||
| 71 | try { | ||
| 72 | PetType petType = petTypeRepository.findById(petTypeId).orElseThrow(); | ||
| 73 | petTypeRepository.delete(petType); | ||
| 74 | return ResponseEntity.noContent().build(); | ||
| 75 | } catch (DataIntegrityViolationException ex) { | catch +1 | 1 |
| 76 | throw new RuntimeException("PetType is in use by existing pets and cannot be deleted", ex); | ||
| 77 | } | ||
| 78 | } |
POST /api/specialties 1 method costs something, out of 12 in the flow 1
SpecialtyMapperImpl.toSpecialty(SpecialtyDto) generated+1
| 19 | public Specialty toSpecialty(SpecialtyDto specialtyDto) { | ||
| 20 | if ( specialtyDto == null ) { | if +1 | 1 |
| 21 | return null; | ||
| 22 | } | ||
| 23 | |||
| 24 | Specialty specialty = new Specialty(); | ||
| 25 | |||
| 26 | specialty.setId( specialtyDto.getId() ); | ||
| 27 | specialty.setName( specialtyDto.getName() ); | ||
| 28 | specialty.setDescription( specialtyDto.getDescription() ); | ||
| 29 | |||
| 30 | return specialty; | ||
| 31 | } |
GET /api/specialties/feed 1 method costs something, out of 9 in the flow 1
SpecialtyFeedController.feed(String)+1
| 27 | public ResponseEntity<List<SpecialtyFeed.Item>> feed( | ||
| 28 | @RequestHeader(value = HttpHeaders.IF_NONE_MATCH, required = false) String ifNoneMatch) { | ||
| 29 | List<SpecialtyFeed.Item> items = specialtyFeed.load(); | ||
| 30 | String etag = specialtyFeed.etag(items); | ||
| 31 | if (etag.equals(ifNoneMatch)) { | if +1 | 1 |
| 32 | return ResponseEntity.status(304).eTag(etag).build(); | ||
| 33 | } | ||
| 34 | return ResponseEntity.ok().eTag(etag).body(items); | ||
| 35 | } |
GET /api/specialties/{specialtyId} 1 method costs something, out of 10 in the flow 1
SpecialtyMapperImpl.toSpecialtyDto(Specialty) generated+1
| 34 | public SpecialtyDto toSpecialtyDto(Specialty specialty) { | ||
| 35 | if ( specialty == null ) { | if +1 | 1 |
| 36 | return null; | ||
| 37 | } | ||
| 38 | |||
| 39 | SpecialtyDto specialtyDto = new SpecialtyDto(); | ||
| 40 | |||
| 41 | specialtyDto.setId( specialty.getId() ); | ||
| 42 | specialtyDto.setName( specialty.getName() ); | ||
| 43 | specialtyDto.setDescription( specialty.getDescription() ); | ||
| 44 | |||
| 45 | return specialtyDto; | ||
| 46 | } |
MCP tools
MCP call_vet_ambulance 1 method costs something, out of 3 in the flow 6
PetClinicMcp.callVetAmbulance(McpSyncRequestContext)+6
| 210 | public String callVetAmbulance(McpSyncRequestContext context) { | ||
| 211 | if (context == null || !context.elicitEnabled()) { | if +1|| +1 | 2 |
| 212 | throw new IllegalStateException( | ||
| 213 | "call_vet_ambulance requires an MCP client that supports elicitation (owner must confirm)."); | ||
| 214 | } | ||
| 215 | // CONFIRMATION-style elicitation: phrase it so ACCEPT reads as "Request" (dispatch), | ||
| 216 | // not "Cancel". Same server-side context.elicit(...) API used elsewhere; the structured | ||
| 217 | // payload carries the required address the vet ambulance should drive to. | ||
| 218 | String prompt = "Request a vet ambulance to drive to your address? " | ||
| 219 | + "Enter the address to dispatch to, then confirm to Request the ambulance."; | ||
| 220 | StructuredElicitResult<AmbulanceAddressInput> elicit = context.elicit(e -> e.message(prompt), | ||
| 221 | AmbulanceAddressInput.class); | ||
| 222 | if (elicit.action() != ElicitResult.Action.ACCEPT) { | if +1 | 3 |
| 223 | return "Vet ambulance was not requested."; | ||
| 224 | } | ||
| 225 | AmbulanceAddressInput input = elicit.structuredContent(); | ||
| 226 | String address = input == null ? null : input.address(); | ternary +1 | 4 |
| 227 | if (address == null || address.isBlank()) { | if +1|| +1 | 6 |
| 228 | throw new IllegalArgumentException("An address is required to dispatch the vet ambulance."); | ||
| 229 | } | ||
| 230 | return "Vet ambulance dispatched to " + address.trim(); | ||
| 231 | } |
MCP create_visit 3 methods cost something, out of 20 in the flow 6
PetClinicMcp.createVisit(int, LocalDate, LocalTime, String)+3
| 121 | public String createVisit( | ||
| 122 | @McpToolParam(description = "Pet ID (must belong to the authenticated owner)", required = true) int petId, | ||
| 123 | @McpToolParam(description = "Visit date (yyyy-MM-dd); must be today or in the future", | ||
| 124 | required = true) LocalDate visitDate, | ||
| 125 | @McpToolParam(description = "Exact local time of the appointment (HH:mm), e.g. 08:00", | ||
| 126 | required = true) LocalTime visitTime, | ||
| 127 | @McpToolParam(description = "Visit description (reason, diagnosis, notes...)", | ||
| 128 | required = true) String description) { | ||
| 129 | int ownerId = McpSecurity.currentOwnerId(); | ||
| 130 | Pet pet = petRepository.findById(petId) | ||
| 131 | .orElseThrow(() -> new IllegalArgumentException("Pet not found: " + petId)); | ||
| 132 | if (pet.getOwner() == null || pet.getOwner().getId() != ownerId) { | if +1|| +1 | 2 |
| 133 | throw new IllegalArgumentException("Pet " + petId + " does not belong to owner " + ownerId); | ||
| 134 | } | ||
| 135 | requireFutureDate(visitDate); | ||
| 136 | if (LocalDateTime.of(visitDate, visitTime).isBefore(LocalDateTime.now())) { | if +1 | 3 |
| 137 | throw new IllegalArgumentException("Visit time must be in the future: " + visitDate + " " + visitTime); | ||
| 138 | } | ||
| 139 | requireUnderUpcomingVisitCap(pet); | ||
| 140 | |||
| 141 | Visit v = new Visit(); | ||
| 142 | v.setDate(visitDate); | ||
| 143 | v.setTime(visitTime); | ||
| 144 | v.setDescription(description); | ||
| 145 | pet.addVisit(v); // maintain both sides of the Pet<->Visit association | ||
| 146 | Visit saved = visitRepository.save(v); | ||
| 147 | return "Created visit id=" + saved.getId() + " for pet '" + pet.getName() + "' on " + visitDate | ||
| 148 | + " at " + visitTime; | ||
| 149 | } |
PetClinicMcp.requireUnderUpcomingVisitCap(Pet)+2
| 187 | private void requireUnderUpcomingVisitCap(Pet pet) { | ||
| 188 | LocalDate today = LocalDate.now(); | ||
| 189 | long upcoming = pet.getVisits().stream() | ||
| 190 | .filter(v -> v.getDate() != null && !v.getDate().isBefore(today)) | && +1 | 4 |
| 191 | .count(); | ||
| 192 | if (upcoming >= MAX_UPCOMING_VISITS_PER_PET) { | if +1 | 5 |
| 193 | throw new IllegalArgumentException( | ||
| 194 | "Pet '" + pet.getName() + "' already has the maximum of " + MAX_UPCOMING_VISITS_PER_PET | ||
| 195 | + " upcoming visits. Please cancel an existing visit before booking another."); | ||
| 196 | } | ||
| 197 | } |
PetClinicMcp.requireFutureDate(LocalDate)+1
| 199 | private static void requireFutureDate(LocalDate d) { | ||
| 200 | if (d.isBefore(LocalDate.now())) { | if +1 | 6 |
| 201 | throw new IllegalArgumentException("Visit date must be today or in the future: " + d); | ||
| 202 | } | ||
| 203 | } |
MCP list_visits 2 methods cost something, out of 17 in the flow 4
PetClinicMcp.listVisits()+3
| 100 | public List<VisitView> listVisits() { | ||
| 101 | int ownerId = McpSecurity.currentOwnerId(); | ||
| 102 | Owner owner = ownerRepository.findByIdFetchingPets(ownerId) | ||
| 103 | .orElseThrow(() -> new IllegalArgumentException("Owner not found: " + ownerId)); | ||
| 104 | List<VisitView> result = new ArrayList<>(); | ||
| 105 | for (Pet pet : owner.getPets()) { | for-each +1 | 1 |
| 106 | // Navigate the mapped Pet→Visit association (lazy; safe under @Transactional) instead of a per-pet repo query. | ||
| 107 | for (Visit v : pet.getVisitsSortedByDate()) { | for-each +2 · nesting 1 | 3 |
| 108 | result.add(new VisitView(v.getId(), pet.getId(), pet.getName(), v.getDate(), v.getTime(), | ||
| 109 | v.getDescription(), formatVet(v.getVet()))); | ||
| 110 | } | ||
| 111 | } | ||
| 112 | return result; | ||
| 113 | } |
PetClinicMcp.formatVet(Vet)+1
| 76 | private String formatVet(Vet vet) { | ||
| 77 | if (vet == null) { | if +1 | 4 |
| 78 | return null; | ||
| 79 | } | ||
| 80 | return vet.getFirstName() + " " + vet.getLastName(); | ||
| 81 | } |
MCP cancel_visit 2 methods cost something, out of 13 in the flow 2
PetClinicMcp.cancelVisit(LocalDate)+1
| 157 | public String cancelVisit( | ||
| 158 | @McpToolParam(description = "Visit date (yyyy-MM-dd); must be in the future", | ||
| 159 | required = true) LocalDate visitDate) { | ||
| 160 | requireFutureDate(visitDate); | ||
| 161 | |||
| 162 | int ownerId = McpSecurity.currentOwnerId(); | ||
| 163 | Owner owner = ownerRepository.findByIdFetchingPets(ownerId) | ||
| 164 | .orElseThrow(() -> new IllegalArgumentException("Owner not found: " + ownerId)); | ||
| 165 | |||
| 166 | // Navigate the mapped Pet→Visit association and filter the matching date (lazy; safe under @Transactional). | ||
| 167 | List<Visit> matching = owner.getPets().stream() | ||
| 168 | .flatMap(pet -> pet.getVisits().stream()) | ||
| 169 | .filter(v -> v.getDate().equals(visitDate)) | ||
| 170 | .toList(); | ||
| 171 | // Detach from the managed collection too, otherwise cascade=ALL re-persists the visit on flush. | ||
| 172 | matching.forEach(v -> { | ||
| 173 | v.getPet().getVisits().remove(v); | ||
| 174 | visitRepository.delete(v); | ||
| 175 | }); | ||
| 176 | |||
| 177 | if (matching.isEmpty()) { | if +1 | 1 |
| 178 | return "No upcoming visits found on " + visitDate; | ||
| 179 | } | ||
| 180 | return "Cancelled " + matching.size() + " visit(s) on " + visitDate; | ||
| 181 | } |
PetClinicMcp.requireFutureDate(LocalDate)+1
| 199 | private static void requireFutureDate(LocalDate d) { | ||
| 200 | if (d.isBefore(LocalDate.now())) { | if +1 | 2 |
| 201 | throw new IllegalArgumentException("Visit date must be today or in the future: " + d); | ||
| 202 | } | ||
| 203 | } |
MCP get_owner_profile 1 method costs something, out of 16 in the flow 1
PetClinicMcp.formatPet(Pet)+1
| 83 | private String formatPet(Pet pet) { | ||
| 84 | String type = pet.getType() == null ? "?" : pet.getType().getName(); | ternary +1 | 1 |
| 85 | return "- id=%d — %s (%s), born %s".formatted(pet.getId(), pet.getName(), type, pet.getBirthDate()); | ||
| 86 | } |
Nothing to explain
11 entry points score 0: every method in their flow reads top to bottom.
- ANY /
- GET /api/owners/count
- PUT /api/owners/{ownerId}
- DELETE /api/owners/{ownerId}
- PUT /api/owners/{ownerId}/pets/{petId}
- DELETE /api/pets/{petId}
- PUT /api/pettypes/{petTypeId}
- PUT /api/specialties/{specialtyId}
- DELETE /api/specialties/{specialtyId}
- DELETE /api/vets/{vetId}
- DELETE /api/visits/{visitId}