Add AVL by java code
here the code I use it : and awues having thsi exception : Loader method com.ptc.windchill.suma.axl.LoadAXL.addAVL reported a failure
No objects were imported due to the error.
found exception:wt.util.WTException: error to create AVL and AML: Message: Resource bundle/Message key = wt.ixb.publicforhandlers.ixbResource/8
wt.util.WTException: error to create AVL and AML: Message: Resource bundle/Message key = wt.ixb.publicforhandlers.ixbResource/8
*/
public static void linkLEONIPart2Partner(WTPart leoniPart,
VendorPart vendorPart, ManufacturerPart manuPart, String context)
throws WTException {
try {
File fData = File.createTempFile("leoparts", ".xml",
new File(LeoniPropertiesReader.get().getLeoniTempFolder()));
FileOutputStream fos = new FileOutputStream(
fData.getAbsolutePath(), false);
String content = "<?xml version='1.0' encoding='UTF-8'?>\n"
+ "<!DOCTYPE NmLoader SYSTEM 'standardX10.dtd'>\n"
+ "<NmLoader>\n";
if (vendorPart != null && manuPart == null) {
content = content
+ "<csvAddAVL handler='com.ptc.windchill.suma.axl.LoadAXL.addAVL'>\n"
+ "<csvOEMPartNumber>"
+ convertSpecialCharactersForXML(leoniPart.getNumber())
+ "</csvOEMPartNumber>\n"
+ "<csvOEMVersion/>\n"
+ "<csvOEMIteration/>\n"
+ "<csvOEMView/>\n"
+ "<csvOEMOrganizationID/>\n"
+ "<csvOEMOrganizationName/>\n"
+ "<csvsourcingContext>"
+ (context != null && context.length() > 0 ? context
: "Default")
+ "</csvsourcingContext>\n"
+ "<csvvendorPartNumber>"
+ convertSpecialCharactersForXML(vendorPart.getNumber())
+ "</csvvendorPartNumber>\n"
+ "<csvvendorName>"
+ convertSpecialCharactersForXML(vendorPart
.getOrganizationName())
+ "</csvvendorName>\n"
+ "<csvvendorID>"
+ vendorPart.getOrganizationCodingSystem()
+ "$"
+ vendorPart.getOrganization().getUniqueIdentifier()
+ "</csvvendorID>\n"
+ "<csvvendorPartContainer>/wt.inf.container.OrgContainer=LeoniUBB/wt.inf.library.WTLibrary="
+ vendorPart.getContainerName()
+ "</csvvendorPartContainer>\n"
+ "<csvvendorSourcingStatus>approved</csvvendorSourcingStatus>\n"
+ "<csvmanufacturerPartNumber></csvmanufacturerPartNumber>\n"
+ "<csvmanufacturerName></csvmanufacturerName>\n"
+ "<csvmanufacturerID></csvmanufacturerID>\n"
+ "<csvmanufacturerPartContainer></csvmanufacturerPartContainer>\n"
+ "</csvAddAVL>\n";
}
content = content + "</NmLoader>\n";
fos.write(content.getBytes("UTF-8"));
fos.close();
java.util.Hashtable hashtable = new java.util.Hashtable();
hashtable.put("CONT_PATH",
"/wt.inf.container.OrgContainer=LeoniUBB");
wt.load.LoadFromFile.doFileImport(fData.getAbsolutePath(), null,
null, "wcadmin", null, null, hashtable);
fData.delete();
} catch (Exception e) {
log.error(e.getMessage(), e);
throw new WTException("error to create AVL and AML: "
+ e.getMessage());
}
}

