Teamcenter LOV속성값 가져오기

혜림·2025년 4월 16일
0
post-thumbnail

LOV(List of Values)란?

💡 특정 필드나 속성에 대해 선택할 수 있는 값들의 목록을 제공하는 기능이다.

자재아이템에서 품목자산분류, 세부분류1,2에대해서 콤보박스에 값을 넣어주는 작업

TCComponentItemType itemType = (TCComponentItemType) session.getTypeComponent("A4MaterialsItem");
TCComponentItemRevisionType revisionType = itemType.getItemRevisionType();
  • a4MaCodeL1(품목자산분류) 코드가 아이템리비전 속성에 설정되어있기때문에 리비전 타입을 받아왔다
TCPropertyDescriptor revisionProperty = revisionType.getPropertyDescriptor("a4MaCodeL1");

🔎 TCPropertyDescriptor : Teamcenter 아이템에 정의된 속성들의 속성 정보(예: 이름, 타입, 제약조건 등)를 포함하는 메타데이터를 설명하는 객체

 TCComponentListOfValues listOfValue1 = revisionProperty.getLOV();//출력 ListOfValuesString
  • 속성에 대한 LOV를 객체에 담아준다
ListOfValuesInfo maCode1 =listOfValue1.getListOfValues(); //출력 A4_MaCodeL1LOV
String[] str1 = maCode1.getLOVDisplayValues(); //이름
Object[] lov1 = maCode1.getListOfValues(); //코드
TCComponentListOfValues[] filter1 = maCode1.getListOfFilters(); //하위 LOV

LOV에 포함된 값들의 목록을 가져와 사용자들에게 보여지는 값, 저장되는 코드값, 하위 LOV들을 확인해볼수있다.

📄 전체 코드

private Map<String, ComboData> listComboMap; //이름, 코드, LOV저장 품목자산
lass 
ComboData {
        String code;
        TCComponentListOfValues lovId;
        public ComboData(String code, TCComponentListOfValues lovId) {
            this.code = code;
            this.lovId = lovId;
        }
        
TCComponentItemType itemType;
		try {
			itemType = (TCComponentItemType) session.getTypeComponent("A4MaterialsItem");
		
			TCComponentItemRevisionType revisionType = itemType.getItemRevisionType();
			
			TCPropertyDescriptor revisionProperty = revisionType.getPropertyDescriptor("a4MaCodeL1");

            TCComponentListOfValues listOfValue1 = revisionProperty.getLOV();//출력 ListOfValuesString

            ListOfValuesInfo maCode1 = listOfValue1.getListOfValues(); //출력 A4_MaCodeL1LOV
            String[] str1 = maCode1.getLOVDisplayValues(); //이름
            Object[] lov1 = maCode1.getListOfValues(); //코드
            TCComponentListOfValues[] filter1 = maCode1.getListOfFilters(); //하위 LOV
            
            listComboMap = new LinkedHashMap<>();
            
            for(int i=0;i<lov1.length;i++) {
            	listComboMap.put(str1[i], new ComboData(lov1[i].toString(), filter1[i]));
            }
            for(String key : listComboMap.keySet()) {
            	listCombo.add(key);
            }
		} catch (TCException e1) {
			e1.printStackTrace();
		}

🔖 하위 LOV 가져오기

 ComboData selectedData = listComboMap.get(selectedText); // 저장된 데이터 가져오기
	
			        ListOfValuesInfo maCode2;
					try {
						maCode2 = (selectedData.lovId).getListOfValues();
						String[] str2 = maCode2.getLOVDisplayValues(); //이름
						Object[] lov2 = maCode2.getListOfValues(); //코드
						TCComponentListOfValues[] filter2 = maCode2.getListOfFilters(); //하위 LOV
						
						detailComboMap1 = new LinkedHashMap<>();
						 
						for(int i=0;i<lov2.length;i++) {
							detailComboMap1.put(str2[i], new ComboData(lov2[i].toString(), filter2[i]));
						}
						for(String key : detailComboMap1.keySet()) {
							detailCombo1.add(key);
						}
					} catch (TCException e1) {
						e1.printStackTrace();
					}
profile
안녕하세요! :)

0개의 댓글