added new SupervisorIdea domain object. Still needs improvements to be useful with new match3 logic.
This commit is contained in:
parent
17aaa1bd28
commit
8cfdf57242
resources/db_update_scripts
src/main/java/se/su/dsv/scipro
match/dataobject
springdata
repos
serviceimpls
services
@ -0,0 +1,48 @@
|
||||
CREATE TABLE `supervisoridea` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`dateCreated` datetime NOT NULL,
|
||||
`lastModified` datetime NOT NULL,
|
||||
`version` int(11) NOT NULL,
|
||||
`title` varchar(255) NOT NULL,
|
||||
`practicalHow` varchar(4000) NOT NULL,
|
||||
`theoryHow` varchar(4000) NOT NULL,
|
||||
`what` varchar(4000) NOT NULL,
|
||||
`why` varchar(4000) NOT NULL,
|
||||
`creator_id` bigint(20) NOT NULL,
|
||||
`project_id` bigint(20) DEFAULT NULL,
|
||||
`projectClass_id` bigint(20) NOT NULL,
|
||||
`applicationPeriod_id` bigint(20) NOT NULL,
|
||||
`description` varchar(4000) NOT NULL,
|
||||
`requirements` varchar(1024) NOT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `projectkey` (`project_id`),
|
||||
KEY `projectclasskey` (`projectClass_id`),
|
||||
KEY `applicationperiodkey` (`applicationPeriod_id`),
|
||||
KEY `creatorkey` (`creator_id`),
|
||||
CONSTRAINT `projectclasskey` FOREIGN KEY (`projectClass_id`) REFERENCES `project_class` (`id`),
|
||||
CONSTRAINT `applicationperiodkey` FOREIGN KEY (`applicationPeriod_id`) REFERENCES `applicationperiod` (`id`),
|
||||
CONSTRAINT `projectkey` FOREIGN KEY (`project_id`) REFERENCES `project` (`id`),
|
||||
CONSTRAINT `creatorkey` FOREIGN KEY (`creator_id`) REFERENCES `role` (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
|
||||
|
||||
CREATE TABLE `supervisoridea_authors` (
|
||||
`supervisoridea_id` bigint(20) NOT NULL,
|
||||
`authors_id` bigint(20) NOT NULL,
|
||||
KEY `supervisorideakey` (`supervisoridea_id`),
|
||||
KEY `authorskey` (`authors_id`),
|
||||
CONSTRAINT `supervisorideakey` FOREIGN KEY (`supervisoridea_id`) REFERENCES `supervisoridea` (`id`),
|
||||
CONSTRAINT `authorskey` FOREIGN KEY (`authors_id`) REFERENCES `role` (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
|
||||
|
||||
|
||||
|
||||
CREATE TABLE `supervisoridea_language` (
|
||||
`supervisoridea_id` bigint(20) NOT NULL,
|
||||
`languages_id` bigint(20) NOT NULL,
|
||||
PRIMARY KEY (`supervisoridea_id`,`languages_id`),
|
||||
KEY `supervisoridea_languagekey` (`supervisoridea_id`),
|
||||
KEY `languages_supervisorideakey` (`languages_id`),
|
||||
CONSTRAINT `supervisoridea_languagekey` FOREIGN KEY (`supervisoridea_id`) REFERENCES `supervisoridea` (`id`),
|
||||
CONSTRAINT `languages_supervisorideakey` FOREIGN KEY (`languages_id`) REFERENCES `language` (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
|
||||
|
@ -0,0 +1,233 @@
|
||||
package se.su.dsv.scipro.match.dataobject;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.SortedSet;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import javax.persistence.Cacheable;
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Embedded;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.JoinTable;
|
||||
import javax.persistence.ManyToMany;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.OneToOne;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import org.hibernate.annotations.Cache;
|
||||
import org.hibernate.annotations.CacheConcurrencyStrategy;
|
||||
import org.hibernate.annotations.Sort;
|
||||
import org.hibernate.annotations.SortType;
|
||||
|
||||
import se.su.dsv.scipro.data.dataobjects.DomainObject;
|
||||
import se.su.dsv.scipro.data.dataobjects.Employee;
|
||||
import se.su.dsv.scipro.data.dataobjects.Language;
|
||||
import se.su.dsv.scipro.data.dataobjects.Project;
|
||||
import se.su.dsv.scipro.data.dataobjects.ProjectClass;
|
||||
import se.su.dsv.scipro.data.dataobjects.Student;
|
||||
import se.su.dsv.scipro.dataproviders.SortableField;
|
||||
|
||||
@Entity
|
||||
@Table(name = "supervisoridea")
|
||||
@Cacheable(true)
|
||||
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
|
||||
public class SupervisorIdea extends DomainObject {
|
||||
|
||||
private static final long serialVersionUID = -2016847385026874488L;
|
||||
|
||||
@Id
|
||||
@GeneratedValue
|
||||
private Long id;
|
||||
|
||||
@ManyToOne(optional = false)
|
||||
@SortableField
|
||||
private ProjectClass projectClass;
|
||||
|
||||
@ManyToMany
|
||||
@JoinTable(name="supervisoridea_authors")
|
||||
@Sort(type=SortType.NATURAL)
|
||||
private SortedSet<Student> authors = new TreeSet<Student>();
|
||||
|
||||
@ManyToOne(optional = false)
|
||||
private Employee creator;
|
||||
|
||||
@ManyToMany
|
||||
private Set<Language> languages = new HashSet<Language>();
|
||||
|
||||
@ManyToOne(optional = false)
|
||||
private ApplicationPeriod applicationPeriod;
|
||||
|
||||
@Column(nullable = false, length = 1024)
|
||||
private String title;
|
||||
@Column(nullable = false, length = 1024)
|
||||
private String description;
|
||||
@Column(nullable = false, length = 1024)
|
||||
private String requirements;
|
||||
|
||||
@Column(nullable=false)
|
||||
private boolean taken = false;
|
||||
|
||||
@Embedded
|
||||
private Watson watson = new Watson();
|
||||
|
||||
@OneToOne
|
||||
private Project project;
|
||||
|
||||
@Override
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public ApplicationPeriod getApplicationPeriod() {
|
||||
return applicationPeriod;
|
||||
}
|
||||
|
||||
public void setApplicationPeriod(ApplicationPeriod applicationPeriod) {
|
||||
this.applicationPeriod = applicationPeriod;
|
||||
}
|
||||
|
||||
public ProjectClass getProjectClass() {
|
||||
return projectClass;
|
||||
}
|
||||
|
||||
public void setProjectClass(ProjectClass projectClass) {
|
||||
this.projectClass = projectClass;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public Project getProject() {
|
||||
return project;
|
||||
}
|
||||
|
||||
public void setProject(Project project) {
|
||||
this.project = project;
|
||||
}
|
||||
|
||||
public Watson getWatson() {
|
||||
return watson;
|
||||
}
|
||||
|
||||
public void setWatson(Watson watson) {
|
||||
this.watson = watson;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((authors == null) ? 0 : authors.hashCode());
|
||||
result = prime * result + ((project == null) ? 0 : project.hashCode());
|
||||
result =
|
||||
prime * result
|
||||
+ ((projectClass == null) ? 0 : projectClass.hashCode());
|
||||
result = prime * result + ((title == null) ? 0 : title.hashCode());
|
||||
result = prime * result + ((watson == null) ? 0 : watson.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
SupervisorIdea other = (SupervisorIdea) obj;
|
||||
System.out.println("Authors " + authors + " OTHER: " + other.authors);
|
||||
if (authors == null) {
|
||||
if (other.authors != null)
|
||||
return false;
|
||||
} else if (!authors.equals(other.authors))
|
||||
return false;
|
||||
if (project == null) {
|
||||
if (other.project != null)
|
||||
return false;
|
||||
} else if (!project.equals(other.project))
|
||||
return false;
|
||||
if (projectClass == null) {
|
||||
if (other.projectClass != null)
|
||||
return false;
|
||||
} else if (!projectClass.equals(other.projectClass))
|
||||
return false;
|
||||
if (title == null) {
|
||||
if (other.title != null)
|
||||
return false;
|
||||
} else if (!title.equals(other.title))
|
||||
return false;
|
||||
if (watson == null) {
|
||||
if (other.watson != null)
|
||||
return false;
|
||||
} else if (!watson.equals(other.watson))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public Set<Language> getLanguages() {
|
||||
return languages;
|
||||
}
|
||||
|
||||
public void setLanguages(Set<Language> languages) {
|
||||
this.languages = languages;
|
||||
}
|
||||
|
||||
public void setTaken(boolean taken) {
|
||||
this.taken = taken;
|
||||
}
|
||||
|
||||
public boolean isTaken() {
|
||||
return taken;
|
||||
}
|
||||
|
||||
public void setCreator(Employee creator) {
|
||||
this.creator = creator;
|
||||
}
|
||||
|
||||
public Employee getCreator() {
|
||||
return creator;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setRequirements(String requirements) {
|
||||
this.requirements = requirements;
|
||||
}
|
||||
|
||||
public String getRequirements() {
|
||||
return requirements;
|
||||
}
|
||||
|
||||
public SortedSet<Student> getAuthors() {
|
||||
return authors;
|
||||
}
|
||||
|
||||
public void setAuthors(SortedSet<Student> authors) {
|
||||
this.authors = authors;
|
||||
}
|
||||
|
||||
public void addAuthor(Student s){
|
||||
this.authors.add(s);
|
||||
}
|
||||
|
||||
public void removeAuthor(Student s){
|
||||
this.authors.remove(s);
|
||||
}
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
package se.su.dsv.scipro.springdata.repos;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.querydsl.QueryDslPredicateExecutor;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import se.su.dsv.scipro.match.dataobject.SupervisorIdea;
|
||||
|
||||
@Transactional(readOnly = true)
|
||||
public interface SupervisorIdeaRepo extends JpaRepository<SupervisorIdea, Long>, QueryDslPredicateExecutor<SupervisorIdea> {
|
||||
|
||||
//nothing here yet
|
||||
|
||||
}
|
54
src/main/java/se/su/dsv/scipro/springdata/serviceimpls/SupervisorIdeaServiceImpl.java
Normal file
54
src/main/java/se/su/dsv/scipro/springdata/serviceimpls/SupervisorIdeaServiceImpl.java
Normal file
@ -0,0 +1,54 @@
|
||||
package se.su.dsv.scipro.springdata.serviceimpls;
|
||||
|
||||
import java.util.SortedSet;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import org.apache.wicket.model.IModel;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import se.su.dsv.scipro.data.dataobjects.Employee;
|
||||
import se.su.dsv.scipro.data.dataobjects.Student;
|
||||
import se.su.dsv.scipro.data.dataobjects.User;
|
||||
import se.su.dsv.scipro.match.dao.interfaces.ApplicationPeriodDao;
|
||||
import se.su.dsv.scipro.match.dataobject.SupervisorIdea;
|
||||
import se.su.dsv.scipro.springdata.repos.SupervisorIdeaRepo;
|
||||
import se.su.dsv.scipro.springdata.services.SupervisorIdeaService;
|
||||
import se.su.dsv.scipro.springdata.services.SupervisorService;
|
||||
|
||||
@Service ( "supervisorIdeaService" )
|
||||
@Transactional ( readOnly = true )
|
||||
public class SupervisorIdeaServiceImpl extends AbstractQueryService<SupervisorIdea, Long> implements SupervisorIdeaService {
|
||||
|
||||
@Resource
|
||||
private SupervisorIdeaRepo supervisorIdeaRepo;
|
||||
@Resource
|
||||
private SupervisorService supervisorService;
|
||||
@Resource
|
||||
private ApplicationPeriodDao periodDao;
|
||||
|
||||
@Autowired
|
||||
public SupervisorIdeaServiceImpl(
|
||||
@Qualifier("supervisorIdeaRepo")
|
||||
SupervisorIdeaRepo supervisorIdeaRepo) {
|
||||
super(supervisorIdeaRepo, supervisorIdeaRepo);
|
||||
System.out.println("SupervisorIdeaServiceImpl instantiating...");
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional ( readOnly = false )
|
||||
public void saveIdeaFromForm(IModel<SupervisorIdea> model, User creator, SortedSet<Student> students) {
|
||||
SupervisorIdea idea = model.getObject();
|
||||
Employee supervisor = supervisorService.findByUser(creator);
|
||||
idea.setCreator(supervisor);
|
||||
idea.setApplicationPeriod(periodDao.load(2L));
|
||||
if(!students.isEmpty())
|
||||
idea.setAuthors(students);
|
||||
supervisorIdeaRepo.save(idea);
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
package se.su.dsv.scipro.springdata.services;
|
||||
|
||||
import java.util.SortedSet;
|
||||
|
||||
import org.apache.wicket.model.IModel;
|
||||
|
||||
import se.su.dsv.scipro.data.dataobjects.Student;
|
||||
import se.su.dsv.scipro.data.dataobjects.User;
|
||||
import se.su.dsv.scipro.match.dataobject.SupervisorIdea;
|
||||
|
||||
public interface SupervisorIdeaService extends GenericService<SupervisorIdea, Long>, QueryService<SupervisorIdea, Long> {
|
||||
|
||||
void saveIdeaFromForm(IModel<SupervisorIdea> model, User creator, SortedSet<Student> students);
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user