package org.xapek.yvesf.classifieds
import groovy.transform.CompileStatic
import java.text.SimpleDateFormat
@CompileStatic
class Model {
static class Classified {
//0 = available" -> "Flexible"
//1 = city" -> "France"
//2 = column_headings" -> "0"
//3 = contact" -> "0795354458"
//4 = currency" -> "CHF"
//5 = date" -> "Jan 25, 16"
//6 = description" -> "Fully furnished house of 270 sqm in total.
\r\n
\r\nVery nice and big house of 270sqm (included 90 sqm2 of basement) with 5 bedrooms, 2 showerooms,1 bathroom and a guest toilet. 70 sqm of closed garage. Wine cellar. Lots of storage.
\r\n
\r\nBig living/dining room with fireplace. Big kitchen all equipped.
\r\n
\r\nLaundry area and storage room.
\r\n
\r\n1000 sqm of land.
\r\n
\r\nLocated in Valleiry 20 minutes from Geneva.
\r\n
\r\n3'000 €
\r\n
\r\nCan be rent unfurnished TBD
\r\n
\r\nNo agencies, thanks!"
//7 = expired" -> "0"
//8 = id" -> "67199"
//9 = location" -> "Valleiry"
//10 ="mark" -> "Mark / Save Ad"
//11 ="mem_first_name" -> "petitemanga"
//12 ="mem_id" -> "16088"
//13 ="mem_link" -> "javascript:open_login_popup();"
//14 ="mem_name" -> "petitemanga"
//15 ="mem_name_js" -> "petitemanga"
//16 ="mem_photo" -> "http://cdn.glocals.com/sites/glocals/_static_media/public/members/empty54.gif"
//17 ="network" -> "Geneva"
//18 ="photo1" -> "/_media/board_flat1/67/67199_bl_photo_eedba.jpg"
//19 ="photo2" -> "/_media/board_flat1/67/67199_bl_photo2_58cc1.jpg"
//20 ="photo3" -> "/_media/board_flat1/67/67199_bl_photo3_a5502.jpg"
//21 ="photo4" -> "/_media/board_flat1/67/67199_bl_photo4_63653.jpg"
//22 ="photos" -> "1"
//23 ="price" -> "3000"
//24 ="rooms" -> "7"
//25 ="status" -> "null"
//26 ="title" -> "Fully furnished house of 270 sqm and huge terrace of 90 sqm"
//27 ="title_js" -> "Fully furnished house of 270 sqm and huge terrace of 90 sqm"
//28 ="type" -> "Apts / Housing for rent"
//29 ="views" -> "8"
String available
String rooms
String location
String city
String type
String price
String currency
String views
String title
String id
String mem_name
String mem_id
String description
String date
Object photo1
Object photo2
Object photo3
Object photo4
Classified(Map map) {
metaClass.properties.grep { it instanceof MetaBeanProperty }.each { MetaProperty property ->
if (!(property as MetaBeanProperty).field) return // ignore setters/getters
if (property.modifiers != 1) return // only public fields
if (map.containsKey(property.name)) {
final value = map.get(property.name)
if (property.type.isAssignableFrom(value.getClass())) {
property.setProperty(this, value)
} else {
throw new IllegalArgumentException("Cannot set field ${property.name} with object of type ${value.getClass()}")
}
} else {
throw new IllegalArgumentException("Missing data for field ${property.name}")
}
}
}
final static SimpleDateFormat dateParser = new SimpleDateFormat('MMM dd, yy', Locale.ENGLISH)
final static SimpleDateFormat dateFormatter = new SimpleDateFormat('EEE, dd MMM yyyy HH:mm:ss Z', Locale.ROOT)
String getFormattedDate() {
return dateFormatter.format(dateParser.parse(date))
}
String getLink() {
return "http://www.glocals.com/classifieds/housing-and-real-estate/${id}.htm"
}
String getComposedLocation() {
return location + (city != location ? ', ' + city : '')
}
Collection getImages() {
return [photo1,photo2,photo3,photo4]
.grep { it instanceof String }
.collect { "http://www.glocals.com/sites/glocals${it}" }
}
String getMemberProfileLink() {
return "http://www.glocals.com/members/member_profile/${id}"
}
}
static class ClassifiedsList extends ArrayList {
long totalCount
@Override
String toString() {
return "Classified List: totalCount=${totalCount} actualCount=${size()}"
}
}
}