Skip to content
This repository has been archived by the owner on Mar 12, 2020. It is now read-only.

Commit

Permalink
Refactor #19
Browse files Browse the repository at this point in the history
  • Loading branch information
tdauth committed Mar 27, 2019
1 parent 038ac13 commit e5d1e85
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@ package de.retest.guistatemachine.api.neo4j
import de.retest.surili.commons.actions.{Action, NavigateRefreshAction}
import org.neo4j.ogm.typeconversion.AttributeConverter

/*
* https://github.com/neo4j/neo4j-ogm/blob/master/neo4j-ogm-docs/src/main/asciidoc/reference/conversion.adoc
*/
class ActionConverter extends AttributeConverter[Action, String] {
def toGraphProperty(value: Action): String = value.toString // TODO #19 convert to XML with element
def toEntityAttribute(value: String): Action = new NavigateRefreshAction // TODO #19 convert from XML to an action
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ case class StateNeo4J(sutState: SutState, guiStateMachine: GuiStateMachineNeo4J)
}

private[api] override def addTransition(a: Action, to: State): Int = Neo4jSessionFactory.transaction {
val filter = new Filter("start", ComparisonOperator.EQUALS, sutState)
val filter2 = new Filter("action", ComparisonOperator.EQUALS, a)
val filterStart = new Filter("start", ComparisonOperator.EQUALS, sutState)
val filterAction = new Filter("action", ComparisonOperator.EQUALS, a)
val targetSutState = to.asInstanceOf[StateNeo4J].sutState
val filter3 = new Filter("end", ComparisonOperator.EQUALS, targetSutState)
val transitions = session.loadAll(classOf[ActionTransitionEntity], filter.and(filter2).and(filter3))
val filterEnd = new Filter("end", ComparisonOperator.EQUALS, targetSutState)
val transitions = session.loadAll(classOf[ActionTransitionEntity], filterStart.and(filterAction).and(filterEnd))
val first = transitions.stream().findFirst()
val counter = if (first.isPresent) {
first.get().counter = first.get().counter + 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ import de.retest.recheck.XmlTransformerUtil
import de.retest.recheck.ui.descriptors.SutState
import org.neo4j.ogm.typeconversion.AttributeConverter

/*
* https://github.com/neo4j/neo4j-ogm/blob/master/neo4j-ogm-docs/src/main/asciidoc/reference/conversion.adoc
*/
class SutStateConverter extends AttributeConverter[SutState, String] {
def toGraphProperty(value: SutState): String = XmlTransformerUtil.getXmlTransformer.toXML(value)
def toEntityAttribute(value: String): SutState =
Expand Down

0 comments on commit e5d1e85

Please sign in to comment.