wt.index
Class IndexDelegate

java.lang.Object
  extended bywt.index.IndexDelegate
All Implemented Interfaces:
Externalizable, Serializable

public class IndexDelegate
extends Object
implements Externalizable

This is the class that extracts textual information out of Business Objects and write it to the indexed search collection. Note that you should not call or instantiate the IndexDelegate directly, but rely on the queing mechanism of the IndexService to execute the methods when appropriate. Note that if you override this class, you will need to update the service.properties file to put your new IndexDelegate into affect.

Supported API: true

Extendable: true

See Also:
Serialized Form

Field Summary
private static String CLASSNAME
           
static long EXTERNALIZATION_VERSION_UID
           
private static String GENERIC_ICON
           
protected static long OLD_FORMAT_VERSION_UID
           
private static String RESOURCE
           
(package private) static long serialVersionUID
           
protected  String SYSTEM_ID
           
private  Index theIndex
           
private  Indexable theIndexable
           
private  WTReference theWTReference
           
private  boolean VERBOSE_EXECUTION
           
 
Constructor Summary
IndexDelegate()
          Instantiate a new IndexDelegate.
 
Method Summary
protected  String createIndexKey()
          This method creates the key that the object will be indexed as.
 Void delete()
          This methods deletes an object out of the indexed collection.
 Index getIndex()
          Gets the object for the association that plays role: theIndex.
 Indexable getIndexable()
          Gets the object for the association that plays role: theIndexable.
protected  IndexAccessor getIndexAccessor(IndexAccessorConnection iaccConn)
          Returns an IndexAccessor that uses the IndexAccessorConnection iaccConn.
protected  String getIndexObjectType()
          This method is in place to be overidden for the case when someone wants to use an object other than "WindchillBusinessObject" from the formats.cfg file.
 WTReference getWTReference()
          Gets the object for the association that plays role: theWTReference.
 Void index()
          This method is what is called by the IndexService to do indexing.
protected  void indexInstanceAttributes(Object businessObj, IndexAccessor iacc)
          Indexes attribute names and values of Instance Based Attributes.
protected  void indexPlugin(IndexAccessor iacc)
          This function is a place keeper for additional indexing capability defined by the user.
private  void Log(String line)
           
 void outputInstanceAttributes(Object businessObj)
          This method outputs the instance attributes for the IBA Holder pointed to by Object o.
 void readExternal(ObjectInput input)
          Reads the non-transient fields of this class from an external source.
private  boolean readOldVersion(ObjectInput input, long readSerialVersionUID, boolean passThrough, boolean superDone)
          Reads the non-transient fields of this class from an external source, which is not the current version.
protected  boolean readVersion(IndexDelegate thisObject, ObjectInput input, long readSerialVersionUID, boolean passThrough, boolean superDone)
          Reads the non-transient fields of this class from an external source.
private  String sanitize(String str)
           
private  void sendAttributeToIndex(Indexable obj, ClassInfo objInfo, PropertyDescriptor prop, String contentSearchField, IndexAccessor iacc)
           
private  void sendAttributeToIndex(Indexable obj, ClassInfo objInfo, String propertyName, IndexAccessor iacc)
           
protected  void sendAttributeToIndex(String indexField, String value, IndexAccessor iacc)
          This method is used to place the string "value", in the field "indexField" in the index.
 void setIndex(Index a_Index)
          Sets the object for the association that plays role: theIndex.
 void setIndexable(Indexable a_Indexable)
          Sets the object for the association that plays role: theIndexable.
 void setWTReference(WTReference a_WTReference)
          Sets the object for the association that plays role: theWTReference.
private  void theIndexValidate(Index a_Index)
           
private  void theWTReferenceValidate(WTReference a_WTReference)
           
 void writeExternal(ObjectOutput output)
          Writes the non-transient fields of this class to an external source.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

RESOURCE

private static final String RESOURCE
See Also:
Constant Field Values

CLASSNAME

private static final String CLASSNAME

theIndex

private Index theIndex

theIndexable

private Indexable theIndexable

theWTReference

private WTReference theWTReference

serialVersionUID

static final long serialVersionUID
See Also:
Constant Field Values

EXTERNALIZATION_VERSION_UID

public static final long EXTERNALIZATION_VERSION_UID
See Also:
Constant Field Values

OLD_FORMAT_VERSION_UID

protected static final long OLD_FORMAT_VERSION_UID
See Also:
Constant Field Values

VERBOSE_EXECUTION

