| | |
| | | import com.vci.corba.omd.lcm.LifeCycle; |
| | | import com.vci.corba.omd.ltm.LinkType; |
| | | import com.vci.corba.omd.stm.StatePool; |
| | | import com.vci.corba.omd.tim.TypeIndexDef; |
| | | import com.vci.corba.omd.vrm.VersionRule; |
| | | import com.vci.dto.OsBtmTypeDTO; |
| | | import com.vci.model.IndexObject; |
| | |
| | | if (Func.isEmpty(conditionMap)) { |
| | | return new ArrayList<>(); |
| | | } |
| | | List<String> indexNameList = new ArrayList<String>(); |
| | | QueryTemplate qtl = new QueryTemplate(); |
| | | List<String> list = new ArrayList<String>(); |
| | | list.add("*"); |
| | | qtl.setBtmType("indexobject"); |
| | | qtl.setClauseList(list); |
| | | qtl.setId("p"); |
| | | qtl.setType("btm"); |
| | | qtl.setRightFlag(false); |
| | | Condition condition = OQTool.getCondition(conditionMap); |
| | | qtl.setCondition(condition); |
| | | //HashMap<String, String> indexmap = new HashMap<String, String>(); |
| | | BusinessObject findBTMObjects[] = platformClientUtil.getQueryService().findBTMObjects(qtl.getId(), OQTool.qtTOXMl(qtl).asXML()); |
| | | List<IndexObject> indexObjects = new ArrayList<>(); |
| | | for (int i = 0; i < findBTMObjects.length; i++) { |
| | | BusinessObject findBTMObject = findBTMObjects[i]; |
| | | TypeIndexDef[] typenames = ClientServiceProvider.getOMDService().getTypeIndexService().getBTIndexDefs(conditionMap.get("typename")); |
| | | |
| | | for (int i = 0; i < typenames.length; i++) { |
| | | TypeIndexDef typename = typenames[i]; |
| | | IndexObject indexObject = new IndexObject(); |
| | | indexObject.setOid(findBTMObject.oid); |
| | | indexObject.setDescription(findBTMObject.description); |
| | | indexObject.setCreateTime(Func.format(new Date(findBTMObject.createTime), DateUtil.PATTERN_DATE)); |
| | | indexObject.setIndexName(ObjectTool.getBOAttributeValue(findBTMObject, "indexname")); |
| | | indexObject.setTypeName(ObjectTool.getBOAttributeValue(findBTMObject, "typename")); |
| | | indexObject.setAttrNames(ObjectTool.getBOAttributeValue(findBTMObject, "attrname")); |
| | | indexObject.setOid(typename.oid); |
| | | indexObject.setDescription(typename.description); |
| | | indexObject.setCreateTime(Func.format(new Date(typename.createTime), DateUtil.PATTERN_DATE)); |
| | | indexObject.setIndexName(typename.name); |
| | | indexObject.setTypeName(typename.typeName); |
| | | indexObject.setAttrNames(typename.attributes); |
| | | indexObjects.add(indexObject); |
| | | } |
| | | return indexObjects; |
| | |
| | | @Override |
| | | public boolean delIndex(String btmName, String indexName) throws PLException { |
| | | VciBaseUtil.alertNotNull(btmName, "业务类型名", indexName, "索引名"); |
| | | Map<String, String> conditionMap = new HashMap<>(); |
| | | conditionMap.put("typename", btmName); |
| | | conditionMap.put("indexname", indexName); |
| | | List<IndexObject> bo2 = getIndexByCondition(conditionMap); |
| | | if (bo2 != null && bo2.size() > 0) { |
| | | TypeIndexDef[] typeIndexDef= ClientServiceProvider.getOMDService().getTypeIndexService().getBTIndexDefs(btmName); |
| | | if( typeIndexDef != null && typeIndexDef.length > 0 ){ |
| | | String[] indexAttr = {indexName}; |
| | | |
| | | boolean alterFlag = platformClientUtil.getBtmService().dropIndex(btmName, indexAttr); |
| | |
| | | if (!alterFlag) { |
| | | return false; |
| | | } |
| | | for (int i = 0; i < bo2.size(); i++) { |
| | | String oid = bo2.get(i).getOid(); |
| | | BusinessObject bo = platformClientUtil.getBOFactoryService().readBusinessObject(oid, "indexobject"); |
| | | platformClientUtil.getBOFactoryService().deleteBusinessObject(bo, 1); |
| | | for (int i = 0; i < typeIndexDef.length; i++) { |
| | | if(!typeIndexDef[i].name.equals(indexName)) { |
| | | continue; |
| | | } |
| | | String oid = typeIndexDef[i].oid; |
| | | ClientServiceProvider.getOMDService().getTypeIndexService().delIndexDef(oid); |
| | | } |
| | | } |
| | | return true; |
| | |
| | | String btmName = indexObjectList.get(0).getTypeName(); |
| | | String indexNames = indexObjectList.stream().map(IndexObject::getIndexName).collect(Collectors.joining(",")); |
| | | String[] oldindexAttr = {indexNames}; |
| | | BusinessObject bo; |
| | | List<BusinessObject> boList = new ArrayList<>(); |
| | | //先查询当前添加索引是否已经存在,如果存在就先删除再新增实现替换操作 |
| | | Map<String, String> conditionMap = new HashMap<>(); |
| | | conditionMap.put("typename", btmName); |
| | | //先这样处理,前端现在只做了单次保存,所以不用in |
| | | conditionMap.put("indexname", indexNames); |
| | | List<IndexObject> indexObjects = getIndexByCondition(conditionMap); |
| | | if (indexObjects != null && indexObjects.size() > 0) { |
| | | //索引不存在时删除就会报错索引不存在,所以这里有索引才去删除 |
| | | boolean b = platformClientUtil.getBtmService().dropIndex(btmName, oldindexAttr); |
| | | if (b) { |
| | | for (int i = 0; i < indexObjects.size(); i++) { |
| | | String oid = (String) indexObjects.get(i).getOid(); |
| | | bo = platformClientUtil.getBOFactoryService().readBusinessObject(oid, "indexobject"); |
| | | platformClientUtil.getBOFactoryService().deleteBusinessObject(bo, 1); |
| | | } |
| | | } |
| | | } |
| | | // BusinessObject bo; |
| | | // List<BusinessObject> boList = new ArrayList<>(); |
| | | // //先查询当前添加索引是否已经存在,如果存在就先删除再新增实现替换操作 |
| | | // Map<String, String> conditionMap = new HashMap<>(); |
| | | // conditionMap.put("typename", btmName); |
| | | // //先这样处理,前端现在只做了单次保存,所以不用in |
| | | // conditionMap.put("indexname", indexNames); |
| | | TypeIndexDef[] typeIndexDefs = platformClientUtil.getTypeIndexService().getBTIndexDefs(btmName); |
| | | |
| | | for (int i = 0; i < indexObjectList.size(); i++) { |
| | | IndexObject indexObject = indexObjectList.get(i); |
| | | //bo = platformClientUtil.getBOFService().initBusinessObject("indexobject"); |
| | | bo = boService.createCBOByBtmName("indexobject"); |
| | | List<AttributeValue> attributeValues = new ArrayList<>(); |
| | | attributeValues.add(new AttributeValue("typename", btmName)); |
| | | attributeValues.add(new AttributeValue("indexname", indexObject.getIndexName())); |
| | | attributeValues.add(new AttributeValue("attrname", indexObject.getAttrNames())); |
| | | bo.newAttrValList = attributeValues.toArray(new AttributeValue[attributeValues.size()]); |
| | | bo.description = indexObject.getDescription(); |
| | | String[] indexAttr = {indexObject.getIndexName(), indexObject.getAttrNames()}; |
| | | //给指定业务类型的指定属性创建索引 |
| | | boolean alterFlag = platformClientUtil.getBtmService().addIndex(btmName, indexAttr); |
| | | //索引创建成功之后,需要存储成功索引到索引表中 |
| | | if (!alterFlag) { |
| | | return false; |
| | | if(typeIndexDefs!=null && typeIndexDefs.length>0){ |
| | | boolean hasIndex = false; |
| | | for(int i = 0; i < typeIndexDefs.length; i ++){ |
| | | if(!typeIndexDefs[i].name.equals(indexNames)) { |
| | | continue; |
| | | } |
| | | String oid = typeIndexDefs[i].oid; |
| | | platformClientUtil.getTypeIndexService().delIndexDef(oid); |
| | | hasIndex = true; |
| | | } |
| | | boList.add(bo); |
| | | //添加索引信息到索引的业务表中 |
| | | //platformClientUtil.getBOFactoryService().createBusinessObject(bo,false,false); |
| | | //索引不存在时删除就会报错索引不存在,所以这里有索引才去删除 |
| | | if(hasIndex) { |
| | | platformClientUtil.getBtmService().dropIndex(btmName, oldindexAttr); |
| | | } |
| | | } |
| | | //添加索引信息到索引的业务表中 |
| | | platformClientUtil.getBOFactoryService().batchCreateBusinessObject(boList.toArray(new BusinessObject[boList.size()]), false, false); |
| | | StringBuilder sb = new StringBuilder(); |
| | | List<TypeIndexDef> saveDefs = new ArrayList<>(); |
| | | for(int i = 0; i < indexObjectList.size(); i ++){ |
| | | TypeIndexDef saveDef = new TypeIndexDef(); |
| | | saveDef.typeName = indexObjectList.get(i).getTypeName(); |
| | | saveDef.name = indexObjectList.get(i).getIndexName(); |
| | | saveDef.description = indexObjectList.get(i).getDescription(); |
| | | saveDef.attributes = indexObjectList.get(i).getAttrNames(); |
| | | sb.append(indexObjectList.get(i).getAttrNames()); |
| | | if(i<indexObjectList.size()-1){ |
| | | sb.append(","); |
| | | } |
| | | saveDefs.add(saveDef); |
| | | } |
| | | String[] indexAttr = {indexObjectList.get(0).getIndexName(),sb.toString()}; |
| | | boolean alterFlag = platformClientUtil.getBtmService().addIndex(btmName, indexAttr); |
| | | if(!alterFlag) { |
| | | return false; |
| | | } |
| | | ClientServiceProvider.getOMDService().getTypeIndexService().saveIndexDefs(saveDefs.toArray(new TypeIndexDef[saveDefs.size()])); |
| | | return true; |
| | | } |
| | | |