com.ca.commons.datamodel
Class DataModelUtil

java.lang.Object
  extended by com.ca.commons.datamodel.MetaDataDefs
      extended by com.ca.commons.datamodel.DataModelUtil
Direct Known Subclasses:
MetaDataUtil

public class DataModelUtil
extends MetaDataDefs

Utility methods. Note that information on metadata properties must be maintained in MetaDataDefs rather then here.


Nested Class Summary
 
Nested classes/interfaces inherited from class com.ca.commons.datamodel.MetaDataDefs
MetaDataDefs.AssocType, MetaDataDefs.EncryptAlgorithms, MetaDataDefs.FlattenStyle, MetaDataDefs.ForceCaseValue, MetaDataDefs.ForceModModeValue, MetaDataDefs.GeneratedOverrideStatus, MetaDataDefs.RegexStyle
 
Field Summary
static Class<?> BYTE_ARRAY_CLASS
           
static String ET_ACCOUNT
          Used to identify account object class, which will have this in "extends" list.
static com.ca.commons.functional.Fn<Item,String> jaxbItemNameGetter
           
static int MAX_DESCRIPTION_LENGTH
          Namespace descriptions must be between 0 and 128 chars long.
static int MAX_NAME_LENGTH
          Namespace names must be between 1 and 50 chars long.
static String META_DATA_NAME
          Used in absolute names for metadata properties, to distinguish them from normal properties, e.g.
 
Fields inherited from class com.ca.commons.datamodel.MetaDataDefs
CUSTOM, MAP_TO_CONNECTOR_VALUE, MD_ABBREVIATION, MD_ACCOUNT_CLASS, MD_ACCOUNT_TEMPLATE_CLASS, MD_ASSOC_OBJ_KEY_ATTR, MD_ASSOC_REF_KEY_ATTR, MD_ASSOC_REF_OBJECT_CLASS, MD_ASSOC_REVERSE_ATTR, MD_ASSOC_TABLE, MD_ASSOC_TABLE_OBJ_COLUMN, MD_ASSOC_TABLE_REF_COLUMN, MD_ASSOC_TYPE, MD_BEAN_PROPERTY_NAME, MD_BOOL_VALUES, MD_CHILD_TYPES, MD_COLLECTIONCONTENTS, MD_CONN_GENERATED_OVERRIDE, MD_CONN_GENERATOR, MD_CONN_MAP_ALIAS, MD_CONN_MAP_TO, MD_CONN_MAP_TO_AMBIGUOUS, MD_CONN_MAP_TO_AMBIGUOUS_CHOICE_ATTR, MD_CONN_MAP_TO_AUX, MD_CONN_MAP_TO_DERIVED, MD_CONN_MAP_TO_LANG, MD_CONN_MAP_TO_LAX, MD_CONN_MAP_TO_MULTIPLE, MD_CONN_MAP_TO_SAME, MD_CONN_MAP_TO_STRICT, MD_CONN_SEARCH_CONTAINER, MD_CONNECTOR_XML, MD_CONVERT_REGEX, MD_CONVERT_REGEX_FROM_CONN, MD_CONVERT_REGEX_STYLE, MD_CONVERTER_CLASS, MD_DEFAULT_POLICY_VALUE, MD_DEFAULT_VALUE, MD_DEREGISTER, MD_DISPLAY_NAME, MD_DN_LDAP_OBJECT_CLASS, MD_DN_LDAP_OBJECT_CLASSES, MD_DN_NAME_ONLY, MD_DN_NAME_ONLY_LDAP_OBJECTCLASS, MD_DN_TEST_EXISTS, MD_DN_TYPE, MD_DONT_PREFIX_ALGORITHM, MD_EDIT_VERSION, MD_ENCRYPT_ALG, MD_ENDPOINT_CLASS, MD_FLATTEN_STYLE, MD_FORCE_CASE, MD_FORCE_MOD_MODE, MD_GROUP_CLASS, MD_GROUP_CONTENTS, MD_GROUP_MAPPINGS, MD_IMPLEMENTATION_BUNDLE, MD_IS_CAPABILITY, MD_IS_CASE_SENSITIVE, MD_IS_COMPOUND_VALUE, MD_IS_CONN_GENERATED, MD_IS_CONNECTION_ATTR, MD_IS_CONNECTOR_FILTERABLE, MD_IS_CONNECTOR_SIBLING, MD_IS_CONTAINER, MD_IS_CREATABLE, MD_IS_DELETABLE, MD_IS_DN_ABSOLUTE, MD_IS_DYNAMIC, MD_IS_ENCRYPTED, MD_IS_EXPENSIVE, MD_IS_HIDDEN, MD_IS_HIERARCHICAL, MD_IS_JAVA_OBJECT, MD_IS_LAX, MD_IS_LOGGING_ATTR, MD_IS_MOVEABLE, MD_IS_MULTI_VALUED, MD_IS_NAMING, MD_IS_NATIVE_DN_TYPE, MD_IS_NESTED, MD_IS_NESTED_ALL, MD_IS_NON_STD, MD_IS_OBFUSCATED, MD_IS_OPERATIONAL_ATTR, MD_IS_POLICY_SYNC, MD_IS_READ_ONLY, MD_IS_READ_ONLY_NATIVE, MD_IS_RENAMABLE, MD_IS_RENAME_VIA_DELETE_ADD, MD_IS_REQUIRED, MD_IS_REQUIRED_AMBIGUOUS, MD_IS_REQUIRED_NATIVE, MD_IS_SEARCHABLE, MD_IS_SESSION_REQUIRED, MD_IS_SINGLE_NAMING_VALUE, MD_IS_STATIC, MD_IS_STORE_NUMERIC, MD_IS_STORE_SYMBOLIC, MD_IS_STRING_ARRAY, MD_IS_TRIM_REQUIRED, MD_IS_UNMANAGED, MD_IS_VIRTUAL, MD_IS_WELL_KNOWN, MD_IS_WRITE_ONLY, MD_JAVA_SRCCLASS, MD_JIAM_OBJECT_TYPE, MD_LINE_SEPARATOR, MD_MAX_LENGTH, MD_MAX_LENGTH_NATIVE, MD_MAX_VALUE, MD_MIN_LENGTH, MD_MIN_VALUE, MD_NESTED_BASE_ATTRIBUTE, MD_POLICY_CLASS, MD_PROJECT_NAME, MD_QUOTE_STRING, MD_REGEX_DESCR, MD_SORT_ORDER_HINT, MD_SUPER_CLASS, MD_UI_SIZE, MD_USE_LIST_RELATIONSHIPS_INSTEAD, MD_USE_SPECIAL_NULL_VALUE, MD_VALID_REGEX, MD_VALID_REGEX_STYLE, MD_VALIDATOR_CLASS, MD_VALUE_MATCH_EXPR, MD_VALUE_TEMPLATE, MD_VERSION, MD_WRITABLE_BY
 