private boolean VERBOSE_EXECUTION

SYSTEM_ID

protected String SYSTEM_ID

GENERIC_ICON

private static final String GENERIC_ICON
See Also:
Constant Field Values
Constructor Detail

IndexDelegate

public IndexDelegate()
              throws IOException
Instantiate a new IndexDelegate.

Supported API: true

Throws:
IOException
Method Detail

writeExternal

public void writeExternal(ObjectOutput output)
                   throws IOException
Writes the non-transient fields of this class to an external source.

Supported API: false

Specified by:
writeExternal in interface Externalizable
Parameters:
output -
Throws:
IOException

readExternal

public void readExternal(ObjectInput input)
                  throws IOException,
                         ClassNotFoundException
Reads the non-transient fields of this class from an external source.

Supported API: false

Specified by:
readExternal in interface Externalizable
Parameters:
input -
Throws:
IOException
ClassNotFoundException

readVersion

protected boolean readVersion(IndexDelegate thisObject,
                              ObjectInput input,
                              long readSerialVersionUID,
                              boolean passThrough,
                              boolean superDone)
                       throws IOException,
                              ClassNotFoundException
Reads the non-transient fields of this class from an external source.

Supported API: false

Parameters:
thisObject -
input -
readSerialVersionUID -
passThrough -
superDone -
Returns:
boolean
Throws:
IOException
ClassNotFoundException

readOldVersion

private boolean readOldVersion(ObjectInput input,
                               long readSerialVersionUID,
                               boolean passThrough,
                               boolean superDone)
                        throws IOException,
                               ClassNotFoundException
Reads the non-transient fields of this class from an external source, which is not the current version.

Parameters:
input -
readSerialVersionUID -
passThrough -
superDone -
Returns:
boolean
Throws:
IOException
ClassNotFoundException

getIndex

public Index getIndex()
Gets the object for the association that plays role: theIndex.

Supported API: false

Returns:
Index

setIndex

public void setIndex(Index a_Index)
              throws WTPropertyVetoException
Sets the object for the association that plays role: theIndex.

Supported API: false

Parameters:
a_Index -
Throws:
WTPropertyVetoException

theIndexValidate

private void theIndexValidate(Index a_Index)
                       throws WTPropertyVetoException
Parameters:
a_Index -
Throws:
WTPropertyVetoException

getIndexable

public Indexable getIndexable()
Gets the object for the association that plays role: theIndexable.

Supported API: false

Returns:
Indexable

setIndexable

public void setIndexable(Indexable a_Indexable)
                  throws WTPropertyVetoException
Sets the object for the association that plays role: theIndexable.

Supported API: false

Parameters:
a_Indexable -
Throws:
WTPropertyVetoException

getWTReference

public WTReference getWTReference()
Gets the object for the association that plays role: theWTReference.

Supported API: false

Returns:
WTReference

setWTReference

public void setWTReference(WTReference a_WTReference)
                    throws WTPropertyVetoException
Sets the object for the association that plays role: theWTReference.

Supported API: false

Parameters:
a_WTReference -
Throws:
WTPropertyVetoException

theWTReferenceValidate

private void theWTReferenceValidate(WTReference a_WTReference)
                             throws WTPropertyVetoException
Parameters:
a_WTReference -
Throws:
WTPropertyVetoException

index

public Void index()
           throws IndexingException,
                  WTException,
                  IllegalAccessException,
                  InvocationTargetException,
                  ClassNotFoundException,
                  InstantiationException,
                  PropertyVetoException,
                  IOException
This method is what is called by the IndexService to do indexing. This

method can be overriden to index text to an indexed collection in a

non-default way. The following is an example of what your code

might look like to override this method.

IndexAccessor iacc = null;

IndexAccessorConnection iaccConn = null;

iaccConn = IndexAccessorConnectionFactory.createAccessor( getIndex( ) );

iacc = getIndexAccessor(iaccConn);

iacc.writeHeader( );

iacc.beginIndex();

iacc.writeType( "MyCrObject" ); // this maps to a type defined in formats.cfg

MyChangeRequest cr = (MyChangeRequest)getIndexable( );

// note - identity and customerSite need to be defined in the formats.cfg

iacc.writeItem( "identity", cr.getIdentity( ) );

iacc.writeItem( "customerSite", cr.getSite ( ) .getDisplay( WTContext.getContext().getLocale( ) ));

iacc.endIndex();

// Wait for the status to come back indicating that indexing is complete.

String accStatus = iaccConn.getStatus();

