Updated current sql with match sql
This commit is contained in:
parent
495903ad00
commit
206ed3f095
resources/db_update_scripts
src/main/java/se/su/dsv/scipro
@ -2,3 +2,209 @@ ALTER TABLE `worker_data` ADD `lastSuccessfulRun` DATETIME NOT NULL DEFAULT '
|
||||
ALTER TABLE `checklist_template` ADD `templateNumber` INT NOT NULL DEFAULT '999'
|
||||
ALTER TABLE project_event_template ADD COLUMN checkListTemplate_id bigint(20);
|
||||
CREATE INDEX checkListTemplate_index ON project_event_template(checkListTemplate_id);
|
||||
|
||||
|
||||
-- Match System tables --
|
||||
|
||||
CREATE TABLE `ApplicationPeriod` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`dateCreated` datetime NOT NULL,
|
||||
`lastModified` datetime NOT NULL,
|
||||
`version` int(11) NOT NULL,
|
||||
`endDate` datetime DEFAULT NULL,
|
||||
`name` varchar(255) DEFAULT NULL,
|
||||
`startDate` datetime DEFAULT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB;
|
||||
|
||||
CREATE TABLE `ApplicationPeriod_project_class` (
|
||||
`ApplicationPeriod_id` bigint(20) NOT NULL,
|
||||
`projectClass_id` bigint(20) NOT NULL,
|
||||
PRIMARY KEY (`ApplicationPeriod_id`,`projectClass_id`),
|
||||
KEY `FK97FDEC24BEC322C1` (`ApplicationPeriod_id`),
|
||||
KEY `FK97FDEC24B2B6081F` (`projectClass_id`),
|
||||
CONSTRAINT `FK97FDEC24B2B6081F` FOREIGN KEY (`projectClass_id`) REFERENCES `project_class` (`id`),
|
||||
CONSTRAINT `FK97FDEC24BEC322C1` FOREIGN KEY (`ApplicationPeriod_id`) REFERENCES `ApplicationPeriod` (`id`)
|
||||
) ENGINE=InnoDB;
|
||||
|
||||
CREATE TABLE `Exemption` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`dateCreated` datetime NOT NULL,
|
||||
`lastModified` datetime NOT NULL,
|
||||
`version` int(11) NOT NULL,
|
||||
`comment` varchar(255) DEFAULT NULL,
|
||||
`author_id` bigint(20) NOT NULL,
|
||||
`grantedBy_id` bigint(20) NOT NULL,
|
||||
`projectClass_id` bigint(20) NOT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `author_id` (`author_id`,`projectClass_id`),
|
||||
KEY `FK47352BA9B2B6081F` (`projectClass_id`),
|
||||
KEY `FK47352BA9314EAC85` (`author_id`),
|
||||
KEY `FK47352BA9DEC4D3D8` (`grantedBy_id`),
|
||||
CONSTRAINT `FK47352BA9DEC4D3D8` FOREIGN KEY (`grantedBy_id`) REFERENCES `user` (`id`),
|
||||
CONSTRAINT `FK47352BA9314EAC85` FOREIGN KEY (`author_id`) REFERENCES `role` (`id`),
|
||||
CONSTRAINT `FK47352BA9B2B6081F` FOREIGN KEY (`projectClass_id`) REFERENCES `project_class` (`id`)
|
||||
) ENGINE=InnoDB;
|
||||
|
||||
CREATE TABLE `keyword` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`dateCreated` datetime NOT NULL,
|
||||
`lastModified` datetime NOT NULL,
|
||||
`version` int(11) NOT NULL,
|
||||
`deleted` bit(1) NOT NULL,
|
||||
`keyword` varchar(255) DEFAULT NULL,
|
||||
`type_id` bigint(20) DEFAULT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `FK32ADB5C9D59A80CA` (`type_id`),
|
||||
KEY `deleted_index` (`deleted`),
|
||||
CONSTRAINT `FK32ADB5C9D59A80CA` FOREIGN KEY (`type_id`) REFERENCES `KeywordType` (`id`)
|
||||
) ENGINE=InnoDB;
|
||||
|
||||
CREATE TABLE `KeywordType` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`dateCreated` datetime NOT NULL,
|
||||
`lastModified` datetime NOT NULL,
|
||||
`version` int(11) NOT NULL,
|
||||
`name` varchar(255) NOT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `name` (`name`)
|
||||
) ENGINE=InnoDB;
|
||||
|
||||
CREATE TABLE `Language` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`dateCreated` datetime NOT NULL,
|
||||
`lastModified` datetime NOT NULL,
|
||||
`version` int(11) NOT NULL,
|
||||
`name` varchar(255) DEFAULT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB;
|
||||
|
||||
CREATE TABLE `matchings` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`dateCreated` datetime NOT NULL,
|
||||
`lastModified` datetime NOT NULL,
|
||||
`version` int(11) NOT NULL,
|
||||
`commentForAdmin` varchar(1024) DEFAULT NULL,
|
||||
`commentForStudent` varchar(1024) DEFAULT NULL,
|
||||
`points` int(11) NOT NULL,
|
||||
`status` varchar(255) DEFAULT NULL,
|
||||
`type` varchar(255) DEFAULT NULL,
|
||||
`createdBy_id` bigint(20) NOT NULL,
|
||||
`projectIdea_id` bigint(20) NOT NULL,
|
||||
`supervisor_id` bigint(20) NOT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `FK24A2D4169AA5FCB` (`createdBy_id`),
|
||||
KEY `FK24A2D4164E31D7A1` (`projectIdea_id`),
|
||||
KEY `FK24A2D416BCA56165` (`supervisor_id`),
|
||||
CONSTRAINT `FK24A2D416BCA56165` FOREIGN KEY (`supervisor_id`) REFERENCES `role` (`id`),
|
||||
CONSTRAINT `FK24A2D4164E31D7A1` FOREIGN KEY (`projectIdea_id`) REFERENCES `projectIdea` (`id`),
|
||||
CONSTRAINT `FK24A2D4169AA5FCB` FOREIGN KEY (`createdBy_id`) REFERENCES `user` (`id`)
|
||||
) ENGINE=InnoDB;
|
||||
|
||||
CREATE TABLE `projectIdea` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`dateCreated` datetime NOT NULL,
|
||||
`lastModified` datetime NOT NULL,
|
||||
`version` int(11) NOT NULL,
|
||||
`externalSupervisorInfo` varchar(255) DEFAULT NULL,
|
||||
`title` varchar(255) DEFAULT NULL,
|
||||
`practicalHow` varchar(1024) NOT NULL,
|
||||
`theoryHow` varchar(1024) NOT NULL,
|
||||
`what` varchar(1024) NOT NULL,
|
||||
`why` varchar(1024) NOT NULL,
|
||||
`match_id` bigint(20) DEFAULT NULL,
|
||||
`preferredSupervisor_id` bigint(20) DEFAULT NULL,
|
||||
`project_id` bigint(20) DEFAULT NULL,
|
||||
`projectClass_id` bigint(20) NOT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `FKC7F5C9B0C1813915` (`project_id`),
|
||||
KEY `FKC7F5C9B048F01CA1` (`match_id`),
|
||||
KEY `FKC7F5C9B0B2B6081F` (`projectClass_id`),
|
||||
KEY `FKC7F5C9B0225C6E84` (`preferredSupervisor_id`),
|
||||
CONSTRAINT `FKC7F5C9B0225C6E84` FOREIGN KEY (`preferredSupervisor_id`) REFERENCES `role` (`id`),
|
||||
CONSTRAINT `FKC7F5C9B048F01CA1` FOREIGN KEY (`match_id`) REFERENCES `matchings` (`id`),
|
||||
CONSTRAINT `FKC7F5C9B0B2B6081F` FOREIGN KEY (`projectClass_id`) REFERENCES `project_class` (`id`),
|
||||
CONSTRAINT `FKC7F5C9B0C1813915` FOREIGN KEY (`project_id`) REFERENCES `project` (`id`)
|
||||
) ENGINE=InnoDB;
|
||||
|
||||
CREATE TABLE `projectIdea_Keyword` (
|
||||
`projectIdea_id` bigint(20) NOT NULL,
|
||||
`keywords_id` bigint(20) NOT NULL,
|
||||
PRIMARY KEY (`projectIdea_id`,`keywords_id`),
|
||||
KEY `FK6C66763A4E31D7A1` (`projectIdea_id`),
|
||||
KEY `FK6C66763AAE316F00` (`keywords_id`),
|
||||
CONSTRAINT `FK6C66763AAE316F00` FOREIGN KEY (`keywords_id`) REFERENCES `Keyword` (`id`),
|
||||
CONSTRAINT `FK6C66763A4E31D7A1` FOREIGN KEY (`projectIdea_id`) REFERENCES `projectIdea` (`id`)
|
||||
) ENGINE=InnoDB;
|
||||
|
||||
CREATE TABLE `projectIdea_Language` (
|
||||
`projectIdea_id` bigint(20) NOT NULL,
|
||||
`languages_id` bigint(20) NOT NULL,
|
||||
PRIMARY KEY (`projectIdea_id`,`languages_id`),
|
||||
KEY `FKA10C45274E31D7A1` (`projectIdea_id`),
|
||||
KEY `FKA10C452755E687C` (`languages_id`),
|
||||
CONSTRAINT `FKA10C452755E687C` FOREIGN KEY (`languages_id`) REFERENCES `Language` (`id`),
|
||||
CONSTRAINT `FKA10C45274E31D7A1` FOREIGN KEY (`projectIdea_id`) REFERENCES `projectIdea` (`id`)
|
||||
) ENGINE=InnoDB;
|
||||
|
||||
CREATE TABLE `projectIdea_role` (
|
||||
`projectIdea_id` bigint(20) NOT NULL,
|
||||
`authors_id` bigint(20) NOT NULL,
|
||||
KEY `FK1904FDA54E31D7A1` (`projectIdea_id`),
|
||||
KEY `FK1904FDA57FEBE8A8` (`authors_id`),
|
||||
CONSTRAINT `FK1904FDA57FEBE8A8` FOREIGN KEY (`authors_id`) REFERENCES `role` (`id`),
|
||||
CONSTRAINT `FK1904FDA54E31D7A1` FOREIGN KEY (`projectIdea_id`) REFERENCES `projectIdea` (`id`)
|
||||
) ENGINE=InnoDB;
|
||||
|
||||
CREATE TABLE `Employee_projectLimits` (
|
||||
`Employee_id` bigint(20) NOT NULL,
|
||||
`projectLimits` int(11) DEFAULT NULL,
|
||||
`projectLimits_KEY` bigint(20) NOT NULL,
|
||||
PRIMARY KEY (`Employee_id`,`projectLimits_KEY`),
|
||||
KEY `FKFFE408E01BF5E55` (`projectLimits_KEY`),
|
||||
KEY `FKFFE408E05FCBC05F` (`Employee_id`),
|
||||
CONSTRAINT `FKFFE408E05FCBC05F` FOREIGN KEY (`Employee_id`) REFERENCES `role` (`id`),
|
||||
CONSTRAINT `FKFFE408E01BF5E55` FOREIGN KEY (`projectLimits_KEY`) REFERENCES `project_class` (`id`)
|
||||
) ENGINE=InnoDB;
|
||||
|
||||
CREATE TABLE `Employee_Keyword` (
|
||||
`role_id` bigint(20) NOT NULL,
|
||||
`keywords_id` bigint(20) NOT NULL,
|
||||
PRIMARY KEY (`role_id`,`keywords_id`),
|
||||
KEY `FKB402CDFB7B617197` (`role_id`),
|
||||
KEY `FKB402CDFBAE316F00` (`keywords_id`),
|
||||
CONSTRAINT `FKB402CDFBAE316F00` FOREIGN KEY (`keywords_id`) REFERENCES `Keyword` (`id`),
|
||||
CONSTRAINT `FKB402CDFB7B617197` FOREIGN KEY (`role_id`) REFERENCES `role` (`id`)
|
||||
) ENGINE=InnoDB;
|
||||
|
||||
CREATE TABLE `Employee_Language` (
|
||||
`role_id` bigint(20) NOT NULL,
|
||||
`languages_id` bigint(20) NOT NULL,
|
||||
PRIMARY KEY (`role_id`,`languages_id`),
|
||||
KEY `FK603173EA55E687C` (`languages_id`),
|
||||
KEY `FK603173EA7B617197` (`role_id`),
|
||||
CONSTRAINT `FK603173EA7B617197` FOREIGN KEY (`role_id`) REFERENCES `role` (`id`),
|
||||
CONSTRAINT `FK603173EA55E687C` FOREIGN KEY (`languages_id`) REFERENCES `Language` (`id`)
|
||||
) ENGINE=InnoDB;
|
||||
|
||||
CREATE TABLE `Employee_projectLimits` (
|
||||
`Employee_id` bigint(20) NOT NULL,
|
||||
`projectLimits` int(11) DEFAULT NULL,
|
||||
`projectLimits_KEY` bigint(20) NOT NULL,
|
||||
PRIMARY KEY (`Employee_id`,`projectLimits_KEY`),
|
||||
KEY `FKFFE408E01BF5E55` (`projectLimits_KEY`),
|
||||
KEY `FKFFE408E05FCBC05F` (`Employee_id`),
|
||||
CONSTRAINT `FKFFE408E05FCBC05F` FOREIGN KEY (`Employee_id`) REFERENCES `role` (`id`),
|
||||
CONSTRAINT `FKFFE408E01BF5E55` FOREIGN KEY (`projectLimits_KEY`) REFERENCES `project_class` (`id`)
|
||||
) ENGINE=InnoDB;
|
||||
|
||||
CREATE TABLE `Student_Exemption` (
|
||||
`role_id` bigint(20) NOT NULL,
|
||||
`exemptions_id` bigint(20) NOT NULL,
|
||||
PRIMARY KEY (`role_id`,`exemptions_id`),
|
||||
UNIQUE KEY `exemptions_id` (`exemptions_id`),
|
||||
KEY `FKEB360B202B6C61BA` (`role_id`),
|
||||
KEY `FKEB360B20259AA500` (`exemptions_id`),
|
||||
CONSTRAINT `FKEB360B20259AA500` FOREIGN KEY (`exemptions_id`) REFERENCES `Exemption` (`id`),
|
||||
CONSTRAINT `FKEB360B202B6C61BA` FOREIGN KEY (`role_id`) REFERENCES `role` (`id`)
|
||||
) ENGINE=InnoDB;
|
||||
|
@ -6,10 +6,13 @@ import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.persistence.AssociationOverride;
|
||||
import javax.persistence.Cacheable;
|
||||
import javax.persistence.ElementCollection;
|
||||
import javax.persistence.Embeddable;
|
||||
import javax.persistence.Embedded;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.JoinTable;
|
||||
import javax.persistence.ManyToMany;
|
||||
|
||||
import org.hibernate.annotations.Cache;
|
||||
@ -26,8 +29,71 @@ import se.su.dsv.scipro.match.dataobject.Keywords;
|
||||
@Cache(usage= CacheConcurrencyStrategy.NONSTRICT_READ_WRITE) //Hibernate specific
|
||||
public class Employee extends ProjectTeamMember {
|
||||
|
||||
public static class Capabilities implements Serializable {
|
||||
|
||||
@Embedded
|
||||
@AssociationOverride(name="languages", joinTable=@JoinTable(name="Employee_Language"))
|
||||
private Capabilities capabilities = new Capabilities();
|
||||
|
||||
@Embedded
|
||||
@AssociationOverride(name="keywords", joinTable=@JoinTable(name="Employee_Keyword"))
|
||||
private Keywords keywords = new Keywords();
|
||||
|
||||
public Keywords getKeywords() {
|
||||
return keywords;
|
||||
}
|
||||
|
||||
public Capabilities getCapabilities() {
|
||||
return capabilities;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Supervisor [id=" + getId() + ", user=" + user + ", capabilities="
|
||||
+ capabilities + ", keywords=" + keywords + "]";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 0;
|
||||
result =
|
||||
prime * result
|
||||
+ ((capabilities == null) ? 0 : capabilities.hashCode());
|
||||
result =
|
||||
prime * result + ((keywords == null) ? 0 : keywords.hashCode());
|
||||
result = prime * result + ((user == null) ? 0 : user.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
Employee other = (Employee) obj;
|
||||
if (capabilities == null) {
|
||||
if (other.capabilities != null)
|
||||
return false;
|
||||
} else if (!capabilities.equals(other.capabilities))
|
||||
return false;
|
||||
if (keywords == null) {
|
||||
if (other.keywords != null)
|
||||
return false;
|
||||
} else if (!keywords.equals(other.keywords))
|
||||
return false;
|
||||
if (user == null) {
|
||||
if (other.user != null)
|
||||
return false;
|
||||
} else if (!user.equals(other.user))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
private static final long serialVersionUID = -2570983581219033271L;
|
||||
@Embeddable
|
||||
public static class Capabilities implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -3561755898522270150L;
|
||||
|
||||
@ElementCollection
|
||||
@ -101,63 +167,5 @@ public class Employee extends ProjectTeamMember {
|
||||
|
||||
}
|
||||
|
||||
@Embedded
|
||||
private Capabilities capabilities = new Capabilities();
|
||||
@Embedded
|
||||
private Keywords keywords = new Keywords();
|
||||
|
||||
public Keywords getKeywords() {
|
||||
return keywords;
|
||||
}
|
||||
|
||||
public Capabilities getCapabilities() {
|
||||
return capabilities;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Supervisor [id=" + getId() + ", user=" + user + ", capabilities="
|
||||
+ capabilities + ", keywords=" + keywords + "]";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 0;
|
||||
result =
|
||||
prime * result
|
||||
+ ((capabilities == null) ? 0 : capabilities.hashCode());
|
||||
result =
|
||||
prime * result + ((keywords == null) ? 0 : keywords.hashCode());
|
||||
result = prime * result + ((user == null) ? 0 : user.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
Employee other = (Employee) obj;
|
||||
if (capabilities == null) {
|
||||
if (other.capabilities != null)
|
||||
return false;
|
||||
} else if (!capabilities.equals(other.capabilities))
|
||||
return false;
|
||||
if (keywords == null) {
|
||||
if (other.keywords != null)
|
||||
return false;
|
||||
} else if (!keywords.equals(other.keywords))
|
||||
return false;
|
||||
if (user == null) {
|
||||
if (other.user != null)
|
||||
return false;
|
||||
} else if (!user.equals(other.user))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
private static final long serialVersionUID = -2570983581219033271L;
|
||||
|
||||
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ import java.util.Map;
|
||||
import javax.persistence.Cacheable;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.FetchType;
|
||||
import javax.persistence.JoinTable;
|
||||
import javax.persistence.MapKey;
|
||||
import javax.persistence.OneToMany;
|
||||
|
||||
@ -26,6 +27,7 @@ public class Student extends Role {
|
||||
private static final long serialVersionUID = 7672230173163740687L;
|
||||
@OneToMany(fetch = FetchType.LAZY)
|
||||
@MapKey(name = "projectClass")
|
||||
@JoinTable(name = "Student_Exemption")
|
||||
private Map<ProjectClass, Exemption> exemptions = new HashMap<ProjectClass, Exemption>();
|
||||
|
||||
@Override
|
||||
|
@ -4,6 +4,7 @@ import javax.persistence.Cacheable;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.JoinTable;
|
||||
import javax.persistence.ManyToOne;
|
||||
|
||||
import org.hibernate.annotations.Cache;
|
||||
|
@ -9,6 +9,7 @@ import java.util.Set;
|
||||
|
||||
import javax.persistence.CascadeType;
|
||||
import javax.persistence.Embeddable;
|
||||
import javax.persistence.JoinTable;
|
||||
import javax.persistence.ManyToMany;
|
||||
|
||||
@Embeddable
|
||||
|
Loading…
x
Reference in New Issue
Block a user