Skip to main content
Version: latest 1.3.x

API - Attribute

The attribute class provides read and write access to attributes of resources, activities and projects.

Fields

FieldTypeDescription
nameStringField name
groupStringField group
dataTypeStringData type identifier
stringValueStringString representation of value
mandatoryBooleanWhether field is mandatory
visibleBooleanWhether field is visible
editableBooleanWhether field is editable
activeBooleanWhether field is active
restrictionRestrictionValidation restrictions

The following data types are supported:

  • APPROVE / APPROVEREJECT - Approval/rejection boolean
  • BOOLEAN - Standard boolean
  • COMPOSE - Composed value
  • DATE - Date value
  • DECIMAL - Decimal number
  • FILE_MANAGEMENT - File handling
  • IDGENERATOR - Auto-generated ID
  • MULTISELECTLIST - Multi-select list
  • NUMBER - Integer/long
  • OWNED_OBJECTLIST - Owned object list
  • RESOURCE - Resource reference
  • ROOT_VALUELIST - Root value list
  • STATUS_ENGINE - Status engine
  • TEMPLATE_VALUELIST - Template value list
  • TEXT / TEXT_LONG - Text fields
  • USER - User reference
  • VALUELIST - Single value list

Methods for getting general information

// Basic getters
/**
*
* @return the name (former manual id) of the attribute.
*/
String getName();

/**
*
* @return the group name (formaer manual id) of the attribute.
*/
String getGroup();
boolean isActive(); // @deprecated

/**
* Information whether the attribute has changed compared to the
* original value saved in the database.
* @return
*/
boolean isChanged();

/**
*
* @return the data type of the attribute.
*/
String getDataType();

/**
*
* @return the value of the attribute as string representation,
* dependend on the type different formatters are used.
*/
String getValueAsString();

/**
*
* @return the display name (Label) of the attribute, if defined by the administrator.
* E.g. for user-friendly display of warnings.
*/
String getDisplayName();

/**
*
* @return whether the attribute is considered empty. For example, a
* multi-select list attribute is considered empty if no value is selected.
*/
boolean isEmpty();

/**
*
* @return whether the attribute is mandatory. Mandatory attributes need to be filled before saving.
*/
void setMandatory(Boolean mandatory);

/**
*
* @return whether the attribute is visible. Invisible attributes are not shown in the UI input masks.
*/
void setVisible(Boolean visible);

/**
*
* @return whether the attribute is editable. Non-editable attributes are shown in the UI input masks but cannot be changed.
*/
void setEditable(Boolean editable);

Type-specific getters

/**
*
* @return the value of the attribute as long, e.g. if the attribute is of type NUMBER
*/
Long getValueAsLong();
/**
*
* @return the value of the attribute as decimal, e.g. if the attribute is of type DECIMAL
*/
BigDecimal getValueAsDecimal();
/**
*
* @return the value of the attribute as date, e.g. if the attribute is of type DATE
*/
Date getValueAsDate();

/**
*
* @return the value of the attribute as boolean, e.g. if the attribute is of type BOOLEAN
*/
Boolean getValueAsBoolean();

/**
*
* @return the value of the attribute as user, e.g. if the attribute is of type USER
*/
User getValueAsUser();

/**
*
* @return get seleccted values with their string representation, e.g.
* if the attribute is of type MULTISELECTLIST
*/
String[] getSelectedStringValues();

/**
*
* @return get selected values as resource references, e.g. if
* the attribute is of type OWNED_OBJECTLIST
*/
Resource[] getOwnedObjectList();

/**
*
* @return get selected value as resource reference, e.g. if the attribute
* is of type VALUELIST, TEMPLATE_VALUELIST or ROOT_VALUELIST
*/
Resource getSelectedValue();

/**
*
* @return get selected values as resource references, e.g. if
* the attribute is of type MULTISELECTLIST
*/
Resource[] getSelectedValues();


Type specific setters

/**
*
* @param value New value of the attribute as string representation
* @throws DataAccessException
*/
void setValueAsString(String value) throws DataAccessException;

/**
*
* @param value New value of the attribute as long, e.g. if the attribute is of type NUMBER
* @throws DataAccessException
*/
void setValueAsLong(Long value) throws DataAccessException;

/**
*
* @param value New value of the attribute as decimal, e.g. if the attribute is of type DECIMAL
* @throws DataAccessException
*/
void setValueAsDecimal(BigDecimal value) throws DataAccessException;

/**
*
* @param value New value of the attribute as date, e.g. if the attribute is of type DATE
* @throws DataAccessException
*/
void setValueAsDate(Date value) throws DataAccessException;

/**
*
* @param value New value of the attribute as boolean, e.g. if the attribute is of type BOOLEAN
* @throws DataAccessException
*/
void setValueAsBoolean(Boolean value) throws DataAccessException;

/**
*
* @param userId New value (loginname) of the attribute as user, e.g.
* if the attribute is of type USER
* @throws DataAccessException
*/
void setValueAsUser(String userId) throws DataAccessException;

/**
*
* @param values New selected values with their string representation, e.g.
* if the attribute is of type MULTISELECTLIST
* @throws DataAccessException
*/
void setSelectedStringValues(String[] values) throws DataAccessException;

Setting input restrictions of attributes

For the attributes restrictions can be defined. Restrictions can be altered within the Drools session and will be finally validated by rules with salience -500. See Restrictions API for details.

/**
*
* @return the restriction of the attribute.
*/
Restriction getRestriction();

Copy attribute values

To copy an attribute independent and create the according typed values this method can be used. The copied attribute will have the same value as the original attribute.

// Special operations
void copyFromAttribute(Attribute sourceAttribute) throws DataAccessException;