001/*
002 * Copyright 2011 The Kuali Foundation.
003 *
004 * Licensed under the Educational Community License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.opensource.org/licenses/ecl2.php
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016package org.kuali.ole.select.service.impl;
017
018import org.apache.commons.lang.StringEscapeUtils;
019import org.kuali.ole.select.businessobject.BibInfoBean;
020import org.kuali.ole.select.service.PopulateBibInfoService;
021import org.kuali.ole.select.testing.PreOrderService;
022import org.kuali.ole.select.testing.WSException_Exception;
023
024public class PreOrderServiceImpl implements PreOrderService {
025
026    private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(PreOrderServiceImpl.class);
027    private PopulateBibInfoService populateBibInfoService;
028    private BibInfoBean bibInfoBean;
029
030    @Override
031    /*
032     * public String createPreOrderForCitation(String citationString, String routeRequesterReceipt, String requestorsNote, String
033     * requestorsFirstName, String requestorsLastName, String requestorsAddress1, String requestorsAddress2, String requestorsCity,
034     * String requestorsState, String requestorsZipCode, String requestorsCountryCode, String requestorsPhone, String
035     * requestorsEmail, String requestorsSMS, String requestorType) throws WSException_Exception {
036     */
037    public String createPreOrderForCitation(String citationString, String routeRequesterReceipt, String requestorsNote,
038                                            String requestorType, String requestorId) throws WSException_Exception {
039        String docNumber = null;
040        try {
041            PopulateBibInfoService populateBibInfoService = getPopulateBibInfoService();
042
043            BibInfoBean bibInfoBean = getBibInfoBean();
044            /*
045             * setRequestorDetail(requestorsNote, requestorsFirstName, requestorsLastName, requestorsAddress1, requestorsAddress2,
046             * requestorsCity, requestorsState, requestorsZipCode, requestorsCountryCode, requestorsPhone, requestorsEmail,
047             * requestorsSMS, requestorType);
048             */
049            setRequestorDetail(requestorsNote, requestorType, requestorId);
050            docNumber = populateBibInfoService.processBibInfoForCitation(citationString, bibInfoBean);
051        } catch (Exception E) {
052
053        }
054        return docNumber;
055    }
056
057    private BibInfoBean getBibInfoBean() {
058        bibInfoBean = new BibInfoBean();
059        return bibInfoBean;
060    }
061
062    private PopulateBibInfoService getPopulateBibInfoService() {
063        if (null == populateBibInfoService) {
064            populateBibInfoService = new PopulateBibInfoServiceImpl();
065        }
066        return populateBibInfoService;
067    }
068
069    public void setPopulateBibInfoService(PopulateBibInfoService populateBibInfoService) {
070        this.populateBibInfoService = populateBibInfoService;
071    }
072
073    @Override
074    /*
075     * public String createPreOrderForOpenURL(String openUrlString,String routeRequestorReceipt, String requestorsNote,String
076     * requestorsFirstName, String requestorsLastName, String requestorsAddress1, String requestorsAddress2, String requestorsCity,
077     * String requestorsState, String requestorsZipCode, String requestorsCountryCode, String requestorsPhone, String
078     * requestorsEmail, String requestorsSMS, String requestorType) throws WSException_Exception {
079     */
080    public String createPreOrderForOpenURL(String openUrlString, String routeRequestorReceipt, String requestorsNote,
081                                           String requestorType, String requestorId) throws WSException_Exception {
082        PopulateBibInfoService populateBibInfoService = new PopulateBibInfoServiceImpl();
083        BibInfoBean bibInfoBean = getBibInfoBean();
084        /*
085         * setRequestorDetail(requestorsNote,requestorsFirstName, requestorsLastName, requestorsAddress1, requestorsAddress2,
086         * requestorsCity, requestorsState, requestorsZipCode, requestorsCountryCode, requestorsPhone, requestorsEmail,
087         * requestorsSMS, requestorType);
088         */
089        setRequestorDetail(requestorsNote, requestorType, requestorId);
090        String docNumber = null;
091        try {
092            docNumber = populateBibInfoService.processBibInfoForOperURL(openUrlString, bibInfoBean);
093        } catch (Exception E) {
094
095        }
096        return docNumber;
097    }
098
099    @Override
100    /*
101     * public String createPreOrderForForm(String title, String author, String edition, String series, String publisher, String
102     * placeOfPublication, String yearOfPublication, String standardNumber, String typeOfStandardNumber, String
103     * routeRequestorReceipt, String requestorsNote, String requestorsFirstName, String requestorsLastName, String
104     * requestorsAddress1, String requestorsAddress2, String requestorsCity, String requestorsState, String requestorsZipCode,
105     * String requestorsCountryCode, String requestorsPhone, String requestorsEmail, String requestorsSMS, String requestorType)
106     * throws WSException_Exception {
107     */
108    public String createPreOrderForForm(String title, String author, String edition, String series, String publisher,
109                                        String placeOfPublication, String yearOfPublication, String standardNumber, String typeOfStandardNumber,
110                                        String requestorsNote, String requestorType, String requestorId) throws WSException_Exception {
111        PopulateBibInfoService populateBibInfoService = getPopulateBibInfoService();
112        BibInfoBean bibInfoBean = getBibInfoBean();
113        StringEscapeUtils stringEscapeUtils = new StringEscapeUtils();
114        title = stringEscapeUtils.escapeHtml(title);
115        author = stringEscapeUtils.escapeHtml(author);
116        edition = stringEscapeUtils.escapeHtml(edition);
117        publisher = stringEscapeUtils.escapeHtml(publisher);
118        placeOfPublication = stringEscapeUtils.escapeHtml(placeOfPublication);
119        requestorId = stringEscapeUtils.escapeHtml(requestorId);
120        /*
121         * setRequestorDetail(requestorsNote, requestorsFirstName, requestorsLastName, requestorsAddress1, requestorsAddress2,
122         * requestorsCity, requestorsState, requestorsZipCode, requestorsCountryCode, requestorsPhone, requestorsEmail,
123         * requestorsSMS, requestorType);
124         */
125        setRequestorDetail(requestorsNote, requestorType, requestorId);
126        String docNumber = null;
127        try {
128            /*
129             * docNumber = populateBibInfoService.processBibInfoForForm(bibInfoBean, title, author, edition, series, publisher,
130             * placeOfPublication, yearOfPublication, standardNumber, typeOfStandardNumber, routeRequestorReceipt);
131             */
132            docNumber = populateBibInfoService
133                    .processBibInfoForForm(bibInfoBean, title, author, edition, series, publisher, placeOfPublication,
134                            yearOfPublication, standardNumber, typeOfStandardNumber, requestorId);
135
136            LOG.info("docNumber in createPreOrderForForm>>>>>>>>>>>>>>" + docNumber);
137        } catch (Exception E) {
138
139        }
140        return docNumber;
141    }
142
143    /*@Override
144    public String createPreOrderForForm(String input) throws Exception {
145        String[] inputArr = input.split("||");
146        for (int i = 0; i < inputArr.length; i++) {
147
148        }
149
150        PopulateBibInfoService populateBibInfoService = getPopulateBibInfoService();
151        BibInfoBean bibInfoBean = getBibInfoBean();
152        StringEscapeUtils stringEscapeUtils=new StringEscapeUtils();
153        String title = stringEscapeUtils.escapeHtml(inputArr[0]);
154        String author = stringEscapeUtils.escapeHtml(inputArr[1]);
155        String edition = stringEscapeUtils.escapeHtml(inputArr[2]);
156        String publisher = stringEscapeUtils.escapeHtml(inputArr[4]);
157        String placeOfPublication = stringEscapeUtils.escapeHtml(inputArr[5]);
158        setRequestorDetail(inputArr[10], inputArr[11],
159                inputArr[12], inputArr[13], inputArr[14], inputArr[15], inputArr[16],
160                inputArr[17], inputArr[18], inputArr[19], inputArr[20],
161                inputArr[21], inputArr[22]);
162        String docNumber = populateBibInfoService.processBibInfoForForm(bibInfoBean,
163                title, author, edition, inputArr[3], publisher, placeOfPublication,
164                inputArr[6], inputArr[7], inputArr[8],
165                inputArr[9]);
166        return docNumber;
167    }*/
168
169    /*
170     * private void setRequestorDetail(String requestorsNote, String requestorsFirstName, String requestorsLastName, String
171     * requestorsAddress1, String requestorsAddress2, String requestorsCity, String requestorsState, String requestorsZipCode,
172     * String requestorsCountryCode, String requestorsPhone, String requestorsEmail, String requestorsSMS, String requestorType)
173     * throws WSException_Exception { bibInfoBean.setRequestersNotes(requestorsNote);
174     * bibInfoBean.setRequestorsFirstName(requestorsFirstName); bibInfoBean.setRequestorsLastName(requestorsLastName);
175     * bibInfoBean.setRequestorsAddress1(requestorsAddress1); bibInfoBean.setRequestorsAddress2(requestorsAddress2);
176     * bibInfoBean.setRequestorsCity(requestorsCity); bibInfoBean.setRequestorsState(requestorsState);
177     * bibInfoBean.setRequestorsZipCode(requestorsZipCode); bibInfoBean.setRequestorsCountryCode(requestorsCountryCode);
178     * bibInfoBean.setRequestorsPhone(requestorsPhone); bibInfoBean.setRequestorsEmail(requestorsEmail);
179     * bibInfoBean.setRequestorsSMS(requestorsSMS); bibInfoBean.setRequestorType(requestorType); }
180     */
181    private void setRequestorDetail(String requestorsNote, String requestorType, String requestorId)
182            throws WSException_Exception {
183        bibInfoBean.setRequestersNotes(requestorsNote);
184        bibInfoBean.setRequestorType(requestorType);
185        bibInfoBean.setRequestorId(requestorId);
186    }
187
188}