// 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:   MigrateReferenceDocumentTypeDef.java

package com.ptc.windchill.pdmlink.upgrade.wt.doc;

import com.ptc.core.meta.type.admin.common.impl.TypeAdminHelper;
import com.ptc.core.meta.type.admin.common.impl.TypeAdminServiceIfc;
import com.ptc.core.meta.type.mgmt.common.TypeDefinitionDefaultView;
import com.ptc.core.meta.type.mgmt.server.TypeDefinitionCache;
import com.ptc.core.meta.type.mgmt.server.impl.AdminTypeDefinitionCache;
import java.rmi.RemoteException;
import wt.method.RemoteAccess;
import wt.services.LightweightServiceHelper;
import wt.session.SessionHelper;
import wt.session.SessionManager;
import wt.util.*;

public class MigrateReferenceDocumentTypeDef
{
    public static class Server
        implements RemoteAccess
    {

        public static Boolean migrateData()
            throws WTException
        {
            SessionHelper.manager.setAdministrator();
            java.util.Locale locale = WTContext.getContext().getLocale();
            TypeAdminServiceIfc service = TypeAdminHelper.service;
            TypeDefinitionDefaultView tddv = AdminTypeDefinitionCache.getInstance().getTypeDefinition("wt.doc.WTDocument|ReferenceDocument", true);
            try
            {
                com.ptc.core.meta.type.mgmt.common.TypeDefinitionNodeView tdnv = tddv.toTypeDefinitionNodeView();
                tdnv = service.checkoutTypeNode("com.ptc", tdnv, locale);
                tddv = service.getTypeDefDefaultView(tdnv, locale);
                tddv.setName("com.ptc.ReferenceDocument");
                tddv.setLogicalIdentifier("com.ptc.ReferenceDocument");
                tddv = service.updateTypeDefDefaultView("com.ptc", tddv, locale);
                tdnv = tddv.toTypeDefinitionNodeView();
                tdnv = service.checkinTypeNode("com.ptc", tdnv, locale);
            }
            catch(WTPropertyVetoException wtpve)
            {
                throw new WTException(wtpve);
            }
            catch(RemoteException re)
            {
                throw new WTException(re);
            }
            return Boolean.TRUE;
        }

        public Server()
        {
        }
    }


    public MigrateReferenceDocumentTypeDef()
    {
    }

    public Boolean runMigration()
        throws WTException
    {
        String SERVER_CLASS = getClass().getName() + "$Server";
        return (Boolean)LightweightServiceHelper.invoke("migrateData", SERVER_CLASS, null, null);
    }

    public static void main(String args[])
    {
        try
        {
            String SERVER_CLASS = (com.ptc.windchill.pdmlink.upgrade.wt.doc.MigrateReferenceDocumentTypeDef.class).getName() + "$Server";
            LightweightServiceHelper.invoke("migrateData", SERVER_CLASS, null, null);
            System.exit(0);
        }
        catch(WTException wte)
        {
            wte.printStackTrace();
        }
        System.exit(1);
    }
}
