cancel
Showing results for 
Search instead for 
Did you mean: 

MDM4J JAVA API validations

Former Member
0 Kudos

Hello All,

Can ayone post a litle code how to do Validations with this old one JAVA API

Thanks in advance,

Andre

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos
Former Member
0 Kudos

Andre, Here's a snippet of code - not plug'n play and without much context, but you'll hopefully get the gist of the solution. My private method getValidationsIDs() merely examines the standard MDM Validations table, and pulls out the IDs for all validations associated with the table being validated

int[] m_tableValidationIds;

CMTableInfo m_validationTableProperties;

ValidateRecordsCommand m_validateRecordsCommand;

m_validateRecordsCommand = m_catalogData.CreateValidateRecordsCommand();

m_validateRecordsCommand.SetTable(yourTableName);

// find the validation table and identify validations for this table

m_validationTableProperties = getValidationTable();

m_tableValidationIds = getValidationsIDs(yourTableID);

// records to validate

m_validateRecordsCommand.SetRecordIDs(recordIds);

// validations to use for the records selected above

m_validateRecordsCommand.SetValidationIDs(m_tableValidationIds);

// validate

int returnCode = m_validateRecordsCommand.Execute();

// retrieve failures

ValidationFailures failures = m_validateRecordsCommand.GetValidationFailures();

// Have any validations failed? Retrieve details.

if (failures.GetTotalValidationsFailed() > 0)

{

int[] failedValidationIds = failures.GetValidationIDs();

Set mappings = getValidationDetails(failedValidationIds).entrySet();

String validationErrorDetails = "Validation Failures: ";

for (Iterator i = mappings.iterator(); i.hasNext();)

{

Map.Entry me = (Map.Entry) i.next();

Object oKey = me.getKey();

Object oValue = me.getValue();

validationErrorDetails = validationErrorDetails + "\n " + oValue.toString();

}

throw new UpdateFailedException(validationErrorDetails);

}