Changeset 778 for trunk/grails-app/domain
- Timestamp:
- Aug 5, 2010, 10:58:09 PM (11 years ago)
- Location:
- trunk/grails-app/domain/dbnp/studycapturing
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/domain/dbnp/studycapturing/EventGroup.groovy
r754 r778 10 10 */ 11 11 class EventGroup implements Serializable { 12 13 static belongsTo = [parent : Study]14 15 12 String name 16 13 14 // keep an internal identifier for use in dynamic forms 15 private int identifier = 0 16 static int iterator = 0 17 18 static transients = [ "identifier", "iterator" ] 19 static belongsTo = [parent : Study] 17 20 static hasMany = [ 18 21 subjects: Subject, … … 23 26 static constraints = { 24 27 } 28 29 /** 30 * Class constructor increments that static iterator 31 * and sets the object's identifier (used in dynamic webforms) 32 * @void 33 */ 34 public EventGroup() { 35 if (!identifier) identifier = iterator++ 36 } 37 38 /** 39 * Return the identifier 40 * @return int 41 */ 42 final public int getIdentifier() { 43 return identifier 44 } 25 45 } -
trunk/grails-app/domain/dbnp/studycapturing/Study.groovy
r774 r778 100 100 } 101 101 102 103 /** 104 * Return all subjects for a specific template 105 * @param Template 106 * @return ArrayList 107 */ 108 def ArrayList<Subject> giveSubjectsForTemplate(Template template) { 109 subjects.findAll { it.template.equals(template) } 110 } 111 102 112 /** 103 113 * Return the unique Event and SamplingEvent templates that are used in this study … … 107 117 // gives trouble when asking .size() to the result 108 118 // So we also use giveTemplates here 109 TemplateEntity.giveTemplates(events + samplingEvents) 119 TemplateEntity.giveTemplates( ((events) ? events : []) + ((samplingEvents) ? samplingEvents : []) ) 120 } 121 122 123 /** 124 * Return all events and samplingEvenets for a specific template 125 * @param Template 126 * @return ArrayList 127 */ 128 def ArrayList giveEventsForTemplate(Template template) { 129 def events = events.findAll { it.template.equals(template) } 130 def samplingEvents = samplingEvents.findAll { it.template.equals(template) } 131 132 return (events) ? events : samplingEvents 110 133 } 111 134 … … 138 161 139 162 140 141 * Delete a specific subject from this study, including all its relations142 * @param subject The subject to be deleted143 * @return A String which contains a (user-readable) message describing the changes to the database144 */163 /** 164 * Delete a specific subject from this study, including all its relations 165 * @param subject The subject to be deleted 166 * @return A String which contains a (user-readable) message describing the changes to the database 167 */ 145 168 String deleteSubject(Subject subject) { 146 147 169 String msg = "Subject ${subject.name} was deleted" 148 170 … … 171 193 return msg 172 194 } 195 196 /** 197 * Delete an event from the study, including all its relations 198 * @param Event 199 * @return String 200 */ 201 String deleteEvent(Event event) { 202 String msg = "Event ${event} was deleted" 203 204 // remove event from the study 205 this.removeFromEvents(event) 206 207 // remove event from eventGroups 208 this.eventGroups.each() { eventGroup -> 209 eventGroup.removeFromEvents(event) 210 } 211 212 return msg 213 } 214 215 /** 216 * Delete a samplingEvent from the study, including all its relations 217 * @param SamplingEvent 218 * @return String 219 */ 220 String deleteSamplingEvent(SamplingEvent samplingEvent) { 221 String msg = "SamplingEvent ${samplingEvent} was deleted" 222 223 // remove event from eventGroups 224 this.eventGroups.each() { eventGroup -> 225 eventGroup.removeFromSamplingEvents(samplingEvent) 226 } 227 228 // remove event from the study 229 this.removeFromSamplingEvents(samplingEvent) 230 231 return msg 232 } 233 /** 234 * Delete an eventGroup from the study, including all its relations 235 * @param EventGroup 236 * @return String 237 */ 238 String deleteEventGroup(EventGroup eventGroup) { 239 String msg = "EventGroup ${eventGroup} was deleted" 240 241 // remove the eventGroup from the study 242 this.removeFromEventGroups(eventGroup) 243 244 return msg 245 } 173 246 } -
trunk/grails-app/domain/dbnp/studycapturing/Template.groovy
r754 r778 33 33 /** The template fields which are the members of this template. This is a List to preserve the field order */ 34 34 List fields 35 36 // keep an internal identifier for use in dynamic forms 37 private int identifier = 0 38 static int iterator = 0 39 40 // set transients 41 static transients = [ "identifier", "iterator" ] 42 35 43 static hasMany = [fields: TemplateField] 36 44 … … 70 78 // which can co-exist with the same name. See also TemplateField 71 79 // name(unique:['entity']) 80 } 81 82 /** 83 * Class constructor increments that static iterator 84 * and sets the object's identifier (used in dynamic webforms) 85 * @void 86 */ 87 public Template() { 88 if (!identifier) identifier = iterator++ 89 println ".instantiating [" + this.getClass() + "] ("+ identifier + ")" 90 } 91 92 /** 93 * Return the identifier 94 * @return int 95 */ 96 final public int getIdentifier() { 97 return identifier 72 98 } 73 99 -
trunk/grails-app/domain/dbnp/studycapturing/TemplateEntity.groovy
r754 r778 18 18 */ 19 19 abstract class TemplateEntity implements Serializable { 20 21 20 /** The actual template of this TemplateEntity instance */ 22 21 Template template … … 38 37 Map templateTermFields = [:] 39 38 39 // keep an internal identifier for use in dynamic forms 40 private int identifier = 0 41 static int iterator = 0 42 43 // set transients 44 static transients = [ "identifier", "iterator" ] 45 46 // define relationships 40 47 static hasMany = [ 41 48 templateStringFields: String, … … 54 61 55 62 static mapping = { 56 57 63 // Specify that each TemplateEntity-subclassing entity should have its own tables to store TemplateField values. 58 64 // This results in a lot of tables, but performance is presumably better because in most queries, only values of … … 324 330 return (!error) 325 331 }) 332 } 333 334 /** 335 * Class constructor increments that static iterator 336 * and sets the object's identifier (used in dynamic webforms) 337 * @void 338 */ 339 public TemplateEntity() { 340 if (!identifier) identifier = iterator++ 341 } 342 343 /** 344 * Return the identifier 345 * @return int 346 */ 347 final public int getIdentifier() { 348 return identifier 326 349 } 327 350 … … 593 616 // it is unset if it is. 594 617 if (value || value == 0 || ( field.type == TemplateFieldType.BOOLEAN && value == false)) { 595 println ".setting [" + ((super) ? super.class : '??') + "] template field: [" + fieldName + "] ([" + value.toString() + "] of type [" + value.class + "])"618 println ".setting [" + ((super) ? super.class : '??') + "] ("+getIdentifier()+") template field: [" + fieldName + "] ([" + value.toString() + "] of type [" + value.class + "])" 596 619 597 620 // set value 598 621 store[fieldName] = value 599 622 } else if (store[fieldName]) { 600 println ".unsetting [" + ((super) ? super.class : '??') + "] template field: [" + fieldName + "]"623 println ".unsetting [" + ((super) ? super.class : '??') + "] ("+getIdentifier()+") template field: [" + fieldName + "]" 601 624 602 625 // remove the item from the Map (if present)
Note: See TracChangeset
for help on using the changeset viewer.