Skip to content

Commit

Permalink
[md2orchestra] invalid treatment of supported attribute #63
Browse files Browse the repository at this point in the history
  • Loading branch information
donmendelson committed Feb 2, 2022
1 parent 96567e5 commit d286ffd
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 7 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# tablature

![Java CI with Maven](https://github.com/FIXTradingCommunity/tablature/workflows/maven.yml/badge.svg)
![Java CI with Maven](https://github.com/FIXTradingCommunity/tablature/workflows/Java%20CI%20with%20Maven/badge.svg)

Converts a Markdown document to a specification and documents a specification as markdown. Markdown can automatically be rendered as a web page in GitHub or other sites. This is an easy way to publish rules of engagement. Roundtrip is supported, allowing a user to update a specification iteratively with an ordinary text editor.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import java.util.EnumSet;
import java.util.List;
import java.util.Objects;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Consumer;
import javax.xml.bind.JAXBException;
import org.apache.commons.cli.CommandLine;
Expand Down Expand Up @@ -355,6 +356,7 @@ private void processFiles(final List<String> inputFilePatterns,
glob);

final PathMatcher matcher = fileSystem.getPathMatcher("glob:" + glob);
final AtomicInteger filesMatched = new AtomicInteger();
Files.walkFileTree(dirPath, EnumSet.of(FileVisitOption.FOLLOW_LINKS), Integer.MAX_VALUE,
new FileVisitor<Path>() {

Expand All @@ -375,6 +377,7 @@ public FileVisitResult visitFile(final Path filePath, final BasicFileAttributes
throws IOException {

if (matcher.matches(filePath)) {
filesMatched.incrementAndGet();
fileConsumer.accept(filePath);
}
return FileVisitResult.CONTINUE;
Expand All @@ -389,6 +392,7 @@ public FileVisitResult visitFileFailed(final Path file, final IOException exc)
}

});
logger.info("Md2Orchestra matched {} file(s)", filesMatched.get());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
import io.fixprotocol._2020.orchestra.repository.SectionType;
import io.fixprotocol._2020.orchestra.repository.StateMachineType;
import io.fixprotocol._2020.orchestra.repository.StateType;
import io.fixprotocol._2020.orchestra.repository.SupportType;
import io.fixprotocol._2020.orchestra.repository.TransitionType;
import io.fixprotocol._2020.orchestra.repository.UnionDataTypeT;
import io.fixprotocol.md.event.Context;
Expand Down Expand Up @@ -1111,6 +1112,15 @@ private void addCode(final DetailTable.TableRow detail, final List<? super CodeT
case "updatedep":
codeType.setUpdatedEP(new BigInteger(p.getValue()));
break;
case "supported":
try {
SupportType supportType = SupportType.fromValue(p.getValue().toLowerCase());
codeType.setSupported(supportType );
} catch (IllegalArgumentException e) {
eventLogger.error("Invalid value for Support attribute {0} of code {1}",
p.getValue(), name);
}
break;
default:
Annotation annotation = codeType.getAnnotation();
if (annotation == null) {
Expand Down Expand Up @@ -1500,6 +1510,15 @@ private void addField(final GraphContext graphContext, final Context keyContext)
case "updatedep":
field.setUpdatedEP(new BigInteger(p.getValue()));
break;
case "supported":
try {
SupportType supportType = SupportType.fromValue(p.getValue().toLowerCase());
field.setSupported(supportType );
} catch (IllegalArgumentException e) {
eventLogger.error("Invalid value for Support attribute {0} at line {1} char {2}",
p.getValue(), detail.getLine(), detail.getCharPositionInLine());
}
break;
default:
if (isDocumentationKey(p.getKey())) {
repositoryAdapter.addDocumentationAsMarkdown(p.getValue(), paragraphDelimiterInTables,
Expand Down Expand Up @@ -2002,6 +2021,15 @@ private ComponentRefType populateComponentRef(final DetailTable.TableRow detail)
case "updatedep":
componentRefType.setUpdatedEP(new BigInteger(p.getValue()));
break;
case "supported":
try {
SupportType supportType = SupportType.fromValue(p.getValue().toLowerCase());
componentRefType.setSupported(supportType );
} catch (IllegalArgumentException e) {
eventLogger.error("Invalid value for Support attribute {0} at line {1} char {2}",
p.getValue(), detail.getLine(), detail.getCharPositionInLine());
}
break;
default:
Annotation annotation = componentRefType.getAnnotation();
if (annotation == null) {
Expand Down Expand Up @@ -2144,6 +2172,15 @@ private FieldRefType populateFieldRef(final DetailTable.TableRow detail) {
case "updatedep":
fieldRefType.setUpdatedEP(new BigInteger(p.getValue()));
break;
case "supported":
try {
SupportType supportType = SupportType.fromValue(p.getValue().toLowerCase());
fieldRefType.setSupported(supportType );
} catch (IllegalArgumentException e) {
eventLogger.error("Invalid value for Support attribute {0} at line {1} char {2}",
p.getValue(), detail.getLine(), detail.getCharPositionInLine());
}
break;
default:
Annotation annotation = fieldRefType.getAnnotation();
if (annotation == null) {
Expand Down Expand Up @@ -2251,7 +2288,7 @@ private FieldRefType populateFieldRef(final DetailTable.TableRow detail) {
return fieldRefType;
}

private GroupRefType populateGroupRef(final DetailProperties detail) {
private GroupRefType populateGroupRef(final DetailTable.TableRow detail) {
final GroupRefType groupRefType = new GroupRefType();

String name = null;
Expand Down Expand Up @@ -2303,6 +2340,15 @@ private GroupRefType populateGroupRef(final DetailProperties detail) {
case "updatedep":
groupRefType.setUpdatedEP(new BigInteger(p.getValue()));
break;
case "supported":
try {
SupportType supportType = SupportType.fromValue(p.getValue().toLowerCase());
groupRefType.setSupported(supportType );
} catch (IllegalArgumentException e) {
eventLogger.error("Invalid value for Support attribute {0} at line {1} char {2}",
p.getValue(), detail.getLine(), detail.getCharPositionInLine());
}
break;
default:
Annotation annotation = groupRefType.getAnnotation();
if (annotation == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,11 @@ void codesetType() throws Exception {
+ "\n"
+ "## Codeset PartyRoleQualifierCodeSet type int scenario Test\n"
+ "\n"
+ "| Name | Value |\n"
+ "|------------------|-------|\n"
+ "| Algorithm | 22 |\n"
+ "| FirmOrLegalEntity| 23 |\n"
+ "| NaturalPerson | 24 |";
+ "| Name | Value | Supported |\n"
+ "|------------------|-------|-----------|\n"
+ "| Algorithm | 22 | Supported |\n"
+ "| FirmOrLegalEntity| 23 | Forbidden |\n"
+ "| NaturalPerson | 24 | Ignored |\n";
InputStream inputStream = new ByteArrayInputStream(text.getBytes());
InputStream referenceStream = new FileInputStream("src/test/resources/OrchestraFIXLatest.xml");
RepositoryBuilder builder = RepositoryBuilder.instance(referenceStream , jsonOutputStream);
Expand Down

0 comments on commit d286ffd

Please sign in to comment.