The next step that is required to register a new algorithm is to provide the implementation for the algorithm. This implementation must implement the SamplingStrategy Interface. The SamplingStrategy Interface has one method getRandomSample. This method takes a list of case identifiers and applies a sampling strategy to the list to generate a random case sample for audit. It accepts three parameters:
The SamplingStrategy Interface can be found in the package curam.samplingstrategy.impl
/*
* Copyright 2011 Curam Software Ltd.
* All rights reserved.
*
* This software is the confidential and
* proprietary information of Curam Software, Ltd.
* ("Confidential Information"). You shall not
* disclose such Confidential Information and shall
* use it only in accordance with the terms of the
* license agreement you entered into with Curam Software.
*/
package curam.samplingstrategy.impl;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import curam.util.exception.AppException;
import curam.util.exception.InformationalException;
public class EveryNthCase implements SamplingStrategy {
public List<Long> getRandomSample(List<Long> masterList,
int sampleSize, Map<String, Object> properties)
throws AppException, InformationalException {
List<Long> randomSampleList = new ArrayList<Long>();
Integer n = (Integer) properties.get("n");
int index = 0;
if (n <= masterList.size()) {
while (randomSampleList.size() < sampleSize) {
if (index + n < masterList.size()) {
index = index + n;
// If the element has been returned already,
// try the next element until one that hasn't
// been returned is found
while (randomSampleList.contains(
masterList.get(index))) {
if (index < masterList.size() - 1) {
index++;
} else {
index = 0;
}
}
randomSampleList.add(masterList.get(index));
} else {
// Run out of elements, loop back to the
// start of the list
int elementsToStartOfList = masterList.size() - index;
index = n - elementsToStartOfList;
// If the element has been returned already,
// try the next element until one that hasn't
// been returned is found
while (randomSampleList.contains(
masterList.get(index))) {
if (index < masterList.size() - 1) {
index++;
} else {
index = 0;
}
}
randomSampleList.add(masterList.get(index));
}
}
}
return randomSampleList;
}
}