ItEr26S13AltaEtiquetasTipoEtiqueta: List labels
This commit is contained in:
parent
cf697cb775
commit
0e1dfa94c4
6 changed files with 65 additions and 5 deletions
|
|
@ -1,5 +1,7 @@
|
|||
package org.navalplanner.business.labels.daos;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.navalplanner.business.common.daos.IGenericDAO;
|
||||
import org.navalplanner.business.labels.entities.Label;
|
||||
|
||||
|
|
@ -8,4 +10,6 @@ import org.navalplanner.business.labels.entities.Label;
|
|||
*/
|
||||
public interface ILabelDAO extends IGenericDAO<Label, Long> {
|
||||
|
||||
List<Label> getAll();
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
package org.navalplanner.business.labels.daos;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.navalplanner.business.common.daos.GenericDAOHibernate;
|
||||
import org.navalplanner.business.labels.entities.Label;
|
||||
import org.springframework.beans.factory.config.BeanDefinition;
|
||||
|
|
@ -16,4 +18,9 @@ import org.springframework.stereotype.Repository;
|
|||
public class LabelDAO extends GenericDAOHibernate<Label, Long> implements
|
||||
ILabelDAO {
|
||||
|
||||
@Override
|
||||
public List<Label> getAll() {
|
||||
return list(Label.class);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package org.navalplanner.web.labels;
|
|||
import java.util.List;
|
||||
|
||||
import org.navalplanner.business.common.exceptions.ValidationException;
|
||||
import org.navalplanner.business.labels.entities.Label;
|
||||
import org.navalplanner.business.labels.entities.LabelType;
|
||||
|
||||
/**
|
||||
|
|
@ -48,4 +49,10 @@ public interface ILabelTypeModel {
|
|||
*/
|
||||
void initEdit(LabelType labelType);
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
List<Label> getLabels();
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import java.util.List;
|
|||
|
||||
import org.hibernate.validator.InvalidValue;
|
||||
import org.navalplanner.business.common.exceptions.ValidationException;
|
||||
import org.navalplanner.business.labels.entities.Label;
|
||||
import org.navalplanner.business.labels.entities.LabelType;
|
||||
import org.navalplanner.web.common.IMessagesForUser;
|
||||
import org.navalplanner.web.common.Level;
|
||||
|
|
@ -77,6 +78,10 @@ public class LabelTypeCRUDController extends GenericForwardComposer {
|
|||
return labelTypeModel.getLabelType();
|
||||
}
|
||||
|
||||
public List<Label> getLabels() {
|
||||
return labelTypeModel.getLabels();
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare form for Create
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -9,7 +9,9 @@ import org.hibernate.validator.ClassValidator;
|
|||
import org.hibernate.validator.InvalidValue;
|
||||
import org.navalplanner.business.common.exceptions.InstanceNotFoundException;
|
||||
import org.navalplanner.business.common.exceptions.ValidationException;
|
||||
import org.navalplanner.business.labels.daos.ILabelDAO;
|
||||
import org.navalplanner.business.labels.daos.ILabelTypeDAO;
|
||||
import org.navalplanner.business.labels.entities.Label;
|
||||
import org.navalplanner.business.labels.entities.LabelType;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.config.BeanDefinition;
|
||||
|
|
@ -28,6 +30,9 @@ public class LabelTypeModel implements ILabelTypeModel {
|
|||
@Autowired
|
||||
private ILabelTypeDAO labelTypeDAO;
|
||||
|
||||
@Autowired
|
||||
private ILabelDAO labelDAO;
|
||||
|
||||
private LabelType labelType;
|
||||
|
||||
private ClassValidator<LabelType> validator = new ClassValidator<LabelType>(
|
||||
|
|
@ -94,10 +99,24 @@ public class LabelTypeModel implements ILabelTypeModel {
|
|||
|
||||
private LabelType getFromDB(Long id) {
|
||||
try {
|
||||
return labelType = labelTypeDAO.find(id);
|
||||
LabelType labelType = labelTypeDAO.find(id);
|
||||
reattachLabels(labelType);
|
||||
return labelType;
|
||||
} catch (InstanceNotFoundException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private void reattachLabels(LabelType labelType) {
|
||||
for (Label label : labelType.getLabels()) {
|
||||
label.getName();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
public List<Label> getLabels() {
|
||||
return labelDAO.getAll();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,9 +4,27 @@
|
|||
<label value="${i18n:_('Name')}"/>
|
||||
<textbox id="name" value="@{controller.labelType.name}"/>
|
||||
</hbox>
|
||||
<hbox>
|
||||
<button label="${i18n:_('Save')}" onClick="controller.save()"/>
|
||||
<button label="${i18n:_('Cancel')}" onClick="controller.cancel()"/>
|
||||
</hbox>
|
||||
</vbox>
|
||||
<panel title="${i18n:_('Label list')}" border="normal"
|
||||
style="margin: 10px 0px">
|
||||
<panelchildren>
|
||||
<button label="${i18n:_('New label')}" />
|
||||
<listbox rows="10"
|
||||
model="@{controller.labels}">
|
||||
<listhead>
|
||||
<listheader label="${i18n:_('Name')}" />
|
||||
</listhead>
|
||||
<listitem self="@{each='label'}" value="@{label}">
|
||||
<listcell>
|
||||
<textbox value="@{label.name}" />
|
||||
</listcell>
|
||||
</listitem>
|
||||
</listbox>
|
||||
</panelchildren>
|
||||
</panel>
|
||||
<hbox>
|
||||
<button label="${i18n:_('Save')}" onClick="controller.save()" />
|
||||
<button label="${i18n:_('Cancel')}"
|
||||
onClick="controller.cancel()" />
|
||||
</hbox>
|
||||
</window>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue