Community Tip - When posting, your subject should be specific and summarize your question. Here are some additional tips on asking a great question. X
As per the original post.
Hi @cblaumeier ,
I am currently having the same issue. I am not quite sure what you mean. I tried loading all classifications branches from where the attribute lies up to the root. I also tried some other approaches but no matter what I try, I always receive null when executing .getConstraints() or .getLegalValueSet().
Could you please explain this in more detail. What exactly do I need to load before loading the attribute itself?
Best regdards
Example snippet:
// Have to pass a valid locale that Windchill knows
var adapter = new PersistableAdapter(obj, null, new Locale("en"), new ChangeOperationIdentifier());
// Have to load the classification binding attribute as well as the classification attribute
var list = new ArrayList();
list.add(attributeName); // name of classification binding attribute
list.add(attributeName2); // some attribute on the class node that is specified in the classification binding attribute
adapter.load(list);
// This should now give valid descriptors in the specified locale and thus, valid constraints
var descriptor1 = adapter.getAttributeDescriptor(attributeName);
var descriptor2 = adapter.getAttributeDescriptor(attributeName2);
print("legalValueSet1: " + descriptor1.getLegalValueSet()); // not null
print("legalValueSet2: " + descriptor2.getLegalValueSet()); // not null
The output then looks like this:
legalValueSet1: [com.ptc.csm.default_clf_namespace,TestClass1]
legalValueSet2: [Test1,Test2,Test3]
also note that the PersistableAdapter requires either the logical identifier to be set equal to the internal name of the global attribute, or the attribute names have to specified like "IBA|attributeName" instead of just "attributeName".
Hi @cblaumeier, Thanks for your help. unfortunately, I was not able to solve it that way, probably because of an invalid ID or an invalid binding attribute. Or maybe there is a problem with our Windchill. The following approach worked for me:
TypeDefinitionReadView clfNodeView = TypeDefinitionServiceHelper.service.getTypeDefView(AttributeTemplateFlavor.LWCSTRUCT,
"com.ptc.csm.default_clf_namespace", "<Classification Node Internal Name>");
AttributeDefinitionReadView adrv = clfNodeView.getAttributeByName("<Classification Attribute Internal Name> ");
Collection<ConstraintDefinitionReadView> constraints = adrv.getAllConstraints();
System.out.println("constraints======>"+constraints);