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

Community Tip - Stay updated on what is happening on the PTC Community by subscribing to PTC Community Announcements. X

Translate the entire conversation x

Persistable Object cannot read State with View Operation Identifier

AM_9930586
6-Contributor

Persistable Object cannot read State with View Operation Identifier

Version: Windchill 13.0

 

Use Case: I am working on an InfoEngine Task that queries for multiple object types, as well as several attributes from each object, with a read-only Operation Identifier.


Description:

Dear PTC Community,

 

I've encountered some frustratingly strange behavior, and can't wrap my head around why this is happening.

 

In our I*E Task, we take a list of input objects, and create new PersistableAdapters to access the data within:

 

PersistableAdapter pa = new PersistableAdapter(object, null, SessionHelper.getLocale(), OperationIdentifier.newOperationIdentifier(OperationIdentifierConstants.VIEW));

 

For this case of Attribute  `state.state`, we process it as follows (abbreviated):

PersistableAdapter objAdapter = pa;

AttributeTypeSummary ats = objAdapter.getAttributeDescriptor(attribute);
DataSet ds = ats.getLegalValueSet();

if (ds != null && ds instanceof EnumeratedSet && loadedValue != null){		
    LWCEnumerationEntryValuesFactory eevf = new LWCEnumerationEntryValuesFactory();
    EnumerationEntryIdentifier eei = ((EnumeratedSet) ds).getElementByKey(loadedValue.toString());
    if (eei instanceof ModeledEnumerationEntryIdentifier){
        ModeledEnumerationEntryIdentifier meei = (ModeledEnumerationEntryIdentifier) eei;
        String className = meei.getContext().getName();
        wt.fc.EnumeratedType cls = wt.fc.EnumeratedTypeUtil.toEnumeratedType(className, loadedValue.toString());
        return cls.getDisplay().toString();
    }
    else{
        return eevf.get(eei, Locale.ENGLISH).getDisplay().toString();
}

 

 

In the resulting MethodServer logs, we catch the following error, and receive no value for `state.state`:

[ajp-nio-127.0.0.1-8010-exec-7] wt.system.out wcadmin - com.ptc.core.meta.container.common.ConstraintException: The value for State cannot be changed. 

 

This alone is strange to me. As far as I can tell, I've followed docs and guidelines pretty well, and can't wrap my head around why this would happen with `wcadmin`. We set a read-only Operation type, but why does it think we're trying to Write?

 

I'd appreciate any insight the community may have, as this particular I*E Task has been a project in of itself.

 

Addendum:

 

A colleague told me to use `null` OperationIdentifier on the `pa`, and it actually worked. There were no complaints in the MethodServer logs about `state.state`. Nice, and it lets me keep working, but this seems like a band-aid solution.

3 REPLIES 3

Article - "Exception "com.ptc.core.meta.container.common.ConstraintException: The value for XXX cannot be changed." while updating Instance Based Attribute(IBA) using PersistableAdapter API in Windchill": https://www.ptc.com/en/support/article/CS387857 

TDT
15-Moonstone
15-Moonstone
(To:AM_9930586)

Hi @AM_9930586,

Can you use the following API and Check

PersistableAdapter pa = new PersistableAdapter(object, null, SessionHelper.getLocale(), new DisplayOperationIdentifier());

AM_9930586
6-Contributor
(To:TDT)

Just tried it out, and no luck on pulling the State. 

Announcements
Top Tags