com.bowstreet.builders.webapp.pageautomation
Class AutomationHelper

java.lang.Object
  extended by com.bowstreet.webapp.util.WebAppUIHelper
      extended by com.bowstreet.builders.webapp.pageautomation.AutomationHelper

public class AutomationHelper
extends com.bowstreet.webapp.util.WebAppUIHelper

Helper class for any PageAutomation Builders and Coordinators


Nested Class Summary
static class AutomationHelper.PropertySet
           
 
Nested classes/interfaces inherited from class com.bowstreet.webapp.util.WebAppUIHelper
com.bowstreet.webapp.util.WebAppUIHelper.AcceptAll, com.bowstreet.webapp.util.WebAppUIHelper.AcceptanceFilter, com.bowstreet.webapp.util.WebAppUIHelper.MethodSignatureComparator
 
Field Summary
static java.lang.String AUTOMATION_PROPERTY
           
 
Constructor Summary
AutomationHelper(WebApp webApp)
           
 
Method Summary
static boolean addTemplateInfoToElement(DataDefinitionElement element, com.bowstreet.builders.webapp.pageautomation.content.HTMLTemplate htmlTemplate, GenContext genContext)
          Add the HTMLTemplate to the element and ensures that the element also has a WebAppPageGenerationAgent
static boolean addTemplateInfoToElement(DataDefinitionElement element, java.lang.String templateFile, GenContext genContext)
          Creates an HTMLTemplate and adds it to the element IMPORTANT!
static void addTypeInfoToLeaf(Leaf leaf, java.lang.String type, boolean inferTypeValidationFromSchema)
          Called by DataPageBuilder and other builders that create new Leaf nodes.
static void assignNodes(Element element, Page page, java.lang.String name, boolean labelOnly)
           
static java.lang.String buildSelector(Element element)
          Builds an appropriate selector string, suitable for sticking into a new BuilderCall
static java.lang.String checkIfElementHidden(Element element, java.lang.String locator)
           
static java.lang.String checkReservedName(java.lang.String name, BuilderCall builderCall)
          Checks that name isn't one of the Java or HTML reserved names.
 Element findElement(java.lang.String locator)
          Find a single element in the WebApp based on a locator string.
 java.util.Collection findElements(IXml locatorSet, IXml typeSet, java.util.Collection warnings)
          Get a list of all the elements selected by the locatorSet and the typeSet.
 java.util.Collection findElementsFromStandardInputs(BuilderInputs builderInputs, java.util.Collection warnings)
          This is a utility method to be used by Builders that use the standard inputs of "FieldSelector, Fields, FieldTypes"
static IXml findNamedElementInIXml(IXml ixml, java.lang.String elementName, java.util.Set blockedNames)
          Find an element within this IXml with the "name" or "id" attribute equal to elementName
static IXml findNamedElementOnPage(Page page, java.lang.String elementName)
          Find an element on this Page with the name attribute equal to elementName
 java.util.List getAllFields(boolean containersOnly)
          Get all the Field Selector Strings.
 java.lang.String getPageName(java.lang.String locator)
          Parses the page name from the provided locator string
static PageReference getPageReference(Page page)
          If there is already a PageReference for this page, returns it, or creates one as needed
 PageReference getPageReference(java.lang.String pageName)
          get a PageReference associated with a page of this name in the webApp
 java.util.Collection getPageReferenceNames()
           
 java.util.Collection getPageReferences()
           
 java.util.Collection getTypeNames()
          Get a list of all type names used in this model.
 java.util.Collection getTypeNames(boolean containersOnly)
          Get a list of all type names used in this model.
 WebApp getWebApp()
           
static boolean hasPageReference(Page page)
          Checks to see if there is already a pageReference for this page
static boolean leafIsInTable(Leaf leaf)
           
static void matchElementsToPage(Element root)
           
static void matchElementsToPage(Element root, AutomationHelper.PropertySet pSet)
           
static void matchElementsToPage(Element root, AutomationHelper.PropertySet pSet, boolean bFixup)
           
static void matchElementsToPage(Element root, boolean bFixup)
           
static com.bowstreet.builders.webapp.pageautomation.content.HTMLTemplate openTemplateFile(java.lang.String templateFile, GenContext genContext)
          Opens an HTMLTemplate file, creating an instance of HTMLTemplate.
 void releasePageReferences()
          release the memory associated with the PageAutomation tools
 BuilderCall setActiveBuilderCall(BuilderCall builderCall)
           
 java.lang.String setActiveBuilderCall(java.lang.String builderCallID)
          Set the current builderCallID in the WebApp, so that the GenElement references to any created objects will point to the correct builderCall.
