package com.tandbergtv.metadatamanager.search;

import com.tandbergtv.watchpoint.search.Entity;
import com.tandbergtv.workflow.driver.search.SearchOperator;
import com.tandbergtv.workflow.driver.search.SearchType;
import com.tandbergtv.workflow.driver.search.ValueParameter;

/**
 * Class that represents the search info for an asset property. 
 * 
 * @author spuranik
 *
 */
public class PropertyValueFieldInfo extends FieldInfo {

	// name of the property for which the criterion will be added
	private String name;
	// value of the property used for matching
	private String value;
	// operator that will be applied to the property when searching
	SearchOperator operator;

	public PropertyValueFieldInfo(String property, String value,
			SearchOperator operator) {
		this.name = property;
		this.value = value;
		this.operator = operator;
	}

	@Override
	public void createEntity(String property, Entity assetEntity) {
		Entity field = new Entity("field", property, "f");

		/* TODO: currently search type is fixed to string. Instead get it from name. */
		field.addParameter(new ValueParameter(name, SearchType.STRING,
				value, operator));		

		assetEntity.addParameter(field);
	}

	/**
	 * @return the property
	 */
	public String getProperty() {
		return name;
	}

	/**
	 * @param property
	 *            the property to set
	 */
	public void setName(String name) {
		this.name = name;
	}

	/**
	 * @return the value
	 */
	public String getValue() {
		return value;
	}

	/**
	 * @param value
	 *            the value to set
	 */
	public void setValue(String value) {
		this.value = value;
	}

}
