搜索并添加 零件与零件族关系的创建过程

搜索并添加 零件与零件族关系的创建过程

 

背景:公司实施了零件族管理模块(PFM),从零件相关项界面点击“搜索并添加”进入搜索界面,选“叶节点族”进行搜索后将所有叶节点族搜索出来提供用户选择一个与当前零件建立关系。

要求:建立零件分类与零件族的配置关系,在用户搜索“叶节点族”进行与零件创建关系的时候,仅仅选出由配置关系定义了的零件族。

实现:

CS端用户输入零件的obid,返回配置相关的零件族对象集合,CS的开发注意要在QueryDb之后对FamilySet中的每个对象调用InflateAllDynamicAttrs方法,确保其显示的正确性:
Java API

MTIObjectVector k2cGetCfgPrtFams(TaskContext taskC, String className, String prtobid);

定义Java Processor类PartFamiliesProcessor,用于调用CS端API:
mtidata  =  K2C. k2cGetCfgPrtFams (getTaskContext(),  " Assembly " , partObid);
int  count  =  mtidata  ==   null   ?   0  : mtidata.size();
Vector list 
=   new  Vector(count);
for ( int  i  =   0 ; i  <  count; i ++ )
{
list.add(
new  com.sdrc._metaphase.enterprise.es_evista.omf.find.Found(mtidata.elementAt(i)));
}
return  list;

定义Java ActionComponent类RedirectRelLeafFamHandler,用于在用户点击搜索的时候判断是重定向到客户化功能点还是系统默认:
String bgClassName  =  (String)arguments.getString( " inBgClassName " );
String schClassName 
=  (String)arguments.getString( " inSchClassName " );

