/*
 * $Id: ClusterCategoryForm.java,v 1.2 2005/07/28 14:46:38 aram Exp $
 *
 * Copyright (c) Siemens AG 2008 
 *           (c) Universität Paderborn 2008 
 * Licensed under EUPL 1.1. 
 *
 * $Log: ClusterCategoryForm.java,v $
 * Revision 1.2  2005/07/28 14:46:38  aram
 * Bestclustering per default aktiv.
 *
 * Revision 1.1  2005/06/23 00:58:30  aram
 * + Initiale Version
 *
 */

package vkc.view.form;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionMapping;

import vkc.db.entities.VKCCategory;
import vkc.db.entities.VKCEntity;
import vkc.db.serializer.VKCCategorySerializer;
import vkc.exception.DBException;
import vkc.view.PageId;

public class ClusterCategoryForm extends DynaForm {
    public static final Integer CLUSTER_CLINK = new Integer(1);
    public static final Integer CLUSTER_SLINK = new Integer(2);
    public static final Integer CLUSTER_AVERAGE = new Integer(3);
    public static final Integer FASTCLUSTERING = new Integer(10);
    public static final Integer BESTCLUSTERING = new Integer(-1);
    private boolean termIntersection = true;
    private Integer clusterAlgoMode			= CLUSTER_AVERAGE;
    private Integer clusterMode				= BESTCLUSTERING;
    private Integer categoryId 				= VKCEntity.ID_UNDEFINED;
	private Integer sourcePageId 			= PageId.CATEGORY_VIEW;
	private Integer subTargetId 			= null;
	private Integer targetId 				= null;
	
	private VKCCategory category = null;
	
    public void reset( ActionMapping mapping, HttpServletRequest request ) {
		super.reset( mapping, request );

	    termIntersection = true;
	    clusterAlgoMode			= CLUSTER_AVERAGE;
	    clusterMode				= BESTCLUSTERING;
		categoryId 				= VKCEntity.ID_UNDEFINED;
		sourcePageId 			= PageId.CATEGORY_VIEW;
		subTargetId 			= null;
		targetId 				= null;

		category = null;
    }

    public ActionErrors validate( ActionMapping mapping, HttpServletRequest request ) {
        ActionErrors errors = new ActionErrors();

		setTermIntersection( request.getParameter( "termIntersection" ) != null );

		return errors;
    }

	public VKCCategory getCategory() throws DBException {
		if ( category == null ) {
			category = VKCCategorySerializer.retrieveCategory( getCategoryId() );
		}

		return category;
	}
	
    public Integer getCategoryId() {
        return categoryId;
    }

    public void setCategoryId( Integer i ) {
        categoryId = i;
    }

	public Integer getSourcePageId() {
		return sourcePageId;
	}

	public void setSourcePageId( Integer i ) {
		sourcePageId = i;
	}

	public Integer getSubTargetId() {
		return subTargetId;
	}

	public Integer getTargetId() {
		return targetId;
	}

	public void setSubTargetId( Integer i ) {
		subTargetId = i;
	}

	public void setTargetId( Integer i ) {
		targetId = i;
	}

    public Integer getClusterMode() {
        return clusterMode;
    }

    public void setClusterMode(Integer clusterMode) {
        this.clusterMode = clusterMode;
    }

    /**
     * @return Returns the termIntersection.
     */
    public boolean isTermIntersection() {
        return termIntersection;
    }
    
    /**
     * @param termIntersection The termIntersection to set.
     */
    public void setTermIntersection(boolean termIntersection) {
        this.termIntersection = termIntersection;
    }
    
    /**
     * @return Returns the clusterAlgoMode.
     */
    public Integer getClusterAlgoMode() {
        return clusterAlgoMode;
    }
    
    /**
     * @param clusterAlgoMode The clusterAlgoMode to set.
     */
    public void setClusterAlgoMode(Integer clusterAlgoMode) {
        this.clusterAlgoMode = clusterAlgoMode;
    }
}