Ignore:
Timestamp:
Dec 9, 2010, 9:12:10 PM (10 years ago)
Author:
robert@…
Message:

Added an export and import functionality for templates, as described in ticket #76

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/grails-app/domain/dbnp/studycapturing/TemplateEntity.groovy

    r1245 r1257  
    781781                }
    782782        }
     783
     784    /**
     785     * Returns a Class object given by the entityname, but only if it is a subclass of TemplateEntity
     786         *
     787         * @return A class object of the given entity, null if the entity is not a subclass of TemplateEntity
     788         * @throws ClassNotFoundException
     789     */
     790    static Class parseEntity( String entityName ) {
     791                if( entityName == null )
     792                        return null
     793
     794        // Find the templates
     795        def entity = Class.forName(entityName, true, Thread.currentThread().getContextClassLoader())
     796
     797        // succes, is entity an instance of TemplateEntity?
     798        if (entity?.superclass =~ /TemplateEntity$/ || entity?.superclass?.superclass =~ /TemplateEntity$/) {
     799            return entity;
     800        } else {
     801            return null;
     802        }
     803
     804    }
    783805}
Note: See TracChangeset for help on using the changeset viewer.