Skip to content

Commit

Permalink
Basic model
Browse files Browse the repository at this point in the history
  • Loading branch information
iduetxe committed Feb 6, 2014
1 parent d372855 commit 19d0a62
Show file tree
Hide file tree
Showing 42 changed files with 1,125 additions and 32 deletions.
Binary file added cobertura.ser
Binary file not shown.
14 changes: 14 additions & 0 deletions fixtures/politicalGroups.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import kuorum.PoliticalGroup

fixture {
// build{
grupoMixto (PoliticalGroup,name: 'Grupo Mixto')
izquierdaPlural (PoliticalGroup,name: 'Grupo de la Izquierda Plural')
grupoVasco (PoliticalGroup,name: 'Grupo Vasco')
upyd (PoliticalGroup,name: 'Grupo UPyD')
grupoCatalan (PoliticalGroup,name: 'Grupo Catalán')
grupoSocialista (PoliticalGroup,name: 'Grupo Socialista')
grupoPopular (PoliticalGroup,name: 'Grupo Popular')

// }
}
27 changes: 27 additions & 0 deletions fixtures/regions.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import kuorum.Region

fixture {

europe(Region){
name ="Europa"
iso3166_2 = "EU"
}

spain(Region){
name ="España"
iso3166_2 = "EU-SP"
superRegion = europe
}

madrid(Region){
name ="Madrid"
iso3166_2 = "EU-SP-MD"
superRegion = spain
}

catalonia(Region){
name ="Cataluña"
iso3166_2 = "EU-SP-CT"
superRegion = spain
}
}
2 changes: 1 addition & 1 deletion fixtures/testData.groovy
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

//include "region"
include "regions"
//include "politicalGroups"
include "authoritiesData"
include "users/*"
26 changes: 17 additions & 9 deletions fixtures/users/user.groovy
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@
import kuorum.core.model.CommissionType
import kuorum.core.model.Gender
import kuorum.users.KuorumUser
import kuorum.users.KuorumUser
import kuorum.users.PersonalData

