Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
OLAT CI-CD Testing Project
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Requirements
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Service Desk
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Lars Oliver Dam
OLAT CI-CD Testing Project
Commits
d6585173
Commit
d6585173
authored
5 years ago
by
aboeckle
Browse files
Options
Downloads
Patches
Plain Diff
OO-4402: Fixed overlapping methods check
parent
6fef6832
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/org/olat/resource/accesscontrol/ui/AccessConfigurationController.java
+31
-24
31 additions, 24 deletions
...ource/accesscontrol/ui/AccessConfigurationController.java
with
31 additions
and
24 deletions
src/main/java/org/olat/resource/accesscontrol/ui/AccessConfigurationController.java
+
31
−
24
View file @
d6585173
...
...
@@ -201,6 +201,7 @@ public class AccessConfigurationController extends FormBasicController {
if
(
event
.
equals
(
Event
.
DONE_EVENT
))
{
OfferAccess
newLink
=
newMethodCtrl
.
commitChanges
();
addConfiguration
(
newLink
);
checkOverlap
();
confControllerContainer
.
setDirty
(
true
);
fireEvent
(
ureq
,
Event
.
CHANGED_EVENT
);
}
...
...
@@ -266,6 +267,8 @@ public class AccessConfigurationController extends FormBasicController {
addConfiguration
(
access
);
}
}
checkOverlap
();
}
protected
void
replace
(
OfferAccess
link
)
{
...
...
@@ -279,6 +282,7 @@ public class AccessConfigurationController extends FormBasicController {
if
(!
updated
)
{
addConfiguration
(
link
);
checkOverlap
();
}
else
{
confControllerContainer
.
setDirty
(
true
);
}
...
...
@@ -304,7 +308,6 @@ public class AccessConfigurationController extends FormBasicController {
}
updateConfirmationEmail
();
checkOverlap
();
}
private
void
updateConfirmationEmail
()
{
...
...
@@ -352,6 +355,7 @@ public class AccessConfigurationController extends FormBasicController {
listenTo
(
cmc
);
}
else
{
addConfiguration
(
link
);
checkOverlap
();
}
}
...
...
@@ -404,47 +408,50 @@ public class AccessConfigurationController extends FormBasicController {
private
void
checkOverlap
()
{
boolean
overlap
=
false
;
// Take a controller from the list
for
(
AccessInfo
confControllerA
:
confControllers
)
{
// Compare it to every other from the list
for
(
AccessInfo
confControllerB
:
confControllers
)
{
// Dont compare a confController with itself
// Don
'
t compare a confController with itself
if
(!
confControllerA
.
equals
(
confControllerB
))
{
Date
aFrom
=
confControllerA
.
getLink
().
getValidFrom
();
Date
aTo
=
confControllerA
.
getLink
().
getValidTo
();
Date
bFrom
=
confControllerB
.
getLink
().
getValidFrom
();
Date
bTo
=
confControllerB
.
getLink
().
getValidTo
();
if
(
aFrom
==
null
||
aTo
==
null
||
bFrom
==
null
||
bTo
==
null
)
{
// Two unlimited bookin methods
if
(
aFrom
==
null
&&
aTo
==
null
&&
bFrom
==
null
&&
bTo
==
null
)
{
overlap
=
true
;
break
;
//
One unlimited method and one with start or end or both
}
else
if
(
a
From
=
=
null
&&
aTo
=
=
null
&&
(
bFrom
!=
null
||
bTo
!=
null
))
{
overlap
=
true
;
break
;
}
else
if
(
aFrom
=
=
null
&&
a
To
!=
null
&&
b
From
!=
null
&&
aTo
.
compareTo
(
b
From
)
>
=
0
)
{
overlap
=
true
;
// One unlimited booking method and another
if
(
aFrom
==
null
&&
aTo
==
null
)
{
overlap
=
true
;
break
;
}
//
Start and end overlap
else
if
(
a
To
!
=
null
&&
bFrom
!
=
null
&&
aTo
.
compareTo
(
bFrom
)
>=
0
)
{
// Exclude not overlapping methods
// Negate condition for no overlap => condition for overlap
if
(!
(
aFrom
!
=
null
&&
b
To
!=
null
&&
a
From
.
compareTo
(
b
To
)
>
0
)
)
{
overlap
=
true
;
break
;
}
}
// Options: Dates cross each other or on date range is within another
else
if
((
aFrom
.
compareTo
(
bFrom
)
<=
0
&&
aTo
.
compareTo
(
bTo
)
<=
0
&&
bFrom
.
compareTo
(
aTo
)
<=
0
)
||
(
aFrom
.
compareTo
(
bFrom
)
<=
0
)
&&
bTo
.
compareTo
(
aTo
)
<=
0
&&
bTo
.
compareTo
(
aFrom
)
>=
0
)
{
}
// Two booking methods without start date
else
if
(
aFrom
==
null
&&
bFrom
==
null
)
{
overlap
=
true
;
break
;
}
// Two booking methods without end date
else
if
(
aTo
==
null
&&
bTo
==
null
)
{
overlap
=
true
;
break
;
}
}
}
// If there is an overlap, don't go for extra checks
if
(
overlap
)
{
break
;
}
}
// Display a warning
confControllerContainer
.
contextPut
(
"overlappingConfigs"
,
overlap
);
confControllerContainer
.
setDirty
(
true
);
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment