⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 viewgenerator.java

📁 OPIAM stands for Open Identity and Access Management. This Suite will provide modules for user & rig
💻 JAVA
字号:
/*
 * OPIAM Suite
 *
 * Distributable under LGPL license.
 * See terms of license at gnu.org.
 */

package opiam.admin.faare.service.services.views;

import opiam.admin.faare.config.ViewsConfig;
import opiam.admin.faare.config.javabeans.JBLevel;
import opiam.admin.faare.config.javabeans.JBLevelRessource;
import opiam.admin.faare.config.javabeans.JBObjectView;
import opiam.admin.faare.config.javabeans.JBOrgChartAtt;
import opiam.admin.faare.config.javabeans.JBOrgChartParams;
import opiam.admin.faare.config.javabeans.JBViewDef;
import opiam.admin.faare.config.javabeans.JBViewDefs;
import opiam.admin.faare.exception.ServiceException;
import opiam.admin.faare.persistence.javabeans.JBTop;
import opiam.admin.faare.service.UserContext;
import opiam.admin.faare.service.services.Service;
import opiam.admin.faare.service.services.views.orgchart.OrgChartPanel;
import opiam.admin.faare.utils.StringUtil;

import org.apache.commons.beanutils.PropertyUtils;

import org.apache.log4j.Logger;

import javax.swing.JFrame;
import javax.swing.tree.DefaultMutableTreeNode;

import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;

import java.net.URL;
import java.net.URLEncoder;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.List;


/**
 * This service allows to generate and manage all the visible views by the
 *  current connected user, as well as to generate orgcharts PDF
 *  corresponding to a view. <br>
 * The views are defined in the views.xml file.<br>
 * The generation of a view is done in two steps:<br>
 *
 *    1.  Call to the ViewGenerator service that plays the motor role of
 *        TreeNode generation.<br>
 *        These TreeNodes include the DefaultMutableTreeNode that will allow
 *        to generate the graphic party of the views.<br>
 *        The service ViewGenerator has also the role to call the view plugin
 *        configured in the views.xml file.<br>
 *
 *    2.  Call to the graphic generator.
 *
 */
public final class ViewGenerator extends Service
{
    /** Utility class. */
    private ViewGenerator()
    {
    }

    /** Instance of logger. */
    private static Logger _logger = Logger.getLogger(ViewGenerator.class);

    /** Instance of viewGenerator. */
    private static ViewGenerator _instance = new ViewGenerator();

    /** Name of the orgchart hashtable representation. */
    private static final String ORGCHART_HASHTABLE_NAME = "orgchart_hashtable";

    /** Identifier of the orgchart. */
    private static final String ORGCHART_ID_NAME = "orgchart_id";

    /** Name of the treeview hashtable representation. */
    private static final String TREEVIEW_HASHTABLE_NAME = "treeview_hashtable";

    /** Identifier of the treeview. */
    private static final String TREEVIEW_ID_NAME = "treeview_id";

    /** Name of the service associated to the treeview. */
    private static final String SERVICE_NAME = "TreeViewGenerator";

    /** Configuration file of the views service. */
    public static final String VIEWS_XML_FILE =
        "/config/service/views/views.xml";

    /** JavaBean of the views set defined in the views.xml file. */
    private static JBViewDefs _jbViewDefs = null;

    /** Node children. */
    private static DefaultMutableTreeNode children = null;

//DW/2644/BeginPatch
    /** Frame for graphic orgchart. */
    private static JFrame aframe;
//DW/2644/EndPatch

    /**
     * Initializes the views service.
     *
     * @param directory  Directory of the views file.
     *
     * @throws ServiceException  if an error occurs.
     */
    public static void initialize(String directory) throws ServiceException
    {
        //DW/2655/BeginPatch
        //ViewGenerator.setServiceEnabled(true);
        _instance.setServiceEnabled(true);
        //DW/2655/EndPatch


        try
        {
            /* Chargement de l'objet JBViewDefs 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -