use of fi.otavanopisto.pyramus.domainmodel.base.Tag in project pyramus by otavanopisto.
the class SchoolController method updateSchoolTags.
public synchronized School updateSchoolTags(School school, List<String> tags) {
Set<String> newTags = new HashSet<>(tags);
Set<Tag> schoolTags = new HashSet<>(school.getTags());
for (Tag schoolTag : schoolTags) {
if (!newTags.contains(schoolTag.getText())) {
removeSchoolTag(school, schoolTag);
}
newTags.remove(schoolTag.getText());
}
for (String newTag : newTags) {
createSchoolTag(school, newTag);
}
return school;
}
use of fi.otavanopisto.pyramus.domainmodel.base.Tag in project pyramus by otavanopisto.
the class StudentController method deleteStudent.
public void deleteStudent(Student student) {
Set<Tag> tags = new HashSet<>(student.getTags());
for (Tag tag : tags) {
studentDAO.removeTag(student, tag);
}
User defaultUser = student.getPerson().getDefaultUser();
boolean newDefaultUser = false;
Long personId = student.getPerson().getId();
if (defaultUser != null) {
if (defaultUser.getId().equals(student.getId())) {
newDefaultUser = true;
personDAO.updateDefaultUser(student.getPerson(), null);
}
}
student = studentDAO.findById(student.getId());
studentDAO.delete(student);
// Do a best guess of the new default user
if (newDefaultUser) {
Person person = personDAO.findById(personId);
Student latestStudent = person.getLatestStudent();
if (latestStudent != null)
personDAO.updateDefaultUser(person, latestStudent);
else {
if (!person.getStudents().isEmpty())
personDAO.updateDefaultUser(person, person.getStudents().get(0));
else if (!person.getStaffMembers().isEmpty())
personDAO.updateDefaultUser(person, person.getStaffMembers().get(0));
}
}
}
use of fi.otavanopisto.pyramus.domainmodel.base.Tag in project pyramus by otavanopisto.
the class StudentGroupController method createStudentGroupTag.
public Tag createStudentGroupTag(StudentGroup studentGroup, String text) {
Tag tag = tagDAO.findByText(text);
if (tag == null) {
tag = tagDAO.create(text);
}
studentGroup.addTag(tag);
return tag;
}
use of fi.otavanopisto.pyramus.domainmodel.base.Tag in project pyramus by otavanopisto.
the class ModuleController method createModuleTag.
/* Tags */
public Tag createModuleTag(Module module, String text) {
Tag tag = tagDAO.findByText(text);
if (tag == null) {
tag = tagDAO.create(text);
}
module.addTag(tag);
return tag;
}
use of fi.otavanopisto.pyramus.domainmodel.base.Tag in project pyramus by otavanopisto.
the class UserEntityFactory method buildFromDomainObject.
public UserEntity buildFromDomainObject(Object domainObject) {
StaffMember user = (StaffMember) domainObject;
Set<String> emails = new HashSet<>();
for (Email email : user.getContactInfo().getEmails()) emails.add(email.getAddress());
int i = 0;
String[] tags = new String[user.getTags().size()];
for (Tag tag : user.getTags()) {
tags[i++] = tag.getText();
}
// , user.getExternalId(), user.getAuthProvider(), user.getRole().name());
return new UserEntity(user.getId(), emails.toArray(new String[0]), user.getFirstName(), user.getLastName(), tags);
}
Aggregations