Newer Version Available

This content describes an older version of this product. View Latest

IndustriesContext Class

Contains methods to create, query, persist, or delete a context. Also, query a record's status, query a context based on tags, or update context attributes by using the available methods.

Namespace

Context

IndustriesContext Methods

Learn more about the available methods with the IndustriesContext class.

The IndustriesContext class includes these methods.

buildContext(input)

Creates a context.

Signature

public Map<String,Object> buildContext(Map<String,Object> input)

1Context.IndustriesContext, buildContext, [Map<String,ANY>], Map<String,ANY>

Example

1Context.IndustriesContext industriesContexts = new Context.IndustriesContext();
2
3Map<String, Object> input = new Map<String, Object>(); 
4
5Map<String, String> metadata = new Map<String, String>(); 
6metadata.put('contextDefinitionId', '11Oxx0000006PinEAE');
7metadata.put('mappingId','11jxx0000004LGRAA2');
8
9String data = '{\'Account\':[{\'id\':\'001xx000003GYK0AAO\',\'businessObjectType\':\'Account\'}]}';
10input.put('data', data);
11input.put('metadata', metadata);
12
13Map<String, Object> context = industriesContexts.buildContext(input);
14System.debug(context.get('contextId'));

Parameters

input
Type: Map<String,Object>
Metadata about the context and payload data required to create a context.

Return Value

Type: Map<String,Object>

Details containing the context ID that’s created.

deleteContext(input)

Deletes a context.

Signature

public void deleteContext(Map<String,Object> input)

1Context.IndustriesContext, deleteContext, [Map<String,ANY>], void

Example

1Context.IndustriesContext industriesContexts = new Context.IndustriesContext();
2Map<String, Object> input = new Map<String, Object>();
3input.put('contextId', '1f6ef0f4f9f361ef966d8a292db12ce90ce20bef22efb4afac431762ac71998d');
4industriesContexts.deleteContext(input);

Parameters

input
Type: Map<String,Object>
Details containing the ID of the context to be deleted.

Return Value

Type: void

evictContextDefinition(input)

Removes the details of the context definition from cache.

Signature

public void evictContextDefinition(Map<String,ANY> input)

1Context.IndustriesContext, evictContextDefinition, [Map<String,ANY>], void

Example

1Context.IndustriesContext industriesContexts = new Context.IndustriesContext();
2Map<String, Object> input = new Map<String, Object>();
3input.put('contextDefinitionName', 'definitionName');
4industriesContexts.evictContextDefinition(input);

Parameters

input
Type: Map<String,ANY>
API name of the context definition to remove the details of the context definition from cache.

Return Value

Type: void

filteringContext(input)

Builds or queries a context based on a filter criteria.

Signature

public Map<String, Object> industriesContexts.filteringContext(buildWithFilter);

Example

Type: BUILD

1Context.IndustriesContext industriesContexts = new Context.IndustriesContext();
2Map<String, Object> buildWithFilter = new Map<String, Object>();
3Map<String, Object> input = new Map<String, Object>();
4
5Map<String, String> metadata = new Map<String, String>();
6metadata.put('contextDefinitionId', '11Oxx0000006PXVEA2');
7metadata.put('mappingId','11jxx0000004L59AAE');
8
9String data = '{\'Account\':[{\'id\':\'001xx000003GYiCAAW\',\'businessObjectType\':\'Account\'}]}';
10input.put('data', data);
11input.put('metadata', metadata);
12
13buildWithFilter.put('type', 'BUILD');
14buildWithFilter.put('build', input);
15buildWithFilter.put('filter', '{ \"buildFilter\": {\"Contact\":[{\"filterType\":\"WHERE\",\"node\":\"Contact\",\"attribute\":\"Name\",\"dataType\":\"String\",\"operands\":[\"Howard Jones\"],\"operator\":\"Equals\"}]}}');
16
17Map<String, Object> res = industriesContexts.filteringContext(buildWithFilter);
18
19System.debug(res);

Type: QUERYRECORDANDCHILDREN or QUERYRECORDS

1Context.IndustriesContext industriesContexts = new Context.IndustriesContext();
2Map<String, Object> queryWithFilter = new Map<String, Object>();
3Map<String, Object> queryInput = new Map<String, Object>();
4
5List<String> dataPath = new List<String>();
6dataPath.add('001xx000003GYiCAAW');
7
8Map<String, Object> contextDataPathInputRepresentation = new Map<String, Object>();
9contextDataPathInputRepresentation.put('dataPath', dataPath);
10
11List<Map<String, Object>> queryPaths = new List<Map<String, Object>>();
12queryPaths.add(contextDataPathInputRepresentation);
13
14queryInput.put('contextId', '44410fea80348668bebd58010279c579d611a8f686ebf71e6b2a6b1a6405160f');
15queryInput.put('queryPaths', queryPaths);
16
17queryWithFilter.put('type', 'QUERYRECORDANDCHILDREN');
18queryWithFilter.put('query', queryInput);
19queryWithFilter.put('filter', '{\"queryFilter\":[{\"filterType\":\"WHERE\",\"node\":\"Contact\",\"attribute\":\"Name\",\"dataType\":\"String\",\"operands\":[\"Howard Jones\"],\"operator\":\"Equals\"}]}');
20
21Map<String, Object> res = industriesContexts.filteringContext(queryWithFilter);
22
23System.debug(res);

