use of org.apache.syncope.core.provisioning.api.event.AnyCreatedUpdatedEvent in project syncope by apache.
the class JPADynRealmDAO method save.
@Override
public DynRealm save(final DynRealm dynRealm) {
DynRealm merged = entityManager().merge(dynRealm);
// refresh dynamic memberships
clearDynMembers(merged);
merged.getDynMemberships().stream().map(memb -> jpaAnySearchDAO().search(SearchCondConverter.convert(memb.getFIQLCond()), memb.getAnyType().getKind())).forEachOrdered(matching -> {
matching.forEach(any -> {
Query insert = entityManager().createNativeQuery("INSERT INTO " + DYNMEMB_TABLE + " VALUES(?, ?)");
insert.setParameter(1, any.getKey());
insert.setParameter(2, merged.getKey());
insert.executeUpdate();
publisher.publishEvent(new AnyCreatedUpdatedEvent<>(this, any, AuthContextUtils.getDomain()));
});
});
return merged;
}
use of org.apache.syncope.core.provisioning.api.event.AnyCreatedUpdatedEvent in project syncope by apache.
the class JPAGroupDAO method delete.
@Override
public void delete(final Group group) {
dynRealmDAO().removeDynMemberships(group.getKey());
findAMemberships(group).forEach(membership -> {
AnyObject leftEnd = membership.getLeftEnd();
leftEnd.getMemberships().remove(membership);
membership.setRightEnd(null);
leftEnd.getPlainAttrs(membership).stream().map(attr -> {
leftEnd.remove(attr);
attr.setOwner(null);
attr.setMembership(null);
return attr;
}).forEachOrdered(attr -> plainAttrDAO.delete(attr));
anyObjectDAO().save(leftEnd);
publisher.publishEvent(new AnyCreatedUpdatedEvent<>(this, leftEnd, AuthContextUtils.getDomain()));
});
findUMemberships(group).forEach(membership -> {
User leftEnd = membership.getLeftEnd();
leftEnd.getMemberships().remove(membership);
membership.setRightEnd(null);
leftEnd.getPlainAttrs(membership).stream().map(attr -> {
leftEnd.remove(attr);
attr.setOwner(null);
attr.setMembership(null);
return attr;
}).forEachOrdered(attr -> plainAttrDAO.delete(attr));
userDAO().save(leftEnd);
publisher.publishEvent(new AnyCreatedUpdatedEvent<>(this, leftEnd, AuthContextUtils.getDomain()));
});
clearUDynMembers(group);
clearADynMembers(group);
entityManager().remove(group);
publisher.publishEvent(new AnyDeletedEvent(this, AnyTypeKind.GROUP, group.getKey(), AuthContextUtils.getDomain()));
}
Aggregations