001package org.kuali.ole.deliver.inquiry;
002
003import org.kuali.ole.OLEConstants;
004import org.kuali.ole.deliver.bo.OlePatronIngestSummaryRecord;
005import org.kuali.rice.kns.inquiry.KualiInquirableImpl;
006
007import java.util.Map;
008
009/**
010 * OlePatronSummaryInquirable provides URL to download the failed patron attachment and filename.
011 */
012public class OlePatronSummaryInquirable extends KualiInquirableImpl {
013    public Object object;
014
015    /**
016     * This method will retrieve the data object using the parameters
017     *
018     * @param parameters
019     * @return object
020     */
021    @Override
022    public Object retrieveDataObject(Map parameters) {
023        object = super.retrieveDataObject(parameters);
024        return object;
025    }
026
027    /**
028     * This method will create the url by appending the olePatronSummaryId to call the download method in the controller
029     *
030     * @return url
031     */
032    public String getUrl() {
033        OlePatronIngestSummaryRecord olePatronIngestSummaryRecord = (OlePatronIngestSummaryRecord) object;
034        String url = OLEConstants.FAILED_PATRON_ATTACHMENT_DOWNLOAD_URL + olePatronIngestSummaryRecord.getOlePatronSummaryId();
035        return url;
036    }
037
038    /**
039     * This will return the file name of the error xml otherwise it will return null
040     *
041     * @return fileName
042     */
043    public String getFileName() {
044        OlePatronIngestSummaryRecord olePatronIngestSummaryRecord = (OlePatronIngestSummaryRecord) object;
045        if (olePatronIngestSummaryRecord.getPatronFailedCount() != null && olePatronIngestSummaryRecord.getPatronFailedCount() > 0)
046            return olePatronIngestSummaryRecord.getOlePatronSummaryId() + OLEConstants.FAILED_PATRON_RECORD_NAME;
047        else
048            return null;
049    }
050}