ReindexView.java 1.5 KB
package org.legrog.web.xyz;

import org.legrog.entities.IndexingException;
import org.legrog.web.account.AccountService;
import org.legrog.web.publisher.PublisherService;

import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;
import javax.inject.Named;
import java.io.Serializable;

/**
 * View for reindex.xhtml
 */
@Named
@RequestScoped
public class ReindexView implements Serializable {
    private int indexedAccountsNumber;
    private int indexedPublishersNumber;
    private PublisherService publisherService;
    private AccountService accountService;

    @Inject
    ReindexView(PublisherService publisherService, AccountService accountService) {
        this.publisherService = publisherService;
        this.accountService = accountService;
    }

    ReindexView() {
        //no args constructor to make it proxyable
    }

    public void reindexAll() throws IndexingException {
        indexedPublishersNumber = publisherService.reindexAllPublishers();
        indexedAccountsNumber = accountService.reindexAllAccounts();
    }

    public int getIndexedAccountsNumber() {
        return indexedAccountsNumber;
    }

    public void setIndexedAccountsNumber(int indexedAccountsNumber) {
        this.indexedAccountsNumber = indexedAccountsNumber;
    }

    public int getIndexedPublishersNumber() {
        return indexedPublishersNumber;
    }

    public void setIndexedPublishersNumber(int indexedPublishersNumber) {
        this.indexedPublishersNumber = indexedPublishersNumber;
    }
}