Skip to content
Snippets Groups Projects
Commit 25d9d2df authored by Tor-Einar Skog's avatar Tor-Einar Skog
Browse files

Fixed User registration issues

parent 6ffb6124
No related branches found
No related tags found
No related merge requests found
Showing
with 52 additions and 12 deletions
...@@ -87,7 +87,7 @@ public class NotificationSubscriptionController extends HttpServlet { ...@@ -87,7 +87,7 @@ public class NotificationSubscriptionController extends HttpServlet {
request.setAttribute("viewUser", viewUser); request.setAttribute("viewUser", viewUser);
request.setAttribute("allCrops", em.createNamedQuery("Organism.findAllCrops").getResultList()); request.setAttribute("allCrops", em.createNamedQuery("Organism.findAllCrops").getResultList());
request.setAttribute("messageTagSet", em.createNamedQuery("MessageTag.findAll").getResultList()); request.setAttribute("messageTagSet", em.createNamedQuery("MessageTag.findAll").getResultList());
request.setAttribute("weatherStationIds", SessionControllerGetter.getPointOfInterestBean().getWeatherstationsForUser(viewUser)); request.setAttribute("weatherStationIds", SessionControllerGetter.getPointOfInterestBean().getWeatherstationsForUserOrganization(viewUser));
request.setAttribute("universalMessageFormats", SessionControllerGetter.getMessagingBean().getAllUniversalMessageFormats()); request.setAttribute("universalMessageFormats", SessionControllerGetter.getMessagingBean().getAllUniversalMessageFormats());
request.setAttribute("messageKey", request.getParameter("messageKey")); request.setAttribute("messageKey", request.getParameter("messageKey"));
request.getRequestDispatcher("/notificationSubscriptionForm.ftl").forward(request, response); request.getRequestDispatcher("/notificationSubscriptionForm.ftl").forward(request, response);
......
...@@ -37,6 +37,7 @@ import javax.servlet.ServletException; ...@@ -37,6 +37,7 @@ import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import no.nibio.vips.i18n.LanguageUtil;
import no.nibio.vips.logic.controller.session.UserBean; import no.nibio.vips.logic.controller.session.UserBean;
import no.nibio.vips.logic.entity.Organization; import no.nibio.vips.logic.entity.Organization;
import no.nibio.vips.logic.entity.UserAuthentication; import no.nibio.vips.logic.entity.UserAuthentication;
...@@ -124,6 +125,7 @@ public class UserController extends HttpServlet { ...@@ -124,6 +125,7 @@ public class UserController extends HttpServlet {
else else
{ {
request.setAttribute("viewUser", viewUser); request.setAttribute("viewUser", viewUser);
request.setAttribute("availableLocales", LanguageUtil.getAvailableLocalesWithDistinctLanguage());
request.setAttribute("organizations", em.createNamedQuery("Organization.findAll").getResultList()); request.setAttribute("organizations", em.createNamedQuery("Organization.findAll").getResultList());
request.setAttribute("userStatusIds", userBean.getUserStatusIds()); request.setAttribute("userStatusIds", userBean.getUserStatusIds());
request.setAttribute("vipsLogicRoles", em.createNamedQuery("VipsLogicRole.findAll").getResultList()); request.setAttribute("vipsLogicRoles", em.createNamedQuery("VipsLogicRole.findAll").getResultList());
...@@ -155,6 +157,8 @@ public class UserController extends HttpServlet { ...@@ -155,6 +157,8 @@ public class UserController extends HttpServlet {
viewUser.setOrganizationId(user.getOrganizationId()); viewUser.setOrganizationId(user.getOrganizationId());
request.setAttribute("viewUser", viewUser); request.setAttribute("viewUser", viewUser);
request.setAttribute("availableLocales", LanguageUtil.getAvailableLocalesWithDistinctLanguage());
request.setAttribute("defaultLocale", user.getOrganizationId().getDefaultLocale());
request.setAttribute("organizations", em.createNamedQuery("Organization.findAll").getResultList()); request.setAttribute("organizations", em.createNamedQuery("Organization.findAll").getResultList());
request.setAttribute("userStatusIds", userBean.getUserStatusIds()); request.setAttribute("userStatusIds", userBean.getUserStatusIds());
List<VipsLogicRole> roles = em.createNamedQuery("VipsLogicRole.findAll").getResultList(); List<VipsLogicRole> roles = em.createNamedQuery("VipsLogicRole.findAll").getResultList();
...@@ -244,6 +248,8 @@ public class UserController extends HttpServlet { ...@@ -244,6 +248,8 @@ public class UserController extends HttpServlet {
viewUser.setEmail(formValidation.getFormField("email").getWebValue()); viewUser.setEmail(formValidation.getFormField("email").getWebValue());
viewUser.setFirstName(formValidation.getFormField("firstName").getWebValue()); viewUser.setFirstName(formValidation.getFormField("firstName").getWebValue());
viewUser.setLastName(formValidation.getFormField("lastName").getWebValue()); viewUser.setLastName(formValidation.getFormField("lastName").getWebValue());
viewUser.setPhone(formValidation.getFormField("phone").getWebValue());
viewUser.setPreferredLocale(formValidation.getFormField("preferredLocale").getWebValue());
if(user.isSuperUser()) if(user.isSuperUser())
{ {
Organization organization = em.find(Organization.class, formValidation.getFormField("organizationId").getValueAsInteger()); Organization organization = em.find(Organization.class, formValidation.getFormField("organizationId").getValueAsInteger());
......
...@@ -86,6 +86,20 @@ public class PointOfInterestBean { ...@@ -86,6 +86,20 @@ public class PointOfInterestBean {
} }
} }
public List<PointOfInterestWeatherStation> getWeatherstationsForUserOrganization(VipsLogicUser user)
{
Query q = em.createNamedQuery("PointOfInterestWeatherStation.findByOrganizationId");
q.setParameter("organizationId", user.getOrganizationId());
try
{
return q.getResultList();
}
catch(NoResultException ex)
{
return null;
}
}
public List<PointOfInterestWeatherStation> getAllWeatherStations() public List<PointOfInterestWeatherStation> getAllWeatherStations()
{ {
Query q = em.createNamedQuery("PointOfInterestWeatherStation.findAll"); Query q = em.createNamedQuery("PointOfInterestWeatherStation.findAll");
......
...@@ -41,9 +41,7 @@ import org.hibernate.annotations.TypeDefs; ...@@ -41,9 +41,7 @@ import org.hibernate.annotations.TypeDefs;
@TypeDefs( {@TypeDef( name= "IntegerArray", typeClass = IntegerArrayUserType.class)}) @TypeDefs( {@TypeDef( name= "IntegerArray", typeClass = IntegerArrayUserType.class)})
public class ForecastEventNotificationSubscription { public class ForecastEventNotificationSubscription {
private static final long serialVersionUID = 1L;
@Id @Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Basic(optional = false) @Basic(optional = false)
@Column(name = "user_id") @Column(name = "user_id")
private Integer userId; private Integer userId;
......
...@@ -42,9 +42,7 @@ import org.hibernate.annotations.TypeDefs; ...@@ -42,9 +42,7 @@ import org.hibernate.annotations.TypeDefs;
@TypeDefs( {@TypeDef( name= "IntegerArray", typeClass = IntegerArrayUserType.class)}) @TypeDefs( {@TypeDef( name= "IntegerArray", typeClass = IntegerArrayUserType.class)})
public class MessageNotificationSubscription implements Serializable { public class MessageNotificationSubscription implements Serializable {
private static final long serialVersionUID = 1L;
@Id @Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Basic(optional = false) @Basic(optional = false)
@Column(name = "user_id") @Column(name = "user_id")
private Integer userId; private Integer userId;
......
...@@ -19,6 +19,9 @@ ...@@ -19,6 +19,9 @@
package no.nibio.vips.logic.util; package no.nibio.vips.logic.util;
import com.ibm.icu.util.ULocale;
import java.util.Locale;
/** /**
* @copyright 2013 <a href="http://www.nibio.no/">NIBIO</a> * @copyright 2013 <a href="http://www.nibio.no/">NIBIO</a>
* @author Tor-Einar Skog <tor-einar.skog@nibio.no> * @author Tor-Einar Skog <tor-einar.skog@nibio.no>
......
...@@ -310,3 +310,4 @@ forecastNotificationMessageHeadingTpl_1=Notification of high risk of infection ...@@ -310,3 +310,4 @@ forecastNotificationMessageHeadingTpl_1=Notification of high risk of infection
forecastNotificationMessageHeadingTpl_2=Notification of moderate infection risk forecastNotificationMessageHeadingTpl_2=Notification of moderate infection risk
task_SendForecastEventNotificationsTask_name=Send forecast event notifications task_SendForecastEventNotificationsTask_name=Send forecast event notifications
task_SendForecastEventNotificationsTask_description=Checks to see if there has been changes in forecasts to YELLOW or RED status. If so, finds subscribers to such events and sends notifications task_SendForecastEventNotificationsTask_description=Checks to see if there has been changes in forecasts to YELLOW or RED status. If so, finds subscribers to such events and sends notifications
preferredLocale=Preferred locale
...@@ -310,3 +310,4 @@ forecastNotificationMessageHeadingTpl_1=Notification of high risk of infection ...@@ -310,3 +310,4 @@ forecastNotificationMessageHeadingTpl_1=Notification of high risk of infection
forecastNotificationMessageHeadingTpl_2=Notification of moderate infection risk forecastNotificationMessageHeadingTpl_2=Notification of moderate infection risk
task_SendForecastEventNotificationsTask_name=Send forecast event notifications task_SendForecastEventNotificationsTask_name=Send forecast event notifications
task_SendForecastEventNotificationsTask_description=Checks to see if there has been changes in forecasts to YELLOW or RED status. If so, finds subscribers to such events and sends notifications task_SendForecastEventNotificationsTask_description=Checks to see if there has been changes in forecasts to YELLOW or RED status. If so, finds subscribers to such events and sends notifications
preferredLocale=Preferred locale
...@@ -309,3 +309,4 @@ forecastNotificationMessageHeadingTpl_1=Notification of high risk of infection ...@@ -309,3 +309,4 @@ forecastNotificationMessageHeadingTpl_1=Notification of high risk of infection
forecastNotificationMessageHeadingTpl_2=Notification of moderate infection risk forecastNotificationMessageHeadingTpl_2=Notification of moderate infection risk
task_SendForecastEventNotificationsTask_name=Send forecast event notifications task_SendForecastEventNotificationsTask_name=Send forecast event notifications
task_SendForecastEventNotificationsTask_description=Checks to see if there has been changes in forecasts to YELLOW or RED status. If so, finds subscribers to such events and sends notifications task_SendForecastEventNotificationsTask_description=Checks to see if there has been changes in forecasts to YELLOW or RED status. If so, finds subscribers to such events and sends notifications
preferredLocale=Preferred locale
...@@ -310,3 +310,4 @@ forecastNotificationMessageHeadingTpl_1=Melding om h\u00f8y infeksjonsrisiko ...@@ -310,3 +310,4 @@ forecastNotificationMessageHeadingTpl_1=Melding om h\u00f8y infeksjonsrisiko
forecastNotificationMessageHeadingTpl_2=Melding om moderat infeksjonsrisiko forecastNotificationMessageHeadingTpl_2=Melding om moderat infeksjonsrisiko
task_SendForecastEventNotificationsTask_name=Send meldinger om endringer i varsel task_SendForecastEventNotificationsTask_name=Send meldinger om endringer i varsel
task_SendForecastEventNotificationsTask_description=Ser om varsler har endret set til GUL eller R\u00d8D status. I tilfelle s\u00f8kes abonnenter opp og meldinger blir distribuert. task_SendForecastEventNotificationsTask_description=Ser om varsler har endret set til GUL eller R\u00d8D status. I tilfelle s\u00f8kes abonnenter opp og meldinger blir distribuert.
preferredLocale=Foretrukket spr\u00e5k
...@@ -310,3 +310,4 @@ forecastNotificationMessageHeadingTpl_1=Notification of high risk of infection ...@@ -310,3 +310,4 @@ forecastNotificationMessageHeadingTpl_1=Notification of high risk of infection
forecastNotificationMessageHeadingTpl_2=Notification of moderate infection risk forecastNotificationMessageHeadingTpl_2=Notification of moderate infection risk
task_SendForecastEventNotificationsTask_name=Send forecast event notifications task_SendForecastEventNotificationsTask_name=Send forecast event notifications
task_SendForecastEventNotificationsTask_description=Checks to see if there has been changes in forecasts to YELLOW or RED status. If so, finds subscribers to such events and sends notifications task_SendForecastEventNotificationsTask_description=Checks to see if there has been changes in forecasts to YELLOW or RED status. If so, finds subscribers to such events and sends notifications
preferredLocale=Preferred locale
...@@ -39,6 +39,13 @@ ...@@ -39,6 +39,13 @@
"required" : true, "required" : true,
"maxLength" : 255 "maxLength" : 255
}, },
{
"name" : "preferredLocale",
"dataType" : "STRING",
"fieldType" : "SELECT_SINGLE",
"required" : true,
"nullValue" : ""
},
{ {
"name" : "vipsLogicRoles", "name" : "vipsLogicRoles",
"dataType" : "INTEGER", "dataType" : "INTEGER",
......
...@@ -54,7 +54,7 @@ ...@@ -54,7 +54,7 @@
<select name="messageN_universalMessageFormatId" onblur="validateField(this);"> <select name="messageN_universalMessageFormatId" onblur="validateField(this);">
<#list universalMessageFormats as format> <#list universalMessageFormats as format>
<option value="${format.universalMessageFormatId}" <option value="${format.universalMessageFormatId}"
<#if messageNotificationSubscription.universalMessageFormatId == format.universalMessageFormatId> selected="selected"</#if> <#if messageNotificationSubscription?has_content && messageNotificationSubscription.universalMessageFormatId == format.universalMessageFormatId> selected="selected"</#if>
>${i18nBundle(format.formatName)}</option> >${i18nBundle(format.formatName)}</option>
</#list> </#list>
</select> </select>
...@@ -64,7 +64,7 @@ ...@@ -64,7 +64,7 @@
<select class="form-control chosen-select" name="messageN_cropOrganismIds" onblur="validateField(this);" multiple="multiple"> <select class="form-control chosen-select" name="messageN_cropOrganismIds" onblur="validateField(this);" multiple="multiple">
<#list allCrops?sort_by("latinName") as organism> <#list allCrops?sort_by("latinName") as organism>
<option value="${organism.organismId}" <option value="${organism.organismId}"
<#if messageNotificationSubscription.cropIds?seq_contains(organism.organismId)> selected="selected"</#if> <#if messageNotificationSubscription?has_content && messageNotificationSubscription.cropIds?seq_contains(organism.organismId)> selected="selected"</#if>
>${organism.latinName!""} / ${organism.tradeName!""} / ${organism.getLocalName(currentLocale.language)!""}</option> >${organism.latinName!""} / ${organism.tradeName!""} / ${organism.getLocalName(currentLocale.language)!""}</option>
</#list> </#list>
</select> </select>
...@@ -74,7 +74,7 @@ ...@@ -74,7 +74,7 @@
<select class="form-control chosen-select" name="messageN_messageTagIds" onblur="validateField(this);" multiple="multiple"> <select class="form-control chosen-select" name="messageN_messageTagIds" onblur="validateField(this);" multiple="multiple">
<#list messageTagSet as messageTag> <#list messageTagSet as messageTag>
<option value="${messageTag.messageTagId}" <option value="${messageTag.messageTagId}"
<#if messageNotificationSubscription.messageTagIds?seq_contains(messageTag.messageTagId)> selected="selected"</#if> <#if messageNotificationSubscription?has_content && messageNotificationSubscription.messageTagIds?seq_contains(messageTag.messageTagId)> selected="selected"</#if>
>${(messageTag.getLocalName(currentLocale))!messageTag.defaultTagName}</option> >${(messageTag.getLocalName(currentLocale))!messageTag.defaultTagName}</option>
</#list> </#list>
</select> </select>
...@@ -85,7 +85,7 @@ ...@@ -85,7 +85,7 @@
<select name="forecastN_universalMessageFormatId" onblur="validateField(this);"> <select name="forecastN_universalMessageFormatId" onblur="validateField(this);">
<#list universalMessageFormats as format> <#list universalMessageFormats as format>
<option value="${format.universalMessageFormatId}" <option value="${format.universalMessageFormatId}"
<#if messageNotificationSubscription.universalMessageFormatId == format.universalMessageFormatId> selected="selected"</#if> <#if messageNotificationSubscription?has_content && messageNotificationSubscription.universalMessageFormatId == format.universalMessageFormatId> selected="selected"</#if>
>${i18nBundle(format.formatName)}</option> >${i18nBundle(format.formatName)}</option>
</#list> </#list>
</select> </select>
...@@ -95,7 +95,7 @@ ...@@ -95,7 +95,7 @@
<select class="form-control chosen-select" name="forecastN_cropOrganismIds" multiple="multiple"> <select class="form-control chosen-select" name="forecastN_cropOrganismIds" multiple="multiple">
<#list allCrops?sort_by("latinName") as organism> <#list allCrops?sort_by("latinName") as organism>
<option value="${organism.organismId}" <option value="${organism.organismId}"
<#if forecastEventNotificationSubscription.cropIds?seq_contains(organism.organismId)> selected="selected"</#if> <#if forecastEventNotificationSubscription?has_content && forecastEventNotificationSubscription.cropIds?seq_contains(organism.organismId)> selected="selected"</#if>
>${organism.latinName!""} / ${organism.tradeName!""} / ${organism.getLocalName(currentLocale.language)!""}</option> >${organism.latinName!""} / ${organism.tradeName!""} / ${organism.getLocalName(currentLocale.language)!""}</option>
</#list> </#list>
</select> </select>
...@@ -105,12 +105,12 @@ ...@@ -105,12 +105,12 @@
<select class="form-control chosen-select" name="forecastN_weatherStationIds" multiple="multiple"> <select class="form-control chosen-select" name="forecastN_weatherStationIds" multiple="multiple">
<option value="-1">${i18nBundle.pleaseSelect} ${i18nBundle.weatherStations?lower_case}</option> <option value="-1">${i18nBundle.pleaseSelect} ${i18nBundle.weatherStations?lower_case}</option>
<#list weatherStationIds?sort_by("name") as poi> <#list weatherStationIds?sort_by("name") as poi>
<option value="${poi.pointOfInterestId}"<#if forecastEventNotificationSubscription.weatherStationIds?seq_contains(poi.pointOfInterestId)> selected="selected"</#if>>${poi.name}</option> <option value="${poi.pointOfInterestId}"<#if forecastEventNotificationSubscription?has_content && forecastEventNotificationSubscription.weatherStationIds?seq_contains(poi.pointOfInterestId)> selected="selected"</#if>>${poi.name}</option>
</#list> </#list>
</select> </select>
<span class="help-block" id="${formId}_weatherStationPointOfInterestId_validation"></span> <span class="help-block" id="${formId}_weatherStationPointOfInterestId_validation"></span>
</div> </div>
<p>Under construction</p>
<button type="submit" class="btn btn-default">${i18nBundle.submit}</button> <button type="submit" class="btn btn-default">${i18nBundle.submit}</button>
</form> </form>
......
...@@ -63,6 +63,15 @@ ...@@ -63,6 +63,15 @@
<input type="text" class="form-control" name="lastName" placeholder="${i18nBundle.lastName}" value="${viewUser.lastName!""}" onblur="validateField(this);"/> <input type="text" class="form-control" name="lastName" placeholder="${i18nBundle.lastName}" value="${viewUser.lastName!""}" onblur="validateField(this);"/>
<span class="help-block" id="${formId}_lastName_validation"></span> <span class="help-block" id="${formId}_lastName_validation"></span>
</div> </div>
<div class="form-group">
<label for="preferredLocale">${i18nBundle.preferredLocale}</label>
<select class="form-control" name="preferredLocale" onblur="validateField(this);">
<#list availableLocales?sort_by("displayLanguage") as locale>
<option value="${locale.language}"<#if (viewUser.preferredLocale?has_content && locale.language == viewUser.preferredLocale) || (!viewUser.preferredLocale?has_content && defaultLocale?has_content && defaultLocale == locale.language)> selected="selected"</#if>>${locale.getDisplayLanguage(currentLocale)}</option>
</#list>
</select>
<span class="help-block" id="${formId}_preferredLocale_validation"></span>
</div>
<div class="form-group"> <div class="form-group">
<label for="organizationId">${i18nBundle.organizationId}</label> <label for="organizationId">${i18nBundle.organizationId}</label>
<select class="form-control" name="organizationId" onblur="validateField(this);"> <select class="form-control" name="organizationId" onblur="validateField(this);">
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment