Class AttributeStatement
- java.lang.Object
-
- pl.edu.icm.unity.types.basic.AttributeStatement
-
public class AttributeStatement extends Object
Attribute statement allows for generating dynamic attributes. Attribute statements are assigned to a group for its members.Attribute statement is evaluated using a MVEL context. The context is composed of several fixed variables as identities, groups and regular attributes (in the statements's group) of an entity. Additionally the statement can be configured to add to the context attributes of another group: either child or parent.
Statement contains a condition. The attribute is assigned only if the condition evaluates to true.
Statement can assign attribute in two alternative ways: either attribute name is provided and an MVEL expression is used to produce values or a fixed attribute is given. The later variant is quite static but allows for editing assigned attribute with the full power of Unity attribute editors in the UI.
- Author:
- K. Benedyczak
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
AttributeStatement.ConflictResolution
static class
AttributeStatement.Direction
-
Constructor Summary
Constructors Constructor Description AttributeStatement()
AttributeStatement(com.fasterxml.jackson.databind.node.ObjectNode src)
AttributeStatement(String condition, String extraAttributesGroup, AttributeStatement.ConflictResolution conflictResolution, String dynamicAttributeType, String dynamicAttributeExpression)
Creates a statement assigning a dynamic attributeAttributeStatement(String condition, String extraAttributesGroup, AttributeStatement.ConflictResolution conflictResolution, Attribute fixedAttribute)
Creates a statement assigning a fixed attribute
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description AttributeStatement
clone()
boolean
dynamicAttributeMode()
boolean
equals(Object obj)
String
getAssignedAttributeName()
Name of the assigned attribute, regardless whether values are fixed or dynamic.Serializable
getCompiledCondition()
Serializable
getCompiledDynamicAttributeExpression()
String
getCondition()
AttributeStatement.ConflictResolution
getConflictResolution()
String
getDynamicAttributeExpression()
String
getDynamicAttributeType()
String
getExtraAttributesGroup()
Attribute
getFixedAttribute()
static AttributeStatement
getFixedEverybodyStatement(Attribute toAssign)
Creates a simple statement that assigns a given attribute to everybodystatic AttributeStatement
getFixedStatement(Attribute toAssign, String extraGroup, String condition)
Creates a statement with a given condition and assigning a fixed attribute and conflict resolution set to skip.int
hashCode()
boolean
isSuitableForDirectedEvaluation(AttributeStatement.Direction direction, String groupOfStatement)
Checks if the statement can be evaluated in course of recursive evaluation of statements, without procuring (infinite) cycles.void
setCondition(String condition)
void
setConflictResolution(AttributeStatement.ConflictResolution conflictResolution)
void
setDynamicAttributeExpression(String dynamicAttributeExpression)
void
setDynamicAttributeType(String dynamicAttributeType)
void
setExtraAttributesGroup(String extraAttributesGroup)
void
setFixedAttribute(Attribute fixedAttribute)
com.fasterxml.jackson.databind.node.ObjectNode
toJson()
String
toString()
void
validate(String owningGroup)
-
-
-
Constructor Detail
-
AttributeStatement
public AttributeStatement(String condition, String extraAttributesGroup, AttributeStatement.ConflictResolution conflictResolution, Attribute fixedAttribute)
Creates a statement assigning a fixed attribute- Parameters:
condition
-visibility
-extraAttributesGroup
-conflictResolution
-fixedAttribute
-
-
AttributeStatement
public AttributeStatement(String condition, String extraAttributesGroup, AttributeStatement.ConflictResolution conflictResolution, String dynamicAttributeType, String dynamicAttributeExpression)
Creates a statement assigning a dynamic attribute- Parameters:
condition
-visibility
-extraAttributesGroup
-conflictResolution
-dynamicAttributeType
-dynamicAttributeExpression
-
-
AttributeStatement
public AttributeStatement()
-
AttributeStatement
public AttributeStatement(com.fasterxml.jackson.databind.node.ObjectNode src)
-
-
Method Detail
-
getFixedEverybodyStatement
public static AttributeStatement getFixedEverybodyStatement(Attribute toAssign)
Creates a simple statement that assigns a given attribute to everybody- Parameters:
toAssign
-- Returns:
-
getFixedStatement
public static AttributeStatement getFixedStatement(Attribute toAssign, String extraGroup, String condition)
Creates a statement with a given condition and assigning a fixed attribute and conflict resolution set to skip.- Parameters:
toAssign
-condition
-- Returns:
-
getCondition
public String getCondition()
-
getExtraAttributesGroup
public String getExtraAttributesGroup()
-
setCondition
public void setCondition(String condition)
-
setExtraAttributesGroup
public void setExtraAttributesGroup(String extraAttributesGroup)
-
getConflictResolution
public AttributeStatement.ConflictResolution getConflictResolution()
-
setConflictResolution
public void setConflictResolution(AttributeStatement.ConflictResolution conflictResolution)
-
getFixedAttribute
public Attribute getFixedAttribute()
-
setFixedAttribute
public void setFixedAttribute(Attribute fixedAttribute)
-
getDynamicAttributeType
public String getDynamicAttributeType()
-
setDynamicAttributeType
public void setDynamicAttributeType(String dynamicAttributeType)
-
getDynamicAttributeExpression
public String getDynamicAttributeExpression()
-
setDynamicAttributeExpression
public void setDynamicAttributeExpression(String dynamicAttributeExpression)
-
dynamicAttributeMode
public boolean dynamicAttributeMode()
-
isSuitableForDirectedEvaluation
public boolean isSuitableForDirectedEvaluation(AttributeStatement.Direction direction, String groupOfStatement)
Checks if the statement can be evaluated in course of recursive evaluation of statements, without procuring (infinite) cycles.This is done as follows: statement can be always evaluated if it doen't depend on attributes in other groups. If it does it is checked whether a dependency group is in the provided direction of the current evaluation.
- Parameters:
direction
-groupOfStatement
-- Returns:
-
getAssignedAttributeName
public String getAssignedAttributeName()
Name of the assigned attribute, regardless whether values are fixed or dynamic.- Returns:
-
getCompiledCondition
public Serializable getCompiledCondition()
-
getCompiledDynamicAttributeExpression
public Serializable getCompiledDynamicAttributeExpression()
-
validate
public void validate(String owningGroup) throws IllegalAttributeValueException
- Throws:
IllegalAttributeValueException
-
toJson
public com.fasterxml.jackson.databind.node.ObjectNode toJson()
-
clone
public AttributeStatement clone()
-
-