Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Let the ruleset module know about metadata #4329

Merged
merged 4 commits into from
Apr 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 0 additions & 18 deletions Kitodo-API/src/main/java/org/kitodo/api/Metadata.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,7 @@

package org.kitodo.api;

import java.util.Collection;
import java.util.Collections;
import java.util.Map;
import java.util.Objects;
import java.util.function.Function;
import java.util.stream.Collectors;

public class Metadata {
/**
Expand Down Expand Up @@ -79,17 +74,4 @@ public boolean equals(Object o) {
return domain == metadata.domain
&& Objects.equals(key, metadata.key);
}

/**
* Map Collection of Metadata objects to a Map of Metadata and String objects.
* @param metadataCollection Collection of Metadata objects
* @return Map of Metadata and String objects as java.util.Map
*/
public static Map<Metadata, String> mapToKey(Collection<Metadata> metadataCollection) {
if (Objects.isNull(metadataCollection)) {
return Collections.emptyMap();
}
return metadataCollection.parallelStream()
.collect(Collectors.toMap(Function.identity(), Metadata::getKey, (duplicateOne, duplicateTwo) -> duplicateOne));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@

import java.util.Collection;
import java.util.List;
import java.util.Map;

import org.kitodo.api.Metadata;

/**
* Provides an interface for the complex-type view service. The complex-type
Expand All @@ -32,7 +33,7 @@ public interface ComplexMetadataViewInterface extends MetadataViewInterface {
* metadata keys that the user has already selected
* @return the metadata keys that the user can add
*/
Collection<MetadataViewInterface> getAddableMetadata(Map<?, String> entered,
Collection<MetadataViewInterface> getAddableMetadata(Collection<Metadata> entered,
Collection<String> additionallySelected);

/**
Expand All @@ -50,8 +51,6 @@ Collection<MetadataViewInterface> getAddableMetadata(Map<?, String> entered,
* keys that the user has already manually added. The list is created and
* then sorted according to the given sorting rules.
*
* @param <T>
* the type of metadata objects
* @param entered
* metadata objects that have already been entered, along with
* their key
Expand All @@ -61,7 +60,7 @@ Collection<MetadataViewInterface> getAddableMetadata(Map<?, String> entered,
* already filled with values, the values are returned here. If a
* key is a multiple-selection, values are grouped below it.
*/
<T> List<MetadataViewWithValuesInterface<T>> getSortedVisibleMetadata(Map<T, String> entered,
List<MetadataViewWithValuesInterface> getSortedVisibleMetadata(Collection<Metadata> entered,
Collection<String> additionallySelected);

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
import java.util.Collection;
import java.util.Optional;

import org.kitodo.api.Metadata;

/**
* Return value of the function
* {@code ComplexMetadataViewInterface.getSortedVisibleMetadatas()}. The
Expand All @@ -26,11 +28,8 @@
* is {@code List<Pair<MetadataViewInterface, Collection<T>>>}. Since the key
* must be repeatable if there is more than one value but the key is not a
* multiple choice, a map would be an inappropriate choice at this point.
*
* @param <T>
* type of data objects
*/
public interface MetadataViewWithValuesInterface<T> {
public interface MetadataViewWithValuesInterface {
/**
* Returns the key to be displayed at this point. The interface can return
* entries where the key is {@code null} with values if there were values
Expand All @@ -48,5 +47,5 @@ public interface MetadataViewWithValuesInterface<T> {
*
* @return the values for the key
*/
Collection<T> getValues();
Collection<Metadata> getValues();
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,19 @@
import java.util.Locale.LanguageRange;
import java.util.Set;

import org.kitodo.api.Metadata;

/**
* Class of the data row objects of the auxiliary table. You can imagine the
* list of these objects in the metadata acquisition mask builder as a large
* table in which all relevant information is entered, one row per metadata
* type, in the order in which the metadata types must be displayed later.
*
* @param <T>
* the type of metadata objects
*/
class AuxiliaryTableRow<T> {
class AuxiliaryTableRow {
/**
* Returns the umpteenth set member as the only element of a list, if that
* exists. Otherwise the empty list.
*
* @param <T>
* the type of the metadata objects
* @param unnumbered
* unnumbered collection
* @param fictitiousNumber
Expand Down Expand Up @@ -84,7 +81,7 @@ private static <T> Collection<T> unorderedCollectionMemberByIndexAsList(Collecti
* which class these objects have, it still accepts them and provides for
* possibly necessary grouping.
*/
private Set<T> metaDataObjects = new HashSet<>();
private Set<Metadata> metaDataObjects = new HashSet<>();

/**
* Creates a new data row object and enters a key into the table.
Expand All @@ -103,7 +100,7 @@ private static <T> Collection<T> unorderedCollectionMemberByIndexAsList(Collecti
* @param metaDataObject
* valuable object added
*/
void add(T metaDataObject) {
void add(Metadata metaDataObject) {
metaDataObjects.add(metaDataObject);

}
Expand All @@ -126,7 +123,7 @@ void addOneAdditionalField() {
* which object should be returned
* @return the data object(s)
*/
Collection<T> getDataObjects(int i) {
Collection<Metadata> getDataObjects(int i) {
if (isMultipleChoice() || isContainingExcludedData()) {
return metaDataObjects;
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,16 @@
import java.util.Collection;
import java.util.Optional;

import org.kitodo.api.Metadata;
import org.kitodo.api.dataeditor.rulesetmanagement.MetadataViewInterface;
import org.kitodo.api.dataeditor.rulesetmanagement.MetadataViewWithValuesInterface;

/**
* Return type for list entries consisting of a metadata key and a collection
* of values. Instances of this class are returned by the metadata acquisition
* mask builder and each represent a line of the metadata input mask.
*
* @param <T>
* type of metadata objects
*/
class FormRow<T> implements MetadataViewWithValuesInterface<T> {
class FormRow implements MetadataViewWithValuesInterface {
/**
* A possible view on the key. None, if it is hidden.
*/
Expand All @@ -34,9 +32,9 @@ class FormRow<T> implements MetadataViewWithValuesInterface<T> {
/**
* The values. This is always one at most, except for multiple selections.
*/
private Collection<T> values;
private Collection<Metadata> values;

FormRow(Optional<MetadataViewInterface> optionalKeyView, Collection<T> values) {
FormRow(Optional<MetadataViewInterface> optionalKeyView, Collection<Metadata> values) {
this.optionalKeyView = optionalKeyView;
this.values = values;
}
Expand All @@ -58,7 +56,7 @@ public Optional<MetadataViewInterface> getMetadata() {
* @return the values
*/
@Override
public Collection<T> getValues() {
public Collection<Metadata> getValues() {
return values;
}

Expand Down
Loading