/*
 * 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.server.events;

import com.b2international.snowowl.core.CoreTerminologyBroker;
import com.b2international.snowowl.core.date.EffectiveTimes;
import com.b2international.snowowl.snomed.core.domain.SnomedReferenceSet;
import com.b2international.snowowl.snomed.datastore.index.refset.SnomedRefSetIndexEntry;
import com.b2international.snowowl.snomed.datastore.server.domain.SnomedReferenceSetImpl;
import com.google.common.base.Function;

/**
 * @since 4.5
 */
class SnomedReferenceSetConverter implements Function<SnomedRefSetIndexEntry, SnomedReferenceSet> {

	@Override
	public SnomedReferenceSet apply(SnomedRefSetIndexEntry entry) {
		final SnomedReferenceSetImpl refset = new SnomedReferenceSetImpl();
		refset.setId(entry.getId());
		refset.setEffectiveTime(EffectiveTimes.toDate(entry.getEffectiveTimeAsLong()));
		refset.setActive(entry.isActive());
		refset.setReleased(entry.isReleased());
		refset.setModuleId(entry.getModuleId());
		refset.setReferencedComponent(CoreTerminologyBroker.getInstance().getComponentInformation(entry.getReferencedComponentType()).getName());
		refset.setType(entry.getType());
		return refset;
	}
}

@@ -813,16 +813,86 @@
 eTimes;%0A
+import com.b2international.snowowl.snomed.core.domain.ISnomedConcept;%0A
 import c
@@ -957,16 +957,16 @@
 nceSet;%0A
-
 import c
@@ -1136,16 +1136,85 @@
 etImpl;%0A
+import com.b2international.snowowl.snomed.snomedrefset.SnomedRefSet;%0A
 import c
@@ -1947,9 +1947,577 @@
 et;%0A
-
 %09%7D%0A
+%09%0A%09public SnomedReferenceSet apply(SnomedRefSet refSet, ISnomedConcept concept) %7B%0A%09%09final SnomedReferenceSetImpl refset = new SnomedReferenceSetImpl();%0A%09%09refset.setId(concept.getId());%0A%09%09refset.setEffectiveTime(concept.getEffectiveTime());%0A%09%09refset.setActive(concept.isActive());%0A%09%09refset.setReleased(concept.isReleased());%0A%09%09refset.setModuleId(concept.getModuleId());%0A%09%09refset.setReferencedComponent(CoreTerminologyBroker.getInstance().getComponentInformation(refSet.getReferencedComponentType()).getName());%0A%09%09refset.setType(refSet.getType());%0A%09%09return refset;%0A%09%7D%0A%09%0A
 %7D%0A

convert new refset and ident. concept to refset representation