<commit_before>/*
 * Copyright 2011-2021 B2i Healthcare Pte Ltd, http://b2i.sg
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.b2international.snowowl.test.commons.snomed;

import static com.google.common.base.Preconditions.checkArgument;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;

import com.b2international.collections.PrimitiveSets;
import com.b2international.commons.CompareUtils;
import com.b2international.snowowl.core.date.EffectiveTimes;
import com.b2international.snowowl.core.domain.IComponent;
import com.b2international.snowowl.snomed.common.SnomedConstants.Concepts;
import com.b2international.snowowl.snomed.common.SnomedRf2Headers;
import com.b2international.snowowl.snomed.core.domain.RelationshipValue;
import com.b2international.snowowl.snomed.core.domain.SnomedConcept;
import com.b2international.snowowl.snomed.core.domain.constraint.ConstraintForm;
import com.b2international.snowowl.snomed.core.domain.refset.DataType;
import com.b2international.snowowl.snomed.core.domain.refset.SnomedRefSetType;
import com.b2international.snowowl.snomed.datastore.index.constraint.SnomedConstraintDocument;
import com.b2international.snowowl.snomed.datastore.index.constraint.SnomedConstraintPredicateType;
import com.b2international.snowowl.snomed.datastore.index.entry.*;
import com.b2international.snowowl.snomed.datastore.index.entry.SnomedRefSetMemberIndexEntry.Fields;

/**
 * 
 * @since 6.4
 */
public abstract class DocumentBuilders {

	private DocumentBuilders() {}
	
	public static SnomedConceptDocument.Builder concept(final String id) {
		return SnomedConceptDocument.builder()
				.id(id)
				.iconId(Concepts.ROOT_CONCEPT)
				.active(true)
				.released(true)
				.exhaustive(false)
				.moduleId(Concepts.MODULE_SCT_CORE)
				.effectiveTime(EffectiveTimes.UNSET_EFFECTIVE_TIME)
				.definitionStatusId(Concepts.PRIMITIVE)
				.parents(PrimitiveSets.newLongSortedSet(IComponent.ROOT_IDL))
				.ancestors(PrimitiveSets.newLongSortedSet())
				.statedParents(PrimitiveSets.newLongSortedSet(IComponent.ROOT_IDL))
				.statedAncestors(PrimitiveSets.newLongSortedSet());
	}
	
	public static SnomedConstraintDocument.Builder constraint() {
		return SnomedConstraintDocument.builder()
				.id(UUID.randomUUID().toString())
				.predicateType(SnomedConstraintPredicateType.RELATIONSHIP)
				.form(ConstraintForm.ALL_FORMS)
				.active(true);
	}
	
	public static SnomedDescriptionIndexEntry.Builder description(final String id, final String type, final String term) {
		return SnomedDescriptionIndexEntry.builder()
				.id(id)
				.active(true)
				.moduleId(Concepts.MODULE_SCT_CORE)
				.typeId(type)
				.languageCode("en")
				.term(term)
				.caseSignificanceId(Concepts.ONLY_INITIAL_CHARACTER_CASE_INSENSITIVE)
				.released(false);
	}
	
	public static SnomedRefSetMemberIndexEntry.Builder member(final String id, String referencedComponentId, String referencedComponentType, String referenceSetId) {
		return SnomedRefSetMemberIndexEntry.builder()
				.id(id)
				.active(true)
				.referencedComponentId(referencedComponentId)
				.referencedComponentType(referencedComponentType)
				.refsetId(referenceSetId)
				.released(true);
	}
	
	public static SnomedRelationshipIndexEntry.Builder relationship(final String source, final String type, final String destination) {
		return relationship(source, type, destination, Concepts.INFERRED_RELATIONSHIP);
	}
	
