org.eclipse.datatools.connectivity.oda.design.util
Class DesignUtil

java.lang.Object
  extended by org.eclipse.datatools.connectivity.oda.design.util.DesignUtil

public class DesignUtil
extends java.lang.Object

An utility class to handle the ODA Design API objects.


Method Summary
static java.lang.String addDefaultToResourceAttribute(java.lang.String newDefault, java.lang.String attributeValue)
          Adds or replaces the default resource string in the specified design attribute value.
static java.lang.String addKeyToResourceAttribute(java.lang.String newKey, java.lang.String attributeValue)
          Adds or replaces the resource key in the specified design attribute value.
static java.util.Properties convertDataSourceProperties(DataSourceDesign dataSourceDesign)
          Converts the public and private properties defined in an ODA data source design definition, and returns in a combined java.util.Properties collection.
static java.util.Properties convertDesignProperties(Properties designProps)
          Converts the given design properties defined in an ODA data source or data set design definition, to a java.util.Properties collection.
static java.lang.String convertFileToPath(java.io.File aFile)
          Converts the specified file to a string representation that can be persisted in an oda design model.
static java.lang.String convertFileToResourcePath(java.io.File aFile, ResourceIdentifiers designResourceIds, boolean convertToRelativePath)
          Converts the specified file to a string representation that can be persisted in an oda design model.
static java.io.File convertPathToFile(java.lang.String filePath)
          Converts the specified string representation of a file pathname, persisted in an oda design model, to its abstract representation.
static java.io.File convertPathToResourceFile(java.lang.String filePath, ResourceIdentifiers designResourceIds)
          Converts the specified string representation of a file pathname, persisted in an oda design model, to its abstract absolute representation.
static Properties convertToDesignProperties(java.util.Properties utilProps)
          Converts the given java.util.Properties collection to ODA design properties that can be applied in an ODA data source or data set design definition.
static ExpressionVariable createFilterVariable(ResultSetColumns columns, int columnIndex)
          Creates a new filter expression variable for the column defined in the specified result set at the specified index.
static SortKey createSortKeyWithColumnIdentifier(ResultSetColumns columns, int columnIndex)
          Creates a new SortKey with the identifier, i.e.
static org.eclipse.emf.common.util.Diagnostic diagnoseObject(org.eclipse.emf.ecore.EObject eObject)
          Diagnoses the given EMF object, and returns the diagnostic result found.
static java.lang.String getDefaultResourceString(java.lang.String attributeValue)
          Returns the default resource string, if any, in the specified design attribute value.
static java.lang.String getResourceKey(java.lang.String attributeValue)
          Returns the resource key, if any, in the specified design attribute value.
static OdaDesignSession loadOdaDesignSession(java.io.File resourceFile)
          An utility method to load the specified resource file, and returns the OdaDesignSession instance found in the file.
static OdaDesignSession loadOdaDesignSession(org.eclipse.emf.common.util.URI uri)
          An utility method to load the specified resource URI, and returns the OdaDesignSession instance found in the resource.
static java.lang.String resolveToApplResourcePath(java.lang.String filePath, ResourceIdentifiers designResourceIds)
          Returns the absolute path of the specified filePath based on the specified host application resource identifiers.
static void saveOdaDesignSession(OdaDesignSession odaDesignSession, java.io.File outputFile)
          An utility method to save the specified OdaDesignSession instance in the specified output file.
static void saveOdaDesignSession(OdaDesignSession odaDesignSession, org.eclipse.emf.common.util.URI uri)
          An utility method to save the specified OdaDesignSession instance in the specified URI.
static void validateDataSourceDesign(DataSourceDesign dataSourceDesign)
          Validates the specified data source design instance.
static void validateObject(org.eclipse.emf.ecore.EObject eObject)
          Validates the given EMF object is valid and has all required elements.
static java.lang.String validateRequestSession(DesignSessionRequest requestSession)
          Validates the specified design session request.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

validateObject

public static void validateObject(org.eclipse.emf.ecore.EObject eObject)
                           throws java.lang.IllegalStateException
Validates the given EMF object is valid and has all required elements.

Parameters:
eObject - an EMF object
Throws:
java.lang.IllegalStateException - if the given object is not valid and have error diagnostics; the exception thrown includes all error and warning diagnostic messages found in given object

diagnoseObject

public static org.eclipse.emf.common.util.Diagnostic diagnoseObject(org.eclipse.emf.ecore.EObject eObject)
Diagnoses the given EMF object, and returns the diagnostic result found.

