use of javax.transaction.Transactional in project CollectiveOneWebapp by CollectiveOne.
the class FileService method uploadImageProfile.
@Transactional
public void uploadImageProfile(UUID userId, MultipartFile file) {
String key = "ProfileImages/" + userId.toString();
FileStored fileUploaded = handleFileUpload(userId, key, file, null);
if (fileUploaded != null) {
AppUserProfile profile = appUserProfileRepository.findByUser_C1Id(userId);
profile.setUploadedPicture(fileUploaded);
appUserProfileRepository.save(profile);
}
}
use of javax.transaction.Transactional in project CollectiveOneWebapp by CollectiveOne.
the class FileService method uploadCardImage.
@Transactional
public PostResult uploadCardImage(UUID userId, UUID cardWrapperId, MultipartFile file) throws IOException {
try (InputStream input = file.getInputStream()) {
try {
ImageIO.read(input).toString();
Initiative initiative = modelService.getCardWrapperInitiative(cardWrapperId);
String key = "CardImages/" + cardWrapperId.toString();
FileStored fileUploaded = handleFileUpload(userId, key, file, initiative.getId());
if (fileUploaded != null) {
return new PostResult("success", "image uploaded", fileUploaded.getId().toString());
}
return new PostResult("error", "error uploading image", "");
} catch (Exception e) {
// It's not an image.
return new PostResult("error", "only image files are supported", "");
}
}
}
use of javax.transaction.Transactional in project CollectiveOneWebapp by CollectiveOne.
the class ActivityService method assignationRevertCancelled.
@Transactional
public void assignationRevertCancelled(Assignation assignation) {
Activity revertOrder = activityRepository.findTop1ByAssignation_IdAndTypeOrderByTimestampDesc(assignation.getId(), ActivityType.ASSIGNATION_REVERT_ORDERED);
Activity activity = new Activity();
activity.setType(ActivityType.ASSIGNATION_REVERT_CANCELLED);
activity.setTriggerUser(revertOrder.getTriggerUser());
activity.setInitiative(assignation.getInitiative());
activity.setTimestamp(new Timestamp(System.currentTimeMillis()));
activity.setAssignation(assignation);
activity = activityRepository.save(activity);
addInitiativeActivityNotifications(activity);
}
use of javax.transaction.Transactional in project CollectiveOneWebapp by CollectiveOne.
the class ActivityService method getInitiativeSubscribers.
@Transactional
private List<Subscriber> getInitiativeSubscribers(UUID initiativeId) {
/* example https://docs.google.com/drawings/d/1PqPhefzrGVlWVfG-SRGS56l_e2qpNEsajLbnsAWcTfA/edit,
* assume initiativeId = C */
/* start with this initiative subscribers (S3 and S6 in example). Take into account that
* a subscriber state may be SUBSCRIPTION_DISABLED */
List<Subscriber> allSubscribers = subscriberRepository.findByElementId(initiativeId);
/* then add the subscribers of all parent initiatives (B and A, in that order) */
List<Initiative> parents = initiativeService.getParentGenealogyInitiatives(initiativeId);
for (Initiative parent : parents) {
List<Subscriber> parentSubscribers = subscriberRepository.findByElementId(parent.getId());
for (Subscriber parentSubscriber : parentSubscribers) {
int ixOfSubscriber = indexOfSubscriber(allSubscribers, parentSubscriber);
if (ixOfSubscriber == -1) {
/* if this user is not already in the list of subscriptions, then
* add it (this means that the applicable subscription is that at
* the lowest level) */
allSubscribers.add(parentSubscriber);
}
}
}
return allSubscribers;
}
use of javax.transaction.Transactional in project CollectiveOneWebapp by CollectiveOne.
the class ActivityService method assignationReverted.
@Transactional
public void assignationReverted(Assignation assignation) {
Activity revertOrder = activityRepository.findTop1ByAssignation_IdAndTypeOrderByTimestampDesc(assignation.getId(), ActivityType.ASSIGNATION_REVERT_ORDERED);
Activity activity = new Activity();
activity.setType(ActivityType.ASSIGNATION_REVERTED);
activity.setTriggerUser(revertOrder.getTriggerUser());
activity.setInitiative(assignation.getInitiative());
activity.setTimestamp(new Timestamp(System.currentTimeMillis()));
activity.setAssignation(assignation);
activity = activityRepository.save(activity);
addInitiativeActivityNotifications(activity);
}
Aggregations