Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
reg-app
Regapp
Commits
808994ac
Commit
808994ac
authored
Feb 18, 2021
by
michael.simon
Browse files
add group change event
parent
88de291c
Changes
1
Hide whitespace changes
Inline
Side-by-side
bwreg-service/src/main/java/edu/kit/scc/webreg/service/impl/LocalGroupServiceImpl.java
View file @
808994ac
...
...
@@ -10,6 +10,7 @@
******************************************************************************/
package
edu.kit.scc.webreg.service.impl
;
import
java.util.HashSet
;
import
java.util.List
;
import
javax.ejb.Stateless
;
...
...
@@ -20,11 +21,16 @@ import org.slf4j.Logger;
import
edu.kit.scc.webreg.dao.BaseDao
;
import
edu.kit.scc.webreg.dao.LocalGroupDao
;
import
edu.kit.scc.webreg.dao.ServiceGroupFlagDao
;
import
edu.kit.scc.webreg.entity.EventType
;
import
edu.kit.scc.webreg.entity.GroupEntity
;
import
edu.kit.scc.webreg.entity.LocalGroupEntity
;
import
edu.kit.scc.webreg.entity.ServiceEntity
;
import
edu.kit.scc.webreg.entity.ServiceGroupFlagEntity
;
import
edu.kit.scc.webreg.entity.ServiceGroupStatus
;
import
edu.kit.scc.webreg.entity.UserEntity
;
import
edu.kit.scc.webreg.event.EventSubmitter
;
import
edu.kit.scc.webreg.event.MultipleGroupEvent
;
import
edu.kit.scc.webreg.exc.EventSubmitException
;
import
edu.kit.scc.webreg.service.LocalGroupService
;
import
edu.kit.scc.webreg.service.group.LocalGroupCreator
;
...
...
@@ -45,6 +51,9 @@ public class LocalGroupServiceImpl extends BaseServiceImpl<LocalGroupEntity, Lon
@Inject
private
ServiceGroupFlagDao
groupFlagDao
;
@Inject
private
EventSubmitter
eventSubmitter
;
@Override
public
LocalGroupEntity
createNew
(
ServiceEntity
service
)
{
return
creator
.
createNew
(
service
);
...
...
@@ -54,6 +63,8 @@ public class LocalGroupServiceImpl extends BaseServiceImpl<LocalGroupEntity, Lon
public
void
createServiceGroupFlagsBulk
(
ServiceEntity
fromService
,
ServiceEntity
toService
,
String
filterRegex
)
{
List
<
ServiceGroupFlagEntity
>
fromFlagList
=
groupFlagDao
.
findLocalGroupsForService
(
fromService
);
HashSet
<
GroupEntity
>
allChangedGroups
=
new
HashSet
<
GroupEntity
>();
for
(
ServiceGroupFlagEntity
fromFlag
:
fromFlagList
)
{
if
(
fromFlag
.
getGroup
()
instanceof
LocalGroupEntity
)
{
LocalGroupEntity
group
=
(
LocalGroupEntity
)
fromFlag
.
getGroup
();
...
...
@@ -69,6 +80,7 @@ public class LocalGroupServiceImpl extends BaseServiceImpl<LocalGroupEntity, Lon
groupFlag
.
setStatus
(
ServiceGroupStatus
.
DIRTY
);
groupFlag
=
groupFlagDao
.
persist
(
groupFlag
);
allChangedGroups
.
add
(
group
);
}
else
{
logger
.
info
(
"Skipping group flags for group {} and service {}, they already exist"
,
group
.
getName
(),
toService
.
getShortName
());
...
...
@@ -79,6 +91,13 @@ public class LocalGroupServiceImpl extends BaseServiceImpl<LocalGroupEntity, Lon
}
}
}
MultipleGroupEvent
mge
=
new
MultipleGroupEvent
(
allChangedGroups
);
try
{
eventSubmitter
.
submit
(
mge
,
EventType
.
GROUP_UPDATE
,
"bulk-job"
);
}
catch
(
EventSubmitException
e
)
{
logger
.
warn
(
"Exeption"
,
e
);
}
}
@Override
...
...
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