Advanced Customization > Info*Engine User’s Guide > Task Webject Reference > Group Webjects > Intersect-Groups
  
Intersect-Groups
DESCRIPTION
Identifies the intersection of two groups and places the result in a new group. For example, say that group A contains the elements u, v, and x and group B contains the elements x, y, and z. This webject identifies the common elements of both groups and uses the results of an intersection to form group C. Group C in this example would contain only the element x.
SYNTAX
<ie:webject name="Intersect-Groups" type="GRP">
  <ie:param name="CLASS" data="class"/>
  <ie:param name="COMPARISON" data="[ALPHA | NUMERIC]/>
  <ie:param name="GROUP_IN" data="input_groups"/>
  <ie:param name="GROUP_OUT" data="output_group_name"/>
  <ie:param name="INTERSECTBY" data="attribute"/>
  <ie:param name="SORTBY" data="attribute"/>
  <ie:param name="SORTED" data="[ASC | DESC]"/>
  <ie:param name="CASE_IGNORE" data="[ TRUE | FALSE]"/>
  </ie:webject>
PARAMETERS
Required
Select
Optional
GROUP_IN
CASE_IGNORE
GROUP_OUT
CLASS
INTERSECTBY
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.
GROUP_IN
Specifies the names of two input groups that are used in computing an intersection.
To specify two group names, you can include two lines with different values for the GROUP_IN parameter. For example:
<ie:param name="GROUP_IN" data="group1"/>
<ie:param name="GROUP_IN" data="group2"/>
This parameter is required.
GROUP_OUT
Specifies the name of the results of computing the intersection of the two groups. This parameter is required.
INTERSECTBY
Identifies the attribute to be used for comparisons. When an intersection is performed, the named attribute of the first named group is compared with the named attribute of the second named group. If the values are the same, then the element from the first group is placed in the resulting output group. Otherwise, it is discarded.
The attribute name placed in the output group is the attribute name of the first INTERSECTBY parameter used. If all the group INTERSECTBY parameters are the same name, then only one need be specified here. If any of the group INTERSECTBY parameters have different names, then all of them must be specified here.
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 creates two groups using the CreateGroup and CreateGroupHr task tags, and then finds the intersection between the NAME attribute in the groups using the Intersect-Groups webject. It creates the output group named “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 a group named createdgroup. -->
<ie:task uri="com/company/CreateGroup.xml"/>

<!--Create a group named createdhrgroup. -->
<ie:task uri="com/company/CreateGroupHr.xml"/>

<!-- Form a group by intersecting the two groups. -->

<ie:webject name="Intersect-Groups" type="GRP">
  <ie:param name="GROUP_IN" data="createhrgroup"/>
  <ie:param name="GROUP_IN" data="createdgroup"/>
  <ie:param name="INTERSECTBY" data="NAME"/>
  <ie:param name="CASE_IGNORE" data="YES"/>
  <ie:param name="COMPARISON" data="ALPHA"/>
  <ie:param name="SORTBY" data="NAME"/>
  <ie:param name="SORTED" data="ASC"/>
  <ie:param name="GROUP_OUT" data="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">
<Unknown-Class-Name NAME="results" TYPE="Object" STATUS="0">
  <wc:INSTANCE>
    <NAME>Harvy Anderson</NAME>
    <POSITION>Marketing</POSITION>
    <PHONE>555-222-2222</PHONE>
  </wc:INSTANCE>
  <wc:INSTANCE>
    <NAME>James O&apos;Connor</NAME>
    <POSITION>Management</POSITION>
    <PHONE></PHONE>
  </wc:INSTANCE>
  <wc:INSTANCE>
    <NAME>Sam Johnson</NAME>
    <POSITION>Engineer</POSITION>
    <PHONE>555-111-1111</PHONE>
  </wc:INSTANCE>
</Unknown-Class-Name>
</wc:COLLECTION>