All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.dspace.app.itemmarking.ItemMarkingCollectionStrategy Maven / Gradle / Ivy

There is a newer version: 8.0
Show newest version
/**
 * The contents of this file are subject to the license and copyright
 * detailed in the LICENSE and NOTICE files at the root of the source
 * tree and available online at
 *
 * http://www.dspace.org/license/
 */
package org.dspace.app.itemmarking;

import java.sql.SQLException;
import java.util.HashMap;
import java.util.Map;

import org.dspace.content.Collection;
import org.dspace.content.Item;
import org.dspace.core.Context;

/**
 * This is an item marking Strategy class that tries to mark an item
 * based on the collection the items belong to
 *
 * @author Kostas Stamatis
 */
public class ItemMarkingCollectionStrategy implements ItemMarkingExtractor {

    Map mapping = new HashMap();

    public ItemMarkingCollectionStrategy() {
    }

    @Override
    public ItemMarkingInfo getItemMarkingInfo(Context context, Item item)
        throws SQLException {

        if (mapping != null) {
            for (Collection collection : item.getCollections()) {
                if (mapping.containsKey(collection.getHandle())) {
                    return mapping.get(collection.getHandle());
                }
            }
        }

        return null;
    }

    public void setMapping(Map mapping) {
        this.mapping = mapping;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy