Diff-Groups
DESCRIPTION
Computes the difference of two groups and places that difference in an output group.
In general, an element is different for two groups if it is part of the first group but not both groups. For example, if an element x exists in group A and group B, then it is not placed in the output group. Additionally, if an element y exists in group A but not in group B, then it is placed in the output group. However, if an element z exists in group B but not in group A then it is not placed in the output group; only the items unique to group A are placed in the output.
SYNTAX
<ie:webject name="Diff-Groups" type="GRP">
<ie:param name="CASE_IGNORE" data="[TRUE | FALSE]"/>
<ie:param name="CLASS" data="class"/>
<ie:param name="COMPARISON" data="[ALPHA | NUMERIC]"/>
<ie:param name="DIFFBY" data="attribute"/>
<ie:param name="GROUP_IN" data="group_name1"/>
<ie:param name="GROUP_IN" data="group_name2"/>
<ie:param name="GROUP_OUT" data="output_group_name"/>
<ie:param name="SORTBY" data="attribute"/>
<ie:param name="SORTED" data="[ASC | DESC]">
</ie:webject>
PARAMETERS
Required
|
Select
|
Optional
|
DIFFBY
|
|
CASE_IGNORE
|
GROUP_IN
|
|
CLASS
|
GROUP_OUT
|
|
COMPARISON
|
|
|
SORTBY
|
|
|
SORTED
|
CASE_IGNORE
Acts as a flag for case. If TRUE is specified, case is ignored. If FALSE is specified, then case is significant. The default for this parameter is FALSE. This parameter is optional.
CLASS
Specifies the type of the objects contained in the output group named by the GROUP_OUT parameter. For example if a webject specifies CLASS=MyClassName and GROUP_OUT=data_1, then the XML representation of the output group contains the following tags:
<MyClassName NAME="data_1" TYPE="Object" STATUS="0">
</MyClassName>
The default for this parameter is “Unknown-Class-Name”. This parameter is optional.
COMPARISON
Describes how to compare the two groups: either ALPHA for an alpha-numeric comparison, or NUMERIC for a strictly numeric comparison. The default for this parameter is ALPHA. This parameter is optional.
DIFFBY
Identifies the name of the attribute that is used in comparing elements to determine whether they are different. If the groups being compared contain elements with attributes of the same name, then one DIFFBY value can be specified. Otherwise, you must specify two DIFFBY parameters to provide the names of the attributes from each respective group that is compared.
The attribute name placed in the output group is the attribute name of the first DIFFBY parameter used. This parameter is required.
GROUP_IN
Specifies the two groups that are compared for differences. This parameter is required.
GROUP_OUT
Specifies the name of the single resulting group comparison. This parameter is required.
SORTBY
Specifies the name of the attribute on which the sorting is done. If you do not include this parameter, the results are not sorted. This parameter is optional.
SORTED
Determines how values in the resulting group are sorted. The attribute named in the SORTBY parameter determines which values are sorted. Specify ASC to sort in ascending order or specify DESC to sort in descending order. The default for this parameter is ASC. This parameter is optional.
EXAMPLE
The following example uses the Create-Group webject and then finds the difference between the NAME attribute in the groups using the Diff-Groups webject. It creates the output group named “DIFF-RESULTS” and adds the group to the local output group collection:
%@page language="java" session="false"%>
<%@taglib uri="http://www.ptc.com/infoengine/taglib/core"
prefix="ie"%>
<!-- Create Group containing the difference between two
groups -->
<ie:webject name="Create-Group" type="GRP">
<ie:param name="ELEMENT" data="NAME=Sam
Johnson:ADDRESS=1234 Main
St.:EMAIL=sjohnson@somewhere.com"/>
<ie:param name="ELEMENT" data="NAME=Harvy
Anderson:ADDRESS=1234 Amber
St.:EMAIL=handerson@somewhere.com"/>
<ie:param name="ELEMENT" data="NAME=James
O'Connor:ADDRESS=775 Main St.:EMAIL="/>
<ie:param name="ELEMENT" data="NAME=Harvey
Hampton:ADDRESS=775 Main
St.:EMAIL=hhampton@somewhere.com"/>
<ie:param name="CLASS" data="EmployeeData"/>
<ie:param name="GROUP_OUT" data="CREATE-RESULTS"/>
</ie:webject>
<ie:webject name="Create-Group" type="GRP">
<ie:param name="ELEMENT" data="NAME=Sam
Johnson:POSITION=Engineer:PHONE=555-111-1111"/>
<ie:param name="ELEMENT" data="NAME=Harvy
Anderson:POSITION=Marketing:PHONE=555-222-2222"/>
<ie:param name="ELEMENT" data="NAME=James
O'Connor:POSITION=Management"/>
<ie:param name="CLASS" data="EmployeeHrData"/>
<ie:param name="GROUP_OUT" data="CREATE-HR-RESULTS"/>
</ie:webject>
<ie:webject name="Diff-Groups" type="GRP">
<ie:param name="GROUP_IN" data="CREATE-RESULTS"/>
<ie:param name="GROUP_IN" data="CREATE-HR-RESULTS"/>
<ie:param name="DIFFBY" data="NAME"/>
<ie:param name="CLASS" data="NewEmployees"/>
<ie:param name="GROUP_OUT" data="DIFF-RESULTS"/>
</ie:webject>
The XML output from executing the example is the following:
<?xml version="1.0" encoding="UTF-8"?>
<wc:COLLECTION xmlns:wc="http://www.ptc.com/infoengine/1.0">
<NewEmployees NAME="DIFF-RESULTS" TYPE="Object" STATUS="0">
<wc:INSTANCE>
<NAME>Harvey Hampton</NAME>
<ADDRESS>775 Main St.</ADDRESS>
<EMAIL>hhampton@somewhere.com</EMAIL>
</wc:INSTANCE>
</NewEmployees>
</wc:COLLECTION>