Sunday 23 October 2016

Teamcenter SOA Clinet : Remove Reference from Dataset

Here we will understand the apis used for removing the named references from Dataset

import com.teamcenter.services.strong.core.DataManagementService;
import com.teamcenter.services.strong.core._2007_09.DataManagement.NamedReferenceInfo;
import com.teamcenter.services.strong.core._2007_09.DataManagement.RemoveNamedReferenceFromDatasetInfo;
import com.teamcenter.soa.client.Connection;
import com.teamcenter.soa.client.model.ModelObject;
import com.teamcenter.soa.client.model.ServiceData;
import com.teamcenter.soa.client.model.strong.Dataset;



String datasetUID = listValues.get(0);

  category.info("datasetUID  : " + datasetUID);

  String strTextUID = listValues.get(1);

  category.info("strTextUID  : " + strTextUID);

  String strNamedRefType = listValues.get(2);

  category.info("NamedReferenceType  : " + strNamedRefType);
  

  TcSOAPlugin soaPlugin = (TcSOAPlugin) plugin;

  Connection soaConnection = soaPlugin.getTcConnection();
  Dataset dataSet = (Dataset) soaPlugin.getConnection().getPinnedObject(datasetUID);
  category.info(" Dataset object pinned  : " + dataSet);

  ModelObject TextFile =  (ModelObject)soaPlugin.getConnection().getPinnedObject(strTextUID);

  category.info(" TextFile object pinned  : " + TextFile);

        DataManagementService dataManagementService = DataManagementService.getService( soaConnection );

      
        NamedReferenceInfo[] nrInfo = new NamedReferenceInfo[1];

        nrInfo[0] = new NamedReferenceInfo();
        nrInfo[0].clientId = "ClientId01";
        nrInfo[0].deleteTarget = true;
        nrInfo[0].type = strNamedRefType;
        nrInfo[0].targetObject = TextFile;


        //Dataset

        RemoveNamedReferenceFromDatasetInfo datasetinfo[] = new  RemoveNamedReferenceFromDatasetInfo[1];
        datasetinfo[0] = new RemoveNamedReferenceFromDatasetInfo();
        datasetinfo[0].clientId = "ClientId01";
        datasetinfo[0].dataset = dataSet;
        datasetinfo[0].nrInfo = nrInfo;

        ServiceData serviceData = dataManagementService.removeNamedReferenceFromDataset(datasetinfo);

RichClient- call URL - TRIGGER_WithoutButton

plugin.xml
<?xml version="1.0" encoding="UTF-8"?>

<?eclipse version="3.4"?>

<plugin>



   <extension

         point="org.eclipse.ui.commands">
      <command

            name="Sample Command"

            id="MITRIGGER.commands.sampleCommand">

      </command>

   </extension>

   <extension

         point="org.eclipse.ui.handlers">

      <handler

            commandId="MITRIGGER.commands.sampleCommand"

            class="mitrigger.handlers.SampleHandler">

      </handler>

   </extension>

  

   <extension

         point="org.eclipse.ui.menus">

      <menuContribution

            locationURI="menu:org.eclipse.ui.main.menu?after=additions">

         <menu

               label="Sample Menu"

            

               id="MITRIGGER.menus.sampleMenu">

            <command

                  commandId="MITRIGGER.commands.sampleCommand"

                

                  id="MITRIGGER.menus.sampleCommand">

            </command>

         </menu>

      </menuContribution>

    

    

      <menuContribution

            locationURI="toolbar:navigator_Toolbar?after=navigator_Toolbar1">

        

            <command

                  commandId="MITRIGGER.commands.sampleCommand"

                  icon="icons/cube.gif"

                  tooltip="MI-Call"

                  id="MITRIGGER.toolbars.sampleCommand">

            </command>

      

      </menuContribution>   

    

    

   </extension>

  

   <extension point="org.eclipse.ui.views">

      <view

         name="MI-CALL"

         class="mitrigger.view.CustomView"

         id="mitrigger.view.CustomView">

      </view>

   </extension>



</plugin>



