zoukankan      html  css  js  c++  java
  • TC设置LOV属性

    TCProperty property = item.getLatestItemRevision().getTCProperty("xxx_lll_xxx");
    String lovTrueValueByDisplayValue1 = LOVUtil.getInstance().getLOVValueByDisplayValue(property.getLOV(), "组内");
    LOVUtil.getInstance().setStringTCLOVProperty(property,lovTrueValueByDisplayValue1);
    
    public String getLOVValueByDisplayValue(TCComponentListOfValues lov, Object object) {
    		if (lov == null) {
    			return "";
    		}
    		try {
    			TCComponentListOfValues[] childs = lov.getListOfFilters();
    			for (int i = 0; i < childs.length; i++) {
    				try {
    					if (childs[i] == null) {
    						continue;
    					}
    					String tmp = getLOVValueByDisplayValue(childs[i], object);
    					if (StringUtils.isNotEmpty(tmp)) {
    						return tmp;
    					}
    				} catch (Exception e) {
    					e.printStackTrace();
    				}
    			}
    			// 取LOV所有值与属性
    			ListOfValuesInfo valuesInfo = lov.getListOfValues(true);
    			Object[] values = valuesInfo.getListOfValues();
    			// String[] descriptions = valuesInfo.getDescriptions();
    			// 取值对应的属性
    			for (int i = 0; i < values.length; i++) {
    				if (valuesInfo.getDisplayableValue(values[i]).equals(object)) {
    					return values[i].toString();
    				}
    			}
    		} catch (Exception tce) {
    			tce.printStackTrace();
    			return "";
    		}
    		return "";
    	}
    
    public void setStringTCLOVProperty(TCProperty property,String value) {
    		try {
    			if(property.getLOV() != null) {
    				int type = property.getPropertyType();
    				String lovTrueValueByDisplayValue = LOVUtil.getInstance().getLOVValueByDisplayValue(property.getLOV(), value); //
    				if(lovTrueValueByDisplayValue != null) {
    					if(TCProperty.PROP_int == type) {
    						if(lovTrueValueByDisplayValue.trim().length() > 0){
    							int intValue = Integer.parseInt(lovTrueValueByDisplayValue);
    							property.setIntValue(intValue);
    						}else {
    							property.setNullVerdict(true);
    						}
    					}else if(TCProperty.PROP_double == type) {
    						if(lovTrueValueByDisplayValue.trim().length() > 0){
    							double doubleValue = Double.parseDouble(lovTrueValueByDisplayValue);
    							property.setDoubleValue(doubleValue);
    						}else {
    							property.setNullVerdict(true);
    						}
    					}else if(TCProperty.PROP_string == type) {
    						property.setStringValue(value);
    					}else {
    						property.setStringValue(value);
    					}
    				}
    			}
    		}catch (TCException e) {
    			e.printStackTrace();
    		}
    	}
  • 相关阅读:
    【Codechef】Chef and Bike(二维多项式插值)
    USACO 完结的一些感想
    USACO 6.5 Checker Challenge
    USACO 6.5 The Clocks
    USACO 6.5 Betsy's Tour (插头dp)
    USACO 6.5 Closed Fences
    USACO 6.4 Electric Fences
    USACO 6.5 All Latin Squares
    USACO 6.4 The Primes
    USACO 6.4 Wisconsin Squares
  • 原文地址:https://www.cnblogs.com/wwssgg/p/15464370.html
Copyright © 2011-2022 走看看