if (!( accStatus.equals(IndexEntryToRware.SUCCESS_STATUS))) {

Object args[] = { identity };

throw new IndexingException( RESOURCE,

indexResource.INDEX_FAILURE,

args );} }

finally {

iaccConn.closeConnection( );

}



Supported API: true

Returns:
Void
Throws:
IndexingException
WTException
IllegalAccessException
InvocationTargetException
ClassNotFoundException
InstantiationException
PropertyVetoException
IOException
See Also:
IndexAccessorConnectionFactory, IndexAccessorConnection, IndexAccessor

delete

public Void delete()
            throws WTException,
                   IllegalAccessException,
                   ClassNotFoundException,
                   InstantiationException,
                   IOException
This methods deletes an object out of the indexed collection. Do not override this method.

Supported API: false

Returns:
Void
Throws:
WTException
IllegalAccessException
ClassNotFoundException
InstantiationException
IOException

createIndexKey

protected String createIndexKey()
                         throws WTException
This method creates the key that the object will be indexed as. Overriding this method is not recommended or supported.

Supported API: false

Returns:
String
Throws:
WTException

getIndexAccessor

protected IndexAccessor getIndexAccessor(IndexAccessorConnection iaccConn)
                                  throws IndexingException,
                                         WTException,
                                         IllegalAccessException,
                                         InvocationTargetException,
                                         ClassNotFoundException,
                                         InstantiationException,
                                         PropertyVetoException,
                                         IOException
Returns an IndexAccessor that uses the IndexAccessorConnection iaccConn.

Supported API: false

Parameters:
iaccConn - IndexAccessorConnection object for which an IndexAccessor is requested.
Returns:
IndexAccessor
Throws:
IndexingException
WTException
IllegalAccessException
InvocationTargetException
ClassNotFoundException
InstantiationException
PropertyVetoException
IOException

indexPlugin

protected void indexPlugin(IndexAccessor iacc)
                    throws WTException,
                           IllegalAccessException,
                           InvocationTargetException
This function is a place keeper for additional indexing capability defined by the user. Override this method to index attributes in addition to the attributes indexed by the default index() method.

Supported API: false

Parameters:
iacc - IndexAccessor that is being used for the current indexing transaction. Is passed in by the index() method.
Throws:
WTException
IllegalAccessException
InvocationTargetException

sendAttributeToIndex

protected void sendAttributeToIndex(String indexField,
                                    String value,
                                    IndexAccessor iacc)
                             throws WTException,
                                    IllegalAccessException,
                                    InvocationTargetException
This method is used to place the string "value", in the field "indexField" in the index.

Supported API: true

Parameters:
indexField - The indexed collection field name that the string "value" is to be written to.
value - A string that is placed in the index field "indexField".
iacc - The IndexAccessor that is associated with the IndexAccessorConnection for this transaction.
Throws:
WTException
IllegalAccessException
InvocationTargetException

getIndexObjectType

protected String getIndexObjectType()
This method is in place to be overidden for the case when someone wants to use an object other than "WindchillBusinessObject" from the formats.cfg file. Simply overide the method by returning a string identifying the object from the formats.cfg file.

Supported API: false

Returns:
String

indexInstanceAttributes

protected void indexInstanceAttributes(Object businessObj,
                                       IndexAccessor iacc)
                                throws WTException,
                                       IllegalAccessException,
                                       InvocationTargetException
Indexes attribute names and values of Instance Based Attributes.

Supported API: false

Parameters:
businessObj -
iacc -
Throws:
WTException
IllegalAccessException
InvocationTargetException

sendAttributeToIndex

private void sendAttributeToIndex(Indexable obj,
                                  ClassInfo objInfo,
                                  PropertyDescriptor prop,
                                  String contentSearchField,
                                  IndexAccessor iacc)
                           throws WTException,
                                  IllegalAccessException,
                                  InvocationTargetException
Throws:
WTException
IllegalAccessException
InvocationTargetException

sendAttributeToIndex

private void sendAttributeToIndex(Indexable obj,
                                  ClassInfo objInfo,
                                  String propertyName,
                                  IndexAccessor iacc)
                           throws WTException,
                                  IllegalAccessException,
                                  InvocationTargetException
Throws:
WTException
IllegalAccessException
InvocationTargetException

outputInstanceAttributes

public void outputInstanceAttributes(Object businessObj)
This method outputs the instance attributes for the IBA Holder pointed to by Object o.


Log

private void Log(String line)

sanitize

private String sanitize(String str)