MANIFEST.MF
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: MITRIGGER
Bundle-SymbolicName: MITRIGGER; singleton:=true
Bundle-Version: 1.0.0.qualifier
Bundle-Activator: mitrigger.Activator
Require-Bundle: org.eclipse.ui, org.eclipse.core.runtime
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.6

CustomeView.java
package mitrigger.view;
/**********************************************************************************************************************
 * Project Description : 1) Provide Custom icon in Manufacturing Process Planner Perspective.
 * 2) Click Action on Custom icon will show Custom view which look like 
 *
 * ________________________________________________________________
 * | |
 * | LabelName_1              TextBox_1 |
 * | |
 * | LabelName_2              TextBox_2 |
 * | |
 * | ----------------- ----------------- |
 * | | Button_Identify| |  Button_Cancel | |
 * | ------------------ ----------------- |
 * |_______________________________________________________________|
 *
 * 3) Click Action on Button_Identify will call some URL to get string name of EBOM line which we needs to highlight 
 *                       
************************************************************************************************************************/
import miconnect.JavaUrlConnectionReader; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.swt.SWT; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Text; import org.eclipse.ui.ISelectionListener; import org.eclipse.ui.IWorkbenchPart; import org.eclipse.ui.part.ViewPart;
public class CustomView extends ViewPart {
/** ID corresponding to the RCP declaration */     public static final String ID = CustomView.class.getName();         Label kitlabel;     Text kittxt;     Label installationlabel;     Text installationtxt;     public CustomView() { super(); } private ISelectionListener listener = new ISelectionListener() { public void selectionChanged(IWorkbenchPart sourcepart, ISelection selection) { // we ignore our own selections
if (sourcepart != CustomView.this) {
   showSelection(sourcepart, selection);
}
}
};
public void showSelection(IWorkbenchPart sourcepart, ISelection selection) {
//setContentDescription(sourcepart.getTitle() + " (" + selection.getClass().getName() + ")");
if (selection instanceof IStructuredSelection) {
IStructuredSelection ss = (IStructuredSelection) selection;
showItems(ss.toArray()); } }
  private void showItems(Object[] items) {

System.out.println("items.length ="+items.length);
   for(int i = 0 ; i < items.length; i++){
   System.out.println("My selected object "+ items[i].toString());
}
if(items.length>0) kittxt.setText(items[0].toString());
//tableviewer.setInput(items);
//pagebook.showPage(tableviewer.getControl());
}
@Override
public void createPartControl(Composite parent) {
// TODO Auto-generated method stub parent.setLayout(new GridLayout(4, false));
//GUI Component Definition Starts 
//1st Row //Label Definition  //kitlabel = new Label(parent, SWT.NONE); //kitlabel.setText("Kit"); //Text Field  Definition with its formating with grid data  //GridData gridDatakit = new GridData(GridData.FILL_HORIZONTAL); //gridDatakit.horizontalSpan = 2; //gridDatakit.grabExcessHorizontalSpace = true;
//kittxt = new Text( parent, SWT.READ_ONLY|SWT.SINGLE | SWT.BORDER );
//To change background colour use kittxt.setBackground(parent.getDisplay().getSystemColor( SWT.COLOR_WHITE ));  //kittxt.setBackground(parent.getDisplay().getSystemColor( SWT.COLOR_WHITE )); //kittxt.setLayoutData(gridDatakit);
//new Label(parent, SWT.NULL);
// 2nd row.
//Label Definition  installationlabel = new Label(parent, SWT.NONE); installationlabel.setText("URL Output");
//Text Field  Definition with its formating with grid data
GridData gridDatainstallation = new GridData(GridData.FILL_HORIZONTAL); gridDatainstallation.horizontalSpan = 2; gridDatainstallation.grabExcessHorizontalSpace = true;
installationtxt = new Text( parent,SWT.MULTI | SWT.BORDER | SWT.H_SCROLL
       | SWT.V_SCROLL); installationtxt.setLayoutData(gridDatainstallation);
GridData gridData = new GridData(GridData.FILL, GridData.FILL, true, true);
   gridData.horizontalSpan = 3;    gridData.grabExcessVerticalSpace = true;    installationtxt.setLayoutData(gridData); Label labelEmpty = new Label(parent, SWT.NULL);    labelEmpty.setText("                             ");    // last row.    new Label(parent, SWT.NULL); // kittxt.setText( "Readonly Data");
//Add Listner 
getSite().getWorkbenchWindow().getSelectionService().addSelectionListener(listener); //Get Manufacturing Process Planner(MPP) EBOM window
System.out.println("Perspective id is "+getSite().getPage().getPerspective().getId());
System.out.println("Perspective name is "+getSite().getPage().getPerspective().getLabel());
System.out.println("Perspective Description is "+getSite().getPage().getPerspective().getDescription());
JavaUrlConnectionReader miconnobj=new JavaUrlConnectionReader();
String mioutput =miconnobj.getUrlContents("http://www.java-samples.com/j2me/");
System.out.println("mioutput="+mioutput);
installationtxt.setText(mioutput); }
public void dispose() { // important: We need do unregister our listener when the view is disposed
getSite().getWorkbenchWindow().getSelectionService().removeSelectionListener(listener);
super.dispose();
}
 @Override
 public void setFocus() {
  // TODO Auto-generated method stub
  
 }
}
Sample Handeler
package mitrigger.handlers;
import org.eclipse.core.commands.AbstractHandler; import org.eclipse.core.commands.ExecutionEvent; import org.eclipse.core.commands.ExecutionException; import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.PartInitException; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.handlers.HandlerUtil; import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.IStructuredSelection;
/**
 * Our sample handler extends AbstractHandler, an IHandler base class.  * @see org.eclipse.core.commands.IHandler  * @see org.eclipse.core.commands.AbstractHandler  */ public class SampleHandler extends AbstractHandler { /** * The constructor. */ public SampleHandler() { }
/** * the command has been executed, so extract extract the needed information * from the application context. */ public Object execute(ExecutionEvent event) throws ExecutionException { try { PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView("mitrigger.view.CustomView"); } catch (PartInitException e) { // TODO Auto-generated catch block e.printStackTrace(); } return null; } }

Change Manager : Enable Change Manager

To enable Change Manager [If not already enabled] 
Go to Edit->Options and search
Preference name : HiddenPerspectives
Remove ChangeManger Value from Hiddenperspective if present in value list.
                                 
              

Create Change Object :
File->New->Change..

if it doesn't show window as shown below ...




That means Change Managemnet template feature is not installed  so
Follow Below steps:
 Run Environment Manager
 On Maintenance Window
   select  Configuration Manager
    press next   
 Configuration Maintenance Window
   select Perform maintenance on existing configuration
    press next
 Old Configuration
    press next
 Feature Maintenance
    press next
 Features
   expand Extentions
   inside it expand enterprise knowledge foundation
    select change management
        press next

shows some popup press ok

Lets Learn about change manager 


Why changemanager ?


- You can track changes to a product throughout its life cycle.

- You can propose a change to a product and then manage the entire cycle of review, approval, and    implementation of the change.

Change Objects :


  1. Problem Report
  2. Change Request also called Engineering Change Request
  3. Change Notice also called Engineering Change Notice
  4. Deviation Request



Problem Report:

- A PR clearly defines a problem or an enhancement.
- A PR may be addressed by multiple ECRs.
- Creating a PR is an optional step in the change process and depends on the company business process.


ECR:
- Initiates a proposal that recommends a change and captures business decisions associated with the change.
- An ECR is sometimes a response to a PR as it captures business decision.
- A single ECR may logically group and address issues identified in multiple PRs
- An ECR states the cost estimate and benefits of making a change and provides a recommended action

ECN:
- Provides a detailed work plan to resolve one or more ECRs or a portion of one ECR.
- An ECN identifies all items and documents affected by a change and authorizes the actions that address a change.

Deviation Request:
Seeks consent to deviate from a business case to resolve a set of problems.

there are two types of deviation requests:

–Request for deviation. Seeks consent to deviate from a part.
–Request for waiver. Seeks consent to deviate from a particular process.