Package com.simplicite.util
Class ObjectFieldList
- java.lang.Object
-
- com.simplicite.util.ObjectFieldList
-
- All Implemented Interfaces:
java.io.Serializable
public class ObjectFieldList extends java.lang.Object implements java.io.Serializable
Contextual Field List- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
ObjectFieldList.ListLink
Linked lists mapped with codes
-
Constructor Summary
Constructors Constructor Description ObjectFieldList(ObjectField field)
Constructor
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
changeValues(java.lang.String[] values, boolean all)
Force translation of each itemsboolean
containsCode(java.lang.String code, boolean all)
Contains a code ?boolean
containsCodes(java.lang.String[] codes, boolean all)
Contains a list of codes ?boolean
containsValue(java.lang.String value, boolean all)
Contains a value ?java.util.List<EnumItem>
getAllItems()
Get all list items (simple list, union of linked lists or all status)java.lang.String
getCode(int index)
Code at position indexjava.lang.String[]
getCodes(boolean all)
Get all codes as an arrayjava.lang.String
getDefaultLabel()
Default label to displayObjectField
getField()
Related object fieldjava.lang.String
getId()
Get the list IDEnumItem
getItem(int index)
Item at position indexEnumItem
getItem(java.lang.String code, boolean all)
Get the item matching with the codeEnumItem
getItemByValue(java.lang.String value, boolean all)
Get the item matching with the valueint
getItemIndex(java.lang.String code, boolean all)
Get the item index matching with the codejava.util.List<EnumItem>
getItems()
Get current items (simple list, linked list or allowed status)java.lang.String
getLinkedFieldList(java.lang.String object, java.lang.String field, java.lang.String code)
Get the linked list namejava.util.Iterator<java.lang.String>
getLinkedFields()
Get all linked object:inputsjava.util.Map<java.lang.String,ObjectFieldList.ListLink>
getLinkedLists()
object:input => code => linked liststatic java.util.List<java.lang.String[]>
getListObjects(java.lang.String list)
List objects containing the listjava.lang.String
getName()
Get the list namestatic java.util.List<java.lang.String[]>
getObjectLov(java.lang.String object)
List LOV containing the objectObjectField
getParentField()
Parent field (when linked to this parent values)java.lang.String
getValue(int index)
Translated value at position indexjava.lang.String[]
getValues(boolean all)
Get all values as an arrayObjectField
initLinkedField(ObjectDB obj, java.lang.String field, java.lang.String code)
Prepare the linked listObjectField
initLinkedField(ObjectDB obj, java.lang.String field, java.lang.String code, boolean search)
Prepare the linked listvoid
initList(ObjectDB obj, boolean create)
Prepare the list of values: including the state model specification, or enable current items when field is updatablevoid
load(ObjectDB obj, java.lang.String name, Grant g)
Load the contextual list of valuesvoid
putItem(EnumItem item)
Append or replace an item in the listvoid
putItem(java.lang.String code, java.lang.String value, boolean enabled)
Append or replace a code/value in the listvoid
putItem(java.lang.String code, java.lang.String value, boolean enabled, int order)
Append or replace a code/value in the listvoid
setDefaultLabel(java.lang.String defaultLabel)
Change the default labelvoid
setField(ObjectField field)
Set the related enumerated fieldvoid
setItems(java.util.List<EnumItem> items)
Set current itemsvoid
setLinkedLists(java.util.HashMap<java.lang.String,ObjectFieldList.ListLink> links)
void
setName(java.lang.String name)
Set the list namevoid
setParentField(ObjectField parent)
Set the parent field (when linked to this parent values)void
showIconsAndLabels(boolean icon, boolean label)
Show icons and labelsorg.json.JSONObject
toJSONObject()
Generates a JSON object representation of the listjava.lang.String
toString()
Generates a string representation of the list
-
-
-
Constructor Detail
-
ObjectFieldList
public ObjectFieldList(ObjectField field)
Constructor- Parameters:
field
- Related enumerate field
-
-
Method Detail
-
load
public void load(ObjectDB obj, java.lang.String name, Grant g)
Load the contextual list of values- Parameters:
obj
- Business object (required to load its linked lists)name
- List nameg
- User rights
-
getId
public java.lang.String getId()
Get the list ID
-
getName
public java.lang.String getName()
Get the list name
-
setName
public void setName(java.lang.String name)
Set the list name
-
getField
public ObjectField getField()
Related object field
-
setField
public void setField(ObjectField field)
Set the related enumerated field
-
getParentField
public ObjectField getParentField()
Parent field (when linked to this parent values)
-
setParentField
public void setParentField(ObjectField parent)
Set the parent field (when linked to this parent values)
-
getAllItems
public java.util.List<EnumItem> getAllItems()
Get all list items (simple list, union of linked lists or all status)
-
getItems
public java.util.List<EnumItem> getItems()
Get current items (simple list, linked list or allowed status)
-
setItems
public void setItems(java.util.List<EnumItem> items)
Set current items
-
getDefaultLabel
public java.lang.String getDefaultLabel()
Default label to display
-
setDefaultLabel
public void setDefaultLabel(java.lang.String defaultLabel)
Change the default label
-
getItem
public EnumItem getItem(int index)
Item at position index
-
getCode
public java.lang.String getCode(int index)
Code at position index
-
getValue
public java.lang.String getValue(int index)
Translated value at position index
-
getCodes
public java.lang.String[] getCodes(boolean all)
Get all codes as an array- Parameters:
all
- union of lists or current one
-
containsCode
public boolean containsCode(java.lang.String code, boolean all)
Contains a code ?- Parameters:
code
- Code to search among codesall
- search in union of lists or current one
-
containsCodes
public boolean containsCodes(java.lang.String[] codes, boolean all)
Contains a list of codes ?- Parameters:
codes
- codes to search among codesall
- search in union of lists or current one
-
getValues
public java.lang.String[] getValues(boolean all)
Get all values as an array- Parameters:
all
- union of lists or current one
-
containsValue
public boolean containsValue(java.lang.String value, boolean all)
Contains a value ?- Parameters:
value
- Value to search among valuesall
- search in union of lists or current one
-
changeValues
public void changeValues(java.lang.String[] values, boolean all)
Force translation of each items
-
putItem
public void putItem(java.lang.String code, java.lang.String value, boolean enabled)
Append or replace a code/value in the list
-
putItem
public void putItem(java.lang.String code, java.lang.String value, boolean enabled, int order)
Append or replace a code/value in the list
-
putItem
public void putItem(EnumItem item)
Append or replace an item in the list
-
getItem
public EnumItem getItem(java.lang.String code, boolean all)
Get the item matching with the code
-
getItemByValue
public EnumItem getItemByValue(java.lang.String value, boolean all)
Get the item matching with the value
-
getItemIndex
public int getItemIndex(java.lang.String code, boolean all)
Get the item index matching with the code
-
getListObjects
public static java.util.List<java.lang.String[]> getListObjects(java.lang.String list)
List objects containing the list
- Parameters:
list
- List name- Returns:
- list of (objectName, objectId)
-
getObjectLov
public static java.util.List<java.lang.String[]> getObjectLov(java.lang.String object)
List LOV containing the object
- Parameters:
object
- Object name or null to get all lists
-
initList
public void initList(ObjectDB obj, boolean create)
Prepare the list of values: including the state model specification, or enable current items when field is updatable- Parameters:
obj
- selected object with grantscreate
- indicate if the initial state must be set
-
getLinkedLists
public java.util.Map<java.lang.String,ObjectFieldList.ListLink> getLinkedLists()
object:input => code => linked list
-
setLinkedLists
public void setLinkedLists(java.util.HashMap<java.lang.String,ObjectFieldList.ListLink> links)
-
getLinkedFields
public java.util.Iterator<java.lang.String> getLinkedFields()
Get all linked object:inputs
-
getLinkedFieldList
public java.lang.String getLinkedFieldList(java.lang.String object, java.lang.String field, java.lang.String code)
Get the linked list name- Parameters:
object
- Objectfield
- Linked field namecode
- Original code- Returns:
- List of value name to apply to the linked field
-
initLinkedField
public ObjectField initLinkedField(ObjectDB obj, java.lang.String field, java.lang.String code)
Prepare the linked list- Parameters:
obj
- Objectfield
- Linked field namecode
- Original code(s) separated with ';'- Returns:
- Reloaded Linked field, or null if unknown
-
initLinkedField
public ObjectField initLinkedField(ObjectDB obj, java.lang.String field, java.lang.String code, boolean search)
Prepare the linked list- Parameters:
obj
- Objectfield
- Linked field namecode
- Selected code(s) separated with ';'search
- Get all linked values when code is empty in a search context- Returns:
- Reloaded Linked field, or null if unknown
-
showIconsAndLabels
public void showIconsAndLabels(boolean icon, boolean label)
Show icons and labels- Parameters:
icon
- true to show icons (if exists on code)label
- true to show labels
-
toJSONObject
public org.json.JSONObject toJSONObject()
Generates a JSON object representation of the list- Returns:
- list as JSON object
-
toString
public java.lang.String toString()
Generates a string representation of the list- Overrides:
toString
in classjava.lang.Object
- Returns:
- list as string
-
-