/*
 * $Id: CompareVersionsForm.java,v 1.3 2006/08/30 21:08:15 marbobo Exp $
 * 
 * Copyright (c) Siemens AG 2008 
 *           (c) Universität Paderborn 2008 
 * Licensed under EUPL 1.1. 
 * 
 * $Log: CompareVersionsForm.java,v $
 * Revision 1.3  2006/08/30 21:08:15  marbobo
 * + Rückkehr zur Projekt- und Funktionssicht korrigiert
 *
 * Revision 1.2  2006/01/26 12:45:00  korowa
 * *** empty log message ***
 *
 * Revision 1.1  2006/01/20 12:44:07  korowa
 * Ermöglicht ein Vergleich von verschiedenen Versionen eines Dokumentes
 *
 *  
 */
package vkc.view.form;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts.action.ActionMapping;

import vkc.db.entities.VKCEntity;
import vkc.view.PageId;

public final class CompareVersionsForm extends BasicActionForm {
	private Integer categoryId = VKCEntity.ID_UNDEFINED;

	private Integer documentId = null;

	private Integer selectedId = null;

	private Integer sourcePageId = PageId.CATEGORY_VIEW;

	private Integer targetId = null;

	private Integer subTargetId = null;

	private String[] selectedDocuments = new String[0];

	public void reset(ActionMapping mapping, HttpServletRequest request) {
		super.reset(mapping, request);

		categoryId = VKCEntity.ID_UNDEFINED;

		documentId = null;

		selectedId = null;

		sourcePageId = PageId.CATEGORY_VIEW;

		targetId = null;

		subTargetId = null;

		selectedDocuments = new String[0];
	}

	public String[] getSelectedDocuments() {
		return selectedDocuments;
	}

	public void setSelectedDocuments(String[] selectedDocuments) {
		this.selectedDocuments = selectedDocuments;
	}

	public String getCompareDocumentsLink() {
		String link = "/compareDocuments.do?initialize=true";
		link += "&categoryId=" + getCategoryId();
		link += "&documentId=" + getDocumentId();
		link += "&sourcePageId=" + getSourcePageId();

		if (getTargetId() != null) {
			link += "&targetId=" + getTargetId();
		}

		if (getSubTargetId() != null) {
			link += "&subTargetId=" + getSubTargetId();
		}

		if (getSelectedDocuments() != null && getSelectedDocuments().length > 0) {
			for (int i = 0; i < getSelectedDocuments().length; i++) {
				link += "&selectedDocuments=" + getSelectedDocuments()[i];
			}
		}

		return link;
	}

	public String getShowVersionsLink() {
		String link = "/showVersions.do?initialize=true";
		link += "&categoryId=" + getCategoryId();
		link += "&documentId=" + getDocumentId();
		link += "&sourcePageId=" + getSourcePageId();

		if (getTargetId() != null) {
			link += "&targetId=" + getTargetId();
		}

		if (getSubTargetId() != null) {
			link += "&subTargetId=" + getSubTargetId();
		}

		if (getSelectedDocuments() != null && getSelectedDocuments().length > 0) {
			for (int i = 0; i < getSelectedDocuments().length; i++) {
				link += "&selectedDocuments=" + getSelectedDocuments()[i];
			}
		}

		return link;
	}

	public Integer getCategoryId() {
		return categoryId;
	}

	public void setCategoryId(Integer categoryId) {
		this.categoryId = categoryId;
	}

	public Integer getDocumentId() {
		return documentId;
	}

	public void setDocumentId(Integer documentId) {
		this.documentId = documentId;
	}

	public Integer getSelectedId() {
		return selectedId;
	}

	public void setSelectedId(Integer selectedId) {
		this.selectedId = selectedId;
	}

	public Integer getSourcePageId() {
		return sourcePageId;
	}

	public void setSourcePageId(Integer sourcePageId) {
		this.sourcePageId = sourcePageId;
	}

	public Integer getSubTargetId() {
		return subTargetId;
	}

	public void setSubTargetId(Integer subTargetId) {
		this.subTargetId = subTargetId;
	}

	public Integer getTargetId() {
		return targetId;
	}

	public void setTargetId(Integer targetId) {
		this.targetId = targetId;
	}
}