// Decompiled by Jad v1.5.8e. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/kpdus/jad.html
// Decompiler options: packimports(3) deadcode 
// Source File Name:   WTDocumentTemplateWithContextDelegate.java

package com.ptc.windchill.pdmlink.doc.server;

import com.ptc.core.meta.common.TypeIdentifier;
import com.ptc.core.meta.server.TypeIdentifierUtility;
import com.ptc.windchill.enterprise.doc.server.WTDocumentTemplateDelegate;
import com.ptc.windchill.enterprise.nativeapp.server.ClientConfiguration;
import java.io.PrintStream;
import java.util.HashMap;
import java.util.Locale;
import wt.doc.WTDocument;
import wt.enterprise.Templateable;
import wt.fc.Persistable;
import wt.inf.container.WTContainer;
import wt.inf.container.WTContainerRef;
import wt.rule.util.InitRuleHelper;
import wt.util.WTException;
import wt.util.WTProperties;

/**
 * @deprecated Class WTDocumentTemplateWithContextDelegate is deprecated
 */

public class WTDocumentTemplateWithContextDelegate extends WTDocumentTemplateDelegate
{

    public WTDocumentTemplateWithContextDelegate()
    {
    }

    /**
     * @deprecated Method createFromTemplate is deprecated
     */

    public Templateable createFromTemplate(Templateable objTemplate, HashMap nameValueData, Locale locale, String applicationName)
        throws WTException
    {
        if(VERBOSE)
            System.out.println("Entering " + CLASSNAME + ".createFromTemplate");
        WTDocument template = (WTDocument)objTemplate;
        WTDocument document = getUnpersistedDocumentFromTemplate(template, nameValueData, "PDMLink", locale);
        document = persistDocumentFromTemplate(template, document, nameValueData, null, "PDMLink", locale);
        return document;
    }

    /**
     * @deprecated Method createTemplate is deprecated
     */

    public Templateable createTemplate(TypeIdentifier objType, HashMap nameValueData, Locale locale)
        throws WTException
    {
        if(VERBOSE)
            System.out.println("Entering " + CLASSNAME + ".createTemplate");
        WTDocument document = getUnpersistedTemplate(nameValueData, objType, "PDMLink", locale);
        document = persistDocumentTemplate(document, null, "PDMLink", locale);
        if(VERBOSE)
            System.out.println("I am done with creating the template.");
        return document;
    }

    /**
     * @deprecated Method getTemplates is deprecated
     */

    public Persistable[] getTemplates(Class objClass, String context, Locale locale)
        throws WTException
    {
        if(VERBOSE)
            System.out.println("Starting " + CLASSNAME + ".getTemplates...");
        return super.getTemplates(objClass, context, locale);
    }

    /**
     * @deprecated Method getTemplateTypes is deprecated
     */

    public TypeIdentifier[] getTemplateTypes(Class objClass, String context, Locale locale)
        throws WTException
    {
        if(VERBOSE)
            System.out.println("Starting " + CLASSNAME + ".getTemplateTypes...");
        return super.getTemplateTypes(objClass, context, locale);
    }

    /**
     * @deprecated Method getCreateTemplateAttributes is deprecated
     */

    public HashMap getCreateTemplateAttributes(WTContainer context, TypeIdentifier objType, HashMap hashMap, Locale locale)
        throws WTException
    {
        String list[] = getPDMLinkSpecificAttributes("create_template");
        boolean autonumber = InitRuleHelper.isAutoNumber(objType.getTypename(), WTContainerRef.newWTContainerRef(context));
        return getCreateTemplateAttributes(list, context, objType, hashMap, autonumber, locale);
    }

    /**
     * @deprecated Method getCreateFromTemplateAttributes is deprecated
     */

    public HashMap getCreateFromTemplateAttributes(WTContainer context, Templateable objTemplate, HashMap hashMap, Locale locale)
        throws WTException
    {
        String list[] = getPDMLinkSpecificAttributes("create");
        TypeIdentifier objType = TypeIdentifierUtility.getTypeIdentifier(objTemplate);
        boolean autonumber = InitRuleHelper.isAutoNumber(objType.getTypename(), WTContainerRef.newWTContainerRef(context));
        return getCreateFromTemplateAttributes(list, context, objTemplate, hashMap, autonumber, locale);
    }

    /**
     * @deprecated Method getUpdateTemplateAttributes is deprecated
     */