Constructor Summary
protected DataModelUtil()
           
 
Method Summary
static
<T> com.ca.commons.functional.Pred<HasMetadata>
fnMatchMdValue(String name, Class<? extends T> cl, com.ca.commons.functional.Fn<? super T,Boolean> pred)
           
static String getAbsoluteMetadataPropertyName(String parent, String mdPropName)
           
static boolean getBoolean(DataModelProperty prop)
          Returns true if prop is both not null, and true.
static boolean getBooleanMetaData(DataModelItem item, String mdName, boolean def)
           
static String[] getCollectionValues(DataModelValue value)
          Get values contained in a collection, as an array.
static String[] getItemPropertyCollectionValues(DataModelItem item, String propName)
          Return string values for multi-valued metadata property propName on the provided class cls.
static Map<String,String[]> getItemPropertyMapStringValues(DataModelItem item, String propName)
          Get values contained in a data model map as Map of String, String[] pairs suitable for Maps using Strings for both key and all values.
static Map<DataModelValue,DataModelValue> getItemPropertyMapValues(DataModelItem item, String propName)
          Get values contained in a data model map as Map of DataModelValue,DataModelValue pairs
static Map<DataModelValue,DataModelValue> getMapValues(DataModelValue value)
          Get values contained in a data model map as Map of DataModelValue,DataModelValue pairs
static String getSuperClassName(DataModelClass datamodelClass)
           
static boolean hasConnectorMapping(DataModelClass cls)
          Helper method to check for all the ways a class can be mapped to connector-speak.
static boolean hasConnectorMapping(DataModelProperty prop)
          Helper method to check for all the ways a property can be mapped to connector-speak.
static boolean isMultiValued(DataModelProperty prop)
          Check if a property is defined to contain multiple values.
static boolean isPropertyTypeDN(DataModelProperty prop)
          Check if a property is defined to contain DN (Distinguished Name) values.
static boolean isSensitive(DataModelProperty prop)
          Return true if values for prop shouldn't be logged.
static boolean isValidDataModelName(String name)
          Checks if a given datamodel name is valid
static com.ca.commons.functional.Fn<DataModelItem,String> itemNameGetter()
           
static String javaClassToDataModel(Class<?> cl)
           
static void mapJavaClassToDataModel(Class<?> cl, String absoluteDataModelName)
           
static com.ca.commons.functional.Pred<DataModelItem> matchItemName(String name)
           
static com.ca.commons.functional.Pred<Item> matchJaxbItemName(String name)
           
static
<T> com.ca.commons.functional.Pred<DataModelItem>
testMetadataEquals(String metadataName, T defaultValue, T compare)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MAX_NAME_LENGTH

public static final int MAX_NAME_LENGTH
Namespace names must be between 1 and 50 chars long.

See Also:
Constant Field Values

MAX_DESCRIPTION_LENGTH

public static final int MAX_DESCRIPTION_LENGTH
Namespace descriptions must be between 0 and 128 chars long.

See Also:
Constant Field Values

BYTE_ARRAY_CLASS

public static final Class<?> BYTE_ARRAY_CLASS

ET_ACCOUNT

public static final String ET_ACCOUNT
Used to identify account object class, which will have this in "extends" list.

See Also:
Constant Field Values