OptionSet options 
=  action_context.getOptionSet();
if  ( bgClassName  !=   null   &&  bgClassName.equals( " Assembly " &&  schClassName.equals( " LeafFam " ) )
{
    
return  options.getOption( " success " );  //  重定向到客户化功能
}
else
{
    
return  options.getOption( " failure " );  //  使用系统默认
}

修改用户点击“搜索”按钮的默认action,原来为(eds_search_link_submit_advanced_class)
< edit  parent ="/PageInfo/PageElements/SearchNestedSearchNext" >
    
< change >
        
< map >
            
< entry  key ="action"  value ="javascript:formsubmit_advanced('bbk_search_link_submit_advanced_class');"   />
        
</ map >
    
</ change >
</ edit >

在application-map.xml中添加以下代码:
<!--  ***************************************************************  -->
<!--  从零件 创建与零件族关系的时候,通过数据集配置查询零件族              -->
<!--  ***************************************************************  -->
< link  id ="bbk_search_link_submit_advanced_class"
    response-chain
="bbk_search_resp_chain_submit_advanced_class" />

< response-chain  id ="bbk_search_resp_chain_submit_advanced_class" >
    
< chain-options >
        
< option  id ="success"  advance ="true" />
        
< option  id ="failure"  page ="failurepage" />
    
</ chain-options >

    
< action-component  id ="store_search_class_in_context"
        handler
="com.edsplm.tc.ent._wcc.mwau.actioncomponents.extractor.CloneVariable" >
        
< component-input  id ="inAttribute"  source ="search_class"   />
        
< component-output  id ="outAttribute"  destination ="eds_search_class_name"   />
    
</ action-component >
    
    
<!--  判断当前是否为 零件搜索添加零件族,如果是则需要重定向到客户化功能点  -->  
    
< action-component  id ="detect_background_class_is_assembly"
        handler
="com.bbk.RedirectRelLeafFamHandler" >
        
< component-input  id ="inBgClassName"  source ="eds_search_background_class_name"   />
        
< component-input  id ="inSchClassName"  source ="eds_search_class_name"   />
        
< option  id ="success"  advance ="true" />
        
< option  id ="failure"  response-chain ="eds_search_resp_chain_submit_advanced_class" />
    
</ action-component >

    
< final-option  response-chain ="bbk_get_config_families_from_assembly"   />
</ response-chain >

<!--  该 response-chain 从系统 eds_search_resp_chain_do_search 上作了一定的修改  -->
< response-chain  id ="bbk_get_config_families_from_assembly" >
    
< chain-options >
        
< option  id ="success"  advance ="true" />
        
< option  id ="failure"  page ="failurepage" />
    
</ chain-options >
    
    
<!--  调用CS,获取与物料相关的零件族对象  -->
    
< action-component  id ="get_families"  handler ="com.bbk.GetPartFamiliesAction" >
        
< component-input  id ="inBgClassName"  source ="eds_search_background_class_name"   />
        
< component-input  id ="inSchClassName"  source ="eds_search_class_name"   />
        
< component-input  id ="inBgItemHandle"  source ="eds_global_background_item_handle"   />
        
< component-output  id ="outSearchResults"  destination ="eds_search_results"   />
        
< component-output  id ="outFoundItemsCount"  destination ="eds_search_found_items_count"   />
        
< option  id ="noResultsFound"  action-component ="eds_search_prepare_display_no_results" />
    
</ action-component >

    
<!--  Use this hook to filter the search results.  -->
    
< hook  id ="eds_search_hook_filter_search_results"   />
    
    
< call-action-chain  id ="prepare_collection_for_display"
        action-chain
="eds_mwau_act_chain_prepare_collection_for_display" >
        
< chain-input  id ="inModelEntityCollection"  source ="eds_search_results"   />
        
< chain-output  id ="outModelEntityContainerBean"  destination  ="sdrcResultsDataBean"   />
    
</ call-action-chain >

    
< call-action-chain  id ="prepare_page_criteria"
        action-chain
="eds_mwau_act_chain_clone_variable" >
        
< chain-input  id ="inVariable"  source ="eds_search_class_name"   />
        
< chain-output  id ="outVariable"  destination ="eds_global_criteria_model_class_name"   />
    
</ call-action-chain >

    
< action-component  id ="prepare_display_results"
        handler
="com.edsplm.tc.ent._wcc.search.DisplaySearchResults" >
        
< component-input  id ="inFoundItemsCount"  source ="eds_search_found_items_count"   />
        
< component-input  id ="inMaxItemsToRetrieve"  source ="MaxItemsToRetrieve"   />
        
< component-output  id ="outGuidanceMessage"  destination ="sdrcSearchResultsGuidance"   />
    
</ action-component >

    
< action-component  id ="set_source_data_list"
        handler
="com.edsplm.tc.ent._wcc.mwau.actioncomponents.appflow.ConfigParamToAttrConverter" >
        
< config-param  name ="inParam"  value ="SearchResults"   />
        
< component-output  id ="outAttribute"  destination ="eds_global_criteria_source_data_list"   />
    
</ action-component >

    
< action-component  id ="set_source_link"
        handler
="com.edsplm.tc.ent._wcc.mwau.actioncomponents.appflow.ConfigParamToAttrConverter" >
        
< config-param  name ="inParam"  value ="eds_search_link_do_search_again"   />
        
< component-output  id ="outAttribute"  destination ="eds_global_source_link"   />
    
</ action-component >

    
<!--  restore the background icon  -->
    
< call-action-chain  id ="restore_background_class_name"
        action-chain
="eds_mwau_act_chain_clone_variable" >
        
< chain-input  id ="inVariable"  source ="eds_search_background_class_name"   />
        
< chain-output  id ="outVariable"  destination ="sdrcClassName"   />
    
</ call-action-chain >

    
<!--  copy back the activetab to the original value  -->
    
< call-action-chain  id ="active_tab_param_clone_action"
        action-chain
="eds_mwau_act_chain_clone_variable" >
        
< chain-input  id ="inVariable"  source ="eds_search_global_active_tab"   />
        
< chain-output  id ="outVariable"  destination ="eds_global_active_tab"   />
    
</ call-action-chain >

    
<!--  Use this hook to do set the environment before displaying the
    results page. 
-->
    
< hook  id ="eds_search_hook_prepare_search_results_page"   />

    
< final-option >
        
< action-component  id ="route_based_on_class_name"
            handler
="com.edsplm.tc.ent._wcc.mwau.actioncomponents.appflow.ClassHierarchyOptionSelector" >
            
< component-input  id ="inClassName"   source ="eds_search_class_name"   />
            
< option  id ="PdmItem"  page ="search_resultpage" />
        
</ action-component >
    
</ final-option >

</ response-chain >
<!--  ***************************************************************  -->
<!--  End of 零件 零件族关系 客制化                                      -->
<!--  ***************************************************************  -->

添加Java ActionComponent类,输入bgClass = 'Assembly', searchClass = 'LeafFam', bgItemHandle = {Item Handle of Assembly},然后从调用Processor获取相关的Leaf Family对象集,设置到display bean中(outSearchResults,outFoundItemsCount)

public  Option handleEnterpriseAction(ActionContext action_context, Arguments arguments)
    
throws  RequestManagerException, EnterpriseException
{
    Manager esManager 
=  ESUtil.getESManager(action_context);
    Session esSession 
=  ESUtil.getESSession(action_context, arguments);
    
    String bgClassName 
=  (String)arguments.getString( " inBgClassName " );
    String schClassName 
=  (String)arguments.getString( " inSchClassName " );
    String bgItemHandle 
=  (String)arguments.getString( " inBgItemHandle " );

    ActionComponentUtil.assertArgument(action_context,
                               arguments,
                               
" inBgClassName " ,
                               bgClassName,
                               
this );
    ActionComponentUtil.assertArgument(action_context,
                               arguments,
                               
" inSchClassName " ,
                               schClassName,
                               
this );
    ActionComponentUtil.assertArgument(action_context,
                               arguments,
                               
" inBgItemHandle " ,
                               bgItemHandle,
                               
this );

    System.out.println(
" ===GetPartFamiliesAction=== " );
    System.out.println(
" bg class : < "   +  bgClassName  + " > " );
    System.out.println(
" search class : < "   +  schClassName  + " > " );
    System.out.println(
" bg item handle : < "   +  bgItemHandle  + " > " );

    OptionSet options 
=  action_context.getOptionSet();
    
if  (  ! bgClassName.equals( " Assembly " ) )
    {
        
return  options.getOption( " failure " );
    }
    
if  (  ! schClassName.equals( " LeafFam " ) )
    {
        
return  options.getOption( " failure " );
    }
    
    Accessor accessor 
=  (Accessor)esManager.getProcessor( " base.Accessor " , esSession);

    
//  import com.sdrc.metaphase.enterprise.es.base.EntityHandle
    EntityHandle entity_handle  =  accessor.reconstructEntityHandle(bgItemHandle);
    
//  import com.sdrc.metaphase.enterprise.es.base.ModelEntity
    ModelEntity model_entity  =  accessor.get(entity_handle);

    
    
//  get string value
    
//  import com.sdrc.metaphase.wcc.mwau.entitybean.ModelEntityBean
    
//  import com.edsplm.tc.ent.wcc.mwau.entitybean.ModelEntityBeanFactory
    ModelEntityBean bean  =  ModelEntityBeanFactory.createModelEntityBean(action_context, arguments, model_entity);
    Object objObid 
=  bean.getItemAttributeValue( " OBID " );
    String strObid 
=  (objObid  ==   null   ?   null  : objObid.toString());



    List list 
=   null ;
    IPartFamiliesProcessor processor 
=  (IPartFamiliesProcessor)esManager.getProcessor( " bbk.PartFamiliesProcessor " , esSession);
    
try
    {
        list 
=  processor.GetPartFamilies(strObid);
    }
    
catch (Exception e)
    {
        e.printStackTrace();
        
return  options.getOption( " failure " );
    }


    
if  ( list  ==   null   ||  list.size()  ==   0  )
    {
        
return  options.getOption( " noResultsFound " );
    }

    arguments.setObject(
" outSearchResults " , list);
    arguments.setObject(
" outFoundItemsCount " new  Integer(list.size()));

    
return  options.getOption( " success " );        
}

你可能感兴趣的:(创建)