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

We are working to address an issue with subscription email notifications. In the meantime, be sure to check your favorite boards for new topics.

how can i retrieve attribute constraints (for parts classification)

tbone7281
5-Regular Member

how can i retrieve attribute constraints (for parts classification)

Windchill 11.2

REST API 1.7

 

Hello all,

  I’ve been trying to pull the attribute constraints for parts classification but have been coming up short.  I’ve found a few things that seem promising at first glance, but results end up being… confusing.

 

PTC Documentation says that the follow are the “Classification Constraint Types”:

Enumerated Value List

External Enumerated Value List

Immutable

Legal Value List

Lowercase

No Duplicate Values

Regular Expression

Required

Single-Valued

String Format (deprecated, use regular expression now)

String Length

Suggested Value List

Uppercase

Valid Range

Wildcard

 

I probably don’t need to get all of them.  The most important ones would be Legal Value List, Valid Range, String Length, and Required since these seem to be used the most.  (Knowing how to get all of them would be great though.)

 

1.  Windchill REST API (1.7 API V2):  The PTC Classification Structure Domain has /GetEnumTypeConstraintOnClfAttributes(nodeInternalName={nodeInternalName},clfStructureNameSpace={clfStructureNameSpace},attributeInternalName={attributeInternalName}).  This seems promising, but it’s not clear to me which type constraints are considered “Enum”.  The following is an example using WC demo data for parts classification.

  /Windchill/servlet/odata/v2/ClfStructure/GetEnumTypeConstraintOnClfAttributes(nodeInternalName='THRUST',clfStructureNameSpace='com.ptc.csm.default_clf_namespace',attributeInternalName='CA9DBB6E35d')

 

So this does return a Legal Value List AND the default value for it.  The problem being that the Legal Value List is only one of 3 constraints this attribute actually has.  Where are String Length and Single-Valued?  I realize those aren’t considered Enum Types so it would make sense that they wouldn’t be returned by this call, but I also see no way of pulling them via the REST API either.

 

2.  Windchill API:  In particular, the AttributeTypeSummary object seemed promising, but much like the REST API, I’m not seeing all of the information brought back that I would expect.  Methods I can get to from AttributeTypeSummary include:

  1. getConstraints (deprecated)
  2. getStringLengthSet
    1. getMaxStringLength
    2. getMinStringLength
  3. getLegalValueSet
  4. getSuggestedValueSet
  5. getCardinalitySet
    1. getMaxCardinality
    2. getMinCardinality
  6. getStringByteLengthSet
    1. getMaxStringByteLength
    2. getMinStringByteLength
  7. isRequired
  8. requiredNoDuplicateValues

At this point, the only ones that I’m pretty sure are bringing back valid data are the ones for String Byte Length.  And this is still confusing because based on the data and how the UI displays things, this appears to actually be String Length.

 

Using the same example as above (classificationNode = Thrust, attribute = Thrust Type), the call for GetStringLengthSet is null, but GetStringByteLengthSet is not and show min of 0, max of 500.

 

 

At this point, I’m running out of ideas.  Does anyone have any idea why what I’m trying to do doesn’t seem to work?  (As in, why does the REST API look like it’s incomplete and why do most of the methods associated with AttributeTypeSummary appear to not do anything?)

 

Is there some kind of constraint list service that I’ve just not stumbled across?  I just feel like getting constraints should be a fairly trivial task, but here I am.

 

Thanks in advance for any help or insight, I appreciate it!

 

-Tony

1 REPLY 1
cblaumeier
4-Participant
(To:tbone7281)

Hi,

 

to make the PersistableAdapter read the constraints and localizations of PartsLink attributes, the list of attributes to load must contain the main classification attribute (the IBA that holds the internal name of the class node on the WTPart).

If you only load attributes that are part of a classification without loading also the classification, then getLegalValueSet() etc. will return null.

 

Best Regards

Christian

 

Top Tags