XPath는 Domain Model을 직접 참조한다.
- Entity
<ModuleName>.<EntityName>
- Attribute
<ModuleName>.<EntityName>/<ProductName>
- Associations
<ModuleName>.<EntityName>/<Association_Name>
- Enum
<modulename>.<enumerationname>.<enumerationvalue>
Token
XPath constraints에는 Token이라는 구조적 요소(structural elements)가 있다.
Token | 예시 | 설명 |
// | //OrderManagement.Order | 데이터베이스 activity 또는 리스트 위젯에서 검색 Mendix는 자동으로 생성한다. Start of an XPath Query |
. | Separator between module and entity name | |
[] | [ProductName = 'Ferrari 599XX'] | XPath 제약조건은 항상 [] 사이에 써라. Constraint |
/ | [OrderManagement.Product/ProductName = 'Ferrari 599XX'] | /는 새 노드로 이동할때마다 사용한다. /는 association 에서 entity로 이동하거나, entity에서 안의 members(attribute or association)로 이동할때 사용한다. 예시는 Product라는 Entity 안의 ProductName이라는 attibute를 찾을 것이다. Seperate between an entity and an association or vice versa |
() | [ (ProductName = 'Ferrari 599XX' or ProductNAme = 'Alfa Romeo 4c') and TotalStock > 0 ] |
제약조건은 괄호(parentheses)로 우선순위를 나타내기 위해서 그룹화될 수 있다. Grouping of contraints |
시스템 변수 사용
현재 사용자에 대한 참조, 해당 사용자 역할, 현재 세션, 데이터를 잘 제어할 수 있는 여러 날짜 및 시간이 포함된다. 이러한 변수는 항상 '[%' 문자로 시작 Ctrl+Space로 자동 완성 메뉴를 사용하여 찾을 수 있다.
**자주 사용하는 것
*[%CurrentObject%] : 현재 컨텍스트 개체의 고유 식별자. DataView에 포함된 DataGrid의 경우 '[%CureentObject%]'가 Data View의 개체를 나타낸다. Data View의 개체는 컨텍스트 개체로 알려져있다.
*[%CurrentUser%] : ctrl-space 드롭다운 메뉴에서 찾을 수 있는 '[%CurrentUser%]' 변수를 통해 수행된다. XPath가 사용되는 모든 위치에서 사용할 수 있다. 보안 제약조건을 생성할때도 유용하며 앱을 보호 가능하다.
But! 예약된 이벤트 및 시작 후 마이크로플로와 같은 시스템 프로세스에서 '[%CurrentUser%]'변수를 사용하지 말 것. 사용자가 없음
*https://docs.mendix.com/refguide/xpath-keywords-and-system-variables/ 전체 토큰
Option 중 Range
여기선 Return Type을 확인 해야 한다.
https://docs.mendix.com/refguide/retrieve/
All : 모든 개체를 한 번에 검색. Return type List of that entity class
First : 첫 번째 개체만 검색. 여러개 나와도 첫 번째 가져오고 Object 하나
Custom: 지정된 인덱스(Offset)에서 시작해 지정된 수의 객체를 검색. 첫 번째 개체의 offset 은 0. 양이 0이면 모든 개체가 검색됨을 의미. Return type 확인
Domain Model 에서 생성한 Entity는 MVC 중에서 Model로 생각하고
Getter/Setter가 자동으로 매핑된다고 생각하기.
여기서 생성된 것을 Micro/Nanoflow에서 사용할 때 Object
App Security에서 각각의 view setting이 가능하고.
모든 내용은 Mendix Academy 및 Docs를 참조함.
XPath Operator
https://docs.mendix.com/refguide/xpath/
- contains(StringAttribute, String) allows you to determine if an attribute contains a particular string.
- starts-with(StringAttribute, String) allows you to determine if an attribute starts with a particular string.
- ends-with(StringAttribute, String) allows you to determine if an attribute ends with a particular string.
- string-length(StringAttribute) returns the length of the StringAttribute.
- day-from-datetime(DateAttribute) returns the day of the month for the DateAttribute
- true() returns true, can be used to compare a BooleanAttribute to true. [HasAccount = true()]
- false() returns false, can be used to compare a BooleanAttribute to false. [HasAccount = false()]
Finally there are some system variables that you can use in your XPath queries:
Object related
- [%Current_User%] The ID of the current user
- [%Current_Object%] The ID of the object currently in context
User Roles each user role has a constant. The constant is [%UserRole_{userrolename}%] for instance[%UserRole_Administrator%]
Time Related
Timerelated constants like [%CurrentDateTime%] and [%BeginOfCurrentDay%] are available as well. A full list can be found in the documentation.
reversed
XPath 안에 있던 reversed()는? 자기 참조에서 부모에서 자식으로 가는 것과 자식에서 부모로 가는 경우가 있다. 거기서 자식 -> 부모로 가려면 reversed를 사용한다.
'Mendix' 카테고리의 다른 글
Resource Path 가져오기 (0) | 2024.12.02 |
---|---|
[Mendix]Pluggable-Widget 생성하기 01 (0) | 2024.01.26 |
[Mendix] Error (0) | 2023.02.13 |
[Mendix] Build local app (0) | 2023.02.10 |
[Mendix] Mendix Academy Knowldege Check (0) | 2023.01.25 |