Commit cfc80c30 by Tuomas Riihimäki

Changed User 'female' field to enum Gender with values FEMALE, MALE, UNDEFINED

1 parent 312eff24
...@@ -117,7 +117,6 @@ public class TestDataBean implements TestDataBeanLocal { ...@@ -117,7 +117,6 @@ public class TestDataBean implements TestDataBeanLocal {
u.setBirthday(bday); u.setBirthday(bday);
u.setCreated(Calendar.getInstance()); u.setCreated(Calendar.getInstance());
u.setEmail("kalle.kavija@example.com"); u.setEmail("kalle.kavija@example.com");
u.setFemale(false);
u.setFirstnames("Kalle Kauko"); u.setFirstnames("Kalle Kauko");
u.setLastname("Kävija"); u.setLastname("Kävija");
u.setLogin("kavija"); u.setLogin("kavija");
...@@ -143,7 +142,6 @@ public class TestDataBean implements TestDataBeanLocal { ...@@ -143,7 +142,6 @@ public class TestDataBean implements TestDataBeanLocal {
u.setBirthday(bday); u.setBirthday(bday);
u.setCreated(Calendar.getInstance()); u.setCreated(Calendar.getInstance());
u.setEmail("admin@inter.net"); u.setEmail("admin@inter.net");
u.setFemale(false);
u.setFirstnames("Asko Admin"); u.setFirstnames("Asko Admin");
u.setLastname("admin"); u.setLastname("admin");
u.setLogin("admin"); u.setLogin("admin");
......
...@@ -14,5 +14,10 @@ ...@@ -14,5 +14,10 @@
</attributes> </attributes>
</classpathentry> </classpathentry>
<classpathentry kind="lib" path="/LanBortal/ExtraLibs/granite.jar"/> <classpathentry kind="lib" path="/LanBortal/ExtraLibs/granite.jar"/>
<classpathentry kind="lib" path="/Users/tuomari/bin/glassfishv31_0507_2/glassfish/modules/org.eclipse.persistence.core.jar">
<attributes>
<attribute name="javadoc_location" value="jar:file:/Applications/eclipse_Helios_m6/plugins/com.sun.enterprise.jst.server.sunappsrv_1.0.53.jar!/javaee6doc"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="build/classes"/> <classpathentry kind="output" path="build/classes"/>
</classpath> </classpath>
...@@ -65,7 +65,7 @@ public class BillLine implements EventChildInterface { ...@@ -65,7 +65,7 @@ public class BillLine implements EventChildInterface {
/** /**
* How much VAT this product contains ( 0, 0.22 ) etc * How much VAT this product contains ( 0, 0.22 ) etc
*/ */
@Column(name = "vat", nullable = false, precision = 3, scale = 2) @Column(name = "vat", nullable = false, precision = 4, scale = 3)
private BigDecimal vat = DEFAULT_VAT; private BigDecimal vat = DEFAULT_VAT;
/** /**
......
package fi.insomnia.bortal.model;
public enum Gender {
MALE,FEMALE,UNDEFINED
}
...@@ -24,6 +24,9 @@ import javax.persistence.TemporalType; ...@@ -24,6 +24,9 @@ import javax.persistence.TemporalType;
import javax.persistence.Transient; import javax.persistence.Transient;
import javax.persistence.Version; import javax.persistence.Version;
import org.eclipse.persistence.annotations.ConversionValue;
import org.eclipse.persistence.annotations.Convert;
import org.eclipse.persistence.annotations.ObjectTypeConverter;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
...@@ -34,6 +37,11 @@ import fi.insomnia.bortal.utilities.PasswordFunctions; ...@@ -34,6 +37,11 @@ import fi.insomnia.bortal.utilities.PasswordFunctions;
*/ */
@Entity @Entity
@Table(name = "users") @Table(name = "users")
@ObjectTypeConverter(name = "gender", objectType = Gender.class, dataType = String.class, conversionValues = {
@ConversionValue(objectValue = "MALE", dataValue = "M"),
@ConversionValue(objectValue = "FEMALE", dataValue = "F"),
@ConversionValue(objectValue = "UNDEFINED", dataValue = "U"),
})
@NamedQueries( { @NamedQueries( {
@NamedQuery(name = "User.findAll", query = "SELECT u FROM User u"), @NamedQuery(name = "User.findAll", query = "SELECT u FROM User u"),
@NamedQuery(name = "User.findById", query = "SELECT u FROM User u WHERE u.id = :id"), @NamedQuery(name = "User.findById", query = "SELECT u FROM User u WHERE u.id = :id"),
...@@ -49,7 +57,7 @@ import fi.insomnia.bortal.utilities.PasswordFunctions; ...@@ -49,7 +57,7 @@ import fi.insomnia.bortal.utilities.PasswordFunctions;
@NamedQuery(name = "User.findByZip", query = "SELECT u FROM User u WHERE u.zip = :zip"), @NamedQuery(name = "User.findByZip", query = "SELECT u FROM User u WHERE u.zip = :zip"),
@NamedQuery(name = "User.findByTown", query = "SELECT u FROM User u WHERE u.town = :town"), @NamedQuery(name = "User.findByTown", query = "SELECT u FROM User u WHERE u.town = :town"),
@NamedQuery(name = "User.findByPhone", query = "SELECT u FROM User u WHERE u.phone = :phone"), @NamedQuery(name = "User.findByPhone", query = "SELECT u FROM User u WHERE u.phone = :phone"),
@NamedQuery(name = "User.findByFemale", query = "SELECT u FROM User u WHERE u.female = :female"), @NamedQuery(name = "User.findByGender", query = "SELECT u FROM User u WHERE u.gender = :gender"),
@NamedQuery(name = "User.findByLogin", query = "SELECT u FROM User u WHERE u.login = :login") }) @NamedQuery(name = "User.findByLogin", query = "SELECT u FROM User u WHERE u.login = :login") })
public class User implements ModelInterface<Integer> { public class User implements ModelInterface<Integer> {
...@@ -101,8 +109,9 @@ public class User implements ModelInterface<Integer> { ...@@ -101,8 +109,9 @@ public class User implements ModelInterface<Integer> {
@Column(name = "phone") @Column(name = "phone")
private String phone; private String phone;
@Column(name = "female") @Convert("gender")
private Boolean female; @Column(name = "gender", nullable = false)
private Gender gender = Gender.UNDEFINED;
@Column(name = "login", unique = true) @Column(name = "login", unique = true)
private String login; private String login;
...@@ -294,14 +303,6 @@ public class User implements ModelInterface<Integer> { ...@@ -294,14 +303,6 @@ public class User implements ModelInterface<Integer> {
this.phone = phone; this.phone = phone;
} }
public Boolean getFemale() {
return female;
}
public void setFemale(Boolean female) {
this.female = female;
}
public String getLogin() { public String getLogin() {
return login; return login;
} }
...@@ -549,4 +550,12 @@ public class User implements ModelInterface<Integer> { ...@@ -549,4 +550,12 @@ public class User implements ModelInterface<Integer> {
public String getPostalTown() { public String getPostalTown() {
return postalTown; return postalTown;
} }
public void setGender(Gender gender) {
this.gender = gender;
}
public Gender getGender() {
return gender;
}
} }
...@@ -18,16 +18,18 @@ ...@@ -18,16 +18,18 @@
<h:form> <h:form>
<h:panelGrid columns="2"> <h:panelGrid columns="2">
<h:outputLabel value="#{i18n['user.nick']}:" /><h:outputLabel value="#{userView.user.nick}" /> <h:outputLabel value="#{i18n['user.login']}:" /><h:inputText value="#{userView.user.login}" />
<h:outputLabel value="#{i18n['user.lastName']}:" /><h:inputText value="#{userView.user.lastname}" /> <h:outputLabel value="#{i18n['user.nick']}:" /><h:inputText value="#{userView.user.nick}" />
<h:outputLabel value="#{i18n['user.firstNames']}:" /><h:inputText value="#{userView.user.firstnames}" /> <h:outputLabel value="#{i18n['user.firstNames']}:" /><h:inputText value="#{userView.user.firstnames}" />
<h:outputLabel value="#{i18n['user.lastName']}:" /><h:inputText value="#{userView.user.lastname}" />
<h:outputLabel value="#{i18n['user.address']}:" /><h:inputText value="#{userView.user.address}" /> <h:outputLabel value="#{i18n['user.address']}:" /><h:inputText value="#{userView.user.address}" />
<h:outputLabel value="#{i18n['user.zipCode']}:" /><h:inputText value="#{userView.user.zip}" /> <h:outputLabel value="#{i18n['user.zipCode']}:" /><h:inputText value="#{userView.user.zip}" />
<h:outputLabel value="#{i18n['user.town']}:" /><h:inputText value="#{userView.user.town}" /> <h:outputLabel value="#{i18n['user.town']}:" /><h:inputText value="#{userView.user.town}" />
<h:outputLabel value="#{i18n['user.sex']}:" /> <h:outputLabel value="#{i18n['user.sex']}:" />
<h:selectOneRadio id="sex" value="#{userView.user.female}"> <h:selectOneRadio id="sex" value="#{userView.user.gender}">
<f:selectItem id="male" itemLabel="Male" itemValue="false" /> <f:selectItem id="undefined" itemLabel="#{i18n['global.sex.UNDEFINED']}" itemValue="UNDEFINED" />
<f:selectItem id="female" itemLabel="Female" itemValue="true" /> <f:selectItem id="male" itemLabel="#{i18n['global.sex.MALE']}" itemValue="MALE" />
<f:selectItem id="female" itemLabel="#{i18n['global.sex.FEMALE']}" itemValue="FEMALE" />
</h:selectOneRadio> </h:selectOneRadio>
<h:commandButton action="#{userView.saveUser()}" value="#{i18n['save']}" /> <h:commandButton action="#{userView.saveUser()}" value="#{i18n['save']}" />
</h:panelGrid> </h:panelGrid>
......
...@@ -59,7 +59,7 @@ ...@@ -59,7 +59,7 @@
<f:facet name="header"> <f:facet name="header">
<h:outputText value="Sex" /> <h:outputText value="Sex" />
</f:facet> </f:facet>
<h:outputText value="#{user.female}" /> <h:outputText value="#{i18n[concat['global.sex.,#user.gender']]}" />
</h:column> </h:column>
<h:column rendered="#{sessionHandler.canWrite('USER_MANAGEMENT') }"> <h:column rendered="#{sessionHandler.canWrite('USER_MANAGEMENT') }">
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
import org.granite.tide.events.TideFaultEvent; import org.granite.tide.events.TideFaultEvent;
import mx.controls.Label; import mx.controls.Label;
import mx.controls.Text; import mx.controls.Text;
import mx.controls.Image;
import fi.insomnia.bortal.beans.EventBean; import fi.insomnia.bortal.beans.EventBean;
import mx.controls.Alert; import mx.controls.Alert;
...@@ -25,6 +26,9 @@ ...@@ -25,6 +26,9 @@
private var tideContext:Context = Ejb.getInstance().getEjbContext(); private var tideContext:Context = Ejb.getInstance().getEjbContext();
private var text1:Label; private var text1:Label;
[Bindable]
private var startupimg : Image;
private function init():void { private function init():void {
identity.isLoggedIn(); identity.isLoggedIn();
text1 = new Label(); text1 = new Label();
...@@ -42,15 +46,17 @@ ...@@ -42,15 +46,17 @@
var text2:Label = new Label(); var text2:Label = new Label();
text2.x = 50; text2.x = 50;
text2.y = 100; text2.y = 100;
text2.text = "Got result3!!"; text2.text = "Got result4!!";
this.addChild(text2); this.addChild(text2);
var text3:Label = new Label(); var text3:Label = new Label();
text3.x = 50; text3.x = 50;
text3.y = 150; text3.y = 150;
var bgimg:Image = new Image();
bgimg.data = event.result;
this.addChild(bgimg);
Alert.show(event.result.toString());
var txt3:String = "null"; var txt3:String = "null";
if(event.result != null) if(event.result != null)
{ {
......
/**
* Generated by Gas3 v2.1.0 (Granite Data Services).
*
* WARNING: DO NOT CHANGE THIS FILE. IT MAY BE OVERWRITTEN EACH TIME YOU USE
* THE GENERATOR.
*/
package fi.insomnia.bortal.model {
import org.granite.util.Enum;
[Bindable]
[RemoteClass(alias="fi.insomnia.bortal.model.Gender")]
public class Gender extends Enum {
public static const MALE:Gender = new Gender("MALE", _);
public static const FEMALE:Gender = new Gender("FEMALE", _);
public static const UNDEFINED:Gender = new Gender("UNDEFINED", _);
function Gender(value:String = null, restrictor:* = null) {
super((value || MALE.name), restrictor);
}
override protected function getConstants():Array {
return constants;
}
public static function get constants():Array {
return [MALE, FEMALE, UNDEFINED];
}
public static function valueOf(name:String):Gender {
return Gender(MALE.constantOf(name));
}
}
}
\ No newline at end of file
...@@ -13,6 +13,7 @@ package fi.insomnia.bortal.model { ...@@ -13,6 +13,7 @@ package fi.insomnia.bortal.model {
import mx.collections.ListCollectionView; import mx.collections.ListCollectionView;
import org.granite.collections.IPersistentCollection; import org.granite.collections.IPersistentCollection;
import org.granite.meta; import org.granite.meta;
import org.granite.util.Enum;
use namespace meta; use namespace meta;
...@@ -36,8 +37,8 @@ package fi.insomnia.bortal.model { ...@@ -36,8 +37,8 @@ package fi.insomnia.bortal.model {
private var _discountInstances:ListCollectionView; private var _discountInstances:ListCollectionView;
private var _email:String; private var _email:String;
private var _eventOrganiser:ListCollectionView; private var _eventOrganiser:ListCollectionView;
private var _female:Boolean;
private var _firstnames:String; private var _firstnames:String;
private var _gender:Gender;
private var _groupMemberships:ListCollectionView; private var _groupMemberships:ListCollectionView;
private var _id:Number; private var _id:Number;
private var _jpaVersionField:int; private var _jpaVersionField:int;
...@@ -167,13 +168,6 @@ package fi.insomnia.bortal.model { ...@@ -167,13 +168,6 @@ package fi.insomnia.bortal.model {
return _eventOrganiser; return _eventOrganiser;
} }
public function set female(value:Boolean):void {
_female = value;
}
public function get female():Boolean {
return _female;
}
public function set firstnames(value:String):void { public function set firstnames(value:String):void {
_firstnames = value; _firstnames = value;
} }
...@@ -181,6 +175,13 @@ package fi.insomnia.bortal.model { ...@@ -181,6 +175,13 @@ package fi.insomnia.bortal.model {
return _firstnames; return _firstnames;
} }
public function set gender(value:Gender):void {
_gender = value;
}
public function get gender():Gender {
return _gender;
}
public function set groupMemberships(value:ListCollectionView):void { public function set groupMemberships(value:ListCollectionView):void {
_groupMemberships = value; _groupMemberships = value;
} }
...@@ -332,8 +333,8 @@ package fi.insomnia.bortal.model { ...@@ -332,8 +333,8 @@ package fi.insomnia.bortal.model {
_discountInstances = input.readObject() as ListCollectionView; _discountInstances = input.readObject() as ListCollectionView;
_email = input.readObject() as String; _email = input.readObject() as String;
_eventOrganiser = input.readObject() as ListCollectionView; _eventOrganiser = input.readObject() as ListCollectionView;
_female = input.readObject() as Boolean;
_firstnames = input.readObject() as String; _firstnames = input.readObject() as String;
_gender = Enum.readEnum(input) as Gender;
_groupMemberships = input.readObject() as ListCollectionView; _groupMemberships = input.readObject() as ListCollectionView;
_id = function(o:*):Number { return (o is Number ? o as Number : Number.NaN) } (input.readObject()); _id = function(o:*):Number { return (o is Number ? o as Number : Number.NaN) } (input.readObject());
_jpaVersionField = input.readObject() as int; _jpaVersionField = input.readObject() as int;
...@@ -377,8 +378,8 @@ package fi.insomnia.bortal.model { ...@@ -377,8 +378,8 @@ package fi.insomnia.bortal.model {
output.writeObject(_discountInstances); output.writeObject(_discountInstances);
output.writeObject(_email); output.writeObject(_email);
output.writeObject(_eventOrganiser); output.writeObject(_eventOrganiser);
output.writeObject(_female);
output.writeObject(_firstnames); output.writeObject(_firstnames);
output.writeObject(_gender);
output.writeObject(_groupMemberships); output.writeObject(_groupMemberships);
output.writeObject(_id); output.writeObject(_id);
output.writeObject(_jpaVersionField); output.writeObject(_jpaVersionField);
......
package fi.insomnia.bortal.web.helper;
/**
* Copypaste from http://forums.sun.com/thread.jspa?threadID=5136965
*
*/
import java.util.HashMap;
import java.util.StringTokenizer;
import javax.faces.FactoryFinder;
import javax.faces.application.ApplicationFactory;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.NoneScoped;
import javax.faces.context.FacesContext;
@ManagedBean(name = "concat")
@NoneScoped
public class ConcatMBean extends HashMap<Object,Object>
{
/**
*
*/
private static final long serialVersionUID = -6232280680582906176L;
/**
* Concat the string separated by a comma Evaluate JSF EL expression if
* token begin by # or $
*
* @param inObject :
* is the list of string to concat separated by a comma. return a
* String exemple : <h:outputText
* value="#{lang[concat['mpr.canton.,#offer.canton']]}"/>
*/
public Object get(Object inObject)
{
StringBuffer resultBuffer = new StringBuffer();
try
{
String inToken = (String) inObject;
StringTokenizer tok = new StringTokenizer((String) inToken, ",", false);
while (tok.hasMoreTokens())
{
String token = tok.nextToken().trim();
if (token.startsWith("#{"))
{
Object tokenEvaluated = this.getElValue(token);
resultBuffer.append(String.valueOf(tokenEvaluated));
}
else if (token.startsWith("${"))
{
token = token.substring(2, token.length() - 1);
Object tokenEvaluated = this.getElValue(this.getJsfEl(token));
resultBuffer.append(String.valueOf(tokenEvaluated));
}
else if (token.startsWith("#"))
{
token = token.substring(1);
Object tokenEvaluated = this.getElValue(this.getJsfEl(token));
resultBuffer.append(String.valueOf(tokenEvaluated));
}
else
{
resultBuffer.append(token);
}
}
}
catch (Exception e)
{
System.out.println("ConcatenationBackingBean error: " + e.getMessage());
}
return resultBuffer.toString();
}
private Object getElValue(String el)
{
ApplicationFactory appFactory = (ApplicationFactory)FactoryFinder.getFactory(FactoryFinder.APPLICATION_FACTORY);
return appFactory.getApplication().evaluateExpressionGet(FacesContext.getCurrentInstance(), el, java.lang.String.class);
}
private String getJsfEl(String value)
{
return "#{" + value + "}";
}
}
...@@ -19,4 +19,8 @@ defaultstr="Something default..." ...@@ -19,4 +19,8 @@ defaultstr="Something default..."
logout=H\u00E4ivy logout=H\u00E4ivy
nasty.user=paha k\u00E4ytt\u00E4j\u00E4 ei yrit\u00E4 haxoroida meid\u00E4n softaa. Kts. nasty.user=paha k\u00E4ytt\u00E4j\u00E4 ei yrit\u00E4 haxoroida meid\u00E4n softaa. Kts.
product.name=Tuote product.name=Tuote
product.price=Hinta product.price=Hinta
\ No newline at end of file
global.sex.UNDEFINED=Mrittelemtt
global.sex.MALE=Mies
global.sex.FEMALE=Nainen
\ No newline at end of file
...@@ -18,3 +18,8 @@ teststr=default locale test ...@@ -18,3 +18,8 @@ teststr=default locale test
defaultstr="Something default..." defaultstr="Something default..."
logout=H\u00E4ivy logout=H\u00E4ivy
nasty.user=paha k\u00E4ytt\u00E4j\u00E4 ei yrit\u00E4 haxoroida meid\u00E4n softaa. Kts. nasty.user=paha k\u00E4ytt\u00E4j\u00E4 ei yrit\u00E4 haxoroida meid\u00E4n softaa. Kts.
global.sex.UNDEFINED=Undefined
global.sex.MALE=Male
global.sex.FEMALE=Female
\ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!