Skip to content

Commit

Permalink
MET-6037: Ensure that the tiers for provider data only are returned d…
Browse files Browse the repository at this point in the history
…uring indexing.
  • Loading branch information
jochen-vermeulen committed Jul 25, 2024
1 parent ac24500 commit e7b6d00
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,10 @@ public interface Indexer extends Closeable {
*
* @param stringRdfRecord The record to index (can be parsed to RDF).
* @param indexingProperties The properties of this indexing operation.
* @param tierResultsConsumer The predicate deciding if the record should be published based on evaluated tier.
* @param tierResultsConsumer The predicate deciding whether the record should be published based
* on the evaluated tier. Note: the tier calculations that are provided
* to the consumer are for provider data only (i.e. mode
* {@link eu.europeana.indexing.tiers.metadata.ClassifierMode#PROVIDER_PROXIES}).
* @throws IndexingException In case a problem occurred during indexing.
*/
void index(String stringRdfRecord, IndexingProperties indexingProperties,
Expand Down Expand Up @@ -131,7 +134,9 @@ void index(String stringRdfRecord, IndexingProperties indexingProperties,
* @param recordContent The record to index (can be parsed to RDF).
* @param indexingProperties The properties of this indexing operation.
* @throws IndexingException In case a problem occurred during indexing.
* @return A pair with both content tier and metadata tier calculations results of the given record
* @return A pair with both content tier and metadata tier calculations results of the given
* record. The tier calculations are for provider data only (i.e. mode
* {@link eu.europeana.indexing.tiers.metadata.ClassifierMode#PROVIDER_PROXIES}).
*/
TierResults indexAndGetTierCalculations(InputStream recordContent,
IndexingProperties indexingProperties) throws IndexingException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,29 +33,29 @@ private IndexerPreprocessor() {
*
* @param rdf the rdf
* @param properties the properties
* @return the tier results
* @return the tier results for the provider data (i.e. {@link ClassifierMode#PROVIDER_PROXIES}).
* @throws IndexingException the indexing exception
*/
public static TierResults preprocessRecord(RDF rdf, IndexingProperties properties)
throws IndexingException {

// Perform the tier classification
final RdfWrapper rdfWrapper = new RdfWrapper(rdf);
TierResults tierCalculationsResult = new TierResults();
if (properties.isPerformTierCalculation() && properties.getTypesEnabledForTierCalculation()
.contains(rdfWrapper.getEdmType())) {
tierCalculationsResult = new TierResults(mediaClassifier.classify(rdfWrapper),
metadataClassifier.classify(rdfWrapper));
RdfTierUtils.setTier(rdf, tierCalculationsResult.getMediaTier());
RdfTierUtils.setTier(rdf, tierCalculationsResult.getMetadataTier());

tierCalculationsResult = new TierResults(mediaClassifier.classify(rdfWrapper),
metadataClassifierEuropeana.classify(rdfWrapper));
RdfTierUtils.setTierEuropeana(rdf, tierCalculationsResult.getMediaTier());
RdfTierUtils.setTierEuropeana(rdf, tierCalculationsResult.getMetadataTier());
final TierResults tierCalculationsResultProvidedData = new TierResults(
mediaClassifier.classify(rdfWrapper), metadataClassifier.classify(rdfWrapper));
RdfTierUtils.setTier(rdf, tierCalculationsResultProvidedData.getMediaTier());
RdfTierUtils.setTier(rdf, tierCalculationsResultProvidedData.getMetadataTier());

final TierResults tierCalculationsResultEuropeana = new TierResults(
mediaClassifier.classify(rdfWrapper), metadataClassifierEuropeana.classify(rdfWrapper));
RdfTierUtils.setTierEuropeana(rdf, tierCalculationsResultEuropeana.getMediaTier());
RdfTierUtils.setTierEuropeana(rdf, tierCalculationsResultEuropeana.getMetadataTier());

return tierCalculationsResultProvidedData;
}

return tierCalculationsResult;
return new TierResults();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ private ClassifierFactory() {
* @return A classifier for the metadata tier with Provider Proxies as default mode.
*/
public static TierClassifier<MetadataTier, MetadataTierBreakdown> getMetadataClassifier() {
return new MetadataClassifier(new LanguageClassifier(), new EnablingElementsClassifier(), new ContextualClassesClassifier());
return getMetadataClassifier(ClassifierMode.PROVIDER_PROXIES);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public class ContextualClassesClassifier implements TierClassifierBreakdown<Cont
private final ClassifierMode classifierMode;

/**
* Instantiates a new Contextual classes classifier.
* Instantiates a new Contextual classes classifier for default mode {@link ClassifierMode#PROVIDER_PROXIES}.
*/
public ContextualClassesClassifier() {
this.classifierMode = ClassifierMode.PROVIDER_PROXIES;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public class EnablingElementsClassifier implements TierClassifierBreakdown<Enabl
private final ClassifierMode classifierMode;

/**
* Instantiates a new Enabling elements' classifier.
* Instantiates a new Enabling elements' classifier for default mode {@link ClassifierMode#PROVIDER_PROXIES}.
*/
public EnablingElementsClassifier() {
this.classifierMode = ClassifierMode.PROVIDER_PROXIES;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public class LanguageClassifier implements TierClassifierBreakdown<LanguageBreak
private final ClassifierMode classifierMode;

/**
* Instantiates a new Language classifier.
* Instantiates a new Language classifier for default mode {@link ClassifierMode#PROVIDER_PROXIES}.
*/
public LanguageClassifier() {
this.classifierMode = ClassifierMode.PROVIDER_PROXIES;
Expand Down

0 comments on commit e7b6d00

Please sign in to comment.