public static boolean addNode(Properties ctx, String treeType, int Record_ID, String trxName)
	{
		// TODO: Check & refactor this
		// Get Tree
		int AD_Tree_ID = 0;
		MClient client = MClient.get(ctx);
		I_AD_ClientInfo ci = client.getInfo();
		if (TREETYPE_Activity.equals(treeType))
			AD_Tree_ID = ci.getAD_Tree_Activity_ID();
		else if (TREETYPE_BoM.equals(treeType))
			throw new IllegalArgumentException("BoM Trees not supported");
		else if (TREETYPE_BPartner.equals(treeType))
			AD_Tree_ID = ci.getAD_Tree_BPartner_ID();
		else if (TREETYPE_Campaign.equals(treeType))
			AD_Tree_ID = ci.getAD_Tree_Campaign_ID();
		else if (TREETYPE_ElementValue.equals(treeType))
			throw new IllegalArgumentException("ElementValue cannot use this API");
		else if (TREETYPE_Menu.equals(treeType))
			AD_Tree_ID = ci.getAD_Tree_Menu_ID();
		else if (TREETYPE_Organization.equals(treeType))
			AD_Tree_ID = ci.getAD_Tree_Org_ID();
		else if (TREETYPE_Product.equals(treeType))
			AD_Tree_ID = ci.getAD_Tree_Product_ID();
		else if (TREETYPE_ProductCategory.equals(treeType))
			throw new IllegalArgumentException("Product Category Trees not supported");
		else if (TREETYPE_Project.equals(treeType))
			AD_Tree_ID = ci.getAD_Tree_Project_ID();
		else if (TREETYPE_SalesRegion.equals(treeType))
			AD_Tree_ID = ci.getAD_Tree_SalesRegion_ID();
		if (AD_Tree_ID == 0)
			throw new IllegalArgumentException("No Tree found");
		MTree_Base tree = MTree_Base.get(ctx, AD_Tree_ID, trxName);
		if (tree.get_ID() != AD_Tree_ID)
			throw new IllegalArgumentException("Tree found AD_Tree_ID=" + AD_Tree_ID);
		// Insert Tree in correct tree
		boolean saved = false;
		if (TREETYPE_Menu.equals(treeType))
		{
			MTree_NodeMM node = new MTree_NodeMM(tree, Record_ID);
			saved = node.save();
		}
		else if (TREETYPE_BPartner.equals(treeType))
		{
			MTree_NodeBP node = new MTree_NodeBP(tree, Record_ID);
			saved = node.save();
		}
		else if (TREETYPE_Product.equals(treeType))
		{
			MTree_NodePR node = new MTree_NodePR(tree, Record_ID);
			saved = node.save();
		}
		else
		{
			MTree_Node node = new MTree_Node(tree, Record_ID);
			saved = node.save();
		}
		return saved;
	}
