Skip to content
Snippets Groups Projects
Commit ab5c882d authored by Piotr Gawron's avatar Piotr Gawron
Browse files

bug during refactor - project was not defined when creating overlays

parent 1cfb12ef
No related branches found
No related tags found
2 merge requests!630WIP: Resolve "The privileges of a new user are not saved in some cases",!497Resolve "overlays should be defined per project not per map"
...@@ -359,9 +359,16 @@ public class OverlayRestImpl extends BaseRestImpl { ...@@ -359,9 +359,16 @@ public class OverlayRestImpl extends BaseRestImpl {
} }
Layout layout = layoutService Layout layout = layoutService
.createLayout(new CreateLayoutParams().async(false).colorInputStream(stream).description(description) .createLayout(new CreateLayoutParams()
.layoutFileName(filename).name(name).user(user).colorSchemaType(colorSchemaType) .async(false)
.directory(".").googleLicenseConsent(googleLicenseConsent.equalsIgnoreCase("true"))); .colorInputStream(stream)
.description(description)
.layoutFileName(filename)
.name(name).user(user)
.colorSchemaType(colorSchemaType)
.directory(".")
.project(project)
.googleLicenseConsent(googleLicenseConsent.equalsIgnoreCase("true")));
int count = layoutService.getCustomLayouts(project, token, false, user).size(); int count = layoutService.getCustomLayouts(project, token, false, user).size();
layout.setOrderIndex(count); layout.setOrderIndex(count);
......
...@@ -9,6 +9,7 @@ import lcsb.mapviewer.api.projects.comments.AllCommentTests; ...@@ -9,6 +9,7 @@ import lcsb.mapviewer.api.projects.comments.AllCommentTests;
import lcsb.mapviewer.api.projects.drugs.AllDrugTests; import lcsb.mapviewer.api.projects.drugs.AllDrugTests;
import lcsb.mapviewer.api.projects.mirnas.AllMiRnaTests; import lcsb.mapviewer.api.projects.mirnas.AllMiRnaTests;
import lcsb.mapviewer.api.projects.models.AllModelsTests; import lcsb.mapviewer.api.projects.models.AllModelsTests;
import lcsb.mapviewer.api.projects.overlays.OverlayRestImplTest;
@RunWith(Suite.class) @RunWith(Suite.class)
@SuiteClasses({ AllChemicalTests.class, @SuiteClasses({ AllChemicalTests.class,
...@@ -16,6 +17,7 @@ import lcsb.mapviewer.api.projects.models.AllModelsTests; ...@@ -16,6 +17,7 @@ import lcsb.mapviewer.api.projects.models.AllModelsTests;
AllDrugTests.class, AllDrugTests.class,
AllMiRnaTests.class, AllMiRnaTests.class,
AllModelsTests.class, AllModelsTests.class,
OverlayRestImplTest.class,
ProjectRestImplTest.class }) ProjectRestImplTest.class })
public class AllProjectTests { public class AllProjectTests {
......
package lcsb.mapviewer.api.projects.overlays;
import static org.junit.Assert.assertNotNull;
import java.util.Map;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import com.google.gson.Gson;
import lcsb.mapviewer.api.RestTestFunctions;
import lcsb.mapviewer.model.Project;
import lcsb.mapviewer.model.map.model.Model;
import lcsb.mapviewer.persist.dao.ProjectDao;
import lcsb.mapviewer.services.utils.data.ColorSchemaType;
public class OverlayRestImplTest extends RestTestFunctions {
@Autowired
OverlayRestImpl overlayRest;
@Autowired
ProjectDao projectDao;
String projectId = "test_id";
@Test
public void testAddDataOverlay() throws Exception {
try {
createProject("testFiles/model/sample.xml", projectId);
Map<String, Object> result = overlayRest.addOverlay(adminToken, projectId, "x", "desc", "s1", null, null,
ColorSchemaType.GENERIC.name(), "true");
Gson gson = new Gson();
assertNotNull(gson.toJson(result));
} catch (Exception e) {
e.printStackTrace();
throw e;
}
}
private void createProject(String string, String projectId) throws Exception {
Project project = new Project(projectId);
Model model = super.getModelForFile(string, true);
project.addModel(model);
projectDao.add(project);
}
}
...@@ -952,4 +952,12 @@ public class LayoutService implements ILayoutService { ...@@ -952,4 +952,12 @@ public class LayoutService implements ILayoutService {
User user = userService.getUserByToken(authenticationToken); User user = userService.getUserByToken(authenticationToken);
return userCanRemoveLayout(layout, user); return userCanRemoveLayout(layout, user);
} }
public LayoutDao getLayoutDao() {
return layoutDao;
}
public void setLayoutDao(LayoutDao layoutDao) {
this.layoutDao = layoutDao;
}
} }
...@@ -17,6 +17,7 @@ import lcsb.mapviewer.model.map.model.Model; ...@@ -17,6 +17,7 @@ import lcsb.mapviewer.model.map.model.Model;
import lcsb.mapviewer.model.map.reaction.Reaction; import lcsb.mapviewer.model.map.reaction.Reaction;
import lcsb.mapviewer.model.map.species.Element; import lcsb.mapviewer.model.map.species.Element;
import lcsb.mapviewer.model.user.User; import lcsb.mapviewer.model.user.User;
import lcsb.mapviewer.persist.dao.map.LayoutDao;
import lcsb.mapviewer.services.SecurityException; import lcsb.mapviewer.services.SecurityException;
import lcsb.mapviewer.services.utils.EmailSender; import lcsb.mapviewer.services.utils.EmailSender;
import lcsb.mapviewer.services.utils.data.ColorSchemaType; import lcsb.mapviewer.services.utils.data.ColorSchemaType;
...@@ -493,4 +494,6 @@ public interface ILayoutService { ...@@ -493,4 +494,6 @@ public interface ILayoutService {
boolean userCanRemoveLayout(Layout layout, String authenticationToken) throws SecurityException; boolean userCanRemoveLayout(Layout layout, String authenticationToken) throws SecurityException;
void setLayoutDao(LayoutDao layoutDao);
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment