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

Community Tip - If community subscription notifications are filling up your inbox you can set up a daily digest and get all your notifications in a single email. X

How to use multithreading for getting WhereUsed Objects?

shindemayur
14-Alexandrite

How to use multithreading for getting WhereUsed Objects?

Hi, 

I have a list of parts and I want to get WhereUsed objects of them. As the data is very big , its taking too long time. so I want to implement multi threading .

This is my  code : 

 

for(WTPart part:setofparts)
    {
     /*ArrayList<Object> objectsList=new ArrayList<>();
     objectsList.add(new HashSet<String>());
     objectsList.add(new HashSet<String>());
     objectsList.add(new ArrayList<String>());
     
     getPartStructure(part, objectsList);    
     dataMap.put(part, objectsList);*/

}

 private   static ArrayList<Object> getPartStructure(WTPart part,ArrayList<Object> objectList )
 {
  try
  {  
   ArrayList<String> set=new ArrayList<>();
    QueryResult resultWhere=StructHelper.service.navigateUsedBy(part.getMaster(),true);  
   
   while (resultWhere.hasMoreElements())
   {
    Object object = (Object) resultWhere.nextElement();  
    if(object instanceof WTPart)
    { 
     WTPart prt=(WTPart) object;
     prt=(WTPart) VersionControlHelper.service.allIterationsOf(prt.getMaster()).nextElement();     
     if(!set.contains(prt.getNumber()))
     {
      set.add(prt.getNumber());
      if(prt.isEndItem())
      {
       String vehicleFamily=getIBAValue(prt,"VehicleFamily_Abbreviation");
       if(vehicleFamily!=null && !vehicleFamily.equals(""))
       {
        HashSet<String>familyList=(HashSet<String>)objectList.get(0);
        familyList.add(vehicleFamily);
       }
       else
       {
        HashSet<String>UndisclosedFamilyList=(HashSet<String>)objectList.get(1);
        UndisclosedFamilyList.add(prt.getNumber());
       }
       ArrayList<String>list=(ArrayList<String>)objectList.get(2);
       list.add(prt.getNumber()+" "+vehicleFamily);
      }else{
      getPartStructure(prt,objectList);
      }
     }
    }
   }
  }catch (Exception ex)
  {
   ex.printStackTrace();
  }
  return objectList;
 }

1 REPLY 1

Hi

The way you are trying to implement this is not really the best way in my opinion. You are thinking about a front-end implementation like if it's a server side service. Two technical ideas to make your need possible:

1- You should look at the WTCollection documentation as ptc has rewritten all it's query API to accept single object and collection of object at the same time. So not sure about the where used but you can find navigateUsageLink version that accepts a collection of objects and returns a WTList of results. 

2- if you still wan to make a multithreaded like behavior Javascript promise object can help you implement similar behavior at the frontend. but this assume you have a fully customized UI that calls §Rest API or SOAP webjects as the OOTB SpringMVC will not support such behavior.

 

Hope this helps.

 

Kamal, 

https://www.pasi-consulting.com/dev-app-entreprises/

Announcements

Top Tags