Hello Team,
I am writing a WRS where we can pass attribute internal name and attribute value and cad oid , and it will update that attribute of given Cad object (with iteration changed).
For stand alone CAD , i succeed in achieving the requirement.However i am stuck with Family table object.
eg: if OID is of Generic or instance.
I am using below code snippet.
Please suggest what i am doing wrong here:
if(epm.isTopGeneric())
{
epmGeneric=epm;
System.out.println("******************Its a generic CAD*********************");
instanceDetailsMap=(Map<EPMDocument, WTHashSet>) getInstanceDetails(epm);
}
else {
System.out.println("*****************Its a Instance CAD *******************");
QueryResult ft_qr2 =EPMStructureHelper.service.navigateGenericToIteration( epm, null, true, null);
epm = (EPMDocument) ft_qr2.nextElement();//Generic Part
System.out.println("************ Fetched Generic from Instance ***********"+epm.getIdentity());
instanceDetailsMap = (Map<EPMDocument, WTHashSet>) getInstanceDetails(epm);
System.out.println("Collect all Instance for a given Instance by getting Generic first");
}
try {
Map<EPMDocument, Object> cadDocLMDMap = prepareCadDocLMDMap(instanceDetailsMap);
Map<EPMDocument, Object> ftStatusMap = prepareFTStatusMap(instanceDetailsMap.values());
WTHashSet collection = instanceDetailsMap.get(epm);
System.out.println("instanceSet size : " + collection.size());
collection.add(epm);
workspace = EPMWorkspaceHelper.manager.addToWorkspace(workspace, collection);
System.out.println("-------------Creating and Adding Objects to Workspace-------------");
EPMDocConfigSpec configSpec = new EPMDocConfigSpec();
configSpec.setLatestActive();
if (WorkInProgressHelper.isCheckedOut(epm)) {
System.out.println(epm.getNumber() + "----CAD Document is Already checked Out . ");
}
else {
List<EPMDocument> checkOutDrawings = new ArrayList<EPMDocument>();
List<EPMDocument> objectsToCheckOut = new ArrayList<EPMDocument>();
System.out.println("------Family Table Objects are checkedOUT----");
WTSet objectsInWorkspace = EPMWorkspaceHelper.manager.getObjectsInWorkspace(workspace, EPMDocument.class);
int count=collectFamilyInstances(epm);
System.out.println("=======NO OF Objects in Family Table is =========="+count);
List<EPMDocument> epmDocList = new ArrayList<>();
epmDocList.addAll(objectsInWorkspace);
checkout(epmDocList, workspace);
System.out.println("---------All workspace Objects are CheckedOUT----------");
HashMap<String, Object> ibaMap = new HashMap<>();
WTKeyedHashMap epmAttributeMap = new WTKeyedHashMap();
for (Iterator i_objects = objectsInWorkspace.persistableIterator(); i_objects.hasNext();) {
Workable epmInWorkspace = (Workable) i_objects.next();
epm = (EPMDocument) epmInWorkspace;
if(epm.isGeneric()) {
epmGeneric = (EPMDocument) PersistenceHelper.manager.refresh(epm);
}
objectsToCheckOut.add(epm);
checkOutDrawings.add(epm);
if (dataType.contains("Integer"))
{
int attrValue=Integer.parseInt(attrVal);
ibaMap.put(attribute, attrValue);
}
else if(dataType.contains("Boolean"))
{
boolean attrValue=Boolean.parseBoolean(attrVal);
ibaMap.put(attribute, attrValue);
}else if(dataType.contains("Double"))
{
double attrValue=Double.parseDouble(attrVal);
ibaMap.put(attribute, attrValue);
}
else if(dataType.contains("Long"))
{
long attrValue=Long.parseLong(attrVal);
ibaMap.put(attribute, attrValue);
}
else if(dataType.contains("Float"))
{
float attrValue=Float.parseFloat(attrVal);
ibaMap.put(attribute, attrValue);
}
if (dataType.contains("String"))
{
String attrValue=attrVal;
ibaMap.put(attribute, attrValue);
}
}
System.out.println("update Generic CADDocument :: CAD Document : " + epmGeneric.getNumber());
System.out.println("Generic is checkedout========"+WorkInProgressHelper.isCheckedOut(epmGeneric));
if (!ibaMap.isEmpty() && epmGeneric !=null) {
epmAttributeMap.put(epmGeneric, ibaMap);
System.out.println("before set att api epmAttributeMap: " +epmGeneric.getNumber() );
EPMWorkspaceHelper.manager.setAttributes(workspace, epmAttributeMap);
PersistenceHelper.manager.refresh(epmGeneric);
System.out.println("After set att api epmAttributeMap: " +epmGeneric.getNumber() );
}
List<Object> objectsToCheckIn = new ArrayList<Object>();
objectsToCheckIn.addAll(checkOutDrawings);
checkin(objectsToCheckIn, checkInComment, workspace);
System.out.println("Objects are checkedIn-------");
//destroyWorkspace(workspace);
if ( workspace != null) {
System.out.println("-----Going to delete workspace----------");
workspace = EPMWorkspaceHelper.manager.removeFromWorkspace(workspace, CollectionsHelper.singletonWTList(epm));
PersistenceHelper.manager.delete(workspace);
System.out.println("-----workspace Deleted----------");
}
updateFTStatus(ftStatusMap);
updateLMD(cadDocLMDMap);
System.out.println("Family Table Status and Last Modified Date Updated ");
System.out.println(" Transaction Details which is getting committed--------"+Transaction.getCurrentTransaction());
trx.commit();
trx = null;
System.out.println("EXIT : UpdateEPMDocServices.updateFT");
}
} catch (WTException e) {
e.printStackTrace();
System.out.println("WTException occurred while updating Attribute of generic document---"+e);
}
Error Message:
===========================================================================
0:52,057 INFO [ajp-nio-127.0.0.1-8010-exec-6] wt.system.out wcadmin - ---------All workspace Objects are CheckedOUT----------
2023-08-06 19:20:52,062 INFO [ajp-nio-127.0.0.1-8010-exec-6] wt.system.out wcadmin - update Generic CADDocument :: CAD Document : REFERENCES
2023-08-06 19:20:52,063 INFO [ajp-nio-127.0.0.1-8010-exec-6] wt.system.out wcadmin - Generic is checkedout========true
2023-08-06 19:20:52,063 INFO [ajp-nio-127.0.0.1-8010-exec-6] wt.system.out wcadmin - before set att api epmAttributeMap: REFERENCES
2023-08-06 19:20:52,129 INFO [ajp-nio-127.0.0.1-8010-exec-6] wt.system.err wcadmin - (wt.query.queryResource/9) wt.query.QueryException: Value array is empty for Search Condition.
2023-08-06 19:20:52,129 INFO [ajp-nio-127.0.0.1-8010-exec-6] wt.system.err wcadmin - at wt.query.SearchCondition.<init>(SearchCondition.java:1929)
2023-08-06 19:20:52,130 INFO [ajp-nio-127.0.0.1-8010-exec-6] wt.system.err wcadmin - at wt.query.SearchCondition.<init>(SearchCondition.java:1881)
2023-08-06 19:20:52,130 INFO [ajp-nio-127.0.0.1-8010-exec-6] wt.system.err wcadmin - at wt.epm.workspaces.WorkspaceAttributeManager.getFTAttributeColumns(WorkspaceAttributeManager.java:1317)
2023-08-06 19:20:52,131 INFO [ajp-nio-127.0.0.1-8010-exec-6] wt.system.err wcadmin - at wt.epm.workspaces.WorkspaceAttributeManager.getFamilyTablesInfo(WorkspaceAttributeManager.java:1112)
2023-08-06 19:20:52,131 INFO [ajp-nio-127.0.0.1-8010-exec-6] wt.system.err wcadmin - at wt.epm.workspaces.WorkspaceAttributeManager.setAttributes(WorkspaceAttributeManager.java:230)
2023-08-06 19:20:52,131 INFO [ajp-nio-127.0.0.1-8010-exec-6] wt.system.err wcadmin - at wt.epm.workspaces.EPMStandardWorkspaceManager.setAttributes(EPMStandardWorkspaceManager.java:812)
2023-08-06 19:20:52,131 INFO [ajp-nio-127.0.0.1-8010-exec-6] wt.system.err wcadmin - at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
2023-08-06 19:20:52,133 INFO [ajp-nio-127.0.0.1-8010-exec-6] wt.system.err wcadmin - at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
2023-08-06 19:20:52,133 INFO [ajp-nio-127.0.0.1-8010-exec-6] wt.system.err wcadmin - at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
2023-08-06 19:20:52,133 INFO [ajp-nio-127.0.0.1-8010-exec-6] wt.system.err wcadmin - at java.base/java.lang.reflect.Method.invoke(Method.java:566)
2023-08-06 19:20:52,133 INFO [ajp-nio-127.0.0.1-8010-exec-6] wt.system.err wcadmin - at wt.services.ServiceFactory$ServerInvocationHandler.invoke(ServiceFactory.java:399)
2023-08-06 19:20:52,133 INFO [ajp-nio-127.0.0.1-8010-exec-6] wt.system.err wcadmin - at com.sun.proxy.$Proxy124.setAttributes(Unknown Source)