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

Model contain SbmlFunction collection

parent 66253f89
No related branches found
No related tags found
1 merge request!186Resolve "upload of sbml"
......@@ -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.
......
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;
}
}
......@@ -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);
}
......@@ -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
......@@ -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);
}
}
......@@ -889,10 +889,4 @@ public class Reaction implements BioEntity {
}
}
@Override
public String getElementId() {
return getIdReaction();
}
}
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());
}
}
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