on 02-10-2011 11:08 AM
Hi ,
Request you to give me sample code to call MDM Validations using MDM Java Api's.
Thanks,
Vaishali.
like this:
(just make some corrections for good compiation, because it was extracted from bigger code)
public ValidationPropertiesResult retrieveValidations(TableId tableId) throws CommandException, ConnectionException {
RetrieveValidationsCommand cmd = new RetrieveValidationsCommand(getUserSessionContext());
cmd.setTableId(tableId);
cmd.execute();
return cmd.getValidationPropertiesResult();
}
your function here to get array of Validation from ValidationPropertiesResult:
ValidationProperties[] validations = _validationPropertiesResult.getValidations();
public ArrayList validate(Validation[] validations) throws Exception {
ArrayList validationResultSet = new ArrayList();
if (validations != null && validations.length > 0) {
MdmWrapper wrapper = getMdmWrapper();
RepositorySchema schema = wrapper.getRepositorySchema();
TableId tableId = schema.getTableId(getTableCode());
ValidationId[] validationIds = new ValidationId[validations.length];
for(int i = 0; i < validations.length; i++) {
validationIds<i> = new ValidationId(validations<i>.getId());
}
com.sap.mdm.validation.ValidationResult result = wrapper.validateRecord(tableId, _modificationRecord.getId(), validationIds);
ValidationProperties[] failedValidations = result.getFailedValidations(new RecordId(getRecordId()));
ArrayList failedValidationsIds = new ArrayList();
if (failedValidations != null) {
for(int i = 0; i < failedValidations.length; i++) {
failedValidationsIds.add(failedValidations<i>.getId());
}
}
for(int i = 0; i < validations.length; i++) {
boolean success = !failedValidationsIds.contains(new ValidationId(validations<i>.getId()));
ValidationResult validationResult = new ValidationResult(getRecordId(), validations<i>, success);
validationResultSet.add(validationResult);
}
}
return validationResultSet;
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
83 | |
24 | |
12 | |
9 | |
7 | |
6 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.