Throw Warning Message in Custom Listener
Version: Windchill 13.0
Description:
We have customized a PRE_WORKSPACE_CHECKIN listener to process an attachment file and populate attributes on the associated CAD document during the check-in process. It works great, but sometimes users forget to add the attachment, which results in none of the necessary attributes being populated. Is there a way to throw a warning (or error that can then be bypassed) to the user during check-in to tell them they are missing the attachment? Ideally I would like to call this in the custom listener.
public void notifyVetoableEvent(Object event) throws Exception{
if(!(event instanceof KeyedEvent)) {
return;
}
//Object target = ((KeyedEvent) event).getEventTarget();
Object type = ((KeyedEvent) event).getEventType();
if(type.equals(EPMWorkspaceManagerEvent.PRE_WORKSPACE_CHECKIN))
{
EPMWorkspaceManagerEvent wsEvent = (EPMWorkspaceManagerEvent) event;
WTSet workingCopies = ((WTKeyedMap) ((EPMWorkspaceManagerEvent) event).getWIPMap()).wtKeySet();
WTCollection epmDocs = workingCopies.subCollection(EPMDocument.class);
Iterator docItr = epmDocs.persistableIterator(EPMDocument.class, true);
while (docItr.hasNext()) {
EPMDocument epmDoc = (EPMDocument) docItr.next();
wt.fc.Persistable pers = (wt.fc.Persistable) epmDoc;
com.ptc.core.meta.common.TypeIdentifier tiObj = wt.type.ClientTypedUtility.getTypeIdentifier(pers);
String objType = tiObj.toString();
if( objType.endsWith("VOCCADDocument")) {
QCheckHelper qChecker = new QCheckHelper(epmDoc);
// WARNING THROW SHOULD HAPPEN HERE, PSUEDO CODE INCLUDED FOR REFERENCE
if (qChecker.hasQCFile() == false) {
new FeedBackMessage("Missing QC File! Continue check-in without adding?");
// IF USER CLICKS "PROCEED" BELOW CODE EXECUTES AND POPULATES WITH BLANK VALUES
// IF USER CLICKS "CANCEL" THE CHECK-IN IS ABORTED
}
// END OF PSUEDO CODE, REMAINING CODE WORKS AS EXPECTED
Map<String, String> attr_value_map = new HashMap<String, String>(7);
attr_value_map.put("QC_ACTACTION", qChecker.getActAction());
attr_value_map.put("QC_ASSESSMENT", qChecker.getAssessment());
attr_value_map.put("QC_CHECK_DATE", qChecker.getCheckDate());
attr_value_map.put("QC_CHECK_TIME", qChecker.getCheckTime());
attr_value_map.put("QC_CHECK_USER", qChecker.getCheckUser());
attr_value_map.put("QC_PROFILE_NAME", qChecker.getProfileName());
WTKeyedMap keyed_map = new WTKeyedHashMap(1);
keyed_map.put(epmDoc, attr_value_map);
EPMWorkspaceHelper.manager.setAttributes(wsEvent.getWorkspace() , keyed_map);
}
}
}
}

