[DS-3952] Move request deletion from test to main.

This commit is contained in:
Mark H. Wood
2018-11-08 08:55:24 -05:00
committed by Mark H. Wood
parent 6fa5bf6548
commit 09b066ca91
6 changed files with 34 additions and 13 deletions

View File

@@ -21,7 +21,7 @@ import org.springframework.beans.factory.annotation.Autowired;
/**
* Service implementation for the RequestItem object.
* This class is responsible for all business logic calls for the RequestItem object and is autowired by spring.
* This class is responsible for all business logic calls for the RequestItem object and is autowired by Spring.
* This class should never be accessed directly.
*
* @author kevinvandevelde at atmire.com
@@ -78,4 +78,13 @@ public class RequestItemServiceImpl implements RequestItemService {
log.error(e.getMessage());
}
}
@Override
public void delete(Context context, RequestItem requestItem) {
try {
requestItemDAO.delete(context, requestItem);
} catch (SQLException e) {
log.error(e.getMessage());
}
}
}

View File

@@ -15,13 +15,21 @@ import org.dspace.core.GenericDAO;
/**
* Database Access Object interface class for the RequestItem object.
* The implementation of this class is responsible for all database calls for the RequestItem object and is autowired
* by spring
* This class should only be accessed from a single service and should never be exposed outside of the API
* The implementation of this class is responsible for all database calls for
* the RequestItem object and is autowired by Spring.
* This class should only be accessed from a single service and should never be
* exposed outside of the API.
*
* @author kevinvandevelde at atmire.com
*/
public interface RequestItemDAO extends GenericDAO<RequestItem> {
/**
* Fetch a request named by its unique token (passed in emails).
*
* @param context the current DSpace context.
* @param token uniquely identifies the request.
* @return the found request (or {@code null}?)
* @throws SQLException passed through.
*/
public RequestItem findByToken(Context context, String token) throws SQLException;
}

View File

@@ -20,7 +20,7 @@ import org.dspace.core.Context;
/**
* Hibernate implementation of the Database Access Object interface class for the RequestItem object.
* This class is responsible for all database calls for the RequestItem object and is autowired by spring
* This class is responsible for all database calls for the RequestItem object and is autowired by Spring.
* This class should never be accessed directly.
*
* @author kevinvandevelde at atmire.com
@@ -39,6 +39,4 @@ public class RequestItemDAOImpl extends AbstractHibernateDAO<RequestItem> implem
criteriaQuery.where(criteriaBuilder.equal(requestItemRoot.get(RequestItem_.token), token));
return uniqueResult(context, criteriaQuery, false, RequestItem.class, -1, -1);
}
}

View File

@@ -16,8 +16,8 @@ import org.dspace.core.Context;
/**
* Service interface class for the RequestItem object.
* The implementation of this class is responsible for all business logic calls for the RequestItem object and is
* autowired by spring
* The implementation of this class is responsible for all business logic calls
* for the RequestItem object and is autowired by Spring.
*
* @author kevinvandevelde at atmire.com
*/
@@ -51,5 +51,11 @@ public interface RequestItemService {
*/
public void update(Context context, RequestItem requestItem);
/**
* Remove the record from the database.
*
* @param context current DSpace context.
* @param request record to be removed.
*/
public void delete(Context context, RequestItem request);
}

View File

@@ -79,7 +79,7 @@ public class RequestItemBuilder
@Override
public void delete(Context context, RequestItem request)
throws Exception {
new RequestItemHelperDAO().delete(context, request.getToken());
requestItemService.delete(context, request);
}
@Override

View File

@@ -6,7 +6,7 @@
* http://www.dspace.org/license/
*/
package org.dspace.app.rest.builder;
package org.dspace.builder;
import java.sql.SQLException;
import javax.persistence.Query;