/*
 * $Id: VKCCategoryPathNode.java,v 1.10 2005/08/22 15:42:16 jonyp Exp $
 * 
 * Copyright (c) Siemens AG 2008 
 *           (c) Universität Paderborn 2008 
 * Licensed under EUPL 1.1. 
 *
 * $Log: VKCCategoryPathNode.java,v $
 * Revision 1.10  2005/08/22 15:42:16  jonyp
 * added isInTrash method
 *
 * Revision 1.9  2005/02/10 01:07:53  marbobo
 * + getShortPathName() auf Unicode-Zeichen angepasst
 *
 * Revision 1.8  2004/07/20 08:46:28  jonyp
 * added copyright info + cvs log
 *
 */
package vkc.util;

import java.io.Serializable;
import vkc.view.WebShare;
import vkc.exception.DBException;

/**
 * Diese Klasse stellt Category Pfad Knoten dar
 * <p>
 * @author jonyP
 */
public final class VKCCategoryPathNode implements Serializable {
    private Integer pathId;
    private String  pathName;
    private boolean rootNode = false;
    private boolean lastNode = false;

    public void setPathId( Integer pathId ) {
        this.pathId = pathId;
    }

    public Integer getPathId() {
        return this.pathId;
    }

    public void setPathName( String pathName ) {
        this.pathName = pathName;
    }

    public String getPathName() {
        return this.pathName;
    }

    public String getShortPathName() {
        String path = VKCStringUtils.decodeXmlEntities( pathName );
        
        if ( path.length() > 12 ) {
            return VKCStringUtils.encodeXmlEntities( path.substring( 0, 11 ) ) + "...";
        } 

        return VKCStringUtils.encodeXmlEntities( path );
    }

    public boolean isRootNode() {
        return rootNode;
    }

    public void setRootNode( boolean b ) {
        rootNode = b;
    }

    public boolean isLastNode() {
        return lastNode;
    }

    public void setLastNode( boolean b ) {
        lastNode = b;
    }
    
    public boolean isInTrash() {
        try {
            return CategoryUtils.isInTree(new Integer(WebShare.getSysParameterValue("TRASH", "TrashCategoryId", "0")), this.pathId);
        } catch (DBException ex) {
            return false;
        }
    }
    
}