	public static SnomedRelationshipIndexEntry.Builder relationship(final String source, final String type, final String destination, String characteristicTypeId) {
		return SnomedRelationshipIndexEntry.builder()
				.id(RandomSnomedIdentiferGenerator.generateRelationshipId())<commit_msg>SO-4946: Remove SNOMED constraint builder from test files<commit_after>/*
 * Copyright 2011-2021 B2i Healthcare Pte Ltd, http://b2i.sg
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.b2international.snowowl.test.commons.snomed;

import static com.google.common.base.Preconditions.checkArgument;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;

import com.b2international.collections.PrimitiveSets;
import com.b2international.commons.CompareUtils;
import com.b2international.snowowl.core.date.EffectiveTimes;
import com.b2international.snowowl.core.domain.IComponent;
import com.b2international.snowowl.snomed.common.SnomedConstants.Concepts;
import com.b2international.snowowl.snomed.common.SnomedRf2Headers;
import com.b2international.snowowl.snomed.core.domain.RelationshipValue;
import com.b2international.snowowl.snomed.core.domain.SnomedConcept;
import com.b2international.snowowl.snomed.core.domain.refset.DataType;
import com.b2international.snowowl.snomed.core.domain.refset.SnomedRefSetType;
import com.b2international.snowowl.snomed.datastore.index.entry.*;
import com.b2international.snowowl.snomed.datastore.index.entry.SnomedRefSetMemberIndexEntry.Fields;

/**
 * 
 * @since 6.4
 */
public abstract class DocumentBuilders {

	private DocumentBuilders() {}
	
	public static SnomedConceptDocument.Builder concept(final String id) {
		return SnomedConceptDocument.builder()
				.id(id)
				.iconId(Concepts.ROOT_CONCEPT)
				.active(true)
				.released(true)
				.exhaustive(false)
				.moduleId(Concepts.MODULE_SCT_CORE)
				.effectiveTime(EffectiveTimes.UNSET_EFFECTIVE_TIME)
				.definitionStatusId(Concepts.PRIMITIVE)
				.parents(PrimitiveSets.newLongSortedSet(IComponent.ROOT_IDL))
				.ancestors(PrimitiveSets.newLongSortedSet())
				.statedParents(PrimitiveSets.newLongSortedSet(IComponent.ROOT_IDL))
				.statedAncestors(PrimitiveSets.newLongSortedSet());
	}
	
	public static SnomedDescriptionIndexEntry.Builder description(final String id, final String type, final String term) {
		return SnomedDescriptionIndexEntry.builder()
				.id(id)
				.active(true)
				.moduleId(Concepts.MODULE_SCT_CORE)
				.typeId(type)
				.languageCode("en")
				.term(term)
				.caseSignificanceId(Concepts.ONLY_INITIAL_CHARACTER_CASE_INSENSITIVE)
				.released(false);
	}
	
	public static SnomedRefSetMemberIndexEntry.Builder member(final String id, String referencedComponentId, String referencedComponentType, String referenceSetId) {
		return SnomedRefSetMemberIndexEntry.builder()
				.id(id)
				.active(true)
				.referencedComponentId(referencedComponentId)
				.referencedComponentType(referencedComponentType)
				.refsetId(referenceSetId)
				.released(true);
	}
	
	public static SnomedRelationshipIndexEntry.Builder relationship(final String source, final String type, final String destination) {
		return relationship(source, type, destination, Concepts.INFERRED_RELATIONSHIP);
	}
	
	public static SnomedRelationshipIndexEntry.Builder relationship(final String source, final String type, final String destination, String characteristicTypeId) {
		return SnomedRelationshipIndexEntry.builder()
				.id(RandomSnomedIdentiferGenerator.generateRelationshipId())
{'fraction_non_alphanumeric': 0.08951310861423221, 'fraction_numerical': 0.008364544319600499, 'mean_word_length': 5.47092084006462, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '2150454', 'n_tokens_mistral': 2670, 'n_tokens_neox': 2390, 'n_words': 476}