-
Notifications
You must be signed in to change notification settings - Fork 10
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
Implement reverse operator #20
Open
Zackhardtoname
wants to merge
3
commits into
CIDARLAB:master
Choose a base branch
from
hicsail:reverse-operator
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
src/main/java/knox/spring/data/neo4j/operations/ReverseOperator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package knox.spring.data.neo4j.operations; | ||
|
||
import knox.spring.data.neo4j.domain.Edge; | ||
import knox.spring.data.neo4j.domain.NodeSpace; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.Set; | ||
|
||
public class ReverseOperator { | ||
public static void apply(NodeSpace inputSpace, NodeSpace outputSpace) { | ||
//copy input space to a new output space | ||
outputSpace.copyNodeSpace(inputSpace); | ||
|
||
Set<Edge> allEdges = outputSpace.getEdges(); | ||
|
||
//traverse all edges of input space and flip the orientation attribute | ||
for(Edge edge: allEdges){ | ||
edge.reverseOrientation(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -517,6 +517,15 @@ $('#apply-operators-tooltip').click(() => { | |
} | ||
div.appendChild(tolDiv); | ||
} | ||
if(this.value === endpoint.operators.REVERSE){ | ||
if(div.contains(inputDiv)){ | ||
div.removeChild(inputDiv); | ||
} | ||
const guidance = document.createElement("P"); | ||
const text = document.createTextNode("The current designSpace will be reversed."); | ||
guidance.appendChild(text); | ||
div.appendChild(guidance); | ||
} | ||
}); | ||
|
||
swal({ | ||
|
@@ -557,6 +566,11 @@ $('#apply-operators-tooltip').click(() => { | |
case endpoint.operators.MERGE: | ||
endpoint.designSpaceMerge(inputSpaces, outputSpace, tolerance); | ||
break; | ||
|
||
case endpoint.operators.REVERSE: | ||
// the reverse operator would only reverse one inputSpace | ||
endpoint.designSpaceReverse(inputSpaces[0], outputSpace); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Zack, you missed my other comment that this is inconsistent with the other functions. This code should be in the Java file, not here. Please squash these commits when you've fixed them. |
||
break; | ||
} | ||
} | ||
}); | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should follow the conventions set by the other functions and throw error if outputSpaceID is null.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the output space is null, in the file
DesignSpaceService.java
, the functions usually choose the first element in the inputBranches as the output space. I think my charges here are consistent?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see that in the
DesignSpaceService.java
, but when you test on the UI, it will throw an error if the outputBranch is empty. But the change you made, where you put get.get(0)
inknox.js
, is inconsistent with the rest of the repo.