Package service.advanced

Source Code of service.advanced.SearchService

/**
* Copyright (C) 2010 Talend Inc. - www.talend.com
*/
package service.advanced;

import java.util.List;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Context;

import org.apache.cxf.jaxrs.ext.search.SearchContext;

import common.advanced.Person;
import common.advanced.PersonCollection;
import common.advanced.PersonInfo;

/**
* JAX-RS SearchService root resource
*/
@Path("search")
public class SearchService {

    private PersonInfoStorage storage;

    public SearchService() {
    }

    public void setStorage(PersonInfoStorage storage) {
        this.storage = storage;
    }

    @GET
    @Produces({"application/xml", "application/json"})
    @Path("person")
    public PersonCollection findPersonsWithTypedQuery(@Context SearchContext context) {
     
      List<Person> personList = storage.getTypedQueryPerson(context);
       
      // Execute JPA2 query and return the result
        return new PersonCollection(personList);
    }
   
    @GET
    @Produces({"application/xml", "application/json"})
    @Path("personinfo/{expression}")
    public List<PersonInfo> findPersonsWithTuple(@Context SearchContext context,
                                             @PathParam("expression") String expression) {
     
      return storage.getTypedQueryTuple(context, expression);
    }

}
TOP

Related Classes of service.advanced.SearchService

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.