<commit_before>package fedreg.core

import org.apache.shiro.SecurityUtils

/**
 * Provides contact management views for Organizations.
 *
 * @author <NAME>
 */
class OrganizationContactController {
	def allowedMethods = [create:'POST', delete:'DELETE']
	
	def search = {
		def contacts
			
		if(!params.givenName && !params.surname && !params.email)
			contacts = Contact.list()
		else {
			def emails
			if(params.email)
				emails = MailURI.findAllByUriLike("%${params.email}%")
			def c = Contact.createCriteria()
			contacts = c.list {
				or {
					ilike("givenName", params.givenName)
					ilike("surname", params.surname)
					if(emails)
						'in'("email", emails)
				}
			}
		}
		render template:"/templates/orgcontacts/results", contextPath: pluginContextPath, model:[contacts:contacts]
	}
	
	def create = {
		if(!params.id || !params.contactID || !params.contactType) {
			log.warn "All name/value pairs required for this call were not present"
			render message(code: 'fedreg.controllers.namevalue.missing')
			response.setStatus(500)
			return
		}
		
		def organization = Organization.get(params.id)
		if(!organization) {
			log.warn "Organization identified by id $params.id was not located"<commit_msg>enhanced search criteria for new models<commit_after>package fedreg.core

import org.apache.shiro.SecurityUtils

/**
 * Provides contact management views for Organizations.
 *
 * @author <NAME>
 */
class OrganizationContactController {
	def allowedMethods = [create:'POST', delete:'DELETE']
	
	def search = {
		def contacts
			
		if(!params.givenName && !params.surname && !params.email)
			contacts = Contact.list()
		else {
			def c = Contact.createCriteria()
			contacts = c.list {
				or {
					ilike("givenName", params.givenName)
					ilike("surname", params.surname)
                    if(params.email)
					   ilike("email", "%${params.email}%".toString())
				}
			}
		}
		render template:"/templates/orgcontacts/results", contextPath: pluginContextPath, model:[contacts:contacts]
	}
	
	def create = {
		if(!params.id || !params.contactID || !params.contactType) {
			log.warn "All name/value pairs required for this call were not present"
			render message(code: 'fedreg.controllers.namevalue.missing')
			response.setStatus(500)
			return
		}
		
		def organization = Organization.get(params.id)
		if(!organization) {
			log.warn "Organization identified by id $params.id was not located"
{'fraction_non_alphanumeric': 0.12618949110467523, 'fraction_numerical': 0.0024824162184526274, 'mean_word_length': 3.7134502923976607, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '6277693', 'n_tokens_mistral': 874, 'n_tokens_neox': 726, 'n_words': 169}