Merge branch 'develop' of ssh://git.dsv.su.se/git/scipro/scipro into develop
This commit is contained in:
commit
7e58fb23be
resources/db_update_scripts
src/main/java/se/su/dsv/scipro
admin
pages/match
panels/match
components
data
dao
interfaces
jpa
dataobjects
match
dao
dataprovider
project/panels
@ -1,5 +1,6 @@
|
||||
ALTER TABLE `worker_data` ADD `lastSuccessfulRun` DATETIME NOT NULL DEFAULT '2011-11-28 13:33:37' AFTER `lastRun`;
|
||||
ALTER TABLE `checklist_template` ADD `templateNumber` INT NOT NULL DEFAULT '999';
|
||||
ALTER TABLE `worker_data` ADD `lastSuccessfulRun` DATETIME NULL DEFAULT '2011-11-28 01:00:00' AFTER `lastRun`;
|
||||
|
||||
ALTER TABLE `project_class_settings` ADD `minAuthors` int(11) NOT NULL DEFAULT '1';
|
||||
ALTER TABLE `project_class_settings` ADD `maxAuthors` int(11) NOT NULL DEFAULT '2';
|
||||
|
||||
@ -271,4 +272,4 @@ CREATE TABLE `checklist_checklist_category` (
|
||||
KEY `FK54F86EB01F327355` (`checklist_id`),
|
||||
CONSTRAINT `FK54F86EB01F327355` FOREIGN KEY (`checklist_id`) REFERENCES `checklist` (`id`),
|
||||
CONSTRAINT `FK54F86EB08725F1D` FOREIGN KEY (`categories_id`) REFERENCES `checklist_category` (`id`)
|
||||
) ENGINE=InnoDB;
|
||||
) ENGINE=InnoDB;
|
||||
|
@ -3,6 +3,12 @@
|
||||
xmlns:wicket="http://wicket.apache.org/dtds.data/wicket-xhtml1.4-strict.dtd">
|
||||
<body>
|
||||
<wicket:extend>
|
||||
<div><b>Unit</b></div>
|
||||
<div wicket:id="manageUnitKeyword"></div>
|
||||
<div><b>Area</b></div>
|
||||
<div wicket:id="manageAreaKeyword"></div>
|
||||
<div><b>Word</b></div>
|
||||
<div wicket:id="manageWordKeyword"></div>
|
||||
</wicket:extend>
|
||||
</body>
|
||||
</html>
|
@ -1,13 +1,22 @@
|
||||
package se.su.dsv.scipro.admin.pages.match;
|
||||
|
||||
import org.apache.wicket.PageParameters;
|
||||
import org.apache.wicket.spring.injection.annot.SpringBean;
|
||||
|
||||
import se.su.dsv.scipro.admin.pages.AbstractAdminMatchPage;
|
||||
import se.su.dsv.scipro.admin.panels.match.ManageKeywordPanel;
|
||||
import se.su.dsv.scipro.match.dao.interfaces.KeywordTypeDao;
|
||||
|
||||
public class AdminKeywordPage extends AbstractAdminMatchPage {
|
||||
|
||||
@SpringBean
|
||||
private KeywordTypeDao keywordTypeDao;
|
||||
|
||||
public AdminKeywordPage(PageParameters pp) {
|
||||
super(pp);
|
||||
add(new ManageKeywordPanel("manageUnitKeyword", keywordTypeDao.findByType(KeywordTypeDao.TYPE.UNIT)));
|
||||
add(new ManageKeywordPanel("manageAreaKeyword", keywordTypeDao.findByType(KeywordTypeDao.TYPE.RESEARCH_AREA)));
|
||||
add(new ManageKeywordPanel("manageWordKeyword", keywordTypeDao.findByType(KeywordTypeDao.TYPE.REGULAR)));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,14 @@
|
||||
<!DOCTYPE html>
|
||||
<html
|
||||
xmlns:wicket="http://wicket.apache.org/dtds.data/wicket-xhtml1.4-strict.dtd">
|
||||
<body>
|
||||
<wicket:panel>
|
||||
<form wicket:id="editKeywordForm">
|
||||
<div><b>Name: </b><input type="text" wicket:id="name"></input></div>
|
||||
<div><b>Type: </b><select wicket:id="keywordTypeSelector"></select></div>
|
||||
<div><b>Active: </b><input type="checkbox" wicket:id="activeCheckbox" /></div>
|
||||
<div><input wicket:id="saveButton" type="submit" value="Save" /></div>
|
||||
</form>
|
||||
</wicket:panel>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,71 @@
|
||||
package se.su.dsv.scipro.admin.panels.match;
|
||||
|
||||
import org.apache.wicket.markup.html.form.Button;
|
||||
import org.apache.wicket.markup.html.form.CheckBox;
|
||||
import org.apache.wicket.markup.html.form.Form;
|
||||
import org.apache.wicket.markup.html.form.TextField;
|
||||
import org.apache.wicket.markup.html.panel.Panel;
|
||||
import org.apache.wicket.model.IModel;
|
||||
import org.apache.wicket.model.Model;
|
||||
import org.apache.wicket.model.PropertyModel;
|
||||
import org.apache.wicket.spring.injection.annot.SpringBean;
|
||||
|
||||
import se.su.dsv.scipro.components.InverseBooleanModel;
|
||||
import se.su.dsv.scipro.components.KeywordTypeSelector;
|
||||
import se.su.dsv.scipro.match.dao.interfaces.KeywordDao;
|
||||
import se.su.dsv.scipro.match.dataobject.Keyword;
|
||||
import se.su.dsv.scipro.match.dataobject.KeywordType;
|
||||
|
||||
public class CreateKeywordPanel extends Panel {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@SpringBean
|
||||
private KeywordDao keywordDao;
|
||||
|
||||
public CreateKeywordPanel(String str, KeywordType keywordType) {
|
||||
super(str);
|
||||
Keyword keyword = new Keyword();
|
||||
keyword.setType(keywordType);
|
||||
add(new EditKeywordForm("editKeywordForm", new Model<Keyword>(keyword)));
|
||||
}
|
||||
|
||||
private class EditKeywordForm extends Form<Keyword>{
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private KeywordTypeSelector keywordTypeSelector;
|
||||
private TextField<String> name;
|
||||
private CheckBox activeCheckbox;
|
||||
|
||||
public EditKeywordForm(String id, final IModel<Keyword> model) {
|
||||
super(id, model);
|
||||
this.setOutputMarkupId(true);
|
||||
|
||||
name = new TextField<String>("name",
|
||||
new PropertyModel<String>(model, "keyword"));
|
||||
|
||||
keywordTypeSelector = new KeywordTypeSelector("keywordTypeSelector",
|
||||
new PropertyModel<KeywordType>(model, "type"));
|
||||
|
||||
activeCheckbox = new CheckBox("activeCheckbox",
|
||||
new InverseBooleanModel(new PropertyModel<Boolean>(model, "deleted")));
|
||||
|
||||
activeCheckbox.setOutputMarkupId(true);
|
||||
|
||||
Button saveButton = new Button("saveButton");
|
||||
|
||||
add(saveButton);
|
||||
add(name);
|
||||
add(keywordTypeSelector);
|
||||
add(activeCheckbox);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onSubmit() {
|
||||
IModel<Keyword> model = getModel();
|
||||
model.setObject(keywordDao.save(model.getObject()));
|
||||
super.onSubmit();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
<!DOCTYPE html>
|
||||
<html
|
||||
xmlns:wicket="http://wicket.apache.org/dtds.data/wicket-xhtml1.4-strict.dtd">
|
||||
<body>
|
||||
<wicket:panel>
|
||||
<form wicket:id="editKeywordForm">
|
||||
<div><b>Name: </b><input type="text" wicket:id="name"></input></div>
|
||||
<div><b>Type: </b><select wicket:id="keywordTypeSelector"></select></div>
|
||||
<div><b>Active: </b><input type="checkbox" wicket:id="activeCheckbox" /></div>
|
||||
<div><input wicket:id="saveButton" type="submit" value="Save" /></div>
|
||||
</form>
|
||||
</wicket:panel>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,68 @@
|
||||
package se.su.dsv.scipro.admin.panels.match;
|
||||
|
||||
import org.apache.wicket.markup.html.form.Button;
|
||||
import org.apache.wicket.markup.html.form.CheckBox;
|
||||
import org.apache.wicket.markup.html.form.Form;
|
||||
import org.apache.wicket.markup.html.form.TextField;
|
||||
import org.apache.wicket.markup.html.panel.Panel;
|
||||
import org.apache.wicket.model.IModel;
|
||||
import org.apache.wicket.model.PropertyModel;
|
||||
import org.apache.wicket.spring.injection.annot.SpringBean;
|
||||
|
||||
import se.su.dsv.scipro.components.InverseBooleanModel;
|
||||
import se.su.dsv.scipro.components.KeywordTypeSelector;
|
||||
import se.su.dsv.scipro.match.dao.interfaces.KeywordDao;
|
||||
import se.su.dsv.scipro.match.dataobject.Keyword;
|
||||
import se.su.dsv.scipro.match.dataobject.KeywordType;
|
||||
|
||||
public class EditKeywordPanel extends Panel {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@SpringBean
|
||||
private KeywordDao keywordDao;
|
||||
|
||||
public EditKeywordPanel(String str, IModel<Keyword> model) {
|
||||
super(str, model);
|
||||
add(new EditKeywordForm("editKeywordForm", model));
|
||||
}
|
||||
|
||||
private class EditKeywordForm extends Form<Keyword>{
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private KeywordTypeSelector keywordTypeSelector;
|
||||
private TextField<String> name;
|
||||
private CheckBox activeCheckbox;
|
||||
|
||||
public EditKeywordForm(String id, final IModel<Keyword> model) {
|
||||
super(id, model);
|
||||
this.setOutputMarkupId(true);
|
||||
|
||||
name = new TextField<String>("name",
|
||||
new PropertyModel<String>(model, "keyword"));
|
||||
|
||||
keywordTypeSelector = new KeywordTypeSelector("keywordTypeSelector",
|
||||
new PropertyModel<KeywordType>(model, "type"));
|
||||
|
||||
activeCheckbox = new CheckBox("activeCheckbox",
|
||||
new InverseBooleanModel(new PropertyModel<Boolean>(model, "deleted")));
|
||||
|
||||
activeCheckbox.setOutputMarkupId(true);
|
||||
|
||||
Button saveButton = new Button("saveButton");
|
||||
|
||||
add(saveButton);
|
||||
add(name);
|
||||
add(keywordTypeSelector);
|
||||
add(activeCheckbox);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onSubmit() {
|
||||
IModel<Keyword> model = getModel();
|
||||
model.setObject(keywordDao.save(model.getObject()));
|
||||
super.onSubmit();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
<!DOCTYPE html>
|
||||
<html
|
||||
xmlns:wicket="http://wicket.apache.org/dtds.data/wicket-xhtml1.4-strict.dtd">
|
||||
<body>
|
||||
<wicket:panel>
|
||||
<div wicket:id="editDialog">
|
||||
<div wicket:id="dialogContent"></div>
|
||||
</div>
|
||||
<a href=# wicket:id="createLink"><img
|
||||
wicket:id="addIcon" alt="" />Create Keyword</a>
|
||||
<form>
|
||||
<table wicket:id="table" class="rounded-corner">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="rounded-left-top">Name</th><th>Type</th><th>Active</th><th class="rounded-right-top">Edit</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr wicket:id="keywordsDataView">
|
||||
<td wicket:id="name"></td>
|
||||
<td wicket:id="type"></td>
|
||||
<td><a href="#" wicket:id="activeLink">
|
||||
<img wicket:id="activeIcon" /></a></td>
|
||||
<td><a href="#" wicket:id="editLink">
|
||||
<img wicket:id="editIcon" /></a></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr>
|
||||
<td colspan="5" class="rounded-foot"> </td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
</form>
|
||||
</wicket:panel>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,126 @@
|
||||
package se.su.dsv.scipro.admin.panels.match;
|
||||
|
||||
import org.apache.wicket.ajax.AjaxRequestTarget;
|
||||
import org.apache.wicket.ajax.markup.html.AjaxLink;
|
||||
import org.apache.wicket.markup.html.WebMarkupContainer;
|
||||
import org.apache.wicket.markup.html.basic.Label;
|
||||
import org.apache.wicket.markup.html.panel.EmptyPanel;
|
||||
import org.apache.wicket.markup.html.panel.Panel;
|
||||
import org.apache.wicket.markup.repeater.Item;
|
||||
import org.apache.wicket.markup.repeater.data.DataView;
|
||||
import org.apache.wicket.model.IModel;
|
||||
import org.apache.wicket.model.Model;
|
||||
import org.apache.wicket.model.PropertyModel;
|
||||
import org.apache.wicket.spring.injection.annot.SpringBean;
|
||||
import org.odlabs.wiquery.ui.dialog.Dialog;
|
||||
|
||||
import se.su.dsv.scipro.components.LazyDeleteAjaxLink;
|
||||
import se.su.dsv.scipro.icons.ImageObject;
|
||||
import se.su.dsv.scipro.match.dao.interfaces.KeywordDao;
|
||||
import se.su.dsv.scipro.match.dataobject.Keyword;
|
||||
import se.su.dsv.scipro.match.dataobject.KeywordType;
|
||||
import se.su.dsv.scipro.match.dataprovider.KeywordsDataProvider;
|
||||
|
||||
public class ManageKeywordPanel extends Panel {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@SpringBean
|
||||
private KeywordDao keywordDao;
|
||||
|
||||
private KeywordsDataProvider keywordsDataProvider;
|
||||
|
||||
private Dialog dialog;
|
||||
private final WebMarkupContainer tableContainer;
|
||||
private final DataView<Keyword> keywordsDataView;
|
||||
|
||||
public ManageKeywordPanel(String str, final KeywordType keywordType) {
|
||||
super(str);
|
||||
|
||||
AjaxLink<Void> createLink = new AjaxLink<Void>("createLink"){
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
public void onClick(AjaxRequestTarget target) {
|
||||
dialog.replace(new CreateKeywordPanel("dialogContent", keywordType));
|
||||
target.addComponent(dialog);
|
||||
dialog.setTitle("Add Keyword...");
|
||||
dialog.open(target);
|
||||
}
|
||||
};
|
||||
createLink.add(new ImageObject("addIcon", ImageObject.SIXTEEN + ImageObject.ADD));
|
||||
|
||||
dialog = new Dialog("editDialog");
|
||||
dialog.setModal(true);
|
||||
dialog.setAutoOpen(false);
|
||||
dialog.setWidth(500);
|
||||
dialog.setHeight(500);
|
||||
dialog.add(new EmptyPanel("dialogContent"));
|
||||
dialog.setOutputMarkupId(true);
|
||||
|
||||
keywordsDataProvider = new KeywordsDataProvider(null, keywordType);
|
||||
|
||||
tableContainer = new WebMarkupContainer("table");
|
||||
tableContainer.setOutputMarkupId(true);
|
||||
|
||||
keywordsDataView = new DataView<Keyword>("keywordsDataView", keywordsDataProvider) {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
protected void populateItem(final Item<Keyword> item) {
|
||||
item.setOutputMarkupId(true);
|
||||
Keyword keyword = item.getModelObject();
|
||||
|
||||
final ImageObject editIcon = new ImageObject("editIcon", ImageObject.SIXTEEN + ImageObject.EDIT);
|
||||
|
||||
final AjaxLink<Void> editLink = new AjaxLink<Void>("editLink") {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
protected void onInitialize() {
|
||||
super.onInitialize();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(AjaxRequestTarget target) {
|
||||
target.addComponent(dialog);
|
||||
dialog.setTitle("Edit keyword...");
|
||||
dialog.replace(new EditKeywordPanel("dialogContent", new Model<Keyword>(item.getModelObject())));
|
||||
dialog.open(target);
|
||||
}
|
||||
};
|
||||
editLink.add(editIcon);
|
||||
|
||||
LazyDeleteAjaxLink activeLink = new LazyDeleteAjaxLink("activeLink",
|
||||
new PropertyModel<Boolean>(item.getModel(), "deleted")) {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
public void onClick(AjaxRequestTarget target) {
|
||||
super.onClick(target);
|
||||
IModel<Keyword> model = item.getModel();
|
||||
model.setObject(keywordDao.save(model.getObject()));
|
||||
target.addComponent(tableContainer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIconId() {
|
||||
return "activeIcon";
|
||||
}
|
||||
};
|
||||
|
||||
item.add(new Label("name", new Model<String>(keyword.getKeyword())));
|
||||
item.add(new Label("type", new Model<String>(keyword.getType().getName())));
|
||||
item.add(editLink);
|
||||
item.add(activeLink);
|
||||
}
|
||||
|
||||
};
|
||||
tableContainer.add(keywordsDataView);
|
||||
add(createLink);
|
||||
add(dialog);
|
||||
add(tableContainer);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
package se.su.dsv.scipro.components;
|
||||
|
||||
import org.apache.wicket.model.IModel;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* A model that inverse the boolean model object
|
||||
* </p>
|
||||
* <p>
|
||||
* activeCheckbox = new CheckBox("activeCheckbox",
|
||||
* new InverseBooleanModel(new PropertyModel<Boolean>(model, "deleted")));
|
||||
* </p>
|
||||
* @author Marcus Höjvall
|
||||
*/
|
||||
public class InverseBooleanModel implements IModel<Boolean> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private final IModel<Boolean> delegate;
|
||||
|
||||
public InverseBooleanModel(IModel<Boolean> delegate) {
|
||||
this.delegate = delegate;
|
||||
}
|
||||
|
||||
public void detach() {
|
||||
delegate.detach();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean getObject() {
|
||||
return !delegate.getObject();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setObject(Boolean bool) {
|
||||
delegate.setObject(!bool);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,56 @@
|
||||
package se.su.dsv.scipro.components;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.wicket.markup.html.form.ChoiceRenderer;
|
||||
import org.apache.wicket.markup.html.form.DropDownChoice;
|
||||
import org.apache.wicket.model.IModel;
|
||||
import org.apache.wicket.model.LoadableDetachableModel;
|
||||
import org.apache.wicket.model.Model;
|
||||
import org.apache.wicket.spring.injection.annot.SpringBean;
|
||||
|
||||
import se.su.dsv.scipro.match.dao.interfaces.KeywordTypeDao;
|
||||
import se.su.dsv.scipro.match.dataobject.KeywordType;
|
||||
|
||||
public class KeywordTypeSelector extends DropDownChoice<KeywordType> {
|
||||
|
||||
private static final long serialVersionUID = -6679286933462794113L;
|
||||
@SpringBean
|
||||
KeywordTypeDao keywordTypeDao;
|
||||
|
||||
public KeywordTypeSelector(String id) {
|
||||
super(id);
|
||||
initChoices();
|
||||
KeywordType defaultKeywordType = getChoices().get(0);
|
||||
setModel(new Model<KeywordType>(defaultKeywordType));
|
||||
}
|
||||
|
||||
public KeywordTypeSelector(String id, IModel<KeywordType> model) {
|
||||
super(id);
|
||||
initChoices();
|
||||
setModel(model);
|
||||
}
|
||||
|
||||
private void initChoices() {
|
||||
|
||||
ChoiceRenderer<KeywordType> cr = new ChoiceRenderer<KeywordType>("name");
|
||||
this.setChoiceRenderer(cr);
|
||||
|
||||
LoadableDetachableModel<List<KeywordType>> choices =
|
||||
new LoadableDetachableModel<List<KeywordType>>() {
|
||||
|
||||
private static final long serialVersionUID = 5284078816313022475L;
|
||||
|
||||
@Override
|
||||
protected List<KeywordType> load() {
|
||||
return keywordTypeDao.findAll();
|
||||
}
|
||||
};
|
||||
|
||||
setChoices(choices);
|
||||
setNullValid(false);
|
||||
setRequired(true);
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
<!DOCTYPE html>
|
||||
<html xmlns:wicket="http://wicket.apache.org/dtds.data/wicket-xhtml1.4-strict.dtd">
|
||||
<body>
|
||||
<wicket:panel>
|
||||
<img wicket:id="activeIcon" />
|
||||
</wicket:panel>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,52 @@
|
||||
package se.su.dsv.scipro.components;
|
||||
|
||||
import org.apache.wicket.ajax.AjaxRequestTarget;
|
||||
import org.apache.wicket.ajax.markup.html.AjaxLink;
|
||||
import org.apache.wicket.model.IModel;
|
||||
|
||||
import se.su.dsv.scipro.icons.ImageObject;
|
||||
|
||||
public abstract class LazyDeleteAjaxLink extends AjaxLink<Boolean> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private ImageObject activeIcon;
|
||||
private final IModel<Boolean> model;
|
||||
|
||||
public LazyDeleteAjaxLink(String id, final IModel<Boolean> model) {
|
||||
super(id, model);
|
||||
|
||||
this.model = model;
|
||||
activeIcon = getActiveIcon(getIconId());
|
||||
|
||||
add(activeIcon);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onBeforeRender() {
|
||||
activeIcon = getActiveIcon(getIconId());
|
||||
super.onBeforeRender();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(AjaxRequestTarget target) {
|
||||
modelChanged();
|
||||
boolean bool = model.getObject();
|
||||
model.setObject(!bool);
|
||||
}
|
||||
|
||||
private ImageObject getActiveIcon(String id){
|
||||
ImageObject tmpIcon;
|
||||
|
||||
if(model.getObject()){
|
||||
tmpIcon = new ImageObject(id, ImageObject.SIXTEEN + ImageObject.DELETE);
|
||||
}else{
|
||||
tmpIcon = new ImageObject(id, ImageObject.SIXTEEN + ImageObject.CHECK);
|
||||
}
|
||||
|
||||
return tmpIcon;
|
||||
}
|
||||
|
||||
public abstract String getIconId();
|
||||
|
||||
}
|
@ -19,6 +19,8 @@ public interface LazyDeleteDao<T extends DomainObject & LazyDeletable> extends D
|
||||
public List<T> findAllLazyDeleted();
|
||||
|
||||
public List<T> findAllLazyDeleted(final int first, final int count);
|
||||
|
||||
public List<T> findAll(boolean includeLazyDeleted);
|
||||
|
||||
}
|
||||
|
||||
|
@ -80,6 +80,21 @@ public abstract class LazyDeleteAbstractDaoJPAImp<T extends DomainObject & LazyD
|
||||
return query.getResultList();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Transactional( readOnly=true )
|
||||
public List<T> findAll(final boolean includeLazyDeleted) {
|
||||
return getJpaTemplate().execute(new JpaCallback<List<T>>() {
|
||||
public List<T> doInJpa(EntityManager em) throws PersistenceException {
|
||||
TypedQuery<T> query;
|
||||
if(includeLazyDeleted)
|
||||
query = em.createQuery("SELECT x FROM "+domainClassString+" x", domainClass);
|
||||
else
|
||||
query = em.createQuery("SELECT x FROM "+domainClassString+" x WHERE x.deleted = false", domainClass);
|
||||
query.setHint(QueryHints.HINT_CACHEABLE, "true");
|
||||
return query.getResultList();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -124,7 +124,6 @@ public class Query {
|
||||
String jpql = query.toString();
|
||||
|
||||
jpql = replaceUnderscoreWithSelectTarget(jpql);
|
||||
System.out.println(jpql);
|
||||
return jpql;
|
||||
}
|
||||
|
||||
|
@ -169,7 +169,6 @@ public class UserDaoJPAImp extends LazyDeleteAbstractDaoJPAImp<User> implements
|
||||
query.setParameter("notIncludeList", notIncludeList);
|
||||
}
|
||||
if (searchQuery != null) {
|
||||
System.out.println("serach params: " + query.getParameter("searchQuery"));
|
||||
query.setParameter("searchQuery", searchQuery + "%");
|
||||
}
|
||||
|
||||
|
@ -29,7 +29,7 @@ public class WorkerDataDaoJPAImp extends AbstractDaoJPAImp<WorkerData> implement
|
||||
return null;
|
||||
}
|
||||
|
||||
TypedQuery<WorkerData> query = em.createQuery("select wd FROM WorkerData wd WHERE wd.name=:name", WorkerData.class);
|
||||
TypedQuery<WorkerData> query = em.createQuery("SELECT wd FROM WorkerData wd WHERE wd.name=:name", WorkerData.class);
|
||||
query.setParameter("name", name);
|
||||
query.setHint(QueryHints.HINT_CACHEABLE, "true");
|
||||
try{
|
||||
|
@ -7,6 +7,8 @@ import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.PrePersist;
|
||||
import javax.persistence.PreUpdate;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import org.hibernate.annotations.Cache;
|
||||
@ -20,6 +22,9 @@ public class WorkerData extends DomainObject{
|
||||
|
||||
private static final long serialVersionUID = 5672978939504481263L;
|
||||
|
||||
public WorkerData() {
|
||||
lastSuccessfulRun = new Date(0);
|
||||
}
|
||||
|
||||
@Id
|
||||
@GeneratedValue
|
||||
@ -30,9 +35,17 @@ public class WorkerData extends DomainObject{
|
||||
|
||||
@Column(nullable=false)
|
||||
private Date lastRun=new Date();
|
||||
|
||||
@Column(nullable=false)
|
||||
private Date lastSuccessfulRun;
|
||||
|
||||
@Column(nullable=false)
|
||||
private Date lastSuccessfulRun=new Date();
|
||||
@PreUpdate
|
||||
@PrePersist
|
||||
public void updatelastSuccessfulRun() {
|
||||
if( lastSuccessfulRun == null ) {
|
||||
lastSuccessfulRun = new Date(0);
|
||||
}
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
|
@ -1,8 +1,11 @@
|
||||
package se.su.dsv.scipro.match.dao.interfaces;
|
||||
|
||||
import se.su.dsv.scipro.data.dao.interfaces.QueryableDao;
|
||||
import se.su.dsv.scipro.data.dataobjects.ProjectClass;
|
||||
import se.su.dsv.scipro.data.dataobjects.Student;
|
||||
import se.su.dsv.scipro.match.dataobject.Exemption;
|
||||
|
||||
public interface ExemptionDao extends QueryableDao<Exemption, ExemptionDaoParams>{
|
||||
|
||||
Exemption getByAuthorAndClass(Student author, ProjectClass projectClass);
|
||||
}
|
||||
|
@ -1,13 +1,16 @@
|
||||
package se.su.dsv.scipro.match.dao.interfaces;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import se.su.dsv.scipro.data.dao.interfaces.Dao;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.LazyDeleteDao;
|
||||
import se.su.dsv.scipro.match.dataobject.Keyword;
|
||||
import se.su.dsv.scipro.match.dataobject.KeywordType;
|
||||
|
||||
public interface KeywordDao extends Dao<Keyword>{
|
||||
public interface KeywordDao extends LazyDeleteDao<Keyword>{
|
||||
|
||||
Set<Keyword> getKeywords(KeywordType type);
|
||||
|
||||
public List<Keyword> findAllFromType(KeywordType kt, boolean includeDeleted);
|
||||
|
||||
}
|
||||
|
@ -1,10 +1,20 @@
|
||||
package se.su.dsv.scipro.match.dao.jpa;
|
||||
|
||||
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.NoResultException;
|
||||
import javax.persistence.PersistenceException;
|
||||
import javax.persistence.TypedQuery;
|
||||
|
||||
import org.hibernate.ejb.QueryHints;
|
||||
import org.springframework.orm.jpa.JpaCallback;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import se.su.dsv.scipro.data.dao.jpa.AbstractQuerySet;
|
||||
import se.su.dsv.scipro.data.dao.jpa.Query;
|
||||
import se.su.dsv.scipro.data.dataobjects.ProjectClass;
|
||||
import se.su.dsv.scipro.data.dataobjects.Student;
|
||||
import se.su.dsv.scipro.match.dao.interfaces.ExemptionDao;
|
||||
import se.su.dsv.scipro.match.dao.interfaces.ExemptionDaoParams;
|
||||
import se.su.dsv.scipro.match.dataobject.Exemption;
|
||||
@ -17,6 +27,26 @@ public class ExemptionDaoJPAImp extends QueryableDaoJPAImp<Exemption, ExemptionD
|
||||
super(Exemption.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(readOnly=true)
|
||||
public Exemption getByAuthorAndClass(final Student author, final ProjectClass projectClass){
|
||||
return getJpaTemplate().execute(new JpaCallback<Exemption>() {
|
||||
@Override
|
||||
public Exemption doInJpa(EntityManager em)
|
||||
throws PersistenceException {
|
||||
TypedQuery<Exemption> query = em.createQuery("select e FROM Exemption e WHERE e.author = :author AND e.projectClass = :projectClass",Exemption.class);
|
||||
query.setParameter("author", author);
|
||||
query.setParameter("projectClass", projectClass);
|
||||
query.setHint(QueryHints.HINT_CACHEABLE, "true");
|
||||
try {
|
||||
return query.getSingleResult();
|
||||
} catch (NoResultException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public AbstractQuerySet<Exemption> createQuerySet(ExemptionDaoParams exemptionDaoParams) {
|
||||
return new QuerySet().authorNameLike(exemptionDaoParams.getAuthorNameLike());
|
||||
}
|
||||
|
@ -1,25 +1,33 @@
|
||||
package se.su.dsv.scipro.match.dao.jpa;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.springframework.stereotype.Repository;
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.PersistenceException;
|
||||
import javax.persistence.TypedQuery;
|
||||
|
||||
import org.hibernate.ejb.QueryHints;
|
||||
import org.springframework.orm.jpa.JpaCallback;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import se.su.dsv.scipro.data.dao.jpa.AbstractDaoJPAImp;
|
||||
import se.su.dsv.scipro.data.dao.jpa.AbstractSortableQuerySet;
|
||||
import se.su.dsv.scipro.data.dao.jpa.LazyDeleteAbstractDaoJPAImp;
|
||||
import se.su.dsv.scipro.data.dao.jpa.Query;
|
||||
import se.su.dsv.scipro.match.dao.interfaces.KeywordDao;
|
||||
import se.su.dsv.scipro.match.dataobject.Keyword;
|
||||
import se.su.dsv.scipro.match.dataobject.KeywordType;
|
||||
|
||||
@Repository("keywordDao")
|
||||
public class KeywordDaoJPAImp extends AbstractDaoJPAImp<Keyword> implements
|
||||
public class KeywordDaoJPAImp extends LazyDeleteAbstractDaoJPAImp<Keyword> implements
|
||||
KeywordDao {
|
||||
|
||||
public KeywordDaoJPAImp() {
|
||||
super(Keyword.class);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Set<Keyword> getKeywords(KeywordType type) {
|
||||
return new HashSet<Keyword>(getJpaTemplate().execute(
|
||||
@ -45,4 +53,20 @@ public class KeywordDaoJPAImp extends AbstractDaoJPAImp<Keyword> implements
|
||||
return new Query().select("k").from("Keyword k");
|
||||
}
|
||||
}
|
||||
|
||||
@Transactional( readOnly=true )
|
||||
public List<Keyword> findAllFromType(final KeywordType keywordType, final boolean includeLazyDeleted) {
|
||||
return getJpaTemplate().execute(new JpaCallback<List<Keyword>>() {
|
||||
public List<Keyword> doInJpa(EntityManager em) throws PersistenceException {
|
||||
TypedQuery<Keyword> query;
|
||||
if(includeLazyDeleted)
|
||||
query = em.createQuery("SELECT x FROM "+domainClassString+" x WHERE x.type = :type", domainClass);
|
||||
else
|
||||
query = em.createQuery("SELECT x FROM "+domainClassString+" x WHERE x.type = :type AND x.deleted = false", domainClass);
|
||||
query.setParameter("type", keywordType);
|
||||
query.setHint(QueryHints.HINT_CACHEABLE, "true");
|
||||
return query.getResultList();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
package se.su.dsv.scipro.match.dataprovider;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.apache.wicket.spring.injection.annot.SpringBean;
|
||||
|
||||
import se.su.dsv.scipro.data.dao.interfaces.Dao;
|
||||
import se.su.dsv.scipro.dataproviders.SortSpecifier;
|
||||
import se.su.dsv.scipro.dataproviders.SortableDataProvider;
|
||||
import se.su.dsv.scipro.match.dao.interfaces.KeywordDao;
|
||||
import se.su.dsv.scipro.match.dataobject.Keyword;
|
||||
import se.su.dsv.scipro.match.dataobject.KeywordType;
|
||||
|
||||
public class KeywordsDataProvider extends SortableDataProvider<Keyword>{
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private KeywordType keywordType = null;
|
||||
|
||||
@SpringBean
|
||||
protected KeywordDao keywordDao;
|
||||
|
||||
@Override
|
||||
protected Dao<Keyword> getDao() {
|
||||
return keywordDao;
|
||||
}
|
||||
|
||||
public KeywordsDataProvider(final SortSpecifier sortSpecifier, KeywordType keywordType) {
|
||||
super(sortSpecifier, Keyword.class);
|
||||
this.keywordType = keywordType;
|
||||
}
|
||||
|
||||
public Iterator<Keyword> iterator(int first, int count) {
|
||||
Iterator<Keyword> iter = keywordDao.getKeywords(keywordType).iterator();
|
||||
return iter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
return keywordDao.getKeywords(keywordType).size();
|
||||
}
|
||||
|
||||
}
|
@ -31,7 +31,6 @@ public class PartnerAdditionPanel extends Panel {
|
||||
private Student coAuthor;
|
||||
private Model<Long> partnerLong;
|
||||
|
||||
|
||||
public PartnerAdditionPanel(String id, PropertyModel<List<Student>> authorListModel) {
|
||||
super(id);
|
||||
partnerLong = new Model<Long>();
|
||||
@ -41,6 +40,7 @@ public class PartnerAdditionPanel extends Panel {
|
||||
}
|
||||
|
||||
addProjectPartner();
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -92,11 +92,16 @@ public class PartnerAdditionPanel extends Panel {
|
||||
}
|
||||
});
|
||||
projectPartnerSelector = builder.build("projectPartner", partnerLong);
|
||||
//Should not be required if exemption to write alone is granted
|
||||
projectPartnerSelector.setRequired(true);
|
||||
add(projectPartnerSelector);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void setPartnerRequired(boolean isExemptionGranted) {
|
||||
projectPartnerSelector.setRequired(!isExemptionGranted);
|
||||
}
|
||||
|
||||
|
||||
public Student getCoAuthor() {
|
||||
return authorDao.getOrCreate(roleDao.load(projectPartnerSelector.getModelObject()).getUser());
|
||||
}
|
||||
|
@ -47,6 +47,7 @@ import se.su.dsv.scipro.data.dataobjects.Student;
|
||||
import se.su.dsv.scipro.data.dataobjects.User;
|
||||
import se.su.dsv.scipro.data.facade.ProjectIdeaFacade;
|
||||
import se.su.dsv.scipro.match.dao.interfaces.AuthorDao;
|
||||
import se.su.dsv.scipro.match.dao.interfaces.ExemptionDao;
|
||||
import se.su.dsv.scipro.match.dao.interfaces.ProjectIdeaDao;
|
||||
import se.su.dsv.scipro.match.dao.interfaces.SupervisorDao;
|
||||
import se.su.dsv.scipro.match.dataobject.Keywords;
|
||||
@ -73,6 +74,8 @@ public class ProjectIdeaSubmissionPanel extends Panel {
|
||||
private LanguageDao languageDao;
|
||||
@SpringBean
|
||||
private AuthorDao authorDao;
|
||||
@SpringBean
|
||||
private ExemptionDao exemptionDao;
|
||||
|
||||
|
||||
private Dialog dialog;
|
||||
@ -146,6 +149,8 @@ public class ProjectIdeaSubmissionPanel extends Panel {
|
||||
|
||||
@Override
|
||||
protected void onUpdate(AjaxRequestTarget target) {
|
||||
partnerAdditionPanel.setPartnerRequired(isExemptionGranted());
|
||||
target.addComponent(partnerAdditionPanel);
|
||||
}
|
||||
|
||||
});
|
||||
@ -172,6 +177,7 @@ public class ProjectIdeaSubmissionPanel extends Panel {
|
||||
|
||||
container.add(keywordPanel);
|
||||
partnerAdditionPanel = new PartnerAdditionPanel("partnerPanel", authorListModel);
|
||||
partnerAdditionPanel.setOutputMarkupId(true);
|
||||
container.add(partnerAdditionPanel);
|
||||
|
||||
addWatsonBoxes();
|
||||
@ -190,6 +196,9 @@ public class ProjectIdeaSubmissionPanel extends Panel {
|
||||
return ideaModel.getObject().getMatch() == null;
|
||||
}
|
||||
|
||||
private boolean isExemptionGranted() {
|
||||
return exemptionDao.getByAuthorAndClass(signedInAuthor, selectedModel.getObject()) != null;
|
||||
}
|
||||
|
||||
//Creation of Watson fields
|
||||
private void addWatsonBoxes() {
|
||||
@ -444,7 +453,7 @@ public class ProjectIdeaSubmissionPanel extends Panel {
|
||||
validated = false;
|
||||
}
|
||||
} else {
|
||||
//check for exemption to write alone?
|
||||
//Panel is not required, exemption exists.
|
||||
}
|
||||
if (!validated)
|
||||
error("Submission failed, please try again");
|
||||
|
Loading…
x
Reference in New Issue
Block a user