com.endeca.portal.compare
Class CompareUtil

java.lang.Object
  extended by com.endeca.portal.compare.CompareUtil

public class CompareUtil
extends java.lang.Object

This component provides the ability for an end user to compare multiple Endeca records side-by-side. It supports the comparison of both standard records and analytics records.

Author:
Endeca Technologies, Inc.

Nested Class Summary
static class CompareUtil.RecordType
           
 
Field Summary
static java.lang.String RECORD_TYPE
           
 
Constructor Summary
CompareUtil()
           
 
Method Summary
static CompareGridModel getCompareConfig(javax.portlet.PortletRequest request, javax.portlet.PortletResponse response, CompareEventParam cep, java.util.Map<java.lang.String,FormatSettings> formatters, SemanticView semanticView, java.util.List<java.lang.String> columns)
          Called when the compare action is invoked.
static java.util.List<CompareGridRecordModel> getFilteredData(java.util.List<java.util.Map<java.lang.String,java.util.List<java.lang.String>>> records, SemanticView mergedSemanticView, javax.portlet.PortletRequest request, CompareUtil.RecordType recordType, java.util.Map<java.lang.String,FormatSettings> formatters, java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.String>> referenceMap)
          Filter the data according to the attribute settings in preferences and control panel
protected static java.lang.String[] getRecordIds(javax.portlet.PortletRequest request, java.lang.String ids, CompareUtil.RecordType type)
          Returns the IDs of the records required.
static java.util.List<java.util.Map<java.lang.String,java.util.List<java.lang.String>>> getRecords(javax.portlet.PortletRequest request, java.lang.String[] recordIDs, CompareUtil.RecordType recordType, DataSource ds, SemanticView semanticView, java.util.List<java.lang.String> columns, java.util.Map<java.lang.String,FormatSettings> formatters)
          Returns the a list of records that contain all the attribute values of it
protected static CompareUtil.RecordType getRecordType(javax.portlet.PortletRequest request, javax.portlet.PortletResponse response, java.lang.String dsId)
          Returns the record type.
protected static java.lang.String[] removeEmptyIds(java.lang.String[] recordIds)
          Removes the empty ids in the id list
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

RECORD_TYPE

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

CompareUtil

public CompareUtil()
Method Detail

getCompareConfig

public static CompareGridModel getCompareConfig(javax.portlet.PortletRequest request,
                                                javax.portlet.PortletResponse response,
                                                CompareEventParam cep,
                                                java.util.Map<java.lang.String,FormatSettings> formatters,
                                                SemanticView semanticView,
                                                java.util.List<java.lang.String> columns)
                                         throws java.lang.Exception
Called when the compare action is invoked. This will return a CompareGridModel, with the record ids of the records chosen to compare so that they can be displayed in a modal window.

Throws:
java.lang.Exception

getRecordIds

protected static java.lang.String[] getRecordIds(javax.portlet.PortletRequest request,
                                                 java.lang.String ids,
                                                 CompareUtil.RecordType type)
                                          throws javax.portlet.PortletException,
                                                 CompareException
Returns the IDs of the records required. If the DataSource name is different from the original one, return the IDs saved in the session. Otherwise, returns the IDs comes from the request and saved them into the session.

Parameters:
request -
Returns:
- a String array that contains the either the id of common records or the statement of analytics records
Throws:
javax.portlet.PortletException
CompareException

removeEmptyIds

protected static java.lang.String[] removeEmptyIds(java.lang.String[] recordIds)
Removes the empty ids in the id list

Parameters:
recordIds -
request -

getRecords

public static java.util.List<java.util.Map<java.lang.String,java.util.List<java.lang.String>>> getRecords(javax.portlet.PortletRequest request,
                                                                                                          java.lang.String[] recordIDs,
                                                                                                          CompareUtil.RecordType recordType,
                                                                                                          DataSource ds,
                                                                                                          SemanticView semanticView,
                                                                                                          java.util.List<java.lang.String> columns,
                                                                                                          java.util.Map<java.lang.String,FormatSettings> formatters)
                                                                                                   throws CompareException,
                                                                                                          javax.portlet.PortletException
Returns the a list of records that contain all the attribute values of it

Parameters:
request -
recordIDs -
Returns:
the List of records, each record is a map whose key is the property name and the value is property value
Throws:
javax.portlet.PortletException - - if the exception we catch is something we cannot handle
CompareException - - if the exception we catch is something we can handle

getRecordType

protected static CompareUtil.RecordType getRecordType(javax.portlet.PortletRequest request,
                                                      javax.portlet.PortletResponse response,
                                                      java.lang.String dsId)
                                               throws javax.portlet.PortletException
Returns the record type. If the DataSource name is different from the original one, return the one saved in the session. Otherwise, returns the one comes from the request and saved it into the session.

Parameters:
request -
Returns:
Type of the record
Throws:
javax.portlet.PortletException

getFilteredData

public static java.util.List<CompareGridRecordModel> getFilteredData(java.util.List<java.util.Map<java.lang.String,java.util.List<java.lang.String>>> records,
                                                                     SemanticView mergedSemanticView,
                                                                     javax.portlet.PortletRequest request,
                                                                     CompareUtil.RecordType recordType,
                                                                     java.util.Map<java.lang.String,FormatSettings> formatters,
                                                                     java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.String>> referenceMap)
Filter the data according to the attribute settings in preferences and control panel

Parameters:
records - The records get from MDEX
existedSemanticView -
request -
recordType - The type of record passed in
isNewEvent -
Returns:
the record that only has the desired attributes