xml
private static List<UdcLicChkInfo> parseElement(Element root) { List<Element> licChkItems = root.getChildren("lic_item"); List<UdcLicChkInfo> licChkItemLst = new ArrayList<UdcLicChkInfo>(); for (Element ue : licChkItems){ UdcLicChkInfo licChkInfo = new UdcLicChkInfo(); licChkInfo.setLicItemName((ue.getAttribute("name").getValue())); try{ if(ue.getAttribute("mode")!=null){ //licChkInfo.setMode((ue.getAttribute("mode").getValue())); String mode = ue.getAttribute("mode").getValue(); String[] modeTypes=mode.split(","); if(!Arrays.asList(modeTypes).contains(getCurMode().toString())){ log.info("lic_item="+licChkInfo.getLicItemName()+" is not support mode "+getCurMode()); continue; } } }catch(Exception e){ log.error("parseElement error:",e); } Element e = ue.getChild("mocs"); List<UdcLicMoc> mocList = new ArrayList<UdcLicMoc>(); if(e!=null){ List<Element> e_lst = e.getChildren(); for(Element child_e : e_lst){ UdcLicMoc moc = new UdcLicMoc(); moc.setMocName(child_e.getAttributeValue("class")); moc.setErrorCode(child_e.getAttributeValue("error_code")); moc.setErrorMsgKey(child_e.getAttributeValue("errorMsgKey")); mocList.add(moc); } } licChkInfo.setMocList(mocList); e = ue.getChild("condition"); if(e!=null){ licChkInfo.setConditionHql(e.getTextNormalize()); }else{ licChkInfo.setConditionHql(null); } e = ue.getChild("condition_sql"); if(e!=null){ licChkInfo.setConditionSql(e.getTextNormalize()); }else{ licChkInfo.setConditionSql(null); } e = ue.getChild("condition_ver50"); if(e!=null){ licChkInfo.setConditionVer50Hql(e.getTextNormalize()); }else{ licChkInfo.setConditionVer50Hql(null); } licChkItemLst.add(licChkInfo); } return licChkItemLst; }
package com.shjv.tdscdma.ebs.bean; import java.io.Serializable; import java.util.List; public class UdcLicChkInfo implements Serializable { /** * */ private static final long serialVersionUID = -382381940331709642L; private String licItemName; private String conditionHql; private String conditionSql; private String conditionVer50Hql; private List<UdcLicMoc> mocList; public String getLicItemName() { return licItemName; } public void setLicItemName(String licItemName) { this.licItemName = licItemName; } public String getConditionHql() { return conditionHql; } public void setConditionHql(String conditionHql) { this.conditionHql = conditionHql; } public List<UdcLicMoc> getMocList() { return mocList; } public void setMocList(List<UdcLicMoc> mocList) { this.mocList = mocList; } public String getConditionSql() { return conditionSql; } public void setConditionSql(String conditionSql) { this.conditionSql = conditionSql; } public String getConditionVer50Hql() { return conditionVer50Hql; } public void setConditionVer50Hql(String conditionVer50Hql) { this.conditionVer50Hql = conditionVer50Hql; } }
<lic_item name="LSUA">
<!-- 该license项涉及的udc对象,根据该列表去判断对象是否需要校验该license -->
<mocs>
<moc class="com.shjv.tdscdma.ebs.bean.udc.UDCUser" error_code="90316" errorMsgKey="ISDN"/><!-- error_code指在opm_errors_zh.xml配置的错误码-->
</mocs>
<!-- 查询license使用量(hql语句),该查询会发到session提交之后,所以当次操作也会被查询出来 -->
<condition>
<![CDATA[select count(*) from UDCPttuser ptt where (ptt.gisCapability>0 or ptt.gisPubCapability>0) and ptt.subNetInternalId=-1]]>
</condition>
</lic_item>
public Long getCurUsedNumbyLicInfo(Session session, UdcLicChkInfo licChkInfo) { Long usedLicNum =0L; //log.info("getUsedNumber licChkInfo.getConditionHql()="+licChkInfo.getConditionHql()); //log.info("getUsedNumber licChkInfo.getConditionSql()="+licChkInfo.getConditionSql()); Long dbRet = null; Object dbRetforsql = null; Long dbRethql = null; session.flush(); String Version = licenseSet.getLicenseItem(UDCLicenseSet.VERSION); if(Version50.equals(Version) && licChkInfo.getConditionVer50Hql()!=null && licChkInfo.getConditionVer50Hql().trim()!=""){ dbRethql = (Long)session.createQuery(licChkInfo.getConditionVer50Hql()).uniqueResult(); }else{ if(licChkInfo.getConditionSql()!=null && licChkInfo.getConditionSql().trim()!="" ){ dbRetforsql = session.createSQLQuery(licChkInfo.getConditionSql()).uniqueResult(); }else if(licChkInfo.getConditionHql()!=null && licChkInfo.getConditionHql().trim()!="" ){ dbRet = (Long)session.createQuery(licChkInfo.getConditionHql()).uniqueResult(); } } if(dbRet!=null ){ usedLicNum = dbRet; log.info("checkLicenseItem hql usedLicNum="+usedLicNum+",licItem="+licChkInfo.getLicItemName()); } if(dbRetforsql!=null){ if(dbRetforsql instanceof BigInteger){ usedLicNum = ((BigInteger)dbRetforsql).longValue(); }else{ usedLicNum = ((BigDecimal)dbRetforsql).longValue(); } log.info("checkLicenseItem sql usedLicNum="+usedLicNum+",licItem="+licChkInfo.getLicItemName()); } if(dbRethql!=null){ usedLicNum = dbRethql; log.info("checkLicenseItem hql usedLicNum="+usedLicNum+",licItem="+licChkInfo.getLicItemName()); } return usedLicNum; }
posted on 2019-03-29 09:31 shangyixiong 阅读(117) 评论(0) 收藏 举报
浙公网安备 33010602011771号