cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Did you get an answer that solved your problem? Please mark it as an Accepted Solution so others with the same problem can find the answer easily. X

Find drawing referenced WtPart on POST_CHECKIN event

gfontana
8-Gravel

Find drawing referenced WtPart on POST_CHECKIN event

Hello everyone,

 I have developed this code that find all the WtPart refrenced by a drawing (.drw).

It's works fine on a stand alone Java application , but when I try to do the same on a POST_CHECKIN Listener the code is unable to find the referenced objects.

Is it matter of the calculation link ?

 

Thank you !

 

public static WTPart wtpRetrieveDrawingAssociatedWtPart(EPMDocument epm) throws Exception {
 
  WTPart wtPart = null;
 
  CADAssociatedParts relationship = new CADAssociatedParts();

   relationship.setTypes(CADAssociatedParts.Type.CALCULATED_BUILD);
  List<Object[]> epmDocs = EPMNavigateHelper.navigate(epm, relationship, CollectItem.SEED_ID, CollectItem.OTHERSIDE).getRawResults();
  if(epmDocs != null) {
   for(Object[] objects : epmDocs) {
    for(Object o : objects) {
     if(o instanceof WTPart) {
      WTPart tempPart = (WTPart) o;
      System.out.println("StandardListenService: " + epm.getName() + " WtPart referenced by" + tempPart.getName() + " " + tempPart.getNumber() );
      if(tempPart.isLatestIteration()) {
       if (tempPart.getName().toLowerCase().contains(".asm")) {
       wtPart = tempPart;
       break;
       }
      }
     }
    }
   }
  }
  return wtPart;
 }

1 ACCEPTED SOLUTION

Accepted Solutions

Hi @gfontana,

A quick suggestion, can you check and validate for POST_STORE event?

 

Regards,

Shirish

View solution in original post

4 REPLIES 4

Hi @gfontana,

A quick suggestion, can you check and validate for POST_STORE event?

 

Regards,

Shirish

Hi ShirishMorkhade,

I'm sorry for the delay in answer to your suggestion.

Anyway the POST_STORE work fine, so now i'm able to reload all calculated links 

 

Thank you very much

 

Giorgio

Hi Giorgio,

 

I am facing the same issue. 

 

I am trying to get the Reference EPMDocuments while checkin the Drawing using the POST_STORE  event.

 

Can I know which API you are using?

 

Thanks,

Hemanth Kumar

 

Hello Hemanth,
first of all thank you for the answer.

My problem was that, starting from a drawing, i had to retrieve the WtPart associated filtered them by a dependency type .
So inside a PUBLISH_COMPLETE listener i have implemented the method below that return an ArrayList of the WtPart that have a dependency type = 4 (establish used an empirical method).

/**
* Retrieve WTPart associated with Drawing (that is an EPMDocument) received as args
* based on Dependency type
* @param epm - working drawing (is an EPMDocument)
* @param deptype - int dependency type
* @return ArrayList of WTPart asscoiated if its exist otherwise null
* @throws Exception
*/
public static ArrayList alWtpRetrieveDrawingAssociatedWtPartByDepType(EPMDocument epm, int deptype) throws Exception {

ArrayList alWtPart = new ArrayList();

QueryResult ref = EPMStructureHelper.service.navigateReferences(epm, null, false);

while (ref.hasMoreElements()) {
Object o=ref.nextElement();
if (o instanceof EPMReferenceLink) {
EPMReferenceLink refLink = (EPMReferenceLink) o;
System.out.println("alWtpRetrieveDrawingAssociatedWtPartByDepType: " + refLink.getAsStoredChildName() + " dependency type " + refLink.getDepType());
if (refLink.getDepType() == deptype) {
Hashtable htcondummy = new Hashtable();
htcondummy.put("iterationInfo.latest", "TRUE");
htcondummy.put("state.state", "<>|OBSOLETE");
String sName = null;
for (int iIdx = 0; iIdx < refLink.getAllObjects().length; iIdx++) {
if (refLink.getAllObjects()[iIdx].getClass().getName().equals("wt.epm.EPMDocumentMaster")) {
sName = ((EPMDocumentMaster)refLink.getAllObjects()[iIdx]).getCADName(); // choose CADName of the EPMdocument Master object
break;
}
}
WTPart wtpDummy = sName != null ? wtpGetPartByNameOrNumber(true,sName,htcondummy) : null;
if (wtpDummy != null) alWtPart.add(wtpDummy);
}
}
}

return alWtPart;

}


This is working for me and I hope this will help you.
If somtehing is not clear fell free to call me on the phone .

Regards/Ciao

Giorgio
Top Tags