<commit_before>
package com.krishagni.catissueplus.core.biospecimen.domain;

import java.util.Collection;
import java.util.Collections;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;

import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.hibernate.envers.Audited;
import org.hibernate.envers.NotAudited;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Configurable;
import org.springframework.beans.factory.annotation.Qualifier;

import com.krishagni.catissueplus.core.administrative.domain.Site;
import com.krishagni.catissueplus.core.administrative.domain.User;
import com.krishagni.catissueplus.core.biospecimen.domain.factory.ParticipantErrorCode;
import com.krishagni.catissueplus.core.common.access.AccessCtrlMgr;
import com.krishagni.catissueplus.core.common.errors.OpenSpecimenException;
import com.krishagni.catissueplus.core.common.events.DependentEntityDetail;
import com.krishagni.catissueplus.core.common.service.LabelGenerator;
import com.krishagni.catissueplus.core.common.util.Status;
import com.krishagni.catissueplus.core.common.util.Utility;
import com.krishagni.catissueplus.core.de.services.impl.FormUtil;
import com.krishagni.rbac.common.errors.RbacErrorCode;

@Configurable
@Audited
public class CollectionProtocolRegistration extends BaseEntity {
	private static final String ENTITY_NAME = "collection_protocol_registration";
	
	private String ppid;

	private Date registrationDate;

	private String externalSubjectId;

	private Site site;

	private Participant participant;

	private CollectionProtocol collectionProtocol;

	private Collection<Visit> visits = new HashSet<>();

	private Collection<PdeNotif> pdeNotifs = new HashSet<>();

	private String activityStatus;

	private Date consentSignDate;

	private User consentWitness;
	
	private String consentComments;
	
	private String signedConsentDocumentName;

	private Set<ConsentTierResponse> consentResponses = new HashSet<>();

	private String barcode;

	private Integer extensionRev;
	
	@Autowired
	@Qualifier("ppidGenerator")
	private LabelGenerator labelGenerator;

	private transient boolean forceDelete;

	private transient Boolean hasDeleteSpecimenRights;

	public static String getEntityName() {
		return ENTITY_NAME;
	}
	
	public String getPpid() {
		return ppid;
	}

	public void setPpid(String ppid) {
		this.ppid = ppid;
	}

	public Date getRegistrationDate() {
		return registrationDate;
	}

	public void setRegistrationDate(Date registrationDate) {
		this.registrationDate = registrationDate;
	}

	public String getExternalSubjectId() {
		return externalSubjectId;
	}

	public void setExternalSubjectId(String externalSubjectId) {
		this.externalSubjectId = externalSubjectId;<commit_msg>OPSMN-5348: Ensured empty external subject IDs ('') are not saved. More than one empty external subject ID results in unique constraint violation error.<commit_after>
package com.krishagni.catissueplus.core.biospecimen.domain;

import java.util.Collection;
import java.util.Collections;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;

import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.hibernate.envers.Audited;
import org.hibernate.envers.NotAudited;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Configurable;
import org.springframework.beans.factory.annotation.Qualifier;

import com.krishagni.catissueplus.core.administrative.domain.Site;
import com.krishagni.catissueplus.core.administrative.domain.User;
import com.krishagni.catissueplus.core.biospecimen.domain.factory.ParticipantErrorCode;
import com.krishagni.catissueplus.core.common.access.AccessCtrlMgr;
import com.krishagni.catissueplus.core.common.errors.OpenSpecimenException;
import com.krishagni.catissueplus.core.common.events.DependentEntityDetail;
import com.krishagni.catissueplus.core.common.service.LabelGenerator;
import com.krishagni.catissueplus.core.common.util.Status;
import com.krishagni.catissueplus.core.common.util.Utility;
import com.krishagni.catissueplus.core.de.services.impl.FormUtil;
import com.krishagni.rbac.common.errors.RbacErrorCode;

@Configurable
@Audited
public class CollectionProtocolRegistration extends BaseEntity {
	private static final String ENTITY_NAME = "collection_protocol_registration";
	
	private String ppid;

	private Date registrationDate;

	private String externalSubjectId;

	private Site site;

	private Participant participant;

	private CollectionProtocol collectionProtocol;

	private Collection<Visit> visits = new HashSet<>();

	private Collection<PdeNotif> pdeNotifs = new HashSet<>();

	private String activityStatus;

	private Date consentSignDate;

	private User consentWitness;
	
	private String consentComments;
	
	private String signedConsentDocumentName;

	private Set<ConsentTierResponse> consentResponses = new HashSet<>();

	private String barcode;

	private Integer extensionRev;
	
	@Autowired
	@Qualifier("ppidGenerator")
	private LabelGenerator labelGenerator;

	private transient boolean forceDelete;

	private transient Boolean hasDeleteSpecimenRights;

	public static String getEntityName() {
		return ENTITY_NAME;
	}
	
	public String getPpid() {
		return ppid;
	}

	public void setPpid(String ppid) {
		this.ppid = ppid;
	}

	public Date getRegistrationDate() {
		return registrationDate;
	}

	public void setRegistrationDate(Date registrationDate) {
		this.registrationDate = registrationDate;
	}

	public String getExternalSubjectId() {
		return externalSubjectId;
	}

	public void setExternalSubjectId(String externalSubjectId) {
		if (StringUtils.isBlank(externalSubjectId)) {
			//
			// this is done to avoid UQ violation because of ''
			// For more details, refer to OPSMN-5348
			//
			this.externalSubjectId = null;
		} else {
			this.externalSubjectId = externalSubjectId;
		}
{'fraction_non_alphanumeric': 0.08327932598833442, 'fraction_numerical': 0.0016202203499675956, 'mean_word_length': 5.959413754227734, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, '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': '3441997', 'n_tokens_mistral': 1892, 'n_tokens_neox': 1785, 'n_words': 388}