fferpcore.MessageDescriptionglobal inherited sharing class MessageDescription This class defines the content and layout of a message produced by a publication. It is created returned from the Field.getDescription methods. { "correlationId" : "Correlation Id - required for all messages" "body" : "Body - Map of the data that would be sent in the message body" } EnumsNodeType
Methods
MessageDescriptionglobal MessageDescription(fferpcore.Context.Source correlation, fferpcore.MessageDescription.Node body, fferpcore.Context rootContext) This constructor is used to create a description of the message sent by the publication to the subscription. The actual structure of the message is defined by the body parameter. Input Parameters
Sample Code//Note: This sample code is for demonstration purposes only. It is not intended for //use in a production environment, is not guaranteed against defects or errors, and //is in no way optimized or streamlined. //The unique identifier field for this message fferpcore.Context.Source correlation = new fferpcore.Context.SObjectSource(ExampleObject__c.EmployeeId__c); //The body which will contain the name and email associated to ExampleObject__c which sends the message fferpcore.MessageDescription.Node body = new fferpcore.MessageDescription.MapNode() .withScalarChild('Name', ExampleObject__c.Name) .withScalarChild('Email', ExampleObject__c.Email__c); //The SObject that this message is associated to fferpcore.Context rootContext = new fferpcore.Context.SObjectContext(ExampleObject__c.SObjectType); fferpcore.MessageDescription description = new fferpcore.MessageDescription(correlation, body, rootContext); getCorrelationglobal fferpcore.Context.Source getCorrelation() This method returns the source of the message description which represents the correlation Id of a message. It should be a unique field. All messages with the same correlation Id are interpreted as relating to the same object in the publishing product. For example, if it is the EmployeeId of a worker, then it can be used to find all messages relating to that worker. Return ValueThis service returns a Context.Source. Sample Code//Note: This sample code is for demonstration purposes only. It is not intended for //use in a production environment, is not guaranteed against defects or errors, and //is in no way optimized or streamlined. //The unique identifier field for this message fferpcore.Context.Source correlation = new fferpcore.Context.SObjectSource(ExampleObject__c.EmployeeId__c); //The body which will contain the name and email associated to ExampleObject__c which sends the message fferpcore.MessageDescription.Node body = new fferpcore.MessageDescription.MapNode() .withScalarChild('Name', ExampleObject__c.Name) .withScalarChild('Email', ExampleObject__c.Email__c); //The SObject that this message is associated to fferpcore.Context rootContext = new fferpcore.Context.SObjectContext(ExampleObject__c.SObjectType); fferpcore.MessageDescription description = new fferpcore.MessageDescription(correlation, body, rootContext); fferpcore.Context.Source returnValue = description.getCorrelation(); getBodyglobal fferpcore.MessageDescription.Node getBody() This method returns the root node associated with this description. It represents the structure of the data to be sent in the message body. Return ValueThis service returns a MessageDescription.Node object. Sample Code//Note: This sample code is for demonstration purposes only. It is not intended for //use in a production environment, is not guaranteed against defects or errors, and //is in no way optimized or streamlined. //The unique identifier field for this message fferpcore.Context.Source correlation = new fferpcore.Context.SObjectSource(ExampleObject__c.EmployeeId__c); //The body which will contain the name and email associated to ExampleObject__c which sends the message fferpcore.MessageDescription.Node body = new fferpcore.MessageDescription.MapNode(). withScalarChild('Name', ExampleObject__c.Name). withScalarChild('Email', ExampleObject__c.Email__c); //The SObject that this message is associated to fferpcore.MessageDescription.Context rootContext = new fferpcore.MessageDescription.SObjectContext(ExampleObject__c.SObjectType); fferpcore.MessageDescription description = new fferpcore.MessageDescription(correlation, body, rootContext); fferpcore.MessageDescription.Node returnValue = description.getBody(); fferpcore.MessageDescription.Nodeglobal inherited sharing abstract class Node This class represents a value in the message. It takes a source that tells the Node where its data comes from. Node cannot be instantiated, and should not be directly subclassed outside of Foundations. People who wish to write custom Nodes must extend one of our concrete Node types depending on the shape of data that their Node represents. Methods
mergeNodeglobal abstract fferpcore.MessageDescription.DeclarativeMergeResult mergeNode(List<String> path, fferpcore.MessageDescription.DeclarativeMergeRequest request) This abstract method should be overridden by any class that extends MessageDescription.Node. Calling mergeNode on a ScalarNode will return an error result. Calling mergeNode on a MapNode will attempt to add a Node to the message tree. The result indicates whether the node was successfully added and, if it was, contains the new node. This method is used by the publication description user interface and is not intended for use elsewhere. Input Parameters
Return ValueThis service returns a DeclarativeMergeResult object. acceptglobal abstract Object accept(fferpcore.MessageDescriptionVisitor visitor, Object memento) This abstract method must be overridden by all classes extending MessageDescription.Node. Implementing methods should follow the visitor pattern; they should call visit on the visitor parameter, passing in themselves and the memento object. Input Parameters
Return ValueThis service returns an Object object. Sample Code//Note: This sample code is for demonstration purposes only. It is not intended for //use in a production environment, is not guaranteed against defects or errors, and //is in no way optimized or streamlined. /** * Only counts the leaf nodes. */ public class CounterVisitor extends fferpcore.MessageDescriptionVisitor { public Integer count = 0; public override Object visit(fferpcore.MessageDescription.ScalarNode node, Object args) { count++; } public override Object visit(fferpcore.MessageDescription.MapNode mapNode, Object args) { for(fferpcore.MessageDescription.NamedNode namedNode : mapNode.getChildren()) { namedNode.getNode().accept(this, null); } } } fferpcore.MessageDescription.Node node = getNode(); //get a node from somewhere CounterVisitor visitor = new CounterVisitor(); node.accept(visitor, null); Integer numLeaves = visitor.count; prepareglobal abstract void prepare(fferpcore.DataSource dataSource) This abstract method must be implemented on every class that extends MessageDescription.Node. Each node contains a Context.Source. This method calls prepare on that source, passing in the DataSource. Calling this method is required before the message can be built. Nodes are responsible for calling prepare on any children they might have. Input Parameters
Sample Code//Note: This sample code is for demonstration purposes only. It is not intended for //use in a production environment, is not guaranteed against defects or errors, and //is in no way optimized or streamlined. public class ExampleDataSource extends fferpcore.DataSource { public Iterator<ExampleDataSourceRow> runQuery() { //return an iterator over some ExampleDataSourceRows } ... } public class ExampleDataSourceRow extends fferpcore.DataSource.Row { ... } fferpcore.MessageDescripition messageDescription = getMessageDescription(); get a MessageDescription from somewhere fferpcore.DataSource source = new ExampleDataSource(); //This example makes some messagerequests List<MessagingSystemService.MessageRequest> messageRequests = new List<MessagingSystemService.MessageRequest>(); Context.Source correlationSource = messageDescription.getCorrelation(); fferpcore.MessageDescription.Node bodyNode = messageDescription.getBody(); //The correlation source must be prepared as the correlation field may not be present in the message. correlationSource.prepare(source); bodyNode.prepare(source); Iterator<fferpcore.DataSource.Row> dataSourceRowIterator = source.runQuery(); while (dataSourceRowIterator.hasNext()) { DataSource.Row dataSourceRow = dataSourceRowIterator.next(); String correlationId = String.valueOf(correlationSource.getData(dataSourceRow)); JSONGenerator message = JSON.createGenerator(false); //Call build, passing in a DataSource.Row bodyNode.build(message, dataSourceRow); String body = generator.getAsString(); MessagingSystemService.MessageRequest messageRequest = new MessagingSystemService.MessageRequest(messageType, correlationId, body); messageRequests.add(messageRequest); } //we now have some messaging requests, ready to go. buildglobal abstract void build(JSONGenerator generator, fferpcore.DataSource.Row row) This abstract method should be overridden by any class that extends MessageDescription.Node. However there are default implementations in fferpcore.MessageDescription.ScalarNode and MessageDescription.MapNode. This method uses the message structure to write the data in the row parameter to the supplied JSONGenerator. Input Parameters
Sample Code//Note: This sample code is for demonstration purposes only. It is not intended for //use in a production environment, is not guaranteed against defects or errors, and //is in no way optimized or streamlined. public class ExampleDataSource extends fferpcore.DataSource { public Iterator<ExampleDataSourceRow> runQuery() { //return an iterator over some ExampleDataSourceRows } ... } public class ExampleDataSourceRow extends fferpcore.DataSource.Row { ... } fferpcore.MessageDescripition messageDescription = getMessageDescription(); get a MessageDescription from somewhere fferpcore.DataSource source = new ExampleDataSource(); //This example makes some messagerequests List<fferpcore.MessagingSystemService.MessageRequest> messageRequests = new List<fferpcore.MessagingSystemService.MessageRequest>(); Context.Source correlationSource = messageDescription.getCorrelation(); fferpcore.MessageDescription.Node bodyNode = messageDescription.getBody(); //The correlation source must be prepared as the correlation field may not be present in the message. correlationSource.prepare(source); bodyNode.prepare(source); Iterator<fferpcore.DataSource.Row> dataSourceRowIterator = source.runQuery(); while (dataSourceRowIterator.hasNext()) { fferpcore.DataSource.Row dataSourceRow = dataSourceRowIterator.next(); String correlationId = String.valueOf(correlationSource.getData(dataSourceRow)); JSONGenerator message = JSON.createGenerator(false); //Call build, passing in a DataSource.Row bodyNode.build(message, dataSourceRow); String body = generator.getAsString(); fferpcore.MessagingSystemService.MessageRequest messageRequest = new fferpcore.MessagingSystemService.MessageRequest(messageType, correlationId, body); messageRequests.add(messageRequest); } //we now have some messaging requests, ready to go. getTypeglobal abstract fferpcore.MessageDescription.NodeType getType() Returns a MessageDescription.NodeType object to indicate this whether this is a ScalarNode or a MapNode. Sample Code//Note: This sample code is for demonstration purposes only. It is not intended for //use in a production environment, is not guaranteed against defects or errors, and //is in no way optimized or streamlined. fferpcore.MessageDescription description = getMessageDescription(); // get a message description from somewhere fferpcore.MessageDescription.Node testNode = description.getBody(); if (testNode.getType() == fferpcore.MessageDescription.NodeType.SCALAR_NODE) { //Do something with the ScalarNode } else if (testNode.getType() == fferpcore.MessageDescription.NodeType.MAP_NODE) { //Do something with the MapNode } else { //Error, unexpected node type! } getSourceglobal fferpcore.Context.Source getSource() Returns the source that provides data for this node. Return ValueThis service returns a Source object. Sample Code//Note: This sample code is for demonstration purposes only. It is not intended for //use in a production environment, is not guaranteed against defects or errors, and //is in no way optimized or streamlined. public void checkSource() { fferpcore.MessageDescription.Node node = makeBody(); //The root is a MapNode, constructed with no parameters. It has a PassthroughSource fferpcore.Context.Source source = node.getSource(); System.assertEquals(fferpcore.Context.SourceType.PASSTHROUGH, source.getType()); //Let's find out what the sources are of the child nodes for (fferpcore.MessageDescription.Node child : node.getChildren()) { System.debug('NodeType: ' + child.getSource().getType()); } } public fferpcore.MessageDescription.Node makeBody() { return new fferpcore.MessageDescription.MapNode() .withChild(UpdateResourceMessage.LINK_CONTROL_KEY, fferpcore.LinkControlBody.getOutgoingDescriptionNode(PSAFakeResource__c.SObjectType, 'PSA')) .withScalarChild(UpdateResourceMessage.NAME_KEY, PSAFakeResource__c.Name) .withChild(UpdateResourceMessage.ADDRESS_KEY, new fferpcore.MessageDescription.MapNode() .withScalarChild(UpdateResourceMessage.ADDRESS_LINE_1_KEY, new fferpcore.Context.SObjectSource(PSAFakeResource__c.Address1__c)) .withScalarChild(UpdateResourceMessage.ADDRESS_LINE_2_KEY, PSAFakeResource__c.Address2__c) .withScalarChild(UpdateResourceMessage.ADDRESS_LINE_3_KEY, PSAFakeResource__c.Address3__c) .withScalarChild(UpdateResourceMessage.ADDRESS_LINE_4_KEY, PSAFakeResource__c.Address4__c)) .withScalarChild(UpdateResourceMessage.TELEPHONE_KEY, PSAFakeResource__c.Phone__c) .withChild(UpdateResourceMessage.DEPARTMENT_KEY, new fferpcore.MessageDescription.MapNode(PSAFakeResource__c.Department__c) .withScalarChild(UpdateResourceMessage.DEPARTMENT_NAME_KEY, PSAFakeDepartment__c.Name)); } isDeclarativeglobal Boolean isDeclarative() Returns true if this is a custom node. Only nodes that have been added via the build method are declarative. Return ValueThis service returns a Boolean object. Sample Code//Note: This sample code is for demonstration purposes only. It is not intended for //use in a production environment, is not guaranteed against defects or errors, and //is in no way optimized or streamlined. public void checkSource() { fferpcore.MessageDescription.Node node = makeBody(); //This node was constructed programmatically, so isDeclarative is false. System.assertnode.isDeclarative(false, node.isDeclarative()); } /** * We assume UpdateResourceMessage is a class with appropriate constants defined in it. */ public fferpcore.MessageDescription.Node makeBody() { return new fferpcore.MessageDescription.MapNode() .withChild(UpdateResourceMessage.LINK_CONTROL_KEY, fferpcore.LinkControlBody.getOutgoingDescriptionNode(PSAFakeResource__c.SObjectType, 'PSA')) .withScalarChild(UpdateResourceMessage.NAME_KEY, PSAFakeResource__c.Name) .withChild(UpdateResourceMessage.ADDRESS_KEY, new fferpcore.MessageDescription.MapNode() .withScalarChild(UpdateResourceMessage.ADDRESS_LINE_1_KEY, new fferpcore.Context.SObjectSource(PSAFakeResource__c.Address1__c)) .withScalarChild(UpdateResourceMessage.ADDRESS_LINE_2_KEY, PSAFakeResource__c.Address2__c) .withScalarChild(UpdateResourceMessage.ADDRESS_LINE_3_KEY, PSAFakeResource__c.Address3__c) .withScalarChild(UpdateResourceMessage.ADDRESS_LINE_4_KEY, PSAFakeResource__c.Address4__c)) .withScalarChild(UpdateResourceMessage.TELEPHONE_KEY, PSAFakeResource__c.Phone__c) .withChild(UpdateResourceMessage.DEPARTMENT_KEY, new fferpcore.MessageDescription.MapNode(PSAFakeResource__c.Department__c) .withScalarChild(UpdateResourceMessage.DEPARTMENT_NAME_KEY, PSAFakeDepartment__c.Name)); } supportsDeclarativeglobal Boolean supportsDeclarative() Indicates whether or not a Node can have declaratively defined children added to it. ScalarNodes never support declarative. MapNodes support declarative by default, but could be modified to not support declarative. Return ValueThis service returns a Boolean object. Sample Code//Note: This sample code is for demonstration purposes only. It is not intended for //use in a production environment, is not guaranteed against defects or errors, and //is in no way optimized or streamlined. public void checkDeclarative() { fferpcore.MessageDescription.Node root = makeBody(); System.assert(root.supportsDeclarative(), 'The root is a MapNode, so supports declarative'); for (fferpcore.MessageDescription.NamedNode namedNode : root.getChildren()) { fferpcore.MessageDescription.Node node = namedNode.getNode(); if (node.getType() == fferpcore.MessageDeclarative.NodeType.SCALAR_NODE) { System.assert(!node.supportsDeclarative(), 'ScalarNodes never support declarative'); } else if (node.getType() == fferpcore.MessageDeclarative.NodeType.MAP_NODE) { System.assert(node.supportsDeclarative(), 'MapNodes don\'t support declarative by default.'); } else { System.assert(false, 'Unexpected Node type: ' + node.getType()); } } } /** * We assume UpdateResourceMessage is a class with appropriate constants defined in it. */ public fferpcore.MessageDescription.Node makeBody() { return new fferpcore.MessageDescription.MapNode() .withChild(UpdateResourceMessage.LINK_CONTROL_KEY, fferpcore.LinkControlBody.getOutgoingDescriptionNode(PSAFakeResource__c.SObjectType, 'PSA')) .withScalarChild(UpdateResourceMessage.NAME_KEY, PSAFakeResource__c.Name) .withChild(UpdateResourceMessage.ADDRESS_KEY, new fferpcore.MessageDescription.MapNode() .withScalarChild(UpdateResourceMessage.ADDRESS_LINE_1_KEY, new fferpcore.Context.SObjectSource(PSAFakeResource__c.Address1__c)) .withScalarChild(UpdateResourceMessage.ADDRESS_LINE_2_KEY, PSAFakeResource__c.Address2__c) .withScalarChild(UpdateResourceMessage.ADDRESS_LINE_3_KEY, PSAFakeResource__c.Address3__c) .withScalarChild(UpdateResourceMessage.ADDRESS_LINE_4_KEY, PSAFakeResource__c.Address4__c)) .withScalarChild(UpdateResourceMessage.TELEPHONE_KEY, PSAFakeResource__c.Phone__c) .withChild(UpdateResourceMessage.DEPARTMENT_KEY, new fferpcore.MessageDescription.MapNode(PSAFakeResource__c.Department__c) .withScalarChild(UpdateResourceMessage.DEPARTMENT_NAME_KEY, PSAFakeDepartment__c.Name)); } getOutputContextglobal fferpcore.Context getOutputContext() This method returns a fferpcore.Context describing the data for the Node. It is a convenience for calling getSource().getOuputContext(). Return ValueThe Output Context from this Node's Source. Sample Code//Note: This sample code is for demonstration purposes only. It is not intended for //use in a production environment, is not guaranteed against defects or errors, and //is in no way optimized or streamlined. public fferpcore.MessageDescription.Node getBody() { return new fferpcore.MessageDescription.MapNode(new fferpcore.Context.SObjectSource('key', Account.Name)); } fferpcore.MessageDescription description = new fferpcore.MessageDescription( new fferpcore.Context.SObjectSource(HCMFakeWorker__c.EmployeeId__c), getBody(), new fferpcore.Context.SObjectContext(Account.SObjectType) ); fferpcore.MessageDescription.Node root = description.getBody() fferpcore.Context cx = root.getOutputContext(); setInputContextglobal virtual void setInputContext(fferpcore.Context context) Each node contains a source. Calling this method sets the context on that source. This method then calls setInputContext on any child nodes the map node has. Input Parameters
Sample Code//Note: This sample code is for demonstration purposes only. It is not intended for //use in a production environment, is not guaranteed against defects or errors, and //is in no way optimized or streamlined. //Note: This sample code is for demonstration purposes only, it is not intended for //use in a production environment, is not guaranteed against defects or errors and //is in no way optimized or streamlined. fferpcore.MessageDescription.Node body = getBody(); //create the message structure fferpcore.Context ctx = new fferpcore.Context.SObjectContext(Account.SObjectType); body.setInputContext(ctx); fferpcore.MessageDescription.ScalarNodeglobal inherited sharing virtual class ScalarNode extends Node A simple value representing a single keyed value in the message. This can be: This class extends fferpcore.MessageDescription.Node Methods
ScalarNodeglobal ScalarNode(fferpcore.Context.Source source) This constructor creates a ScalarNode with data coming from the specified Source. Input Parameters
Sample Code//Note: This sample code is for demonstration purposes only. It is not intended for //use in a production environment, is not guaranteed against defects or errors, and //is in no way optimized or streamlined. fferpcore.Context.Source exampleSource = new fferpcore.Context.StaticSource('1234', 'Fixed Field'); fferpcore.MessageDescription.ScalarNode node = new fferpcore.MessageDescription.ScalarNode(exampleSource); acceptglobal virtual override Object accept(fferpcore.MessageDescriptionVisitor visitor, Object memento) This method forms part of the visitor pattern. If this method is overridden, implementations should call visit on the visitor parameter, passing in themselves and the memento object. Input Parameters
Return ValueThis service returns an Object object. Sample Code//Note: This sample code is for demonstration purposes only. It is not intended for //use in a production environment, is not guaranteed against defects or errors, and //is in no way optimized or streamlined. /** * Only counts the leaf nodes. */ public class CounterVisitor extends fferpcore.MessageDescriptionVisitor { public Integer count = 0; public override Object visit(fferpcore.MessageDescription.ScalarNode node, Object args) { count++; } public override Object visit(fferpcore.MessageDescription.MapNode mapNode, Object args) { for(fferpcore.MessageDescription.NamedNode namedNode : mapNode.getChildren()) { namedNode.getNode().accept(this, null); } } } fferpcore.MessageDescription.Node node = getNode(); //get a node from somewhere CounterVisitor visitor = new CounterVisitor(); node.accept(visitor, null); Integer numLeaves = visitor.count; mergeNodeglobal virtual override fferpcore.MessageDescription.DeclarativeMergeResult mergeNode(List<String> path, fferpcore.MessageDescription.DeclarativeMergeRequest request) Calling mergeNode on a ScalarNode will return an error result. This method is used by the publication description user interface and is not intended for use elsewhere. Input Parameters
Return ValueThis service returns a DeclarativeMergeResult object. prepareglobal virtual override void prepare(fferpcore.DataSource dataSource) Each node contains an Context.Source. This method calls prepare on that source, passing in the DataSource. Calling this method is required before the message can be built. Input Parameters
Sample Code//Note: This sample code is for demonstration purposes only. It is not intended for //use in a production environment, is not guaranteed against defects or errors, and //is in no way optimized or streamlined. public class ExampleDataSource extends fferpcore.DataSource { public Iterator<ExampleDataSourceRow> runQuery() { //return an iterator over some ExampleDataSourceRows } ... } public class ExampleDataSourceRow extends fferpcore.DataSource.Row { ... } fferpcore.MessageDescripition messageDescription = getMessageDescription(); get a MessageDescription from somewhere fferpcore.DataSource source = new ExampleDataSource(); //This example makes some messagerequests List<fferpcore.MessagingSystemService.MessageRequest> messageRequests = new List<fferpcore.MessagingSystemService.MessageRequest>(); fferpcore.Context.Source correlationSource = messageDescription.getCorrelation(); fferpcore.MessageDescription.Node bodyNode = messageDescription.getBody(); //The correlation source must be prepared as the correlation field may not be present in the message. correlationSource.prepare(source); bodyNode.prepare(source); Iterator<fferpcore.DataSource.Row> dataSourceRowIterator = source.runQuery(); while (dataSourceRowIterator.hasNext()) { fferpcore.DataSource.Row dataSourceRow = dataSourceRowIterator.next(); String correlationId = String.valueOf(correlationSource.getData(dataSourceRow)); JSONGenerator message = JSON.createGenerator(false); //Call build, passing in a DataSource.Row bodyNode.build(message, dataSourceRow); String body = generator.getAsString(); fferpcore.MessagingSystemService.MessageRequest messageRequest = new fferpcore..MessageRequest(messageType, correlationId, body); messageRequests.add(messageRequest); } //we now have some messaging requests, ready to go. buildglobal virtual override void build(JSONGenerator generator, fferpcore.DataSource.Row row) This method uses the message structure to write the data in the row parameter to the supplied JSONGenerator. Input Parameters
Sample Code//Note: This sample code is for demonstration purposes only. It is not intended for //use in a production environment, is not guaranteed against defects or errors, and //is in no way optimized or streamlined. public class ExampleDataSource extends fferpcore.DataSource { public Iterator<ExampleDataSourceRow> runQuery() { //return an iterator over some ExampleDataSourceRows } ... } public class ExampleDataSourceRow extends fferpcore.DataSource.Row { ... } fferpcore.MessageDescripition messageDescription = getMessageDescription(); get a MessageDescription from somewhere fferpcore.DataSource source = new ExampleDataSource(); //This example makes some messagerequests List<fferpcore.MessagingSystemService.MessageRequest> messageRequests = new List<fferpcore.MessagingSystemService.MessageRequest>(); fferpcore.Context.Source correlationSource = messageDescription.getCorrelation(); fferpcore.MessageDescription.Node bodyNode = messageDescription.getBody(); //The correlation source must be prepared as the correlation field may not be present in the message. correlationSource.prepare(source); bodyNode.prepare(source); Iterator<fferpcore.DataSource.Row> dataSourceRowIterator = source.runQuery(); while (dataSourceRowIterator.hasNext()) { fferpcore.DataSource.Row dataSourceRow = dataSourceRowIterator.next(); String correlationId = String.valueOf(correlationSource.getData(dataSourceRow)); JSONGenerator message = JSON.createGenerator(false); //Call build, passing in a DataSource.Row bodyNode.build(message, dataSourceRow); String body = generator.getAsString(); fferpcore.MessagingSystemService.MessageRequest messageRequest = new fferpcore..MessageRequest(messageType, correlationId, body); messageRequests.add(messageRequest); } //we now have some messaging requests, ready to go. getTypeglobal override fferpcore.MessageDescription.NodeType getType() Returns a MessageDescription.NodeType object to indicate this is a ScalarNode type node. Return ValueThis service returns a MessageDescription.NodeType object. Sample Code//Note: This sample code is for demonstration purposes only. It is not intended for //use in a production environment, is not guaranteed against defects or errors, and //is in no way optimized or streamlined. fferpcore.MessageDescription description = getMessageDescription(); // get a message description from somewhere fferpcore.MessageDescription.Node testNode = description.getBody(); if (testNode.getType() == fferpcore.MessageDescription.NodeType.SCALAR_NODE) { //Do something with the ScalarNode } else if (testNode.getType() == fferpcore.MessageDescription.NodeType.MAP_NODE) { //Do something with the MapNode } else { //Error, unexpected node type! } fferpcore.MessageDescription.MapNodeglobal inherited sharing virtual class MapNode extends Node implements ContainerNode A container node that contains a many keyed nodes. The child nodes preserve order. Methods
MapNodeglobal MapNode(fferpcore.Context.Source source) This constructor creates a MapNode with the specified source. Input Parameters
Sample Code//Note: This sample code is for demonstration purposes only. It is not intended for //use in a production environment, is not guaranteed against defects or errors, and //is in no way optimized or streamlined. /** * Create the description for our message * We assume UpdateResourceMessage is a class with appropriate constants defined in it. */ public fferpcore.MessageDescription.Node getBody() { return new fferpcore.MessageDescription.MapNode() .withChild(UpdateResourceMessage.LINK_CONTROL_KEY, fferpcore.LinkControlBody.getOutgoingDescriptionNode(PSAFakeResource__c.SObjectType, 'PSA')) .withScalarChild(UpdateResourceMessage.NAME_KEY, PSAFakeResource__c.Name) .withChild(UpdateResourceMessage.ADDRESS_KEY, new fferpcore.MessageDescription.MapNode() .withScalarChild(UpdateResourceMessage.ADDRESS_LINE_1_KEY, PSAFakeResource__c.Address1__c) .withScalarChild(UpdateResourceMessage.ADDRESS_LINE_2_KEY, PSAFakeResource__c.Address2__c) .withScalarChild(UpdateResourceMessage.ADDRESS_LINE_3_KEY, PSAFakeResource__c.Address3__c) .withScalarChild(UpdateResourceMessage.ADDRESS_LINE_4_KEY, PSAFakeResource__c.Address4__c)) .withScalarChild(UpdateResourceMessage.TELEPHONE_KEY, PSAFakeResource__c.Phone__c) .withChild(UpdateResourceMessage.DEPARTMENT_KEY, new fferpcore.MessageDescription.MapNode(new fferpcore.Context.SObjectSource(PSAFakeResource__c.Department__c)) .withScalarChild(UpdateResourceMessage.DEPARTMENT_NAME_KEY, PSAFakeDepartment__c.Name)); } MapNodeglobal MapNode() Creates a new MapNode with a PassthroughSource. It is equivalent to calling new MessageDescription.MapNode(new Context.PassthroughSource()). Sample Code//Note: This sample code is for demonstration purposes only. It is not intended for //use in a production environment, is not guaranteed against defects or errors, and //is in no way optimized or streamlined. /** * Create the description for our message * We assume UpdateResourceMessage is a class with appropriate constants defined in it. */ public fferpcore.MessageDescription.Node getBody() { return new fferpcore.MessageDescription.MapNode() .withChild(UpdateResourceMessage.LINK_CONTROL_KEY, fferpcore.LinkControlBody.getOutgoingDescriptionNode(PSAFakeResource__c.SObjectType, 'PSA')) .withScalarChild(UpdateResourceMessage.NAME_KEY, PSAFakeResource__c.Name) .withChild(UpdateResourceMessage.ADDRESS_KEY, new fferpcore.MessageDescription.MapNode() .withScalarChild(UpdateResourceMessage.ADDRESS_LINE_1_KEY, PSAFakeResource__c.Address1__c) .withScalarChild(UpdateResourceMessage.ADDRESS_LINE_2_KEY, PSAFakeResource__c.Address2__c) .withScalarChild(UpdateResourceMessage.ADDRESS_LINE_3_KEY, PSAFakeResource__c.Address3__c) .withScalarChild(UpdateResourceMessage.ADDRESS_LINE_4_KEY, PSAFakeResource__c.Address4__c)) .withScalarChild(UpdateResourceMessage.TELEPHONE_KEY, PSAFakeResource__c.Phone__c) .withChild(UpdateResourceMessage.DEPARTMENT_KEY, new fferpcore.MessageDescription.MapNode(new fferpcore.Context.SObjectSource(PSAFakeResource__c.Department__c)) .withScalarChild(UpdateResourceMessage.DEPARTMENT_NAME_KEY, PSAFakeDepartment__c.Name)); } MapNodeglobal MapNode(SObjectField field) Constructs a MapNode specifying an SObjectField as the data source. It is equivalent to calling new MessageDescription.MapNode(new Context.SObjectSource(field)). Input Parameters
Sample Code//Note: This sample code is for demonstration purposes only. It is not intended for //use in a production environment, is not guaranteed against defects or errors, and //is in no way optimized or streamlined. /** * Create the description for our message * We assume UpdateResourceMessage is a class with appropriate constants defined in it. */ public fferpcore.MessageDescription.Node getBody() { return new fferpcore.MessageDescription.MapNode() .withChild(UpdateResourceMessage.LINK_CONTROL_KEY, fferpcore.LinkControlBody.getOutgoingDescriptionNode(PSAFakeResource__c.SObjectType, 'PSA')) .withScalarChild(UpdateResourceMessage.NAME_KEY, PSAFakeResource__c.Name) .withChild(UpdateResourceMessage.ADDRESS_KEY, new fferpcore.MessageDescription.MapNode() .withScalarChild(UpdateResourceMessage.ADDRESS_LINE_1_KEY, PSAFakeResource__c.Address1__c) .withScalarChild(UpdateResourceMessage.ADDRESS_LINE_2_KEY, PSAFakeResource__c.Address2__c) .withScalarChild(UpdateResourceMessage.ADDRESS_LINE_3_KEY, PSAFakeResource__c.Address3__c) .withScalarChild(UpdateResourceMessage.ADDRESS_LINE_4_KEY, PSAFakeResource__c.Address4__c)) .withScalarChild(UpdateResourceMessage.TELEPHONE_KEY, PSAFakeResource__c.Phone__c) .withChild(UpdateResourceMessage.DEPARTMENT_KEY, new fferpcore.MessageDescription.MapNode(PSAFakeResource__c.Department__c) .withScalarChild(UpdateResourceMessage.DEPARTMENT_NAME_KEY, PSAFakeDepartment__c.Name)); } getChildrenglobal virtual List<fferpcore.MessageDescription.NamedNode> getChildren() Returns the children of this node. The child nodes are wrapped in NamedNode objects which contain the node key as well as the node itself. Return ValueThis service returns a list of MessageDescription.NamedNode objects. Sample Code//Note: This sample code is for demonstration purposes only. It is not intended for //use in a production environment, is not guaranteed against defects or errors, and //is in no way optimized or streamlined. /** * Create the description for our message * We assume UpdateResourceMessage is a class with appropriate constants defined in it. */ public fferpcore.MessageDescription.Node getBody() { return new fferpcore.MessageDescription.MapNode() .withChild(UpdateResourceMessage.LINK_CONTROL_KEY, fferpcore.LinkControlBody.getOutgoingDescriptionNode(PSAFakeResource__c.SObjectType, 'PSA')) .withScalarChild(UpdateResourceMessage.NAME_KEY, PSAFakeResource__c.Name) .withChild(UpdateResourceMessage.ADDRESS_KEY, new fferpcore.MessageDescription.MapNode() .withScalarChild(UpdateResourceMessage.ADDRESS_LINE_1_KEY, PSAFakeResource__c.Address1__c) .withScalarChild(UpdateResourceMessage.ADDRESS_LINE_2_KEY, PSAFakeResource__c.Address2__c) .withScalarChild(UpdateResourceMessage.ADDRESS_LINE_3_KEY, PSAFakeResource__c.Address3__c) .withScalarChild(UpdateResourceMessage.ADDRESS_LINE_4_KEY, PSAFakeResource__c.Address4__c)) .withScalarChild(UpdateResourceMessage.TELEPHONE_KEY, PSAFakeResource__c.Phone__c) .withChild(UpdateResourceMessage.DEPARTMENT_KEY, new fferpcore.MessageDescription.MapNode(PSAFakeResource__c.Department__c) .withScalarChild(UpdateResourceMessage.DEPARTMENT_NAME_KEY, PSAFakeDepartment__c.Name)); } public void performBodyTest() { fferpcore.MessageDescription.Node body = getBody(); List<fferpcore.MessageDescription.NamedNode> children = body.getChildren(); System.assertEquals(5, children.size()); } withChildglobal fferpcore.MessageDescription.MapNode withChild(String name, fferpcore.MessageDescription.Node child) Adds the specified child node. This method returns the object the method is called on, so can be used as part of the fluent pattern. Input Parameters
Return ValueThis service returns a MessageDescription.MapNode. Sample Code//Note: This sample code is for demonstration purposes only. It is not intended for //use in a production environment, is not guaranteed against defects or errors, and //is in no way optimized or streamlined. /** * Create the description for our message * We assume UpdateResourceMessage is a class with appropriate constants defined in it. */ public fferpcore.MessageDescription.Node getBody() { return new fferpcore.MessageDescription.MapNode() .withChild(UpdateResourceMessage.LINK_CONTROL_KEY, fferpcore.LinkControlBody.getOutgoingDescriptionNode(PSAFakeResource__c.SObjectType, 'PSA')) .withScalarChild(UpdateResourceMessage.NAME_KEY, PSAFakeResource__c.Name) .withChild(UpdateResourceMessage.ADDRESS_KEY, new fferpcore.MessageDescription.MapNode() .withScalarChild(UpdateResourceMessage.ADDRESS_LINE_1_KEY, PSAFakeResource__c.Address1__c) .withScalarChild(UpdateResourceMessage.ADDRESS_LINE_2_KEY, PSAFakeResource__c.Address2__c) .withScalarChild(UpdateResourceMessage.ADDRESS_LINE_3_KEY, PSAFakeResource__c.Address3__c) .withScalarChild(UpdateResourceMessage.ADDRESS_LINE_4_KEY, PSAFakeResource__c.Address4__c)) .withScalarChild(UpdateResourceMessage.TELEPHONE_KEY, PSAFakeResource__c.Phone__c) .withChild(UpdateResourceMessage.DEPARTMENT_KEY, new fferpcore.MessageDescription.MapNode(PSAFakeResource__c.Department__c) .withScalarChild(UpdateResourceMessage.DEPARTMENT_NAME_KEY, PSAFakeDepartment__c.Name)); } withScalarChildglobal fferpcore.MessageDescription.MapNode withScalarChild(String name, fferpcore.Context.Source source) Adds a new scalar node with the specified source. This method returns the object the method is called on, so can be used as part of the fluent pattern. It is equivalent to calling withChild(name, new MessageDescription.ScalarNode(source)). Input Parameters
Return ValueThis service returns a MessageDescription.MapNode. Sample Code//Note: This sample code is for demonstration purposes only. It is not intended for //use in a production environment, is not guaranteed against defects or errors, and //is in no way optimized or streamlined. /** * Create the description for our message * We assume UpdateResourceMessage is a class with appropriate constants defined in it. */ public fferpcore.MessageDescription.Node getBody() { return new fferpcore.MessageDescription.MapNode() .withChild(UpdateResourceMessage.LINK_CONTROL_KEY, fferpcore.LinkControlBody.getOutgoingDescriptionNode(PSAFakeResource__c.SObjectType, 'PSA')) .withScalarChild(UpdateResourceMessage.NAME_KEY, PSAFakeResource__c.Name) .withChild(UpdateResourceMessage.ADDRESS_KEY, new fferpcore.MessageDescription.MapNode() .withScalarChild(UpdateResourceMessage.ADDRESS_LINE_1_KEY, new fferpcore.Context.SObjectSource(PSAFakeResource__c.Address1__c)) .withScalarChild(UpdateResourceMessage.ADDRESS_LINE_2_KEY, PSAFakeResource__c.Address2__c) .withScalarChild(UpdateResourceMessage.ADDRESS_LINE_3_KEY, PSAFakeResource__c.Address3__c) .withScalarChild(UpdateResourceMessage.ADDRESS_LINE_4_KEY, PSAFakeResource__c.Address4__c)) .withScalarChild(UpdateResourceMessage.TELEPHONE_KEY, PSAFakeResource__c.Phone__c) .withChild(UpdateResourceMessage.DEPARTMENT_KEY, new fferpcore.MessageDescription.MapNode(PSAFakeResource__c.Department__c) .withScalarChild(UpdateResourceMessage.DEPARTMENT_NAME_KEY, PSAFakeDepartment__c.Name)); } withScalarChildglobal fferpcore.MessageDescription.MapNode withScalarChild(String name, SObjectField field) Adds a new scalar node with the specified source. This method returns the object the method is called on, so can be used as part of the fluent pattern. It is equivalent to calling withChild(name, new Context.SObjectSource(field)). Input Parameters
Return ValueThis service returns a MessageDescription.MapNode. Sample Code//Note: This sample code is for demonstration purposes only. It is not intended for //use in a production environment, is not guaranteed against defects or errors, and //is in no way optimized or streamlined. /** * Create the description for our message * We assume UpdateResourceMessage is a class with appropriate constants defined in it. */ public fferpcore.MessageDescription.Node getBody() { return new fferpcore.MessageDescription.MapNode() .withChild(UpdateResourceMessage.LINK_CONTROL_KEY, fferpcore.LinkControlBody.getOutgoingDescriptionNode(PSAFakeResource__c.SObjectType, 'PSA')) .withScalarChild(UpdateResourceMessage.NAME_KEY, PSAFakeResource__c.Name) .withChild(UpdateResourceMessage.ADDRESS_KEY, new fferpcore.MessageDescription.MapNode() .withScalarChild(UpdateResourceMessage.ADDRESS_LINE_1_KEY, PSAFakeResource__c.Address1__c) .withScalarChild(UpdateResourceMessage.ADDRESS_LINE_2_KEY, PSAFakeResource__c.Address2__c) .withScalarChild(UpdateResourceMessage.ADDRESS_LINE_3_KEY, PSAFakeResource__c.Address3__c) .withScalarChild(UpdateResourceMessage.ADDRESS_LINE_4_KEY, PSAFakeResource__c.Address4__c)) .withScalarChild(UpdateResourceMessage.TELEPHONE_KEY, PSAFakeResource__c.Phone__c) .withChild(UpdateResourceMessage.DEPARTMENT_KEY, new fferpcore.MessageDescription.MapNode(PSAFakeResource__c.Department__c) .withScalarChild(UpdateResourceMessage.DEPARTMENT_NAME_KEY, PSAFakeDepartment__c.Name)); } acceptglobal override Object accept(fferpcore.MessageDescriptionVisitor visitor, Object memento) This method forms part of the visitor pattern. If this method is overridden, implementations should call call visit on the visitor parameter, passing in themselves and the memento object. Input Parameters
Return ValueThis service returns an Object object. Sample Code//Note: This sample code is for demonstration purposes only. It is not intended for //use in a production environment, is not guaranteed against defects or errors, and //is in no way optimized or streamlined. /** * Only counts the leaf nodes. */ public class CounterVisitor extends fferpcore.MessageDescriptionVisitor { public Integer count = 0; public override Object visit(fferpcore.MessageDescription.ScalarNode node, Object args) { count++; } public override Object visit(fferpcore.MessageDescription.MapNode mapNode, Object args) { for(fferpcore.MessageDescription.NamedNode namedNode : mapNode.getChildren()) { namedNode.getNode().accept(this, null); } } } fferpcore.MessageDescription.Node node = getNode(); //get a node from somewhere CounterVisitor visitor = new CounterVisitor(); node.accept(visitor, null); Integer numLeaves = visitor.count; mergeNodeglobal override fferpcore.MessageDescription.DeclarativeMergeResult mergeNode(List<String> path, fferpcore.MessageDescription.DeclarativeMergeRequest request) Calling mergeNode on a MapNode will attempt to add a node to the message tree. The result indicates whether the node was successfully added and if it was, contains the new node. This method is used by the publication description user interface and is not intended for use elsewhere. Input Parameters
Return ValueThis service returns a DeclarativeMergeResult object. prepareglobal override virtual void prepare(fferpcore.DataSource dataSource) Each node contains an Context.Source. This method calls prepare on that source, passing in the DataSource. Calling this method is required before the message can be built. MapNode will call prepare on its children. Input Parameters
Sample Code//Note: This sample code is for demonstration purposes only. It is not intended for //use in a production environment, is not guaranteed against defects or errors, and //is in no way optimized or streamlined. public class ExampleDataSource extends fferpcore.DataSource { public Iterator<ExampleDataSourceRow> runQuery() { //return an iterator over some ExampleDataSourceRows } ... } public class ExampleDataSourceRow extends fferpcore.DataSource.Row { ... } fferpcore.MessageDescripition messageDescription = getMessageDescription(); get a MessageDescription from somewhere fferpcore.DataSource source = new ExampleDataSource(); //This example makes some messagerequests List<fferpcore.MessagingSystemService.MessageRequest> messageRequests = new List<fferpcore.MessagingSystemService.MessageRequest>(); fferpcore.Context.Source correlationSource = messageDescription.getCorrelation(); fferpcore.MessageDescription.Node bodyNode = messageDescription.getBody(); //The correlation source must be prepared as the correlation field may not be present in the message. correlationSource.prepare(source); bodyNode.prepare(source); Iterator<fferpcore.DataSource.Row> dataSourceRowIterator = source.runQuery(); while (dataSourceRowIterator.hasNext()) { fferpcore.DataSource.Row dataSourceRow = dataSourceRowIterator.next(); String correlationId = String.valueOf(correlationSource.getData(dataSourceRow)); JSONGenerator message = JSON.createGenerator(false); //Call build, passing in a DataSource.Row bodyNode.build(message, dataSourceRow); String body = generator.getAsString(); fferpcore.MessagingSystemService.MessageRequest messageRequest = new fferpcore..MessageRequest(messageType, correlationId, body); messageRequests.add(messageRequest); } //we now have some messaging requests, ready to go. setInputContextglobal override void setInputContext(fferpcore.Context ctx) Each node contains a source. Calling this method sets the context on that source. This method then calls setInputContext on any child nodes the map node has. Input Parameters
Sample Code//Note: This sample code is for demonstration purposes only. It is not intended for //use in a production environment, is not guaranteed against defects or errors, and //is in no way optimized or streamlined. fferpcore.MessageDescription.MapNode body = getBody(); //create the message structure. The root is a MapNode. fferpcore.Context ctx = new fferpcore.Context.SObjectContext(Account.SObjectType); body.setInputContext(ctx); buildglobal override virtual void build(JSONGenerator generator, fferpcore.DataSource.Row parentRow) This method uses the message structure to write the data in the row parameter to the supplied JSONGenerator. Input Parameters
Sample Code//Note: This sample code is for demonstration purposes only. It is not intended for //use in a production environment, is not guaranteed against defects or errors, and //is in no way optimized or streamlined. public class ExampleDataSource extends fferpcore.DataSource { public Iterator<ExampleDataSourceRow> runQuery() { //return an iterator over some ExampleDataSourceRows } ... } public class ExampleDataSourceRow extends fferpcore.DataSource.Row { ... } fferpcore.MessageDescripition messageDescription = getMessageDescription(); get a MessageDescription from somewhere fferpcore.DataSource source = new ExampleDataSource(); //This example makes some messagerequests List<fferpcore.MessagingSystemService.MessageRequest> messageRequests = new List<fferpcore.MessagingSystemService.MessageRequest>(); fferpcore.Context.Source correlationSource = messageDescription.getCorrelation(); fferpcore.MessageDescription.Node bodyNode = messageDescription.getBody(); //The correlation source must be prepared as the correlation field may not be present in the message. correlationSource.prepare(source); bodyNode.prepare(source); Iterator<fferpcore.DataSource.Row> dataSourceRowIterator = source.runQuery(); while (dataSourceRowIterator.hasNext()) { fferpcore.DataSource.Row dataSourceRow = dataSourceRowIterator.next(); String correlationId = String.valueOf(correlationSource.getData(dataSourceRow)); JSONGenerator message = JSON.createGenerator(false); //Call build, passing in a DataSource.Row bodyNode.build(message, dataSourceRow); String body = generator.getAsString(); fferpcore.MessagingSystemService.MessageRequest messageRequest = new fferpcore..MessageRequest(messageType, correlationId, body); messageRequests.add(messageRequest); } //we now have some messaging requests, ready to go. getTypeglobal override fferpcore.MessageDescription.NodeType getType() Returns a MessageDescription.NodeType object to indicate this is a MapNode type node. Return ValueThis service returns a MessageDescription.NodeType object. Sample Code//Note: This sample code is for demonstration purposes only. It is not intended for //use in a production environment, is not guaranteed against defects or errors, and //is in no way optimized or streamlined. fferpcore.MessageDescription description = getMessageDescription(); // get a message description from somewhere fferpcore.MessageDescription.Node testNode = description.getBody(); if (testNode.getType() == fferpcore.MessageDescription.NodeType.SCALAR_NODE) { //Do something with the ScalarNode } else if (testNode.getType() == fferpcore.MessageDescription.NodeType.MAP_NODE) { //Do something with the MapNode } else { //Error, unexpected node type! } fferpcore.MessageDescription.ListNodeglobal inherited sharing class ListNode extends Node implements ContainerNode A container node that creates a list. Methods
ListNodeglobal ListNode(fferpcore.Context.Source source) This constructor creates a ListNode with the specified source. Input Parameters
ListNodeglobal ListNode(SObjectType childType, SObjectField childLookupField) Constructs a ListNode specifying an SObjectType and SObjectField as the data source. This is equivalent to calling new MessageDescription.ListNode(new Context.SObjectSource(childType, childLookupField)). Input Parameters
getChildrenglobal List<fferpcore.MessageDescription.NamedNode> getChildren() withChildglobal fferpcore.MessageDescription.ListNode withChild(String name, fferpcore.MessageDescription.Node child) Adds the specified child node. This method returns the object that the method is called on, so can be used as part of the fluent pattern. Input Parameters
Return ValueThis service returns a MessageDescription.ListNode. withScalarChildglobal fferpcore.MessageDescription.ListNode withScalarChild(String name, fferpcore.Context.Source source) Adds a new scalar node with the specified source. This method returns the object the method is called on, so can be used as part of the fluent pattern. This is equivalent to calling withChild(name, new MessageDescription.ScalarNode(source)). Input Parameters
Return ValueThis service returns a MessageDescription.ListNode. withScalarChildglobal fferpcore.MessageDescription.ListNode withScalarChild(String name, SObjectField field) Adds a new scalar node with the specified source. This method returns the object that the method is called on, so can be used as part of the fluent pattern. This is equivalent to calling withChild(name, new Context.SObjectSource(field)). Input Parameters
Return ValueThis service returns a MessageDescription.ListNode. acceptglobal override Object accept(fferpcore.MessageDescriptionVisitor visitor, Object memento) This method forms part of the visitor pattern. Input Parameters
Return ValueThis service returns an Object object. mergeNodeglobal override fferpcore.MessageDescription.DeclarativeMergeResult mergeNode(List<String> path, fferpcore.MessageDescription.DeclarativeMergeRequest request) This method attempts to add a node to the message tree. The result indicates whether the node was successfully added. If it was, it also contains the new node. This method is used by the publication description user interface and is not intended for use elsewhere. Input Parameters
Return ValueThis service returns a DeclarativeMergeResult object. prepareglobal override virtual void prepare(fferpcore.DataSource dataSource) This method calls Prepare on each fferpcore.Context.Source and passes in the DataSource. This method must be called before the message is built. ListNode calls Prepare on its children. Input Parameters
setInputContextglobal override void setInputContext(fferpcore.Context ctx) Each node contains a source. Calling this method sets the context on that source. This method then calls setInputContext on any child nodes the map node has. Input Parameters
buildglobal override virtual void build(JSONGenerator generator, fferpcore.DataSource.Row parentRow) This method uses the message structure to write the data in the row parameter to the supplied JSONGenerator. Input Parameters
getTypeglobal override fferpcore.MessageDescription.NodeType getType() Returns a MessageDescription.NodeType object to indicate this is a ListNode type node. Return ValueThis service returns a MessageDescription.NodeType object. fferpcore.MessageDescription.NamedNodeglobal inherited sharing class NamedNode A wrapper that holds a Node and a String that identifies it. This class is used as the children on a MapNode. Methods
NamedNodeglobal NamedNode(String name, fferpcore.MessageDescription.Node node) Constructs a fferpcore.MessageDescription.NamedNode with the specified name and node. Input Parameters
Sample Code//Note: This sample code is for demonstration purposes only. It is not intended for //use in a production environment, is not guaranteed against defects or errors, and //is in no way optimized or streamlined. fferpcore.MessageDescription.ScalarNode scalarNode1 = new fferpcore.MessageDescription.ScalarNode(new fferpcore.Context.StaticSource('TestData', 'Example data for our source')); fferpcore.MessageDescription.ScalarNode scalarNode2 = new fferpcore.MessageDescription.ScalarNode(new fferpcore.Context.StaticSource('DifferentDadta', 'More data for our source')); fferpcore.MessageDescription.NamedNode namedNode = new fferpcore.MessageDescription.NamedNode('staticNode', scalarNode1); System.assertEquals(namedNode, new fferpcore.MessageDescription.NamedNode('staticNode', scalarNode1)); System.assertNotEquals(namedNode, new fferpcore.MessageDescription.NamedNode('abc', scalarNode1), 'Are not equal and the names are different'); System.assertNotEquals(namedNode, new fferpcore.MessageDescription.NamedNode('staticNode', scalarNode2), 'Are not equals as the Nodes are different') getNameglobal String getName() Returns a string identifying the node. Return ValueThis service returns a string object. Sample Code//Note: This sample code is for demonstration purposes only. It is not intended for //use in a production environment, is not guaranteed against defects or errors, and //is in no way optimized or streamlined. /** * Method to recursively traverse the message tree and log the names of all the nodes. */ public void logChildNames(fferpcore.MessageDescription.NamedNode namedNode) { System.debug("Found node: " + namedNode.getName()); fferpcore.MessageDescription.Node node = namedNode.getNode(); if (node.getType() == fferpcore.MessageDescription.NodeType.MAP_NODE) { (fferpcore.MessageDescription.MapNode) mapNode = (fferpcore.MessageDescription.MapNode) node; for (fferpcore.MessageDescription.Node child : mapNode.getChildren()) { logChildNames(child); } } } getNodeglobal fferpcore.MessageDescription.Node getNode() Returns the Node contained in this NamedNode. Return ValueThis service returns a Node object. Sample Code//Note: This sample code is for demonstration purposes only. It is not intended for //use in a production environment, is not guaranteed against defects or errors, and //is in no way optimized or streamlined. /** * Method to recursively traverse the message tree and log the names of all the nodes. */ public void logChildNames(fferpcore.MessageDescription.NamedNode namedNode) { System.debug("Found node: " + namedNode.getName()); fferpcore.MessageDescription.Node node = namedNode.getNode(); if (node.getType() == fferpcore.MessageDescription.NodeType.MAP_NODE) { (fferpcore.MessageDescription.MapNode) mapNode = (fferpcore.MessageDescription.MapNode) node; for (fferpcore.MessageDescription.Node child : mapNode.getChildren()) { logChildNames(child); } } } equalsglobal Boolean equals(Object obj) Determines whether the node is equal to the supplied object. Two NamedNodes are considered to be equal if they have the same name and their nodes are equal. Input Parameters
Sample Code//Note: This sample code is for demonstration purposes only. It is not intended for //use in a production environment, is not guaranteed against defects or errors, and //is in no way optimized or streamlined. fferpcore.MessageDescription.ScalarNode scalarNode1 = new fferpcore.MessageDescription.ScalarNode(new fferpcore.Context.StaticSource('TestData', 'Example data for our source')); fferpcore.MessageDescription.ScalarNode scalarNode2 = new fferpcore.MessageDescription.ScalarNode(new fferpcore.Context.StaticSource('DifferentDadta', 'More data for our source')); fferpcore.MessageDescription.NamedNode namedNode = new fferpcore.MessageDescription.NamedNode('staticNode', scalarNode1); //test1 is true as the names are the same and the nodes are equal Boolean test1 = namedNode.equals(new fferpcore.MessageDescription.NamedNode('staticNode', scalarNode1)); //test2 is false because the names are different Boolean test2 = namedNode.equals(new fferpcore.MessageDescription.NamedNode('abc', scalarNode1)); //test 3 is false because the Nodes are not equal Boolean test3 = namedNode.equals(new fferpcore.MessageDescription.NamedNode('staticNode', scalarNode2)); hashCodeglobal Integer hashCode() Returns an Integer computed from the Name and Node in this object. Sample Code//Note: This sample code is for demonstration purposes only. It is not intended for //use in a production environment, is not guaranteed against defects or errors, and //is in no way optimized or streamlined. fferpcore.MessageDescription.ScalarNode scalarNode1 = new fferpcore.MessageDescription.ScalarNode(new Context.StaticSource('TestData', 'Example data for our source')); fferpcore.MessageDescription.NamedNode namedNode1 = new MessageDescription.NamedNode('staticNode', scalarNode1); fferpcore.MessageDescription.NamedNode namedNode2 = new MessageDescription.NamedNode('staticNode', scalarNode1); System.assertEquals(namedNode1, namedNode2); System.assertEquals(namedNode1.hashCode(), namedNode2.hashCode()); fferpcore.MessageDescription.DeclarativeMergeResultglobal inherited sharing class DeclarativeMergeResult This result contains the result of calling mergeNode on a MessageDescription.Node. If the merge was successful the result contains the child node. If the merge was not successful, the result contains a String detailing the problem. Methods
DeclarativeMergeResultglobal DeclarativeMergeResult(Boolean passed, fferpcore.MessageDescription.Node node) This constructor is used to create a successful merge result. The resulting object acts as a wrapper for the child node that was added. Input Parameters
Sample Code//Note: This sample code is for demonstration purposes only. It is not intended for //use in a production environment, is not guaranteed against defects or errors, and //is in no way optimized or streamlined. fferpcore.MessageDescription.Node oldNode = new fferpcore.MessageDescription.ScalarNode(new fferpcore.Context.SObjectSource(Account.Name)); fferpcore.MessageDescription.DeclarativeMergeResult result = new fferpcore.MessageDescription.DeclarativeMergeResult(true, node); fferpcore.MessageDescription.Node newNode = result.getNode(); System.assertEquals(oldNode, newNode, 'Check the result acts as a wrapper for the node'); DeclarativeMergeResultglobal DeclarativeMergeResult(Boolean passed, String message) This constructor is used to create an unseccessful merge result. The resulting object acts as a wrapper for the error message. Input Parameters
Sample Code//Note: This sample code is for demonstration purposes only. It is not intended for //use in a production environment, is not guaranteed against defects or errors, and //is in no way optimized or streamlined. fferpcore.MessageDescription.DeclarativeMergeResult result = new fferpcore.MessageDescription.DeclarativeMergeResult(false, 'Error'); System.assertEquals('Error', result.getMessage(), 'Check the result acts as a wrapper for the message'); hasPassedglobal Boolean hasPassed() Indicates whether a declarative merge request was successful. Return ValueThis service returns a Boolean object. Sample Code//Note: This sample code is for demonstration purposes only. It is not intended for //use in a production environment, is not guaranteed against defects or errors, and //is in no way optimized or streamlined. fferpcore.MessageDescription.DeclarativeMergeRequest request = getRequest(); //get a request from somewhere fferpcore.MessageDescription.DeclarativeMergeResult result = request.build(new fferpcore.Context.SObjectContext(Account.SObjectType)); if (result.hasPassed()) { fferpcore.MessageDescription.Node node = result.getNode(); //do something with the child node } else { String error = result.getMessage(); //do something with the error } getMessageglobal String getMessage() Returns the error message of an unseccessful declarative merge request. If called on a successful request then the empty string is returned. Return ValueThis service returns a String object. Sample Code//Note: This sample code is for demonstration purposes only. It is not intended for //use in a production environment, is not guaranteed against defects or errors, and //is in no way optimized or streamlined. fferpcore.MessageDescription.DeclarativeMergeRequest request = getRequest(); //get a request from somewhere fferpcore.MessageDescription.DeclarativeMergeResult result = request.build(new fferpcore.Context.SObjectContext(Account.SObjectType)); if (result.hasPassed()) { fferpcore.MessageDescription.Node node = result.getNode(); //do something with the child node } else { String error = result.getMessage(); //do something with the error } getNodeglobal fferpcore.MessageDescription.Node getNode() Returns the node that was added in a successful declarative merge request. If called on an unsuccessful request then null returned. Return ValueThis service returns a Node object. Sample Code//Note: This sample code is for demonstration purposes only. It is not intended for //use in a production environment, is not guaranteed against defects or errors, and //is in no way optimized or streamlined. fferpcore.MessageDescription.DeclarativeMergeRequest request = getRequest(); //get a request from somewhere fferpcore.MessageDescription.DeclarativeMergeResult result = request.build(new fferpcore.Context.SObjectContext(Account.SObjectType)); if (result.hasPassed()) { fferpcore.MessageDescription.Node node = result.getNode(); //do something with the child node } else { String error = result.getMessage(); //do something with the error } fferpcore.MessageDescription.DeclarativeMergeRequestglobal inherited sharing class DeclarativeMergeRequest This class is used internally by EPR to build the message descriptions. It does not have any global constructors and cannot be used elsewhere. This object holds the fferpcore.MessageDescription.Node we are attemping to add to the message. Methodsbuildglobal fferpcore.MessageDescription.DeclarativeMergeResult build(fferpcore.Context context) This method is called on a fferpcore.MessageDescription.DeclarativeMergeRequest to add a node to the message. The context parameter states the source of data required for the node specified in the request. Return ValueThis service returns a DeclarativeMergeResult object. Sample Code//Note: This sample code is for demonstration purposes only. It is not intended for //use in a production environment, is not guaranteed against defects or errors, and //is in no way optimized or streamlined. fferpcore.MessageDescription.DeclarativeMergeRequest request = getRequest(); //get a request from somewhere fferpcore.MessageDescription.DeclarativeMergeResult result = request.build(new fferpcore.Context.SObjectContext(Account.SObjectType)); if (result.hasPassed()) { fferpcore.MessageDescription.Node node = result.getNode(); //do something with the child node } else { String error = result.getMessage(); //do something with the error } |