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
d1c1cdba
Commit
d1c1cdba
authored
Oct 26, 2025
by
Breixo Senra
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Insercion de Mascotas con fecha actual
parent
6a37b255
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
67 additions
and
57 deletions
+67
-57
PetManagedBean.java
jsf/src/main/java/es/uvigo/esei/xcs/jsf/PetManagedBean.java
+3
-2
pets.xhtml
jsf/src/main/webapp/owner/pets.xhtml
+54
-55
PetService.java
...e/src/main/java/es/uvigo/esei/xcs/service/PetService.java
+10
-0
No files found.
jsf/src/main/java/es/uvigo/esei/xcs/jsf/PetManagedBean.java
View file @
d1c1cdba
...
...
@@ -7,10 +7,10 @@ import java.util.Map;
import
java.util.Optional
;
import
javax.annotation.PostConstruct
;
import
javax.ejb.EJB
;
import
javax.enterprise.context.RequestScoped
;
import
javax.faces.context.FacesContext
;
import
javax.faces.view.ViewScoped
;
import
javax.inject.Inject
;
import
javax.inject.Named
;
import
org.primefaces.model.FilterMeta
;
...
...
@@ -27,7 +27,7 @@ import es.uvigo.esei.xcs.service.PetService;
public
class
PetManagedBean
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
@
Inject
@
EJB
private
PetService
service
;
private
String
name
;
...
...
@@ -159,6 +159,7 @@ public class PetManagedBean implements Serializable{
this
.
service
.
update
(
pet
);
}
else
{
//this.service.create(new Pet(name, animal, birth));
this
.
service
.
createPet
(
name
,
animal
,
new
Date
());
}
this
.
clear
();
...
...
jsf/src/main/webapp/owner/pets.xhtml
View file @
d1c1cdba
...
...
@@ -2,60 +2,59 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html
xmlns=
"http://www.w3.org/1999/xhtml"
xmlns:h=
"http://xmlns.jcp.org/jsf/html"
xmlns:p=
"http://primefaces.org/ui"
xmlns:f=
"http://xmlns.jcp.org/jsf/core"
xmlns:ui=
"http://xmlns.jcp.org/jsf/facelets"
xmlns:a=
"http://xmlns.jcp.org/jsf/passthrough"
>
<head>
<title>
Pet Store - Pets
</title>
</head>
<body>
<ui:composition
template=
"../WEB-INF/template.xhtml"
>
<ui:define
name=
"jumbotron"
>
<h2>
New Pet
</h2>
<h:panelGroup
class=
"row"
>
<h:form>
<h:inputText
class=
"form-control"
a:placeholder=
"Pet name"
value=
"#{pet.name}"
></h:inputText>
<h:inputText
value=
"#{pet.birth}"
size=
"20"
required=
"true"
label=
"Receipt Date"
class=
"form-control"
a:placeholder=
"Birth (YYYY-MM-DD hh:mm:ss)"
>
<f:convertDateTime
pattern=
"yyyy-M-d hh:mm:ss"
/>
</h:inputText>
<h:selectOneMenu
value=
"#{pet.animal}"
class=
"form-control"
>
<f:selectItem
itemValue=
"BIRD"
itemLabel=
"Bird"
/>
<f:selectItem
itemValue=
"CAT"
itemLabel=
"Cat"
/>
<f:selectItem
itemValue=
"DOG"
itemLabel=
"Dog"
/>
</h:selectOneMenu>
<h:inputHidden
value=
"#{pet.id}"
></h:inputHidden>
xmlns:p=
"http://primefaces.org/ui"
xmlns:f=
"http://xmlns.jcp.org/jsf/core"
xmlns:ui=
"http://xmlns.jcp.org/jsf/facelets"
xmlns:a=
"http://xmlns.jcp.org/jsf/passthrough"
>
<head>
<title>
Pet Store - Pets
</title>
</head>
<body>
<ui:composition
template=
"../WEB-INF/template.xhtml"
>
<ui:define
name=
"jumbotron"
>
<h2>
New Pet
</h2>
<h:messages
globalOnly=
"false"
/>
<h:form
id=
"mainForm"
>
<h:panelGroup
class=
"row"
>
<h:inputText
class=
"form-control"
a:placeholder=
"Pet name"
value=
"#{pet.name}"
/>
<!--<h:inputText value="#{pet.birth}" size="20" label="Receipt Date" class="form-control" a:placeholder="Birth (YYYY-MM-DD hh:mm:ss)">
<f:convertDateTime pattern="yyyy-M-d hh:mm:ss" />
</h:inputText>-->
<h:selectOneMenu
value=
"#{pet.animal}"
class=
"form-control"
>
<f:selectItem
itemValue=
"BIRD"
itemLabel=
"Bird"
/>
<f:selectItem
itemValue=
"CAT"
itemLabel=
"Cat"
/>
<f:selectItem
itemValue=
"DOG"
itemLabel=
"Dog"
/>
</h:selectOneMenu>
<h:inputHidden
value=
"#{pet.id}"
/>
<h:commandButton
id=
"submit"
class=
"btn btn-default"
value=
"Store"
action=
"#{pet.store()}"
/>
<h:commandButton
id=
"cancel"
class=
"btn btn-default"
value=
"Cancel"
action=
"#{pet.cancelEditing()}"
/>
</h:form>
</h:panelGroup>
<div
class=
"row"
>
<h:panelGroup
class=
"alert alert-danger"
role=
"alert"
rendered=
"#{pet.error}"
>
<span
class=
"glyphicon glyphicon-exclamation-sign"
aria-hidden=
"true"
></span>
Error: #{pet.errorMessage}
</h:panelGroup>
</div>
</ui:define>
<ui:define
name=
"content"
>
<p:dataTable
id=
"pets-table"
value=
"#{pet.pets}"
var=
"petEntity"
paginator=
"true"
rows=
"10"
lazy=
"true"
styleClass=
"table table-striped table-bordered"
>
<p:column
headerText=
"Name"
>
#{petEntity.name}
</p:column>
<p:column
headerText=
"Birth"
>
<h:outputText
value=
"#{petEntity.birth}"
>
<f:convertDateTime
pattern=
"yyyy-M-d hh:mm:ss"
/>
</h:outputText>
</p:column>
<p:column
headerText=
"Type"
>
#{petEntity.animal}
</p:column>
<p:column
headerText=
"Opciones"
>
<h:form>
<h:commandButton
value=
"Remove"
action=
"#{pet.remove(petEntity.id)}"
/>
<h:commandButton
value=
"Edit"
action=
"#{pet.edit(petEntity.id)}"
/>
</h:form>
</p:column>
</p:dataTable>
<h:commandButton
id=
"cancel"
class=
"btn btn-default"
value=
"Cancel"
action=
"#{pet.cancelEditing()}"
/>
</h:panelGroup>
<div
class=
"row"
>
<h:panelGroup
class=
"alert alert-danger"
role=
"alert"
rendered=
"#{pet.error}"
>
<span
class=
"glyphicon glyphicon-exclamation-sign"
aria-hidden=
"true"
></span>
Error: #{pet.errorMessage}
</h:panelGroup>
</div>
</ui:define>
</ui:composition>
</body>
</html>
\ No newline at end of file
<p:dataTable
id=
"pets-table"
value=
"#{pet.pets}"
var=
"petEntity"
paginator=
"true"
rows=
"10"
lazy=
"true"
styleClass=
"table table-striped table-bordered"
>
<p:column
headerText=
"Name"
>
#{petEntity.name}
</p:column>
<p:column
headerText=
"Birth"
>
<h:outputText
value=
"#{petEntity.birth}"
>
<f:convertDateTime
pattern=
"yyyy-M-d hh:mm:ss"
/>
</h:outputText>
</p:column>
<p:column
headerText=
"Type"
>
#{petEntity.animal}
</p:column>
<p:column
headerText=
"Opciones"
>
<p:commandButton
value=
"Remove"
action=
"#{pet.remove(petEntity.id)}"
process=
"@this"
update=
"@form"
/>
<p:commandButton
value=
"Edit"
action=
"#{pet.edit(petEntity.id)}"
process=
"@this"
update=
"@form"
/>
</p:column>
</p:dataTable>
</h:form>
</ui:define>
</ui:composition>
</body>
</html>
service/src/main/java/es/uvigo/esei/xcs/service/PetService.java
View file @
d1c1cdba
...
...
@@ -4,6 +4,7 @@ import static java.util.Objects.requireNonNull;
import
java.io.Console
;
import
java.security.Principal
;
import
java.util.Date
;
import
java.util.List
;
import
javax.annotation.security.PermitAll
;
...
...
@@ -15,6 +16,7 @@ import javax.inject.Inject;
import
javax.persistence.EntityManager
;
import
javax.persistence.PersistenceContext
;
import
es.uvigo.esei.xcs.domain.entities.AnimalType
;
import
es.uvigo.esei.xcs.domain.entities.Owner
;
import
es.uvigo.esei.xcs.domain.entities.Pet
;
import
es.uvigo.esei.xcs.domain.entities.Vaccination
;
...
...
@@ -142,6 +144,14 @@ public class PetService {
}
}
public
Pet
createPet
(
String
name
,
AnimalType
animal
,
Date
birth
)
{
Owner
owner
=
em
.
find
(
Owner
.
class
,
currentUser
.
getName
());
Pet
pet
=
new
Pet
(
name
,
animal
,
birth
,
owner
);
this
.
em
.
persist
(
pet
);
return
pet
;
}
/**
* Updates the information of a pet. If the pet is not stored, it will be
* created.
...
...
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