继承关系
OrderEntryServiceImpl extends AbstractBase implements OrderEntryService
AbstractBase implements AdapterConfig :内部获取Aapter,调用各种方法。
interface Adapter
SiebelAdapter implements Adapter
具体请看:
SiebelAdapter.java —适配器实现类
联动 ExceptionWithCode, JDBFactory
public class SiebelAdapter<Z extends BaseModel> implements Adapter<Z>{
public static final Logger logger = LoggerFactory.getLogger(SiebelAdapter.class);
protected AdapterConfig<Z> config;
public AdapterConfig<Z> getConfig(){
return config;
}
public void setConfig( AdapterConfig<Z> config){
this.config = config;
}
//1;获取适配器配置
public Z getConfigByModel(Z model){
return fillProperties(getConfig(),model);
}
public Z fillProperties(AdapterConfig<Z> adapter, Z model){
if(StringUtils.isBlank(model.getBusinessComponeseName())){ model.setBusinessComponeseName(adapter.getBCName())}
//BC,BO,IC,IO,PBC一样,我就不写了.基本就是在各个实现类中 重写AdapterConfig接口的方法.
return model;
}
//2:getMapping
final private Map<String ,String> getMapping(){
Map<String ,String> mapping = new LinkedHashMap<>();
if(mapping.isEmpty() ){
Map<String ,String> map = getConfig().getRawMapping();
if( map != null ){
map.put("Id","rowId");
map.put("Created","createTime");
map.put("Created By","creatorId");
mapping.putAll(map);
}
}
return mapping;
}
//3,4 getExpress/getOrExpress 条件拼接。
public final String getExpress (List<String> exprList){
StringBuffer expr = new String Buffer();
for(String e : exprList){
if( expr.length() > 0 ) expr.append(" and ");
expr.append(e);
}
return expr.toString();
}
public final String getOrExpress (List<String> exprList){
StringBuffer expr = new String Buffer();
for(String e : exprList){
if( expr.length() > 0 ) expr.append(" or");
expr.append(e);
}
return expr.toString();
}
//5通过查询 取得数据的列表
public List<Z> getList(Z model) throws Exception{
return getList( model, getConfig().getListExpress(model) );
}
public List<Z> getListByBs(Z model) throws Exception{
return getListByBs( model,getConfig().getListExpress(model) );
}
//--通过查询 取得数据的列表
public List<Z> getList(Z model,String expr) throws Exception{
Z modelconfig = getConfigByModel(model);//得到具体有Bo,BC,IC,IO配置的模型
if(StringUtils.isBlank(modelconfig.getBOName())){ throw new ExceptionWithCode("0010");} --BO未指定
if(StringUtils.isBlank(modelconfig.getBCName())){ throw new ExceptionWithCode("0011");}--BC未指定
/从这里可以看出来,在具体的实现类中必须 重写BO,BC方法,指明其名字,否则将报错。
List<Z> retlist = new LinkedList<Z>();
//获取siebel--数据对象
SiebelDataBean sdb = JDBFactory.getSiebelDataBean();
try{ getConfigInfo(sdb);
//获取siebel--BO对象
SiebelBusObject busObject = sdb.getBusObject(modelconfig.getBusinessObjectNameI());
//获取siebel--BC对象,及其父BC对象
try{ SiebelBusComp busComp = busObject.getBusComp(modelconfig.getBusinessComponeseName());
try{ SiebelBusComp pc