Ignore:
Timestamp:
May 20, 2010, 2:56:52 PM (12 years ago)
Author:
tabma
Message:
  • first page of simple import wizard working with entity-/templatefilter
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/grails-app/controllers/dbnp/importer/ImporterController.groovy

    r417 r449  
    2929import dbnp.studycapturing.TemplateFieldType
    3030import dbnp.studycapturing.TemplateField
     31import grails.converters.JSON
    3132
    3233class ImporterController {
    33     def ImporterService
     34    def ImporterService   
    3435
    3536    /**
     
    4041
    4142    def simplewizard = {
    42         def entities = ["Subject", "Event", "Sample"]
    43         render(view:"index_simple", model:[studies:Study.list(), entities:entities])
     43        render(view:"index_simple", model:[studies:Study.list(), entities: grailsApplication.config.gscf.domain.importableEntities])
    4444    }
    4545
     
    160160        render(view:"step4")
    161161    }
     162
     163    /**
     164    * Return templates which belong to a certain entity type
     165    *
     166    * @param entity entity name string (Sample, Subject, Study et cetera)
     167    * @return JSON object containing the found templates
     168    */
     169    def ajaxGetTemplatesByEntity = {
     170        def entityClass = grailsApplication.config.gscf.domain.importableEntities.get(params.entity).entity
     171
     172        // fetch all templates for a specific entity
     173        def templates = Template.findAllByEntity(Class.forName(entityClass, true, this.getClass().getClassLoader()))
     174
     175        println templates
     176       
     177        // render as JSON
     178        render templates as JSON
     179    }
    162180}
Note: See TracChangeset for help on using the changeset viewer.