public static boolean addNode(Properties ctx, String treeType, int Record_ID, String trxName)
	{
	
	
		int AD_Tree_ID = 0;
		MClient client = MClient.get(ctx);
		I_AD_ClientInfo ci = client.getInfo();
		if (TREETYPE_Activity.equals(treeType))
			AD_Tree_ID = ci.getAD_Tree_Activity_ID();
		else if (TREETYPE_BoM.equals(treeType))
			throw new IllegalArgumentException("BoM Trees not supported");
		else if (TREETYPE_BPartner.equals(treeType))
			AD_Tree_ID = ci.getAD_Tree_BPartner_ID();
		else if (TREETYPE_Campaign.equals(treeType))
			AD_Tree_ID = ci.getAD_Tree_Campaign_ID();
		else if (TREETYPE_ElementValue.equals(treeType))
			throw new IllegalArgumentException("ElementValue cannot use this API");
		else if (TREETYPE_Menu.equals(treeType))
			AD_Tree_ID = ci.getAD_Tree_Menu_ID();
		else if (TREETYPE_Organization.equals(treeType))
			AD_Tree_ID = ci.getAD_Tree_Org_ID();
		else if (TREETYPE_Product.equals(treeType))
			AD_Tree_ID = ci.getAD_Tree_Product_ID();
		else if (TREETYPE_ProductCategory.equals(treeType))
			throw new IllegalArgumentException("Product Category Trees not supported");
		else if (TREETYPE_Project.equals(treeType))
			AD_Tree_ID = ci.getAD_Tree_Project_ID();
		else if (TREETYPE_SalesRegion.equals(treeType))
			AD_Tree_ID = ci.getAD_Tree_SalesRegion_ID();
		if (AD_Tree_ID == 0)
			throw new IllegalArgumentException("No Tree found");
		MTree_Base tree = MTree_Base.get(ctx, AD_Tree_ID, trxName);
		if (tree.get_ID() != AD_Tree_ID)
			throw new IllegalArgumentException("Tree found AD_Tree_ID=" + AD_Tree_ID);
	
		boolean saved = false;
		if (TREETYPE_Menu.equals(treeType))
		{
			MTree_NodeMM node = new MTree_NodeMM(tree, Record_ID);
			saved = node.save();
		}
		else if (TREETYPE_BPartner.equals(treeType))
		{
			MTree_NodeBP node = new MTree_NodeBP(tree, Record_ID);
			saved = node.save();
		}
		else if (TREETYPE_Product.equals(treeType))
		{
			MTree_NodePR node = new MTree_NodePR(tree, Record_ID);
			saved = node.save();
		}
		else
		{
			MTree_Node node = new MTree_Node(tree, Record_ID);
			saved = node.save();
		}
		return saved;
	}
public static boolean addnode(properties ctx, string treetype, int record_id, string trxname) { int ad_tree_id = 0; mclient client = mclient.get(ctx); i_ad_clientinfo ci = client.getinfo(); if (treetype_activity.equals(treetype)) ad_tree_id = ci.getad_tree_activity_id(); else if (treetype_bom.equals(treetype)) throw new illegalargumentexception("bom trees not supported"); else if (treetype_bpartner.equals(treetype)) ad_tree_id = ci.getad_tree_bpartner_id(); else if (treetype_campaign.equals(treetype)) ad_tree_id = ci.getad_tree_campaign_id(); else if (treetype_elementvalue.equals(treetype)) throw new illegalargumentexception("elementvalue cannot use this api"); else if (treetype_menu.equals(treetype)) ad_tree_id = ci.getad_tree_menu_id(); else if (treetype_organization.equals(treetype)) ad_tree_id = ci.getad_tree_org_id(); else if (treetype_product.equals(treetype)) ad_tree_id = ci.getad_tree_product_id(); else if (treetype_productcategory.equals(treetype)) throw new illegalargumentexception("product category trees not supported"); else if (treetype_project.equals(treetype)) ad_tree_id = ci.getad_tree_project_id(); else if (treetype_salesregion.equals(treetype)) ad_tree_id = ci.getad_tree_salesregion_id(); if (ad_tree_id == 0) throw new illegalargumentexception("no tree found"); mtree_base tree = mtree_base.get(ctx, ad_tree_id, trxname); if (tree.get_id() != ad_tree_id) throw new illegalargumentexception("tree found ad_tree_id=" + ad_tree_id); boolean saved = false; if (treetype_menu.equals(treetype)) { mtree_nodemm node = new mtree_nodemm(tree, record_id); saved = node.save(); } else if (treetype_bpartner.equals(treetype)) { mtree_nodebp node = new mtree_nodebp(tree, record_id); saved = node.save(); } else if (treetype_product.equals(treetype)) { mtree_nodepr node = new mtree_nodepr(tree, record_id); saved = node.save(); } else { mtree_node node = new mtree_node(tree, record_id); saved = node.save(); } return saved; }