Commit dd13a4e2 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

Merge branch '1408-and-gate-in-sbgn-like-view' into 'devel_15.1.x'

Resolve "AND gate is not visible"

See merge request !1260
parents fd483377 b36dbbb8
Pipeline #34579 failed with stage
in 16 minutes and 7 seconds
......@@ -11,6 +11,8 @@ minerva (15.1.1) stable; urgency=medium
message (#1367)
* Bug fix: opening map in google maps without background resulted in
unexpected error (#1416)
* Bug fix: normal user could not update tos information (#1419)
* Bug fix: and operator in SBGN-like view was not drawn (#1408)
-- Piotr Gawron <piotr.gawron@uni.lu> Thu, 23 Nov 2020 15:00:00 +0200
......
......@@ -16,7 +16,8 @@ import lcsb.mapviewer.converter.graphics.ConverterParams;
import lcsb.mapviewer.converter.graphics.DrawingException;
import lcsb.mapviewer.converter.graphics.bioEntity.BioEntityConverter;
import lcsb.mapviewer.converter.graphics.geometry.ArrowTransformation;
import lcsb.mapviewer.model.graphics.*;
import lcsb.mapviewer.model.graphics.ArrowTypeData;
import lcsb.mapviewer.model.graphics.PolylineData;
import lcsb.mapviewer.model.map.layout.ColorSchema;
import lcsb.mapviewer.model.map.layout.GenericColorSchema;
import lcsb.mapviewer.model.map.reaction.*;
......@@ -357,41 +358,28 @@ public class ReactionConverter extends BioEntityConverter<Reaction> {
// draw line
arrowTransformation.drawLine(operator.getLine(), graphics);
// in SBGN view - draw connecting point only if it's not connected to
// reactants or products
if (!sbgnFormat || operator.getLine().getEndAtd().getArrowType() != ArrowType.NONE
|| (!operator.getOutputs().isEmpty() && operator.getOutputs().get(0) instanceof NodeOperator)) {
// and now connecting point
Point2D centerPoint = operator.getLine().getPoints().get(0);
Color fillColor = Color.WHITE;
double radius = DEFAULT_OPERATOR_RADIUS;
// bigger connecting point circles in SBGN view
if (sbgnFormat) {
radius *= SBGN_RADIUS_MULTIPLIER;
} else if (operator instanceof AndOperator || operator instanceof SplitOperator
|| operator instanceof DissociationOperator || operator instanceof AssociationOperator
|| operator instanceof TruncationOperator) {
radius = 1.5;
fillColor = operator.getLine().getColor();
}
// it's a circle
Ellipse2D cir = new Ellipse2D.Double(centerPoint.getX() - radius, centerPoint.getY() - radius, 2 * radius,
2 * radius);
graphics.setColor(fillColor);
graphics.fill(cir);
graphics.setColor(operator.getLine().getColor());
graphics.draw(cir);
// and text defined by operator
String text;
if (!sbgnFormat) {
text = operator.getOperatorText();
} else {
text = operator.getSBGNOperatorText();
}
Rectangle2D rect = graphics.getFontMetrics().getStringBounds(text, graphics);
graphics.drawString(text, (int) (centerPoint.getX() - rect.getWidth() / 2 + 1),
(int) (centerPoint.getY() + rect.getHeight() / 2) - 2);
Point2D centerPoint = operator.getLine().getPoints().get(0);
Color fillColor = Color.WHITE;
double radius = DEFAULT_OPERATOR_RADIUS;
// bigger connecting point circles in SBGN view
if (operator instanceof AndOperator || operator instanceof SplitOperator
|| operator instanceof DissociationOperator || operator instanceof AssociationOperator
|| operator instanceof TruncationOperator) {
radius = 1.5;
fillColor = operator.getLine().getColor();
}
// it's a circle
Ellipse2D cir = new Ellipse2D.Double(centerPoint.getX() - radius, centerPoint.getY() - radius, 2 * radius,
2 * radius);
graphics.setColor(fillColor);
graphics.fill(cir);
graphics.setColor(operator.getLine().getColor());
graphics.draw(cir);
// and text defined by operator
String text = operator.getOperatorText();
Rectangle2D rect = graphics.getFontMetrics().getStringBounds(text, graphics);
graphics.drawString(text, (int) (centerPoint.getX() - rect.getWidth() / 2 + 1),
(int) (centerPoint.getY() + rect.getHeight() / 2) - 2);
graphics.setColor(oldColor);
}
......
......@@ -51,11 +51,6 @@ public class AndOperator extends NodeOperator {
return "";
}
@Override
public String getSBGNOperatorText() {
return "AND";
}
@Override
public AndOperator copy() {
if (this.getClass() == AndOperator.class) {
......
......@@ -180,15 +180,6 @@ public abstract class NodeOperator extends AbstractNode {
*/
public abstract String getOperatorText();
/**
* Returns SBGN description of the operator.
*
* @return SBGN description of the operator
*/
public String getSBGNOperatorText() {
return getOperatorText();
}
/**
* Checks if the operator connects several inputs (that are modifiers) to one
* output.
......
......@@ -52,11 +52,6 @@ public class OrOperator extends NodeOperator {
return "|";
}
@Override
public String getSBGNOperatorText() {
return "OR";
}
@Override
public OrOperator copy() {
if (this.getClass() == OrOperator.class) {
......
......@@ -36,7 +36,6 @@ public class AndOperatorTest extends ModelTestFunctions {
@Test
public void testGetters() {
AndOperator operator = new AndOperator();
assertFalse("".equals(new AndOperator().getSBGNOperatorText()));
NodeOperator nodeOperatorForInput = new AndOperator();
NodeOperator nodeOperatorForOutput = new AndOperator();
......
......@@ -36,7 +36,6 @@ public class NandOperatorTest extends ModelTestFunctions {
@Test
public void testGetters() {
assertFalse("".equals(new NandOperator().getSBGNOperatorText()));
assertFalse("".equals(new NandOperator().getOperatorText()));
}
......
......@@ -115,7 +115,6 @@ public class NodeOperatorTest extends ModelTestFunctions {
@Test
public void testGetters() {
NodeOperator operator = new NodeOperatorMock();
assertNotNull(operator.getSBGNOperatorText());
List<AbstractNode> inputs = new ArrayList<>();
List<AbstractNode> outputs = new ArrayList<>();
operator.setInputs(inputs);
......
......@@ -36,7 +36,6 @@ public class OrOperatorTest extends ModelTestFunctions {
@Test
public void testGetters() {
assertFalse("".equals(new OrOperator().getSBGNOperatorText()));
assertFalse("".equals(new OrOperator().getOperatorText()));
}
......
......@@ -35,7 +35,6 @@ public class SplitOperatorTest extends ModelTestFunctions {
@Test
public void testGetters() {
assertNotNull(new SplitOperator().getSBGNOperatorText());
assertNotNull(new SplitOperator().getOperatorText());
}
......
......@@ -35,7 +35,6 @@ public class TruncationOperatorTest extends ModelTestFunctions {
@Test
public void testGetters() {
assertNotNull(new TruncationOperator().getSBGNOperatorText());
assertNotNull(new TruncationOperator().getOperatorText());
}
......
......@@ -36,7 +36,6 @@ public class UnknownOperatorTest extends ModelTestFunctions {
@Test
public void testGetters() {
assertFalse("".equals(new UnknownOperator().getSBGNOperatorText()));
assertFalse("".equals(new UnknownOperator().getOperatorText()));
}
......
......@@ -680,7 +680,7 @@ public class UserRestImpl extends BaseRestImpl {
} else if (key.equalsIgnoreCase("connectedtoldap")) {
if (isAdmin) {
user.setConnectedToLdap((Boolean) value);
} else {
} else if (!Objects.equals(user.isConnectedToLdap(), value)) {
throw new AccessDeniedException("connectedtoldap can be updated by admin");
}
} else if (key.equalsIgnoreCase("password")) {
......
......@@ -441,7 +441,7 @@ public class UserControllerIntegrationTest extends ControllerIntegrationTest {
public void userCannotUpdateOwnLdapConnection() throws Exception {
MockHttpSession session = createSession(TEST_USER_LOGIN, TEST_USER_PASSWORD);
String body = "{\"user\":{\"connectedtoldap\":false}}";
String body = "{\"user\":{\"connectedtoldap\":" + (!user.isConnectedToLdap()) + "}}";
RequestBuilder grantRequest = patch("/users/" + TEST_USER_LOGIN)
.contentType(MediaType.APPLICATION_FORM_URLENCODED)
......@@ -452,6 +452,21 @@ public class UserControllerIntegrationTest extends ControllerIntegrationTest {
.andExpect(status().isForbidden());
}
@Test
public void userCannotUpdateOwnLdapConnectionButNoChangeShouldPass() throws Exception {
MockHttpSession session = createSession(TEST_USER_LOGIN, TEST_USER_PASSWORD);
String body = "{\"user\":{\"connectedtoldap\":" + user.isConnectedToLdap() + "}}";
RequestBuilder grantRequest = patch("/users/" + TEST_USER_LOGIN)
.contentType(MediaType.APPLICATION_FORM_URLENCODED)
.content(body)
.session(session);
mockMvc.perform(grantRequest)
.andExpect(status().is2xxSuccessful());
}
@Test
public void removeUserWithLayouts() throws Exception {
MockHttpSession session = createSession(BUILT_IN_TEST_ADMIN_LOGIN, BUILT_IN_TEST_ADMIN_PASSWORD);
......@@ -604,7 +619,7 @@ public class UserControllerIntegrationTest extends ControllerIntegrationTest {
content = EntityUtils.toString(new UrlEncodedFormEntity(Arrays.asList(
new BasicNameValuePair("token", token.getToken()),
new BasicNameValuePair("password", newPassword+"xx"))));
new BasicNameValuePair("password", newPassword + "xx"))));
resetRequest = post("/users:resetPassword")
.content(content)
......@@ -642,7 +657,6 @@ public class UserControllerIntegrationTest extends ControllerIntegrationTest {
public void resetPasswordWithInvalidToken() throws Exception {
configureServerForResetPasswordRequest();
String content = EntityUtils.toString(new UrlEncodedFormEntity(Arrays.asList(
new BasicNameValuePair("token", "blah"),
new BasicNameValuePair("password", "???"))));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment