use of io.fixprotocol._2020.orchestra.repository.Messages in project fix-orchestra by FIXTradingCommunity.
the class DocGenerator method generate.
/**
* Generates documentation
*
* @throws Exception if input cannot be read or output cannot be written to a file
*/
public void generate() throws Exception {
this.repository = unmarshal(inputStream);
// Implementation note: consideration was given to supporting "jar:file:" scheme, but the
// supporting FileSystem is not guaranteed to be installed.
pathManager = getPathManager(outputRootDir);
final Path baseOutputPath = pathManager.makeRootPath(outputRootDir);
createCss(baseOutputPath);
generateMain(baseOutputPath, getTitle());
generateMetadata(baseOutputPath, repository, repository.getMetadata().getAny());
final Path datatypesOutputPath = pathManager.makeDirectory(baseOutputPath.resolve("datatypes"));
generateDatatypeList(datatypesOutputPath, repository.getDatatypes().getDatatype());
repository.getDatatypes().getDatatype().forEach(d -> {
try {
generateDatatype(datatypesOutputPath, d);
} catch (final Exception e) {
throw new RuntimeException(e);
}
});
final Path fieldsOutputPath = pathManager.makeDirectory(baseOutputPath.resolve("fields"));
final List<FieldType> sortedFieldList = repository.getFields().getField().stream().sorted(Comparator.comparing(FieldType::getName)).collect(Collectors.toList());
generateFieldsList(fieldsOutputPath, sortedFieldList);
repository.getFields().getField().forEach(f -> {
try {
generateFieldDetail(fieldsOutputPath, f);
} catch (final Exception e) {
throw new RuntimeException(e);
}
});
final List<CodeSetType> allCodeSets = repository.getCodeSets().getCodeSet();
generateCodeSetList(datatypesOutputPath, allCodeSets.stream().sorted(Comparator.comparing(CodeSetType::getName)).collect(Collectors.toList()));
repository.getCodeSets().getCodeSet().forEach(cs -> {
try {
generateCodeSetDetail(datatypesOutputPath, cs);
} catch (final Exception e) {
throw new RuntimeException(e);
}
});
final Path messagesDocPath = pathManager.makeDirectory(baseOutputPath.resolve("messages"));
final Path messagesImgPath = pathManager.makeDirectory(messagesDocPath.resolve("img"));
final Optional<Categories> optCategories = Optional.ofNullable(repository.getCategories());
final List<CategoryType> sortedCategoryList = optCategories.orElse(new Categories()).getCategory().stream().filter(c -> c.getComponentType() == CatComponentTypeT.MESSAGE).sorted((o1, o2) -> {
final String sectionValue1 = o1.getSection() != null ? o1.getSection() : "";
final String sectionValue2 = o2.getSection() != null ? o2.getSection() : "";
int retv = sectionValue1.compareTo(sectionValue2);
if (retv == 0) {
retv = o1.getName().compareTo(o2.getName());
}
return retv;
}).collect(Collectors.toList());
generateCategories(messagesDocPath, "Message Categories", sortedCategoryList);
final List<MessageType> sortedMessageList = repository.getMessages().getMessage().stream().sorted(Comparator.comparing(MessageType::getName).thenComparing(MessageType::getScenario)).collect(Collectors.toList());
final Optional<Actors> actors = Optional.ofNullable(repository.getActors());
final List<ActorType> actorList = actors.orElse(new Actors()).getActorOrFlow().stream().filter(af -> af instanceof ActorType).map(af -> (ActorType) af).collect(Collectors.toList());
generateActorsList(messagesDocPath, actorList);
actorList.forEach(a -> {
try {
generateActorDetail(messagesDocPath, messagesImgPath, a);
} catch (final Exception e) {
throw new RuntimeException(e);
}
});
final List<FlowType> flowList = actors.orElse(new Actors()).getActorOrFlow().stream().filter(af -> af instanceof FlowType).map(af -> (FlowType) af).collect(Collectors.toList());
generateFlowsList(messagesDocPath, flowList);
flowList.forEach(f -> {
try {
generateFlowDetail(messagesDocPath, f);
generateMessageListByFlow(messagesDocPath, f, sortedMessageList);
} catch (final Exception e) {
throw new RuntimeException(e);
}
});
generateAllMessageList(messagesDocPath, sortedMessageList);
sortedCategoryList.forEach(c -> {
try {
generateMessageListByCategory(messagesDocPath, c, sortedMessageList);
} catch (final Exception e) {
throw new RuntimeException(e);
}
});
final List<ComponentType> componentList = repository.getComponents().getComponent();
final List<ComponentType> sortedComponentList = componentList.stream().sorted(Comparator.comparing(ComponentType::getName).thenComparing(ComponentType::getScenario)).collect(Collectors.toList());
generateAllComponentsList(messagesDocPath, sortedComponentList);
componentList.forEach(c -> {
try {
generateComponentDetail(messagesDocPath, c);
} catch (final Exception e) {
throw new RuntimeException(e);
}
});
final List<GroupType> groupList = repository.getGroups().getGroup();
final List<GroupType> sortedGroupList = groupList.stream().sorted(Comparator.comparing(GroupType::getName).thenComparing(GroupType::getScenario)).collect(Collectors.toList());
generateAllGroupsList(messagesDocPath, sortedGroupList);
groupList.forEach(c -> {
try {
generateGroupDetail(messagesDocPath, c);
} catch (final Exception e) {
throw new RuntimeException(e);
}
});
repository.getMessages().getMessage().forEach(m -> {
try {
generateMessageDetail(messagesDocPath, messagesImgPath, m);
} catch (final Exception e) {
throw new RuntimeException(e);
}
});
pathManager.close();
}
use of io.fixprotocol._2020.orchestra.repository.Messages in project fix-orchestra by FIXTradingCommunity.
the class DocGenerator method generateMessageListByFlow.
private void generateMessageListByFlow(final Path messagesDocPath, final FlowType flow, final List<MessageType> messageList) throws Exception {
final ST st = stGroup.getInstanceOf("messages");
final List<MessageType> filteredMessageList = messageList.stream().filter(m -> flow.getName().equals(m.getFlow())).collect(Collectors.toList());
st.add("messages", filteredMessageList);
st.add("title", String.format("%s Messages", flow.getName()));
final Path path = messagesDocPath.resolve(String.format("%sMessages.html", flow.getName()));
try (final STWriterWrapper writer = getWriter(path)) {
st.write(writer, templateErrorListener);
}
}
use of io.fixprotocol._2020.orchestra.repository.Messages in project fix-orchestra by FIXTradingCommunity.
the class RepositoryCompressor method compress.
private boolean compress(InputStream is, OutputStream os, Predicate<? super MessageType> messagePredicate) {
try {
final Repository inRepository = unmarshal(is);
final Categories categories = inRepository.getCategories();
isCategoryInSection.setCategories(categories.getCategory());
final Repository outRepository = new Repository();
inRepository.copyTo(null, outRepository, AttributeCopyStrategy.INSTANCE);
final ElementOrRefinementContainer metadata = (ElementOrRefinementContainer) inRepository.getMetadata().clone();
final List<JAXBElement<SimpleLiteral>> literals = metadata.getAny();
final ObjectFactory objectFactory = new ObjectFactory();
final SimpleLiteral contributor = new SimpleLiteral();
contributor.getContent().add("RepositoryCompressor");
literals.add(objectFactory.createContributor(contributor));
outRepository.setMetadata(metadata);
if (categories != null) {
outRepository.setCategories((Categories) categories.clone());
}
final Sections sections = inRepository.getSections();
if (sections != null) {
outRepository.setSections((Sections) sections.clone());
}
final Datatypes datatypes = inRepository.getDatatypes();
if (datatypes != null) {
outRepository.setDatatypes((Datatypes) datatypes.clone());
}
final Actors actors = inRepository.getActors();
if (actors != null) {
outRepository.setActors((Actors) actors.clone());
}
final Components components = inRepository.getComponents();
if (components != null) {
final Components inComponents = (Components) components.clone();
componentList = inComponents.getComponent();
}
final Groups groups = inRepository.getGroups();
if (groups != null) {
final Groups inGroups = (Groups) groups.clone();
groupList = inGroups.getGroup();
}
final Messages messages = inRepository.getMessages();
final List<MessageType> messageList;
if (messages != null) {
final Messages inMessages = (Messages) messages.clone();
messageList = inMessages.getMessage();
} else {
messageList = Collections.emptyList();
}
final List<MessageType> filteredMessages = messageList.stream().filter(messagePredicate).collect(Collectors.toList());
filteredMessages.forEach(m -> walk(m.getStructure().getComponentRefOrGroupRefOrFieldRef()));
final List<BigInteger> distinctFieldIds = fieldIdList.stream().distinct().collect(Collectors.toList());
final Fields inFields = (Fields) inRepository.getFields().clone();
final List<FieldType> fieldsWithFlow = inFields.getField().stream().filter(f -> distinctFieldIds.contains(f.getId())).collect(Collectors.toList());
final Fields outFields = new Fields();
outFields.getField().addAll(fieldsWithFlow);
outRepository.setFields(outFields);
final List<String> typeList = fieldsWithFlow.stream().map(FieldType::getType).distinct().collect(Collectors.toList());
final CodeSets inCodeSets = (CodeSets) inRepository.getCodeSets().clone();
final List<CodeSetType> codeSetsWithFlow = inCodeSets.getCodeSet().stream().filter(cs -> typeList.contains(cs.getName())).collect(Collectors.toList());
final CodeSets outCodeSets = new CodeSets();
outCodeSets.getCodeSet().addAll(codeSetsWithFlow);
outRepository.setCodeSets(outCodeSets);
final List<BigInteger> distinctComponentsIds = componentIdList.stream().distinct().collect(Collectors.toList());
final List<ComponentType> componentsWithFlow = componentList.stream().filter(c -> distinctComponentsIds.contains(c.getId())).collect(Collectors.toList());
final Components outComponents = new Components();
outComponents.getComponent().addAll(componentsWithFlow);
outRepository.setComponents(outComponents);
final List<BigInteger> distinctGroupIds = groupIdList.stream().distinct().collect(Collectors.toList());
final List<GroupType> groupWithFlow = groupList.stream().filter(c -> distinctGroupIds.contains(c.getId())).collect(Collectors.toList());
final Groups outGroups = new Groups();
outGroups.getGroup().addAll(groupWithFlow);
outRepository.setGroups(outGroups);
final Messages outMessages = new Messages();
outMessages.getMessage().addAll(filteredMessages);
outRepository.setMessages(outMessages);
marshal(outRepository, os);
return true;
} catch (JAXBException e) {
logger.fatal("RepositoryCompressor failed", e);
return false;
}
}
use of io.fixprotocol._2020.orchestra.repository.Messages in project fix-orchestra by FIXTradingCommunity.
the class DocGenerator method generateMessageListByCategory.
private void generateMessageListByCategory(final Path messagesDocPath, final CategoryType category, final List<MessageType> messageList) throws Exception {
final ST st = stGroup.getInstanceOf("messages");
final List<MessageType> filteredMessageList = messageList.stream().filter(m -> category.getName().equals(m.getCategory())).collect(Collectors.toList());
st.add("messages", filteredMessageList);
st.add("title", String.format("%s Messages", category.getName()));
final Path path = messagesDocPath.resolve(String.format("%sMessages.html", category.getName()));
try (final STWriterWrapper writer = getWriter(path)) {
st.write(writer, templateErrorListener);
}
}
Aggregations