diff --git a/model/src/main/java/lcsb/mapviewer/model/map/BioEntity.java b/model/src/main/java/lcsb/mapviewer/model/map/BioEntity.java index 068af61908262d6eca1908b8b53610b2631a7212..4f9d07386c1e8e486295f17835de6c50f797a744 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/BioEntity.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/BioEntity.java @@ -157,14 +157,12 @@ public interface BioEntity extends Serializable { */ void setVisibilityLevel(Integer zoomLevelVisibility); - /** - * Returns semantic zoom level visibility. - * - * @return semantic zoom level visibility - */ - String getVisibilityLevel(); - - String getElementId(); + /** + * Returns semantic zoom level visibility. + * + * @return semantic zoom level visibility + */ + String getVisibilityLevel(); /** * Returns the {@link Model} where BioEntity is located. diff --git a/model/src/main/java/lcsb/mapviewer/model/map/SbmlFunction.java b/model/src/main/java/lcsb/mapviewer/model/map/SbmlFunction.java new file mode 100644 index 0000000000000000000000000000000000000000..fc75944422f6147e87ad2d8d6a55f9f89fd181be --- /dev/null +++ b/model/src/main/java/lcsb/mapviewer/model/map/SbmlFunction.java @@ -0,0 +1,109 @@ +package lcsb.mapviewer.model.map; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; + +import javax.persistence.CollectionTable; +import javax.persistence.Column; +import javax.persistence.ElementCollection; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.Table; +import javax.xml.bind.annotation.XmlRootElement; + +import org.apache.log4j.Logger; +import org.hibernate.annotations.IndexColumn; + +/** + * Representation of a single SBML function + * + * @author Piotr Gawron + * + */ +@Entity +@Table(name = "sbml_function") +@org.hibernate.annotations.GenericGenerator(name = "test-increment-strategy", strategy = "increment") +@XmlRootElement +public class SbmlFunction implements Serializable { + + /** + * Default class logger. + */ + @SuppressWarnings("unused") + private static Logger logger = Logger.getLogger(SbmlFunction.class); + + /** + * + */ + private static final long serialVersionUID = 1L; + + /** + * Unique database identifier. + */ + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "idDb", unique = true, nullable = false) + private int id; + + private String functionId; + + private String name; + + @Column(columnDefinition = "TEXT") + private String definition; + + @ElementCollection + @CollectionTable(name = "sbml_function_arguments", joinColumns = @JoinColumn(name = "sbml_function_iddb")) + @IndexColumn(name = "idx") + @Column(name = "argument_name") + private List<String> arguments = new ArrayList<>(); + + /** + * Constructor required by hibernate. + */ + SbmlFunction() { + super(); + } + + public SbmlFunction(String functionId) { + this.functionId = functionId; + } + + public String getFunctionId() { + return functionId; + } + + public void setFunctionId(String functionId) { + this.functionId = functionId; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public List<String> getArguments() { + return arguments; + } + + public void setArguments(List<String> arguments) { + this.arguments = arguments; + } + + public String getDefinition() { + return definition; + } + + public void setDefinition(String definition) { + this.definition = definition; + } + + +} diff --git a/model/src/main/java/lcsb/mapviewer/model/map/model/Model.java b/model/src/main/java/lcsb/mapviewer/model/map/model/Model.java index f20bbd35a49e556693c7d9c318bc700f13c4f258..613c5ce87787ac6a4fc74c6a6a71ff04b0019c36 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/model/Model.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/model/Model.java @@ -8,6 +8,7 @@ import java.util.Set; import lcsb.mapviewer.model.Project; import lcsb.mapviewer.model.map.BioEntity; import lcsb.mapviewer.model.map.MiriamData; +import lcsb.mapviewer.model.map.SbmlFunction; import lcsb.mapviewer.model.map.compartment.Compartment; import lcsb.mapviewer.model.map.graph.DataMiningSet; import lcsb.mapviewer.model.map.layout.BlockDiagram; @@ -588,4 +589,8 @@ public interface Model { * layout to remove */ void removeLayout(Layout dbLayout); + + Set<SbmlFunction> getFunctions(); + + void addFunctions(Collection<SbmlFunction> parseXmlFunctionCollection); } diff --git a/model/src/main/java/lcsb/mapviewer/model/map/model/ModelData.java b/model/src/main/java/lcsb/mapviewer/model/map/model/ModelData.java index e5c17ee79861f77859bb66464e4be93434ba39d2..95fe2a9fbdf13cef3d5481774cb6f3e7fbfb3d27 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/model/ModelData.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/model/ModelData.java @@ -27,6 +27,7 @@ import org.hibernate.annotations.CascadeType; import lcsb.mapviewer.common.exception.InvalidArgumentException; import lcsb.mapviewer.model.Project; +import lcsb.mapviewer.model.map.SbmlFunction; import lcsb.mapviewer.model.map.graph.DataMiningSet; import lcsb.mapviewer.model.map.layout.BlockDiagram; import lcsb.mapviewer.model.map.layout.ElementGroup; @@ -101,6 +102,16 @@ public class ModelData implements Serializable { @OneToMany(mappedBy = "model", orphanRemoval = true) private Set<Reaction> reactions = new HashSet<>(); + /** + * Collection of SBML functions in the map. + * + * @see SbmlFunction + * + */ + @Cascade({ CascadeType.ALL }) + @OneToMany(mappedBy = "model", orphanRemoval = true) + private Set<SbmlFunction> functions = new HashSet<>(); + /** * When the map was created. */ @@ -110,7 +121,7 @@ public class ModelData implements Serializable { * Width of the map. */ private Double width; - + /** * Height of the map. */ @@ -120,7 +131,7 @@ public class ModelData implements Serializable { * X coordinate that should be used when initially showing map. */ private Double defaultCenterX; - + /** * Y coordinate that should be used when initially showing map. */ @@ -732,4 +743,8 @@ public class ModelData implements Serializable { public void setDefaultZoomLevel(Integer defaultZoomLevel) { this.defaultZoomLevel = defaultZoomLevel; } + + public Set<SbmlFunction> getFunctions() { + return functions; + } } \ No newline at end of file diff --git a/model/src/main/java/lcsb/mapviewer/model/map/model/ModelFullIndexed.java b/model/src/main/java/lcsb/mapviewer/model/map/model/ModelFullIndexed.java index 9a5c504bc38475d5f62cf62d3fd3472628d9d03b..99a09db9a8def3b1d92c7874973690364b455b83 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/model/ModelFullIndexed.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/model/ModelFullIndexed.java @@ -16,6 +16,7 @@ import lcsb.mapviewer.common.exception.InvalidArgumentException; import lcsb.mapviewer.model.Project; import lcsb.mapviewer.model.map.BioEntity; import lcsb.mapviewer.model.map.MiriamData; +import lcsb.mapviewer.model.map.SbmlFunction; import lcsb.mapviewer.model.map.compartment.Compartment; import lcsb.mapviewer.model.map.graph.DataMiningSet; import lcsb.mapviewer.model.map.layout.BlockDiagram; @@ -652,4 +653,14 @@ public class ModelFullIndexed implements Model { public void setDefaultZoomLevel(Integer defaultZoomLevel) { modelData.setDefaultZoomLevel(defaultZoomLevel); } + + @Override + public Set<SbmlFunction> getFunctions() { + return modelData.getFunctions(); + } + + @Override + public void addFunctions(Collection<SbmlFunction> functions) { + modelData.getFunctions().addAll(functions); + } } diff --git a/model/src/main/java/lcsb/mapviewer/model/map/reaction/Reaction.java b/model/src/main/java/lcsb/mapviewer/model/map/reaction/Reaction.java index d1139cf5a6c9c26ee6958efc415565b54eb65cbe..eb6e6ccac3b9756e27a3a55be425cc93dc8a2555 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/reaction/Reaction.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/reaction/Reaction.java @@ -889,10 +889,4 @@ public class Reaction implements BioEntity { } } - - @Override - public String getElementId() { - return getIdReaction(); - } - } diff --git a/model/src/test/java/lcsb/mapviewer/model/map/SbmlFunctionTest.java b/model/src/test/java/lcsb/mapviewer/model/map/SbmlFunctionTest.java new file mode 100644 index 0000000000000000000000000000000000000000..20e3c983f963d874f2a23cb982e3dbb110fcca97 --- /dev/null +++ b/model/src/test/java/lcsb/mapviewer/model/map/SbmlFunctionTest.java @@ -0,0 +1,45 @@ +package lcsb.mapviewer.model.map; + +import static org.junit.Assert.*; + +import java.util.ArrayList; +import java.util.List; + +import org.junit.Test; + +public class SbmlFunctionTest { + + @Test + public void testConstructor() { + String id = "function_i"; + SbmlFunction function = new SbmlFunction(id); + assertEquals(id, function.getFunctionId()); + } + + @Test + public void testSetName() { + String name = "name"; + SbmlFunction function = new SbmlFunction(""); + function.setName(name); + assertEquals(name, function.getName()); + } + + @Test + public void testSetDefinition() { + String definition = "<lambda><bvar><ci> x </ci></bvar></lambda>"; + SbmlFunction function = new SbmlFunction(""); + function.setDefinition(definition); + assertEquals(definition, function.getDefinition()); + } + + @Test + public void testGetArguments() { + List<String> arguments = new ArrayList<>(); + arguments.add("x"); + + SbmlFunction function = new SbmlFunction(""); + function.setArguments(arguments); + assertEquals(arguments, function.getArguments()); + } + +}