Merge branch 'master' into ldap
This commit is contained in:
commit
5e0f2f4775
28 changed files with 331 additions and 290 deletions
|
|
@ -32,6 +32,7 @@ import org.hibernate.NonUniqueResultException;
|
|||
import org.hibernate.validator.AssertTrue;
|
||||
import org.hibernate.validator.NotNull;
|
||||
import org.navalplanner.business.calendars.daos.ICalendarExceptionTypeDAO;
|
||||
import org.navalplanner.business.common.IHumanIdentifiable;
|
||||
import org.navalplanner.business.common.IntegrationEntity;
|
||||
import org.navalplanner.business.common.Registry;
|
||||
import org.navalplanner.business.common.exceptions.InstanceNotFoundException;
|
||||
|
|
@ -44,7 +45,8 @@ import org.springframework.orm.hibernate3.HibernateOptimisticLockingFailureExcep
|
|||
*
|
||||
* @author Manuel Rego Casasnovas <mrego@igalia.com>
|
||||
*/
|
||||
public class CalendarExceptionType extends IntegrationEntity {
|
||||
public class CalendarExceptionType extends IntegrationEntity implements
|
||||
IHumanIdentifiable {
|
||||
|
||||
private String name;
|
||||
|
||||
|
|
@ -183,4 +185,9 @@ public class CalendarExceptionType extends IntegrationEntity {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHumanId() {
|
||||
return name;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -135,4 +135,9 @@ public class Machine extends Resource {
|
|||
return String.format("MACHINE: %s", name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHumanId() {
|
||||
return name;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -48,6 +48,7 @@ import org.navalplanner.business.calendars.entities.ICalendar;
|
|||
import org.navalplanner.business.calendars.entities.ResourceCalendar;
|
||||
import org.navalplanner.business.calendars.entities.SameWorkHoursEveryDay;
|
||||
import org.navalplanner.business.common.BaseEntity;
|
||||
import org.navalplanner.business.common.IHumanIdentifiable;
|
||||
import org.navalplanner.business.common.IntegrationEntity;
|
||||
import org.navalplanner.business.common.Registry;
|
||||
import org.navalplanner.business.common.exceptions.InstanceNotFoundException;
|
||||
|
|
@ -71,7 +72,8 @@ import org.navalplanner.business.workingday.IntraDayDate.PartialDay;
|
|||
* @author Susana Montes Pedreira <smontes@wirelessgalicia.com>
|
||||
* @author Jacobo Aragunde Perez <jaragunde@igalia.com>
|
||||
*/
|
||||
public abstract class Resource extends IntegrationEntity {
|
||||
public abstract class Resource extends IntegrationEntity implements
|
||||
IHumanIdentifiable {
|
||||
|
||||
public static class AllResourceAssignments implements IAssignmentsOnResourceCalculator {
|
||||
|
||||
|
|
|
|||
|
|
@ -113,4 +113,9 @@ public class VirtualWorker extends Worker {
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHumanId() {
|
||||
return getFirstName();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -200,4 +200,9 @@ public class Worker extends Resource implements Comparable {
|
|||
return worker.getShortDescription().compareTo(getShortDescription());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHumanId() {
|
||||
return firstName + " " + surname;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,9 +21,12 @@
|
|||
|
||||
package org.navalplanner.business.users.daos;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.navalplanner.business.common.daos.IGenericDAO;
|
||||
import org.navalplanner.business.common.exceptions.InstanceNotFoundException;
|
||||
import org.navalplanner.business.common.exceptions.ValidationException;
|
||||
import org.navalplanner.business.users.entities.OrderAuthorization;
|
||||
import org.navalplanner.business.users.entities.Profile;
|
||||
|
||||
/**
|
||||
|
|
@ -34,8 +37,6 @@ import org.navalplanner.business.users.entities.Profile;
|
|||
*/
|
||||
public interface IProfileDAO extends IGenericDAO<Profile, Long>{
|
||||
|
||||
void checkIsReferencedByOtherEntities(Profile profile) throws ValidationException;
|
||||
|
||||
boolean existsByProfileName(String profileName);
|
||||
|
||||
boolean existsByProfileNameAnotherTransaction(String profileName);
|
||||
|
|
@ -46,4 +47,8 @@ public interface IProfileDAO extends IGenericDAO<Profile, Long>{
|
|||
Profile findByProfileNameAnotherTransaction(String profileName)
|
||||
throws InstanceNotFoundException;
|
||||
|
||||
void checkHasUsers(Profile profile) throws ValidationException;
|
||||
|
||||
List<OrderAuthorization> getOrderAuthorizationsByProfile(Profile profile);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ import java.util.List;
|
|||
import org.navalplanner.business.common.daos.IGenericDAO;
|
||||
import org.navalplanner.business.common.exceptions.InstanceNotFoundException;
|
||||
import org.navalplanner.business.scenarios.entities.Scenario;
|
||||
import org.navalplanner.business.users.entities.OrderAuthorization;
|
||||
import org.navalplanner.business.users.entities.User;
|
||||
|
||||
/**
|
||||
|
|
@ -80,4 +81,5 @@ public interface IUserDAO extends IGenericDAO<User, Long>{
|
|||
|
||||
public List<User> findByLastConnectedScenario(Scenario scenario);
|
||||
|
||||
List<OrderAuthorization> getOrderAuthorizationsByUser(User user);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ import org.hibernate.criterion.Restrictions;
|
|||
import org.navalplanner.business.common.daos.GenericDAOHibernate;
|
||||
import org.navalplanner.business.common.exceptions.InstanceNotFoundException;
|
||||
import org.navalplanner.business.common.exceptions.ValidationException;
|
||||
import org.navalplanner.business.users.entities.OrderAuthorization;
|
||||
import org.navalplanner.business.users.entities.Profile;
|
||||
import org.navalplanner.business.users.entities.ProfileOrderAuthorization;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
|
@ -88,24 +89,15 @@ public class ProfileDAO extends GenericDAOHibernate<Profile, Long> implements
|
|||
}
|
||||
|
||||
@Override
|
||||
public void checkIsReferencedByOtherEntities(Profile profile) throws ValidationException {
|
||||
checkHasUsers(profile);
|
||||
checkHasOrderAuthorizations(profile);
|
||||
}
|
||||
|
||||
private void checkHasOrderAuthorizations(Profile profile) {
|
||||
public List<OrderAuthorization> getOrderAuthorizationsByProfile(Profile profile) {
|
||||
List orderAuthorizations = getSession()
|
||||
.createCriteria(ProfileOrderAuthorization.class)
|
||||
.add(Restrictions.eq("profile", profile)).list();
|
||||
if (!orderAuthorizations.isEmpty()) {
|
||||
throw ValidationException
|
||||
.invalidValue(
|
||||
"Cannot delete profile. It is being used at this moment by some order authorizations.",
|
||||
profile);
|
||||
}
|
||||
return orderAuthorizations;
|
||||
}
|
||||
|
||||
private void checkHasUsers(Profile profile) {
|
||||
@Override
|
||||
public void checkHasUsers(Profile profile) throws ValidationException {
|
||||
// Query against a collection of elements
|
||||
// http://community.jboss.org/message/353859#353859
|
||||
Query query = getSession().createQuery(
|
||||
|
|
|
|||
|
|
@ -28,7 +28,9 @@ import org.hibernate.criterion.Restrictions;
|
|||
import org.navalplanner.business.common.daos.GenericDAOHibernate;
|
||||
import org.navalplanner.business.common.exceptions.InstanceNotFoundException;
|
||||
import org.navalplanner.business.scenarios.entities.Scenario;
|
||||
import org.navalplanner.business.users.entities.OrderAuthorization;
|
||||
import org.navalplanner.business.users.entities.User;
|
||||
import org.navalplanner.business.users.entities.UserOrderAuthorization;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import org.springframework.transaction.annotation.Propagation;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
|
@ -117,4 +119,11 @@ public class UserDAO extends GenericDAOHibernate<User, Long>
|
|||
return c.list();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<OrderAuthorization> getOrderAuthorizationsByUser(User user) {
|
||||
List orderAuthorizations = getSession()
|
||||
.createCriteria(UserOrderAuthorization.class)
|
||||
.add(Restrictions.eq("user", user)).list();
|
||||
return orderAuthorizations;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -222,11 +222,6 @@ public abstract class BaseCRUDController<T extends IHumanIdentifiable> extends
|
|||
private void saveCommonActions() throws ValidationException {
|
||||
beforeSaving();
|
||||
|
||||
Util.reloadBindings(editWindow);
|
||||
if (!ConstraintChecker.isValid(editWindow)) {
|
||||
throw new ValidationException("Please fix invalid fields in form");
|
||||
}
|
||||
|
||||
save();
|
||||
|
||||
messagesForUser.showMessage(
|
||||
|
|
@ -249,13 +244,16 @@ public abstract class BaseCRUDController<T extends IHumanIdentifiable> extends
|
|||
}
|
||||
|
||||
/**
|
||||
* Performs additional operations before saving (usually generate codes of
|
||||
* related entities).
|
||||
* Performs additional operations before saving (usually do some checks or
|
||||
* generate codes of related entities).
|
||||
*
|
||||
* Default behavior do nothing, however it could be overridden if needed.
|
||||
* Default behavior use {@link ConstraintChecker} to see if
|
||||
* {@link #editWindow} is valid, however it could be overridden if needed.
|
||||
*/
|
||||
protected void beforeSaving() {
|
||||
// Do nothing
|
||||
protected void beforeSaving() throws ValidationException {
|
||||
if (!ConstraintChecker.isValid(editWindow)) {
|
||||
throw new ValidationException("Please fix invalid fields in form");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -292,14 +290,20 @@ public abstract class BaseCRUDController<T extends IHumanIdentifiable> extends
|
|||
}
|
||||
|
||||
/**
|
||||
* Shows a dialog asking for confirmation to user and if ok remove entity
|
||||
* passed as parameter. Delegate in {@link #delete(entity)} that should be
|
||||
* implemented in subclasses.
|
||||
* First call {@link #beforeDeleting(entity)} in order to perform some
|
||||
* checkings before trying to delete if needed. Then show a dialog asking
|
||||
* for confirmation to user and if ok remove entity passed as parameter.
|
||||
* Delegate in {@link #delete(entity)} that should be implemented in
|
||||
* subclasses.
|
||||
*
|
||||
* @param entity
|
||||
* Entity to be removed
|
||||
*/
|
||||
public final void confirmDelete(T entity) {
|
||||
if (!beforeDeleting(entity)) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
if (Messagebox.show(
|
||||
_("Delete {0} \"{1}\". Are you sure?", getEntityType(),
|
||||
|
|
@ -318,6 +322,21 @@ public abstract class BaseCRUDController<T extends IHumanIdentifiable> extends
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs additional operations before deleting (usually check some wrong
|
||||
* conditions before deleting).
|
||||
*
|
||||
* Default behavior do nothing, however it could be overridden if needed.
|
||||
*
|
||||
* @param entity
|
||||
* Entity to be removed
|
||||
* @return Return true if deletion can carry on
|
||||
*/
|
||||
protected boolean beforeDeleting(T entity) {
|
||||
// Do nothing
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs actions needed to remove entity passed as parameter
|
||||
*
|
||||
|
|
|
|||
|
|
@ -23,16 +23,13 @@ import static org.navalplanner.web.I18nHelper._;
|
|||
import java.util.ConcurrentModificationException;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.navalplanner.business.calendars.entities.CalendarExceptionType;
|
||||
import org.navalplanner.business.calendars.entities.Capacity;
|
||||
import org.navalplanner.business.calendars.entities.PredefinedCalendarExceptionTypes;
|
||||
import org.navalplanner.business.common.exceptions.InstanceNotFoundException;
|
||||
import org.navalplanner.business.common.exceptions.ValidationException;
|
||||
import org.navalplanner.web.common.IMessagesForUser;
|
||||
import org.navalplanner.web.common.BaseCRUDController;
|
||||
import org.navalplanner.web.common.Level;
|
||||
import org.navalplanner.web.common.MessagesForUser;
|
||||
import org.navalplanner.web.common.OnlyOneVisible;
|
||||
import org.navalplanner.web.common.Util;
|
||||
import org.navalplanner.web.common.Util.Getter;
|
||||
import org.navalplanner.web.common.Util.Setter;
|
||||
|
|
@ -45,33 +42,22 @@ import org.zkoss.zk.ui.Component;
|
|||
import org.zkoss.zk.ui.WrongValueException;
|
||||
import org.zkoss.zk.ui.event.CheckEvent;
|
||||
import org.zkoss.zk.ui.event.Event;
|
||||
import org.zkoss.zk.ui.event.MouseEvent;
|
||||
import org.zkoss.zk.ui.util.GenericForwardComposer;
|
||||
import org.zkoss.zul.Button;
|
||||
import org.zkoss.zul.Checkbox;
|
||||
import org.zkoss.zul.Grid;
|
||||
import org.zkoss.zul.Messagebox;
|
||||
import org.zkoss.zul.Row;
|
||||
import org.zkoss.zul.Textbox;
|
||||
import org.zkoss.zul.Window;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Diego Pino <dpino@igalia.com>
|
||||
*
|
||||
*/
|
||||
public class CalendarExceptionTypeCRUDController extends GenericForwardComposer {
|
||||
|
||||
private static final org.apache.commons.logging.Log LOG = LogFactory
|
||||
.getLog(CalendarExceptionTypeCRUDController.class);
|
||||
public class CalendarExceptionTypeCRUDController extends
|
||||
BaseCRUDController<CalendarExceptionType> {
|
||||
|
||||
@Autowired
|
||||
private ICalendarExceptionTypeModel calendarExceptionTypeModel;
|
||||
|
||||
private Window listWindow;
|
||||
|
||||
private Window editWindow;
|
||||
|
||||
private Textbox tbName;
|
||||
|
||||
private Textbox tbColor;
|
||||
|
|
@ -82,19 +68,10 @@ public class CalendarExceptionTypeCRUDController extends GenericForwardComposer
|
|||
|
||||
private EffortDurationPicker extraEffort;
|
||||
|
||||
private OnlyOneVisible visibility;
|
||||
|
||||
private IMessagesForUser messagesForUser;
|
||||
|
||||
private Component messagesContainer;
|
||||
|
||||
@Override
|
||||
public void doAfterCompose(Component comp) throws Exception {
|
||||
super.doAfterCompose(comp);
|
||||
messagesForUser = new MessagesForUser(messagesContainer);
|
||||
comp.setVariable("controller", this, true);
|
||||
initializeEditWindowComponents();
|
||||
showListWindow();
|
||||
}
|
||||
|
||||
private void initializeCapacityPicker() {
|
||||
|
|
@ -123,37 +100,16 @@ public class CalendarExceptionTypeCRUDController extends GenericForwardComposer
|
|||
extraEffort = Util.findComponentAt(editWindow, "extraEffort");
|
||||
}
|
||||
|
||||
private void showListWindow() {
|
||||
showWindow(listWindow);
|
||||
}
|
||||
|
||||
private void showWindow(Window window) {
|
||||
getVisibility().showOnly(window);
|
||||
}
|
||||
|
||||
private OnlyOneVisible getVisibility() {
|
||||
if (visibility == null) {
|
||||
visibility = new OnlyOneVisible(listWindow, editWindow);
|
||||
}
|
||||
return visibility;
|
||||
}
|
||||
|
||||
private void showEditWindow() {
|
||||
initializeCapacityPicker();
|
||||
editWindow.setTitle(_("Edit Exception Day Type"));
|
||||
showWindow(editWindow);
|
||||
}
|
||||
|
||||
public void goToCreateForm() {
|
||||
@Override
|
||||
protected void initCreate() {
|
||||
calendarExceptionTypeModel.initCreate();
|
||||
showCreateWindow();
|
||||
Util.reloadBindings(editWindow);
|
||||
initializeCapacityPicker();
|
||||
}
|
||||
|
||||
private void showCreateWindow() {
|
||||
@Override
|
||||
protected void initEdit(CalendarExceptionType calendarExceptionType) {
|
||||
calendarExceptionTypeModel.initEdit(calendarExceptionType);
|
||||
initializeCapacityPicker();
|
||||
editWindow.setTitle(_("Create Exception Day Type"));
|
||||
showWindow(editWindow);
|
||||
}
|
||||
|
||||
public CalendarExceptionType getExceptionDayType() {
|
||||
|
|
@ -164,9 +120,9 @@ public class CalendarExceptionTypeCRUDController extends GenericForwardComposer
|
|||
return calendarExceptionTypeModel.getExceptionDayTypes();
|
||||
}
|
||||
|
||||
public void cancel() {
|
||||
@Override
|
||||
protected void cancel() {
|
||||
clearFields();
|
||||
showListWindow();
|
||||
}
|
||||
|
||||
private void clearFields() {
|
||||
|
|
@ -174,73 +130,36 @@ public class CalendarExceptionTypeCRUDController extends GenericForwardComposer
|
|||
tbColor.setRawValue("");
|
||||
}
|
||||
|
||||
private boolean save() {
|
||||
try {
|
||||
calendarExceptionTypeModel.confirmSave();
|
||||
messagesForUser.showMessage(Level.INFO, _("Calendar Exception Type saved"));
|
||||
return true;
|
||||
} catch (ValidationException e) {
|
||||
messagesForUser.showInvalidValues(e);
|
||||
@Override
|
||||
protected void save() throws ValidationException {
|
||||
calendarExceptionTypeModel.confirmSave();
|
||||
clearFields();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean beforeDeleting(CalendarExceptionType calendarExceptionType) {
|
||||
if (PredefinedCalendarExceptionTypes.contains(calendarExceptionType)) {
|
||||
messagesForUser
|
||||
.showMessage(
|
||||
Level.ERROR,
|
||||
_("Cannot remove the predefined Exception Day Type \"{0}\"",
|
||||
calendarExceptionType.getHumanId()));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public void saveAndExit() {
|
||||
boolean couldSave = save();
|
||||
if (couldSave) {
|
||||
clearFields();
|
||||
showListWindow();
|
||||
Util.reloadBindings(listWindow);
|
||||
}
|
||||
}
|
||||
|
||||
public void saveAndContinue() {
|
||||
boolean couldSave = save();
|
||||
if (couldSave) {
|
||||
calendarExceptionTypeModel.initEdit(calendarExceptionTypeModel
|
||||
.getExceptionDayType());
|
||||
}
|
||||
}
|
||||
|
||||
public void showRemoveConfirmationMessage(MouseEvent event) {
|
||||
Button button = (Button) event.getTarget();
|
||||
Component comp = (Component) event.getTarget();
|
||||
CalendarExceptionType exceptionType = (CalendarExceptionType) ((Row) button
|
||||
.getParent().getParent()).getValue();
|
||||
|
||||
if (PredefinedCalendarExceptionTypes.contains(exceptionType)) {
|
||||
throw new WrongValueException(comp, "Cannot remove a predefined Exception Day Type");
|
||||
} else {
|
||||
showRemoveConfirmationMessage(exceptionType);
|
||||
}
|
||||
}
|
||||
|
||||
public void showRemoveConfirmationMessage(
|
||||
CalendarExceptionType exceptionType) {
|
||||
@Override
|
||||
protected void delete(CalendarExceptionType calendarExceptionType) {
|
||||
try {
|
||||
int status = Messagebox
|
||||
.show(_("Delete item {0}. Are you sure?",
|
||||
exceptionType.getName()), _("Delete"),
|
||||
Messagebox.OK | Messagebox.CANCEL,
|
||||
Messagebox.QUESTION);
|
||||
if (Messagebox.OK == status) {
|
||||
confirmDelete(exceptionType);
|
||||
Util.reloadBindings(listWindow);
|
||||
}
|
||||
} catch (InterruptedException e) {
|
||||
LOG.error(_("Error on showing delete confirm"), e);
|
||||
}
|
||||
}
|
||||
|
||||
public void confirmDelete(CalendarExceptionType exceptionType) {
|
||||
try {
|
||||
calendarExceptionTypeModel.confirmDelete(exceptionType);
|
||||
calendarExceptionTypeModel.confirmDelete(calendarExceptionType);
|
||||
} catch (InstanceNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
throw new RuntimeException(e);
|
||||
} catch (InvalidValueException e) {
|
||||
NewDataSortableGrid listExceptionDayTypes = (NewDataSortableGrid) listWindow
|
||||
.getFellowIfAny("listExceptionDayTypes");
|
||||
Row row = findRowByValue(listExceptionDayTypes, exceptionType);
|
||||
Row row = findRowByValue(listExceptionDayTypes,
|
||||
calendarExceptionType);
|
||||
throw new WrongValueException(row, e.getMessage());
|
||||
}
|
||||
}
|
||||
|
|
@ -255,12 +174,6 @@ public class CalendarExceptionTypeCRUDController extends GenericForwardComposer
|
|||
return null;
|
||||
}
|
||||
|
||||
public void goToEditForm(CalendarExceptionType exceptionType) {
|
||||
calendarExceptionTypeModel.initEdit(exceptionType);
|
||||
showEditWindow();
|
||||
Util.reloadBindings(editWindow);
|
||||
}
|
||||
|
||||
public void onCheckGenerateCode(Event e) {
|
||||
CheckEvent ce = (CheckEvent) e;
|
||||
if (ce.isChecked()) {
|
||||
|
|
@ -274,4 +187,19 @@ public class CalendarExceptionTypeCRUDController extends GenericForwardComposer
|
|||
Util.reloadBindings(editWindow);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getEntityType() {
|
||||
return "Exception Day Type";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getPluralEntityType() {
|
||||
return "Exception Day Types";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected CalendarExceptionType getEntityBeingEdited() {
|
||||
return calendarExceptionTypeModel.getExceptionDayType();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -323,8 +323,10 @@ public class LabelTypeCRUDController extends BaseCRUDController<LabelType> {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void beforeSaving() {
|
||||
protected void beforeSaving() throws ValidationException {
|
||||
validate();
|
||||
labelTypeModel.generateCodes();
|
||||
Util.reloadBindings(editWindow);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,9 +28,6 @@ import java.util.Date;
|
|||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.hibernate.validator.InvalidValue;
|
||||
import org.joda.time.LocalDate;
|
||||
import org.navalplanner.business.calendars.entities.BaseCalendar;
|
||||
import org.navalplanner.business.calendars.entities.ResourceCalendar;
|
||||
|
|
@ -39,11 +36,9 @@ import org.navalplanner.business.common.exceptions.ValidationException;
|
|||
import org.navalplanner.business.resources.entities.Machine;
|
||||
import org.navalplanner.web.calendars.BaseCalendarEditionController;
|
||||
import org.navalplanner.web.calendars.IBaseCalendarModel;
|
||||
import org.navalplanner.web.common.BaseCRUDController;
|
||||
import org.navalplanner.web.common.ConstraintChecker;
|
||||
import org.navalplanner.web.common.IMessagesForUser;
|
||||
import org.navalplanner.web.common.Level;
|
||||
import org.navalplanner.web.common.MessagesForUser;
|
||||
import org.navalplanner.web.common.OnlyOneVisible;
|
||||
import org.navalplanner.web.common.Util;
|
||||
import org.navalplanner.web.common.components.bandboxsearch.BandboxMultipleSearch;
|
||||
import org.navalplanner.web.common.components.finders.FilterPair;
|
||||
|
|
@ -58,7 +53,6 @@ import org.zkoss.zk.ui.event.CheckEvent;
|
|||
import org.zkoss.zk.ui.event.Event;
|
||||
import org.zkoss.zk.ui.event.EventListener;
|
||||
import org.zkoss.zk.ui.event.Events;
|
||||
import org.zkoss.zk.ui.util.GenericForwardComposer;
|
||||
import org.zkoss.zul.Combobox;
|
||||
import org.zkoss.zul.Comboitem;
|
||||
import org.zkoss.zul.ComboitemRenderer;
|
||||
|
|
@ -70,7 +64,6 @@ import org.zkoss.zul.Label;
|
|||
import org.zkoss.zul.Listbox;
|
||||
import org.zkoss.zul.Listcell;
|
||||
import org.zkoss.zul.Listitem;
|
||||
import org.zkoss.zul.Messagebox;
|
||||
import org.zkoss.zul.Row;
|
||||
import org.zkoss.zul.RowRenderer;
|
||||
import org.zkoss.zul.SimpleListModel;
|
||||
|
|
@ -83,20 +76,10 @@ import org.zkoss.zul.api.Window;
|
|||
* @author Diego Pino Garcia <dpino@igalia.com>
|
||||
* @author Lorenzo Tilve Álvaro <ltilve@igalia.com>
|
||||
*/
|
||||
public class MachineCRUDController extends GenericForwardComposer {
|
||||
|
||||
private Window listWindow;
|
||||
|
||||
private Window editWindow;
|
||||
public class MachineCRUDController extends BaseCRUDController<Machine> {
|
||||
|
||||
private IMachineModel machineModel;
|
||||
|
||||
private OnlyOneVisible visibility;
|
||||
|
||||
private IMessagesForUser messagesForUser;
|
||||
|
||||
private Component messagesContainer;
|
||||
|
||||
private Component configurationUnits;
|
||||
|
||||
private CriterionsMachineController criterionsController;
|
||||
|
|
@ -117,13 +100,6 @@ public class MachineCRUDController extends GenericForwardComposer {
|
|||
|
||||
private BandboxMultipleSearch bdFilters;
|
||||
|
||||
private static final Log LOG = LogFactory
|
||||
.getLog(MachineCRUDController.class);
|
||||
|
||||
public MachineCRUDController() {
|
||||
|
||||
}
|
||||
|
||||
private BaseCalendarsComboitemRenderer baseCalendarsComboitemRenderer = new BaseCalendarsComboitemRenderer();
|
||||
|
||||
public List<Machine> getMachines() {
|
||||
|
|
@ -137,8 +113,6 @@ public class MachineCRUDController extends GenericForwardComposer {
|
|||
@Override
|
||||
public void doAfterCompose(Component comp) throws Exception {
|
||||
super.doAfterCompose(comp);
|
||||
comp.setVariable("controller", this, true);
|
||||
messagesForUser = new MessagesForUser(messagesContainer);
|
||||
setupCriterionsController();
|
||||
setupConfigurationController();
|
||||
setupResourcesCostCategoryAssignmentController(comp);
|
||||
|
|
@ -147,10 +121,6 @@ public class MachineCRUDController extends GenericForwardComposer {
|
|||
setupFilterLimitingResourceListbox();
|
||||
}
|
||||
|
||||
private void showListWindow() {
|
||||
getVisibility().showOnly(listWindow);
|
||||
}
|
||||
|
||||
private void initFilterComponent() {
|
||||
this.filterFinishDate = (Datebox) listWindow
|
||||
.getFellowIfAny("filterFinishDate");
|
||||
|
|
@ -165,13 +135,6 @@ public class MachineCRUDController extends GenericForwardComposer {
|
|||
clearFilterDates();
|
||||
}
|
||||
|
||||
private OnlyOneVisible getVisibility() {
|
||||
if (visibility == null) {
|
||||
visibility = new OnlyOneVisible(listWindow, editWindow);
|
||||
}
|
||||
return visibility;
|
||||
}
|
||||
|
||||
private void setupCriterionsController() throws Exception {
|
||||
final Component comp = editWindow.getFellowIfAny("criterionsContainer");
|
||||
criterionsController = new CriterionsMachineController();
|
||||
|
|
@ -184,45 +147,29 @@ public class MachineCRUDController extends GenericForwardComposer {
|
|||
.getVariable("configurationController", true);
|
||||
}
|
||||
|
||||
private void setupResourcesCostCategoryAssignmentController(Component comp)
|
||||
{
|
||||
private void setupResourcesCostCategoryAssignmentController(Component comp) {
|
||||
Component costCategoryAssignmentContainer =
|
||||
editWindow.getFellowIfAny("costCategoryAssignmentContainer");
|
||||
resourcesCostCategoryAssignmentController = (ResourcesCostCategoryAssignmentController)
|
||||
costCategoryAssignmentContainer.getVariable("assignmentController", true);
|
||||
}
|
||||
|
||||
public void goToCreateForm() {
|
||||
@Override
|
||||
protected void initCreate() {
|
||||
machineModel.initCreate();
|
||||
criterionsController.prepareForCreate(machineModel.getMachine());
|
||||
configurationController.initConfigurationController(machineModel);
|
||||
resourcesCostCategoryAssignmentController.setResource(machineModel.getMachine());
|
||||
selectMachineDataTab();
|
||||
showEditWindow(_("Create Machine"));
|
||||
resourceCalendarModel.cancel();
|
||||
}
|
||||
|
||||
private void showEditWindow(String title) {
|
||||
editWindow.setTitle(title);
|
||||
showEditWindow();
|
||||
}
|
||||
|
||||
private void showEditWindow() {
|
||||
getVisibility().showOnly(editWindow);
|
||||
Util.reloadBindings(editWindow);
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads {@link Machine} into model, shares loaded {@link Machine} with
|
||||
* {@link CriterionsController}
|
||||
* @param machine
|
||||
*/
|
||||
public void goToEditForm(Machine machine) {
|
||||
@Override
|
||||
protected void initEdit(Machine machine) {
|
||||
machineModel.initEdit(machine);
|
||||
prepareCriterionsForEdit();
|
||||
prepareCalendarForEdit();
|
||||
selectMachineDataTab();
|
||||
showEditWindow(_("Edit Machine"));
|
||||
configurationController.initConfigurationController(machineModel);
|
||||
resourcesCostCategoryAssignmentController.setResource(machineModel.getMachine());
|
||||
}
|
||||
|
|
@ -254,35 +201,18 @@ public class MachineCRUDController extends GenericForwardComposer {
|
|||
Util.reloadBindings(createNewVersionWindow);
|
||||
}
|
||||
|
||||
public void save() {
|
||||
@Override
|
||||
protected void beforeSaving() throws ValidationException {
|
||||
validateConstraints();
|
||||
try {
|
||||
saveCalendar();
|
||||
if (!confirmCriterions()) {
|
||||
return;
|
||||
}
|
||||
machineModel.confirmSave();
|
||||
goToList();
|
||||
messagesForUser.showMessage(Level.INFO, _("Machine saved"));
|
||||
} catch (ValidationException e) {
|
||||
messagesForUser.showInvalidValues(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void saveAndContinue() {
|
||||
validateConstraints();
|
||||
try {
|
||||
saveCalendar();
|
||||
if (!confirmCriterions()) {
|
||||
return;
|
||||
}
|
||||
machineModel.confirmSave();
|
||||
goToEditForm(machineModel.getMachine());
|
||||
messagesForUser.showMessage(Level.INFO,_("Machine saved"));
|
||||
} catch (ValidationException e) {
|
||||
messagesForUser.showMessage(Level.ERROR,
|
||||
_("Could not save machine") + " " + showInvalidValues(e));
|
||||
@Override
|
||||
protected void save() throws ValidationException {
|
||||
saveCalendar();
|
||||
if (!confirmCriterions()) {
|
||||
return;
|
||||
}
|
||||
machineModel.confirmSave();
|
||||
}
|
||||
|
||||
private void validateConstraints() {
|
||||
|
|
@ -305,14 +235,6 @@ public class MachineCRUDController extends GenericForwardComposer {
|
|||
.getFellowIfAny("machineDataTabpanel"));
|
||||
}
|
||||
|
||||
private String showInvalidValues(ValidationException e) {
|
||||
String result = "";
|
||||
for (InvalidValue each : e.getInvalidValues()) {
|
||||
result = result + each.getMessage();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private void saveCalendar() throws ValidationException {
|
||||
if (baseCalendarEditionController != null) {
|
||||
baseCalendarEditionController.save();
|
||||
|
|
@ -332,15 +254,6 @@ public class MachineCRUDController extends GenericForwardComposer {
|
|||
return true;
|
||||
}
|
||||
|
||||
private void goToList() {
|
||||
getVisibility().showOnly(listWindow);
|
||||
Util.reloadBindings(listWindow);
|
||||
}
|
||||
|
||||
public void cancel() {
|
||||
goToList();
|
||||
}
|
||||
|
||||
public List<BaseCalendar> getBaseCalendars() {
|
||||
return machineModel.getBaseCalendars();
|
||||
}
|
||||
|
|
@ -620,28 +533,24 @@ public class MachineCRUDController extends GenericForwardComposer {
|
|||
}
|
||||
}
|
||||
|
||||
public void confirmRemove(Machine machine) {
|
||||
@Override
|
||||
protected boolean beforeDeleting(Machine machine) {
|
||||
if (!machineModel.canRemove(machine)) {
|
||||
messagesForUser
|
||||
.showMessage(
|
||||
Level.WARNING,
|
||||
_("This machine cannot be deleted because it has assignments to projects or imputed hours"));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void delete(Machine machine) {
|
||||
try {
|
||||
int status = Messagebox.show(_("Confirm deleting this machine. Are you sure?"), _("Delete"),
|
||||
Messagebox.OK | Messagebox.CANCEL, Messagebox.QUESTION);
|
||||
if (Messagebox.OK != status) {
|
||||
return;
|
||||
}
|
||||
if(machineModel.canRemove(machine)) {
|
||||
machineModel.confirmRemove(machine);
|
||||
messagesForUser.showMessage(Level.INFO, _("Machine deleted"));
|
||||
goToList();
|
||||
}
|
||||
else {
|
||||
messagesForUser.showMessage(Level.WARNING,
|
||||
_("This machine cannot be deleted because it has assignments to projects or imputed hours"));
|
||||
}
|
||||
} catch (InterruptedException e) {
|
||||
messagesForUser.showMessage(
|
||||
Level.ERROR, e.getMessage());
|
||||
machineModel.confirmRemove(machine);
|
||||
} catch (InstanceNotFoundException e) {
|
||||
messagesForUser.showMessage(
|
||||
Level.INFO, _("This machine was already removed by other user"));
|
||||
messagesForUser.showMessage(Level.INFO,
|
||||
_("This machine was already removed by other user"));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -677,7 +586,7 @@ public class MachineCRUDController extends GenericForwardComposer {
|
|||
hbox.appendChild(Util.createRemoveButton(new EventListener() {
|
||||
@Override
|
||||
public void onEvent(Event event) {
|
||||
confirmRemove(machine);
|
||||
confirmDelete(machine);
|
||||
}
|
||||
}));
|
||||
row.appendChild(hbox);
|
||||
|
|
@ -686,4 +595,19 @@ public class MachineCRUDController extends GenericForwardComposer {
|
|||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getEntityType() {
|
||||
return "Machine";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getPluralEntityType() {
|
||||
return "Machines";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Machine getEntityBeingEdited() {
|
||||
return machineModel.getMachine();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ public interface IProfileModel {
|
|||
*/
|
||||
void addRole(UserRole role);
|
||||
|
||||
void checkIsReferencedByOtherEntities(Profile profile) throws ValidationException;
|
||||
void checkHasUsers(Profile profile) throws ValidationException;
|
||||
|
||||
/**
|
||||
* Stores the removal of the passed {@link Profile}
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ package org.navalplanner.web.users;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import org.navalplanner.business.common.exceptions.InstanceNotFoundException;
|
||||
import org.navalplanner.business.common.exceptions.ValidationException;
|
||||
import org.navalplanner.business.users.entities.Profile;
|
||||
import org.navalplanner.business.users.entities.User;
|
||||
|
|
@ -125,4 +126,6 @@ public interface IUserModel {
|
|||
|
||||
boolean hasChangedDefaultPasswordOrDisabled(MandatoryUser admin);
|
||||
|
||||
void confirmRemove(User user) throws InstanceNotFoundException;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -196,7 +196,7 @@ public class ProfileCRUDController extends GenericForwardComposer implements
|
|||
|
||||
private boolean isReferencedByOtherEntities(Profile profile) {
|
||||
try {
|
||||
profileModel.checkIsReferencedByOtherEntities(profile);
|
||||
profileModel.checkHasUsers(profile);
|
||||
return false;
|
||||
} catch (ValidationException e) {
|
||||
showCannotDeleteProfileDialog(e.getInvalidValue().getMessage(),
|
||||
|
|
|
|||
|
|
@ -26,7 +26,9 @@ import java.util.List;
|
|||
|
||||
import org.navalplanner.business.common.exceptions.InstanceNotFoundException;
|
||||
import org.navalplanner.business.common.exceptions.ValidationException;
|
||||
import org.navalplanner.business.users.daos.IOrderAuthorizationDAO;
|
||||
import org.navalplanner.business.users.daos.IProfileDAO;
|
||||
import org.navalplanner.business.users.entities.OrderAuthorization;
|
||||
import org.navalplanner.business.users.entities.Profile;
|
||||
import org.navalplanner.business.users.entities.UserRole;
|
||||
import org.navalplanner.web.common.concurrentdetection.OnConcurrentModification;
|
||||
|
|
@ -52,6 +54,9 @@ public class ProfileModel implements IProfileModel {
|
|||
@Autowired
|
||||
private IProfileDAO profileDAO;
|
||||
|
||||
@Autowired
|
||||
private IOrderAuthorizationDAO orderAuthorizationDAO;
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void confirmSave() throws ValidationException {
|
||||
|
|
@ -126,6 +131,12 @@ public class ProfileModel implements IProfileModel {
|
|||
@Transactional
|
||||
public void confirmRemove(Profile profile)
|
||||
throws InstanceNotFoundException {
|
||||
List<OrderAuthorization> orderAuthorizations = profileDAO.getOrderAuthorizationsByProfile(profile);
|
||||
if (!orderAuthorizations.isEmpty()){
|
||||
for (OrderAuthorization orderAuthorization : orderAuthorizations) {
|
||||
orderAuthorizationDAO.remove(orderAuthorization.getId());
|
||||
}
|
||||
}
|
||||
profileDAO.remove(profile.getId());
|
||||
}
|
||||
|
||||
|
|
@ -140,8 +151,8 @@ public class ProfileModel implements IProfileModel {
|
|||
|
||||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
public void checkIsReferencedByOtherEntities(Profile profile) throws ValidationException {
|
||||
profileDAO.checkIsReferencedByOtherEntities(profile);
|
||||
public void checkHasUsers(Profile profile) throws ValidationException {
|
||||
profileDAO.checkHasUsers(profile);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,6 +25,8 @@ import static org.navalplanner.web.I18nHelper._;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.navalplanner.business.common.exceptions.InstanceNotFoundException;
|
||||
import org.navalplanner.business.common.exceptions.ValidationException;
|
||||
import org.navalplanner.business.users.entities.Profile;
|
||||
import org.navalplanner.business.users.entities.User;
|
||||
|
|
@ -46,6 +48,7 @@ import org.zkoss.zk.ui.util.GenericForwardComposer;
|
|||
import org.zkoss.zul.Combobox;
|
||||
import org.zkoss.zul.Comboitem;
|
||||
import org.zkoss.zul.Constraint;
|
||||
import org.zkoss.zul.Messagebox;
|
||||
import org.zkoss.zul.Textbox;
|
||||
import org.zkoss.zul.api.Window;
|
||||
|
||||
|
|
@ -58,6 +61,8 @@ import org.zkoss.zul.api.Window;
|
|||
public class UserCRUDController extends GenericForwardComposer implements
|
||||
IUserCRUDController {
|
||||
|
||||
private static final org.apache.commons.logging.Log LOG = LogFactory.getLog(UserCRUDController.class);
|
||||
|
||||
private Window createWindow;
|
||||
|
||||
private Window listWindow;
|
||||
|
|
@ -277,4 +282,35 @@ public class UserCRUDController extends GenericForwardComposer implements
|
|||
listWindow)
|
||||
: visibility;
|
||||
}
|
||||
|
||||
public void confirmRemove(User user) {
|
||||
int result = showConfirmDeleteUser(user);
|
||||
if (result == Messagebox.OK) {
|
||||
try {
|
||||
userModel.confirmRemove(user);
|
||||
goToList();
|
||||
} catch (InstanceNotFoundException e) {
|
||||
messagesForUser
|
||||
.showMessage(
|
||||
Level.ERROR,
|
||||
_("Cannot delete user: it does not exist anymore"));
|
||||
LOG.error(_("Error removing element: ", user.getId()), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private int showConfirmDeleteUser(User user) {
|
||||
try {
|
||||
return Messagebox.show(
|
||||
_("Confirm deleting this User. Are you sure?"),
|
||||
_("Delete"), Messagebox.OK | Messagebox.CANCEL,
|
||||
Messagebox.QUESTION);
|
||||
} catch (InterruptedException e) {
|
||||
LOG.error(
|
||||
_("Error on showing removing element: ", user.getId()),
|
||||
e);
|
||||
}
|
||||
return Messagebox.CANCEL;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,10 +26,11 @@ import java.util.List;
|
|||
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.navalplanner.business.common.Configuration;
|
||||
import org.navalplanner.business.common.Registry;
|
||||
import org.navalplanner.business.common.exceptions.InstanceNotFoundException;
|
||||
import org.navalplanner.business.common.exceptions.ValidationException;
|
||||
import org.navalplanner.business.users.daos.IOrderAuthorizationDAO;
|
||||
import org.navalplanner.business.users.daos.IUserDAO;
|
||||
import org.navalplanner.business.users.entities.OrderAuthorization;
|
||||
import org.navalplanner.business.users.entities.Profile;
|
||||
import org.navalplanner.business.users.entities.User;
|
||||
import org.navalplanner.business.users.entities.UserRole;
|
||||
|
|
@ -55,6 +56,9 @@ public class UserModel extends PasswordUtil implements IUserModel {
|
|||
@Autowired
|
||||
private IUserDAO userDAO;
|
||||
|
||||
@Autowired
|
||||
private IOrderAuthorizationDAO orderAuthorizationDAO;
|
||||
|
||||
@Autowired
|
||||
private IDBPasswordEncoderService dbPasswordEncoderService;
|
||||
|
||||
|
|
@ -221,4 +225,22 @@ public class UserModel extends PasswordUtil implements IUserModel {
|
|||
return user.hasChangedDefaultPasswordOrDisabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void confirmRemove(User user)
|
||||
throws InstanceNotFoundException {
|
||||
List<OrderAuthorization> orderAuthorizations = getReferencedByOtherEntities(user);
|
||||
if (!orderAuthorizations.isEmpty()) {
|
||||
for (OrderAuthorization orderAuthorization : orderAuthorizations) {
|
||||
orderAuthorizationDAO.remove(orderAuthorization.getId());
|
||||
}
|
||||
}
|
||||
userDAO.remove(user.getId());
|
||||
}
|
||||
|
||||
@Transactional(readOnly = true)
|
||||
public List<OrderAuthorization> getReferencedByOtherEntities(User user){
|
||||
return userDAO.getOrderAuthorizationsByUser(user);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ import java.util.List;
|
|||
import javax.xml.bind.annotation.XmlAttribute;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlElementWrapper;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
import org.navalplanner.business.calendars.entities.BaseCalendar;
|
||||
import org.navalplanner.ws.common.api.IntegrationEntityDTO;
|
||||
|
|
@ -36,6 +37,7 @@ import org.navalplanner.ws.common.api.IntegrationEntityDTO;
|
|||
*
|
||||
* @author Manuel Rego Casasnovas <mrego@igalia.com>
|
||||
*/
|
||||
@XmlRootElement(name = "base-calendar")
|
||||
public class BaseCalendarDTO extends IntegrationEntityDTO {
|
||||
|
||||
public final static String ENTITY_TYPE = "base-calendar";
|
||||
|
|
|
|||
|
|
@ -21,6 +21,8 @@
|
|||
|
||||
package org.navalplanner.ws.calendars.api;
|
||||
|
||||
import javax.ws.rs.core.Response;
|
||||
|
||||
import org.navalplanner.business.calendars.entities.BaseCalendar;
|
||||
import org.navalplanner.ws.common.api.InstanceConstraintViolationsListDTO;
|
||||
|
||||
|
|
@ -33,6 +35,9 @@ public interface ICalendarService {
|
|||
|
||||
BaseCalendarListDTO getBaseCalendars();
|
||||
|
||||
public InstanceConstraintViolationsListDTO addBaseCalendars(
|
||||
InstanceConstraintViolationsListDTO addBaseCalendars(
|
||||
BaseCalendarListDTO BaseCalendraListDTO);
|
||||
|
||||
Response getBaseCalendar(String code);
|
||||
|
||||
}
|
||||
|
|
@ -27,7 +27,9 @@ import javax.ws.rs.Consumes;
|
|||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.PathParam;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.core.Response;
|
||||
|
||||
import org.navalplanner.business.calendars.daos.IBaseCalendarDAO;
|
||||
import org.navalplanner.business.calendars.entities.BaseCalendar;
|
||||
|
|
@ -98,4 +100,13 @@ public class CalendarServiceREST extends
|
|||
BaseCalendarListDTO baseCalendraListDTO) {
|
||||
return save(baseCalendraListDTO.baseCalendars);
|
||||
}
|
||||
|
||||
@Override
|
||||
@GET
|
||||
@Path("/{code}/")
|
||||
@Transactional(readOnly = true)
|
||||
public Response getBaseCalendar(@PathParam("code") String code) {
|
||||
return getDTOByCode(code);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -24,6 +24,9 @@ package org.navalplanner.ws.common.impl;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.ws.rs.core.Response;
|
||||
import javax.ws.rs.core.Response.Status;
|
||||
|
||||
import org.navalplanner.business.common.IAdHocTransactionService;
|
||||
import org.navalplanner.business.common.IOnTransaction;
|
||||
import org.navalplanner.business.common.IntegrationEntity;
|
||||
|
|
@ -197,4 +200,36 @@ public abstract class GenericRESTService<E extends IntegrationEntity,
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a DTO searching by code. This will be useful for all REST
|
||||
* services of IntegrationEntities
|
||||
*
|
||||
* @param code
|
||||
* this is the code for the element which will be searched
|
||||
* @return DTO which represents the IntegrationEntity with this code
|
||||
* @throws InstanceNotFoundException
|
||||
* If entity with this code is not found
|
||||
*/
|
||||
protected DTO findByCode(String code) throws InstanceNotFoundException {
|
||||
return toDTO(getIntegrationEntityDAO().findByCode(code));
|
||||
}
|
||||
|
||||
/**
|
||||
* Wraps within a {@link Response} object the DTO searching the entity by
|
||||
* code.
|
||||
*
|
||||
* If entity is not found returns 404 HTTP status code (NOT_FOUND).
|
||||
*
|
||||
* @param code
|
||||
* this is the code for the element which will be searched
|
||||
* @return The {@link Response} with DTO if OK or 404 if NOT_FOUND
|
||||
*/
|
||||
protected Response getDTOByCode(String code) {
|
||||
try {
|
||||
return Response.ok(findByCode(code)).build();
|
||||
} catch (InstanceNotFoundException e) {
|
||||
return Response.status(Status.NOT_FOUND).build();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -49,7 +49,8 @@
|
|||
<label value="${i18n:_('Name')}"/>
|
||||
<textbox id="tbName"
|
||||
value="@{controller.exceptionDayType.name}"
|
||||
width="300px" />
|
||||
width="300px"
|
||||
onBlur="controller.updateWindowTitle()" />
|
||||
</row>
|
||||
<row>
|
||||
<label value="${i18n:_('Color')}" />
|
||||
|
|
@ -82,7 +83,7 @@
|
|||
<button onClick="controller.saveAndContinue()"
|
||||
label="${i18n:_('Save and Continue')}"
|
||||
sclass="save-button global-action"/>
|
||||
<button onClick="controller.cancel()"
|
||||
<button onClick="controller.cancelForm()"
|
||||
label="${i18n:_('Cancel')}"
|
||||
sclass="cancel-button global-action"/>
|
||||
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@
|
|||
<button sclass="icono" image="/common/img/ico_borrar1.png"
|
||||
hoverImage="/common/img/ico_borrar.png"
|
||||
tooltiptext="${i18n:_('Delete')}"
|
||||
onClick="controller.showRemoveConfirmationMessage(event)"/>
|
||||
onClick="controller.confirmDelete(self.parent.parent.value)"/>
|
||||
</hbox>
|
||||
</row>
|
||||
</rows>
|
||||
|
|
|
|||
|
|
@ -54,7 +54,8 @@
|
|||
<row>
|
||||
<label value="${i18n:_('Name')}" />
|
||||
<textbox value="@{controller.machine.name}" width="500px"
|
||||
constraint="no empty:${i18n:_('Name cannot be null or empty')}" />
|
||||
constraint="no empty:${i18n:_('Name cannot be null or empty')}"
|
||||
onBlur="controller.updateWindowTitle()" />
|
||||
</row>
|
||||
<row>
|
||||
<label value="${i18n:_('Description')}" />
|
||||
|
|
@ -93,13 +94,13 @@
|
|||
</tabpanels>
|
||||
</tabbox>
|
||||
<button label="${i18n:_('Save')}"
|
||||
onClick="controller.save();"
|
||||
onClick="controller.saveAndExit();"
|
||||
sclass="save-button global-action"/>
|
||||
<button label="${i18n:_('Save & Continue')}"
|
||||
onClick="controller.saveAndContinue();"
|
||||
sclass="save-button global-action"/>
|
||||
<button label="${i18n:_('Cancel')}"
|
||||
onClick="controller.cancel();"
|
||||
onClick="controller.cancelForm();"
|
||||
sclass="cancel-button global-action"/>
|
||||
|
||||
<zscript><![CDATA[
|
||||
|
|
|
|||
|
|
@ -41,6 +41,11 @@
|
|||
tooltiptext="${i18n:_('Edit')}"
|
||||
onClick="controller.goToEditForm(self.parent.parent.value);">
|
||||
</button>
|
||||
<button sclass="icono" image="/common/img/ico_borrar1.png"
|
||||
hoverImage="/common/img/ico_borrar.png"
|
||||
tooltiptext="${i18n:_('Delete')}"
|
||||
onClick="controller.confirmRemove(self.parent.parent.value);">
|
||||
</button>
|
||||
</hbox>
|
||||
</row>
|
||||
</rows>
|
||||
|
|
|
|||
|
|
@ -7,21 +7,25 @@ read loginName
|
|||
printf "Password: "
|
||||
read password
|
||||
|
||||
code=$2
|
||||
|
||||
if [ "$2" = "--prod" ]; then
|
||||
baseServiceURL=$PRODUCTION_BASE_SERVICE_URL
|
||||
certificate=$PRODUCTION_CERTIFICATE
|
||||
code=$3
|
||||
elif [ "$2" = "--dev" ]; then
|
||||
baseServiceURL=$DEVELOPMENT_BASE_SERVICE_URL
|
||||
certificate=$DEVELOPMENT_CERTIFICATE
|
||||
baseServiceURL=$DEVELOPMENT_BASE_SERVICE_URL
|
||||
certificate=$DEVELOPMENT_CERTIFICATE
|
||||
code=$3
|
||||
else
|
||||
baseServiceURL=$DEMO_BASE_SERVICE_URL
|
||||
certificate=$DEMO_CERTIFICATE
|
||||
baseServiceURL=$DEMO_BASE_SERVICE_URL
|
||||
certificate=$DEMO_CERTIFICATE
|
||||
fi
|
||||
|
||||
authorization=`echo -n "$loginName:$password" | base64`
|
||||
|
||||
result=`curl -sv -X GET $certificate --header "Authorization: Basic $authorization" \
|
||||
$baseServiceURL/$1`
|
||||
$baseServiceURL/$1/$code`
|
||||
|
||||
if hash tidy &> /dev/null; then
|
||||
echo $result | tidy -xml -i -q -utf8
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue