4747import org .dspace .services .ConfigurationService ;
4848import org .dspace .util .ItemUtils ;
4949import org .springframework .beans .factory .annotation .Autowired ;
50+ import org .springframework .stereotype .Service ;
5051
5152/**
5253 * Utility class used to search for duplicates inside the dedup solr core.
5354 *
5455 */
55- public class DedupUtils {
56+
57+ @ Service
58+ public class DedupUtils implements IDedupUtils {
5659
5760 private static Logger log = LogManager .getLogger (DedupUtils .class );
5861
@@ -64,11 +67,14 @@ public class DedupUtils {
6467 @ Autowired (required = true )
6568 protected ConfigurationService configurationService ;
6669
67- public DuplicateInfoList findSignatureWithDuplicate (Context context , String signatureType , int resourceType ,
68- int limit , int offset , int rule ) throws SearchServiceException , SQLException {
70+ @ Override
71+ public Collection <DuplicateInfo > findSignatureWithDuplicate (Context context , String signatureType , int resourceType ,
72+ int limit , int offset , int rule )
73+ throws SearchServiceException , SQLException {
6974 return findPotentialMatch (context , signatureType , resourceType , limit , offset , rule );
7075 }
7176
77+ @ Override
7278 public Map <String , Integer > countSignaturesWithDuplicates (String query , int resourceTypeId )
7379 throws SearchServiceException {
7480 Map <String , Integer > results = new HashMap <String , Integer >();
@@ -113,6 +119,7 @@ public Map<String, Integer> countSignaturesWithDuplicates(String query, int reso
113119 return results ;
114120 }
115121
122+ @ Override
116123 public Map <String , Integer > countSuggestedDuplicate (String query , int resourceTypeId )
117124 throws SearchServiceException {
118125 Map <String , Integer > results = new HashMap <String , Integer >();
@@ -241,8 +248,9 @@ private boolean hasStoredDecision(UUID firstItemID, UUID secondItemID, Duplicate
241248 return !response .getResults ().isEmpty ();
242249 }
243250
251+ @ Override
244252 public boolean matchExist (Context context , UUID itemID , UUID targetItemID , Integer resourceType ,
245- String signatureType , Boolean isInWorkflow ) throws SQLException , SearchServiceException {
253+ String signatureType , Boolean isInWorkflow ) throws SQLException , SearchServiceException {
246254 boolean exist = false ;
247255 List <DuplicateItemInfo > potentialDuplicates = findDuplicate (context , itemID , resourceType , null , isInWorkflow );
248256 for (DuplicateItemInfo match : potentialDuplicates ) {
@@ -256,6 +264,7 @@ public boolean matchExist(Context context, UUID itemID, UUID targetItemID, Integ
256264
257265 }
258266
267+ @ Override
259268 public boolean rejectAdminDups (Context context , UUID firstId , UUID secondId , Integer type )
260269 throws SQLException , AuthorizeException {
261270 if (firstId == secondId ) {
@@ -309,6 +318,7 @@ public boolean rejectAdminDups(Context context, UUID firstId, UUID secondId, Int
309318 * @throws AuthorizeException
310319 * @throws SearchServiceException
311320 */
321+ @ Override
312322 public boolean rejectAdminDups (Context context , UUID itemID , String signatureType , int resourceType )
313323 throws SQLException , AuthorizeException , SearchServiceException {
314324
@@ -336,15 +346,17 @@ public boolean rejectAdminDups(Context context, UUID itemID, String signatureTyp
336346
337347 }
338348
349+ @ Override
339350 public void rejectAdminDups (Context context , List <DSpaceObject > items , String signatureID )
340351 throws SQLException , AuthorizeException , SearchServiceException {
341352 for (DSpaceObject item : items ) {
342353 rejectAdminDups (context , item .getID (), signatureID , item .getType ());
343354 }
344355 }
345356
357+ @ Override
346358 public void verify (Context context , int dedupId , UUID firstId , UUID secondId , int type , boolean toFix , String note ,
347- boolean check ) throws SQLException , AuthorizeException {
359+ boolean check ) throws SQLException , AuthorizeException {
348360 UUID [] sortedIds = new UUID [] { firstId , secondId };
349361 Arrays .sort (sortedIds );
350362 firstId = sortedIds [0 ];
@@ -417,8 +429,9 @@ private Deduplication retrieveDuplicationRow(Context context, UUID firstId, UUID
417429 return row ;
418430 }
419431
432+ @ Override
420433 public void setDuplicateDecision (Context context , UUID firstId , UUID secondId , Integer type ,
421- DuplicateDecisionObjectRest decisionObject )
434+ DuplicateDecisionObjectRest decisionObject )
422435 throws AuthorizeException , SQLException , SearchServiceException {
423436
424437 if (hasAuthorization (context , firstId , secondId )) {
@@ -478,6 +491,7 @@ public void setDuplicateDecision(Context context, UUID firstId, UUID secondId, I
478491 }
479492 }
480493
494+ @ Override
481495 public boolean validateDecision (DuplicateDecisionObjectRest decisionObject ) {
482496 boolean valid = false ;
483497
@@ -500,8 +514,9 @@ public boolean validateDecision(DuplicateDecisionObjectRest decisionObject) {
500514 return valid ;
501515 }
502516
517+ @ Override
503518 public boolean rejectDups (Context context , UUID firstId , UUID secondId , Integer type , boolean notDupl , String note ,
504- boolean check ) throws SQLException {
519+ boolean check ) throws SQLException {
505520 UUID [] sortedIds = new UUID [] { firstId , secondId };
506521 Arrays .sort (sortedIds );
507522 Deduplication row = null ;
@@ -547,11 +562,9 @@ public boolean rejectDups(Context context, UUID firstId, UUID secondId, Integer
547562 return false ;
548563 }
549564
550- private DuplicateInfoList findPotentialMatch (Context context , String signatureType , int resourceType , int start ,
565+ private List < DuplicateInfo > findPotentialMatch (Context context , String signatureType , int resourceType , int start ,
551566 int rows , int rule ) throws SearchServiceException , SQLException {
552567
553- DuplicateInfoList dil = new DuplicateInfoList ();
554-
555568 if (StringUtils .isNotEmpty (signatureType )) {
556569 if (!StringUtils .contains (signatureType , "_signature" )) {
557570 signatureType += "_signature" ;
@@ -594,7 +607,7 @@ private DuplicateInfoList findPotentialMatch(Context context, String signatureTy
594607
595608 FacetField facetField = responseFacet .getFacetField (signatureType );
596609
597- List <DuplicateInfo > result = new ArrayList <DuplicateInfo >();
610+ List <DuplicateInfo > result = new ArrayList <>();
598611
599612 int index = 0 ;
600613 for (Count facetHit : facetField .getValues ()) {
@@ -653,10 +666,7 @@ private DuplicateInfoList findPotentialMatch(Context context, String signatureTy
653666 }
654667 index ++;
655668 }
656-
657- dil .setDsi (result );
658- dil .setSize (facetField .getValues ().size ());
659- return dil ;
669+ return result ;
660670 }
661671
662672 private DuplicateSignatureInfo findPotentialMatchByID (Context context , String signatureType , int resourceType ,
@@ -699,38 +709,45 @@ private DuplicateSignatureInfo findPotentialMatchByID(Context context, String si
699709 return dsi ;
700710 }
701711
712+ @ Override
702713 public DedupService getDedupService () {
703714 return dedupService ;
704715 }
705716
717+ @ Override
706718 public void setDedupService (DedupService dedupService ) {
707719 this .dedupService = dedupService ;
708720 }
709721
722+ @ Override
710723 public void commit () {
711724 dedupService .commit ();
712725 }
713726
727+ @ Override
714728 public List <DuplicateItemInfo > getDuplicateByIDandType (Context context , UUID itemID , int typeID ,
715- boolean isInWorkflow ) throws SQLException , SearchServiceException {
729+ boolean isInWorkflow )
730+ throws SQLException , SearchServiceException {
716731 return getDuplicateByIdAndTypeAndSignatureType (context , itemID , typeID , null , isInWorkflow );
717732 }
718733
734+ @ Override
719735 public List <DuplicateItemInfo > getDuplicateByIdAndTypeAndSignatureType (Context context , UUID itemID , int typeID ,
720- String signatureType , boolean isInWorkflow ) throws SQLException , SearchServiceException {
736+ String signatureType , boolean isInWorkflow )
737+ throws SQLException , SearchServiceException {
721738 return findDuplicate (context , itemID , typeID , signatureType , isInWorkflow );
722739 }
723740
741+ @ Override
724742 public List <DuplicateItemInfo > getAdminDuplicateByIdAndType (Context context , UUID itemID , int typeID )
725743 throws SQLException , SearchServiceException {
726744 return findDuplicate (context , itemID , typeID , null , null );
727745 }
728746
729- public DuplicateInfoList findSuggestedDuplicate (Context context , int resourceType , int start , int rows )
747+ @ Override
748+ public List <DuplicateInfo > findSuggestedDuplicate (Context context , int resourceType , int start , int rows )
730749 throws SearchServiceException , SQLException {
731750
732- DuplicateInfoList dil = new DuplicateInfoList ();
733-
734751 SolrQuery solrQueryInternal = new SolrQuery ();
735752
736753 solrQueryInternal .setQuery (SolrDedupServiceImpl .SUBQUERY_NOT_IN_REJECTED );
@@ -774,8 +791,6 @@ public DuplicateInfoList findSuggestedDuplicate(Context context, int resourceTyp
774791 index ++;
775792 }
776793
777- dil .setDsi (result );
778- dil .setSize (solrDocumentList .getNumFound ());
779- return dil ;
794+ return result ;
780795 }
781796}
0 commit comments