@ThingworxExtensionApiClass(since={6,6}, canInstantiate=true) public class DataShape extends ServiceProviderEntity implements java.lang.Cloneable
Data shapes are an exposed form of a persistable data format in the ThingWorx platform. All entities that can be persisted, including
data shapes themselves, have a data shape describing their format. Data shapes are also used to define the format of an InfoTable
, DataTableThing
, and com.thingworx.streams.StreamThing.
The DataShape
class should not be confused with the {link DataShapeDefinition} class. DataShapeDefinition
is a transient,
serializable collection of field definitions. DataShape
is an actual entity backed by at least one DataShapeDefinition
object. It is persistent and modifiable via the REST APIs and user interface.
DataShapeDefinition
,
RootEntity
,
Serialized FormBASIC_PROPERTIES
NAME_COMPARATOR
Constructor and Description |
---|
DataShape()
Constructs a new, unnamed data shape object without any fields defined. |
Modifier and Type | Method and Description |
---|---|
void |
addFieldDefinition(FieldDefinition field)
Add a field definition to this data shape. |
void |
AddFieldDefinition(java.lang.String name,
java.lang.String description,
java.lang.String type,
java.lang.Integer ordinal,
java.lang.Boolean primaryKey,
java.lang.String dataShape)
Service Category: Fields
Service Description: Add a field definition.
An entity service that adds a new field to the current data shape. |
InfoTable |
CreateValues()
Service Category: Values
Service Description: Create an empty info table of the correct datashape for this data table.
An entity service that generates an info table backed by this data shape. |
InfoTable |
CreateValuesWithData(org.json.JSONObject values)
Service Category: Crawl
Service Description: Create an info table of the correct datashape for this stream and include data values.
An entity service that generates an info table backed by this data shape with a single row containing the values from the provided JSON object that match the fields defined in this shape. |
static DataShape |
fromJSON(org.json.JSONObject jsonObject)
Deprecated.
|
DataShapeDefinition |
getDataShape()
Returns the definition of this data shape independent of its hierarchy; inherited fields are not visible through this method. |
org.json.JSONObject |
GetDataShapeMetadataAsJSON()
Service Category: Metadata
Service Description: Get the metadata for this data shape as JSON.
An entity service that returns a JSON object describing the metadata for this data shape. |
EntityReferenceTypeMap |
getDependencies()
Returns a mapping describing all upstream and downstream dependencies for this data shape and its underlying fields. |
org.json.JSONObject |
GetEffectiveDataShapeMetadataAsJSON()
Service Category: Metadata
Service Description: Get the effective metadata for this data shape as JSON.
|
InfoTable |
GetEffectiveFieldDefinition(java.lang.String name)
Service Category: Fields
Service Description: Get an effective field definition by name for this data shape.
|
InfoTable |
GetEffectiveFieldDefinitions()
Service Category: Fields
Service Description: Get the effective fields for this data shape.
|
RelationshipTypes.ThingworxRelationshipTypes |
getEntityType()
Returns the entity type for this data shape. |
FieldDefinition |
getFieldDefinition(java.lang.String name)
Returns the definition of the field with the supplied name. |
InfoTable |
GetFieldDefinition(java.lang.String name)
Service Category: Fields
Service Description: Get a field definition by name for this data shape.
An entity service that returns an info table describing a requested field relevant to this data shape. |
InfoTable |
GetFieldDefinitions()
Service Category: Fields
Service Description: Get the fields for this data shape.
An entity service that returns an info table describing the fields relevant to this data shape. |
FieldDefinitionCollection |
getFields()
Returns a collection containing all of the fields relevant to this data shape. |
InfoTable |
GetRelatedEntities(java.lang.Double maxItems)
Service Category: Queries
Service Description: Get the entities that use this data shape.
An entity service that returns an info table listing all entities that utilize this data shape (i.e., all downstream dependencies). |
boolean |
hasPrimaryKey()
Tests if any field defined in this data shape has been set as a primary key. |
boolean |
matches(DataShapeDefinition ds1)
Determines whether or not the provided DataShapeDefinition matches this data shape. |
void |
RemoveFieldDefinition(java.lang.String name)
Service Category: Fields
Service Description: Remove a field definition.
An entity service that removes a field from this data shape. |
void |
setFields(FieldDefinitionCollection fields)
Assigns the collection of fields to this data shape, overwriting all existing fields. |
ValueCollection |
toValueCollection()
A helper method that creates a ValueCollection containing mappings describing the data shape and its field definitions. |
void |
UpdateFieldDefinition(java.lang.String name,
java.lang.String description,
java.lang.String type,
java.lang.Integer ordinal,
java.lang.Boolean primaryKey,
java.lang.String dataShape)
Service Category: Fields
Service Description: Update a field definition.
An entity service that modifies an existing field definition. |
void |
validateConfiguration(ImportedEntityCollection importedEntities)
|
getInstancePublicServiceDefinitions, getInstanceServiceDefinition, getInstanceServiceDefinitions, initializeEntity, preInitializeEntity, processAPIServiceRequest, processServiceRequest
AddConfigurationTableDefinition, addDesignTimePermission, AddDesignTimePermission, addRunTimePermission, AddRunTimePermission, AddTags, addVisibilityPermission, AddVisibilityPermission, CheckDesignTimePermission, CheckDesignTimePermissionForGroup, CheckDesignTimePermissionForUser, CheckPermission, CheckPermissionForGroup, CheckPermissionForUser, cleanupEntity, cleanupEntity, DeleteAllConfigurationTableRows, DeleteConfigurationTable, DeleteConfigurationTableRows, deleteDesignTimePermission, DeleteDesignTimePermission, deleteRunTimePermission, DeleteRunTimePermission, deleteVisibilityPermission, DeleteVisibilityPermission, dispose, getAspects, GetAvatar, getAvatarContent, GetAvatarURL, GetConfigurationChangeHistory, getConfigurationSetting, getConfigurationTable, GetConfigurationTable, GetConfigurationTableDefinition, GetConfigurationTableRow, GetConfigurationTables, GetDescription, getDesignTimePermissions, GetDesignTimePermissions, GetDesignTimePermissionsAsJSON, getDocumentationContent, getEntityTypeAsString, GetEventDefinition, GetEventDefinitions, GetHomeMashup, GetIncomingDependencies, GetIncomingDependenciesAsNetwork, GetInstanceMetadataAsJSON, GetInstanceMetadataWithPermissionsAsJSON, GetLastModifiedDate, GetMetadata, GetMetadataAsJSON, GetMetadataWithPermissionsAsJSON, GetOutgoingDependencies, GetOutgoingDependenciesAsNetwork, getOwner, GetPermissionsForCurrentUser, GetPermissionsForGroup, GetPermissionsForUser, GetProjectName, GetPropertyDefinition, GetPropertyDefinitions, getRunTimePermissions, GetRunTimePermissions, GetRunTimePermissionsAsJSON, GetServiceDefinition, GetServiceDefinitions, getStringConfigurationSetting, getStringConfigurationSettingWithDefault, GetSummaryInformation, getTags, GetTags, GetTagsAsInfoTable, getVisibilityPermissions, GetVisibilityPermissions, GetVisibilityPermissionsAsJSON, HasIncomingDependencies, HasOutgoingDependencies, isEditable, isEditableExtensionObject, isEditableSystemObject, isExtensionObject, IsMultiRowTable, isOwner, isSystemObject, isThemeObject, isVisible, isVisible, persistDesignTimePermissions, persistRunTimePermissions, persistVisibilityPermissions, RemoveTags, SaveConfigurationTables, SetAvatar, setConfigurationSetting, SetConfigurationTable, SetConfigurationTableRows, SetDescription, setDesignTimePermissions, SetDesignTimePermissionsAsJSON, setDocumentationContent, setExtensionObject, SetHomeMashup, setLastModifiedDate, SetMultiRowConfigurationTable, setOwner, SetOwner, SetProjectName, setRunTimePermissions, SetRunTimePermissionsAsJSON, setStringConfigurationSetting, SetTags, setVisibilityPermissions, SetVisibilityPermissionsAsJSON, toJSON, toJSONDefinition
getID, hasID, isTransient
getDescription, getName, setDescription, setName
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getID, hasID
getDescription, getName
getID, getName
@ThingworxExtensionApiMethod(since={6,6}) public DataShape()
@ThingworxExtensionApiMethod(since={6,6}) public void validateConfiguration(ImportedEntityCollection importedEntities) throws java.lang.Exception
RootEntity
Validates the configuration of the entity during the import process. This method is called whenever a entity is created or modified
via the REST APIs. During the validation step, there may be other associated entities that are being imported. These can be accessed
via the importedEntities
collection if needed.
Note that some resources belonging to the entity or other associated entities may not be available during this step in the lifecycle.
It is required for all subclasses of RootEntity
to call super.validateConfiguration(importedEntityCollections)
if
they override this method.
validateConfiguration
in class RootEntity
importedEntities
- a collection of entities that have been successfully importedjava.lang.Exception
- If an error occurs
@ThingworxExtensionApiMethod(since={6,6}) public DataShapeDefinition getDataShape()
@ThingworxExtensionApiMethod(since={6,6}) public boolean hasPrimaryKey()
true
if a field set as a primary key existsDataShapeDefinition.hasPrimaryKey()
@ThingworxExtensionApiMethod(since={6,6}) public void addFieldDefinition(FieldDefinition field)
field
- the field definition to add to this data shapeDataShapeDefinition.addFieldDefinition(FieldDefinition)
@ThingworxExtensionApiMethod(since={6,6}) public FieldDefinition getFieldDefinition(java.lang.String name)
name
- the name of the field to retrieveFieldDefinition
of the field with the supplied name, or null
if the field does not existDataShapeDefinition.getFieldDefinition(String)
@ThingworxExtensionApiMethod(since={6,6}) public FieldDefinitionCollection getFields()
DataShapeDefinition.getFields()
@ThingworxExtensionApiMethod(since={6,6}) public void setFields(FieldDefinitionCollection fields)
fields
- a collection containing the new fields for this data shapeDataShapeDefinition.setFields(FieldDefinitionCollection)
@ThingworxExtensionApiMethod(since={6,6}) public boolean matches(DataShapeDefinition ds1)
DataShapeDefinition
matches this data shape.ds1
- the definition to match against this data shapetrue
if the definition matches against this data shape@ThingworxExtensionApiMethod(since={6,6}) public InfoTable CreateValues() throws java.lang.Exception
java.lang.Exception
- if an error occurs@ThingworxExtensionApiMethod(since={6,6}) public InfoTable CreateValuesWithData(org.json.JSONObject values) throws java.lang.Exception
values
- a JSON object mapping the desired values to the field namesInfoTable
with a single row of datajava.lang.Exception
- if the value in the JSON object is not a legal representation of the field's base type@ThingworxExtensionApiMethod(since={6,6}) public InfoTable GetRelatedEntities(java.lang.Double maxItems) throws java.lang.Exception
maxItems
- the maximum number of entities to list (by default, it will be set to the value of
RESTAPIConstants.DEFAULT_ITEM_COUNT
)java.lang.Exception
- if an error occurs during dependency calculation@ThingworxExtensionApiMethod(since={6,6}) public org.json.JSONObject GetDataShapeMetadataAsJSON() throws java.lang.Exception
java.lang.Exception
- if an error occurs during JSON serialization@ThingworxExtensionApiMethod(since={6,6}) public org.json.JSONObject GetEffectiveDataShapeMetadataAsJSON() throws java.lang.Exception
java.lang.Exception
- If an error occurs@ThingworxExtensionApiMethod(since={6,6}) public InfoTable GetEffectiveFieldDefinitions() throws java.lang.Exception
java.lang.Exception
- If an error occurs@ThingworxExtensionApiMethod(since={6,6}) public InfoTable GetEffectiveFieldDefinition(java.lang.String name) throws java.lang.Exception
name
- Field name - STRINGjava.lang.Exception
- If an error occurs@ThingworxExtensionApiMethod(since={6,6}) public InfoTable GetFieldDefinitions() throws java.lang.Exception
InfoTable
describing the fieldsjava.lang.Exception
- if an error occurs@ThingworxExtensionApiMethod(since={6,6}) public InfoTable GetFieldDefinition(java.lang.String name) throws java.lang.Exception
name
- the name of the fieldjava.lang.Exception
- if the requested field does not exist@ThingworxExtensionApiMethod(since={6,6}) public void AddFieldDefinition(java.lang.String name, java.lang.String description, java.lang.String type, java.lang.Integer ordinal, java.lang.Boolean primaryKey, java.lang.String dataShape) throws java.lang.Exception
name
- the name of the field to createdescription
- the description of the fieldtype
- the type of the field, corresponding to a type in the BaseTypes
enumerationordinal
- the ordinality of the field to insertprimaryKey
- a boolean indicating if this field is a primary keydataShape
- the underlying data shape, if the type is assigned to INFOTABLE
java.lang.Exception
- if a validation error occurs@ThingworxExtensionApiMethod(since={6,6}) public void UpdateFieldDefinition(java.lang.String name, java.lang.String description, java.lang.String type, java.lang.Integer ordinal, java.lang.Boolean primaryKey, java.lang.String dataShape) throws java.lang.Exception
name
- the name of the field to modifydescription
- the description of the fieldtype
- the type of the field, corresponding to a type in the BaseTypes
enumerationordinal
- the ordinality of the fieldprimaryKey
- a boolean indicating if this field is a primary keydataShape
- the underlying data shape, if the type is assigned to INFOTABLE
java.lang.Exception
- if a validation error occurs@ThingworxExtensionApiMethod(since={6,6}) public void RemoveFieldDefinition(java.lang.String name) throws java.lang.Exception
name
- the name of the field to removejava.lang.Exception
- if the field does not exist@ThingworxExtensionApiMethod(since={6,6}) public EntityReferenceTypeMap getDependencies()
@ThingworxExtensionApiMethod(since={6,6}) public ValueCollection toValueCollection()
ValueCollection
containing mappings describing the data shape and its field definitions.toValueCollection
in class NamedObject
@ThingworxExtensionApiMethod(since={6,6}) public RelationshipTypes.ThingworxRelationshipTypes getEntityType()
getEntityType
in class RootEntity
DataShape
constant@Deprecated @ThingworxExtensionApiMethod(since={6,6}, deprecatedSince={8,4}) public static DataShape fromJSON(org.json.JSONObject jsonObject) throws java.lang.Exception
jsonObject
- the JSON object describing the serialized data shapeDataShape
described by the JSON objectjava.lang.Exception
- if the JSON object does not properly represent a DataShape