Parameters:
eObject - an EMF object
Returns:
the diagnostic result, or null if no diagnostic result found

convertDataSourceProperties

public static java.util.Properties convertDataSourceProperties(DataSourceDesign dataSourceDesign)
Converts the public and private properties defined in an ODA data source design definition, and returns in a combined java.util.Properties collection.

Parameters:
dataSourceDesign -
Returns:

convertDesignProperties

public static java.util.Properties convertDesignProperties(Properties designProps)
Converts the given design properties defined in an ODA data source or data set design definition, to a java.util.Properties collection.

Parameters:
designProps - the ODA design properties to convert from
Returns:
converted properties in a java.util.Properties collection

convertToDesignProperties

public static Properties convertToDesignProperties(java.util.Properties utilProps)
Converts the given java.util.Properties collection to ODA design properties that can be applied in an ODA data source or data set design definition.

Parameters:
utilProps - the java.util.Properties collection to convert from
Returns:
converted properties in a design properties collection

validateRequestSession

public static java.lang.String validateRequestSession(DesignSessionRequest requestSession)
                                               throws java.lang.IllegalStateException
Validates the specified design session request. If valid, returns the request's ODA data source element id.

Parameters:
requestSession -
Returns:
Throws:
java.lang.IllegalStateException - if specified session request is invalid

validateDataSourceDesign

public static void validateDataSourceDesign(DataSourceDesign dataSourceDesign)
                                     throws java.lang.IllegalStateException
Validates the specified data source design instance.

Parameters:
dataSourceDesign -
Throws:
java.lang.IllegalStateException - if specified design is invalid

convertPathToFile

public static java.io.File convertPathToFile(java.lang.String filePath)
Converts the specified string representation of a file pathname, persisted in an oda design model, to its abstract representation.

Parameters:
filePath - the string representation of a file
Returns:
the abstract representation of a file pathname, or null if the specified argument is null, invalid or the file does not exist
Since:
3.0.4
See Also:
convertPathToResourceFile(String, ResourceIdentifiers), convertFileToPath(File)

convertPathToResourceFile

public static java.io.File convertPathToResourceFile(java.lang.String filePath,
                                                     ResourceIdentifiers designResourceIds)
Converts the specified string representation of a file pathname, persisted in an oda design model, to its abstract absolute representation.

Parameters:
filePath - the string representation of a file, may be an absolute file path, or relative path based on the specified designResourceIds
designResourceIds - a design resource identifier instance defined by the host application
Returns:
the abstract representation of an absolute file pathname, or null if the specified filePath argument is null, invalid or the file does not exist
Since:
3.3.4 (DTP 1.9.2)

convertFileToPath

public static java.lang.String convertFileToPath(java.io.File aFile)
Converts the specified file to a string representation that can be persisted in an oda design model.

Parameters:
aFile - the abstract representation of a file pathname
Returns:
the string representation of the specified file, or null if the specified argument is null
Since:
3.0.4
See Also:
convertFileToResourcePath(File, ResourceIdentifiers, boolean), convertPathToFile(String)

convertFileToResourcePath

public static java.lang.String convertFileToResourcePath(java.io.File aFile,
                                                         ResourceIdentifiers designResourceIds,
                                                         boolean convertToRelativePath)
Converts the specified file to a string representation that can be persisted in an oda design model.

Parameters:
aFile - the abstract representation of an absolute file pathname
designResourceIds - a design resource identifier instance defined by the host application
convertToRelativePath - true indicates whether to convert the specified file to a relative path based on the host-defined design resource; false to convert to the absolute path of the specified file
Returns:
the relative path of the specified filePath, if specified by the convertToRelativePath argument; otherwise, returns the absolute path of the specified filePath
Since:
3.3.4 (DTP 1.9.2)

resolveToApplResourcePath

public static java.lang.String resolveToApplResourcePath(java.lang.String filePath,
                                                         ResourceIdentifiers designResourceIds)
Returns the absolute path of the specified filePath based on the specified host application resource identifiers.

Parameters:
filePath - the path to resolve; may be a relative or absolute path
designResourceIds - a design resource identifier instance defined by the host application
Returns:
the absolute path of the specified filePath
Since:
3.3.4 (DTP 1.9.2)

saveOdaDesignSession

public static void saveOdaDesignSession(OdaDesignSession odaDesignSession,
                                        java.io.File outputFile)
                                 throws java.io.IOException,
                                        java.lang.IllegalArgumentException
