Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reporting to images #61

Open
wants to merge 21 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
daaec55
#19 create report service
ThetaSinner Oct 25, 2018
a4bd706
#19 Create report module and define data model
ThetaSinner Oct 26, 2018
0e41d77
#19 create initial helper for rendering diagrams using java2d
ThetaSinner Oct 27, 2018
abc7fd3
#19 Demonstrate how to draw an arrow between two images
ThetaSinner Oct 27, 2018
2d5a2d2
#19 display text
ThetaSinner Oct 27, 2018
cc4e857
#19 Build the report model graph in the report service
ThetaSinner Oct 27, 2018
2836ca7
#19 building report from graph
ThetaSinner Oct 27, 2018
89e70d7
#19 start working on the layout process
ThetaSinner Oct 28, 2018
7797d6f
#19 calculate tile positions
ThetaSinner Oct 29, 2018
548989c
#19 Give the report service access to the graphical asset service
ThetaSinner Oct 30, 2018
f01f3f8
#19 fix detekt issues and add docs
ThetaSinner Oct 30, 2018
5ab3d48
#19 Draw images onto the report
ThetaSinner Nov 10, 2018
eaea754
#19 Create default images for software specializations
ThetaSinner Nov 11, 2018
37e0e29
#19 create application and system graphics and bootstrap command
ThetaSinner Nov 11, 2018
5b3efe9
#19 Bug fix for depth counts and export after report run
ThetaSinner Nov 11, 2018
0e79762
#19 Fixes for positioning
ThetaSinner Nov 11, 2018
d4839ea
#19 Start on card builder for rendering images with text
ThetaSinner Nov 12, 2018
8453b26
#19 draw images and text from the card builder
ThetaSinner Nov 12, 2018
02632c7
#19 Add missing doc comments for classes in the render package
ThetaSinner Nov 13, 2018
9b1fa61
#19 Improve layout for columns in rendering
ThetaSinner Nov 13, 2018
3406096
#19 Fixing detect issues
ThetaSinner Nov 14, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ spring-shell.log
.idea/*
*.log

user/staging
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,15 @@ class GraphicalAssetPersistence {
fun findAll(): MutableIterable<GraphicalAssetEntity> {
return repo.findAll()
}

/**
* Find a graphical asset by name
*
* @param name The name of the asset
* @return the asset, if found
*/
fun find(name: String): GraphicalAssetEntity? {
val asset = repo.findByName(name)
return if (asset.isPresent) asset.get() else null
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,17 @@ package org.ephyra.acropolis.persistence.impl

import org.ephyra.acropolis.persistence.api.entity.GraphicalAssetEntity
import org.springframework.data.repository.CrudRepository
import java.util.Optional

/**
* Repository for storing graphical assets
*/
interface GraphicalAssetRepository : CrudRepository<GraphicalAssetEntity, Long>
interface GraphicalAssetRepository : CrudRepository<GraphicalAssetEntity, Long> {
/**
* Find a graphical asset by name
*
* @param name The name of the asset
* @return the asset, if found
*/
fun findByName(name: String): Optional<GraphicalAssetEntity>
}
69 changes: 69 additions & 0 deletions acropolis-report/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
buildscript {
ext {
kotlinVersion = "1.2.71"
}
repositories {
jcenter()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
classpath "org.jetbrains.kotlin:kotlin-allopen:$kotlinVersion"
}
}

apply plugin: 'kotlin'
apply plugin: 'jacoco'

sourceCompatibility = 1.8
compileKotlin {
kotlinOptions {
freeCompilerArgs = ["-Xjsr305=strict"]
jvmTarget = "1.8"
}
}

jacoco {
toolVersion = '0.8.2'
}

jacocoTestReport {
reports {
xml.enabled = true
html.enabled = true
csv.enabled = false
}
}

jacocoTestCoverageVerification {
violationRules {
rule {
limit {
minimum = 0.9
}
}
}
}

test {
useJUnitPlatform()
}

dependencies {
// The Kotlin standard library
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8"

// https://mvnrepository.com/artifact/org.slf4j/slf4j-api
compile group: 'org.slf4j', name: 'slf4j-api', version: '1.7.25'

// https://mvnrepository.com/artifact/org.springframework/spring-context
compile group: 'org.springframework', name: 'spring-context', version: '5.1.1.RELEASE'

// https://mvnrepository.com/artifact/ch.qos.logback/logback-classic
testCompile group: 'ch.qos.logback', name: 'logback-classic', version: '1.2.3'

// https://mvnrepository.com/artifact/io.kotlintest/kotlintest-runner-junit5
testCompile "io.kotlintest:kotlintest-runner-junit5:3.1.9"

// https://mvnrepository.com/artifact/io.mockk/mockk
testCompile "io.mockk:mockk:1.8.7"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package org.ephyra.acropolis.report.api

import java.io.InputStream

/**
* Image source to provide images on request to the rendering process.
*/
interface IImageSource {
/**
* Get an image by its resource name
*
* @param resourceName The resource name of the image
* @return An input stream for the image data to be read from
*/
fun get(resourceName: String): InputStream
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package org.ephyra.acropolis.report.api

import org.ephyra.acropolis.report.api.model.GraphContainer

/**
* Interface for a report runner. This interface provides the entry point into this module.
*/
interface IReportRunner {
/**
* Run a report based on the provided model
*
* @param graphContainer The container for the model to build the report from
* @param imageSource Source to allow images to be provided during the rendering process
*/
fun run(graphContainer: GraphContainer, imageSource: IImageSource)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
package org.ephyra.acropolis.report.api.model

/**
* Container for a graph model.
* Allows metadata to be provided with the model.
*/
class GraphContainer(
val graph: Graph
) {
private val subGraphs: MutableList<SubGraphSelector> = ArrayList()

/**
* Define a named sub-graph of the graph held by this container.
* The provided list of nodes can later be used to extract a sub-graph.
*
* @param name The name of the sub-graph
* @param includeNodes The nodes to include in the sub-graph
*/
fun defineSubgraph(name: String, includeNodes: List<Node>) {
subGraphs.add(SubGraphSelector(name, includeNodes))
}
}

/**
* Model to represent a graph, in the mathematical sense.
*/
class Graph {
private val nodes: MutableSet<Node> = HashSet()

private val edges: MutableList<Edge> = ArrayList()

/**
* Add a node to the graph
*
* @param node The node to add
*/
fun addNode(node: Node) {
nodes.add(node)
}

/**
* Add an edge between two nodes
*
* @param n1 Node to connect
* @param n2 Node to connect
*/
fun addEdge(n1: Node, n2: Node) {
edges.add(Edge(n1, n2, false))
}

/**
* Add a directed edge between two nodes
*
* @param from The source node for the edge
* @param to The sink node for the edge
*/
fun addDirectedEdge(from: Node, to: Node) {
edges.add(Edge(from, to, true))
}

/**
* Find a node by its label
*
* @param label The label to search for
* @return The node, if found
*/
fun findNode(label: String): Node? {
return nodes.find { node -> node.label == label }
}

/**
* Find nodes, N, such that all edges which connect N to the graph, N is the source.
*
* Only valid for di-graphs, otherwise must allow edges if incoming edges have a corresponding outgoing edge.
*/
fun findSourceNodes(): HashSet<Node> {
val tempNodes = HashSet<Node>()
tempNodes.addAll(nodes)

edges.forEach { edge ->
val node = edge.sink
tempNodes.remove(node)
}

return tempNodes
}

/**
* Return which ever node happens to be first.
*
* @return The first node in the graph, as it is stored
*/
fun firstNode(): Node {
return nodes.first()
}

/**
* Finds edges such that the specified node is the source, and collects the set of sink nodes
* from these edges.
*/
fun findNodesConnectedFrom(node: Node): HashSet<Node> {
val tempNodes = HashSet<Node>()
edges.forEach { edge ->
if (edge.source == node) {
tempNodes.add(edge.sink)
}
}

return tempNodes
}
}

/**
* Model to represent a node in a graph
*/
class Node(
val label: String,

val representedByResourceName: String
)

/**
* Model to represent an edge in a graph
*/
class Edge(
val source: Node,

val sink: Node,

val directed: Boolean = false
)

/**
* Selector for building a sub-graph from a subset of a graph's nodes.
*/
class SubGraphSelector (
val name: String,

val includeNodes: List<Node>
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package org.ephyra.acropolis.report.config

import org.springframework.context.annotation.ComponentScan
import org.springframework.context.annotation.Configuration

/**
* Configuration root for the module. By directing the Spring framework to load this class as configuration
* the entire module will be configured for use.
*/
@Configuration
@ComponentScan(basePackages = ["org.ephyra.acropolis.report.config", "org.ephyra.acropolis.report.impl"])
open class ReportConfiguration
Loading