Skip to content

Commit

Permalink
Addressed #320
Browse files Browse the repository at this point in the history
  • Loading branch information
IgorRodchenkov committed Jul 4, 2024
1 parent 75b491d commit 5a601d8
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 17 deletions.
4 changes: 2 additions & 2 deletions src/main/java/cpath/service/ServiceImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -378,8 +378,8 @@ public ServiceResponse getCommonStream(OutputFormat format,
return new ErrorResponse(MAINTENANCE, "Waiting for the initialization to complete (try again later)...");
}

if (direction == Direction.BOTHSTREAM) {
return new ErrorResponse(BAD_REQUEST, "Direction cannot be BOTHSTREAM for the COMMONSTREAM query");
if (direction == Direction.BOTHSTREAM || direction == Direction.UNDIRECTED) {
return new ErrorResponse(BAD_REQUEST, "COMMONSTREAM graph query direction must be either UPSTREAM or DOWNSTREAM (default)");
} else if(direction == null) {
direction = Direction.DOWNSTREAM;
}
Expand Down
9 changes: 3 additions & 6 deletions src/main/java/cpath/web/args/CommonStream.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,21 @@
public class CommonStream extends BaseGraph {

@Schema(
description = "Graph search direction (default: UNDIRECTED; cannot be BOTHSTREAM)",
example = "undirected"
description = "Graph search direction (default: DOWNSTREAM; can be either DOWNSTREAM or UPSTREAM)",
example = "downstream"
)
private Direction direction;

public CommonStream() {
super();
direction = Direction.UNDIRECTED;
}

public Direction getDirection() {
return direction;
}

public void setDirection(String direction) {
Direction dir = Direction.typeOf(direction); //null when illegal value (also handles empty/null and register/case)
//also exclude/replace BOTHSTREAM value
this.direction = (dir != null && dir != Direction.BOTHSTREAM) ? dir : Direction.UNDIRECTED;
this.direction = Direction.typeOf(direction); //null when illegal value
}

@Override
Expand Down
8 changes: 3 additions & 5 deletions src/main/java/cpath/web/args/Graph.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ public class Graph extends BaseGraph {
private GraphType kind;

@Schema(
description = "Graph search direction (default: UNDIRECTED)",
example = "undirected"
description = "Graph search direction (only for 'neighborhood' and 'commonstream' graph query types; the latter only accepts: 'upstream' or 'downstream')",
example = "downstream"
)
private Direction direction;

Expand All @@ -47,7 +47,6 @@ public class Graph extends BaseGraph {
public Graph() {
super();
limitType = LimitType.NORMAL; //for pathsfromto only
direction = Direction.UNDIRECTED;
}

public GraphType getKind() {
Expand All @@ -63,8 +62,7 @@ public Direction getDirection() {
}

public void setDirection(String direction) {
Direction dir = Direction.typeOf(direction); //null when illegal value (also handles empty/null and register/case)
this.direction = (dir != null) ? dir : Direction.UNDIRECTED;
this.direction = Direction.typeOf(direction); //null when illegal value (also handles empty/null and register/case)
}

public String[] getTarget() {
Expand Down
7 changes: 3 additions & 4 deletions src/main/java/cpath/web/args/Neighborhood.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,22 @@ public class Neighborhood extends BaseGraph {

public Neighborhood() {
super();
direction = Direction.UNDIRECTED;
}

public Direction getDirection() {
return direction;
}

public void setDirection(String direction) {
Direction dir = Direction.typeOf(direction); //null when illegal value (also handles empty/null and register/case)
this.direction = (dir != null) ? dir : Direction.UNDIRECTED;
this.direction = Direction.typeOf(direction); //null when illegal value (also handles empty/null and register/case)
}

@Override
public String toString() {
StringBuilder sb = new StringBuilder(super.toString());
if (direction != null)
if (direction != null) {
sb.append("; dir:").append(direction);
}
return sb.toString();
}

Expand Down

0 comments on commit 5a601d8

Please sign in to comment.