diff --git a/sql/locanda.sql b/sql/locanda.sql index a9632893..fbdb5ef3 100644 --- a/sql/locanda.sql +++ b/sql/locanda.sql @@ -15,6 +15,8 @@ /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; + + -- -- Table structure for table `adjustment` -- diff --git a/src/model/Alloggiato.java b/src/model/Alloggiato.java new file mode 100644 index 00000000..c16e436c --- /dev/null +++ b/src/model/Alloggiato.java @@ -0,0 +1,102 @@ +/******************************************************************************* + * + * Copyright 2011 - Sardegna Ricerche, Distretto ICT, Pula, Italy + * + * Licensed under the EUPL, Version 1.1. + * You may not use this work except in compliance with the Licence. + * You may obtain a copy of the Licence at: + * + * http://www.osor.eu/eupl + * + * Unless required by applicable law or agreed to in writing, software distributed under the Licence is distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the Licence for the specific language governing permissions and limitations under the Licence. + * In case of controversy the competent court is the Court of Cagliari (Italy). + *******************************************************************************/ +package model; + +import java.io.Serializable; +import java.util.Date; + +import model.questura.CodiceAlloggiato; + +import javax.xml.bind.annotation.XmlRootElement; + + + +import org.apache.solr.client.solrj.beans.Field; +import org.codehaus.jackson.annotate.JsonIgnoreProperties; + +@XmlRootElement +@JsonIgnoreProperties(ignoreUnknown = true) +public class Alloggiato implements Serializable{ + + @Field + private Integer id; + @Field + private Integer idBooking; + private Guest guest; + private CodiceAlloggiato codiceAlloggiato; + + private Date fromDate; + private Date toDate; + + + + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((id == null) ? 0 : id.hashCode()); + return result; + } + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + Alloggiato other = (Alloggiato) obj; + if (id == null) { + if (other.id != null) + return false; + } else if (!id.equals(other.id)) + return false; + return true; + } + public Integer getId() { + return id; + } + public void setId(Integer id) { + this.id = id; + } + public Guest getGuest() { + return guest; + } + public void setGuest(Guest guest) { + this.guest = guest; + } + public CodiceAlloggiato getCodiceAlloggiato() { + return codiceAlloggiato; + } + public void setCodiceAlloggiato(CodiceAlloggiato codiceAlloggiato) { + this.codiceAlloggiato = codiceAlloggiato; + } + public Date getFromDate() { + return fromDate; + } + public void setFromDate(Date fromDate) { + this.fromDate = fromDate; + } + public Date getToDate() { + return toDate; + } + public void setToDate(Date toDate) { + this.toDate = toDate; + } + + +} \ No newline at end of file diff --git a/src/model/Booking.java b/src/model/Booking.java index ae65ee89..7a81fe4b 100644 --- a/src/model/Booking.java +++ b/src/model/Booking.java @@ -48,6 +48,7 @@ public class Booking implements Serializable{ private Integer id_convention = null; private Integer id_room = null; + private List registroAlloggiati; public Booking(){ this.extras = new ArrayList(); @@ -55,6 +56,8 @@ public Booking(){ this.payments = new ArrayList(); this.guests = new ArrayList(); this.extraItems = new ArrayList(); + this.registroAlloggiati = new ArrayList(); + } public Integer calculateNumNights(){ @@ -212,6 +215,12 @@ public Boolean addExtraItem(ExtraItem anExtraItem){ public Boolean removeExtraItem(Guest anExtraItem){ return this.getExtraItems().remove(anExtraItem); } + public Boolean addAlloggiato(Alloggiato guest){ + return this.getRegistroAlloggiati().add(guest); + } + public Boolean removeAlloggiato(Alloggiato guest){ + return this.getRegistroAlloggiati().remove(guest); + } @Override public int hashCode() { final int prime = 31; @@ -350,4 +359,12 @@ public void setId_room(Integer id_room) { this.id_room = id_room; } + public List getRegistroAlloggiati() { + return registroAlloggiati; + } + + public void setRegistroAlloggiati(List registroAlloggiati) { + this.registroAlloggiati = registroAlloggiati; + } + } \ No newline at end of file diff --git a/src/model/Documento.java b/src/model/Documento.java new file mode 100644 index 00000000..97abe870 --- /dev/null +++ b/src/model/Documento.java @@ -0,0 +1,96 @@ +/******************************************************************************* + * + * Copyright 2011 - Sardegna Ricerche, Distretto ICT, Pula, Italy + * + * Licensed under the EUPL, Version 1.1. + * You may not use this work except in compliance with the Licence. + * You may obtain a copy of the Licence at: + * + * http://www.osor.eu/eupl + * + * Unless required by applicable law or agreed to in writing, software distributed under the Licence is distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the Licence for the specific language governing permissions and limitations under the Licence. + * In case of controversy the competent court is the Court of Cagliari (Italy). + *******************************************************************************/ +package model; + +import java.io.Serializable; + +import model.questura.Comune; +import model.questura.Nazione; +import model.questura.TipoDocumento; +import model.questura.Luogo; + + +import javax.xml.bind.annotation.XmlRootElement; + + + +import org.apache.solr.client.solrj.beans.Field; +import org.codehaus.jackson.annotate.JsonIgnoreProperties; + +@XmlRootElement +@JsonIgnoreProperties(ignoreUnknown = true) +public class Documento implements Serializable{ + + + private Integer id; + @Field + private TipoDocumento tipoDocumento; + @Field + private String numeroDocumento; //max 20 char + @Field + private Luogo luogoRilascio; //Nazione OR Comune Type + + + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((id == null) ? 0 : id.hashCode()); + return result; + } + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + Documento other = (Documento) obj; + if (id == null) { + if (other.id != null) + return false; + } else if (!id.equals(other.id)) + return false; + return true; + } + public Integer getId() { + return id; + } + public void setId(Integer id) { + this.id = id; + } + public TipoDocumento getTipoDocumento() { + return tipoDocumento; + } + public void setTipoDocumento(TipoDocumento tipoDocumento) { + this.tipoDocumento = tipoDocumento; + } + public String getNumeroDocumento() { + return numeroDocumento; + } + public void setNumeroDocumento(String numeroDocumento) { + this.numeroDocumento = numeroDocumento; + } + public Luogo getLuogoRilascio() { + return luogoRilascio; + } + public void setLuogoRilascio(Luogo luogoRilascio) { + this.luogoRilascio = luogoRilascio; + } + +} \ No newline at end of file diff --git a/src/model/Guest.java b/src/model/Guest.java index 70dd6dc4..511034e3 100644 --- a/src/model/Guest.java +++ b/src/model/Guest.java @@ -18,6 +18,10 @@ import java.io.Serializable; import java.util.Date; +import model.Documento; +import model.questura.Comune; +import model.questura.Nazione; + import javax.xml.bind.annotation.XmlRootElement; @@ -54,6 +58,22 @@ public class Guest implements Serializable{ private String idNumber; @Field private Integer id_structure; + + + + private Comune comuneDiNascita; //comune e prov + + private Nazione statoNascita; // + + private Nazione cittadinanza; + private Integer id_cittadinanza; + + private Comune residenza; //comune e prov + + private Nazione statoResidenza; + + + @Override @@ -79,6 +99,8 @@ public boolean equals(Object obj) { return false; return true; } + + public Integer getId() { return id; } @@ -163,5 +185,43 @@ public String getBirthPlace() { public void setBirthPlace(String birthPlace) { this.birthPlace = birthPlace; } + public Nazione getStatoNascita() { + return statoNascita; + } + public void setStatoNascita(Nazione statoNascita) { + this.statoNascita = statoNascita; + } + public Nazione getCittadinanza() { + return cittadinanza; + } + public void setCittadinanza(Nazione cittadinanza) { + this.cittadinanza = cittadinanza; + } + public Comune getResidenza() { + return residenza; + } + public void setResidenza(Comune residenza) { + this.residenza = residenza; + } + public Nazione getStatoResidenza() { + return statoResidenza; + } + public void setStatoResidenza(Nazione statoResidenza) { + this.statoResidenza = statoResidenza; + } + public Comune getComuneDiNascita() { + return comuneDiNascita; + } + public void setComuneDiNascita(Comune comuneDiNascita) { + this.comuneDiNascita = comuneDiNascita; + } + public Integer getId_cittadinanza() { + return id_cittadinanza; + } + public void setId_cittadinanza(Integer id_cittadinanza) { + this.id_cittadinanza = id_cittadinanza; + } + + } \ No newline at end of file diff --git a/src/model/GuestQuesturaFormatter.java b/src/model/GuestQuesturaFormatter.java new file mode 100644 index 00000000..cfceb963 --- /dev/null +++ b/src/model/GuestQuesturaFormatter.java @@ -0,0 +1,249 @@ +/******************************************************************************* + * + * Copyright 2011 - Sardegna Ricerche, Distretto ICT, Pula, Italy + * + * Licensed under the EUPL, Version 1.1. + * You may not use this work except in compliance with the Licence. + * You may obtain a copy of the Licence at: + * + * http://www.osor.eu/eupl + * + * Unless required by applicable law or agreed to in writing, software distributed under the Licence is distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the Licence for the specific language governing permissions and limitations under the Licence. + * In case of controversy the competent court is the Court of Cagliari (Italy). + *******************************************************************************/ +package model; + +import java.io.Serializable; +import java.util.Date; +import java.text.SimpleDateFormat; +import java.lang.String; +import java.lang.Integer; +import javax.xml.bind.annotation.XmlRootElement; + + + +import org.apache.solr.client.solrj.beans.Field; +import org.codehaus.jackson.annotate.JsonIgnoreProperties; + +@XmlRootElement +@JsonIgnoreProperties(ignoreUnknown = true) +public class GuestQuesturaFormatter implements Serializable{ + @Field + private Integer id; + + + + /* + * Dati per la Questura + */ + private Integer tipoAllogiato; // values in range[16-20] + private Date dataArrivo; // gg/mm/aaaa + private String cognome; // 50 chars + private String nome; // 30 chars + private String sesso; // 1 chars (M,F) + private Date dataDiNascita; // gg/mm/aaaa + private String comuneDiNascita; // 9 chars + private String provinciaDiNascita;// 2 chars sigla + private String statoDiNascita; // 9 chars + private String cittadinanza; // 9 chars + private String comuneResidenza; // 9 chars + private String provinciaResidenza; //2 chars + private String statoResidenza; //9 chars + private String indirizzo; // 50 chars + private String tipoDocumento; // 5 chars + private String numeroDocumento; // 20 chars + private String luogoRilascioDocumento; // 9 chars + + /* + * Dati aggiuntivi per la RegioneSardegna + */ + private Date dataDiPartenza; // 10 chars + private String tipoTurismo; // 30 chars + private String mezzoDiTrasporto; // 30 chars + private int camereOccupate; // 3 chars + private int camereDisponibili; // 3 chars + private int lettiDisponibili; // 4 chars + private int tassaSoggiorno; // 1 char (1=yes, 0=no) + private String codiceIdPosizione; // 10 char + private int modalita; // 1 char (1=Nuovo, 2=Variazione, 2=Eliminazione) + + + + + //return a string wich length is fixedSize and and if s < fixedSize is filled with blank spaces + private String fillString(String s, int fixedSize){ + String result = " "; + result = s.concat(result); + return result.substring(0, fixedSize); + + } + + /** + * get the resulting row (236 chars) + * you need to append a (CR+LF) characters at the end of the row + */ + public String getRowQuestura(){ + SimpleDateFormat formatter = new SimpleDateFormat("dd/MM/yyyy"); + String s = ""; + + s = s.concat(Integer.toString(tipoAllogiato)); + s = s.concat(formatter.format(dataArrivo)); + s = s.concat(cognome + nome + sesso); + s = s.concat(formatter.format(dataDiNascita)); + s = s.concat(comuneDiNascita + provinciaDiNascita + statoDiNascita); + s = s.concat(cittadinanza + comuneResidenza + provinciaResidenza + statoResidenza); + s = s.concat(indirizzo + tipoDocumento + numeroDocumento + luogoRilascioDocumento); + + return s; + } + + public String getRowRegione(){ + String questura = this.getRowQuestura(); + SimpleDateFormat formatter = new SimpleDateFormat("dd/MM/yyyy"); + String regione = "todo"; + return questura + regione; + } + + + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((id == null) ? 0 : id.hashCode()); + return result; + } + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + GuestQuesturaFormatter other = (GuestQuesturaFormatter) obj; + if (id == null) { + if (other.id != null) + return false; + } else if (!id.equals(other.id)) + return false; + return true; + } + + + public Integer getId() { + return id; + } + public void setId(Integer id) { + this.id = id; + } + + public Integer getTipoAllogiato(){ + return tipoAllogiato; + } + public void setTipoAllogiato(Integer tipoAllogiato){ + this.tipoAllogiato = tipoAllogiato; + } + + public Date getDataArrivo(){ + return dataArrivo; + } + public void setDataArrivo(Date dataArrivo){ + this.dataArrivo = dataArrivo; + } + + public String getCognome(){ + return cognome; + } + public void setCognome(String cognome){ + this.cognome = fillString(cognome, 50); + } + public String getNome(){ + return nome; + } + public void setNome(String nome){ + this.nome = fillString(nome, 30); + } + public String getSesso(){ + return sesso; + } + public void setSesso(String sesso){ + this.sesso = fillString(sesso, 1); + } + public Date getDataDiNascita(){ + return dataDiNascita; + } + public void setDataDiNascita(Date dataDiNascita){ + this.dataDiNascita = dataDiNascita; + } + public String getComuneDiNascita(){ + return comuneDiNascita; + } + public void setComuneDiNascita(String comuneDiNascita){ + this.comuneDiNascita = fillString(comuneDiNascita, 9); + } + public String getProvinciaDiNascita(){ + return provinciaDiNascita; + } + public void setProvinciaDiNascita(String provinciaDiNascita){ + this.provinciaDiNascita = fillString(provinciaDiNascita,2); + } + public String getStatoDiNascita(){ + return statoDiNascita; + } + public void setStatoDiNascita(String statoDiNascita){ + this.statoDiNascita = fillString(statoDiNascita,9); + } + public String getCittadinanza(){ + return cittadinanza; + } + public void setCittadinanza(String cittadinanza){ + this.cittadinanza = fillString(cittadinanza,9); + } + public String getComuneResidenza(){ + return comuneResidenza; + } + public void setComuneResidenza(String comuneResidenza){ + this.comuneResidenza = fillString(comuneResidenza,9); + } + public String getProvinciaResidenza(){ + return provinciaResidenza; + } + public void setProvinciaResidenza(String provinciaResidenza){ + this.provinciaResidenza = fillString(provinciaResidenza,2); + } + public String getStatoResidenza(){ + return statoResidenza; + } + public void setStatoResidenza(String statoResidenza){ + this.statoResidenza = fillString(statoResidenza,9); + } + public String getIndirizzo(){ + return indirizzo; + } + public void setIndirizzo(String indirizzo){ + this.indirizzo = fillString(indirizzo,50); + } + public String getTipoDocumento(){ + return tipoDocumento; + } + public void setTipoDocumento(String tipoDocumento){ + this.tipoDocumento = fillString(tipoDocumento,5); + } + public String getNumeroDocumento(){ + return numeroDocumento; + } + public void setNumeroDocumento(String numeroDocumento){ + this.numeroDocumento = fillString(numeroDocumento,20); + } + public String getLuogoRilascioDocumento(){ + return luogoRilascioDocumento; + } + public void setLuogoRilascioDocumento(String luogoRilascioDocumento){ + this.luogoRilascioDocumento = fillString(luogoRilascioDocumento,9); + } + + +} \ No newline at end of file diff --git a/src/model/questura/CodiceAlloggiato.java b/src/model/questura/CodiceAlloggiato.java new file mode 100644 index 00000000..aa1fb21c --- /dev/null +++ b/src/model/questura/CodiceAlloggiato.java @@ -0,0 +1,83 @@ +/******************************************************************************* + * + * Copyright 2011 - Sardegna Ricerche, Distretto ICT, Pula, Italy + * + * Licensed under the EUPL, Version 1.1. + * You may not use this work except in compliance with the Licence. + * You may obtain a copy of the Licence at: + * + * http://www.osor.eu/eupl + * + * Unless required by applicable law or agreed to in writing, software distributed under the Licence is distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the Licence for the specific language governing permissions and limitations under the Licence. + * In case of controversy the competent court is the Court of Cagliari (Italy). + *******************************************************************************/ +package model.questura; + +import java.io.Serializable; +import java.util.Date; + +import javax.xml.bind.annotation.XmlRootElement; + + + +import org.apache.solr.client.solrj.beans.Field; +import org.codehaus.jackson.annotate.JsonIgnoreProperties; + +@XmlRootElement +@JsonIgnoreProperties(ignoreUnknown = true) +public class CodiceAlloggiato implements Serializable{ + + @Field + private Integer id; + @Field + private Integer codice; + @Field + private String descrizione; + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((id == null) ? 0 : id.hashCode()); + return result; + } + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + CodiceAlloggiato other = (CodiceAlloggiato) obj; + if (id == null) { + if (other.id != null) + return false; + } else if (!id.equals(other.id)) + return false; + return true; + } + + + public Integer getId() { + return id; + } + public void setId(Integer id) { + this.id = id; + } + public Integer getCodice() { + return codice; + } + public void setCodice(Integer codice) { + this.codice = codice; + } + public String getDescrizione() { + return descrizione; + } + public void setDescrizione(String descrizione) { + this.descrizione = descrizione; + } + +} \ No newline at end of file diff --git a/src/model/questura/Comune.java b/src/model/questura/Comune.java new file mode 100644 index 00000000..9ec29092 --- /dev/null +++ b/src/model/questura/Comune.java @@ -0,0 +1,99 @@ +/******************************************************************************* + * + * Copyright 2011 - Sardegna Ricerche, Distretto ICT, Pula, Italy + * + * Licensed under the EUPL, Version 1.1. + * You may not use this work except in compliance with the Licence. + * You may obtain a copy of the Licence at: + * + * http://www.osor.eu/eupl + * + * Unless required by applicable law or agreed to in writing, software distributed under the Licence is distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the Licence for the specific language governing permissions and limitations under the Licence. + * In case of controversy the competent court is the Court of Cagliari (Italy). + *******************************************************************************/ +package model.questura; + +import java.io.Serializable; +import java.util.Date; +import model.questura.Luogo; +import javax.xml.bind.annotation.XmlRootElement; + + + +import org.apache.solr.client.solrj.beans.Field; +import org.codehaus.jackson.annotate.JsonIgnoreProperties; + +@XmlRootElement +@JsonIgnoreProperties(ignoreUnknown = true) +public class Comune implements Luogo,Serializable{ + + @Field + private Integer id; + @Field + private Integer codice; + @Field + private String descrizione; + @Field + private String provincia; + @Field + private Date dataFineVal; + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((id == null) ? 0 : id.hashCode()); + return result; + } + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + Comune other = (Comune) obj; + if (id == null) { + if (other.id != null) + return false; + } else if (!id.equals(other.id)) + return false; + return true; + } + + + public Integer getId() { + return id; + } + public void setId(Integer id) { + this.id = id; + } + public Integer getCodice() { + return codice; + } + public void setCodice(Integer codice) { + this.codice = codice; + } + public String getDescrizione() { + return descrizione; + } + public void setDescrizione(String descrizione) { + this.descrizione = descrizione; + } + public String getProvincia() { + return provincia; + } + public void setProvincia(String provincia) { + this.provincia = provincia; + } + public Date getDataFineVal() { + return dataFineVal; + } + public void setDataFineVal(Date dataFineVal) { + this.dataFineVal = dataFineVal; + } + +} \ No newline at end of file diff --git a/src/model/questura/Luogo.java b/src/model/questura/Luogo.java new file mode 100644 index 00000000..1051ee50 --- /dev/null +++ b/src/model/questura/Luogo.java @@ -0,0 +1,16 @@ +package model.questura; + +import java.util.Date; + +public interface Luogo { + + public void setCodice(Integer codice); + public String getDescrizione(); + public void setDescrizione(String descrizione); + public String getProvincia(); + public void setProvincia(String provincia); + public Date getDataFineVal(); + public void setDataFineVal(Date dataFineVal); + + +} diff --git a/src/model/questura/Nazione.java b/src/model/questura/Nazione.java new file mode 100644 index 00000000..314d7672 --- /dev/null +++ b/src/model/questura/Nazione.java @@ -0,0 +1,101 @@ +/******************************************************************************* + * + * Copyright 2011 - Sardegna Ricerche, Distretto ICT, Pula, Italy + * + * Licensed under the EUPL, Version 1.1. + * You may not use this work except in compliance with the Licence. + * You may obtain a copy of the Licence at: + * + * http://www.osor.eu/eupl + * + * Unless required by applicable law or agreed to in writing, software distributed under the Licence is distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the Licence for the specific language governing permissions and limitations under the Licence. + * In case of controversy the competent court is the Court of Cagliari (Italy). + *******************************************************************************/ +package model.questura; + +import java.io.Serializable; +import java.util.Date; +import model.questura.Luogo; + + +import javax.xml.bind.annotation.XmlRootElement; + + + +import org.apache.solr.client.solrj.beans.Field; +import org.codehaus.jackson.annotate.JsonIgnoreProperties; + +@XmlRootElement +@JsonIgnoreProperties(ignoreUnknown = true) +public class Nazione implements Luogo,Serializable{ + + @Field + private Integer id; + @Field + private Integer codice; + @Field + private String descrizione; + @Field + private String provincia; + @Field + private Date dataFineVal; + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((id == null) ? 0 : id.hashCode()); + return result; + } + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + Nazione other = (Nazione) obj; + if (id == null) { + if (other.id != null) + return false; + } else if (!id.equals(other.id)) + return false; + return true; + } + + + public Integer getId() { + return id; + } + public void setId(Integer id) { + this.id = id; + } + public Integer getCodice() { + return codice; + } + public void setCodice(Integer codice) { + this.codice = codice; + } + public String getDescrizione() { + return descrizione; + } + public void setDescrizione(String descrizione) { + this.descrizione = descrizione; + } + public String getProvincia() { + return provincia; + } + public void setProvincia(String provincia) { + this.provincia = provincia; + } + public Date getDataFineVal() { + return dataFineVal; + } + public void setDataFineVal(Date dataFineVal) { + this.dataFineVal = dataFineVal; + } + +} \ No newline at end of file diff --git a/src/model/questura/TipoDocumento.java b/src/model/questura/TipoDocumento.java new file mode 100644 index 00000000..c728afe9 --- /dev/null +++ b/src/model/questura/TipoDocumento.java @@ -0,0 +1,83 @@ +/******************************************************************************* + * + * Copyright 2011 - Sardegna Ricerche, Distretto ICT, Pula, Italy + * + * Licensed under the EUPL, Version 1.1. + * You may not use this work except in compliance with the Licence. + * You may obtain a copy of the Licence at: + * + * http://www.osor.eu/eupl + * + * Unless required by applicable law or agreed to in writing, software distributed under the Licence is distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the Licence for the specific language governing permissions and limitations under the Licence. + * In case of controversy the competent court is the Court of Cagliari (Italy). + *******************************************************************************/ +package model.questura; + +import java.io.Serializable; +import java.util.Date; + +import javax.xml.bind.annotation.XmlRootElement; + + + +import org.apache.solr.client.solrj.beans.Field; +import org.codehaus.jackson.annotate.JsonIgnoreProperties; + +@XmlRootElement +@JsonIgnoreProperties(ignoreUnknown = true) +public class TipoDocumento implements Serializable{ + + @Field + private Integer id; + @Field + private String codice; + @Field + private String descrizione; + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((id == null) ? 0 : id.hashCode()); + return result; + } + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + TipoDocumento other = (TipoDocumento) obj; + if (id == null) { + if (other.id != null) + return false; + } else if (!id.equals(other.id)) + return false; + return true; + } + + + public Integer getId() { + return id; + } + public void setId(Integer id) { + this.id = id; + } + public String getCodice() { + return codice; + } + public void setCodice(String codice) { + this.codice = codice; + } + public String getDescrizione() { + return descrizione; + } + public void setDescrizione(String descrizione) { + this.descrizione = descrizione; + } + +} \ No newline at end of file diff --git a/src/persistence/mybatis/mappers/CodiceAlloggiatoMapper.java b/src/persistence/mybatis/mappers/CodiceAlloggiatoMapper.java new file mode 100644 index 00000000..a9980b6c --- /dev/null +++ b/src/persistence/mybatis/mappers/CodiceAlloggiatoMapper.java @@ -0,0 +1,28 @@ +/******************************************************************************* + * + * Copyright 2011 - Sardegna Ricerche, Distretto ICT, Pula, Italy + * + * Licensed under the EUPL, Version 1.1. + * You may not use this work except in compliance with the Licence. + * You may obtain a copy of the Licence at: + * + * http://www.osor.eu/eupl + * + * Unless required by applicable law or agreed to in writing, software distributed under the Licence is distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the Licence for the specific language governing permissions and limitations under the Licence. + * In case of controversy the competent court is the Court of Cagliari (Italy). + *******************************************************************************/ +package persistence.mybatis.mappers; + +import java.util.List; + +import model.questura.CodiceAlloggiato; + +public interface CodiceAlloggiatoMapper { + public List findAll(); +// public List findCodiceAlloggiatoByIdStructure(Integer id_structure); +// public Guest findGuestById(Integer id); + public Integer insertCodiceAlloggiato(CodiceAlloggiato codiceAlloggiato); + +} \ No newline at end of file diff --git a/src/persistence/mybatis/mappers/CodiceAlloggiatoMapper.xml b/src/persistence/mybatis/mappers/CodiceAlloggiatoMapper.xml new file mode 100644 index 00000000..09edf66c --- /dev/null +++ b/src/persistence/mybatis/mappers/CodiceAlloggiatoMapper.xml @@ -0,0 +1,40 @@ + + + + + + + + + + + + + SELECT id,codice,descrizione FROM codicealloggiato + + + + INSERT INTO codicealloggiato(codice,descrizione) VALUES + (#{codice},#{descrizione}) + + + + + + \ No newline at end of file diff --git a/src/persistence/mybatis/mappers/ComuneMapper.java b/src/persistence/mybatis/mappers/ComuneMapper.java new file mode 100644 index 00000000..9fc3a465 --- /dev/null +++ b/src/persistence/mybatis/mappers/ComuneMapper.java @@ -0,0 +1,28 @@ +/******************************************************************************* + * + * Copyright 2011 - Sardegna Ricerche, Distretto ICT, Pula, Italy + * + * Licensed under the EUPL, Version 1.1. + * You may not use this work except in compliance with the Licence. + * You may obtain a copy of the Licence at: + * + * http://www.osor.eu/eupl + * + * Unless required by applicable law or agreed to in writing, software distributed under the Licence is distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the Licence for the specific language governing permissions and limitations under the Licence. + * In case of controversy the competent court is the Court of Cagliari (Italy). + *******************************************************************************/ +package persistence.mybatis.mappers; + +import java.util.List; + +import model.questura.Comune; + +public interface ComuneMapper { + public List findAll(); + public List getAllProvincia(); +// public List findCodiceAlloggiatoByIdStructure(Integer id_structure); +// public Guest findGuestById(Integer id); + +} \ No newline at end of file diff --git a/src/persistence/mybatis/mappers/ComuneMapper.xml b/src/persistence/mybatis/mappers/ComuneMapper.xml new file mode 100644 index 00000000..920e8887 --- /dev/null +++ b/src/persistence/mybatis/mappers/ComuneMapper.xml @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + select id,codice,descrizione,provincia,datafineval FROM comune + + + + + + \ No newline at end of file diff --git a/src/persistence/mybatis/mappers/NazioneMapper.java b/src/persistence/mybatis/mappers/NazioneMapper.java new file mode 100644 index 00000000..d6c6307e --- /dev/null +++ b/src/persistence/mybatis/mappers/NazioneMapper.java @@ -0,0 +1,24 @@ +/******************************************************************************* + * + * Copyright 2011 - Sardegna Ricerche, Distretto ICT, Pula, Italy + * + * Licensed under the EUPL, Version 1.1. + * You may not use this work except in compliance with the Licence. + * You may obtain a copy of the Licence at: + * + * http://www.osor.eu/eupl + * + * Unless required by applicable law or agreed to in writing, software distributed under the Licence is distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the Licence for the specific language governing permissions and limitations under the Licence. + * In case of controversy the competent court is the Court of Cagliari (Italy). + *******************************************************************************/ +package persistence.mybatis.mappers; + +import java.util.List; + +import model.questura.Nazione; + +public interface NazioneMapper { + public List findAll(); +} \ No newline at end of file diff --git a/src/persistence/mybatis/mappers/NazioneMapper.xml b/src/persistence/mybatis/mappers/NazioneMapper.xml new file mode 100644 index 00000000..0c65c3bd --- /dev/null +++ b/src/persistence/mybatis/mappers/NazioneMapper.xml @@ -0,0 +1,33 @@ + + + + + + + + + + + + + select id,codice,descrizione,provincia,datafineval FROM nazione + + + + \ No newline at end of file diff --git a/src/persistence/mybatis/mappers/TipoDocumentoMapper.java b/src/persistence/mybatis/mappers/TipoDocumentoMapper.java new file mode 100644 index 00000000..b53ad276 --- /dev/null +++ b/src/persistence/mybatis/mappers/TipoDocumentoMapper.java @@ -0,0 +1,25 @@ +/******************************************************************************* + * + * Copyright 2011 - Sardegna Ricerche, Distretto ICT, Pula, Italy + * + * Licensed under the EUPL, Version 1.1. + * You may not use this work except in compliance with the Licence. + * You may obtain a copy of the Licence at: + * + * http://www.osor.eu/eupl + * + * Unless required by applicable law or agreed to in writing, software distributed under the Licence is distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the Licence for the specific language governing permissions and limitations under the Licence. + * In case of controversy the competent court is the Court of Cagliari (Italy). + *******************************************************************************/ +package persistence.mybatis.mappers; + +import java.util.List; + +import model.questura.TipoDocumento; + + +public interface TipoDocumentoMapper { + public List findAll(); +} \ No newline at end of file diff --git a/src/persistence/mybatis/mappers/TipoDocumentoMapper.xml b/src/persistence/mybatis/mappers/TipoDocumentoMapper.xml new file mode 100644 index 00000000..6e7067a3 --- /dev/null +++ b/src/persistence/mybatis/mappers/TipoDocumentoMapper.xml @@ -0,0 +1,33 @@ + + + + + + + + + + + + + SELECT id,codice,descrizione FROM tipodocumento + + + + \ No newline at end of file diff --git a/src/resources/QuesturaResource.java b/src/resources/QuesturaResource.java new file mode 100644 index 00000000..95cc70c3 --- /dev/null +++ b/src/resources/QuesturaResource.java @@ -0,0 +1,147 @@ +package resources; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +import javax.annotation.PostConstruct; +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.MediaType; + +import model.questura.TipoDocumento; +import model.questura.CodiceAlloggiato; +import model.questura.Comune; +import model.questura.Nazione; + + + +import service.TipoDocumentoService; +import service.NazioneService; +import service.CodiceAlloggiatoService; +import service.ComuneService; + + +import org.apache.solr.client.solrj.SolrQuery; +import org.apache.solr.client.solrj.SolrServer; +import org.apache.solr.client.solrj.SolrServerException; +import org.apache.solr.client.solrj.response.QueryResponse; +import org.apache.solr.client.solrj.response.FacetField.Count; +import org.apache.solr.common.SolrDocument; +import org.apache.solr.common.SolrDocumentList; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Component; + +import com.sun.jersey.api.NotFoundException; + + + + +@Path("/questura/") +@Component +@Scope("prototype") +public class QuesturaResource { + + @Autowired + private TipoDocumentoService documentoService = null; + + @Autowired + private NazioneService nazioneService = null; + + @Autowired + private CodiceAlloggiatoService codiceAlloggiatoService = null; + + @Autowired + private ComuneService comuneService = null; + + + + + + @PostConstruct + public void init(){ + + } + + @GET + @Path("documento/all") + @Produces({MediaType.APPLICATION_JSON}) + public List getDocumenti(){ + return this.getDocumentoService().findAll(); + + } + + @GET + @Path("codicealloggiato/all") + @Produces({MediaType.APPLICATION_JSON}) + public List getCodiceAlloggiati(){ + return this.getCodiceAlloggiatoService().findAll(); + } + + @GET + @Path("nazione/all") + @Produces({MediaType.APPLICATION_JSON}) + public List getNazioni(){ + return this.getNazioneService().findAll(); + } + + @GET + @Path("comune/all") + @Produces({MediaType.APPLICATION_JSON}) + public List getComuni(){ + return this.getComuneService().findAll(); + } + + @GET + @Path("comune/allprovincia") + @Produces({MediaType.APPLICATION_JSON}) + public List getComuniProv(){ + return this.getComuneService().getAllProvincia(); + } + + + public NazioneService getNazioneService() { + return nazioneService; + } + + public void setNazioneService(NazioneService nazioneService) { + this.nazioneService = nazioneService; + } + + public CodiceAlloggiatoService getCodiceAlloggiatoService() { + return codiceAlloggiatoService; + } + + public void setCodiceAlloggiatoService( + CodiceAlloggiatoService codiceAlloggiatoService) { + this.codiceAlloggiatoService = codiceAlloggiatoService; + } + + public TipoDocumentoService getDocumentoService() { + return documentoService; + } + + public void setDocumentoService(TipoDocumentoService documentoService) { + this.documentoService = documentoService; + } + + public ComuneService getComuneService() { + return comuneService; + } + + public void setComuneService(ComuneService comuneService) { + this.comuneService = comuneService; + } + + + + +} \ No newline at end of file diff --git a/src/service/CodiceAlloggiatoService.java b/src/service/CodiceAlloggiatoService.java new file mode 100644 index 00000000..dece1430 --- /dev/null +++ b/src/service/CodiceAlloggiatoService.java @@ -0,0 +1,26 @@ +/******************************************************************************* + * + * Copyright 2011 - Sardegna Ricerche, Distretto ICT, Pula, Italy + * + * Licensed under the EUPL, Version 1.1. + * You may not use this work except in compliance with the Licence. + * You may obtain a copy of the Licence at: + * + * http://www.osor.eu/eupl + * + * Unless required by applicable law or agreed to in writing, software distributed under the Licence is distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the Licence for the specific language governing permissions and limitations under the Licence. + * In case of controversy the competent court is the Court of Cagliari (Italy). + *******************************************************************************/ +package service; + +import java.util.List; +import org.springframework.transaction.annotation.Transactional; +import model.questura.CodiceAlloggiato; + +@Transactional +public interface CodiceAlloggiatoService { + public List findAll(); + public Integer insertGuest(CodiceAlloggiato codiceAlloggiato); +} \ No newline at end of file diff --git a/src/service/CodiceAlloggiatoServiceImpl.java b/src/service/CodiceAlloggiatoServiceImpl.java new file mode 100644 index 00000000..d69e161d --- /dev/null +++ b/src/service/CodiceAlloggiatoServiceImpl.java @@ -0,0 +1,51 @@ +/******************************************************************************* + * + * Copyright 2011 - Sardegna Ricerche, Distretto ICT, Pula, Italy + * + * Licensed under the EUPL, Version 1.1. + * You may not use this work except in compliance with the Licence. + * You may obtain a copy of the Licence at: + * + * http://www.osor.eu/eupl + * + * Unless required by applicable law or agreed to in writing, software distributed under the Licence is distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the Licence for the specific language governing permissions and limitations under the Licence. + * In case of controversy the competent court is the Court of Cagliari (Italy). + *******************************************************************************/ +package service; + +import java.util.List; + +import model.questura.CodiceAlloggiato; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import persistence.mybatis.mappers.CodiceAlloggiatoMapper; + +@Service +public class CodiceAlloggiatoServiceImpl implements CodiceAlloggiatoService{ + @Autowired + private CodiceAlloggiatoMapper codiceAlloggiatoMapper; + + + @Override + public Integer insertGuest(CodiceAlloggiato codiceAlloggiato) { + return this.getCodiceAlloggiatoMapper().insertCodiceAlloggiato(codiceAlloggiato); + } + + @Override + public List findAll() { + return this.getCodiceAlloggiatoMapper().findAll(); + } + + + public CodiceAlloggiatoMapper getCodiceAlloggiatoMapper() { + return codiceAlloggiatoMapper; + } + public void setCodiceAlloggiatoMapper(CodiceAlloggiatoMapper codiceAlloggiatoMapper) { + this.codiceAlloggiatoMapper = codiceAlloggiatoMapper; + } + +} \ No newline at end of file diff --git a/src/service/ComuneService.java b/src/service/ComuneService.java new file mode 100644 index 00000000..1bc218bd --- /dev/null +++ b/src/service/ComuneService.java @@ -0,0 +1,26 @@ +/******************************************************************************* + * + * Copyright 2011 - Sardegna Ricerche, Distretto ICT, Pula, Italy + * + * Licensed under the EUPL, Version 1.1. + * You may not use this work except in compliance with the Licence. + * You may obtain a copy of the Licence at: + * + * http://www.osor.eu/eupl + * + * Unless required by applicable law or agreed to in writing, software distributed under the Licence is distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the Licence for the specific language governing permissions and limitations under the Licence. + * In case of controversy the competent court is the Court of Cagliari (Italy). + *******************************************************************************/ +package service; + +import java.util.List; +import org.springframework.transaction.annotation.Transactional; +import model.questura.Comune; + +@Transactional +public interface ComuneService { + public List findAll(); + public List getAllProvincia(); +} \ No newline at end of file diff --git a/src/service/ComuneServiceImpl.java b/src/service/ComuneServiceImpl.java new file mode 100644 index 00000000..6acd7d33 --- /dev/null +++ b/src/service/ComuneServiceImpl.java @@ -0,0 +1,62 @@ +/******************************************************************************* + * + * Copyright 2011 - Sardegna Ricerche, Distretto ICT, Pula, Italy + * + * Licensed under the EUPL, Version 1.1. + * You may not use this work except in compliance with the Licence. + * You may obtain a copy of the Licence at: + * + * http://www.osor.eu/eupl + * + * Unless required by applicable law or agreed to in writing, software distributed under the Licence is distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the Licence for the specific language governing permissions and limitations under the Licence. + * In case of controversy the competent court is the Court of Cagliari (Italy). + *******************************************************************************/ +package service; + +import java.util.List; +import java.util.Collections; + +import model.questura.Comune; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import persistence.mybatis.mappers.ComuneMapper; + +@Service +public class ComuneServiceImpl implements ComuneService{ + @Autowired + private ComuneMapper comuneMapper; + + + + @Override + public List findAll() { + return this.getComuneMapper().findAll(); + } + + @Override + public List getAllProvincia() { + List prov = this.getComuneMapper().getAllProvincia(); + Collections.sort(prov); + return prov; + } + + + public ComuneMapper getComuneMapper() { + return comuneMapper; + } + + + + public void setComuneMapper(ComuneMapper comuneMapper) { + this.comuneMapper = comuneMapper; + } + + + + + +} \ No newline at end of file diff --git a/src/service/NazioneService.java b/src/service/NazioneService.java new file mode 100644 index 00000000..884de697 --- /dev/null +++ b/src/service/NazioneService.java @@ -0,0 +1,25 @@ +/******************************************************************************* + * + * Copyright 2011 - Sardegna Ricerche, Distretto ICT, Pula, Italy + * + * Licensed under the EUPL, Version 1.1. + * You may not use this work except in compliance with the Licence. + * You may obtain a copy of the Licence at: + * + * http://www.osor.eu/eupl + * + * Unless required by applicable law or agreed to in writing, software distributed under the Licence is distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the Licence for the specific language governing permissions and limitations under the Licence. + * In case of controversy the competent court is the Court of Cagliari (Italy). + *******************************************************************************/ +package service; + +import java.util.List; +import org.springframework.transaction.annotation.Transactional; +import model.questura.Nazione; + +@Transactional +public interface NazioneService { + public List findAll(); +} \ No newline at end of file diff --git a/src/service/NazioneServiceImpl.java b/src/service/NazioneServiceImpl.java new file mode 100644 index 00000000..76cf897f --- /dev/null +++ b/src/service/NazioneServiceImpl.java @@ -0,0 +1,52 @@ +/******************************************************************************* + * + * Copyright 2011 - Sardegna Ricerche, Distretto ICT, Pula, Italy + * + * Licensed under the EUPL, Version 1.1. + * You may not use this work except in compliance with the Licence. + * You may obtain a copy of the Licence at: + * + * http://www.osor.eu/eupl + * + * Unless required by applicable law or agreed to in writing, software distributed under the Licence is distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the Licence for the specific language governing permissions and limitations under the Licence. + * In case of controversy the competent court is the Court of Cagliari (Italy). + *******************************************************************************/ +package service; + +import java.util.List; + +import model.questura.Nazione; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import persistence.mybatis.mappers.NazioneMapper; + +@Service +public class NazioneServiceImpl implements NazioneService{ + @Autowired + private NazioneMapper nazioneMapper; + + + + @Override + public List findAll() { + return this.getNazioneMapper().findAll(); + } + + + + public NazioneMapper getNazioneMapper() { + return nazioneMapper; + } + + + + public void setNazioneMapper(NazioneMapper nazioneMapper) { + this.nazioneMapper = nazioneMapper; + } + + +} \ No newline at end of file diff --git a/src/service/TipoDocumentoService.java b/src/service/TipoDocumentoService.java new file mode 100644 index 00000000..730440e1 --- /dev/null +++ b/src/service/TipoDocumentoService.java @@ -0,0 +1,25 @@ +/******************************************************************************* + * + * Copyright 2011 - Sardegna Ricerche, Distretto ICT, Pula, Italy + * + * Licensed under the EUPL, Version 1.1. + * You may not use this work except in compliance with the Licence. + * You may obtain a copy of the Licence at: + * + * http://www.osor.eu/eupl + * + * Unless required by applicable law or agreed to in writing, software distributed under the Licence is distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the Licence for the specific language governing permissions and limitations under the Licence. + * In case of controversy the competent court is the Court of Cagliari (Italy). + *******************************************************************************/ +package service; + +import java.util.List; +import org.springframework.transaction.annotation.Transactional; +import model.questura.TipoDocumento; + +@Transactional +public interface TipoDocumentoService { + public List findAll(); +} \ No newline at end of file diff --git a/src/service/TipoDocumentoServiceImpl.java b/src/service/TipoDocumentoServiceImpl.java new file mode 100644 index 00000000..67b0a145 --- /dev/null +++ b/src/service/TipoDocumentoServiceImpl.java @@ -0,0 +1,55 @@ +/******************************************************************************* + * + * Copyright 2011 - Sardegna Ricerche, Distretto ICT, Pula, Italy + * + * Licensed under the EUPL, Version 1.1. + * You may not use this work except in compliance with the Licence. + * You may obtain a copy of the Licence at: + * + * http://www.osor.eu/eupl + * + * Unless required by applicable law or agreed to in writing, software distributed under the Licence is distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the Licence for the specific language governing permissions and limitations under the Licence. + * In case of controversy the competent court is the Court of Cagliari (Italy). + *******************************************************************************/ +package service; + +import java.util.List; + +import model.questura.TipoDocumento; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import persistence.mybatis.mappers.TipoDocumentoMapper; + +@Service +public class TipoDocumentoServiceImpl implements TipoDocumentoService{ + @Autowired + private TipoDocumentoMapper tipoDocumentoMapper; + + + + @Override + public List findAll() { + return this.getTipoDocumentoMapper().findAll(); + } + + + + + + + public TipoDocumentoMapper getTipoDocumentoMapper() { + return tipoDocumentoMapper; + } + + + + public void setTipoDocumentoMapper(TipoDocumentoMapper tipoDocumentoMapper) { + this.tipoDocumentoMapper = tipoDocumentoMapper; + } + + +} \ No newline at end of file diff --git a/test/test/GuestQuesturaFormatterTest.java b/test/test/GuestQuesturaFormatterTest.java new file mode 100644 index 00000000..e9c1efc6 --- /dev/null +++ b/test/test/GuestQuesturaFormatterTest.java @@ -0,0 +1,53 @@ +package test; + +import static org.junit.Assert.*; + +import java.util.Date; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import model.GuestQuesturaFormatter; + +public class GuestQuesturaFormatterTest { + GuestQuesturaFormatter m; + + @Before + public void setUp() throws Exception { + m = new GuestQuesturaFormatter(); + m.setTipoAllogiato(14); + m.setDataArrivo(new Date("02/05/2011")); + m.setCognome("Mura"); + m.setNome("Tore"); + m.setSesso("M"); + m.setDataDiNascita(new Date("12/02/1950")); + m.setComuneDiNascita("Santulussurgiu"); + m.setProvinciaDiNascita("CAGLIARI"); + m.setStatoDiNascita("Italia"); + m.setCittadinanza("Italiana"); + m.setComuneResidenza("Selargius"); + m.setProvinciaResidenza("Cagliari"); + m.setStatoResidenza("Italia"); + m.setIndirizzo("Via delle fresche frasche, n1"); + m.setTipoDocumento("Patente"); + m.setNumeroDocumento("CC123456lkjdf"); + m.setLuogoRilascioDocumento("Villanovaforru"); + } + + @After + public void tearDown() throws Exception { + } + + @Test + public void outputLengthTest() { + //System.out.print(m.getRowQuestura()); + assertEquals(236,m.getRowQuestura().length()); + } + + @Test + public void sessoTest() { + assertEquals("M", m.getRowQuestura().substring(92, 93)); + + } + +}