package com.console.strategies;

import java.util.List;

import javax.xml.bind.ValidationException;

import com.console.configuration.Request;
import com.console.configuration.Response;
import com.console.dao.FacadeLocal;
import com.console.jpa.Attribute;
import com.console.jpa.ObjectType;

public class SearchStrategy extends Strategy {

	public SearchStrategy(FacadeLocal f) {
		super(f);
	}

	@Override
	public String service(Request request, Response response) {
		String searchType = request.getString("searchType");
		String name = request.getString("name");
		if (searchType == null || name == null || searchType.equals("")|| name.equals("")){
			return "search.jsp";
		}
		request.setAttribute("searchType", searchType);
		request.setAttribute("name", name);
		List<ObjectType> results = facade.searchObjectType(name, searchType);
		request.setAttribute("results", results);
		return "search.jsp";
	}

}
