Commit 883722f2 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

glyph data structure created

parent 1233ccd8
......@@ -37,6 +37,7 @@ import lcsb.mapviewer.model.map.OverviewImage;
import lcsb.mapviewer.model.map.OverviewImageLink;
import lcsb.mapviewer.model.map.OverviewLink;
import lcsb.mapviewer.model.map.layout.Layout;
import lcsb.mapviewer.model.map.layout.graphics.Glyph;
import lcsb.mapviewer.model.map.model.Model;
import lcsb.mapviewer.model.map.model.ModelData;
......@@ -182,6 +183,15 @@ public class Project implements Serializable {
@LazyCollection(LazyCollectionOption.FALSE)
private List<OverviewImage> overviewImages = new ArrayList<>();
/**
* List of glyph images that can be used to draw elements on maps.
*/
@Cascade({ CascadeType.ALL })
@OneToMany(mappedBy = "project", orphanRemoval = true)
@OrderBy("id")
@LazyCollection(LazyCollectionOption.FALSE)
private List<Glyph> glyphs = new ArrayList<>();
/**
* Default constructor.
*/
......@@ -680,4 +690,12 @@ public class Project implements Serializable {
this.creationDate = creationDate;
}
public List<Glyph> getGlyphs() {
return glyphs;
}
public void setGlyphs(List<Glyph> glyphs) {
this.glyphs = glyphs;
}
}
package lcsb.mapviewer.model.map.layout.graphics;
import java.io.Serializable;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToOne;
import org.apache.log4j.Logger;
import org.hibernate.annotations.Cascade;
import org.hibernate.annotations.CascadeType;
import lcsb.mapviewer.model.Project;
import lcsb.mapviewer.model.cache.UploadedFileEntry;
import lcsb.mapviewer.model.map.BioEntity;
/**
* This class describes glyph used to represent {@link BioEntity} on the map.
*
* @author Piotr Gawron
*
*/
@Entity
public class Glyph implements Serializable {
/**
*
*/
private static final long serialVersionUID = 1L;
/**
* Default class logger.
*/
@SuppressWarnings("unused")
private static Logger logger = Logger.getLogger(Glyph.class);
/**
* Unique database identifier.
*/
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private int id;
/**
* File that should be used for drawing a glyph.
*/
@Cascade({ CascadeType.SAVE_UPDATE })
@OneToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "file_entry_id")
private UploadedFileEntry file;
/**
* Project in which this glyph is available.
*/
@ManyToOne(fetch = FetchType.LAZY, optional = false)
private Project project;
public UploadedFileEntry getFile() {
return file;
}
public void setFile(UploadedFileEntry file) {
this.file = file;
}
public Project getProject() {
return project;
}
public void setProject(Project project) {
this.project = project;
}
}
......@@ -42,6 +42,7 @@ import lcsb.mapviewer.model.map.MiriamData;
import lcsb.mapviewer.model.map.SearchIndex;
import lcsb.mapviewer.model.map.compartment.Compartment;
import lcsb.mapviewer.model.map.kinetics.SbmlArgument;
import lcsb.mapviewer.model.map.layout.graphics.Glyph;
import lcsb.mapviewer.model.map.layout.graphics.LayerText;
import lcsb.mapviewer.model.map.model.ElementSubmodelConnection;
import lcsb.mapviewer.model.map.model.Model;
......@@ -114,6 +115,13 @@ public abstract class Element implements BioEntity, Serializable, SbmlArgument {
@ManyToOne(fetch = FetchType.LAZY)
private ModelData model;
/**
* When defined this represent glyph that should be used for drawing this
* element.
*/
@ManyToOne(fetch = FetchType.LAZY)
private Glyph glyph;
/**
* Submodel that is extension of these element.
*/
......@@ -1082,4 +1090,12 @@ public abstract class Element implements BioEntity, Serializable, SbmlArgument {
public void setZ(Integer z) {
this.z = z;
}
public Glyph getGlyph() {
return glyph;
}
public void setGlyph(Glyph glyph) {
this.glyph = glyph;
}
}
\ No newline at end of file
CREATE SEQUENCE glyph_sequence
INCREMENT 1
MINVALUE 1
MAXVALUE 9223372036854775807
START 1
CACHE 1;
CREATE TABLE glyph_table
(
id integer NOT NULL DEFAULT nextval('glyph_sequence'::regclass),
file_entry_id integer NOT NULL,
project_id integer NOT NULL,
CONSTRAINT glyph_table_pk PRIMARY KEY (id),
CONSTRAINT glyph_table_file_entry_fk FOREIGN KEY (file_entry_id)
REFERENCES file_entry_table (id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION,
CONSTRAINT glyph_table_project FOREIGN KEY (project_id)
REFERENCES project_table (id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION
)
WITH (
OIDS=FALSE
);
alter table element_table add column glyph_id integer;
alter table element_table add constraint element_table_glyph_fk FOREIGN KEY (glyph_id)
REFERENCES glyph_table (id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION;
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