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

Windchill Customization(Giving constraint to an attribute)

SOLVED

Re: Windchill Customization(Giving constraint to an attribute)

Theresa I implement your solution It working fine as a multiselect thanks for that ..

But what I want is a littile different .

I need the functionality of MultiValued attribute like that plus or minus button

Thanks everyone for your answers finally I got the answer after backtracking the OOTB functionality.

Re: Windchill Customization(Giving constraint to an attribute)

Hello,

I ve the same problem to resolve. Could you explain to me how you succeed to get a multi valuated component with suggested list? backtracking OOTB functionality? Tank's a lot. I am on the PDMLink 10.4.

Re: Windchill Customization(Giving constraint to an attribute)

Using this code has one demerit

The OOTB processor can’t persist the value so you have to write a custom processor also.

View solution in original post

Re: Windchill Customization(Giving constraint to an attribute)

Hi Kaushik,

Thanks for sharing the code. Please share the processor src too. this will help a lot.

Thanks in Advance.

Re: Windchill Customization(Giving constraint to an attribute)

Hi,

I assume that the IBA’s internal name is VendorName and it’s only in a specific subtype of WTDocument whose

internal name is com.ptc.Agenda.

For Create Mode :-

package ext.customization.processor;

import java.util.Arrays;

import java.util.Enumeration;

import java.util.HashSet;

import java.util.Iterator;

import java.util.List;

import javax.servlet.http.HttpServletRequest;

import wt.doc.WTDocument;

import wt.fc.ObjectReference;

import wt.fc.Persistable;

import wt.fc.PersistenceHelper;

import wt.folder.Folder;

import wt.util.WTException;

import com.ptc.core.components.beans.ObjectBean;

import com.ptc.core.components.forms.FormResult;

import com.ptc.core.lwc.server.LWCNormalizedObject;

import com.ptc.core.meta.common.TypeIdentifierHelper;

import com.ptc.core.meta.common.UpdateOperationIdentifier;

import com.ptc.netmarkets.util.beans.NmCommandBean;

import com.ptc.windchill.enterprise.doc.forms.CreateDocFormProcessor;

import com.ptc.windchill.wp.delivery.DeliveryRecord;

public class CustomDocProcessor extends CreateDocFormProcessor

