Package com.easydesk.web.support
Class AttributeOptionTreeSupport
java.lang.Object
com.easydesk.web.support.AttributeOptionTreeSupport
AttributeOption 들을 부모/자식(A_PARENT_CHILD_B) 관계대로 tree 로 보여주기 위한 공용 로직.
Attribute 상세(admin-attribute-detail), ItemTypeAttribute 상세(admin-item-type-attribute),
ModuleAttribute 상세(admin-module-attribute) 세 화면이 같은 규칙을 쓰므로 여기로 뽑았다.
core 의 Attribute#getTopAttributeOptions() 로 맨 상위 Option 들을 구하고, 각 Option 의
AttributeOption#getChildren() 으로 내려가면서 tree 를 만든다 (형제끼리는 core 가 돌려주는
PreferredOrder 순서 그대로). 삭제(removed) 처리된 Option 은 그 아래 subtree 까지 함께 제외한다 -
기존 화면이 쓰던 attribute.getAttributeOptions(false) 와 같은 기준.
화면(Thymeleaf)에서는 재귀 fragment 대신
flatten(List) 로 펼친 AttributeOptionTreeSupport.Row 목록을 그대로
table 의 tr 로 뿌린다. 각 Row 의 prefix("│ ├─ " 같은 문자열)를 이름 앞에 고정폭으로 찍어 주면
table 의 다른 column(Active/Order 등)은 그대로 유지하면서 이름 column 만 tree 모양이 된다.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordtree 의 한 node. option 과 그 자식 node 들.static final record화면에 찍을 한 줄. depth 는 0(맨 상위)부터, prefix 는 이름 앞에 붙일 tree 선 문자열. -
Method Summary
Modifier and TypeMethodDescriptionstatic List<AttributeOptionTreeSupport.Node> attribute 의 (삭제되지 않은) AttributeOption 전체를 tree 로 만든다.static List<AttributeOptionTreeSupport.Row> tree 를 위에서부터(pre-order) 펼친 Row 목록으로 만든다.static List<AttributeOptionTreeSupport.Node> prune(List<AttributeOptionTreeSupport.Node> nodes, Predicate<AttributeOption> keep) keep 을 만족하는 Option 과, 그런 Option 을 자손으로 가진 조상 Option 만 남긴 tree 를 돌려준다.
-
Method Details
-
build
public static List<AttributeOptionTreeSupport.Node> build(Attribute attribute) throws TorqueException attribute 의 (삭제되지 않은) AttributeOption 전체를 tree 로 만든다.- Throws:
TorqueException
-
prune
public static List<AttributeOptionTreeSupport.Node> prune(List<AttributeOptionTreeSupport.Node> nodes, Predicate<AttributeOption> keep) keep 을 만족하는 Option 과, 그런 Option 을 자손으로 가진 조상 Option 만 남긴 tree 를 돌려준다. ItemTypeOption/ModuleOption 처럼 일부 Option 만 연결된 경우, 연결된 Option 이 tree 의 어디에 있는지 보여주려고 조상은 남겨두는 용도. -
flatten
public static List<AttributeOptionTreeSupport.Row> flatten(List<AttributeOptionTreeSupport.Node> roots) tree 를 위에서부터(pre-order) 펼친 Row 목록으로 만든다.
-