Skip to content
This repository has been archived by the owner on Apr 14, 2023. It is now read-only.

Commit

Permalink
Merge pull request #1267 from finos/fix-isins-master-merge-3
Browse files Browse the repository at this point in the history
Fix ISINs
  • Loading branch information
pdaulbyscottlogic authored Sep 2, 2019
2 parents a3a0cc0 + c01ef5a commit 4396398
Show file tree
Hide file tree
Showing 34 changed files with 1,067 additions and 1,055 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,19 @@
package com.scottlogic.deg.common.profile.constraints.atomic;

public enum StandardConstraintTypes{
SEDOL,
ISIN,
CUSIP,
RIC
SEDOL("[B-DF-HJ-NP-TV-Z0-9]{6}[0-9]"),
ISIN("[A-Z]{2}[A-Z0-9]{10}"),
CUSIP("[0-9]{3}[0-9A-Z]{5}[0-9]"),
RIC("[A-Z]{1,4}\\.[A-Z]{1,2}");

private final String regex;

StandardConstraintTypes(String regex) {

this.regex = regex;
}

public String getRegex() {
return regex;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@
import java.util.List;
import java.util.regex.Pattern;

import static com.scottlogic.deg.common.profile.constraints.atomic.StandardConstraintTypes.RIC;

public class FieldSpecFactory {
public static final String RIC_REGEX = "[A-Z]{1,4}\\.[A-Z]{1,2}";
private final StringRestrictionsFactory stringRestrictionsFactory;

@Inject
Expand Down Expand Up @@ -256,12 +257,16 @@ private FieldSpec construct(ContainsRegexConstraint constraint, boolean negate)
}

private FieldSpec construct(MatchesStandardConstraint constraint, boolean negate) {
if (constraint.standard.equals(StandardConstraintTypes.RIC)) {
return construct(new MatchesRegexConstraint(constraint.field, Pattern.compile(RIC_REGEX)), negate);
if (constraint.standard.equals(RIC)) {
return construct(new MatchesRegexConstraint(constraint.field, Pattern.compile(RIC.getRegex())), negate);
}

if (negate){
return construct(new MatchesRegexConstraint(constraint.field, Pattern.compile(constraint.standard.getRegex())), negate);
}

return FieldSpec.Empty
.withStringRestrictions(new MatchesStandardStringRestrictions(constraint.standard, negate));
.withStringRestrictions(new MatchesStandardStringRestrictions(constraint.standard));
}

private FieldSpec construct(FormatConstraint constraint, boolean negate) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
import com.scottlogic.deg.generator.generation.fieldvaluesources.FieldValueSource;
import com.scottlogic.deg.generator.generation.fieldvaluesources.RealNumberFieldValueSource;
import com.scottlogic.deg.generator.generation.fieldvaluesources.datetime.DateTimeFieldValueSource;
import com.scottlogic.deg.generator.generation.string.RegexStringGenerator;
import com.scottlogic.deg.generator.generation.string.StringGenerator;
import com.scottlogic.deg.generator.generation.string.generators.RegexStringGenerator;
import com.scottlogic.deg.generator.generation.string.generators.StringGenerator;
import com.scottlogic.deg.generator.restrictions.*;

import java.util.*;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ public DecisionTree runUpfrontPrune(DecisionTree tree, DataGeneratorMonitor moni
monitor.addLineToPrintAtEndOfGeneration("The provided profile is wholly contradictory!");
monitor.addLineToPrintAtEndOfGeneration("No data can be generated!");
return new DecisionTree(null, tree.getFields());

} else if (isPartiallyContradictory(markedTree.getRootNode())) {
monitor.addLineToPrintAtEndOfGeneration("");
monitor.addLineToPrintAtEndOfGeneration("The provided profile is partially contradictory!");
Expand Down

This file was deleted.

This file was deleted.

Loading

0 comments on commit 4396398

Please sign in to comment.