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
Show 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;
...
@@ -7,10 +7,10 @@ import java.util.Map;
import
java.util.Optional
;
import
java.util.Optional
;
import
javax.annotation.PostConstruct
;
import
javax.annotation.PostConstruct
;
import
javax.ejb.EJB
;
import
javax.enterprise.context.RequestScoped
;
import
javax.enterprise.context.RequestScoped
;
import
javax.faces.context.FacesContext
;
import
javax.faces.context.FacesContext
;
import
javax.faces.view.ViewScoped
;
import
javax.faces.view.ViewScoped
;
import
javax.inject.Inject
;
import
javax.inject.Named
;
import
javax.inject.Named
;
import
org.primefaces.model.FilterMeta
;
import
org.primefaces.model.FilterMeta
;
...
@@ -27,7 +27,7 @@ import es.uvigo.esei.xcs.service.PetService;
...
@@ -27,7 +27,7 @@ import es.uvigo.esei.xcs.service.PetService;
public
class
PetManagedBean
implements
Serializable
{
public
class
PetManagedBean
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
private
static
final
long
serialVersionUID
=
1L
;
@
Inject
@
EJB
private
PetService
service
;
private
PetService
service
;
private
String
name
;
private
String
name
;
...
@@ -159,6 +159,7 @@ public class PetManagedBean implements Serializable{
...
@@ -159,6 +159,7 @@ public class PetManagedBean implements Serializable{
this
.
service
.
update
(
pet
);
this
.
service
.
update
(
pet
);
}
else
{
}
else
{
//this.service.create(new Pet(name, animal, birth));
//this.service.create(new Pet(name, animal, birth));
this
.
service
.
createPet
(
name
,
animal
,
new
Date
());
}
}
this
.
clear
();
this
.
clear
();
...
...
jsf/src/main/webapp/owner/pets.xhtml
View file @
d1c1cdba
...
@@ -13,30 +13,31 @@
...
@@ -13,30 +13,31 @@
<ui:composition
template=
"../WEB-INF/template.xhtml"
>
<ui:composition
template=
"../WEB-INF/template.xhtml"
>
<ui:define
name=
"jumbotron"
>
<ui:define
name=
"jumbotron"
>
<h2>
New Pet
</h2>
<h2>
New Pet
</h2>
<h:messages
globalOnly=
"false"
/>
<h:form
id=
"mainForm"
>
<h:panelGroup
class=
"row"
>
<h:panelGroup
class=
"row"
>
<h:form>
<h:inputText
class=
"form-control"
a:placeholder=
"Pet name"
value=
"#{pet.name}"
/>
<h:inputText
class=
"form-control"
a:placeholder=
"Pet name"
value=
"#{pet.name}"
></h:inputText>
<!--<h:inputText value="#{pet.birth}" size="20" label="Receipt Date" class="form-control" a:placeholder="Birth (YYYY-MM-DD hh:mm:ss)">
<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" />
<f:convertDateTime pattern="yyyy-M-d hh:mm:ss" />
</h:inputText>
</h:inputText>-->
<h:selectOneMenu
value=
"#{pet.animal}"
class=
"form-control"
>
<h:selectOneMenu
value=
"#{pet.animal}"
class=
"form-control"
>
<f:selectItem
itemValue=
"BIRD"
itemLabel=
"Bird"
/>
<f:selectItem
itemValue=
"BIRD"
itemLabel=
"Bird"
/>
<f:selectItem
itemValue=
"CAT"
itemLabel=
"Cat"
/>
<f:selectItem
itemValue=
"CAT"
itemLabel=
"Cat"
/>
<f:selectItem
itemValue=
"DOG"
itemLabel=
"Dog"
/>
<f:selectItem
itemValue=
"DOG"
itemLabel=
"Dog"
/>
</h:selectOneMenu>
</h:selectOneMenu>
<h:inputHidden
value=
"#{pet.id}"
></h:inputHidden
>
<h:inputHidden
value=
"#{pet.id}"
/
>
<h:commandButton
id=
"submit"
class=
"btn btn-default"
value=
"Store"
action=
"#{pet.store()}"
/>
<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:commandButton
id=
"cancel"
class=
"btn btn-default"
value=
"Cancel"
action=
"#{pet.cancelEditing()}"
/>
</h:form>
</h:panelGroup>
</h:panelGroup>
<div
class=
"row"
>
<div
class=
"row"
>
<h:panelGroup
class=
"alert alert-danger"
role=
"alert"
rendered=
"#{pet.error}"
>
<h:panelGroup
class=
"alert alert-danger"
role=
"alert"
rendered=
"#{pet.error}"
>
<span
class=
"glyphicon glyphicon-exclamation-sign"
aria-hidden=
"true"
></span>
<span
class=
"glyphicon glyphicon-exclamation-sign"
aria-hidden=
"true"
></span>
Error: #{pet.errorMessage}
Error: #{pet.errorMessage}
</h:panelGroup>
</h:panelGroup>
</div>
</div>
</ui:define>
<ui:define
name=
"content"
>
<p:dataTable
id=
"pets-table"
value=
"#{pet.pets}"
var=
"petEntity"
<p:dataTable
id=
"pets-table"
value=
"#{pet.pets}"
var=
"petEntity"
paginator=
"true"
rows=
"10"
lazy=
"true"
paginator=
"true"
rows=
"10"
lazy=
"true"
styleClass=
"table table-striped table-bordered"
>
styleClass=
"table table-striped table-bordered"
>
...
@@ -48,13 +49,11 @@
...
@@ -48,13 +49,11 @@
</p:column>
</p:column>
<p:column
headerText=
"Type"
>
#{petEntity.animal}
</p:column>
<p:column
headerText=
"Type"
>
#{petEntity.animal}
</p:column>
<p:column
headerText=
"Opciones"
>
<p:column
headerText=
"Opciones"
>
<h:form>
<p:commandButton
value=
"Remove"
action=
"#{pet.remove(petEntity.id)}"
process=
"@this"
update=
"@form"
/>
<h:commandButton
value=
"Remove"
action=
"#{pet.remove(petEntity.id)}"
/>
<p:commandButton
value=
"Edit"
action=
"#{pet.edit(petEntity.id)}"
process=
"@this"
update=
"@form"
/>
<h:commandButton
value=
"Edit"
action=
"#{pet.edit(petEntity.id)}"
/>
</h:form>
</p:column>
</p:column>
</p:dataTable>
</p:dataTable>
</h:form>
</ui:define>
</ui:define>
</ui:composition>
</ui:composition>
</body>
</body>
...
...
service/src/main/java/es/uvigo/esei/xcs/service/PetService.java
View file @
d1c1cdba
...
@@ -4,6 +4,7 @@ import static java.util.Objects.requireNonNull;
...
@@ -4,6 +4,7 @@ import static java.util.Objects.requireNonNull;
import
java.io.Console
;
import
java.io.Console
;
import
java.security.Principal
;
import
java.security.Principal
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.List
;
import
javax.annotation.security.PermitAll
;
import
javax.annotation.security.PermitAll
;
...
@@ -15,6 +16,7 @@ import javax.inject.Inject;
...
@@ -15,6 +16,7 @@ import javax.inject.Inject;
import
javax.persistence.EntityManager
;
import
javax.persistence.EntityManager
;
import
javax.persistence.PersistenceContext
;
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.Owner
;
import
es.uvigo.esei.xcs.domain.entities.Pet
;
import
es.uvigo.esei.xcs.domain.entities.Pet
;
import
es.uvigo.esei.xcs.domain.entities.Vaccination
;
import
es.uvigo.esei.xcs.domain.entities.Vaccination
;
...
@@ -142,6 +144,14 @@ public class PetService {
...
@@ -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
* Updates the information of a pet. If the pet is not stored, it will be
* created.
* 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