Class DataShape
- All Implemented Interfaces:
ISupportsAccessModifier,IConfigurableObject,INotScriptFriendly,ISupportsDeprecation,IDiffableObject,IAvatar,IEntityLifeCycleEvent,IPersistable,IServiceProvider,ITaggableObject,IDependencyScannableObject,IEntityDefinition,IPersistableObject<String>,IDesignTimeSecurable,IDesignTimeSecurableEntity,IRunTimeSecurable,IRunTimeSecurableEntity,ISecurable,IVisibilitySecurable,IVisibilitySecurableEntity,IAspectContainer,INamedObject,Serializable,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.
- See Also:
-
Field Summary
Fields inherited from class com.thingworx.entities.RootEntity
BASIC_PROPERTY_DEFINITIONS, EXCLUDED_ENTITY_TYPES_IN_PROJECTFields inherited from class com.thingworx.types.NamedObject
NAME_COMPARATOR -
Constructor Summary
ConstructorsConstructorDescriptionConstructs a new, unnamed data shape object without any fields defined. -
Method Summary
Modifier and TypeMethodDescriptionvoidAdd a field definition to this data shape.voidAddFieldDefinition(String name, String description, String type, Integer ordinal, Boolean primaryKey, String dataShape) Service Category: Fields Service Description: Add a field definition.Service Category: Values Service Description: Create an empty info table of the correct datashape for this data table.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.static DataShapefromJSON(org.json.JSONObject jsonObject) Deprecated.Returns the definition of this data shape independent of its hierarchy; inherited fields are not visible through this method.org.json.JSONObjectService Category: Metadata Service Description: Get the metadata for this data shape as JSON.Returns a mapping describing all upstream and downstream dependencies for this data shape and its underlying fields.org.json.JSONObjectService Category: Metadata Service Description: Get the effective metadata for this data shape as JSON.Service Category: Fields Service Description: Get an effective field definition by name for this data shape.Service Category: Fields Service Description: Get the effective fields for this data shape.Returns the entity type for this data shape.getFieldDefinition(String name) Returns the definition of the field with the supplied name.GetFieldDefinition(String name) Service Category: Fields Service Description: Get a field definition by name for this data shape.Service Category: Fields Service Description: Get the fields for this data shape.Returns a collection containing all of the fields relevant to this data shape.GetRelatedEntities(Double maxItems) Service Category: Queries Service Description: Get the entities that use this data shape.booleanTests if any field defined in this data shape has been set as a primary key.booleanDetermines whether or not the providedDataShapeDefinitionmatches this data shape.voidRemoveFieldDefinition(String name) Service Category: Fields Service Description: Remove a field definition.voidsetFields(FieldDefinitionCollection fields) Assigns the collection of fields to this data shape, overwriting all existing fields.A helper method that creates aValueCollectioncontaining mappings describing the data shape and its field definitions.voidUpdateFieldDefinition(String name, String description, String type, Integer ordinal, Boolean primaryKey, String dataShape) Service Category: Fields Service Description: Update a field definition.voidvalidateConfiguration(ImportedEntityCollection importedEntities) Verifies that this data shape is valid and that any other entities it references have been imported or persisted.Methods inherited from class com.thingworx.entities.ServiceProviderEntity
getInstancePublicServiceDefinitions, getInstanceServiceDefinition, getInstanceServiceDefinitions, initializeEntity, preInitializeEntity, processAPIServiceRequest, processServiceRequestMethods inherited from class com.thingworx.entities.RootEntity
AddConfigurationTableDefinition, AddConfigurationTableDefinition, addDesignTimePermission, AddDesignTimePermission, addRunTimePermission, AddRunTimePermission, AddTags, addVisibilityPermission, AddVisibilityPermission, CheckDesignTimePermission, CheckDesignTimePermissionForGroup, CheckDesignTimePermissionForUser, CheckPermission, CheckPermissionForGroup, CheckPermissionForUser, cleanupEntity, DeleteAllConfigurationTableRows, DeleteConfigurationTable, DeleteConfigurationTableRows, 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, 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, ListDeprecatedUsage, 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, UpdateProjectDependenciesMethods inherited from class com.thingworx.persistence.common.PersistableNamedObject
getID, hasID, isTransientMethods inherited from class com.thingworx.types.NamedObject
getDescription, getName, setDescription, setNameMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.thingworx.types.INamedObject
getDescription, getNameMethods inherited from interface com.thingworx.entities.interfaces.IPersistable
getID, hasIDMethods inherited from interface com.thingworx.security.permissions.ISecurable
getID, getNameMethods inherited from interface com.thingworx.accesscontrol.ISupportsAccessModifier
getAccessModifier, getAccessModifierScope, getExemptList, hasAccessModifier, isInternalAccess, isPrivateAccess, isRestrictedAccessMethods inherited from interface com.thingworx.deprecation.ISupportsDeprecation
getDeprecated, isDeprecated, isDeprecatedBefore, since
-
Constructor Details
-
DataShape
Constructs a new, unnamed data shape object without any fields defined. The data shape is not yet persisted.
-
-
Method Details
-
validateConfiguration
@ThingworxExtensionApiMethod(since={6,6}) public void validateConfiguration(ImportedEntityCollection importedEntities) throws Exception Verifies that this data shape is valid and that any other entities it references have been imported or persisted. This includes the following:- The data shape inheritance hierarchy does not contain any cycles
- The base data shape, if defined, refers to a data shape that exists or is in the list of entities that are imported
- Each field name is valid
- If a field has a base type of InfoTable with a data shape assigned to it, that the backing data shape has been persisted.
- Overrides:
validateConfigurationin classRootEntity- Parameters:
importedEntities- a collection of entities that have been successfully imported- Throws:
Exception- if the entity is invalid
-
getDataShape
Returns the definition of this data shape independent of its hierarchy; inherited fields are not visible through this method.- Returns:
- the data shape definition for this shape, ignoring any inherited fields
-
hasPrimaryKey
Tests if any field defined in this data shape has been set as a primary key.- Returns:
trueif a field set as a primary key exists- See Also:
-
addFieldDefinition
Add a field definition to this data shape.- Parameters:
field- the field definition to add to this data shape- See Also:
-
getFieldDefinition
Returns the definition of the field with the supplied name.- Parameters:
name- the name of the field to retrieve- Returns:
- the
FieldDefinitionof the field with the supplied name, ornullif the field does not exist - See Also:
-
getFields
Returns a collection containing all of the fields relevant to this data shape.- Returns:
- a {code FieldDefinitionCollection} containing all of the fields relevant to this data shape
- See Also:
-
setFields
Assigns the collection of fields to this data shape, overwriting all existing fields.- Parameters:
fields- a collection containing the new fields for this data shape- See Also:
-
matches
Determines whether or not the providedDataShapeDefinitionmatches this data shape.- Parameters:
ds1- the definition to match against this data shape- Returns:
trueif the definition matches against this data shape
-
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.
- Returns:
- an info table using this data shape for its field definitions
- Throws:
Exception- if an error occurs
-
CreateValuesWithData
@ThingworxExtensionApiMethod(since={6,6}) public InfoTable CreateValuesWithData(org.json.JSONObject values) throws Exception - 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.
- Parameters:
values- a JSON object mapping the desired values to the field names- Returns:
- the generated
InfoTablewith a single row of data - Throws:
Exception- if the value in the JSON object is not a legal representation of the field's base type
-
GetRelatedEntities
@ThingworxExtensionApiMethod(since={6,6}) public InfoTable GetRelatedEntities(Double maxItems) throws Exception - 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).
- Parameters:
maxItems- the maximum number of entities to list (by default, it will be set to the value ofRESTAPIConstants.DEFAULT_ITEM_COUNT)- Returns:
- an info table of entities
- Throws:
Exception- if an error occurs during dependency calculation
-
GetDataShapeMetadataAsJSON
@ThingworxExtensionApiMethod(since={6,6}) public org.json.JSONObject GetDataShapeMetadataAsJSON() throws Exception- 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.
- Returns:
- the metadata represented in JSON
- Throws:
Exception- if an error occurs during JSON serialization
-
GetEffectiveDataShapeMetadataAsJSON
@ThingworxExtensionApiMethod(since={6,6}) public org.json.JSONObject GetEffectiveDataShapeMetadataAsJSON() throws Exception- Service Category:
- Metadata
- Service Description:
- Get the effective metadata for this data shape as JSON.
- Returns:
- result Field definitions - JSON
- Throws:
Exception- if an error occurs
-
GetEffectiveFieldDefinitions
@ThingworxExtensionApiMethod(since={6,6}) public InfoTable GetEffectiveFieldDefinitions() throws Exception- Service Category:
- Fields
- Service Description:
- Get the effective fields for this data shape.
- Returns:
- result Field definitions - INFOTABLE - Aspects {dataShape:FieldDefinition}
- Throws:
Exception- if an error occurs
-
GetEffectiveFieldDefinition
@ThingworxExtensionApiMethod(since={6,6}) public InfoTable GetEffectiveFieldDefinition(String name) throws Exception - Service Category:
- Fields
- Service Description:
- Get an effective field definition by name for this data shape.
- Parameters:
name- Field name - STRING- Returns:
- result Field definitions - INFOTABLE - Aspects {dataShape:FieldDefinition}
- Throws:
Exception- if an error occurs
-
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.
- Returns:
- an
InfoTabledescribing the fields - Throws:
Exception- if an error occurs
-
GetFieldDefinition
@ThingworxExtensionApiMethod(since={6,6}) public InfoTable GetFieldDefinition(String name) throws Exception - 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.
- Parameters:
name- the name of the field- Returns:
- an info table describing the requested field
- Throws:
Exception- if the requested field does not exist
-
AddFieldDefinition
@ThingworxExtensionApiMethod(since={6,6}) public void AddFieldDefinition(String name, String description, String type, Integer ordinal, Boolean primaryKey, String dataShape) throws Exception - Service Category:
- Fields
- Service Description:
- Add a field definition.
An entity service that adds a new field to the current data shape.
- Parameters:
name- the name of the field to createdescription- the description of the fieldtype- the type of the field, corresponding to a type in theBaseTypesenumerationordinal- 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 toINFOTABLE- Throws:
Exception- if a validation error occurs
-
UpdateFieldDefinition
@ThingworxExtensionApiMethod(since={6,6}) public void UpdateFieldDefinition(String name, String description, String type, Integer ordinal, Boolean primaryKey, String dataShape) throws Exception - Service Category:
- Fields
- Service Description:
- Update a field definition.
An entity service that modifies an existing field definition.
- Parameters:
name- the name of the field to modifydescription- the description of the fieldtype- the type of the field, corresponding to a type in theBaseTypesenumerationordinal- the ordinality of the fieldprimaryKey- a boolean indicating if this field is a primary keydataShape- the underlying data shape, if the type is assigned toINFOTABLE- Throws:
Exception- if a validation error occurs
-
RemoveFieldDefinition
@ThingworxExtensionApiMethod(since={6,6}) public void RemoveFieldDefinition(String name) throws Exception - Service Category:
- Fields
- Service Description:
- Remove a field definition.
An entity service that removes a field from this data shape.
- Parameters:
name- the name of the field to remove- Throws:
Exception- if the field does not exist
-
getDependencies
Returns a mapping describing all upstream and downstream dependencies for this data shape and its underlying fields.- Returns:
- a map of dependent entities that refer to this data shape or are referred to by this data shape and/or its fields
-
toValueCollection
A helper method that creates aValueCollectioncontaining mappings describing the data shape and its field definitions.- Overrides:
toValueCollectionin classNamedObject- Returns:
- a map describing this data shape
-
getEntityType
@ThingworxExtensionApiMethod(since={6,6}) public RelationshipTypes.ThingworxRelationshipTypes getEntityType()Returns the entity type for this data shape.- Specified by:
getEntityTypein classRootEntity- Returns:
- the
DataShapeconstant
-
fromJSON
@Deprecated @ThingworxExtensionApiMethod(since={6,6}, deprecatedSince={8,4}) public static DataShape fromJSON(org.json.JSONObject jsonObject) throws Exception Deprecated.Parses a serialized data shape as a JSON object. The JSON object must contain, at a minimum, the required properties for an entity as well as the JSON object describing the field definitions for the data shape. It may also optionally include the name of the base data shape.- Parameters:
jsonObject- the JSON object describing the serialized data shape- Returns:
- the deserialized
DataShapedescribed by the JSON object - Throws:
Exception- if the JSON object does not properly represent aDataShape
-