/*
 * $Id: ProcessDefinitionsForm.java,v 1.3 2005/07/18 14:45:59 marbobo Exp $
 *
 * Copyright (c) Siemens AG 2008 
 *           (c) Universität Paderborn 2008 
 * Licensed under EUPL 1.1. 
 * 
 * Created on 17.07.2004
 *
 * $Log: ProcessDefinitionsForm.java,v $
 * Revision 1.3  2005/07/18 14:45:59  marbobo
 * + Datentypen-Anzeigen anzeigen abschaltbar
 *
 * Revision 1.2  2004/09/20 10:26:12  koppy
 * +javadoc Dokumentation
 *
 * Revision 1.1  2004/08/30 14:49:56  koppy
 * Initiale Version der Workflow-Komponente
 *
 */
package vkc.workflow.web;

import java.util.Collection;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts.action.ActionMapping;

import vkc.view.WebShare;
import vkc.view.bean.GroupInfo;
import vkc.view.bean.UserInfo;
import vkc.view.form.DynaForm;
import vkc.workflow.WfConstants;
import vkc.workflow.model.MappingInfo;

/**
 * This class represents the corresponding 
 * struts form bean used with <code>ProcessDefinitionsAction</code>
 * @author Andreas Koop
 */
public class ProcessDefinitionsForm extends DynaForm{
    private String action;
    private String pkgId;
    private String procDefId = null;
    private String detailId; 
    
    private Collection userInfos = null;
    private Collection groupInfos = null;
    private MappingInfo [] partMappings = null;
    
    public void reset(ActionMapping mapping, HttpServletRequest request) {
        super.reset(mapping, request);
        
        if ( partMappings == null ) {
            partMappings = MappingInfo.getEmptyMappings(20);
        }
    }
    
    public Collection getGroupInfos() {
        return groupInfos;
    }
    
    public Collection getUserInfos() {
        return userInfos;
    }
    
    public String getAction() {
        return action;
    }
    
    public void setAction(String action) {
        this.action = action;
    }
    
    public String getPkgId() {
        return pkgId;
    }
    
    public void setPkgId(String pkgId) {
        this.pkgId = pkgId;
    }
    
    public String getProcDefId() {
        return procDefId;
    }
    
    public void setProcDefId(String procDefId) {
        this.procDefId = procDefId;
    }
    
    public MappingInfo[] getPartMappings() {
        return partMappings;
    }
    
    public void setPartMappings(MappingInfo[] partMappings) {
        this.partMappings = partMappings;
    }
   
    public boolean isPartMappingsEmpty(){
        return this.partMappings == null || this.partMappings.length == 0;
    }
    
    public void setGroupInfos(Collection groupInfos) {
        this.groupInfos = groupInfos;
        
        GroupInfo gi = new GroupInfo();
        gi.setName( WfConstants.UNKNOWN );
        groupInfos.add( gi);
    }

    public void setUserInfos(Collection userInfos) {
        this.userInfos = userInfos;
        
        UserInfo ui = new UserInfo();
        ui.setUsername( WfConstants.UNKNOWN);
        ui.setFirstname( WfConstants.UNKNOWN);
        ui.setLastname( WfConstants.UNKNOWN);
        this.userInfos.add(ui);
    }

    public String getDetailId() {
        return detailId;
    }
    
    public void setDetailId(String detailId) {
        this.detailId = detailId;
    }
    
    public boolean isShowDataTypes() {
        return Integer.parseInt(WebShare.getSysParameterValue("WORKFLOW", "ShowDatatype", "1")) != 0 ? true : false;
    }
}