Issue using PersistableAdapter to set an int
For a few workflows I've created methods to set an object's attribute (one for String, one for TimeStamps) which have worked great over the past few years. I have a new requirement to set an int's value. I created a new method and changed the input attribute to accept an int. When I call the method, i get an odd error telling me I've violated the limit constraint. The value I'm sending is 2 which should not cause any issues.
wt.system.err Administrator - com.ptc.core.meta.container.common.ConstraintException: The value for Number Of Cavities must be between -9,223,372,036,854,775,808 and 9,223,372,036,854,775,807, inclusive.
The method i have is the following
public static void setAttributeValue(WTObject pbo, String IBAName,int IBAValue) {
PersistableAdapter obj;
try {
obj = new PersistableAdapter(pbo, null,Locale.US, new UpdateOperationIdentifier());
obj.load(IBAName);
System.out.println("Attribute " + IBAName + " value is " + IBAValue);
obj.set(IBAName,IBAValue);
obj.apply();
PersistenceHelper.manager.modify(pbo);
} catch (WTException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (NullPointerException e) {
System.out.println("Null Pointer Encounterd In Code");
e.printStackTrace();
}
}
This method is called by the following method to checkout the doc and check it in
public static String setFaiDocumentAttributes(WTDocument doc,String checkinComment,String attName,int attValue,Boolean checkinDoc) {
try {
if (WorkInProgressHelper.service.isLocked(doc) == false) {
doc = (WTDocument)WorkInProgressHelper.service.checkout(doc,WorkInProgressHelper.service.getCheckoutFolder(), "").getWorkingCopy();
} else {
doc = (WTDocument)WorkInProgressHelper.service. workingCopyOf(doc);
}
ChangeWorkflowHelper.setAttributeValue(doc,attName,attValue);
checkinComment += attName + ": " + attValue + "\n";
} catch (WTPropertyVetoException | WTException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
if (checkinDoc) {
try {
wt.vc.wip.WorkInProgressHelper.service.checkin(doc, checkinComment);
} catch (WorkInProgressException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (WTPropertyVetoException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (PersistenceException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (WTException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
return checkinComment;
}
Through the UI, I can set the attribute to the value 2. I've also added a limit constraint from 0 - max int size and the error message using the API was still showing the range violation of -max int size - positive max int size.

