How can load the class name from the available child class details

Hi Team,   I want to get the class name from the child (subclass)deatils. We have part & document as a class for the base class Item.  I have sublass called “XYZ” and details of it  like number, type etc , i am able to read it.  But in my code i need to check for  only Part type class not the Document type. Since i am reading the CO first to get  Affected Item and iterate to get item deatils.  while iteration only i want to check that the Affected item is of Document type and skip its check in my code. below code is available in the user guide . But i do not want to check it from the admin user deatils. IAgileClass[] classes = m_admin.getAgileClasses(IAdmin.CONCRETE); for (int i = 0; i < classes.length; i++) { if (classes[i].getTargetType() == IItem.OBJECT_TYPE) { System.out.println(“Class Name : ” + classes[i].getName()); System.out.println(“ID : ” + classes[i].getId()); } } }

Agile User Asked on June 6, 2022 in Product Collaboration.
Add Comment
3 Answer(s)

Personally, I usually check this by fetching the IAgileClass of the affected item, and then using the isSubclassOf method:

ITable affectedItems = ichg.getTable(ChangeConstants.TABLE_AFFECTEDITEMS);

Iterator it = affectedItems.Iterator();

while(it.hasNext()){

     IRow row =(IRow)it.next()

     IAgileClass subcls = row.getReferent().getAgileClass();

     if(subcls.isSubclassOf("Documents"){

         //ignore

     else if(subcls.isSubclassOf("Parts"){

     //DoSomething

     }

}

 

Agile Talent Answered on June 6, 2022.

Thanks!  It will help me

on June 8, 2022.
Add Comment
// This was added to the Actions menu of an Item. Groovy script.

// How to come up with a single, unique list of all components in a BOM, including all levels.
import com.agile.agileDSL.ScriptObj.IBaseScriptObj;

import com.agile.agileDSL.ScriptObj.AgileDSLException;

import com.agile.api.*;

import java.util.*;

import com.agile.px.IEventInfo;

import com.agile.px.EventConstants;

// import com.agile.px.IWFChangeStatusEventInfo;
import com.agile.px.IObjectEventInfo;
import java.util.*;

import java.util.regex.*;

import java.time.*;

import java.time.format.DateTimeFormatter;

import javax.activation.*;
void invokeScript(IBaseScriptObj obj) {
IAgileSession session = obj.getAgileSDKSession();

IEventInfo req = obj.getPXEventInfo();

int v_bomcnt = 0;
try {
IDataObject dataObject = eventInfo.getDataObject();

IAgileClass relObjectClass = dataObject.getAgileClass();
str_class = relObjectClass.getName();

obj.logMonitor("The subclass of the Items class is: " + str_class);
IItem pitem = dataObject;

String partnbr = (String) pitem.getValue(ItemConstants.ATT_TITLE_BLOCK_NUMBER);
// ----- Look at the BOM Table
ITable tblBom = pitem.getTable(ItemConstants.TABLE_BOM);

Iterator bomit = tblBom.iterator();

IRow bomrow = null;
while(bomit.hasNext()) {

bomrow = (IRow)bomit.next();

v_bomcnt = v_bomcnt + 1;

}
if( v_bomcnt > 0 ) {

ArrayList compList = []; // https://docs.oracle.com/javase/7/docs/api/java/util/ArrayList.html

ArrayList compListT = [];
// compList will become an array of every component from every level of the BOM, and as a unique list of item numbers.
compListT = explodeBOM(obj, pitem, 1, compListT);
for( String cmTmpVala : compListT ) {

if ( compList.contains( cmTmpVala )) {

// do not add duplicate value

} else {

compList.add(cmTmpVala);

}

}

// Output to the History tab of your item, a list of unique item numbers that are in the BOM of the top level parent.

for( String abcValue : compList ) {

obj.logMonitor("BOM component: " + abcValue );

}

}

catch (MessagingException ex) {

ex.printStackTrace();

obj.logMonitor(ex.getMessage());

// throw new AgileDSLException(ex);

}

}
//

// ------ explodeBOM ------

//

private static ArrayList explodeBOM(IBaseScriptObj obj, IItem item, int level, ArrayList cmList) throws APIException {
// This will look at the BOM for an item and add the components to an array named cmList.

IRow row;

String bomNumber;

ITable table = item.getTable(ItemConstants.TABLE_BOM);

Iterator it = table.iterator();

int addFlag = 1;
while (it.hasNext()) {

row = (IRow)it.next();

bomNumber = (String)row.getValue(ItemConstants.ATT_BOM_ITEM_NUMBER);

obj.logMonitor("level: " + (String)level + " part: " + bomNumber);
cmList.add(bomNumber);

IItem bomItem = (IItem)row.getReferent();
// This is a recursive routine. It calls itself. This way we can explode the BOM for every level. A full BOM explosion.

// The end result will be a unique list of all the component item numbers, from every level, appended to the array named cmList.

// We may end up with duplicate part numbers added to the array, but we will remove the dups later
cmList = explodeBOM(obj, bomItem, level + 1, cmList); // recursive call, add 1 to go to next BOM level

}

return (cmList);

}
Agile Talent Answered on July 1, 2022.
Add Comment

In my post above, I forgot to define eventInfo.  Add this:

try {

if (req instanceof IObjectEventInfo) {

eventInfo = (IObjectEventInfo)req;

} else {

obj.logMonitor("req IS NOT AN instanceof IObjectEventInfo");

}
if (eventInfo!=null) {

IDataObject dataObject = eventInfo.getDataObject();

IAgileClass relObjectClass = dataObject.getAgileClass();
:

Agile Talent Answered on July 1, 2022.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.