/*
 * Copyright 2011-2015 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.snomed.datastore.request;

import com.b2international.snowowl.datastore.request.SearchRequest;
import com.b2international.snowowl.snomed.core.domain.SnomedConcepts;

/**
 * @since 4.5
 */
public final class SnomedConceptSearchRequestBuilder extends SnomedSearchRequestBuilder<SnomedConceptSearchRequestBuilder, SnomedConcepts> {

	SnomedConceptSearchRequestBuilder(String repositoryId) {
		super(repositoryId);
	}

	public final SnomedConceptSearchRequestBuilder withDoi() {
		return addOption(SnomedConceptSearchRequest.OptionKey.USE_DOI, true);
	}

	public final SnomedConceptSearchRequestBuilder filterByTerm(String term) {
		return addOption(SnomedConceptSearchRequest.OptionKey.TERM, term);
	}

	public final SnomedConceptSearchRequestBuilder filterByEscg(String expression) {
		return addOption(SnomedConceptSearchRequest.OptionKey.ESCG, expression);
	}

	/**
	 * Filter matches to have the specified parent a direct super type.
	 * 
	 * @param parentId
	 * @return
	 */
	public final SnomedConceptSearchRequestBuilder filterByParent(String parentId) {
		return addOption(SnomedConceptSearchRequest.OptionKey.PARENT, parentId);
	}

	/**
	 * Filter matches to have the specified ancestor identifier in their super type hierarchy (including direct parents).
	 * 
	 * @param ancestorId
	 * @return
	 */
	public final SnomedConceptSearchRequestBuilder filterByAncestor(String ancestorId) {
		return addOption(SnomedConceptSearchRequest.OptionKey.ANCESTOR, ancestorId);
	}

	@Override
	protected SearchRequest<SnomedConcepts> create() {
		return new SnomedConceptSearchRequest();
	}
}

@@ -1575,16 +1575,46 @@
 ent 
-a direct
+identifier amongst the direct inferred
  sup
@@ -1620,16 +1620,17 @@
 per type
+s
 .%0A%09 * %0A%09
@@ -1821,24 +1821,25 @@
 rentId);%0A%09%7D%0A
+%09
 %0A%09/**%0A%09 * Fi
@@ -1877,83 +1877,744 @@
 ied 
-ancestor identifier in their super type hierarchy (including direct parents
+parent identifier amongst the direct stated super types.%0A%09 * %0A%09 * @param parentId%0A%09 * @return%0A%09 */%0A%09public final SnomedConceptSearchRequestBuilder filterByStatedParent(String parentId) %7B%0A%09%09return addOption(SnomedConceptSearchRequest.OptionKey.STATED_PARENT, parentId);%0A%09%7D%0A%0A%09/**%0A%09 * Filter matches to have the specified ancestor identifier amongst the inferred super types (including direct as well).%0A%09 * %0A%09 * @param ancestorId%0A%09 * @return%0A%09 */%0A%09public final SnomedConceptSearchRequestBuilder filterByAncestor(String ancestorId) %7B%0A%09%09return addOption(SnomedConceptSearchRequest.OptionKey.ANCESTOR, ancestorId);%0A%09%7D%0A%09%0A%09/**%0A%09 * Filter matches to have the specified ancestor identifier amongst the stated super types (including direct as well
 ).%0A%09
@@ -2704,32 +2704,38 @@
 Builder filterBy
+Stated
 Ancestor(String 
@@ -2796,32 +2796,39 @@
 quest.OptionKey.
+STATED_
 ANCESTOR, ancest

support for stated parent/ancestor based filtering...