Parameters

input
Type: Enum
Object defining the type of operation. Operation Metadata along with filter criteria to be applied on the operation. Valid values are: BUILD,QUERYRECORDANDCHILDREN and QUERYRECORDS
filter: String
Metadata about the filter object.
build: Map<String,Object>
Metadata to build the context. Only for type with value BUILD.
query: Map<String,Object>
Metadata to query records in the context. Only for type with value QUERYRECORDANDCHILDREN and QUERYRECORDS.

Return Value

Type: Map<String,Object>

Mapping of the contextId or queryResults with the requested operation type.

getContext(input)

Retrieves context details.

Signature

public Map<String,Object> getContext(Map<String,Object> input)

1Context.IndustriesContext, getContext, [Map<String,ANY>], Map<String,ANY>

Example

1Context.IndustriesContext industriesContexts = new Context.IndustriesContext();
2Map<String, Object> input = new Map<String, Object>();
3
4input.put('contextId', '03950312e509b6ae5c41653408fe4869efc931cc0ffd0e61f5599daa59a22309');
5Map<String, Object> res = industriesContexts.getContext(input);
6
7System.debug(res);

Parameters

input
Type: Map<String,Object>
Details containing the ID of the context to be retrieved.

Return Value

Type: Map<String,Object>

Details of the retrieved context.

getContextTranslation(input)

Retrieves context mappings based on a target mapping ID.

Signature

public Map<String,Object> getContextTranslation(Map<String,Object> input)

1Context.IndustriesContext, getContextTranslation, [Map<String,ANY>], Map<String,ANY>

Example

1Context.IndustriesContext industriesContexts = new Context.IndustriesContext();
2Map<String, Object> input = new Map<String, Object>();
3input.put('contextId', '1f6ef0f4f9f361ef966d8a292db12ce90ce20bef22efb4afac431762ac71998d');
4input.put('contextMappingId', '11jxx0000004LGRAA2');
5List<String> persistAttibuteTypes = new List<String>();
6persistAttibuteTypes.add('OUTPUT');
7persistAttibuteTypes.add('INPUTOUTPUT');
8input.put(persistAttibuteTypes’,  persistAttibuteTypes);
9Boolean isDependenciesEstablished = false;
10input.put(isDependenciesEstablished’, isDependenciesEstablished);
11Boolean removeRestrictedFields = false;
12input.put(removeRestrictedFields’, removeRestrictedFields);
13Map<String, Object> res = industriesContexts.getContextTranslation(input);
14System.debug(res);

Parameters

input
Type: Map<String,Object>
Details of the request parameters to retrieve context mappings. The details include list of persisted attributes and settings to indicate whether any dependencies are established or restricted fields are removed.

Return Value

Type: Map<String,Object>

Details of the retrieved context mappings.

persistContext(input)

Persists the current data or state of context to the database.

Signature

public Map<String,Object> persistContext(Map<String,Object> input)

1Context.IndustriesContext, persistContext, [Map<String,ANY>], Map<String,ANY>

Example

1Context.IndustriesContext industriesContexts = new Context.IndustriesContext();
2Map<String, Object> input = new Map<String, Object>();
3input.put('contextId', '5a42181d891c60f0097d50e0e1d52d6009ee3ef593d9ea145e1f4e05996a17c6');
4input.put('targetMappingId', '');
5Map<String, Object> output = industriesContexts.persistContext(input);
6System.debug(output.get('referenceId'));

Parameters

input
Type: Map<String,Object>
Details to persist context such as context ID and target mapping ID.

Return Value

Type: Map<String,Object>

Reference ID for the persisted context.

queryContextRecordsAndChildren(input)

Queries Context records and children based on the dataPath instead of tags.

Signature

Map<String, Object> industriesContexts.queryContextRecordsAndChildren(input: Map<String, Object>);

Example

1Context.IndustriesContext industriesContexts = new Context.IndustriesContext();
2Map<String, Object> input = new Map<String, Object>();
3
4List<String> dataPath = new List<String>();
5dataPath.add('001xx000003GaX6AAK');
6
7Map<String, Object> contextDataPathInputRepresentation = new Map<String, Object>();
8contextDataPathInputRepresentation.put('dataPath', dataPath);
9
10List<Map<String, Object>> queryPaths = new List<Map<String, Object>>();
11queryPaths.add(contextDataPathInputRepresentation);
12
13input.put('contextId', '7a823bc5f047b1b69aa059b05c3df0ccd69b1bc702e03b4f6c12740d0e277b7b');
14input.put('queryPaths', queryPaths);
15
16Map<String, Object> res = industriesContexts.queryContextRecordsAndChildren(input);
17
18System.debug(res);

