use of org.springframework.transaction.annotation.Propagation in project syncope by apache.
the class JPAUserDAO method findDynRoles.
@Transactional(propagation = Propagation.REQUIRES_NEW, readOnly = true)
@Override
@SuppressWarnings("unchecked")
public List<Role> findDynRoles(final String key) {
Query query = entityManager().createNativeQuery("SELECT role_id FROM " + JPARoleDAO.DYNMEMB_TABLE + " WHERE any_id=?");
query.setParameter(1, key);
List<Role> result = new ArrayList<>();
query.getResultList().stream().map(resultKey -> resultKey instanceof Object[] ? (String) ((Object[]) resultKey)[0] : ((String) resultKey)).forEachOrdered(actualKey -> {
Role role = roleDAO.find(actualKey.toString());
if (role == null) {
LOG.error("Could not find role with id {}, even though returned by the native query", actualKey);
} else if (!result.contains(role)) {
result.add(role);
}
});
return result;
}
use of org.springframework.transaction.annotation.Propagation in project CzechIdMng by bcvsolutions.
the class DefaultSysProvisioningAttributeService method saveAttributes.
/**
* Provisioning operation is saved in new transaction, attributes has to be saved too.
*/
@Override
@Transactional(propagation = Propagation.REQUIRES_NEW)
public void saveAttributes(ProvisioningOperation operation) {
Assert.notNull(operation, "Operation is required.");
Assert.notNull(operation.getId(), "Operation identifier is required.");
//
if (operation.getProvisioningContext().getConnectorObject() != null) {
List<IcAttribute> connectorAttributes = operation.getProvisioningContext().getConnectorObject().getAttributes();
if (!CollectionUtils.isEmpty(connectorAttributes)) {
for (IcAttribute connectorAttribute : connectorAttributes) {
SysProvisioningAttribute provisioningAttribute = new SysProvisioningAttribute(operation.getId(), connectorAttribute.getName());
if (CollectionUtils.isEmpty(connectorAttribute.getValues())) {
provisioningAttribute.setRemoved(true);
} else {
provisioningAttribute.setRemoved(connectorAttribute.getValues().stream().allMatch(v -> {
return v == null || StringUtils.isEmpty(v.toString());
}));
}
repository.save(provisioningAttribute);
}
}
}
}
use of org.springframework.transaction.annotation.Propagation in project hub-alert by blackducksoftware.
the class DefaultJiraServerJobDetailsAccessor method saveConcreteJobDetails.
@Override
@Transactional(propagation = Propagation.REQUIRED)
public JiraServerJobDetailsModel saveConcreteJobDetails(UUID jobId, JiraServerJobDetailsModel jobDetails) {
JiraServerJobDetailsEntity jiraServerJobDetailsToSave = new JiraServerJobDetailsEntity(jobId, jobDetails.isAddComments(), jobDetails.getIssueCreatorUsername(), jobDetails.getProjectNameOrKey(), jobDetails.getIssueType(), jobDetails.getResolveTransition(), jobDetails.getReopenTransition(), jobDetails.getIssueSummary());
JiraServerJobDetailsEntity savedJobDetails = jiraServerJobDetailsRepository.save(jiraServerJobDetailsToSave);
jiraServerJobCustomFieldRepository.bulkDeleteByJobId(jobId);
List<JiraServerJobCustomFieldEntity> customFieldsToSave = jobDetails.getCustomFields().stream().map(model -> new JiraServerJobCustomFieldEntity(savedJobDetails.getJobId(), model.getFieldName(), model.getFieldValue())).collect(Collectors.toList());
List<JiraServerJobCustomFieldEntity> savedJobCustomFields = jiraServerJobCustomFieldRepository.saveAll(customFieldsToSave);
savedJobDetails.setJobCustomFields(savedJobCustomFields);
return convertToModel(savedJobDetails);
}
use of org.springframework.transaction.annotation.Propagation in project hub-alert by blackducksoftware.
the class DefaultEmailJobDetailsAccessor method saveConcreteJobDetails.
@Override
@Transactional(propagation = Propagation.REQUIRED)
public EmailJobDetailsModel saveConcreteJobDetails(UUID jobId, EmailJobDetailsModel jobDetails) {
EmailJobDetailsEntity jobDetailsToSave = new EmailJobDetailsEntity(jobId, jobDetails.getSubjectLine().orElse(null), jobDetails.isProjectOwnerOnly(), jobDetails.isAdditionalEmailAddressesOnly(), jobDetails.getAttachmentFileType());
EmailJobDetailsEntity savedJobDetails = emailJobDetailsRepository.save(jobDetailsToSave);
additionalEmailAddressRepository.bulkDeleteByJobId(jobId);
List<EmailJobAdditionalEmailAddressEntity> additionalEmailAddressEntitiesToSave = jobDetails.getAdditionalEmailAddresses().stream().map(emailAddress -> new EmailJobAdditionalEmailAddressEntity(jobId, emailAddress)).collect(Collectors.toList());
List<EmailJobAdditionalEmailAddressEntity> savedAdditionalEmailAddressEntities = additionalEmailAddressRepository.saveAll(additionalEmailAddressEntitiesToSave);
savedJobDetails.setEmailJobAdditionalEmailAddresses(savedAdditionalEmailAddressEntities);
return convertToModel(savedJobDetails);
}
use of org.springframework.transaction.annotation.Propagation in project syncope by apache.
the class JPAAnyObjectDAO method findDynGroups.
@Transactional(propagation = Propagation.REQUIRES_NEW, readOnly = true)
@Override
@SuppressWarnings("unchecked")
public List<Group> findDynGroups(final String key) {
Query query = entityManager().createNativeQuery("SELECT group_id FROM " + JPAGroupDAO.ADYNMEMB_TABLE + " WHERE any_id=?");
query.setParameter(1, key);
List<Group> result = new ArrayList<>();
query.getResultList().stream().map(resultKey -> resultKey instanceof Object[] ? (String) ((Object[]) resultKey)[0] : ((String) resultKey)).forEachOrdered(actualKey -> {
Group group = groupDAO().find(actualKey.toString());
if (group == null) {
LOG.error("Could not find group with id {}, even though returned by the native query", actualKey);
} else if (!result.contains(group)) {
result.add(group);
}
});
return result;
}
Aggregations