Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
E
ejercicio2-framework-back
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
Josue
ejercicio2-framework-back
Commits
0f3e3745
Commit
0f3e3745
authored
Nov 30, 2021
by
Roberto Loayza
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/dev_mg' into dev_mg
parents
1ed2b328
c001f3e9
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
125 additions
and
33 deletions
+125
-33
SchedulerTaskBean.java
src/main/java/com/bytesw/bytebot/bean/SchedulerTaskBean.java
+7
-7
WeekSchedulerBean.java
src/main/java/com/bytesw/bytebot/bean/WeekSchedulerBean.java
+3
-2
CalendarExceptionController.java
...ytesw/bytebot/controller/CalendarExceptionController.java
+58
-0
Calendar.java
src/main/java/com/bytesw/bytebot/model/Calendar.java
+1
-1
CalendarException.java
...main/java/com/bytesw/bytebot/model/CalendarException.java
+1
-1
SchedulerTask.java
src/main/java/com/bytesw/bytebot/model/SchedulerTask.java
+12
-6
WeekScheduler.java
src/main/java/com/bytesw/bytebot/model/WeekScheduler.java
+7
-1
WeekSchedulerRepository.java
...om/bytesw/bytebot/repository/WeekSchedulerRepository.java
+2
-1
CalendarService.java
...main/java/com/bytesw/bytebot/service/CalendarService.java
+1
-1
SchedulerTaskService.java
...java/com/bytesw/bytebot/service/SchedulerTaskService.java
+12
-8
WeekSchedulerService.java
...java/com/bytesw/bytebot/service/WeekSchedulerService.java
+21
-5
No files found.
src/main/java/com/bytesw/bytebot/bean/SchedulerTaskBean.java
View file @
0f3e3745
...
@@ -13,17 +13,17 @@ public class SchedulerTaskBean implements Serializable {
...
@@ -13,17 +13,17 @@ public class SchedulerTaskBean implements Serializable {
@Expose
@Expose
private
BigInteger
id
;
private
BigInteger
id
;
@Expose
@Expose
long
version
;
private
long
version
;
@Expose
@Expose
String
description
;
private
String
description
;
@Expose
@Expose
String
internals
;
private
String
internals
;
@Expose
@Expose
String
cronExpression
;
private
String
cronExpression
;
@Expose
@Expose
String
stringParameters
;
private
String
stringParameters
;
@Expose
@Expose
String
calendar
;
private
String
calendarID
;
@Expose
@Expose
String
calendarName
;
private
String
calendarName
;
}
}
src/main/java/com/bytesw/bytebot/bean/WeekSchedulerBean.java
View file @
0f3e3745
...
@@ -21,6 +21,7 @@ public class WeekSchedulerBean {
...
@@ -21,6 +21,7 @@ public class WeekSchedulerBean {
@Expose
@Expose
private
OffsetTime
to
;
private
OffsetTime
to
;
@Expose
@Expose
private
CalendarBean
calendar
;
private
String
calendarID
;
@Expose
private
String
calendarName
;
}
}
src/main/java/com/bytesw/bytebot/controller/CalendarExceptionController.java
0 → 100644
View file @
0f3e3745
package
com
.
bytesw
.
bytebot
.
controller
;
import
com.bytesw.bytebot.bean.CalendarExceptionBean
;
import
com.bytesw.bytebot.service.CalendarExceptionService
;
import
com.bytesw.xdf.annotation.ProgramSecurity
;
import
com.bytesw.xdf.controller.XDFController
;
import
io.swagger.annotations.ApiResponse
;
import
io.swagger.annotations.ApiResponses
;
import
lombok.extern.log4j.Log4j2
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.security.access.prepost.PreAuthorize
;
import
org.springframework.web.bind.annotation.*
;
import
javax.servlet.http.HttpServletRequest
;
import
java.math.BigInteger
;
import
java.util.List
;
import
java.util.Map
;
@RestController
()
@RequestMapping
(
"/calendar-exception"
)
@ProgramSecurity
(
"calendar-exception"
)
@Log4j2
public
class
CalendarExceptionController
extends
XDFController
<
CalendarExceptionBean
,
BigInteger
>
{
@Autowired
CalendarExceptionService
service
;
public
CalendarExceptionController
(
CalendarExceptionService
service
)
{
super
(
service
);
}
@ApiResponses
({
@ApiResponse
(
code
=
200
,
message
=
"Success"
,
response
=
ResponseEntity
.
class
),
@ApiResponse
(
code
=
404
,
message
=
"Not Found"
),
@ApiResponse
(
code
=
505
,
message
=
"Internal Server Error"
)})
@RequestMapping
(
value
=
{
"/find-by-calendar-id"
},
method
=
{
RequestMethod
.
POST
}
)
@ResponseBody
@PreAuthorize
(
"hasPermission(this, 'view')"
)
public
ResponseEntity
<
String
>
getCalendarExceptionbyID
(
@RequestBody
Map
<
String
,
String
>
parametersCalendar
,
HttpServletRequest
req
)
{
List
<
CalendarExceptionBean
>
calendarExceptionBeanList
=
this
.
service
.
getCalendarExceptionbyID
(
parametersCalendar
);
return
new
ResponseEntity
(
this
.
gson
.
toJson
(
calendarExceptionBeanList
),
HttpStatus
.
OK
);
}
}
src/main/java/com/bytesw/bytebot/model/Calendar.java
View file @
0f3e3745
...
@@ -12,7 +12,7 @@ import java.util.List;
...
@@ -12,7 +12,7 @@ import java.util.List;
@Audited
@Audited
@Entity
@Entity
@Table
(
name
=
"
avb_calendar
"
)
@Table
(
name
=
"
AVB_CALENDAR
"
)
@NamedQuery
(
name
=
"Calendar.findByPK"
,
query
=
"Select u from Calendar u where u.id = ?1"
)
@NamedQuery
(
name
=
"Calendar.findByPK"
,
query
=
"Select u from Calendar u where u.id = ?1"
)
@Getter
@Getter
@Setter
@Setter
...
...
src/main/java/com/bytesw/bytebot/model/CalendarException.java
View file @
0f3e3745
...
@@ -17,7 +17,7 @@ import java.math.BigInteger;
...
@@ -17,7 +17,7 @@ import java.math.BigInteger;
@Inheritance
(
@Inheritance
(
strategy
=
InheritanceType
.
SINGLE_TABLE
strategy
=
InheritanceType
.
SINGLE_TABLE
)
)
@DiscriminatorColumn
(
name
=
"CA
EX
_FRECU"
,
discriminatorType
=
DiscriminatorType
.
STRING
)
@DiscriminatorColumn
(
name
=
"CA
LE_EXC
_FRECU"
,
discriminatorType
=
DiscriminatorType
.
STRING
)
@Table
(
name
=
"AVB_CALENDAR_EXCEPTION"
)
@Table
(
name
=
"AVB_CALENDAR_EXCEPTION"
)
@Getter
@Getter
@Setter
@Setter
...
...
src/main/java/com/bytesw/bytebot/model/SchedulerTask.java
View file @
0f3e3745
...
@@ -5,6 +5,8 @@ import lombok.EqualsAndHashCode;
...
@@ -5,6 +5,8 @@ import lombok.EqualsAndHashCode;
import
lombok.Getter
;
import
lombok.Getter
;
import
lombok.Setter
;
import
lombok.Setter
;
import
lombok.ToString
;
import
lombok.ToString
;
import
org.hibernate.annotations.NotFound
;
import
org.hibernate.annotations.NotFoundAction
;
import
org.hibernate.envers.Audited
;
import
org.hibernate.envers.Audited
;
import
javax.persistence.*
;
import
javax.persistence.*
;
...
@@ -13,8 +15,8 @@ import java.math.BigInteger;
...
@@ -13,8 +15,8 @@ import java.math.BigInteger;
@Audited
@Audited
@Entity
@Entity
@Table
(
name
=
"
GTW
_SCHEDULER_TASK"
)
@Table
(
name
=
"
AVB
_SCHEDULER_TASK"
)
@NamedQuery
(
name
=
"SchedulerTask
s
.findByPK"
,
query
=
"Select u from SchedulerTask u where u.id = ?1"
)
@NamedQuery
(
name
=
"SchedulerTask.findByPK"
,
query
=
"Select u from SchedulerTask u where u.id = ?1"
)
@Getter
@Getter
@Setter
@Setter
@EqualsAndHashCode
@EqualsAndHashCode
...
@@ -23,12 +25,12 @@ public class SchedulerTask implements Serializable {
...
@@ -23,12 +25,12 @@ public class SchedulerTask implements Serializable {
@Id
@Id
@Column
(
name
=
"SHTA_ID"
)
@Column
(
name
=
"SHTA_ID"
)
@SequenceGenerator
(
name
=
"
GTW_SCHEDULER_TASK_GENERATOR"
,
sequenceName
=
"GTW
_SCHEDULER_TASK_SEQ"
,
initialValue
=
1
,
allocationSize
=
1
)
@SequenceGenerator
(
name
=
"
AVB_SCHEDULER_TASK_GENERATOR"
,
sequenceName
=
"AVB
_SCHEDULER_TASK_SEQ"
,
initialValue
=
1
,
allocationSize
=
1
)
@GeneratedValue
(
strategy
=
GenerationType
.
SEQUENCE
,
generator
=
"
GTW
_SCHEDULER_TASK_GENERATOR"
)
@GeneratedValue
(
strategy
=
GenerationType
.
SEQUENCE
,
generator
=
"
AVB
_SCHEDULER_TASK_GENERATOR"
)
private
BigInteger
id
;
private
BigInteger
id
;
@Version
@Version
@Column
(
name
=
"VERSION"
)
@Column
(
name
=
"
SHTA_
VERSION"
)
@Basic
(
optional
=
false
)
@Basic
(
optional
=
false
)
private
long
version
;
private
long
version
;
...
@@ -45,8 +47,12 @@ public class SchedulerTask implements Serializable {
...
@@ -45,8 +47,12 @@ public class SchedulerTask implements Serializable {
@Column
(
name
=
"SHTA_PARAM"
)
@Column
(
name
=
"SHTA_PARAM"
)
private
String
stringParameters
;
private
String
stringParameters
;
@Column
(
name
=
"CALE_ID"
)
private
String
calendarID
;
@ManyToOne
(
optional
=
false
)
@ManyToOne
(
optional
=
false
)
@JoinColumn
(
name
=
"CALE_ID"
,
referencedColumnName
=
"CALE_ID"
,
nullable
=
false
)
@NotFound
(
action
=
NotFoundAction
.
IGNORE
)
@JoinColumn
(
name
=
"cale_id"
,
referencedColumnName
=
"cale_id"
,
nullable
=
false
)
private
Calendar
calendar
;
private
Calendar
calendar
;
}
}
src/main/java/com/bytesw/bytebot/model/WeekScheduler.java
View file @
0f3e3745
...
@@ -4,6 +4,8 @@ import lombok.EqualsAndHashCode;
...
@@ -4,6 +4,8 @@ import lombok.EqualsAndHashCode;
import
lombok.Getter
;
import
lombok.Getter
;
import
lombok.Setter
;
import
lombok.Setter
;
import
lombok.ToString
;
import
lombok.ToString
;
import
org.hibernate.annotations.NotFound
;
import
org.hibernate.annotations.NotFoundAction
;
import
org.hibernate.envers.Audited
;
import
org.hibernate.envers.Audited
;
import
javax.persistence.*
;
import
javax.persistence.*
;
...
@@ -41,8 +43,12 @@ public class WeekScheduler implements Serializable {
...
@@ -41,8 +43,12 @@ public class WeekScheduler implements Serializable {
@Column
(
name
=
"WESC_TO"
,
nullable
=
false
)
@Column
(
name
=
"WESC_TO"
,
nullable
=
false
)
private
OffsetTime
to
;
private
OffsetTime
to
;
@Column
(
name
=
"CALE_ID"
)
private
String
calendarID
;
@ManyToOne
(
optional
=
false
)
@ManyToOne
(
optional
=
false
)
@JoinColumn
(
name
=
"CALE_ID"
,
referencedColumnName
=
"CALE_ID"
,
nullable
=
false
)
@NotFound
(
action
=
NotFoundAction
.
IGNORE
)
@JoinColumn
(
name
=
"cale_id"
,
referencedColumnName
=
"cale_id"
,
nullable
=
false
)
private
Calendar
calendar
;
private
Calendar
calendar
;
}
}
src/main/java/com/bytesw/bytebot/repository/WeekSchedulerRepository.java
View file @
0f3e3745
...
@@ -11,6 +11,7 @@ import java.util.List;
...
@@ -11,6 +11,7 @@ import java.util.List;
import
java.util.Optional
;
import
java.util.Optional
;
public
interface
WeekSchedulerRepository
extends
CrudRepository
<
WeekScheduler
,
BigInteger
>,
JpaSpecificationExecutor
<
WeekScheduler
>
{
public
interface
WeekSchedulerRepository
extends
CrudRepository
<
WeekScheduler
,
BigInteger
>,
JpaSpecificationExecutor
<
WeekScheduler
>
{
@Query
(
"select b from WeekScheduler b where b.calendar.id = :caleId"
)
@Query
(
"select b from WeekScheduler b where b.calendarID = :caleId"
)
Optional
<
List
<
WeekScheduler
>>
findByCalendarId
(
@Param
(
"caleId"
)
String
caleId
);
Optional
<
List
<
WeekScheduler
>>
findByCalendarId
(
@Param
(
"caleId"
)
String
caleId
);
}
}
src/main/java/com/bytesw/bytebot/service/CalendarService.java
View file @
0f3e3745
...
@@ -62,7 +62,7 @@ public class CalendarService extends XDFService<Calendar, CalendarBean, String>
...
@@ -62,7 +62,7 @@ public class CalendarService extends XDFService<Calendar, CalendarBean, String>
protected
CalendarBean
toBean
(
Calendar
model
)
{
protected
CalendarBean
toBean
(
Calendar
model
)
{
CalendarBean
bean
=
new
CalendarBean
();
CalendarBean
bean
=
new
CalendarBean
();
BeanUtils
.
copyProperties
(
model
,
bean
);
BeanUtils
.
copyProperties
(
model
,
bean
);
bean
.
setWeekSchedulerBeanList
(
this
.
weekSchedulerService
.
getWeekSchedulerByCalId
(
model
.
getId
()));
bean
.
setWeekSchedulerBeanList
(
this
.
weekSchedulerService
.
getWeekSchedulerByCalId
(
model
.
getId
()
.
trim
()
));
return
bean
;
return
bean
;
}
}
...
...
src/main/java/com/bytesw/bytebot/service/SchedulerTaskService.java
View file @
0f3e3745
...
@@ -20,9 +20,6 @@ import java.util.*;
...
@@ -20,9 +20,6 @@ import java.util.*;
@Transactional
@Transactional
public
class
SchedulerTaskService
extends
XDFService
<
SchedulerTask
,
SchedulerTaskBean
,
BigInteger
>
{
public
class
SchedulerTaskService
extends
XDFService
<
SchedulerTask
,
SchedulerTaskBean
,
BigInteger
>
{
@Autowired
private
CalendarService
calendarService
;
@Autowired
@Autowired
private
CalendarService
CalendarService
;
private
CalendarService
CalendarService
;
...
@@ -41,14 +38,16 @@ public class SchedulerTaskService extends XDFService<SchedulerTask, SchedulerTas
...
@@ -41,14 +38,16 @@ public class SchedulerTaskService extends XDFService<SchedulerTask, SchedulerTas
BeanUtils
.
copyProperties
(
bean
,
model
);
BeanUtils
.
copyProperties
(
bean
,
model
);
model
.
setInternals
(
"Y"
.
equals
(
bean
.
getInternals
()));
model
.
setInternals
(
"Y"
.
equals
(
bean
.
getInternals
()));
if
(
bean
.
getCalendar
()
==
null
)
{
if
(
bean
.
getCalendar
ID
()
==
null
)
{
throw
new
NotFoundException
(
"Calendar can not be null"
);
throw
new
NotFoundException
(
"Calendar can not be null"
);
}
}
Optional
<
Calendar
>
calendarOptional
=
this
.
calendarRepository
.
findById
(
bean
.
getCalendar
());
Optional
<
Calendar
>
calendarOptional
=
this
.
calendarRepository
.
findById
(
bean
.
getCalendarID
());
if
(!
calendarOptional
.
isPresent
())
{
if
(!
calendarOptional
.
isPresent
())
{
throw
new
NotFoundException
(
"Calendar not found "
+
bean
.
getCalendar
());
throw
new
NotFoundException
(
"Calendar not found "
+
bean
.
getCalendar
ID
());
}
}
model
.
setCalendar
(
calendarOptional
.
get
());
model
.
setCalendar
(
calendarOptional
.
get
());
return
model
;
return
model
;
}
}
...
@@ -57,8 +56,13 @@ public class SchedulerTaskService extends XDFService<SchedulerTask, SchedulerTas
...
@@ -57,8 +56,13 @@ public class SchedulerTaskService extends XDFService<SchedulerTask, SchedulerTas
SchedulerTaskBean
bean
=
new
SchedulerTaskBean
();
SchedulerTaskBean
bean
=
new
SchedulerTaskBean
();
BeanUtils
.
copyProperties
(
model
,
bean
);
BeanUtils
.
copyProperties
(
model
,
bean
);
bean
.
setInternals
(
model
.
getInternals
().
booleanValue
()
?
"Y"
:
"N"
);
bean
.
setInternals
(
model
.
getInternals
().
booleanValue
()
?
"Y"
:
"N"
);
bean
.
setCalendar
(
model
.
getCalendar
().
getId
());
bean
.
setCalendarName
(
model
.
getCalendar
().
getName
());
CalendarBean
found
=
this
.
CalendarService
.
getById
(
bean
.
getCalendarID
().
trim
());
if
(
found
!=
null
){
bean
.
setCalendarName
(
found
.
getName
());
}
return
bean
;
return
bean
;
}
}
...
...
src/main/java/com/bytesw/bytebot/service/WeekSchedulerService.java
View file @
0f3e3745
package
com
.
bytesw
.
bytebot
.
service
;
package
com
.
bytesw
.
bytebot
.
service
;
import
com.bytesw.bytebot.bean.CalendarBean
;
import
com.bytesw.bytebot.bean.WeekSchedulerBean
;
import
com.bytesw.bytebot.bean.WeekSchedulerBean
;
import
com.bytesw.bytebot.model.Calendar
;
import
com.bytesw.bytebot.model.Calendar
;
import
com.bytesw.bytebot.model.WeekScheduler
;
import
com.bytesw.bytebot.model.WeekScheduler
;
...
@@ -22,11 +23,16 @@ import java.util.Optional;
...
@@ -22,11 +23,16 @@ import java.util.Optional;
public
class
WeekSchedulerService
extends
XDFService
<
WeekScheduler
,
WeekSchedulerBean
,
BigInteger
>
{
public
class
WeekSchedulerService
extends
XDFService
<
WeekScheduler
,
WeekSchedulerBean
,
BigInteger
>
{
@Autowired
@Autowired
private
WeekSchedulerRepository
weekSchedulerRepository
;
private
WeekSchedulerRepository
weekSchedulerRepository
;
@Autowired
@Autowired
private
CalendarService
calendarService
;
private
CalendarService
calendarService
;
@Autowired
@Autowired
private
CalendarRepository
calendarRepository
;
private
CalendarRepository
calendarRepository
;
@Autowired
private
CalendarService
CalendarService
;
protected
WeekSchedulerService
(
WeekSchedulerRepository
repository
)
{
protected
WeekSchedulerService
(
WeekSchedulerRepository
repository
)
{
super
(
repository
);
super
(
repository
);
}
}
...
@@ -37,13 +43,16 @@ public class WeekSchedulerService extends XDFService<WeekScheduler, WeekSchedule
...
@@ -37,13 +43,16 @@ public class WeekSchedulerService extends XDFService<WeekScheduler, WeekSchedule
model
=
new
WeekScheduler
();
model
=
new
WeekScheduler
();
}
}
BeanUtils
.
copyProperties
(
bean
,
model
);
BeanUtils
.
copyProperties
(
bean
,
model
);
if
(
bean
.
getCalendar
()
==
null
)
{
if
(
bean
.
getCalendarID
()
==
null
)
{
throw
new
NotFoundException
(
"Calendar can not be null"
);
throw
new
NotFoundException
(
"Calendar can not be null"
);
}
}
Optional
<
Calendar
>
calendarOptional
=
calendarRepository
.
findById
(
bean
.
getCalendar
().
getId
());
Optional
<
Calendar
>
calendarOptional
=
calendarRepository
.
findById
(
bean
.
getCalendarID
().
trim
());
if
(!
calendarOptional
.
isPresent
())
{
if
(!
calendarOptional
.
isPresent
())
{
throw
new
NotFoundException
(
"Calendar not found "
+
bean
.
getCalendar
().
getId
());
throw
new
NotFoundException
(
"Calendar not found "
+
bean
.
getCalendar
ID
());
}
}
model
.
setCalendar
(
calendarOptional
.
get
());
model
.
setCalendar
(
calendarOptional
.
get
());
return
model
;
return
model
;
}
}
...
@@ -52,13 +61,20 @@ public class WeekSchedulerService extends XDFService<WeekScheduler, WeekSchedule
...
@@ -52,13 +61,20 @@ public class WeekSchedulerService extends XDFService<WeekScheduler, WeekSchedule
protected
WeekSchedulerBean
toBean
(
WeekScheduler
model
)
{
protected
WeekSchedulerBean
toBean
(
WeekScheduler
model
)
{
WeekSchedulerBean
bean
=
new
WeekSchedulerBean
();
WeekSchedulerBean
bean
=
new
WeekSchedulerBean
();
BeanUtils
.
copyProperties
(
model
,
bean
);
BeanUtils
.
copyProperties
(
model
,
bean
);
bean
.
setCalendar
(
calendarService
.
toBean
(
model
.
getCalendar
()));
bean
.
setCalendarID
(
model
.
getCalendarID
());
CalendarBean
found
=
this
.
CalendarService
.
getById
(
bean
.
getCalendarID
().
trim
());
if
(
found
!=
null
){
bean
.
setCalendarName
(
found
.
getName
());
}
return
bean
;
return
bean
;
}
}
public
List
<
WeekSchedulerBean
>
getWeekSchedulerByCalId
(
String
caleID
)
{
public
List
<
WeekSchedulerBean
>
getWeekSchedulerByCalId
(
String
caleID
)
{
List
<
WeekSchedulerBean
>
weekSchedulerBeanList
=
new
ArrayList
<>(
7
);
List
<
WeekSchedulerBean
>
weekSchedulerBeanList
=
new
ArrayList
<>(
7
);
Optional
<
List
<
WeekScheduler
>>
weekSchedulerOptional
=
this
.
weekSchedulerRepository
.
findByCalendarId
(
caleID
);
Optional
<
List
<
WeekScheduler
>>
weekSchedulerOptional
=
this
.
weekSchedulerRepository
.
findByCalendarId
(
caleID
.
trim
()
);
if
(!
weekSchedulerOptional
.
isPresent
())
{
if
(!
weekSchedulerOptional
.
isPresent
())
{
for
(
int
i
=
0
;
i
<
7
;
i
++)
{
for
(
int
i
=
0
;
i
<
7
;
i
++)
{
weekSchedulerBeanList
.
add
(
i
,
new
WeekSchedulerBean
());
weekSchedulerBeanList
.
add
(
i
,
new
WeekSchedulerBean
());
...
...
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