package com.hida.service;

import org.apache.log4j.Logger;
import com.hida.controller.ResolverController;
import com.hida.model.Citation;
import com.hida.repositories.CitationRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * ResolverServiceImpl
 *
 * holds functions that allow communication, and communicate with database
 * methods 1.ResolverServiceImpl - sets up conn, specify, serverURL, username,
 * password of database 2.Openconnection 3.closeConnection 4.retrieveUrl -
 * retrieve url requested 5.insertCitation - insert purl, along with its url,
 * who, what, when, erc 6.editUrl - edits url of a specified purl
 *
 * @author lruffin
 * @author: leland lopez
 */
@Service("resolverService")
@Transactional
public class ResolverServiceImpl implements ResolverService {
   

    @Autowired
    private CitationRepository CitationRepo;

    final static Logger logger = Logger.getLogger(ResolverController.class);

    /**
     * retrieves url of provided purlid returns url string if successfull, null
     * if not
     *
     * @param purl purlid of desired row
     * @return String
     */
    @Override
    public String retrieveUrl(String purl) {
        Citation entity = CitationRepo.findOne(purl);
        String url = entity.getUrl();

        return url;
    }

    /**
     * inserts PURL into database returns true if successful, false if not
     *
     * @param citation Citation to insert into database
     */
    @Override
    public void insertCitation(Citation citation) {
        CitationRepo.save(citation);
    }

    /**
     * edits url of db row with corresponding purlid. returns true if
     * successful, false if not
     *
     * @param purl purlid of desired edited row
     * @param url url that desired row url will be changed to
     */
    @Override
    public void editUrl(String purl, String url) {
        Citation entity = CitationRepo.findOne(purl);
        entity.setUrl(url);
    }

    /**
     * deletes db row with corresponding purlid returns true if successful,
     * false if not
     *
     * @param purl purlid of desired deleted row
     */
    @Override
    public void deleteCitation(String purl) {
        Citation entity = CitationRepo.findOne(purl);
        CitationRepo.delete(entity);
    }

    /**
     * retrieves model of purl_id object returns the respective purl db row.
     *
     * @param purl purlid of desired row that will become Citation
     * @return Citation
     */
    @Override
    public Citation retrieveCitation(String purl) {
        Citation entity = CitationRepo.findOne(purl);

        return entity;
    }
}

@@ -56,55 +56,8 @@
 er;%0A
-import com.hida.controller.ResolverController;%0A
 impo
@@ -320,403 +320,145 @@
 %0A * 
-ResolverServiceImpl%0A *%0A * holds functions that allow communication, and communicate with database%0A * methods 1.ResolverServiceImpl - sets up conn, specify, serverURL, username,
+Allows the performance of CRUD operations on citation objects by by serving
 %0A * 
-p
 as
-sword of database 2.Openconnection 3.closeConnection 4.retrieveUrl -%0A * retrieve url requested 5.insertCitation - insert purl, along with its url,%0A * who, what, when, erc 6.editUrl - edits url of a specified purl
+ a middle ground between the database and the controller
 %0A *%0A
@@ -609,20 +609,16 @@
 ervice %7B
-%0A   
 %0A%0A    @A
@@ -734,18 +734,19 @@
 lver
-Controller
+ServiceImpl
 .cla
@@ -758,33 +758,33 @@
 %0A    /**%0A     * 
-r
+R
 etrieves url of 
@@ -802,62 +802,8 @@
 rlid
- returns url string if successfull, null%0A     * if not
 %0A   
@@ -1071,17 +1071,17 @@
 %0A     * 
-i
+I
 nserts P
@@ -1101,49 +1101,8 @@
 base
- returns true if successful, false if not
 %0A   
@@ -1294,17 +1294,17 @@
 %0A     * 
-e
+E
 dits url
@@ -1343,57 +1343,8 @@
 rlid
-. returns true if%0A     * successful, false if not
 %0A   
@@ -1634,17 +1634,17 @@
 %0A     * 
-d
+D
 eletes d
@@ -1678,56 +1678,8 @@
 rlid
- returns true if successful,%0A     * false if not
 %0A   
@@ -1912,17 +1912,17 @@
 %0A     * 
-r
+R
 etrieves
@@ -1926,67 +1926,51 @@
 ves 
-model of purl_id object returns the respective purl db row.
+citation corresponding to a particular purl
 %0A   

Clean ResolverServiceImpl