    public HashMap getUpdateTemplateAttributes(Templateable object, HashMap hashMap, Locale locale)
        throws WTException
    {
        String list[] = getPDMLinkSpecificAttributes("update_template");
        return getUpdateDocumentAttributes(list, object, hashMap, locale);
    }

    /**
     * @deprecated Method getDetailsTemplateAttributes is deprecated
     */

    public HashMap getDetailsTemplateAttributes(Templateable object, HashMap hashMap, ClientConfiguration clientInfo, Locale locale)
        throws WTException
    {
        String list[] = getPDMLinkSpecificAttributes("display_template");
        return getDetailsDocumentAttributes(list, object, hashMap, clientInfo, locale);
    }

    /**
     * @deprecated Method getCheckinTemplateAttributes is deprecated
     */

    public HashMap getCheckinTemplateAttributes(Templateable object, HashMap hashMap, Locale locale)
        throws WTException
    {
        String list[] = getPDMLinkSpecificAttributes("checkin_template");
        return getCheckinDocumentAttributes(list, object, hashMap, locale);
    }

    private String[] getPDMLinkSpecificAttributes(String operation)
    {
        String list[];
        if(operation.equals("checkin_template"))
        {
            list = (new String[] {
                "number", "name", "title", "description", "template.enabled"
            });
            return list;
        }
        if(operation.equals("update_template"))
        {
            list = (new String[] {
                "number", "name", "title", "description"
            });
            return list;
        }
        String orglist[];
        if(operation.equals("create"))
        {
            list = (new String[] {
                "number", "name", "title", "location", "description", "container"
            });
            orglist = (new String[] {
                "number", "name", "title", "location", "description", "container", "organization"
            });
            if(SHOWORG)
                return orglist;
            else
                return list;
        }
        if(operation.equals("create_template"))
        {
            list = (new String[] {
                "number", "name", "title", "description", "container", "template.enabled"
            });
            orglist = (new String[] {
                "number", "name", "title", "description", "container", "organization", "template.enabled"
            });
            if(SHOWORG)
                return orglist;
            else
                return list;
        }
        list = (new String[] {
            "type", "number", "name", "title", "description", "versionInfo", "checkoutInfo", "location", "teamName", "lifeCycleState", 
            "templated", "template.enabled", "enabledVersion", "primaryName", "primaryFormat", "primarySize", "primaryUpdated", "creator", "createTimestamp", "modifier", 
            "modifyTimestamp", "obid"
        });
        orglist = (new String[] {
            "type", "organizationName", "number", "name", "title", "description", "versionInfo", "checkoutInfo", "location", "teamName", 
            "lifeCycleState", "templated", "template.enabled", "enabledVersion", "primaryName", "primaryFormat", "primarySize", "primaryUpdated", "creator", "createTimestamp", 
            "modifier", "modifyTimestamp", "obid"
        });
        if(SHOWORG)
            return orglist;
        else
            return list;
    }

    static Class _mthclass$(String x0)
    {
        return Class.forName(x0);
        ClassNotFoundException x1;
        x1;
        throw (new NoClassDefFoundError()).initCause(x1);
    }

    private static final String RESOURCE = "com.ptc.windchill.pdmlink.doc.server.serverResource";
    private static final String CLASSNAME;
    private static final String CREATE_FROM_TEMPLATE = "create";
    private static final String CREATE_TEMPLATE = "create_template";
    private static final String UPDATE_TEMPLATE = "update_template";
    private static final String DISPLAY_TEMPLATE = "display_template";
    private static final String CHECKIN_TEMPLATE = "checkin_template";
    private static boolean VERBOSE = false;
    private static final boolean SHOWORG;

    static 
    {
        CLASSNAME = (com.ptc.windchill.pdmlink.doc.server.WTDocumentTemplateWithContextDelegate.class).getName();
        try
        {
            WTProperties properties = WTProperties.getLocalProperties();
            VERBOSE = properties.getProperty("com.ptc.windchill.enterprise.verbose", false);
            SHOWORG = properties.getProperty("wt.org.OrganizationOwned.displayOrganization", false);
        }
        catch(Throwable t)
        {
            System.err.println("com.ptc.windchill.pdmlink.doc.server.WTDocumentTemplateWithContextDelegate : Error reading com.ptc.windchill.enterprise.* properties");
            t.printStackTrace(System.err);
            throw new ExceptionInInitializerError(t);
        }
    }
}
