Source Code‎ > ‎src‎ > ‎in.co.sunrays.proj1‎ > ‎action‎ > ‎

CollegeListAction.java

package in.co.sunrays.proj1.action;
 
import in.co.sunrays.proj1.dto.CollegeDTO;
import in.co.sunrays.proj1.exception.ApplicationException;
import in.co.sunrays.proj1.service.CollegeServiceInt;
 
import org.apache.log4j.Logger;
 
/**
 * College List functionality Action. Performs operation for list, search and
 * delete operations of College
 * 
 * @author SUNRAYS Technologies
 * @version 1.0
 * @Copyright (c) SUNRAYS Technologies
 */
public class CollegeListAction extends BaseListAction {
 
    private static Logger log = Logger.getLogger(CollegeListAction.class);
    private String name;
    private String city;
    private CollegeServiceInt service;
 
    public void setService(CollegeServiceInt service) {
        this.service = service;
    }
 
    public String getName() {
        return name;
    }
 
    public void setName(String name) {
        this.name = name;
    }
 
    public String getCity() {
        return city;
    }
 
    public void setCity(String city) {
        this.city = city;
    }
 
    /**
     * Performs display operations for CollegeListAction
     * 
     * @return type String
     * @return INPUT
     */
    public String input() {
        log.debug("CollegeListAction.input() Start");
        try {
            dtoList = service.list(pageNo, pageSize);
        } catch (ApplicationException e) {
            log.error("Critical Issue ", e);
            return OP_ERROR;
        }
        log.debug("CollegeListAction.input() End");
        return INPUT;
    }
 
    /**
     * Performs submit operations for CollegeListAction
     * 
     * @return type String
     * @return SUCCESS
     */
    @Override
    public String execute() {
        log.debug("CollegeListAction.execute() Start");
        /**
         * Set search parameters
         */
        CollegeDTO searchDTO = new CollegeDTO();
        searchDTO.setName(name);
        searchDTO.setCity(city);
        try {
            if (OP_DELETE.equalsIgnoreCase(operation) && ids != null) {
                CollegeDTO deleteDTO = new CollegeDTO();
                for (int i = 0; i < ids.length; i++) {
                    deleteDTO.setId(ids[i]);
                    service.delete(deleteDTO);
                    pageNo = 1;
                }
            } else if (OP_NEXT.equalsIgnoreCase(operation)) {
                pageNo++;
            } else if (OP_PREVIOUS.equalsIgnoreCase(operation) && pageNo > 1) {
                pageNo--;
            }
            dtoList = service.search(searchDTO, pageNo, pageSize);
            if (dtoList.size() == 0) {
                pageNo--;
                addActionError("No Record Found");
            }
        } catch (ApplicationException e) {
            log.error("Critical Issue ", e);
            return OP_ERROR;
        }
        log.debug("CollegeListAction.execute() End " + operation);
        return INPUT;
    }
 
}
Comments