com.apelon.dts.client.subset
Class SubsetExpressionBuilder

java.lang.Object
  extended by com.apelon.dts.client.subset.SubsetExpressionBuilder

public class SubsetExpressionBuilder
extends Object

This class provides a way to construct a subset expression.

The rules for creating a subset expression is described in Subset class header.

Example : Create an expression defined as

 DTS Concepts
   FROM Triad
     HAVING CONCEPT NAME OR SYNONYM MATCHING *PROC*
     ALL PROCEDURE
       HAVING PROPERTY print_name
     EXCLUDE
       ALL DIAGNOSTIC_PROCEDURE
 
The code to create this expression will look similar to the following example:
 // Subset Expression instance
 SubsetExpressionBuilder expr = new SubsetExpressionBuilder();

 // FROM Triad
 Namespace ns = namespacequery.findNamespaceByName("Triad");
 DefaultMutableTreeNode nsNode = expr.initNamespace(ns);

 // HAVING CONCEPT NAME OR SYNONYM MATCHING *PROC*
 expr.addConceptNameFilter(nsNode, "*PROC*", false);

 // ALL PROCEDURE
 DTSConcept con = ontylogquery.findConceptByName("PROCEDURE", ns.getId(), ConceptAttributeSetDescriptor.NO_ATTRIBUTES);
 DefaultMutableTreeNode conNode = expr.addConceptFilter(nsNode, con, false);

 // HAVING PROPERTY print_name
 DTSPropertyType propType = ontylogquery.findPropertyTypeByName("print_name", 50);
 DefaultMutableTreeNode propNode = expr.addPropertyFilter(conNode, propType, null);

 // EXCLUDE
 DefaultMutableTreeNode exNode = expr.addExclude(nsNode);

 // ALL DIAGNOSTIC_PROCEDURE
 DTSConcept con1 = ontylogquery.findConceptByName("DIAGNOSTIC_PROCEDURE", ns.getId(), ConceptAttributeSetDescriptor.NO_ATTRIBUTES);
 DefaultMutableTreeNode conNode1 = expr.addConceptFilter(exNode, con1, false);

 // Build subset expression
 String xml = expr.buildExpression();
 

Copyright: Copyright (c) 2004

Company: Apelon, Inc.

Since:
3.4.0
Version:
DTS 3.4.0
Author:
Abhay Sinha

Field Summary
static String DTS_CONCEPTS
           
static String EXCLUDE
           
 
Constructor Summary
SubsetExpressionBuilder()
           
 
Method Summary
 void addConcept(DefaultMutableTreeNode parent, DTSConcept con)
          Creates OntylogConceptFilter for the given Concept with modifier "ONLY".
 DefaultMutableTreeNode addConceptFilter(DefaultMutableTreeNode parent, DTSConcept con, boolean descendentsOnly)
          Creates OntylogConceptFilter for the given Concept.
 DefaultMutableTreeNode addConceptNameFilter(DefaultMutableTreeNode parent, String pattern, boolean searchConceptsOnly)
          Creates ConceptNameFilter for the given search pattern.
 DefaultMutableTreeNode addExclude(DefaultMutableTreeNode parent)
          Creates an Exclude node and adds it to parent
 DefaultMutableTreeNode addPropertyFilter(DefaultMutableTreeNode parent, DTSPropertyType propType, String pattern)
          Creates PropertyFilter for the given DTSPropertyType and search pattern.
 void build(String expr)
          Builds the root node from the given xml string using XMLDecoder.
 String buildExpression()
          Returns XML representation of the root node created using XMLEncoder.
 DefaultMutableTreeNode getRootNode()
          Returns the root node for the Subset Expression.
 DefaultMutableTreeNode initNamespace(Namespace ns)
          Initializes the namespace for the subset expression.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DTS_CONCEPTS

public static final String DTS_CONCEPTS
See Also:
Constant Field Values

EXCLUDE

public static final String EXCLUDE
See Also:
Constant Field Values
Constructor Detail

SubsetExpressionBuilder

public SubsetExpressionBuilder()
Method Detail

getRootNode

public DefaultMutableTreeNode getRootNode()
Returns the root node for the Subset Expression.

Returns:
DefaultMutableTreeNode

buildExpression

public String buildExpression()
                       throws Exception
Returns XML representation of the root node created using XMLEncoder. This can be used as expression in Subset.setExpression(String) method.

Returns:
XML string
Throws:
Exception - when
  1. the expression does not have at least one filter added for namespace.
  2. there is error persisting root node using XMLEncoder

build

public void build(String expr)
           throws Exception
Builds the root node from the given xml string using XMLDecoder.

Parameters:
expr - xml string created using XMLEncoder
Throws:
Exception - If there is error creating root node using XMLDecoder

initNamespace

public DefaultMutableTreeNode initNamespace(Namespace ns)
Initializes the namespace for the subset expression. Subset expression can have only one namespace. The resulting node is added as child of the root node.

Parameters:
ns - Namespace
Returns:
Namespace Node

addConceptFilter

public DefaultMutableTreeNode addConceptFilter(DefaultMutableTreeNode parent,
                                               DTSConcept con,
                                               boolean descendentsOnly)
Creates OntylogConceptFilter for the given Concept. Creates a Concept Filter node for the filter and adds it as child of the given parent node.

Parameters:
parent - Parent Node. This can be Namespace Node, Concept Filter Node or Exclude Node
con - Concept
descendentsOnly - true if only descendents of the concept are required
Returns:
Concept Filter Node
Throws:
IllegalArgumentException - If namespace of concept does not match expression namespace.

addConcept

public void addConcept(DefaultMutableTreeNode parent,
                       DTSConcept con)
Creates OntylogConceptFilter for the given Concept with modifier "ONLY". Creates a Concept node for the filter and adds it as child of the given parent node.

Parameters:
parent - Parent Node. This can be Namespace Node, Concept Filter Node or Exclude Node
con - Concept
Throws:
IllegalArgumentException - If namespace of concept does not match expression namespace.

addPropertyFilter

public DefaultMutableTreeNode addPropertyFilter(DefaultMutableTreeNode parent,
                                                DTSPropertyType propType,
                                                String pattern)
Creates PropertyFilter for the given DTSPropertyType and search pattern. If the pattern is null, the filter is on DTSPropertyType only. Creates a Concept Filter node for the filter and adds it as child of the given parent node.

Parameters:
parent - Parent Node. This can be Namespace Node, Concept Filter Node or Exclude Node
propType - DTS Property Type
pattern - search pattern to search in Property value
Returns:
Concept Filter Node

addConceptNameFilter

public DefaultMutableTreeNode addConceptNameFilter(DefaultMutableTreeNode parent,
                                                   String pattern,
                                                   boolean searchConceptsOnly)
Creates ConceptNameFilter for the given search pattern. If the pattern cannot be null, Creates a Concept Filter node for the filter and adds it as child of the given parent node.

Parameters:
parent - Parent Node. This can be Namespace Node, Concept Filter Node or Exclude Node
pattern - search pattern to search in synonyms and concept names
searchConceptsOnly - true if only concept names are searched, false if both synonyms and concept names are searched.
Returns:
Concept Filter Node
Throws:
IllegalArgumentException - if pattern is null or blank

addExclude

public DefaultMutableTreeNode addExclude(DefaultMutableTreeNode parent)
Creates an Exclude node and adds it to parent

Parameters:
parent - Parent Node. This can be Namespace Node or Concept Filter Node.
Returns:
Exclude Node
Throws:
IllegalArgumentException - if Parent node is Exclude node


Copyright © 2011. All Rights Reserved.