META_DATA_NAME

public static final String META_DATA_NAME
Used in absolute names for metadata properties, to distinguish them from normal properties, e.g. "mynamespace.myclass._metadata.metadata1" will access a metadata property called "metadata1" on class "myclass".

See Also:
Constant Field Values

jaxbItemNameGetter

@NotNull
public static final com.ca.commons.functional.Fn<Item,String> jaxbItemNameGetter
Constructor Detail

DataModelUtil

protected DataModelUtil()
Method Detail

getAbsoluteMetadataPropertyName

public static String getAbsoluteMetadataPropertyName(String parent,
                                                     String mdPropName)

isValidDataModelName

public static boolean isValidDataModelName(String name)
Checks if a given datamodel name is valid


getBoolean

public static boolean getBoolean(DataModelProperty prop)
Returns true if prop is both not null, and true.


getBooleanMetaData

public static boolean getBooleanMetaData(DataModelItem item,
                                         String mdName,
                                         boolean def)

getMapValues

public static Map<DataModelValue,DataModelValue> getMapValues(DataModelValue value)
Get values contained in a data model map as Map of DataModelValue,DataModelValue pairs

Parameters:
value - Map value.
Returns:
Map

getItemPropertyMapValues

public static Map<DataModelValue,DataModelValue> getItemPropertyMapValues(DataModelItem item,
                                                                          String propName)
Get values contained in a data model map as Map of DataModelValue,DataModelValue pairs

Parameters:
item - Data model element to be looked up.
propName - Map metadata property name
Returns:
Map representation of the property if found or null otherwise.

getItemPropertyMapStringValues

public static Map<String,String[]> getItemPropertyMapStringValues(DataModelItem item,
                                                                  String propName)
Get values contained in a data model map as Map of String, String[] pairs suitable for Maps using Strings for both key and all values.

Parameters:
item - Data model element to be looked up.
propName - Map metadata property name
Returns:
Map representation of the property if found or null otherwise.

getCollectionValues

public static String[] getCollectionValues(DataModelValue value)
Get values contained in a collection, as an array.

Parameters:
value - Collection value.
Returns:
Array of values.

getItemPropertyCollectionValues

public static String[] getItemPropertyCollectionValues(DataModelItem item,
                                                       String propName)
Return string values for multi-valued metadata property propName on the provided class cls.

Parameters:
item - Data model element to be looked up.
propName - Multi-valued metadata property name
Returns:
String values in value of metadata property, if found, null otherwise.

isMultiValued

public static boolean isMultiValued(DataModelProperty prop)
Check if a property is defined to contain multiple values.

Parameters:
prop - Property to be checked.
Returns:
True if property is either defined as multi-valued in datamodel (setValue or sequenceValue) or has a true MetaDataDefs.MD_IS_MULTI_VALUED setting).

isSensitive

public static boolean isSensitive(@NotNull
                                  DataModelProperty prop)
Return true if values for prop shouldn't be logged.


hasConnectorMapping

public static boolean hasConnectorMapping(DataModelClass cls)
Helper method to check for all the ways a class can be mapped to connector-speak.

Parameters:
prop - Property to be checked.
Returns:
True if property is mapped to connector-speak.

hasConnectorMapping

public static boolean hasConnectorMapping(DataModelProperty prop)
Helper method to check for all the ways a property can be mapped to connector-speak.

Parameters:
prop - Property to be checked.
Returns:
True if property is mapped to connector-speak.

isPropertyTypeDN

public static boolean isPropertyTypeDN(DataModelProperty prop)
Check if a property is defined to contain DN (Distinguished Name) values.

Parameters:
prop - Property to be checked.
Returns:
True if property contains DN value(s).

getSuperClassName

@Nullable
public static String getSuperClassName(DataModelClass datamodelClass)

itemNameGetter

@NotNull
public static com.ca.commons.functional.Fn<DataModelItem,String> itemNameGetter()

testMetadataEquals

@NotNull
public static <T> com.ca.commons.functional.Pred<DataModelItem> testMetadataEquals(@NotNull
                                                                                           String metadataName,
                                                                                           @NotNull
                                                                                           T defaultValue,
                                                                                           @NotNull
                                                                                           T compare)

matchItemName

@NotNull
public static com.ca.commons.functional.Pred<DataModelItem> matchItemName(@NotNull
                                                                                  String name)

fnMatchMdValue

public static <T> com.ca.commons.functional.Pred<HasMetadata> fnMatchMdValue(String name,
                                                                             Class<? extends T> cl,
                                                                             com.ca.commons.functional.Fn<? super T,Boolean> pred)

matchJaxbItemName

@NotNull
public static com.ca.commons.functional.Pred<Item> matchJaxbItemName(@NotNull
                                                                             String name)

mapJavaClassToDataModel

public static void mapJavaClassToDataModel(@NotNull
                                           Class<?> cl,
                                           @NotNull
                                           String absoluteDataModelName)

javaClassToDataModel

@NotNull
public static String javaClassToDataModel(@NotNull
                                                  Class<?> cl)


Created 2009-10-09 16:43 EST