fixture {

userPersonalData(PersonalData){
gender = Gender.MALE
postalCode = 28001
regionCode = "EU-SP-MD"
birthday = Date.parse("dd/MM/yyyy","09/10/1983")
}

user(KuorumUser){
username = "Peter"
email = "Peter@kuorum.org"
name ="Peter-Jhon Kevin"

accountExpired = false
accountLocked = false
authorities = [roleUser]
dateCreated = Date.parse("dd/MM/yyyy","20/11/2013")
enabled = true
language ="es_ES"
lastUpdated = Date.parse("dd/MM/yyyy","01/11/2013")
password = springSecurityService.encodePassword("test")
passwordExpired = false
relevantCommissions = [
CommissionType.JUSTICE,
CommissionType.CONSTITUTIONAL,
Expand All @@ -43,5 +42,14 @@ fixture {
CommissionType.SUSTAINABLE_MOBILITY,
CommissionType.OTHERS
]
language ="es_ES"

accountExpired = false
accountLocked = false
authorities = [roleUser]
dateCreated = Date.parse("dd/MM/yyyy","20/11/2013")
enabled = true
lastUpdated = Date.parse("dd/MM/yyyy","01/11/2013")
passwordExpired = false
}
}
4 changes: 2 additions & 2 deletions grails-app/conf/BootStrap.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ class BootStrap {
def init = { servletContext ->
environments {
development {
// KuorumUser.collection.getDB().dropDatabase()
// fixtureLoader.load("testData")
KuorumUser.collection.getDB().dropDatabase()
fixtureLoader.load("testData")
}
test{
KuorumUser.collection.getDB().dropDatabase()
Expand Down
4 changes: 3 additions & 1 deletion grails-app/conf/BuildConfig.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ grails.project.fork = [
// compile: [maxMemory: 256, minMemory: 64, debug: false, maxPerm: 256, daemon:true],
development : [test: false,run: false],
// configure settings for the test-app JVM, uses the daemon by default
test: [maxMemory: 768, minMemory: 64, debug: false, maxPerm: 256, daemon:true],
//test: [maxMemory: 768, minMemory: 64, debug: false, maxPerm: 256, daemon:true],
test:false ,
// configure settings for the run-app JVM
run: [maxMemory: 768, minMemory: 64, debug: false, maxPerm: 256, forkReserve:false],
// configure settings for the run-war JVM
Expand Down Expand Up @@ -63,6 +64,7 @@ grails.project.dependency.resolution = {
//compile 'org.springframework.social:spring-social-core:1.0.1.RELEASE'


compile 'org.apache.solr:solr-solrj:4.6.0'
compile "net.sf.ehcache:ehcache-core:2.4.6" // Para eliminar :cache:1.1.1 que da un problema de dependencia al quitar hibernate

//TEST
Expand Down
15 changes: 12 additions & 3 deletions grails-app/conf/Config.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@
// "file:${userHome}/.grails/${appName}-config.properties",
// "file:${userHome}/.grails/${appName}-config.groovy"]

//grails.config.locations = [
// "classpath:${grails.util.Environment.current.name}_config.properties"
// Environment.current.name
// "classpath:development_config.properties"

//]

// if (System.properties["${appName}.config.location"]) {
// grails.config.locations << "file:" + System.properties["${appName}.config.location"]
// }
Expand Down Expand Up @@ -98,9 +105,11 @@ environments {
log4j = {
// Example of changing the log pattern for the default console appender:
//
//appenders {
// console name:'stdout', layout:pattern(conversionPattern: '%c{2} %m%n')
//}
appenders {
console name:'stdout', layout:pattern(conversionPattern: '%c{2} %m%n')
}

info 'grails.app'

error 'org.codehaus.groovy.grails.web.servlet', // controllers
'org.codehaus.groovy.grails.web.pages', // GSP
Expand Down
6 changes: 6 additions & 0 deletions grails-app/controllers/kuorum/LawController.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package kuorum

class LawController {

static scaffold = true
}
25 changes: 25 additions & 0 deletions grails-app/controllers/kuorum/SearchController.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package kuorum

import grails.converters.JSON

class SearchController {
def searchSolrService
def indexSolrService

def search(String word) {

def docs = searchSolrService.search(word)
render docs as JSON

}

def index(){
indexSolrService.fullIndex()
render "Ok"
}

def suggest(String word){
def res = searchSolrService.suggest(word)
render res as JSON
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package kuorum.users

class KuorumUserController {

static scaffold = true
}
34 changes: 34 additions & 0 deletions grails-app/domain/kuorum/Institution.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package kuorum

import org.bson.types.ObjectId

/**
* Represents the different places where the politician celebrate meetings
* to make decisions -Parlament, Senate -
*
* Parlament of Catalonia, Parlament of Spain, Senate of spain
*
*/
class Institution {

ObjectId id
String name
Region region

static embedded = [ 'region' ]

static constraints = {
name blank: false, nullable:false
}

String toString(){
name
}

boolean equals(Object object){
object && (
id && id.equals(object?.id) ||
name && name.equals(object.name) && region && region.equals(object.region)
)
}
}
33 changes: 33 additions & 0 deletions grails-app/domain/kuorum/ParliamentaryGroup.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package kuorum

import org.bson.types.ObjectId

class ParliamentaryGroup {

ObjectId id
String name
Institution institution

//Desnorm from institution: is for make easier searchs
Region region

static embedded = [ 'institution', 'region' ]

static constraints = {
name blank: false
institution nullable:false
region validator: { val, obj ->
if (val != obj.institution.region) {
return ['notSameRegionAsInstitution']
}
}
}

String toString(){
name
}

boolean equals(Object object){
id.equals(object?.id)
}
}
30 changes: 30 additions & 0 deletions grails-app/domain/kuorum/Region.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package kuorum

import org.bson.types.ObjectId

class Region {

ObjectId id
String name
Region superRegion
String iso3166_2

static constraints = {
iso3166_2 blank: false,
matches: '([A-Z]{2}-)*[A-Z]{2}', // ES-PV España - Pais Vasco
validator: { val, obj ->
if (obj.superRegion && !val.startsWith("${obj.superRegion.iso3166_2}-")) {
return ['incorrectMaterializedPath']
}
}
superRegion nullable:true
}

String toString(){
name
}

boolean equals(Object object){
iso3166_2.equals(object?.iso3166_2)
}
}
24 changes: 24 additions & 0 deletions grails-app/domain/kuorum/law/Law.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package kuorum.law

import kuorum.Institution
import kuorum.Region
import kuorum.core.model.CommissionType

class Law {

String hashtag
String shortName
String realName
String description
String introduction
List<CommissionType> commissions = []
Region region

static embedded = ['region' ]

static constraints = {
hashtag matches: '#[a-zA-Z0-9]+', nullable: false
shortName nullable: false
commissions nullable: false
}
}
20 changes: 20 additions & 0 deletions grails-app/domain/kuorum/post/Cluck.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package kuorum.post

import kuorum.users.KuorumUser

class Cluck {

/**
* The user who has created the cluck
*/
KuorumUser owner
/**
* The user who has created the post clucked
*/
KuorumUser postOwner

Post post

static constraints = {
}
}
18 changes: 18 additions & 0 deletions grails-app/domain/kuorum/post/Post.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package kuorum.post

import kuorum.law.Law
import kuorum.users.KuorumUser

class Post {

KuorumUser owner
Law law
String title
String text
String photo
Integer numVotes

static constraints = {
numVotes min:0
}
}
19 changes: 19 additions & 0 deletions grails-app/domain/kuorum/post/PostVote.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package kuorum.post

import kuorum.users.PersonalData
import kuorum.users.KuorumUser

/**
* Storage the person vote of each post
*/
class PostVote {

Post post
KuorumUser user
PersonalData personalData

static embedded = ['personalData']

static constraints = {
}
}
Loading

0 comments on commit 19d0a62

Please sign in to comment.