diff --git a/src/main/java/net/geant/nmaas/notifications/NotificationManager.java b/src/main/java/net/geant/nmaas/notifications/NotificationManager.java index 858af10900c024a66a89af7439c2062f4fcd4079..28925c36fccb0f30cb46c83f30ec5d699981022a 100644 --- a/src/main/java/net/geant/nmaas/notifications/NotificationManager.java +++ b/src/main/java/net/geant/nmaas/notifications/NotificationManager.java @@ -18,6 +18,7 @@ import net.geant.nmaas.notifications.types.persistence.entity.FormType; import net.geant.nmaas.notifications.types.service.FormTypeService; import net.geant.nmaas.portal.api.configuration.ConfigurationView; import net.geant.nmaas.portal.api.domain.UserView; +import net.geant.nmaas.portal.api.domain.VlabAppListElement; import net.geant.nmaas.portal.api.exception.MissingElementException; import net.geant.nmaas.portal.api.exception.ProcessingException; import net.geant.nmaas.portal.persistent.entity.Role; @@ -32,6 +33,8 @@ import org.springframework.ui.freemarker.FreeMarkerTemplateUtils; import java.io.IOException; import java.io.StringReader; +import java.time.OffsetDateTime; +import java.time.format.DateTimeFormatter; import java.util.List; import java.util.Map; import java.util.Optional; @@ -153,7 +156,15 @@ public class NotificationManager { ObjectMapper objectMapper = new ObjectMapper(); List<Object> datesList = objectMapper.convertValue(datesObject, new TypeReference<List<Object>>() {}); Map<String,Object> dates = objectMapper.convertValue(datesList.get(0), new TypeReference<Map<String, Object>>() {}); - dates.forEach((k,v) -> mailAttributes.getOtherAttributes().put(k,v)); + + dates.forEach((k,v) -> { + OffsetDateTime offsetDateTime = OffsetDateTime.parse(v.toString()); + mailAttributes.getOtherAttributes().put(k,offsetDateTime.format(DateTimeFormatter.ofPattern("dd.MM.yyyy"))); + }); + + List<VlabAppListElement> appList = objectMapper.convertValue(mailAttributes.getOtherAttributes().get("appList"), new TypeReference<List<VlabAppListElement>>() {}); + mailAttributes.getOtherAttributes().put("appList",appList.stream().map(VlabAppListElement::getAppListName).collect(Collectors.joining(", "))) ; + } if (contactFormKey.isEmpty()) { log.error("Invalid contact form request, subType is null"); diff --git a/src/main/java/net/geant/nmaas/portal/api/domain/VlabAppListElement.java b/src/main/java/net/geant/nmaas/portal/api/domain/VlabAppListElement.java new file mode 100644 index 0000000000000000000000000000000000000000..121bad7bc1c30752305b0fc38c997c88e97f691e --- /dev/null +++ b/src/main/java/net/geant/nmaas/portal/api/domain/VlabAppListElement.java @@ -0,0 +1,18 @@ +package net.geant.nmaas.portal.api.domain; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; + +@Getter +@Setter +@Builder +@AllArgsConstructor +@NoArgsConstructor +public class VlabAppListElement { + + private String appListName; + +} diff --git a/src/main/java/net/geant/nmaas/portal/service/impl/ApplicationStatePerDomainServiceImpl.java b/src/main/java/net/geant/nmaas/portal/service/impl/ApplicationStatePerDomainServiceImpl.java index c11f3b1d65bd9ce246b3749ae73aa79220e2b8f2..06b6afa12f947b368d1c609d447bdb79b2451f5d 100644 --- a/src/main/java/net/geant/nmaas/portal/service/impl/ApplicationStatePerDomainServiceImpl.java +++ b/src/main/java/net/geant/nmaas/portal/service/impl/ApplicationStatePerDomainServiceImpl.java @@ -47,9 +47,10 @@ public class ApplicationStatePerDomainServiceImpl implements ApplicationStatePer List<Domain> allDomains = domainRepository.findAll(); allDomains.forEach(domain -> domain.addApplicationState(appState)); //update domains groups - set app to false by default - appState.setEnabled(false); + ApplicationStatePerDomain appState2 = new ApplicationStatePerDomain(applicationBase); + appState2.setEnabled(false); domainGroupRepository.findAll().forEach(d -> { - d.getApplicationStatePerDomain().add(appState); + d.getApplicationStatePerDomain().add(appState2); }); return domainRepository.saveAll(allDomains); } diff --git a/src/test/shell/data/mails/vlabRequest.json b/src/test/shell/data/mails/vlabRequest.json index 779cdb9ff8b2c944ad1af7af4ced6020fe9430b0..bd1b049116183fccd48df2e2f77d69916de821ba 100644 --- a/src/test/shell/data/mails/vlabRequest.json +++ b/src/test/shell/data/mails/vlabRequest.json @@ -11,7 +11,7 @@ "subject": "nmaas: New vLAB request", "template": { "HEADER": "Dear ${username},", - "CONTENT": "<p>New vLAB request was sent from the contact form.</p><p>Requester email: ${email}</p><p>Requester institution: ${institution}</p><p>Requested number of lab participants: ${students}</p><p>Requested number of lab managers: ${managers}</p><p>List of considered applications:</p><#list appList as app><span>${app.appListName}, </span></#list><p>vLAB start date: ${startDay}</p><p>vLAB end date: ${endDay}</p><p>Additional information: ${message}</p>", + "CONTENT": "<p>New vLAB request was sent from the contact form.</p><p>Requester email: ${email}</p><p>Requester institution: ${institution}</p><p>Requested number of lab participants: ${students}</p><p>Requested number of lab managers: ${managers}</p><p>List of considered applications:</p><p>${appList}</p><p>vLAB start date: ${startDay}</p><p>vLAB end date: ${endDay}</p><p>Additional information: ${message}</p>", "SENDER": "Best regards,<br />nmaas Team", "NOREPLY": "This is an automatically generated message, please do not reply.", "SENDER_POLICY": "" @@ -22,7 +22,7 @@ "subject": "nmaas: New vLAB request", "template": { "HEADER": "Dear ${username},", - "CONTENT": "<p>New vLAB request was sent from the contact form.</p><p>Requester email: ${email}</p><p>Requester institution: ${institution}</p><p>Requested number of lab participants: ${students}</p><p>Requested number of lab managers: ${managers}</p><p>List of considered applications:</p><#list appList as app><span>${app.appListName}, </span></#list><p>vLAB start date: ${startDay}</p><p>vLAB end date: ${endDay}</p><p>Additional information: ${message}</p>", + "CONTENT": "<p>New vLAB request was sent from the contact form.</p><p>Requester email: ${email}</p><p>Requester institution: ${institution}</p><p>Requested number of lab participants: ${students}</p><p>Requested number of lab managers: ${managers}</p><p>List of considered applications:</p><p>${appList}</p><p>vLAB start date: ${startDay}</p><p>vLAB end date: ${endDay}</p><p>Additional information: ${message}</p>", "SENDER": "Best regards,<br />nmaas Team", "NOREPLY": "This is an automatically generated message, please do not reply.", "SENDER_POLICY": "" @@ -33,7 +33,7 @@ "subject": "nmaas: New vLAB request", "template": { "HEADER": "Dear ${username},", - "CONTENT": "<p>New vLAB request was sent from the contact form.</p><p>Requester email: ${email}</p><p>Requester institution: ${institution}</p><p>Requested number of lab participants: ${students}</p><p>Requested number of lab managers: ${managers}</p><p>List of considered applications:</p><#list appList as app><span>${app.appListName}, </span></#list><p>vLAB start date: ${startDay}</p><p>vLAB end date: ${endDay}</p><p>Additional information: ${message}</p>", + "CONTENT": "<p>New vLAB request was sent from the contact form.</p><p>Requester email: ${email}</p><p>Requester institution: ${institution}</p><p>Requested number of lab participants: ${students}</p><p>Requested number of lab managers: ${managers}</p><p>List of considered applications:</p><p>${appList}</p><p>vLAB start date: ${startDay}</p><p>vLAB end date: ${endDay}</p><p>Additional information: ${message}</p>", "SENDER": "Best regards,<br />nmaas Team", "NOREPLY": "This is an automatically generated message, please do not reply.", "SENDER_POLICY": "" @@ -44,7 +44,7 @@ "subject": "nmaas: New vLAB request", "template": { "HEADER": "Dear ${username},", - "CONTENT": "<p>New vLAB request was sent from the contact form.</p><p>Requester email: ${email}</p><p>Requester institution: ${institution}</p><p>Requested number of lab participants: ${students}</p><p>Requested number of lab managers: ${managers}</p><p>List of considered applications:</p><#list appList as app><span>${app.appListName}, </span></#list><p>vLAB start date: ${startDay}</p><p>vLAB end date: ${endDay}</p><p>Additional information: ${message}</p>", + "CONTENT": "<p>New vLAB request was sent from the contact form.</p><p>Requester email: ${email}</p><p>Requester institution: ${institution}</p><p>Requested number of lab participants: ${students}</p><p>Requested number of lab managers: ${managers}</p><p>List of considered applications:</p><p>${appList}</p><p>vLAB start date: ${startDay}</p><p>vLAB end date: ${endDay}</p><p>Additional information: ${message}</p>", "SENDER": "Best regards,<br />nmaas Team", "NOREPLY": "This is an automatically generated message, please do not reply.", "SENDER_POLICY": ""