{

@SuppressWarnings({ "rawtypes", "unchecked" })

@Override

public FormResult postProcess(NmCommandBean paramNmCommandBean,

List<ObjectBean> paramList) throws WTException

{

/* Taking the object of WTDocument which is created form the CreateDocFromProcessor*/

WTDocument localWTDocument = null;

for (Iterator localIterator = paramList.iterator(); localIterator.hasNext(); )

localWTDocument = (WTDocument)(((ObjectBean)localIterator.next()).getObject());

try{ /* Checking whether the WTDocument is of desired subtype */

if(( TypeIdentifierHelper.getType(localWTDocument).toString().equals("WCTYPE|wt.doc.WTDocument|

com.ptc.Agenda ")))//internal name of your subtype

{

HttpServletRequest req = paramNmCommandBean.getRequest();

Enumeration em = req.getParameterNames();

String temp = null;

while(em.hasMoreElements())

{

String name="VendorName";//internal name of your iba

String old = "old";

temp = em.nextElement().toString();

if(temp.contains(name) && !temp.endsWith(old))

break;

}

//Giving value to the soft attribute

LWCNormalizedObject obj = new LWCNormalizedObject(localWTDocument,null,null,new

UpdateOperationIdentifier());

//removing duplicate value

obj.load("VendorName");

obj.set("VendorName",(String[])new HashSet( Arrays.asList( req.getParameterValues(temp) )

).toArray( new String[]{} ));

/*persisting the value of IBA after removing duplicate value*/

obj.apply();

PersistenceHelper.manager.modify(localWTDocument);

}

}

catch(WTException e)

{

e.printStackTrace();

}

// TODO Auto-generated method stub

return super.postProcess(paramNmCommandBean, paramList);

}

}

Re: Windchill Customization(Giving constraint to an attribute)

For Edit

package ext.customization.processor;

import java.util.*;

import javax.servlet.http.HttpServletRequest;

import wt.doc.WTDocument;

import wt.fc.PersistenceHelper;

import wt.util.WTException;

import com.ptc.core.components.beans.ObjectBean;

import com.ptc.core.components.forms.EditWorkableFormProcessor;

import com.ptc.core.components.forms.FormResult;

import com.ptc.core.lwc.server.LWCNormalizedObject;

import com.ptc.core.meta.common.TypeIdentifierHelper;

import com.ptc.core.meta.common.UpdateOperationIdentifier;

import com.ptc.netmarkets.util.beans.NmCommandBean;

public class CustomEditDocProcessor extends EditWorkableFormProcessor

{

@SuppressWarnings("rawtypes")

@Override

public FormResult postProcess(NmCommandBean paramNmCommandBean,

List<ObjectBean> paramList) throws WTException

{

WTDocument localWTDocument = null;

for (Iterator localIterator = paramList.iterator(); localIterator.hasNext(); )

localWTDocument = (WTDocument)(((ObjectBean)localIterator.next()).getObject());

/* Taking the object of WTDocument which is created form the EditWorkableFormProcessor*/

try

{

if( (

TypeIdentifierHelper.getType(localWTDocument).toString().equals("WCTYPE|wt.doc.WTDocument|com.ITCINFOTECH.VendorPart")))

{

HttpServletRequest req = paramNmCommandBean.getRequest();

Enumeration em = req.getParameterNames();

String temp = null;

while(em.hasMoreElements())

{

String name="VendorName";

String old = "old";

temp = em.nextElement().toString();

if(temp.contains(name) && !temp.endsWith(old))

break;

}

//Giving value to the soft attribute

LWCNormalizedObject obj = new LWCNormalizedObject(localWTDocument,null,null,new

UpdateOperationIdentifier());

@SuppressWarnings({ "unchecked" })

String[] s = (String[])new HashSet( Arrays.asList( req.getParameterValues(temp) ) ).toArray( new

String[]{} );

List<String> list = new ArrayList<String>();

for(String str : s)

{

if(str != null && str.length() > 0)

{

list.add(str);

}

}

s = list.toArray(new String[list.size()]);

/* After removing any blank string from String array */

obj.load("VendorName");

obj.set("VendorName",s);

obj.apply();

PersistenceHelper.manager.modify(localWTDocument);

}

}

catch(WTException e)

{

e.printStackTrace();

}

// TODO Auto-generated method stub

return super.postProcess(paramNmCommandBean, paramList);

}

}

Thanks And Regards,

Kaushik

Re: Windchill Customization(Giving constraint to an attribute)

Hi Kaushik,

Is there a way to fetch all the attributes for a given subtype?

Is there a way to pull the metadata of the fetched attribute?

For example, i have a subtype of "CustomerExperience" object and many attributes configured on this subtype.

I am trying to fetch all the MBA(Model Based Attributes) and IBA(Instances Based Attributes), and after that fetch all the constraints,default values, datatype etc.. i.e metadata of the attribute

Thanks

RK

Re: Windchill Customization(Giving constraint to an attribute)

Hi RK,

To fetch all the IBA's of a given softtype use below method.

public static ArrayList<String> getIBAInformationForSoftType(

String internalName) {

ArrayList<String> logicalNames = new ArrayList<String>();

LogicalIdentifierFactory factory = new LogicalIdentifierFactory();

TypeIdentifier ti = factory.newWCTypeIdentifier(internalName);

GetSoftSchemaAttributesCommand command = new GetSoftSchemaAttributesCommand();

command.setType_id(ti);

try {

command = (GetSoftSchemaAttributesCommand) command.execute();

AttributeTypeIdentifierSet atis = command.getAttributes();

Iterator iter = atis.iterator();

while (iter.hasNext()) {

AttributeTypeIdentifier ati = (AttributeTypeIdentifier) iter

.next();

if (!ati.getAttributeName().equals("view")) {

try {

String name = ati.toLogicalForm();

logicalNames.add(name);

System.out.println("Logical identifier of the IBA :- " + name);

} catch (Exception e) {

e.printStackTrace();

}

}

}

} catch (CommandException e) {

e.printStackTrace();

}

return logicalNames;

}

Thanks,

Kaushik

Re: Windchill Customization(Giving constraint to an attribute)

Hi Kaushik,

Happy new year. Thanks you so much for repying.

I tried the snippet however it fetches only the IBAs. I am trying to fetch both IBAs and MBAs, i.e. all attributes(instance based and model based). Any furthur updates on all attributes is really helpful.

Thanks

RK

Re: Windchill Customization(Giving constraint to an attribute)

Hello Ramakrishna,

Happy new year to you to.

For MBA try below snippet.

public static ArrayList<String> getIBAInformationForHardType(String className) {

ArrayList<String> attributes = new ArrayList<String>();

LogicalIdentifierFactory factory = new LogicalIdentifierFactory();

TypeIdentifier ti = factory.newWCTypeIdentifier(className);

GetHardSchemaAttributesCommand command = new GetHardSchemaAttributesCommand();

command.setType_id(ti);

try {

command = (GetHardSchemaAttributesCommand) command.execute();

AttributeTypeIdentifierSet atis = command.getAttributes();

Iterator iter = atis.iterator();

while(iter.hasNext()){

AttributeTypeIdentifier ati = (AttributeTypeIdentifier) iter.next();

if(!ati.getAttributeName().equals("view")){

String name = ati.getAttributeName();

System.out.println(name);

attributes.add(name);

}

}

} catch (CommandException e) {

e.printStackTrace();

}

return attributes;

}

------------------------------------------------------------------------------

getIBAInformationForHardType("wt.doc.WTDocument")

Thanks and Regards,

Kaushik

Announcements
LiveWorx Call For Papers Happening Now!