Class ContextImpl
- java.lang.Object
-
- org.gcube.informationsystem.base.impl.ElementImpl
-
- org.gcube.informationsystem.base.impl.entities.EntityElementImpl
-
- org.gcube.informationsystem.contexts.impl.entities.ContextImpl
-
- All Implemented Interfaces:
Serializable,Element,EntityElement,IdentifiableElement,SchemaMixedElement,Context
public class ContextImpl extends EntityElementImpl implements Context
The default implementation of theContextinterface.- Author:
- Luca Frosini (ISTI - CNR)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected Map<String,Object>additionalPropertiesAdditional properties of the context.protected Set<String>allowedAdditionalKeysA set of keys that are allowed as additional properties, even if they start with '_' or '@'.protected List<Context>childrenThe children of the context.protected ContextStateeffectiveStateThe effective (inherited) state of the context.protected List<Event>historyThe history events of the context.protected StringnameThe name of the context.protected ContextparentThe parent of the context.protected StringpathThe hierarchical path of the context, e.g.protected Set<String>previousPathsThe previous hierarchical paths under which this context still resolves.protected ContextStatestateThe state of the context.-
Fields inherited from class org.gcube.informationsystem.base.impl.entities.EntityElementImpl
metadata, uuid
-
Fields inherited from interface org.gcube.informationsystem.contexts.reference.entities.Context
CHILDREN_PROPERTY, EFFECTIVE_STATE, HISTORY, NAME, NAME_PROPERTY, NAME_REGEX, PARENT_PROPERTY, PATH, PREVIOUS_PATHS, STATE
-
Fields inherited from interface org.gcube.informationsystem.base.reference.Element
DATETIME_PATTERN, NAME, REDACTED, TYPE_PROPERTY, UNKNOWN_USER
-
Fields inherited from interface org.gcube.informationsystem.base.reference.entities.EntityElement
NAME
-
Fields inherited from interface org.gcube.informationsystem.base.reference.IdentifiableElement
ID_PROPERTY, METADATA_PROPERTY
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedContextImpl()Default constructor.ContextImpl(String name)Constructs a new context with a given name.ContextImpl(String name, UUID uuid)Constructs a new context with a given name and UUID.ContextImpl(UUID uuid)Constructs a new context with a given UUID.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddChild(UUID uuid)Adds a child to this context by its UUID.voidaddChild(Context child)Adds a child to this context.protected voidaddChildFromJson(Context child)Adds a child from a JSON-deserialized context object.Map<String,Object>getAdditionalProperties()Returns a map of all additional properties not defined in the schema.ObjectgetAdditionalProperty(String key)Retrieves a single additional property by its key.List<Context>getChildren()Returns the children of this context.ContextStategetEffectiveState()Returns the current effective state of the context.List<Event>getHistory()Returns the list of history events for this context.StringgetName()Returns the name of the context.ContextgetParent()Returns the parent of this context.StringgetPath()Returns the hierarchical path of the context, e.g.Set<String>getPreviousPaths()Returns the set of historical paths this context still answers to.ContextStategetState()Returns the current state of the context.voidsetAdditionalProperties(Map<String,Object> additionalProperties)Sets the map of additional properties for the element.voidsetAdditionalProperty(String key, Object value)Sets a single additional property.protected voidsetChildrenFromJson(List<Context> children)Sets the children from a JSON-deserialized list of contexts.voidsetEffectiveState(ContextState effectiveState)Sets the effective state of the context.voidsetHistory(List<Event> history)Sets the history events for this context.voidsetName(String name)Sets the name of the context.voidsetParent(UUID uuid)Sets the parent of this context by its UUID.voidsetParent(Context context)Sets the parent of this context.protected voidsetParentFromJson(Context context)Sets the parent from a JSON-deserialized context object.voidsetPath(String path)Sets the hierarchical path of the context.voidsetPreviousPaths(Set<String> previousPaths)Sets the set of historical paths this context still answers to.voidsetState(ContextState state)Sets the state of the context.-
Methods inherited from class org.gcube.informationsystem.base.impl.entities.EntityElementImpl
getID, getMetadata, setID, setMetadata
-
Methods inherited from class org.gcube.informationsystem.base.impl.ElementImpl
getTypeName, toString
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.gcube.informationsystem.base.reference.Element
getTypeName
-
Methods inherited from interface org.gcube.informationsystem.base.reference.entities.EntityElement
getID, getMetadata, setID, setMetadata
-
-
-
-
Field Detail
-
name
protected String name
The name of the context.
-
parent
protected Context parent
The parent of the context.
-
path
protected String path
The hierarchical path of the context, e.g./gcube/devsec/devVRE.
-
previousPaths
protected Set<String> previousPaths
The previous hierarchical paths under which this context still resolves.
-
state
protected ContextState state
The state of the context.
-
effectiveState
protected ContextState effectiveState
The effective (inherited) state of the context.
-
additionalProperties
protected Map<String,Object> additionalProperties
Additional properties of the context.
-
-
Constructor Detail
-
ContextImpl
protected ContextImpl()
Default constructor.
-
ContextImpl
public ContextImpl(UUID uuid)
Constructs a new context with a given UUID.- Parameters:
uuid- The UUID.
-
ContextImpl
public ContextImpl(String name)
Constructs a new context with a given name.- Parameters:
name- The name.
-
-
Method Detail
-
getName
public String getName()
Returns the name of the context.
-
setName
public void setName(String name)
Sets the name of the context.
-
getPath
public String getPath()
Returns the hierarchical path of the context, e.g./gcube/devsec/devVRE.
-
setPath
public void setPath(String path)
Sets the hierarchical path of the context.This method is intended for internal use by the resource-registry to persist the path at creation, rename, and reparent time. It is not expected to be called by external clients, and may not perform any path validation or recomputation.
-
getPreviousPaths
public Set<String> getPreviousPaths()
Returns the set of historical paths this context still answers to.- Specified by:
getPreviousPathsin interfaceContext- Returns:
- The set of previous paths, never
null(empty set by default).
-
setPreviousPaths
public void setPreviousPaths(Set<String> previousPaths)
Sets the set of historical paths this context still answers to.- Specified by:
setPreviousPathsin interfaceContext- Parameters:
previousPaths- The set of previous paths to set.
-
getState
public ContextState getState()
Returns the current state of the context.
-
setState
public void setState(ContextState state)
Sets the state of the context.
-
getEffectiveState
public ContextState getEffectiveState()
Returns the current effective state of the context.- Specified by:
getEffectiveStatein interfaceContext- Returns:
- The context effective state.
-
setEffectiveState
public void setEffectiveState(ContextState effectiveState)
Sets the effective state of the context.The effective state is derived from the context's own
Context.STATEand the effective state of its parent chain. A context isSUSPENDEDwhen any ancestor isCREATEDorSUSPENDED, regardless of the context's own local state. This method is intended for internal use by the resource-registry to persist the effective state at creation, rename, reparent, and state change time. It is not expected to be called by external clients, and may not perform any effective state recomputation based on the parent chain.- Specified by:
setEffectiveStatein interfaceContext- Parameters:
effectiveState- The effective state to set.
-
getParent
public Context getParent()
Returns the parent of this context.
-
setParent
public void setParent(UUID uuid)
Sets the parent of this context by its UUID.
-
setParent
public void setParent(Context context)
Sets the parent of this context.
-
setParentFromJson
protected void setParentFromJson(Context context)
Sets the parent from a JSON-deserialized context object.- Parameters:
context- The deserialized parent context.
-
getChildren
public List<Context> getChildren()
Returns the children of this context.- Specified by:
getChildrenin interfaceContext- Returns:
- A list of child contexts.
-
setChildrenFromJson
protected void setChildrenFromJson(List<Context> children)
Sets the children from a JSON-deserialized list of contexts.- Parameters:
children- The list of deserialized child contexts.
-
addChildFromJson
protected void addChildFromJson(Context child)
Adds a child from a JSON-deserialized context object.- Parameters:
child- The deserialized child context.
-
addChild
public void addChild(UUID uuid)
Adds a child to this context by its UUID.
-
addChild
public void addChild(Context child)
Adds a child to this context.
-
getHistory
public List<Event> getHistory()
Returns the list of history events for this context.- Specified by:
getHistoryin interfaceContext- Returns:
- The history events.
-
setHistory
public void setHistory(List<Event> history)
Sets the history events for this context.- Specified by:
setHistoryin interfaceContext- Parameters:
history- The history events to set.
-
getAdditionalProperties
public Map<String,Object> getAdditionalProperties()
Returns a map of all additional properties not defined in the schema.- Specified by:
getAdditionalPropertiesin interfaceContext- Specified by:
getAdditionalPropertiesin interfaceSchemaMixedElement- Returns:
- A
Mapcontaining the additional properties, where the key is the property name and the value is the property value.
-
setAdditionalProperties
public void setAdditionalProperties(Map<String,Object> additionalProperties)
Sets the map of additional properties for the element.- Specified by:
setAdditionalPropertiesin interfaceContext- Specified by:
setAdditionalPropertiesin interfaceSchemaMixedElement- Parameters:
additionalProperties- AMapof additional properties.
-
getAdditionalProperty
public Object getAdditionalProperty(String key)
Retrieves a single additional property by its key.- Specified by:
getAdditionalPropertyin interfaceContext- Specified by:
getAdditionalPropertyin interfaceSchemaMixedElement- Parameters:
key- The name of the additional property to retrieve.- Returns:
- The value of the property, or
nullif the key is not found.
-
setAdditionalProperty
public void setAdditionalProperty(String key, Object value)
Sets a single additional property.- Specified by:
setAdditionalPropertyin interfaceContext- Specified by:
setAdditionalPropertyin interfaceSchemaMixedElement- Parameters:
key- The name of the additional property.value- The value of the additional property.
-
-