Disable or hide the create PDF action for documents which was enabled by DefaultUIComponentValidator
Version: Windchill 12.0
Use Case: user need not see the action of createPDF for WtDocuments which are inside one specific folder. user did not able to perform the action. that action was enabled by DefaultUIComponentValidator.
Description:
one of the subfolders, we used for storing all approved documents and Restricted documents. if this action enabled, it allows all users to recreate the PDF without stamps that may cause data changes that to for wt documents.
user need not see the action of createPDF for WtDocuments which are inside one specific folder. user did not able to perform the action. that action was enabled by DefaultUIComponentValidator.
i already created validator but it is not working. i cannot be able to see the logs in method server.
Here is the class example:
private UIValidationResultSet validateMenuEntry(UIValidationKey vkey, UIValidationCriteria vcriteria, Locale locale) throws WTException {
UIValidationResultSet vrs = UIValidationResultSet.newInstance();
WTReference wref = vcriteria.getPageObject();
Persistable object = wref.getObject();
log.debug("Validating menu entry for object: " + object);
if (object instanceof EPMDocument) {
System.out.println("object is EPM Document");
EPMDocument doc = (EPMDocument) object;
if (doc.getDocType().toString().equalsIgnoreCase(CADDRAWING)) {
System.out.println("object is : : " + doc.getDocType().toString());
vrs.addResult(UIValidationResult.newInstance(vkey, UIValidationStatus.ENABLED));
System.out.println("object is EPM Document-- CreatePDF action was enabled");
}
} else if (object instanceof WTDocument) {
WTDocument doc = (WTDocument) object;
String typeID = TypedUtility.getTypeIdentifier(doc).getTypename();
String containerName = doc.getContainer().getName();
System.out.println("object is ::" + typeID + " , " +containerName);
vrs.addResult(UIValidationResult.newInstance(vkey, UIValidationStatus.DISABLED));
log.debug("Document type: " + typeID);
log.debug("Container name: " + containerName);
if ((typeID.equals(EXTERNAL_DOC_TYPE) || INTERNAL_DOC_TYPE.equals(typeID))
&& (GLOBAL_STD_LB.equals(containerName) || BRAKING_ACTUATION.equals(containerName))) {
boolean isLicenseType = ZFPLMObjectHelper.getBooleanAttributeValue(doc, LICENSE_TYPE);
String folderLocation = FolderHelper.getLocation((CabinetBased) doc);
System.out.println("License and folder location is ::" + isLicenseType + " , " +folderLocation);
log.debug("License type: " + isLicenseType);
log.debug("Folder location: " + folderLocation);
if (isLicenseType || RESTRICTED_ACCESS_FOLDER.equals(folderLocation)) {
vrs.addResult(UIValidationResult.newInstance(vkey, UIValidationStatus.HIDDEN));
return vrs;
}
}
// Additional check for "Documents with Restricted Access" folder
String folderLocation = FolderHelper.getLocation((CabinetBased) doc);
System.out.println("folderlocation is : " + folderLocation);
if (RESTRICTED_ACCESS_FOLDER.equalsIgnoreCase(folderLocation)) {
System.out.println("Document is in 'Documents with Restricted Access' folder. Disabling action.");
log.debug("Document is in 'Documents with Restricted Access' folder. Disabling action.");
vrs.addResult(UIValidationResult.newInstance(vkey, UIValidationStatus.DISABLED));
return vrs;
}
if (ProceedJobHelper.isAllowedFormat(doc.getFormatName())) {
vrs.addResult(UIValidationResult.newInstance(vkey, UIValidationStatus.ENABLED));
}
}
System.out.println("Proceed Menu Entry is ended...");
return vrs;
}

