Showing posts with label Windchill Examples. Show all posts
Showing posts with label Windchill Examples. Show all posts

Windchill Command Line Utility Skeleton

In the last topic Windchill Remote Method Server Access API we saw how we can use RemoteMethodServer to invoke method server code remotely. Even though there are plenty of utilities available in Windchill OOTB, we came across various scenarios where we need to write our own custom utilities.
In this post I am trying to share the Windchill command line utility skeleton which uses RemoteMethodServer.
package com.blogspot.maheshmhetre.windchill.utilities;

import java.lang.reflect.InvocationTargetException;
import java.rmi.RemoteException;

import wt.method.RemoteAccess;
import wt.method.RemoteMethodServer;
import wt.session.SessionHelper;
import wt.util.WTException;

public class WindchillCustomUtilitySkeleton {

 //START of inner class - Server
 public static class Server implements RemoteAccess {
  
  public static void methodOne(String param1, String param2) {
   try {
    //Get login credentials
    SessionHelper.manager.getPrincipal();
    
    //Call core processing method
    WindchillCustomUtilitySkeleton utility = new WindchillCustomUtilitySkeleton(); 
    utility.doOperation(param1, param2);
    
   } catch (Exception e) {
    e.printStackTrace();
   }
   
   return;
  }
 } //END of inner class - Server

 private void doOperation(String param1, String param2) throws WTException{
  //TODO execute your utility logic
  System.out.println("This sysout will be available in method server log.");
 }
 
 public static void main(String[] args) {
  //TODO get utility input parameters
  //TODO basic validation

  System.out.println("This sysout will be available on console from where the utility is running.");
  //prepare input params
  //data types will depends on your method parameters and can be any valid object type
  Class argTypes[] = {String.class, String.class};//add all remote method parameter data types
  Object argValues[] = {"param_1_value", "param_2_value"};//respective data value
  
  //call remote method - pass inner class name, method name, arg types and arg values
  try {
   RemoteMethodServer.getDefault().invoke("methodOne", 
     "com.blogspot.maheshmhetre.windchill.utilities.WindchillCustomUtilitySkeleton$Server",
     null, argTypes, argValues);
  } catch (RemoteException e) {
   e.printStackTrace();
  } catch (InvocationTargetException e) {
   e.printStackTrace();
  }

  Runtime.getRuntime().exit(0);
 }
}

Please share your thoughts to improve this skeleton.

Windchill ... Where to Start?

Many guys who want or have to work on Windchill, the first question they usually ask is “Where to start?”.

The best training material for Windchill is PTC University courses. This is a web based training provided by PTC and need to be purchased.

As we can see, most of the companies working in Windchill are service industries. Rare to see those companies purchasing PTC University courses to train employees. Adding to this, these days the Windchill service industry following the pattern of hiring pure Java developers for Windchill customization and train them the Windchill framework. So all the responsibility goes to the senior person in the team who is most of time busy.
Now you are at dead end where we must start to explore Windchill yourself. Here are few pointers where we can start learning Windchill.

Windchill Help:
URL: http://hostname/Windchill-WHC/index.jspx
This the real material to learn the Windchill functionality. You can directly go to the home page and explore the area the you of interest. The other way is open help from the screen you are working on, this will take to the respective help topic.

Windchill Java/API Doc:
Folder: Windchill_Home/codebase/wt/clients/library/api/index.html
Web: http://hostname/Windchill/wt/clients/library/api/index.html

Windchill Examples:
Location: Windchill_Home/codebase/netmarkets/jsp/carambola/customization/examples/
Many examples found under his location.
In Windchill 10.x you can found this under Tools as well.

Top most Windchill Guides:
Windchill Customization Guide
Windchill Business Administration Guide
Windchill System Administration Guide