|
@ -38,9 +38,9 @@ public class MetatdataStandardExistStrategy extends SQLGeneralDAO {
|
|
|
this.adapterDatasetService = adapterDatasetService;
|
|
|
}
|
|
|
|
|
|
public MetatdataStandardExistStrategy(IStdMetaDataModelDao stdMetaDataModelDao){
|
|
|
this.stdMetaDataModelDao = stdMetaDataModelDao;
|
|
|
}
|
|
|
public MetatdataStandardExistStrategy(IStdMetaDataModelDao stdMetaDataModelDao) {
|
|
|
this.stdMetaDataModelDao = stdMetaDataModelDao;
|
|
|
}
|
|
|
|
|
|
public IStdMetaDataModelDao getStdMetaDataModelDao() {
|
|
|
return stdMetaDataModelDao;
|
|
@ -68,6 +68,7 @@ public class MetatdataStandardExistStrategy extends SQLGeneralDAO {
|
|
|
|
|
|
public MetatdataStandardExistStrategy() {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 对传进来的StdeMetadata进行匹配
|
|
|
*
|
|
@ -77,42 +78,45 @@ public class MetatdataStandardExistStrategy extends SQLGeneralDAO {
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
@Transactional
|
|
|
public boolean match(AdapterMetadataModel strategyMetadata,MetadataMatchVO matchVO, String adapter_std_version,String version ) throws Exception {
|
|
|
public boolean match(AdapterMetadataModel strategyMetadata, MetadataMatchVO matchVO, String std_version, String adapter_std_version, String version) {
|
|
|
boolean flag = false;
|
|
|
String metadataNameFirstCode= GetChineseFirst.cn2py(strategyMetadata.getStdMetadataName());//待匹配
|
|
|
List<AdapterMetadataModel> adapterMetadatas=matchVO.getCodeAdapter().get(metadataNameFirstCode);//已存在
|
|
|
if(adapterMetadatas!=null&&adapterMetadatas.size()>0){
|
|
|
//获取待适配的数据集名
|
|
|
Integer unAdaptDatasetId = strategyMetadata.getStdDatasetId();
|
|
|
Integer adapterDatasetId = strategyMetadata.getAdapterDatasetId();
|
|
|
StdDataSetModel stdDataset = stdDataSetModelDao.getDatasetName(adapter_std_version, unAdaptDatasetId);
|
|
|
StdDataSetModel adapterDataset = stdDataSetModelDao.getDatasetName(adapter_std_version, unAdaptDatasetId);
|
|
|
String stdDatasetName = stdDataset.getName();
|
|
|
for (AdapterMetadataModel stdeMetadataTemp : adapterMetadatas) {
|
|
|
//利用名字來匹配
|
|
|
if(stdeMetadataTemp.getStdMetadataName().contains(strategyMetadata.getStdMetadataName())){
|
|
|
String orgMetadataName= stdeMetadataTemp.getAdapterMetadataName();
|
|
|
//根据名字查找出 该项目下面的数据元名称
|
|
|
List<StdMetaDataModel> metadataTemps = stdMetaDataModelDao.getMetadata(adapter_std_version,orgMetadataName,stdDatasetName);
|
|
|
if(metadataTemps!=null&&metadataTemps.size()>0){
|
|
|
String adapterInfo = "1";//找到默认为疑似适配
|
|
|
if(metadataTemps.size()==1){//找到条数为1,默认为完全适配
|
|
|
adapterInfo="2";
|
|
|
try {
|
|
|
String metadataNameFirstCode = GetChineseFirst.cn2py(strategyMetadata.getStdMetadataName());//待匹配
|
|
|
List<AdapterMetadataModel> adapterMetadatas = matchVO.getCodeAdapter().get(metadataNameFirstCode);//已存在
|
|
|
if (adapterMetadatas != null && adapterMetadatas.size() > 0) {
|
|
|
//获取待适配的数据集名
|
|
|
Integer unAdaptStdId = strategyMetadata.getStdDatasetId();
|
|
|
StdDataSetModel stdDataset = stdDataSetModelDao.getDatasetName(std_version, unAdaptStdId);
|
|
|
StdDataSetModel adapterDataset = stdDataSetModelDao.getDatasetName(adapter_std_version, unAdaptStdId);
|
|
|
String stdDatasetName = stdDataset.getName();
|
|
|
for (AdapterMetadataModel stdeMetadataTemp : adapterMetadatas) {
|
|
|
//利用名字來匹配
|
|
|
if (stdeMetadataTemp.getStdMetadataName().contains(strategyMetadata.getStdMetadataName())) {
|
|
|
String orgMetadataName = stdeMetadataTemp.getAdapterMetadataName();
|
|
|
//根据名字查找出 该项目下面的数据元名称
|
|
|
List<StdMetaDataModel> metadataTemps = stdMetaDataModelDao.getMetadata(adapter_std_version, orgMetadataName, stdDatasetName);
|
|
|
if (metadataTemps != null && metadataTemps.size() > 0) {
|
|
|
String adapterInfo = "1";//找到默认为疑似适配
|
|
|
if (metadataTemps.size() == 1) {//找到条数为1,默认为完全适配
|
|
|
adapterInfo = "2";
|
|
|
}
|
|
|
StdMetaDataModel orgMetadata = metadataTemps.get(0);
|
|
|
//保存适配
|
|
|
|
|
|
adapterMetadataService.saveAdapt(strategyMetadata, orgMetadata, version, adapterInfo);
|
|
|
flag = true;
|
|
|
break;
|
|
|
}
|
|
|
StdMetaDataModel orgMetadata=metadataTemps.get(0);
|
|
|
//保存适配
|
|
|
adapterMetadataService.saveAdapt(strategyMetadata, orgMetadata, version,adapterInfo);
|
|
|
flag=true;
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
if (adapterDataset != null) {
|
|
|
adapterDatasetService = SpringBeanUtil.getService(AdapterDatasetService.BEAN_ID);
|
|
|
AdapterDatasetModel entity = adapterDatasetService.getAdapterDatasetByCode(version, adapterDataset.getCode());
|
|
|
adapterDatasetService.saveAdaptDataset(entity,adapterDataset,version);
|
|
|
}
|
|
|
}
|
|
|
adapterDatasetService = SpringBeanUtil.getService(AdapterDatasetService.BEAN_ID);
|
|
|
AdapterDatasetModel entity = adapterDatasetService.getAdapterDatasetByCode( version,adapterDataset.getCode());
|
|
|
entity.setAdapterDatasetId(strategyMetadata.getAdapterDatasetId());
|
|
|
entity.setAdapterDatasetCode(adapterDataset.getCode());
|
|
|
entity.setAdapterDatasetName(adapterDataset.getName());
|
|
|
adapterDatasetService.modifyAdapterDateset(version,entity);
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
return flag;
|
|
|
}
|