Parameters

input
contextId: String
ID of the context to be queried.
queryPaths: Map<String,Object>
List of dataPath to be queried.

Return Value

queryResults: Map<String,Object>

Result containing the record data.

queryRecordStatus(input)

Queries the status of a record.

Signature

public Map<String,Object> queryRecordStatus(Map<String,Object> input)

1Context.IndustriesContext, queryRecordStatus, [Map<String,ANY>], Map<String,ANY>

Example

1Context.IndustriesContext industriesContexts = new Context.IndustriesContext();
2Map<String, Object> input = new Map<String, Object>();
3input.put('contextId', '5a42181d891c60f0097d50e0e1d52d6009ee3ef593d9ea145e1f4e05996a17c6');
4List<Map<String,Object>> queryPaths = new List<Map<String,Object>>();
5Map<String,Object> queryPath = new Map<String,Object>();
6List<String> dataPaths = new List<String>();
7dataPaths.add('TestOrder123');
8queryPath.put('dataPath', dataPaths);
9queryPaths.add(queryPath);
10input.put('queryPaths', queryPaths);
11Map<String, Object> output = industriesContexts.queryRecordStatus(input);

Parameters

input
Type: Map<String,Object>
Details containing the context ID and list of record paths for context data to query the status for.

Return Value

Type: Map<String,Object>

Details containing the results of the query.

queryTags(input)

Queries a context by using tags.

Signature

public Map<String,Object> queryTags(Map<String,Object> input)

1Context.IndustriesContext, queryTags, [Map<String,ANY>], Map<String,ANY>

Example

1Context.IndustriesContext industriesContexts = new Context.IndustriesContext();
2Map<String, Object> input = new Map<String, Object>(); 
3List<String> tag = new List<String>();
4tag.add('contactNameTag');
5input.put('contextId', '967934fc3069c04bb17df94e526052d75ab99fd87393ffad008ed07d7ac54a13');
6input.put('tags', tag);
7Map<String, Object> output = industriesContexts.queryTags(input);
8Map<String, Object> queryresult = (Map<String, Object>)output.get('queryResult');
9List<Object> contextTagDataRepresentations= (List<Object>)queryresult.get('contactNameTag');
10Map<String,Object> contextTagDataRepresentation = (Map<String,Object>)contextTagDataRepresentations.get(0);
11System.debug(contextTagDataRepresentation.get('dataPath'));
12System.debug(contextTagDataRepresentation.get('tagValue'));

Parameters

input
Type: Map<String,Object>
Details containing the context ID and tags to be queried.

Return Value

Type: Map<String,Object>

Details containing the results of the query.

updateContextAttributes(input)

Updates the attributes of a context.

Signature

public Map<String,Object> updateContextAttributes(Map<String,Object> input)

1Context.IndustriesContext, updateContextAttributes, [Map<String,ANY>], Map<String,ANY>

Example

1Context.IndustriesContext industriesContexts = new Context.IndustriesContext();
2Map<String, Object> input = new Map<String, Object>();
3Map<String, Object> contextAttributeValueInputRepresentation = new Map<String, Object>();
4contextAttributeValueInputRepresentation.put('attributeName', 'Name');
5contextAttributeValueInputRepresentation.put('attributeValue', 'Elon');
6
7List<Map<String, Object>> attributes = new List<Map<String, Object>>();
8attributes.add(contextAttributeValueInputRepresentation);
9
10List<String> dataPath = new List<String>();
11dataPath.add('001xx000003GaX6AAK');
12
13Map<String, Object> contextDataPathInputRepresentation = new Map<String,Object>();
14contextDataPathInputRepresentation.put('dataPath', dataPath);
15
16Map<String, Object> nodePathAndAttributesInputRepresentation = new Map<String, Object>();
17nodePathAndAttributesInputRepresentation.put('nodePath', contextDataPathInputRepresentation);
18nodePathAndAttributesInputRepresentation.put('attributes', attributes);
19
20List<Map<String, Object>> nodePathAndAttributes = new List<Map<String, Object>>();
21nodePathAndAttributes.add(nodePathAndAttributesInputRepresentation);
22
23input.put('contextId', 'f4fe20aa8ffb441998a3bba42c7a0452d9b104dcadd9907810cbacff4db7c39a');
24input.put('nodePathAndAttributes', nodePathAndAttributes);
25
26
27Map<String, Object> res = industriesContexts.updateContextAttributes(input);
28
29System.debug(res.get('isSuccess'));

Parameters

input
Type: Map<String,Object>
Details containing the context ID and node path. The node path contains the path of the context record and list of attributes to be updated with their values.

Return Value

Type: Map<String,Object>

Details containing the updated attribute list.