PublisherService.java 3.05 KB
package org.legrog.web.publisher;

import org.legrog.entities.*;

import javax.validation.constraints.NotNull;
import java.util.List;

/**
 * Interface correspondant à la gestion des éditeurs, de leurs versions et des actions correspondantes.
 * Contient des signatures pour les méthodes d'ajout, de modification et de validation de version ainsi
 * que de restitution.
 */
public interface PublisherService {

    /**
     * Creates Publisher, associates it with PublisherVersion and back.
     * PublisherVersion is completed with author and date time.
     * Both Publisher and PublisherVersion are persisted.
     *
     * @param publisherVersion for creation of new Publisher ; has no publisher, author or date time
     * @return updated PublisherVersion
     */
    PublisherVersion addNewPublisher(@NotNull PublisherVersion publisherVersion);

    /**
     * Updates Publisher's versions, adding PublisherVersion. Reverse association is also done.
     * PublisherVersion is completed with author and date time.
     * Both Publisher and PublisherVersion are persisted.
     *
     * @param publisher has at least one version
     * @param publisherVersion has no publisher, author or date time
     * @return updated PublisherVersion
     */
    PublisherVersion addVersionToPublisher(@NotNull Publisher publisher, @NotNull PublisherVersion publisherVersion);

    /**
     * Sets PublisherVersion as its Publisher validated version.
     * Creates the PublisherAction for the validation.
     * Both Publisher and PublisherAction are persisted.
     *
     * @param publisherVersion
     * @return PublisherAction related to the validation
     */
    PublisherAction validatePublisherVersion(@NotNull PublisherVersion publisherVersion);

    /**
     * @return all persisted PublisherVersions
     */
    List<PublisherVersion> getAllPublisherVersions();

    /**
     * @param publisherVersionId
     * @return PublisherVersion with id publisherVersionId
     */
    PublisherVersion getPublisherVersion(@NotNull Integer publisherVersionId);

    /**
     * @param publisher
     * @return PublisherAction for Publisher's last validation
     */
    PublisherAction getLastValidate(@NotNull Publisher publisher);

    /**
     * @return all persisted PublisherAction
     */
    List<PublisherAction> getAllPublisherActions();

    /**
     * @param publisherVersion
     * @return all PublisherAction on that PublisherVersion
    */
    List<PublisherAction> getAllPublisherVersionActions(@NotNull PublisherVersion publisherVersion);

    /**
     *
     * @param string String searched indexed publishers
     * @return indexed publishers that match the String
     */
    List<PublisherVersion> search(@NotNull String string) throws SearchingException;

    /**
     *
     * @param indexedPublishers to convert
     * @return PublisherVersion List
     */
    List<PublisherVersion> convertIndexedPublishersIntoPublisherVersions(List<IndexedPublisher> indexedPublishers);

    /**
     *
     * @return number of indexed publishers
     */
    public int reindexAllPublishers() throws IndexingException;
}