/*
 * Copyright 2011-2016 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.datastore.index;

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

import org.eclipse.emf.cdo.common.id.CDOID;
import org.eclipse.emf.cdo.common.id.CDOIDUtil;

import com.b2international.index.revision.Revision;
import com.b2international.snowowl.core.api.component.IconIdProvider;
import com.b2international.snowowl.core.api.index.IIndexEntry;

/**
 * @since 4.7
 */
public abstract class AbstractRevisionIndexEntry extends Revision implements IIndexEntry, IconIdProvider<String> {

	private final String id;
	private final String label;
	private final float score;
	private final String iconId;
	
	protected AbstractRevisionIndexEntry(final String id, final String label, String iconId, final float score, final long storageKey) {
		this.id = checkNotNull(id, "id");
		this.label = checkNotNull(label, "label");
		this.iconId = iconId;
		this.score = score;
	}
	
	@Override
	public String getLabel() {
		return label;
	}

	@Override
	public String getId() {
		return id;
	}

	@Override
	public String getIconId() {
		return iconId;
	}

	@Override
	public float getScore() {
		return score;
	}

	@Override
	public String toString() {
		return String.format("%02.2f %s - %s [%d]", score, id, label, getStorageKey());
	}

	/**
	 * (non-API)
	 * 
	 * @return returns with the storage key of the current component as a CDO ID.
	 */
	public CDOID cdoID() {
		return CDOIDUtil.createLong(getStorageKey());
	}

}

@@ -1018,16 +1018,68 @@
 exEntry;
+%0Aimport com.fasterxml.jackson.annotation.JsonIgnore;
 %0A%0A/**%0A *
@@ -1210,16 +1210,165 @@
 ing%3E %7B%0A%0A
+%09/**%0A%09 * @since 4.7%0A%09 */%0A%09public static class Fields %7B%0A%09%09public static final String ID = %22id%22;%0A%09%09public static final String ICON_ID = %22iconId%22;%0A%09%7D%0A%09%0A
 %09private
@@ -1740,16 +1740,29 @@
 e;%0A%09%7D%0A%09%0A
+%09@JsonIgnore%0A
 %09@Overri
@@ -1921,24 +1921,38 @@
  iconId;%0A%09%7D%0A
+%09%0A%09@JsonIgnore
 %0A%09@Override%0A

add ignored fields to AbstractRevisionIndexEntry