<commit_before>package dbnp.studycapturing

import dbnp.authentication.SecUser

/**
 * Domain class describing the basic entity in the study capture part: the Study class.
 *
 * Revision information:
 * $Rev$
 * $Author$
 * $Date$
 */
class Study extends TemplateEntity {
	static searchable = true

	SecUser owner		// The owner of the study. A new study is automatically owned by its creator.
	String title		// The title of the study
	String description	// A brief synopsis of what the study is about
	String code			// currently used as the external study ID, e.g. to reference a study in a SAM module
	Date dateCreated
	Date lastUpdated
	Date startDate
	List subjects
	List events
	List samplingEvents
	List eventGroups
	List samples
	List assays
	boolean published = false // Determines whether a study is private (only accessable by the owner and writers) or published (also visible to readers)
	boolean publicstudy = false  // Determines whether anonymous users are allowed to see this study. This has only effect when published = true

	static hasMany = [
		subjects: Subject,
		samplingEvents: SamplingEvent,
		events: Event,
		eventGroups: EventGroup,
		samples: Sample,
		assays: Assay,
		persons: StudyPerson,
		publications: Publication,
		readers: SecUser,
		writers: SecUser
	]

	static constraints = {
		owner(nullable: true, blank: true)
		code(nullable: false, blank: true, unique: true)

		// TODO: add custom validator for 'published' to assess whether the study meets all quality criteria for publication
		// tested by SampleTests.testStudyPublish
	}

	static mapping = {
		autoTimestamp true
		sort "title"

		// Workaround for bug http://jira.codehaus.org/browse/GRAILS-6754
		templateTextFields type: 'text'
	}

	// The external identifier (studyToken) is currently the code of the study.
	// It is used from within dbNP submodules to refer to particular study in this GSCF instance.

	def getToken() { code }

	/**
	 * return the domain fields for this domain class
	 * @return List
	 */
	static List<TemplateField> giveDomainFields() { return Study.domainFields }

	static final List<TemplateField> domainFields = [
		new TemplateField(
			name: 'title',
			type: TemplateFieldType.STRING,
			required: true),
		new TemplateField(
			name: 'description',
			type: TemplateFieldType.TEXT,
			comment:'Give a brief synopsis of what your study is about',
			required: false),
		new TemplateField(
			name: 'code',
			type: TemplateFieldType.STRING,
			preferredIdentifier: true,
			comment: 'Fill out the code by which many people will recognize your study',
			required: true),
		new TemplateField(
			name: 'startDate',
			type: TemplateFieldType.DATE,
			comment: 'Fill out the official start date or date of first action',
			required: true),<commit_msg>- made description a required field<commit_after>package dbnp.studycapturing

import dbnp.authentication.SecUser

/**
 * Domain class describing the basic entity in the study capture part: the Study class.
 *
 * Revision information:
 * $Rev$
 * $Author$
 * $Date$
 */
class Study extends TemplateEntity {
	static searchable = true

	SecUser owner		// The owner of the study. A new study is automatically owned by its creator.
	String title		// The title of the study
	String description	// A brief synopsis of what the study is about
	String code			// currently used as the external study ID, e.g. to reference a study in a SAM module
	Date dateCreated
	Date lastUpdated
	Date startDate
	List subjects
	List events
	List samplingEvents
	List eventGroups
	List samples
	List assays
	boolean published = false // Determines whether a study is private (only accessable by the owner and writers) or published (also visible to readers)
	boolean publicstudy = false  // Determines whether anonymous users are allowed to see this study. This has only effect when published = true

	static hasMany = [
		subjects: Subject,
		samplingEvents: SamplingEvent,
		events: Event,
		eventGroups: EventGroup,
		samples: Sample,
		assays: Assay,
		persons: StudyPerson,
		publications: Publication,
		readers: SecUser,
		writers: SecUser
	]

	static constraints = {
		owner(nullable: true, blank: true)
		code(nullable: false, blank: true, unique: true)

		// TODO: add custom validator for 'published' to assess whether the study meets all quality criteria for publication
		// tested by SampleTests.testStudyPublish
	}

	static mapping = {
		autoTimestamp true
		sort "title"

		// Workaround for bug http://jira.codehaus.org/browse/GRAILS-6754
		templateTextFields type: 'text'
	}

	// The external identifier (studyToken) is currently the code of the study.
	// It is used from within dbNP submodules to refer to particular study in this GSCF instance.

	def getToken() { code }

	/**
	 * return the domain fields for this domain class
	 * @return List
	 */
	static List<TemplateField> giveDomainFields() { return Study.domainFields }

	static final List<TemplateField> domainFields = [
		new TemplateField(
			name: 'title',
			type: TemplateFieldType.STRING,
			required: true),
		new TemplateField(
			name: 'description',
			type: TemplateFieldType.TEXT,
			comment:'Give a brief synopsis of what your study is about',
			required: true),
		new TemplateField(
			name: 'code',
			type: TemplateFieldType.STRING,
			preferredIdentifier: true,
			comment: 'Fill out the code by which many people will recognize your study',
			required: true),
		new TemplateField(
			name: 'startDate',
			type: TemplateFieldType.DATE,
			comment: 'Fill out the official start date or date of first action',
			required: true),
{'fraction_non_alphanumeric': 0.07366911632909123, 'fraction_numerical': 0.001433948736332676, 'mean_word_length': 3.873362445414847, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7552114', 'n_tokens_mistral': 1692, 'n_tokens_neox': 1524, 'n_words': 658}