Merge remote-tracking branch 'origin/develop' into develop
This commit is contained in:
commit
bbd58ee4c9
src/main/java/se/su/dsv/scipro
@ -1,5 +1,6 @@
|
||||
package se.su.dsv.scipro.reusable;
|
||||
|
||||
import org.apache.wicket.ajax.AjaxRequestTarget;
|
||||
import se.su.dsv.scipro.data.dataobjects.Role;
|
||||
import se.su.dsv.wicket.components.AutoCompleteObjectField;
|
||||
|
||||
@ -16,6 +17,33 @@ public abstract class AbstractRoleAutoCompleteComponent<T extends Role> extends
|
||||
super(id, type);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Long getId(T s) {
|
||||
// return s.getId();
|
||||
if (s != null) {
|
||||
return s.getId();
|
||||
}
|
||||
else {
|
||||
return 0L;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Long convertId(String id) {
|
||||
// return Long.valueOf(id);
|
||||
if (id != null && !id.isEmpty()) {
|
||||
return Long.valueOf(id);
|
||||
}
|
||||
else {
|
||||
return 0L;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getName(T item) {
|
||||
return item.getNameAsString();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Renderer<T> getListItemRenderer() {
|
||||
return new Renderer<T>() {
|
||||
@ -32,4 +60,23 @@ public abstract class AbstractRoleAutoCompleteComponent<T extends Role> extends
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onNewSelection(AjaxRequestTarget pTarget, T newSelection) {
|
||||
if (newSelection != null) {
|
||||
if (pTarget != null) {
|
||||
action(pTarget, newSelection);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Override this method for actions to be performed when an object is selected.
|
||||
*
|
||||
* @param pTarget ajax
|
||||
* @param newSelection employee
|
||||
*/
|
||||
protected abstract void action(AjaxRequestTarget pTarget, T newSelection);
|
||||
|
||||
}
|
||||
|
@ -22,73 +22,75 @@ import java.util.SortedSet;
|
||||
*/
|
||||
public abstract class AddRemoveStudentsPanel extends Panel {
|
||||
|
||||
private static final long serialVersionUID = -7690822667493306854L;
|
||||
private SortedSet<Student> studentSet;
|
||||
private WebMarkupContainer wmc;
|
||||
private ListView<Student> studentListView;
|
||||
private Label emptyLabel;
|
||||
private AuthorAutoComplete addnew;
|
||||
private static final long serialVersionUID = -7690822667493306854L;
|
||||
private SortedSet<Student> studentSet;
|
||||
private WebMarkupContainer wmc;
|
||||
private ListView<Student> studentListView;
|
||||
private Label emptyLabel;
|
||||
private AuthorAutoComplete addnew;
|
||||
|
||||
/**
|
||||
* Override this method to use AJAX
|
||||
* @param target
|
||||
*/
|
||||
public abstract void onUpdate(AjaxRequestTarget target);
|
||||
|
||||
public AddRemoveStudentsPanel(String id, final SortedSet<Student> studentSet) {
|
||||
super(id);
|
||||
/**
|
||||
* Override this method to use AJAX
|
||||
*
|
||||
* @param target
|
||||
*/
|
||||
public abstract void onUpdate(AjaxRequestTarget target);
|
||||
|
||||
this.studentSet = studentSet;
|
||||
|
||||
wmc = new WebMarkupContainer("wmc");
|
||||
wmc.setOutputMarkupId(true);
|
||||
add(wmc);
|
||||
public AddRemoveStudentsPanel(String id, final SortedSet<Student> studentSet) {
|
||||
super(id);
|
||||
|
||||
wmc.add(emptyLabel = new Label("emptyLabel", "No students"));
|
||||
emptyLabel.setVisible(studentSet.isEmpty());
|
||||
emptyLabel.setOutputMarkupId(true);
|
||||
this.studentSet = studentSet;
|
||||
|
||||
wmc.add(studentListView = new ListView<Student>("listview", new ArrayList(studentSet)) {
|
||||
protected void populateItem(ListItem item) {
|
||||
final Student s = (Student) item.getModelObject();
|
||||
item.add(new Label("name", s.getNameAsString()));
|
||||
item.add(new AjaxLink("deleteLink") {
|
||||
private static final long serialVersionUID = -5174472375922201597L;
|
||||
@Override
|
||||
public void onClick(AjaxRequestTarget target) {
|
||||
studentSet.remove(s);
|
||||
studentListView.setList(new ArrayList(studentSet));
|
||||
target.addComponent(wmc);
|
||||
emptyLabel.setVisible(studentSet.isEmpty());
|
||||
target.addComponent(emptyLabel);
|
||||
onUpdate(target);
|
||||
}
|
||||
}.add(new ImageObject("deleteImage", ImageObject.SIXTEEN + ImageObject.DELETE).setVisible(isEditable())));
|
||||
}
|
||||
});
|
||||
wmc = new WebMarkupContainer("wmc");
|
||||
wmc.setOutputMarkupId(true);
|
||||
add(wmc);
|
||||
|
||||
wmc.add(addnew = new AuthorAutoComplete("addnew") {
|
||||
@Override
|
||||
public void action(AjaxRequestTarget pTarget, Student newSelection) {
|
||||
wmc.add(emptyLabel = new Label("emptyLabel", "No students"));
|
||||
emptyLabel.setVisible(studentSet.isEmpty());
|
||||
emptyLabel.setOutputMarkupId(true);
|
||||
|
||||
setSelection(null);
|
||||
wmc.add(studentListView = new ListView<Student>("listview", new ArrayList(studentSet)) {
|
||||
protected void populateItem(ListItem item) {
|
||||
final Student s = (Student) item.getModelObject();
|
||||
item.add(new Label("name", s.getNameAsString()));
|
||||
item.add(new AjaxLink("deleteLink") {
|
||||
private static final long serialVersionUID = -5174472375922201597L;
|
||||
|
||||
studentSet.add(newSelection);
|
||||
studentListView.setList(new ArrayList(studentSet));
|
||||
pTarget.addComponent(wmc);
|
||||
pTarget.addComponent(addnew);
|
||||
emptyLabel.setVisible(studentSet.isEmpty());
|
||||
pTarget.addComponent(emptyLabel);
|
||||
onUpdate(pTarget);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public SortedSet<Student> getStudentSet(){
|
||||
return studentSet;
|
||||
}
|
||||
@Override
|
||||
public void onClick(AjaxRequestTarget target) {
|
||||
studentSet.remove(s);
|
||||
studentListView.setList(new ArrayList(studentSet));
|
||||
target.addComponent(wmc);
|
||||
emptyLabel.setVisible(studentSet.isEmpty());
|
||||
target.addComponent(emptyLabel);
|
||||
onUpdate(target);
|
||||
}
|
||||
}.add(new ImageObject("deleteImage", ImageObject.SIXTEEN + ImageObject.DELETE).setVisible(isEditable())));
|
||||
}
|
||||
});
|
||||
|
||||
private boolean isEditable(){
|
||||
return SciProSession.get().authorizedForRole(Roles.SYSADMIN);
|
||||
}
|
||||
wmc.add(addnew = new AuthorAutoComplete("addnew") {
|
||||
@Override
|
||||
public void action(AjaxRequestTarget pTarget, Student newSelection) {
|
||||
|
||||
setSelection(null);
|
||||
|
||||
studentSet.add(newSelection);
|
||||
studentListView.setList(new ArrayList(studentSet));
|
||||
pTarget.addComponent(wmc);
|
||||
pTarget.addComponent(addnew);
|
||||
emptyLabel.setVisible(studentSet.isEmpty());
|
||||
pTarget.addComponent(emptyLabel);
|
||||
onUpdate(pTarget);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public SortedSet<Student> getStudentSet() {
|
||||
return studentSet;
|
||||
}
|
||||
|
||||
private boolean isEditable() {
|
||||
return SciProSession.get().authorizedForRole(Roles.SYSADMIN);
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
package se.su.dsv.scipro.reusable;
|
||||
|
||||
import org.apache.wicket.ajax.AjaxRequestTarget;
|
||||
import org.apache.wicket.spring.injection.annot.SpringBean;
|
||||
import se.su.dsv.scipro.data.dataobjects.Student;
|
||||
import se.su.dsv.scipro.match.dao.interfaces.AuthorDao;
|
||||
@ -37,31 +36,12 @@ public abstract class AuthorAutoComplete extends AbstractRoleAutoCompleteCompone
|
||||
super(id, Student.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Long getId(Student s) {
|
||||
// return s.getId();
|
||||
if (s != null) {
|
||||
return s.getId();
|
||||
} else {
|
||||
return 0L;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Long convertId(String id) {
|
||||
// return Long.valueOf(id);
|
||||
if (id != null && !id.isEmpty()) {
|
||||
return Long.valueOf(id);
|
||||
} else {
|
||||
return 0L;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Student loadObject(Long id) {
|
||||
if (id != null && id != 0L) {
|
||||
return authorDao.load(id);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@ -71,21 +51,4 @@ public abstract class AuthorAutoComplete extends AbstractRoleAutoCompleteCompone
|
||||
return authorDao.getAutoCompleteAuthors(input, 6).iterator();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onNewSelection(AjaxRequestTarget pTarget, Student newSelection) {
|
||||
super.onNewSelection(pTarget, newSelection);
|
||||
if (newSelection != null) {
|
||||
if (pTarget != null) {
|
||||
action(pTarget, newSelection);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Override this method for actions to be performed when an object is selected.
|
||||
*
|
||||
* @param pTarget ajax
|
||||
* @param newSelection employee
|
||||
*/
|
||||
protected abstract void action(AjaxRequestTarget pTarget, Student newSelection);
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
package se.su.dsv.scipro.reusable;
|
||||
|
||||
import org.apache.wicket.ajax.AjaxRequestTarget;
|
||||
import org.apache.wicket.spring.injection.annot.SpringBean;
|
||||
import se.su.dsv.scipro.data.dataobjects.Employee;
|
||||
import se.su.dsv.scipro.match.dao.interfaces.SupervisorDao;
|
||||
@ -37,29 +36,12 @@ public abstract class EmployeeAutoComplete extends AbstractRoleAutoCompleteCompo
|
||||
super(id, Employee.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Long getId(Employee e) {
|
||||
if (e != null) {
|
||||
return e.getId();
|
||||
} else {
|
||||
return 0L;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Long convertId(String id) {
|
||||
if (id != null && !id.isEmpty()) {
|
||||
return Long.valueOf(id);
|
||||
} else {
|
||||
return 0L;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Employee loadObject(Long id) {
|
||||
if (id != null && id != 0L) {
|
||||
return supervisorDao.load(id);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@ -69,21 +51,5 @@ public abstract class EmployeeAutoComplete extends AbstractRoleAutoCompleteCompo
|
||||
return supervisorDao.getAutoCompleteCapableSupervisors(input, 6).iterator();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onNewSelection(AjaxRequestTarget pTarget, Employee newSelection) {
|
||||
super.onNewSelection(pTarget, newSelection);
|
||||
if (newSelection != null) {
|
||||
if (pTarget != null) {
|
||||
action(pTarget, newSelection);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Override this method for actions to be performed when an object is selected.
|
||||
*
|
||||
* @param pTarget ajax
|
||||
* @param newSelection employee
|
||||
*/
|
||||
protected abstract void action(AjaxRequestTarget pTarget, Employee newSelection);
|
||||
}
|
||||
|
||||
|
@ -7,13 +7,12 @@ import java.util.Set;
|
||||
|
||||
import javax.mail.Address;
|
||||
import javax.mail.MessagingException;
|
||||
import javax.mail.SendFailedException;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.sun.mail.smtp.SMTPSendFailedException;
|
||||
|
||||
import se.su.dsv.scipro.data.dao.interfaces.GeneralSystemSettingsDao;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.MailEventDao;
|
||||
import se.su.dsv.scipro.data.dataobjects.MailEvent;
|
||||
@ -65,7 +64,7 @@ public class MailEventWorker extends AbstractWorker {
|
||||
replyToEmails[i] = u.getEmailAddress();
|
||||
i++;
|
||||
}
|
||||
|
||||
|
||||
if( generalSystemSettingsDao.getGeneralSystemSettingsInstance().isMailNotifications() ){ //If false, mail-events "vanish"
|
||||
logger.debug("Sending mail notification to: "+recipients);
|
||||
mail.mail(fromName, fromEmail, recipientsEmails, replyToEmails, subject, messageBody, false);
|
||||
@ -75,19 +74,26 @@ public class MailEventWorker extends AbstractWorker {
|
||||
|
||||
this.commitTransaction();
|
||||
|
||||
} catch(SMTPSendFailedException e){
|
||||
} catch(SendFailedException e){
|
||||
// We need to catch this exception for the use case when one or
|
||||
// more of the recipients are invalid, to make sure we still
|
||||
// send the mail to the valid recipients, and delete the mail
|
||||
// event to prevent spamming.
|
||||
// event to prevent spamming.
|
||||
logger.info("Could not send mail to all of the recipients, more info:");
|
||||
if(e.getInvalidAddresses()!=null){
|
||||
for(Address a : e.getInvalidAddresses()) {
|
||||
logger.info("Message could not be sent to the following invalid address: "+a.toString());
|
||||
}
|
||||
}
|
||||
if(e.getValidSentAddresses()!=null){
|
||||
for(Address a : e.getValidSentAddresses()){
|
||||
logger.info("Message have been sent to the following valid address: "+a.toString());
|
||||
}
|
||||
}
|
||||
if(e.getValidUnsentAddresses()!=null){
|
||||
for(Address a : e.getValidUnsentAddresses()){
|
||||
logger.info("Message have not been sent to the following valid address: "+a.toString());
|
||||
}
|
||||
}
|
||||
mailEvent = mailEventDao.reLoad(mailEvent);
|
||||
mailEventDao.delete(mailEvent);
|
||||
|
Loading…
x
Reference in New Issue
Block a user