An utility method to save the specified OdaDesignSession instance in the specified output file.

Parameters:
outputFile - an output file; any existing content would get overwritten
odaDesignSession - the design session instance to save
Throws:
java.io.IOException
java.lang.IllegalArgumentException
Since:
DTP 1.6

saveOdaDesignSession

public static void saveOdaDesignSession(OdaDesignSession odaDesignSession,
                                        org.eclipse.emf.common.util.URI uri)
                                 throws java.io.IOException
An utility method to save the specified OdaDesignSession instance in the specified URI.

Parameters:
uri - the URI of the saved resource
odaDesignSession - the design session instance to save
Throws:
java.io.IOException
Since:
DTP 1.6

loadOdaDesignSession

public static OdaDesignSession loadOdaDesignSession(java.io.File resourceFile)
                                             throws java.io.IOException,
                                                    java.lang.IllegalArgumentException
An utility method to load the specified resource file, and returns the OdaDesignSession instance found in the file.

Parameters:
resourceFile - a resource file to load from
Returns:
the design session instance found in the specified file
Throws:
java.io.IOException
java.lang.IllegalArgumentException
Since:
DTP 1.6

loadOdaDesignSession

public static OdaDesignSession loadOdaDesignSession(org.eclipse.emf.common.util.URI uri)
                                             throws java.io.IOException
An utility method to load the specified resource URI, and returns the OdaDesignSession instance found in the resource.

Parameters:
uri - the URI of the resource to load from
Returns:
the design session instance found in the specified URI
Throws:
java.io.IOException
Since:
DTP 1.6

createFilterVariable

public static ExpressionVariable createFilterVariable(ResultSetColumns columns,
                                                      int columnIndex)
Creates a new filter expression variable for the column defined in the specified result set at the specified index.

Parameters:
columns - a ResultSetColumns that contains a collection of column definitions
columnIndex - 0-based index of column in the specified columns; must be a valid index within range of the specified columns
Returns:
a new instance of ExpressionVariable based on the attributes of the specified column; may be null if specified column does not exist
Since:
3.2.0 (DTP 1.7.0)

createSortKeyWithColumnIdentifier

public static SortKey createSortKeyWithColumnIdentifier(ResultSetColumns columns,
                                                        int columnIndex)
Creates a new SortKey with the identifier, i.e. name and position, of the column defined in the specified result set at the specified index.

Parameters:
columns - a ResultSetColumns that contains a collection of column definitions
columnIndex - 0-based index of column in the specified columns; must be a valid index within range of the specified columns
Returns:
a new instance of SortKey based on the name and position of the specified column; may be null if specified column does not exist
Since:
3.2.0 (DTP 1.7.0)

getResourceKey

public static java.lang.String getResourceKey(java.lang.String attributeValue)
Returns the resource key, if any, in the specified design attribute value.

Parameters:
attributeValue - the persisted value of a localizable attribute that may contain a resource key and a default resource string
Returns:
the resource key found in the specified design attribute value; may be null if none is available
Since:
3.2.3

addKeyToResourceAttribute

public static java.lang.String addKeyToResourceAttribute(java.lang.String newKey,
                                                         java.lang.String attributeValue)
Adds or replaces the resource key in the specified design attribute value.

Parameters:
newKey - the resource key to add or replace in the specified attributeValue; the key must not contain any embedded white space
attributeValue - the current persisted value of a localizable attribute that may contain a resource key and a default string
Returns:
the new formatted attribute value that contains the new resource key and existing default string, if any
Since:
3.2.3

getDefaultResourceString

public static java.lang.String getDefaultResourceString(java.lang.String attributeValue)
Returns the default resource string, if any, in the specified design attribute value.

Parameters:
attributeValue - the persisted value of a localizable attribute that may contain a resource key and a default resource string
Returns:
the default resource string in the specified attribute value; may be null if none is available
Since:
3.2.3

addDefaultToResourceAttribute

public static java.lang.String addDefaultToResourceAttribute(java.lang.String newDefault,
                                                             java.lang.String attributeValue)
Adds or replaces the default resource string in the specified design attribute value.

Parameters:
newDefault - the new default resource string to add or replace in the specified attributeValue
attributeValue - the current persisted value of a localizable attribute that may contain a resource key and a default string
Returns:
the new formatted attribute value that contains the existing resource key, if any, and the new default string
Since:
3.2.3