Commit 8373beb0 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

when copying element fon't forget about glyph

parent 3f299d06
...@@ -53,13 +53,29 @@ public class Glyph implements Serializable { ...@@ -53,13 +53,29 @@ public class Glyph implements Serializable {
@OneToOne(fetch = FetchType.LAZY) @OneToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "file_entry_id") @JoinColumn(name = "file_entry_id")
private UploadedFileEntry file; private UploadedFileEntry file;
/** /**
* Project in which this glyph is available. * Project in which this glyph is available.
*/ */
@ManyToOne(fetch = FetchType.LAZY, optional = false) @ManyToOne(fetch = FetchType.LAZY, optional = false)
private Project project; private Project project;
/**
* Default constructor.
*/
public Glyph() {
}
/**
* Constructor that creates copy of the element.
*
* @param original element to be copied
*/
public Glyph(Glyph original) {
// we should reference to the same file
setFile(file);
}
public UploadedFileEntry getFile() { public UploadedFileEntry getFile() {
return file; return file;
} }
......
...@@ -302,6 +302,7 @@ public abstract class Element implements BioEntity, Serializable, SbmlArgument { ...@@ -302,6 +302,7 @@ public abstract class Element implements BioEntity, Serializable, SbmlArgument {
this.formula = original.getFormula(); this.formula = original.getFormula();
setVisibilityLevel(original.getVisibilityLevel()); setVisibilityLevel(original.getVisibilityLevel());
setTransparencyLevel(original.getTransparencyLevel()); setTransparencyLevel(original.getTransparencyLevel());
setGlyph(new Glyph(original.getGlyph()));
} }
/** /**
......
...@@ -25,6 +25,7 @@ import lcsb.mapviewer.model.map.MiriamData; ...@@ -25,6 +25,7 @@ import lcsb.mapviewer.model.map.MiriamData;
import lcsb.mapviewer.model.map.MiriamType; import lcsb.mapviewer.model.map.MiriamType;
import lcsb.mapviewer.model.map.SearchIndex; import lcsb.mapviewer.model.map.SearchIndex;
import lcsb.mapviewer.model.map.compartment.Compartment; import lcsb.mapviewer.model.map.compartment.Compartment;
import lcsb.mapviewer.model.map.layout.graphics.Glyph;
import lcsb.mapviewer.model.map.layout.graphics.LayerText; import lcsb.mapviewer.model.map.layout.graphics.LayerText;
import lcsb.mapviewer.model.map.model.ElementSubmodelConnection; import lcsb.mapviewer.model.map.model.ElementSubmodelConnection;
import lcsb.mapviewer.model.map.model.Model; import lcsb.mapviewer.model.map.model.Model;
...@@ -98,19 +99,36 @@ public class ElementTest extends ModelTestFunctions { ...@@ -98,19 +99,36 @@ public class ElementTest extends ModelTestFunctions {
assertEquals(Math.sqrt(200), distance, EPSILON); assertEquals(Math.sqrt(200), distance, EPSILON);
} }
@Test @Test
public void testConstructor() { public void testConstructor() {
try { try {
GenericProtein protein = new GenericProtein(); GenericProtein protein = new GenericProtein();
protein.addSearchIndex(new SearchIndex()); protein.addSearchIndex(new SearchIndex());
protein.setSubmodel(new ElementSubmodelConnection()); protein.setSubmodel(new ElementSubmodelConnection());
Element copy = new GenericProtein(protein); Element copy = new GenericProtein(protein);
assertNotNull(copy); assertNotNull(copy);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
throw e; throw e;
} }
} }
@Test
public void testCopyGlyph() {
try {
GenericProtein protein = new GenericProtein();
protein.addSearchIndex(new SearchIndex());
protein.setSubmodel(new ElementSubmodelConnection());
protein.setGlyph(new Glyph());
Element copy = new GenericProtein(protein);
assertNotNull(copy.getGlyph());
ElementComparator comparator = new ElementComparator();
assertEquals(0, comparator.compare(copy, protein));
} catch (Exception e) {
e.printStackTrace();
throw e;
}
}
@Test @Test
public void testIncreaseBorder() { public void testIncreaseBorder() {
......
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