cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

How to get primary attachment file in the CheckinObjectFormProcessor?

Highlighted

How to get primary attachment file in the CheckinObjectFormProcessor?

Hi!

I need to customize CheckinObjectFormProcessor. I need to get primary attached file that user insert in the checkin wizard. I've created my own CIObjectFormprocessor that extended OOTB CheckinObjectFormProcessor:

public class CIObjectFormProcessor extends CheckinObjectFormProcessor

{

  public FormResult doOperation(NmCommandBean paramNmCommandBean, List<ObjectBean> paramList) throws WTException

  {

     FormResult localFormResult = new FormResult();

     localFormResult.setStatus(FormProcessingStatus.SUCCESS);

   

      // Need there to get new primary attachment file

     localFormResult = super.doOperation(paramNmCommandBean, paramList);

     return localFormResult;

  }

}

localObjectBean.getParameterMap() can give me the Map with a lot of properties. But I can't to get the file I need. Please help.

1 REPLY 1

Re: How to get primary attachment file in the CheckinObjectFormProcessor?

Hi M Bagryanov‌,

you can try something like this:

/* (non-Javadoc)

  * @see com.ptc.windchill.enterprise.doc.forms.CreateDocFormProcessor#doOperation(com.ptc.netmarkets.util.beans.NmCommandBean, java.util.List)

  */

  @Override

  public FormResult doOperation(NmCommandBean arg0, List<ObjectBean> arg1) throws WTException {

       System.out.println("*** I am in doOperation method");

       HashMap map=getFormData(arg0);

       java.util.Set setOfKeys = map.keySet();

       java.util.Iterator iterator = setOfKeys.iterator();

       while (iterator.hasNext()) {

            String key = (String) iterator.next();

            Object value = (Object)map.get(key);

            System.out.println("\nKey: "+ key+", Value: "+ value);

            //PRIMARY_FILE_wt.content.ApplicationData:1423826261835_filePath

            if (key.startsWith("PRIMARY_FILE_wt.content.ApplicationData") && key.endsWith("_filePath")) {

                 String valueoffile = value.toString();

                 System.out.println("\t *** File is --- " +valueoffile);

                 File file = new File(valueoffile);

                 System.out.println("\t *** File Name - "+file.getName());

            }

       }

       return super.doOperation(arg0, arg1);

  }

  @SuppressWarnings("unchecked")

  protected static HashMap getFormData( NmCommandBean clientData ) throws WTException {

       HashMap formData = new HashMap();

       Map comboBoxData = null;

       Map radioData = null;

       Map textData = null;

       Map textAreaData = null;

       comboBoxData = clientData.getComboBox();

       radioData = clientData.getRadio();

       textData = clientData.getText();

       textAreaData = clientData.getTextArea();

       Map checkedData = clientData.getChecked();

       Map uncheckedData = clientData.getUnChecked();

       if (checkedData != null) {

            Iterator itChecked = checkedData.keySet().iterator();

            while (itChecked.hasNext()) {

                 formData.put(itChecked.next(), Boolean.TRUE.toString());

            }

       } // end if checkedData

       if (uncheckedData != null) {

            Iterator itUnchecked = uncheckedData.keySet().iterator();

            while (itUnchecked.hasNext()) {

                 formData.put(itUnchecked.next(), Boolean.FALSE.toString());

            }

       } // end if uncheckedData

       if(comboBoxData != null) {

            System.out.println("Prniting the comboBoxData::::" +comboBoxData);

            formData.putAll(comboBoxData);

       }

       if(radioData != null) {

            System.out.println("Prniting the radioData::::" +radioData);

            formData.putAll(radioData);

       }

       if(textData != null) {

            System.out.println("Prniting the textdata::::" +textData);

            formData.putAll(textData);

       }

       if(textAreaData != null) {

            System.out.println("Prniting the textAreaData::::" +textAreaData);

            formData.putAll(textAreaData);

       }

    

       return formData;

  }

It will give you an file name which user selects in wizard.

I hope this helps you.

Regards,

Shirish