Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
th-app-java
Overview
Overview
Details
Activity
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
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Amparo Oliver
th-app-java
Commits
e03ab869
Commit
e03ab869
authored
Nov 23, 2021
by
willgonzz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
no se puede crear convocatoria del mismo cargo si existe una abierta
parent
805430c0
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
4 deletions
+16
-4
curriculumsearch/src/main/java/com/roshka/controller/ConvocatoriaController.java
+12
-4
curriculumsearch/src/main/webapp/jsp/convocatorias.jsp
+4
-0
No files found.
curriculumsearch/src/main/java/com/roshka/controller/ConvocatoriaController.java
View file @
e03ab869
...
@@ -2,6 +2,7 @@ package com.roshka.controller;
...
@@ -2,6 +2,7 @@ package com.roshka.controller;
import
java.text.SimpleDateFormat
;
import
java.text.SimpleDateFormat
;
import
java.util.Date
;
import
java.util.Date
;
import
java.util.List
;
import
com.roshka.modelo.Cargo
;
import
com.roshka.modelo.Cargo
;
import
com.roshka.modelo.ConvocatoriaCargo
;
import
com.roshka.modelo.ConvocatoriaCargo
;
...
@@ -16,6 +17,7 @@ import org.hibernate.jpa.TypedParameterValue;
...
@@ -16,6 +17,7 @@ import org.hibernate.jpa.TypedParameterValue;
import
org.hibernate.type.IntegerType
;
import
org.hibernate.type.IntegerType
;
import
org.hibernate.type.LongType
;
import
org.hibernate.type.LongType
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.context.MessageSource
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.ui.Model
;
import
org.springframework.ui.Model
;
import
org.springframework.validation.BindingResult
;
import
org.springframework.validation.BindingResult
;
...
@@ -24,6 +26,7 @@ import org.springframework.web.bind.annotation.PathVariable;
...
@@ -24,6 +26,7 @@ import org.springframework.web.bind.annotation.PathVariable;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.servlet.mvc.support.RedirectAttributes
;
@Controller
@Controller
public
class
ConvocatoriaController
{
public
class
ConvocatoriaController
{
...
@@ -38,7 +41,7 @@ public class ConvocatoriaController {
...
@@ -38,7 +41,7 @@ public class ConvocatoriaController {
}
}
@RequestMapping
(
"/convocatorias"
)
@RequestMapping
(
"/convocatorias"
)
public
String
menuConvocatorias
(
Model
model
,
public
String
menuConvocatorias
(
Model
model
,
RedirectAttributes
redirectAttrs
,
@RequestParam
(
required
=
false
)
Long
cargoId
,
@RequestParam
(
required
=
false
)
Long
cargoId
,
@RequestParam
(
required
=
false
)
Integer
isOpen
//1: true, 0: false
@RequestParam
(
required
=
false
)
Integer
isOpen
//1: true, 0: false
)
{
)
{
...
@@ -55,9 +58,15 @@ public class ConvocatoriaController {
...
@@ -55,9 +58,15 @@ public class ConvocatoriaController {
model
.
addAttribute
(
"convocatoria"
,
new
ConvocatoriaCargo
());
model
.
addAttribute
(
"convocatoria"
,
new
ConvocatoriaCargo
());
return
"convocatoria-form"
;
return
"convocatoria-form"
;
}
}
@PostMapping
(
"/convocatoria"
)
@PostMapping
(
"/convocatoria"
)
public
String
guardarConvocatoria
(
@ModelAttribute
ConvocatoriaCargo
convocatoria
,
BindingResult
result
)
{
public
String
guardarConvocatoria
(
@ModelAttribute
ConvocatoriaCargo
convocatoria
,
BindingResult
result
,
RedirectAttributes
redirectAttributes
)
{
for
(
ConvocatoriaCargo
conv:
convoRepo
.
findByCargoId
(
convocatoria
.
getCargoId
()))
{
if
(
conv
.
getEstado
()==
EstadoConvocatoria
.
abierto
){
redirectAttributes
.
addFlashAttribute
(
"SUCCESS_MESSAGE"
,
"Ya existe una convocatoria Abierta con ese cargo"
);
return
"redirect:/convocatorias"
;
}
}
if
(
result
.
hasErrors
());
if
(
result
.
hasErrors
());
convocatoria
.
setFechaInicio
(
new
Date
());
convocatoria
.
setFechaInicio
(
new
Date
());
convocatoria
.
setEstado
(
EstadoConvocatoria
.
abierto
);
convocatoria
.
setEstado
(
EstadoConvocatoria
.
abierto
);
...
@@ -88,7 +97,6 @@ public class ConvocatoriaController {
...
@@ -88,7 +97,6 @@ public class ConvocatoriaController {
@RequestMapping
(
"/convocatoria/{id}"
)
@RequestMapping
(
"/convocatoria/{id}"
)
public
String
guardarConvocatoria
(
@ModelAttribute
ConvocatoriaCargo
convocatoria
,
BindingResult
result
,
@PathVariable
(
required
=
false
)
Long
id
,
Model
model
)
{
public
String
guardarConvocatoria
(
@ModelAttribute
ConvocatoriaCargo
convocatoria
,
BindingResult
result
,
@PathVariable
(
required
=
false
)
Long
id
,
Model
model
)
{
if
(
result
.
hasErrors
());
if
(
id
!=
null
)
convocatoria
.
setId
(
id
);
if
(
id
!=
null
)
convocatoria
.
setId
(
id
);
convocatoria
=
convoRepo
.
findByIdConvocatoriaCargo
(
id
);
convocatoria
=
convoRepo
.
findByIdConvocatoriaCargo
(
id
);
convocatoria
.
setEstado
(
EstadoConvocatoria
.
cerrado
);
convocatoria
.
setEstado
(
EstadoConvocatoria
.
cerrado
);
...
...
curriculumsearch/src/main/webapp/jsp/convocatorias.jsp
View file @
e03ab869
...
@@ -27,6 +27,9 @@
...
@@ -27,6 +27,9 @@
</div>
</div>
<div>
<div>
<a href="/convocatoria">Agregar Nueva Convocatoria</a>
<a href="/convocatoria">Agregar Nueva Convocatoria</a>
<c:if test="${SUCCESS_MESSAGE != null}">
<div id="status_message">${SUCCESS_MESSAGE}</div>
</c:if>
<table class="table">
<table class="table">
<thead>
<thead>
<tr>
<tr>
...
@@ -57,6 +60,7 @@
...
@@ -57,6 +60,7 @@
</table>
</table>
</div>
</div>
</layout:put>
</layout:put>
<layout:put block="scripts" type="APPEND">
<layout:put block="scripts" type="APPEND">
<script language="JavaScript">
<script language="JavaScript">
...
...
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