Skip to content

Commit

Permalink
Merge branch 'kitodo:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
danilopenagos authored Dec 14, 2022
2 parents 1a2fe2f + cdf3ef0 commit 4614561
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -129,12 +129,7 @@ public void search() {
}

private boolean skipHitList(ImportConfiguration importConfiguration, String searchField) {
if (SearchInterfaceType.OAI.name().equals(importConfiguration.getInterfaceType())
|| searchField.equals(importConfiguration.getIdSearchField().getLabel())) {
return true;
}
return (Objects.isNull(importConfiguration.getMetadataRecordIdXPath())
|| Objects.isNull(importConfiguration.getMetadataRecordTitleXPath()));
return ImportService.skipHitlist(importConfiguration, searchField);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,25 @@ public static String getDefaultSearchField(ImportConfiguration importConfigurati
return "";
}

/**
* Check and return whether to skip hit list for given ImportConfiguration and search field or not.
* Hit list is skipped either if SearchInterfaceType of given ImportConfiguration does not support
* hit lists (e.g. OAI and FTP interfaces) or if the provides search field equals the ID search field
* of the given ImportConfiguration.
* @param configuration ImportConfiguration to check
* @param field value of SearchField to check
* @return whether to skip hit list or not
*/
public static boolean skipHitlist(ImportConfiguration configuration, String field) {
if (SearchInterfaceType.OAI.name().equals(configuration.getInterfaceType())
|| SearchInterfaceType.FTP.name().equals(configuration.getInterfaceType())
|| field.equals(configuration.getIdSearchField().getLabel())) {
return true;
}
return (Objects.isNull(configuration.getMetadataRecordIdXPath())
|| Objects.isNull(configuration.getMetadataRecordTitleXPath()));
}

/**
* Get default import depth for given import configuration.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* (c) Kitodo. Key to digital objects e. V. <[email protected]>
*
* This file is part of the Kitodo project.
*
* It is licensed under GNU General Public License version 3 or later.
*
* For the full copyright and license information, please read the
* GPL3-License.txt file that was distributed with this source code.
*/

package org.kitodo.production.services.catalogimport;

import org.junit.Assert;
import org.junit.Test;
import org.kitodo.api.externaldatamanagement.ImportConfigurationType;
import org.kitodo.api.externaldatamanagement.SearchInterfaceType;
import org.kitodo.data.database.beans.ImportConfiguration;
import org.kitodo.production.services.data.ImportService;

public class ImportServiceTest {

/**
* Test whether hit list is properly skipped for FTP type import configurations.
*/
@Test
public void shouldSkipHitListForFtpImportConfiguration() {
ImportConfiguration ftpConfiguration = createFtpImportConfiguration();
Assert.assertTrue("'Skip hit list' should return 'true' for FTP configurations",
ImportService.skipHitlist(ftpConfiguration, null));
}

/**
* Create and return an ImportConfiguration with configuration type `OPAC_SEARCH` and search interface type 'FTP'.
*/
private ImportConfiguration createFtpImportConfiguration() {
ImportConfiguration genericFtpConfiguration = new ImportConfiguration();
genericFtpConfiguration.setTitle("FTP example configuration");
genericFtpConfiguration.setConfigurationType(ImportConfigurationType.OPAC_SEARCH.name());
genericFtpConfiguration.setInterfaceType(SearchInterfaceType.FTP.name());
return genericFtpConfiguration;
}
}

0 comments on commit 4614561

Please sign in to comment.