-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into feature/#86-event-based-animation
- Loading branch information
Showing
16 changed files
with
314 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
files/src/main/java/org/matsim/viz/files/entities/Taggable.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package org.matsim.viz.files.entities; | ||
|
||
import com.fasterxml.jackson.annotation.JsonIgnore; | ||
import lombok.Getter; | ||
import lombok.Setter; | ||
import org.apache.commons.codec.digest.DigestUtils; | ||
import org.apache.commons.codec.digest.MessageDigestAlgorithms; | ||
|
||
import javax.persistence.*; | ||
import java.util.HashSet; | ||
import java.util.Set; | ||
import java.util.stream.Collectors; | ||
|
||
@Entity | ||
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS) | ||
@Getter | ||
@Setter | ||
public abstract class Taggable extends Resource { | ||
|
||
private static DigestUtils digestUtils = new DigestUtils(MessageDigestAlgorithms.SHA_256); | ||
|
||
@ManyToMany(fetch = FetchType.EAGER) | ||
private Set<Tag> tags = new HashSet<>(); | ||
|
||
@JsonIgnore | ||
@Column(nullable = false, length = 64) | ||
private String tagSummary = ""; | ||
|
||
void addTag(Tag tag) { | ||
this.tags.add(tag); | ||
updateTagSummary(); | ||
} | ||
|
||
public void addTags(String[] tagIds) { | ||
for (String tagId : tagIds) { | ||
Tag tag = new Tag(); | ||
tag.setId(tagId); | ||
this.addTag(tag); | ||
} | ||
} | ||
|
||
void removeTag(Tag tag) { | ||
this.tags.remove(tag); | ||
updateTagSummary(); | ||
} | ||
|
||
private void updateTagSummary() { | ||
final String allTags = tags.stream() | ||
.sorted((tag1, tag2) -> tag1.getId().compareToIgnoreCase(tag2.getId())) | ||
.map(Tag::getId) | ||
.collect(Collectors.joining()); | ||
this.tagSummary = digestUtils.digestAsHex(allTags); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
files/src/main/resources/db/migration/V0.1.4__add_updatedAt_and_taggable.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
-- | ||
-- Set character set the client will use to send SQL statements to the server | ||
-- | ||
SET NAMES 'utf8'; | ||
|
||
-- | ||
-- Resources now have a updateAt property. We must alter all Resources tables which are | ||
-- Project, FileEntry and Visualization | ||
-- | ||
|
||
-- | ||
-- Add updatedAt property to FileEntry and set it to 'now' | ||
-- | ||
ALTER TABLE FileEntry | ||
ADD COLUMN updatedAt DATETIME; | ||
|
||
UPDATE FileEntry | ||
SET updatedAt = CURRENT_TIMESTAMP(); | ||
|
||
-- | ||
-- Add updatedAt property to Visualization and set it to 'now' | ||
-- | ||
ALTER TABLE Visualization | ||
ADD COLUMN updatedAt DATETIME; | ||
|
||
UPDATE Visualization | ||
SET updatedAt = CURRENT_TIMESTAMP(); | ||
|
||
-- | ||
-- Add updatedAt property to Project and set it to 'now' | ||
-- | ||
ALTER TABLE Project | ||
ADD COLUMN updatedAt DATETIME; | ||
|
||
UPDATE Project | ||
SET updatedAt = CURRENT_TIMESTAMP(); | ||
|
||
-- | ||
-- Tags are now assignable through the Taggable class which FileEntry and Visualization derive from now | ||
-- We need to Create a Taggable_Tag table and copy the old values from FileEntry_Tag | ||
-- At last we delete the old FileEntry_Tag table | ||
-- | ||
|
||
-- | ||
-- Create Table Taggable_Tag | ||
-- | ||
CREATE TABLE Taggable_Tag | ||
( | ||
Taggable_id VARCHAR(255) NOT NULL, | ||
tags_id VARCHAR(255) NOT NULL, | ||
PRIMARY KEY (Taggable_id, tags_id), | ||
KEY FKq7cqx9j002d4ywlft24j0ox3e (tags_id), | ||
CONSTRAINT FKq7cqx9j002d4ywlft24j0ox3e FOREIGN KEY (tags_id) REFERENCES Tag (id) | ||
) | ||
CHARACTER SET utf8, | ||
COLLATE utf8_general_ci; | ||
|
||
-- | ||
-- Also give a tag summary column to Visualization | ||
-- | ||
ALTER TABLE Visualization | ||
ADD COLUMN tagSummary VARCHAR(64); | ||
|
||
UPDATE Visualization | ||
SET tagSummary = ''; | ||
|
||
-- | ||
-- Copy all values from FileEntry_Tag | ||
-- | ||
INSERT INTO Taggable_Tag (Taggable_id, tags_id) | ||
SELECT FileEntry_id, tags_id FROM FileEntry_Tag; | ||
|
||
-- | ||
-- Drop old FileEntry_Tag table | ||
-- | ||
DROP TABLE IF EXISTS FileEntry_Tag; |
32 changes: 32 additions & 0 deletions
32
files/src/main/resources/db/migration/V0.1.5__add_new_properties_to_visualization.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
-- | ||
-- Set character set the client will use to send SQL statements to the server | ||
-- | ||
SET NAMES 'utf8'; | ||
|
||
-- | ||
-- Visualizations have new properties like title, thumbnail, and properties | ||
-- | ||
|
||
ALTER TABLE Visualization | ||
ADD COLUMN title VARCHAR(255); | ||
UPDATE Visualization | ||
SET title = ''; | ||
|
||
ALTER TABLE Visualization | ||
ADD COLUMN thumbnail LONGTEXT; | ||
UPDATE Visualization | ||
SET thumbnail = ''; | ||
|
||
-- | ||
-- properties are a separate table | ||
-- | ||
CREATE TABLE Visualization_properties | ||
( | ||
Visualization_id varchar(255) NOT NULL, | ||
value varchar(10000) DEFAULT NULL, | ||
properties_KEY varchar(255) NOT NULL, | ||
PRIMARY KEY (Visualization_id, properties_KEY), | ||
CONSTRAINT FK556sp5rugb2160u30kcmyw99n FOREIGN KEY (Visualization_id) REFERENCES Visualization (id) | ||
) | ||
CHARACTER SET utf8, | ||
COLLATE utf8_general_ci; |
Oops, something went wrong.