Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
B
bspastoriza19-esi-solutions
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Breixo Senra Pastoriza
bspastoriza19-esi-solutions
Commits
3ef867d3
Commit
3ef867d3
authored
Oct 26, 2025
by
Breixo Senra
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Proyecto casi acabado
parent
36f83ffd
Changes
15
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
85 additions
and
94 deletions
+85
-94
PetDetailsManagedBean.java
...ain/java/es/uvigo/esei/xcs/jsf/PetDetailsManagedBean.java
+1
-2
PetManagedBean.java
jsf/src/main/java/es/uvigo/esei/xcs/jsf/PetManagedBean.java
+1
-10
VaccineManagedBean.java
...c/main/java/es/uvigo/esei/xcs/jsf/VaccineManagedBean.java
+60
-19
VetManagedBean.java
jsf/src/main/java/es/uvigo/esei/xcs/jsf/VetManagedBean.java
+0
-5
index.xhtml
jsf/src/main/webapp/index.xhtml
+0
-1
OwnerResource.java
rest/src/main/java/es/uvigo/esei/xcs/rest/OwnerResource.java
+2
-3
VaccinationResource.java
...main/java/es/uvigo/esei/xcs/rest/VaccinationResource.java
+1
-1
VaccineResource.java
...src/main/java/es/uvigo/esei/xcs/rest/VaccineResource.java
+0
-1
VetResource.java
rest/src/main/java/es/uvigo/esei/xcs/rest/VetResource.java
+13
-15
AdministratorService.java
.../java/es/uvigo/esei/xcs/service/AdministratorService.java
+1
-1
OwnerService.java
...src/main/java/es/uvigo/esei/xcs/service/OwnerService.java
+4
-6
PetService.java
...e/src/main/java/es/uvigo/esei/xcs/service/PetService.java
+0
-1
VaccinationService.java
...in/java/es/uvigo/esei/xcs/service/VaccinationService.java
+0
-18
VaccineService.java
...c/main/java/es/uvigo/esei/xcs/service/VaccineService.java
+0
-1
VetService.java
...e/src/main/java/es/uvigo/esei/xcs/service/VetService.java
+2
-10
No files found.
jsf/src/main/java/es/uvigo/esei/xcs/jsf/PetDetailsManagedBean.java
View file @
3ef867d3
...
...
@@ -24,7 +24,6 @@ import es.uvigo.esei.xcs.service.VaccinationService;
import
es.uvigo.esei.xcs.service.VaccineService
;
@Named
(
"petDetails"
)
//@RequestScoped
@ViewScoped
public
class
PetDetailsManagedBean
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
...
...
@@ -42,7 +41,7 @@ public class PetDetailsManagedBean implements Serializable{
private
Pet
pet
;
private
Long
selectedVaccineId
;
private
Date
vaccinationDate
;
// yyyy-MM-dd
private
Date
vaccinationDate
;
private
List
<
Vaccine
>
allVaccines
;
@PostConstruct
...
...
jsf/src/main/java/es/uvigo/esei/xcs/jsf/PetManagedBean.java
View file @
3ef867d3
...
...
@@ -22,7 +22,6 @@ import es.uvigo.esei.xcs.domain.entities.Pet;
import
es.uvigo.esei.xcs.service.PetService
;
@Named
(
"pet"
)
//@RequestScoped
@ViewScoped
public
class
PetManagedBean
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
...
...
@@ -119,14 +118,7 @@ public class PetManagedBean implements Serializable{
this
.
id
=
id
;
}
/*public List<Pet> getPets() {
List<Pet> list = this.service.getAll(0, 100);
System.out.println(list);
return list;
}*/
public
String
edit
(
Long
petId
)
{
//throw new RuntimeException("ERROR GRAVE (" + petId + ")");
final
Pet
pet
=
this
.
service
.
get
(
petId
);
this
.
id
=
pet
.
getId
();
...
...
@@ -134,7 +126,7 @@ public class PetManagedBean implements Serializable{
this
.
birth
=
pet
.
getBirth
();
this
.
animal
=
pet
.
getAnimal
();
return
null
;
// this.getViewId();
return
null
;
}
public
String
cancelEditing
()
{
...
...
@@ -159,7 +151,6 @@ public class PetManagedBean implements Serializable{
this
.
service
.
update
(
pet
);
}
else
{
//this.service.create(new Pet(name, animal, birth));
this
.
service
.
createPet
(
name
,
animal
,
birth
);
}
...
...
jsf/src/main/java/es/uvigo/esei/xcs/jsf/VaccineManagedBean.java
View file @
3ef867d3
...
...
@@ -11,7 +11,6 @@ import es.uvigo.esei.xcs.domain.entities.Vaccine;
import
es.uvigo.esei.xcs.service.VaccineService
;
@Named
(
"vaccine"
)
//@RequestScoped
@ViewScoped
public
class
VaccineManagedBean
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
...
...
@@ -42,18 +41,27 @@ public class VaccineManagedBean implements Serializable{
vaccines
=
vaccineService
.
list
(
0
,
100
);
}
private
Vaccine
selectedVaccine
;
// vacuna que vamos a editar
private
String
newName
;
// nuevo nombre para editar
private
Vaccine
selectedVaccine
;
private
String
newName
;
public
Vaccine
getSelectedVaccine
()
{
return
selectedVaccine
;
}
public
Vaccine
getSelectedVaccine
()
{
return
selectedVaccine
;
}
public
void
setSelectedVaccine
(
Vaccine
selectedVaccine
)
{
this
.
selectedVaccine
=
selectedVaccine
;
if
(
selectedVaccine
!=
null
)
{
this
.
newName
=
selectedVaccine
.
getName
();
// precarga el nombre actual
this
.
newName
=
selectedVaccine
.
getName
();
}
}
public
String
getNewName
()
{
return
newName
;
}
public
void
setNewName
(
String
newName
)
{
this
.
newName
=
newName
;
}
public
String
getNewName
()
{
return
newName
;
}
public
void
setNewName
(
String
newName
)
{
this
.
newName
=
newName
;
}
public
void
editVaccine
()
{
if
(
selectedVaccine
!=
null
&&
newName
!=
null
&&
!
newName
.
trim
().
isEmpty
())
{
...
...
@@ -72,16 +80,49 @@ public class VaccineManagedBean implements Serializable{
periodicType
=
null
;
}
// Getters y setters
public
List
<
Vaccine
>
getVaccines
()
{
return
vaccines
;
}
public
String
getName
()
{
return
name
;
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
public
String
getType
()
{
return
type
;
}
public
void
setType
(
String
type
)
{
this
.
type
=
type
;
}
public
Integer
getDoses
()
{
return
doses
;
}
public
void
setDoses
(
Integer
doses
)
{
this
.
doses
=
doses
;
}
public
Integer
getPeriode
()
{
return
periode
;
}
public
void
setPeriode
(
Integer
periode
)
{
this
.
periode
=
periode
;
}
public
String
getPeriodicType
()
{
return
periodicType
;
}
public
void
setPeriodicType
(
String
periodicType
)
{
this
.
periodicType
=
periodicType
;
}
public
List
<
Vaccine
>
getVaccines
()
{
return
vaccines
;
}
public
String
getName
()
{
return
name
;
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
public
String
getType
()
{
return
type
;
}
public
void
setType
(
String
type
)
{
this
.
type
=
type
;
}
public
Integer
getDoses
()
{
return
doses
;
}
public
void
setDoses
(
Integer
doses
)
{
this
.
doses
=
doses
;
}
public
Integer
getPeriode
()
{
return
periode
;
}
public
void
setPeriode
(
Integer
periode
)
{
this
.
periode
=
periode
;
}
public
String
getPeriodicType
()
{
return
periodicType
;
}
public
void
setPeriodicType
(
String
periodicType
)
{
this
.
periodicType
=
periodicType
;
}
}
jsf/src/main/java/es/uvigo/esei/xcs/jsf/VetManagedBean.java
View file @
3ef867d3
...
...
@@ -22,7 +22,6 @@ import es.uvigo.esei.xcs.domain.entities.Vet;
import
es.uvigo.esei.xcs.service.VetService
;
@Named
(
"vet"
)
//@RequestScoped
@ViewScoped
public
class
VetManagedBean
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
...
...
@@ -93,10 +92,6 @@ public class VetManagedBean implements Serializable{
public
List
<
Vet
>
getVets
()
{
return
this
.
service
.
list
();
}
/*public List<Pet> getPets() {
return this.service.getPets(0, 100);
}*/
public
String
getPetNames
()
{
return
this
.
service
.
getPets
(
0
,
100
).
stream
()
...
...
jsf/src/main/webapp/index.xhtml
View file @
3ef867d3
...
...
@@ -14,7 +14,6 @@
<ui:define
name=
"jumbotron"
>
<h2>
Welcome!
</h2>
<div>
This is the Pet Store web page, where you can manage your pets. Please, login to continue.
</div>
<p:commandButton
value=
"Open Dialog"
/>
</ui:define>
</ui:composition>
</body>
...
...
rest/src/main/java/es/uvigo/esei/xcs/rest/OwnerResource.java
View file @
3ef867d3
...
...
@@ -140,10 +140,9 @@ public class OwnerResource {
}
@Path
(
"
{login}/
pet/{petIdentifierType}/{petIdentifierValue}/vaccination"
)
@Path
(
"pet/{petIdentifierType}/{petIdentifierValue}/vaccination"
)
@GET
public
Response
listVaccinations
(
@PathParam
(
"login"
)
String
login
,
@PathParam
(
"petIdentifierType"
)
IdentifierType
petIdentifierType
,
@PathParam
(
"petIdentifierValue"
)
String
petIdentifierValue
,
@QueryParam
(
"page"
)
int
page
,
...
...
@@ -151,7 +150,7 @@ public class OwnerResource {
)
{
return
Response
.
ok
(
this
.
service
.
getVaccinationsFromOwnPet
(
login
,
//
login,
petIdentifierType
,
petIdentifierValue
,
page
,
...
...
rest/src/main/java/es/uvigo/esei/xcs/rest/VaccinationResource.java
View file @
3ef867d3
...
...
@@ -43,7 +43,7 @@ public class VaccinationResource {
public
Response
createVaccination
(
@PathParam
(
"petId"
)
Long
petId
,
@PathParam
(
"vaccineId"
)
Long
vaccineId
,
@QueryParam
(
"date"
)
String
textDate
// opcional, formato yyyy-MM-dd
@QueryParam
(
"date"
)
String
textDate
)
{
Date
date
=
new
Date
();
if
(
textDate
!=
null
)
{
...
...
rest/src/main/java/es/uvigo/esei/xcs/rest/VaccineResource.java
View file @
3ef867d3
...
...
@@ -32,7 +32,6 @@ public class VaccineResource {
@POST
public
Response
create
(
VaccineCreationData
vaccineData
)
{
requireNonNull
(
vaccineData
,
"vaccineData can't be null"
);
//Vaccine vaccine = vaccineService.create(vaccineData.toVaccine());
Vaccine
vaccine
=
vaccineService
.
create
(
vaccineData
.
getName
(),
vaccineData
.
getType
(),
...
...
rest/src/main/java/es/uvigo/esei/xcs/rest/VetResource.java
View file @
3ef867d3
...
...
@@ -100,12 +100,9 @@ public class VetResource {
@GET
@Path
(
"pets"
)
public
Response
listPets
(
//@PathParam("login") String login,
@QueryParam
(
"page"
)
@DefaultValue
(
"0"
)
int
page
,
@QueryParam
(
"pageSize"
)
@DefaultValue
(
"10"
)
int
pageSize
)
{
//requireNonNull(login, "login can't be null");
return
Response
.
ok
(
this
.
vetService
.
getPets
(
page
,
pageSize
)).
build
();
}
...
...
@@ -124,10 +121,16 @@ public class VetResource {
}
@Path
(
"vaccine"
)
@POST
@Path
(
"vaccine"
)
public
Response
createVaccine
(
VaccineCreationData
vaccineData
)
{
Vaccine
vaccine
=
null
;
//this.vaccineService.create(vaccineData.toVaccine());
Vaccine
vaccine
=
this
.
vaccineService
.
create
(
vaccineData
.
getName
(),
vaccineData
.
getType
(),
vaccineData
.
getDoses
(),
vaccineData
.
getPeriodicType
(),
vaccineData
.
getPeriode
()
);
return
Response
.
ok
(
vaccine
).
build
();
}
...
...
@@ -155,16 +158,14 @@ public class VetResource {
}
}
@Path
(
"pet
s
/{petIdentifierType}/{petIdentifierValue}/vaccination"
)
@Path
(
"pet/{petIdentifierType}/{petIdentifierValue}/vaccination"
)
@GET
public
Response
listVaccinations
(
@PathParam
(
"login"
)
String
login
,
@PathParam
(
"petIdentifierType"
)
IdentifierType
petIdentifierType
,
@PathParam
(
"petIdentifierValue"
)
String
petIdentifierValue
,
@QueryParam
(
"page"
)
int
page
,
@QueryParam
(
"pageSize"
)
int
pageSize
)
{
requireNonNull
(
login
,
"login can't be null"
);
return
Response
.
ok
(
this
.
vetService
.
getVaccinationsFromOwnPet
(
//login,
...
...
@@ -175,12 +176,15 @@ public class VetResource {
)).
build
();
}
@Path
(
"
pets/{petIdentifierType}/{petIdentifierValue}/
vaccination"
)
@Path
(
"vaccination"
)
@POST
public
Response
registerVaccination
(
@QueryParam
(
"date"
)
Date
date
,
VaccinationCreationData
vaccinationData
)
{
if
(
date
==
null
)
{
date
=
new
Date
();
}
Vaccination
vaccination
=
this
.
vaccinationService
.
create
(
vaccinationData
.
getPetId
(),
vaccinationData
.
getVaccineId
(),
...
...
@@ -197,16 +201,13 @@ public class VetResource {
@POST
@Path
(
"/assign/pets/{petId}"
)
public
Response
assignVetToPet
(
//@PathParam("login") String vetLogin,
@PathParam
(
"petId"
)
Long
petId
)
{
//requireNonNull(vetLogin, "vetLogin can't be null");
requireNonNull
(
petId
,
"petId can't be null"
);
try
{
petService
.
assignVetToPet
(
petId
);
return
Response
.
ok
()
//.entity("Vet " + vetLogin + " assigned to pet " + petId)
.
build
();
}
catch
(
IllegalArgumentException
e
)
{
return
Response
.
status
(
Response
.
Status
.
NOT_FOUND
)
...
...
@@ -218,16 +219,13 @@ public class VetResource {
@DELETE
@Path
(
"{login}/unassign/pets/{petId}"
)
public
Response
unassignVetFromPet
(
//@PathParam("login") String vetLogin,
@PathParam
(
"petId"
)
Long
petId
)
{
//requireNonNull(vetLogin, "vetLogin can't be null");
requireNonNull
(
petId
,
"petId can't be null"
);
try
{
petService
.
unassignVetFromPet
(
petId
);
return
Response
.
ok
()
//.entity("Vet " + vetLogin + " unassigned from pet " + petId)
.
build
();
}
catch
(
IllegalArgumentException
e
)
{
return
Response
.
status
(
Response
.
Status
.
NOT_FOUND
)
...
...
service/src/main/java/es/uvigo/esei/xcs/service/AdministratorService.java
View file @
3ef867d3
...
...
@@ -32,7 +32,7 @@ public class AdministratorService {
throw
new
IllegalArgumentException
(
"The page size can't be negative or zero"
);
}
return
em
.
createQuery
(
"SELECT DISTINCT u FROM User u"
,
User
.
class
)
.
setFirstResult
(
(
page
-
1
)
*
pageSize
)
.
setFirstResult
(
page
*
pageSize
)
.
setMaxResults
(
pageSize
)
.
getResultList
();
...
...
service/src/main/java/es/uvigo/esei/xcs/service/OwnerService.java
View file @
3ef867d3
...
...
@@ -25,7 +25,7 @@ import es.uvigo.esei.xcs.domain.entities.Vaccination;
* @author Miguel Reboiro Jato
*/
@Stateless
@RolesAllowed
(
"ADMIN"
)
@RolesAllowed
(
{
"ADMIN"
,
"OWNER"
}
)
public
class
OwnerService
{
@PersistenceContext
private
EntityManager
em
;
...
...
@@ -160,13 +160,11 @@ public class OwnerService {
public
List
<
Vaccination
>
getVaccinationsFromOwnPet
(
String
login
,
IdentifierType
identifierType
,
String
identifierValue
,
int
page
,
int
pageSize
){
requireNonNull
(
login
,
"login can't be null"
);
requireNonNull
(
identifierType
,
"pet's identifier type can't be null"
);
requireNonNull
(
identifierValue
,
"pet's identifier value can't be null"
);
...
...
@@ -183,10 +181,10 @@ public class OwnerService {
+
"JOIN p.vaccinations v "
+
"WHERE "
+
"o.login = :login AND "
+
"i.
identifierT
ype = :identifierType AND "
+
"i.
identifierV
alue = :identifierValue"
,
+
"i.
t
ype = :identifierType AND "
+
"i.
v
alue = :identifierValue"
,
Vaccination
.
class
)
.
setParameter
(
"login"
,
login
)
.
setParameter
(
"login"
,
currentUser
.
getName
()
)
.
setParameter
(
"identifierType"
,
identifierType
)
.
setParameter
(
"identifierValue"
,
identifierValue
)
.
setFirstResult
(
page
*
pageSize
)
...
...
service/src/main/java/es/uvigo/esei/xcs/service/PetService.java
View file @
3ef867d3
...
...
@@ -31,7 +31,6 @@ import es.uvigo.esei.xcs.domain.entities.Vet;
*/
@Stateless
@RolesAllowed
({
"VET"
,
"OWNER"
})
//@PermitAll
public
class
PetService
{
@Inject
private
Principal
currentUser
;
...
...
service/src/main/java/es/uvigo/esei/xcs/service/VaccinationService.java
View file @
3ef867d3
...
...
@@ -54,24 +54,6 @@ public class VaccinationService {
}
/*public Vaccination create(int petId, int vaccineId, String textDate) {
Pet pet = requireNonNull(em.find(Pet.class, petId), "Pet can't be null");
Vaccine vaccine = requireNonNull(em.find(Vaccine.class, vaccineId), "Vaccine can't be null");
Date date = new Date();
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
if(textDate != null) {
try {
date = format.parse(textDate);
} catch (ParseException e) {
date = null;
}
}
Vaccination vaccination = new Vaccination(pet, vaccine, date);
em.persist(vaccination);
return vaccination;
}*/
public
Vaccination
create
(
Long
petId
,
Long
vaccineId
,
Date
date
)
{
Pet
pet
=
requireNonNull
(
em
.
find
(
Pet
.
class
,
petId
),
"Pet can't be null"
);
Vaccine
vaccine
=
requireNonNull
(
em
.
find
(
Vaccine
.
class
,
vaccineId
),
"Vaccine can't be null"
);
...
...
service/src/main/java/es/uvigo/esei/xcs/service/VaccineService.java
View file @
3ef867d3
...
...
@@ -18,7 +18,6 @@ import es.uvigo.esei.xcs.domain.entities.Pet;
import
es.uvigo.esei.xcs.domain.entities.Vaccine
;
@Stateless
//@PermitAll
@RolesAllowed
(
"VET"
)
public
class
VaccineService
{
@PersistenceContext
...
...
service/src/main/java/es/uvigo/esei/xcs/service/VetService.java
View file @
3ef867d3
...
...
@@ -19,7 +19,6 @@ import es.uvigo.esei.xcs.domain.entities.Vet;
@Stateless
@RolesAllowed
(
"VET"
)
//@PermitAll
public
class
VetService
{
@Inject
private
Principal
currentUser
;
...
...
@@ -83,7 +82,6 @@ public class VetService {
public
List
<
Pet
>
getPets
(
int
first
,
int
pageSize
)
{
//requireNonNull(login, "Login can't be null");
if
(
first
<
0
)
throw
new
IllegalArgumentException
(
"First can't be negative"
);
if
(
pageSize
<=
0
)
throw
new
IllegalArgumentException
(
"Page size must be positive"
);
...
...
@@ -96,13 +94,11 @@ public class VetService {
}
public
List
<
Vaccination
>
getVaccinationsFromOwnPet
(
//String login,
IdentifierType
identifierType
,
String
identifierValue
,
int
page
,
int
pageSize
){
//requireNonNull(login, "login can't be null");
requireNonNull
(
identifierType
,
"pet's identifier type can't be null"
);
requireNonNull
(
identifierValue
,
"pet's identifier value can't be null"
);
if
(
page
<
0
)
{
...
...
@@ -118,8 +114,8 @@ public class VetService {
+
"JOIN p.vaccinations v "
+
"WHERE "
+
"vet.login = :login AND "
+
"i.
identifierT
ype = :identifierType AND "
+
"i.
identifierV
alue = :identifierValue"
,
+
"i.
t
ype = :identifierType AND "
+
"i.
v
alue = :identifierValue"
,
Vaccination
.
class
)
.
setParameter
(
"login"
,
currentUser
.
getName
())
.
setParameter
(
"identifierType"
,
identifierType
)
...
...
@@ -129,9 +125,5 @@ public class VetService {
.
getResultList
();
}
public
void
assignPetToVet
()
{
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment