/*
 * $Id: SystemMaintenanceForm.java,v 1.6 2007/08/28 12:16:03 korowa Exp $
 *
 * Copyright (c) Siemens AG 2008 
 *           (c) Universität Paderborn 2008 
 * Licensed under EUPL 1.1. 
 *
 * $Log: SystemMaintenanceForm.java,v $
 * Revision 1.6  2007/08/28 12:16:03  korowa
 * Export- und Importfunktionen hinzugefügt
 *
 * Revision 1.5  2007/08/14 14:49:58  marbobo
 * + Licenseverwaltung komplett umgeschrieben
 * + Kategoriesuche und verlorene Kategorien anzeigen komplett umgeschrieben
 * + Fehler beim Speichern von Beschreibenungsfeldern für Entitäten beseitigt.
 *
 * Revision 1.4  2006/11/10 12:54:18  korowa
 * Eine Möglichkeit Kategorien die keiner lesen kann zu finden  hinzugefügt
 *
 * Revision 1.3  2004/11/08 12:28:35  koppy
 * Überarbeitet
 *
 * Revision 1.2  2004/10/05 12:31:30  koppy
 * +CONVERSIONS Kontext
 *
 * Revision 1.1  2004/08/23 15:58:17  jonyp
 * first strike
 *
 *
 */
package vkc.administration.form;

import java.util.ArrayList;
import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts.action.ActionMapping;

import vkc.db.serializer.VKCSysParameterSerializer;
import vkc.exception.DBException;
import vkc.view.form.BasicActionForm;

public class SystemMaintenanceForm extends BasicActionForm {
    public static final String SEARCHCLASSIFYINDEX = "SEARCHCLASSIFYINDEX";
    public static final String CONVERTER = "CONVERTER";
    public static final String CONVERSIONS = "CONVERSIONS";
    public static final String LOSTFOLDERS = "LOSTFOLDERS";
	public static final String EXPORT		= "EXPORT";
	public static final String IMPORT		= "IMPORT";

    public static final Integer INDEX_METHOD_REBUILD = new Integer(0);
    public static final Integer INDEX_METHOD_OPTIMIZE = new Integer(1);

    private String selectedContext = SEARCHCLASSIFYINDEX;

    private Integer indexMethod = INDEX_METHOD_OPTIMIZE;

    private List contextNames = null;

    public void reset(ActionMapping mapping, HttpServletRequest request) {
        super.reset(mapping, request);
        selectedContext = SEARCHCLASSIFYINDEX;
        indexMethod = INDEX_METHOD_OPTIMIZE;
        contextNames = null;
    }

    public List getContextNames() {
        if (contextNames == null) {
            contextNames = new ArrayList();
            contextNames.add(SEARCHCLASSIFYINDEX);
            contextNames.add(CONVERTER);
            contextNames.add(CONVERSIONS);
            contextNames.add(LOSTFOLDERS);
            contextNames.add(EXPORT);
    	    contextNames.add(IMPORT);
        }
        
        return contextNames;
    }

    public String getContextName(String context) {
        return getResources().getMessage(getLocale(), "vkc.administration.systemmaintenance." + context);

    }

    public String getSelectedContext() {
        return selectedContext;
    }

    public void setSelectedContext(String selectedContext) {
        this.selectedContext = selectedContext == null ? SystemMaintenanceForm.SEARCHCLASSIFYINDEX : selectedContext;
    }

    public String getIndexMethod() {
        return indexMethod.toString();
    }

    public void setIndexMethod(String i) {
        indexMethod = new Integer(i);
    }

    public String getSearchIndexDir() throws DBException {
        return VKCSysParameterSerializer.retrieveValue("SYSTEMPATHS", "SearchIndexDir", "WEB-INF/searchindex");
    }

    public String getClassifyIndexDir() throws DBException {
        return VKCSysParameterSerializer.retrieveValue("SYSTEMPATHS", "ClassifyIndexDir", "WEB-INF/classifyindex");
    }
}