private BlockingSettingsWeb convertToClientModel(BlockingSettings blockingSettings) { BlockingSettingsWeb blockingSettingsWeb = new BlockingSettingsWeb(); blockingSettingsWeb.setNumberOfRecordsToSample(blockingSettings.getNumberOfRecordsToSample()); List<BlockingRound> rounds = blockingSettings.getBlockingRounds(); List<BlockingFieldBaseWeb> fields = new java.util.ArrayList<BlockingFieldBaseWeb>(rounds.size()); int blockingRoundIndex = 1; for (BlockingRound blockingRound : rounds) { int blockingFieldIndex = 1; for (org.openhie.openempi.configuration.BaseFieldPair baseFieldPair : blockingRound.getFields()) { BlockingFieldBaseWeb clientField = new BlockingFieldBaseWeb( blockingRoundIndex, blockingFieldIndex, baseFieldPair.getLeftFieldName(), baseFieldPair.getRightFieldName()); fields.add(clientField); blockingFieldIndex++; } blockingRoundIndex++; } blockingSettingsWeb.setBlockingFields(fields); return blockingSettingsWeb; }
private BlockingSettings convertFromClientModel(BlockingSettingsWeb blockingConfiguration) { BlockingSettings blockingSettings = new BlockingSettings(); blockingSettings.setNumberOfRecordsToSample(blockingConfiguration.getNumberOfRecordsToSample()); int roundsCount = 0; for (BlockingFieldBaseWeb baseField : blockingConfiguration.getBlockingFields()) { if (baseField.getBlockingRound() > roundsCount) { roundsCount = baseField.getBlockingRound(); } } List<BlockingRound> rounds = new java.util.ArrayList<BlockingRound>(roundsCount); for (int currRound = 1; currRound <= roundsCount; currRound++) { BlockingRound round = new BlockingRound(); for (BlockingFieldBaseWeb baseField : blockingConfiguration.getBlockingFields()) { if (baseField.getBlockingRound() == currRound) { round.addField(baseField.getLeftFieldName(), baseField.getRightFieldName()); } } rounds.add(round); } blockingSettings.setBlockingRounds(rounds); return blockingSettings; }