static void setDefaultLabel(Element element, java.lang.String name)
           
 
Methods inherited from class com.bowstreet.webapp.util.WebAppUIHelper
addVariableReferences, checkVarRefExists, getActions, getActions, getActionsForActionList, getCategorizedActions, getClassInfoMemberSignatures, getClassInfoMethodSignatures, getInputReferences, getLinkedModelPublicMethods, getLinkedModelPublicPages, getLinkedObjectMethods, getLinkedObjectMethodSignatures, getMethodReferences, getMethods, getNamedElementsOnPage, getPages, getPages, getReferences, getReferences, getSchemaTypes, getVariables, getVariableTypes, setAcceptanceFilter
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

AUTOMATION_PROPERTY

public static final java.lang.String AUTOMATION_PROPERTY
See Also:
Constant Field Values
Constructor Detail

AutomationHelper

public AutomationHelper(WebApp webApp)
Method Detail

addTemplateInfoToElement

public static boolean addTemplateInfoToElement(DataDefinitionElement element,
                                               com.bowstreet.builders.webapp.pageautomation.content.HTMLTemplate htmlTemplate,
                                               GenContext genContext)
Add the HTMLTemplate to the element and ensures that the element also has a WebAppPageGenerationAgent

Parameters:
element - The element, null tolerated
htmlTemplate - The HTMLTemplate, null tolerated
genContext - The current GenContext, must be non-null
Returns:
True if the template was added to the element (false if either was null

addTemplateInfoToElement

public static boolean addTemplateInfoToElement(DataDefinitionElement element,
                                               java.lang.String templateFile,
                                               GenContext genContext)
Creates an HTMLTemplate and adds it to the element IMPORTANT! Side-effect: If the file can not be opened, an error will be placed in the current BuilderCall.

Parameters:
element - The element, null tolerated
templateFile - name of an HTML Template file, null is tolerated
genContext - The current GenContext, must be non-null
Returns:
True if the template was added to the element (false if element was null or HTML template couldn't be created)

addTypeInfoToLeaf

public static void addTypeInfoToLeaf(Leaf leaf,
                                     java.lang.String type,
                                     boolean inferTypeValidationFromSchema)
Called by DataPageBuilder and other builders that create new Leaf nodes.

Parameters:
leaf - new Leaf node
type - String the schema type
inferTypeValidationFromSchema - true if we should infer Type Validation mathods

assignNodes

public static void assignNodes(Element element,
                               Page page,
                               java.lang.String name,
                               boolean labelOnly)

buildSelector

public static java.lang.String buildSelector(Element element)
Builds an appropriate selector string, suitable for sticking into a new BuilderCall

Parameters:
element - The PageAutomation Element you want to select
Returns:
selector String, possibly null if element was null. Warning! recursive

checkIfElementHidden

public static java.lang.String checkIfElementHidden(Element element,
                                                    java.lang.String locator)

checkReservedName

public static java.lang.String checkReservedName(java.lang.String name,
                                                 BuilderCall builderCall)
Checks that name isn't one of the Java or HTML reserved names. If it is, then it will modify it and return the new value.

Parameters:
name - the name to check.
builderCall - If non-null, a warning will be added.
Returns:
the name, modified if necessary.

findElement

public Element findElement(java.lang.String locator)
Find a single element in the WebApp based on a locator string.

Parameters:
locator - String that would have been generated by a PageAutomationFieldChooserWidget
Returns:
A single Element, possibly null, if there is no match.

findElements

public java.util.Collection findElements(IXml locatorSet,
                                         IXml typeSet,
                                         java.util.Collection warnings)
Get a list of all the elements selected by the locatorSet and the typeSet. Either one may be null.

Parameters:
locatorSet - IXml of the type returned by standard BuilderInput Fields
typeSet - IXml of the type returned by standard BuilderInput FieldTypes
warnings - Any warnings will be put here, if this is non-null
Returns:
a (possibly empty) Collection of Elements.

findElementsFromStandardInputs

public java.util.Collection findElementsFromStandardInputs(BuilderInputs builderInputs,
                                                           java.util.Collection warnings)
This is a utility method to be used by Builders that use the standard inputs of "FieldSelector, Fields, FieldTypes"

Parameters:
builderInputs - BuilderInputs passed into doBuilderCall
warnings - Any warnings will be put here, if this is non-null
Returns:
a (possibly empty) Collection of Elements which are selected by the fields.

findNamedElementInIXml

public static IXml findNamedElementInIXml(IXml ixml,
                                          java.lang.String elementName,
                                          java.util.Set blockedNames)
Find an element within this IXml with the "name" or "id" attribute equal to elementName

Parameters:
ixml - IXml within which to search
elementName - name to match
blockedNames - TODO
Returns:
The found element, or null

findNamedElementOnPage

public static IXml findNamedElementOnPage(Page page,
                                          java.lang.String elementName)
Find an element on this Page with the name attribute equal to elementName

Parameters:
page - WebApp Page
elementName - name to match
Returns:
The found element, or null

getAllFields

public java.util.List getAllFields(boolean containersOnly)
Get all the Field Selector Strings. This is used by the PageAutomationFieldChooserWidget

Parameters:
containersOnly - if true, only selectors for containers will be added to list
Returns:
List of Strings of all the Field Selectors.

getPageName

public java.lang.String getPageName(java.lang.String locator)
Parses the page name from the provided locator string

Parameters:
locator - String that would have been generated by a PageAutomationFieldChooserWidget
Returns:
A page name from the locator string

getPageReference

public static PageReference getPageReference(Page page)
If there is already a PageReference for this page, returns it, or creates one as needed

Parameters:
page - a WebApp page
Returns:
PageReference that is already associated with this page, if one exists, else creates one

getPageReference

public PageReference getPageReference(java.lang.String pageName)
get a PageReference associated with a page of this name in the webApp

Parameters:
pageName -
Returns:
a PageReference associated with a page of this name in the webApp, or null

getPageReferenceNames

public java.util.Collection getPageReferenceNames()
Returns:
Collection of Strings: names of all PageReferences in this webApp

getPageReferences

public java.util.Collection getPageReferences()
Returns:
All PageReferences in this webApp

getTypeNames

public java.util.Collection getTypeNames()
Get a list of all type names used in this model.

Returns:
Collection (actually a Set) of Strings

getTypeNames

public java.util.Collection getTypeNames(boolean containersOnly)
Get a list of all type names used in this model.

Returns:
Collection (actually a Set) of Strings

getWebApp

public WebApp getWebApp()

hasPageReference

public static boolean hasPageReference(Page page)
Checks to see if there is already a pageReference for this page

Parameters:
page - a WebApp page
Returns:
true if a pageReference already exists for this page

leafIsInTable

public static boolean leafIsInTable(Leaf leaf)

matchElementsToPage

public static void matchElementsToPage(Element root)

matchElementsToPage

public static void matchElementsToPage(Element root,
                                       AutomationHelper.PropertySet pSet)

matchElementsToPage

public static void matchElementsToPage(Element root,
                                       AutomationHelper.PropertySet pSet,
                                       boolean bFixup)

matchElementsToPage

public static void matchElementsToPage(Element root,
                                       boolean bFixup)

openTemplateFile

public static com.bowstreet.builders.webapp.pageautomation.content.HTMLTemplate openTemplateFile(java.lang.String templateFile,
                                                                                                 GenContext genContext)
Opens an HTMLTemplate file, creating an instance of HTMLTemplate. IMPORTANT! Side-effect: If the file can not be opened, an error will be placed in the current BuilderCall.

Parameters:
templateFile - name of an HTML Template file, null is tolerated
genContext - the current GenContext, must be non-null
Returns:
an HTMLTemplate pointing to the file specified, or null if it couldn't be opened.

releasePageReferences

public void releasePageReferences()
release the memory associated with the PageAutomation tools


setActiveBuilderCall

public BuilderCall setActiveBuilderCall(BuilderCall builderCall)

setActiveBuilderCall

public java.lang.String setActiveBuilderCall(java.lang.String builderCallID)
Set the current builderCallID in the WebApp, so that the GenElement references to any created objects will point to the correct builderCall. This returns the previous builderCallID so that you can restore it when you are done.

Parameters:
builderCallID -
Returns:
previous builderCallID so you can restore it

setDefaultLabel

public static void setDefaultLabel(Element element,
                                   java.lang.String name)


Copyright © 2009 IBM. All Rights Reserved.