| | |
| | | import com.vci.starter.web.annotation.log.VciUnLog; |
| | | import com.vci.starter.web.enumpck.VciFieldTypeEnum; |
| | | import com.vci.starter.web.pagemodel.BaseQueryObject; |
| | | import com.vci.starter.web.pagemodel.BaseResult; |
| | | import com.vci.starter.web.pagemodel.DataGrid; |
| | | import com.vci.starter.web.util.BeanUtil; |
| | | import com.vci.starter.web.util.VciBaseUtil; |
| | |
| | | } |
| | | |
| | | /** |
| | | * 链接类型的列表 |
| | | * |
| | | * @return 链接类型的显示对象 |
| | | */ |
| | | @Override |
| | | public BaseResult<List<LinkType>> gridLink() throws PLException { |
| | | |
| | | LinkType[] linkTypes = platformClientUtil.getLinkTypeService().getLinkTypes(); |
| | | return BaseResult.dataList(Arrays.asList(linkTypes)); |
| | | } |
| | | /** |
| | | * 链接类型保存 |
| | | * linkType 链接类型的保存对象 |
| | | * addFlag 是否为新增 true新增,false修改 |
| | | * @return 保存结果 |
| | | */ |
| | | @Override |
| | | public BaseResult addAndEditLink(LinkType linkType, Boolean addFlag) throws PLException { |
| | | VciBaseUtil.alertNotNull(linkType.name,"请输入链接类型名称",linkType.btmItemsFrom,"From端业务类型不能为空!", |
| | | linkType.btmItemsTo,"To端类型均不能为空!"); |
| | | int maxLength = platformClientUtil.getLinkTypeService().getLTNameMaxLength(); |
| | | if(linkType.name.length() > maxLength){ |
| | | throw new PLException("500",new String[] {"链接类型名长度不能超过" + maxLength}); |
| | | } |
| | | if(!linkType.name.matches("^[A-Za-z]+$")){ |
| | | throw new PLException("500",new String[] {"链接类型名称只能为英文字母"}); |
| | | } |
| | | LinkType historyLink = platformClientUtil.getLinkTypeService().getLinkType(linkType.name); |
| | | if(historyLink != null && !historyLink.name.equals("") && addFlag){ |
| | | throw new PLException("500",new String[] {"该链接类型名称已经存在"}); |
| | | } |
| | | linkType.modifier = WebUtil.getCurrentUserId(); |
| | | if(addFlag){ |
| | | linkType.creator = WebUtil.getCurrentUserId(); |
| | | platformClientUtil.getLinkTypeService().addLinkType(linkType); |
| | | return BaseResult.success(null,"保存成功!"); |
| | | } |
| | | ArrayList<String> removeAbList = getRemovedApList(historyLink, linkType); |
| | | if(removeAbList.size() > 0 && platformClientUtil.getLinkTypeService().hasData(linkType.name)){ |
| | | linkType.attributes = historyLink.attributes; |
| | | platformClientUtil.getLinkTypeService().modifyLinkType(linkType); |
| | | throw new PLException("500",new String[] {"类型已有实例, 不进行移除操作"}); |
| | | } |
| | | platformClientUtil.getLinkTypeService().modifyLinkType(linkType); |
| | | return BaseResult.success(null,"保存成功!"); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取修改链接类型时 减少的属性 |
| | | * @param oldLt |
| | | * @param newLt |
| | | * @return |
| | | */ |
| | | private ArrayList<String> getRemovedApList(LinkType oldLt, |
| | | LinkType newLt) { |
| | | String[] oldAbInfo = oldLt.attributes; |
| | | ArrayList<String> oldNameList = new ArrayList<String>(); |
| | | for(int i = 0; i < oldAbInfo.length; i++){ |
| | | oldNameList.add(oldAbInfo[i]); |
| | | } |
| | | String[] newAbInfo = newLt.attributes; |
| | | ArrayList<String> newNameList = new ArrayList<String>(); |
| | | for(int i = 0; i < newAbInfo.length; i++){ |
| | | newNameList.add(newAbInfo[i]); |
| | | } |
| | | |
| | | ArrayList<String> removedApList = new ArrayList<String>(); |
| | | |
| | | for(Iterator<String> iterator = oldNameList.iterator(); iterator.hasNext();){ |
| | | String oldName = iterator.next(); |
| | | if(!newNameList.contains(oldName)){ |
| | | removedApList.add(oldName); |
| | | } |
| | | } |
| | | return removedApList; |
| | | } |
| | | |
| | | /** |
| | | * 清除缓存 |
| | | */ |
| | | @Override |