ItEr41S20CUGravacionModelosUnidadesTraballoItEr40S25: Removing IOrderLineGroupManipulator since Order extends OrderLineGroup.
This commit is contained in:
parent
4d0c4ebfb1
commit
013425c9ca
7 changed files with 64 additions and 133 deletions
|
|
@ -1,32 +0,0 @@
|
|||
/*
|
||||
* This file is part of ###PROJECT_NAME###
|
||||
*
|
||||
* Copyright (C) 2009 Fundación para o Fomento da Calidade Industrial e
|
||||
* Desenvolvemento Tecnolóxico de Galicia
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package org.navalplanner.business.orders.entities;
|
||||
|
||||
import org.navalplanner.business.trees.ITreeNode;
|
||||
|
||||
/**
|
||||
* Container of {@link OrderElement}. <br />
|
||||
*
|
||||
* @author Óscar González Fernández <ogonzalez@igalia.com>
|
||||
*/
|
||||
public interface IOrderLineGroup extends ITreeNode<OrderElement> {
|
||||
|
||||
}
|
||||
|
|
@ -46,7 +46,53 @@ import org.navalplanner.business.advance.exceptions.DuplicateAdvanceAssignmentFo
|
|||
import org.navalplanner.business.advance.exceptions.DuplicateValueTrueReportGlobalAdvanceException;
|
||||
import org.navalplanner.business.templates.entities.OrderElementTemplate;
|
||||
import org.navalplanner.business.templates.entities.OrderLineGroupTemplate;
|
||||
public class OrderLineGroup extends OrderElement implements IOrderLineGroup {
|
||||
import org.navalplanner.business.trees.ITreeNode;
|
||||
import org.navalplanner.business.trees.TreeNodeOnList;
|
||||
|
||||
|
||||
public class OrderLineGroup extends OrderElement implements
|
||||
ITreeNode<OrderElement> {
|
||||
|
||||
private final class ChildrenManipulator extends
|
||||
TreeNodeOnList<OrderElement, OrderLineGroup> {
|
||||
|
||||
private ChildrenManipulator(OrderLineGroup parent,
|
||||
List<OrderElement> children) {
|
||||
super(parent, children);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onChildAdded(OrderElement newChild) {
|
||||
final OrderLineGroup parent = getParent();
|
||||
if (parent != null) {
|
||||
SchedulingState schedulingState = newChild
|
||||
.getSchedulingState();
|
||||
removeSchedulingStateFromParent(newChild);
|
||||
parent.getSchedulingState().add(schedulingState);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onChildRemoved(OrderElement previousChild) {
|
||||
removeSchedulingStateFromParent(previousChild);
|
||||
}
|
||||
|
||||
private void removeSchedulingStateFromParent(
|
||||
OrderElement previousChild) {
|
||||
SchedulingState schedulingState = previousChild
|
||||
.getSchedulingState();
|
||||
if (!schedulingState.isRoot()) {
|
||||
schedulingState.getParent().removeChild(schedulingState);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setParentIfRequired(OrderElement newChild) {
|
||||
if (getParent() != null) {
|
||||
newChild.setParent(getParent());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static OrderLineGroup create() {
|
||||
OrderLineGroup result = new OrderLineGroup();
|
||||
|
|
@ -146,9 +192,8 @@ public class OrderLineGroup extends OrderElement implements IOrderLineGroup {
|
|||
getManipulator().up(orderElement);
|
||||
}
|
||||
|
||||
private OrderLineGroupManipulator getManipulator() {
|
||||
return OrderLineGroupManipulator.createManipulatorForOrderLineGroup(
|
||||
this, children);
|
||||
private ChildrenManipulator getManipulator() {
|
||||
return new ChildrenManipulator(this, children);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -1,80 +0,0 @@
|
|||
/*
|
||||
* This file is part of ###PROJECT_NAME###
|
||||
*
|
||||
* Copyright (C) 2009 Fundación para o Fomento da Calidade Industrial e
|
||||
* Desenvolvemento Tecnolóxico de Galicia
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package org.navalplanner.business.orders.entities;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.navalplanner.business.trees.TreeNodeOnList;
|
||||
|
||||
/**
|
||||
* Implementation of {@link IOrderLineGroup}. <br />
|
||||
* @author Óscar González Fernández <ogonzalez@igalia.com>
|
||||
*/
|
||||
public class OrderLineGroupManipulator extends
|
||||
TreeNodeOnList<OrderElement, OrderLineGroup> {
|
||||
|
||||
public static OrderLineGroupManipulator createManipulatorForOrder(
|
||||
List<OrderElement> orderElements) {
|
||||
return new OrderLineGroupManipulator(null, orderElements);
|
||||
}
|
||||
|
||||
public static OrderLineGroupManipulator createManipulatorForOrderLineGroup(
|
||||
OrderLineGroup group, List<OrderElement> children) {
|
||||
return new OrderLineGroupManipulator(group, children);
|
||||
}
|
||||
|
||||
private OrderLineGroupManipulator(OrderLineGroup parent,
|
||||
List<OrderElement> orderElements) {
|
||||
super(parent, orderElements);
|
||||
}
|
||||
|
||||
protected void setParentIfRequired(OrderElement orderElement) {
|
||||
if (getParent() != null) {
|
||||
orderElement.setParent(getParent());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onChildAdded(OrderElement newChild) {
|
||||
addSchedulingStateToParent(newChild);
|
||||
}
|
||||
|
||||
private void addSchedulingStateToParent(OrderElement orderElement) {
|
||||
final OrderLineGroup parent = getParent();
|
||||
if (parent != null) {
|
||||
SchedulingState schedulingState = orderElement.getSchedulingState();
|
||||
removeSchedulingStateFromParent(orderElement);
|
||||
parent.getSchedulingState().add(schedulingState);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onChildRemoved(OrderElement previousChild) {
|
||||
removeSchedulingStateFromParent(previousChild);
|
||||
}
|
||||
|
||||
private void removeSchedulingStateFromParent(OrderElement orderElement) {
|
||||
SchedulingState schedulingState = orderElement.getSchedulingState();
|
||||
if (!schedulingState.isRoot()) {
|
||||
schedulingState.getParent().removeChild(schedulingState);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -27,9 +27,9 @@ import java.util.Map;
|
|||
import org.navalplanner.business.calendars.entities.BaseCalendar;
|
||||
import org.navalplanner.business.common.exceptions.ValidationException;
|
||||
import org.navalplanner.business.labels.entities.Label;
|
||||
import org.navalplanner.business.orders.entities.IOrderLineGroup;
|
||||
import org.navalplanner.business.orders.entities.Order;
|
||||
import org.navalplanner.business.orders.entities.OrderElement;
|
||||
import org.navalplanner.business.orders.entities.OrderLineGroup;
|
||||
import org.navalplanner.business.qualityforms.entities.QualityForm;
|
||||
import org.navalplanner.business.resources.entities.Criterion;
|
||||
import org.navalplanner.business.resources.entities.CriterionType;
|
||||
|
|
@ -62,7 +62,7 @@ public interface IOrderModel {
|
|||
|
||||
List<QualityForm> getQualityForms();
|
||||
|
||||
IOrderLineGroup getOrder();
|
||||
OrderLineGroup getOrder();
|
||||
|
||||
IOrderElementModel getOrderElementModel(OrderElement orderElement);
|
||||
|
||||
|
|
|
|||
|
|
@ -32,10 +32,10 @@ import org.hibernate.validator.InvalidValue;
|
|||
import org.navalplanner.business.calendars.entities.BaseCalendar;
|
||||
import org.navalplanner.business.common.exceptions.ValidationException;
|
||||
import org.navalplanner.business.orders.entities.HoursGroup;
|
||||
import org.navalplanner.business.orders.entities.IOrderLineGroup;
|
||||
import org.navalplanner.business.orders.entities.Order;
|
||||
import org.navalplanner.business.orders.entities.OrderElement;
|
||||
import org.navalplanner.business.orders.entities.OrderLine;
|
||||
import org.navalplanner.business.orders.entities.OrderLineGroup;
|
||||
import org.navalplanner.web.common.IMessagesForUser;
|
||||
import org.navalplanner.web.common.Level;
|
||||
import org.navalplanner.web.common.MessagesForUser;
|
||||
|
|
@ -262,7 +262,7 @@ public class OrderCRUDController extends GenericForwardComposer {
|
|||
return cachedOnlyOneVisible;
|
||||
}
|
||||
|
||||
public IOrderLineGroup getOrder() {
|
||||
public OrderLineGroup getOrder() {
|
||||
return orderModel.getOrder();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -26,7 +26,6 @@ import java.util.ArrayList;
|
|||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.navalplanner.business.orders.entities.IOrderLineGroup;
|
||||
import org.navalplanner.business.orders.entities.Order;
|
||||
import org.navalplanner.business.orders.entities.OrderElement;
|
||||
import org.navalplanner.business.orders.entities.OrderLine;
|
||||
|
|
@ -117,7 +116,7 @@ public class OrderElementTreeModel {
|
|||
|
||||
private void addOrderElementAt(OrderElement parent,
|
||||
OrderElement orderElement) {
|
||||
IOrderLineGroup container = turnIntoContainerIfNeeded(parent);
|
||||
OrderLineGroup container = turnIntoContainerIfNeeded(parent);
|
||||
container.add(orderElement);
|
||||
addToTree(toNode(container), orderElement);
|
||||
updateCriterionRequirementsInHierarchy(parent, orderElement,
|
||||
|
|
@ -126,7 +125,7 @@ public class OrderElementTreeModel {
|
|||
|
||||
private void addOrderElementAt(OrderElement destinationNode,
|
||||
OrderElement elementToAdd, int position) {
|
||||
IOrderLineGroup container = turnIntoContainerIfNeeded(destinationNode);
|
||||
OrderLineGroup container = turnIntoContainerIfNeeded(destinationNode);
|
||||
container.add(position, elementToAdd);
|
||||
addToTree(toNode(container), position, elementToAdd);
|
||||
updateCriterionRequirementsInHierarchy(destinationNode, elementToAdd,
|
||||
|
|
@ -143,16 +142,16 @@ public class OrderElementTreeModel {
|
|||
}
|
||||
}
|
||||
|
||||
private OrderElement toNode(IOrderLineGroup container) {
|
||||
return (OrderElement) container;
|
||||
private OrderElement toNode(OrderLineGroup container) {
|
||||
return container;
|
||||
}
|
||||
|
||||
private IOrderLineGroup turnIntoContainerIfNeeded(
|
||||
private OrderLineGroup turnIntoContainerIfNeeded(
|
||||
OrderElement selectedForTurningIntoContainer) {
|
||||
if (selectedForTurningIntoContainer instanceof IOrderLineGroup) {
|
||||
return (IOrderLineGroup) selectedForTurningIntoContainer;
|
||||
if (selectedForTurningIntoContainer instanceof OrderLineGroup) {
|
||||
return (OrderLineGroup) selectedForTurningIntoContainer;
|
||||
}
|
||||
IOrderLineGroup parentContainer = asOrderLineGroup(getParent(selectedForTurningIntoContainer));
|
||||
OrderLineGroup parentContainer = asOrderLineGroup(getParent(selectedForTurningIntoContainer));
|
||||
OrderLineGroup asContainer = selectedForTurningIntoContainer
|
||||
.toContainer();
|
||||
parentContainer.replace(selectedForTurningIntoContainer, asContainer);
|
||||
|
|
@ -234,13 +233,13 @@ public class OrderElementTreeModel {
|
|||
}
|
||||
|
||||
public void up(OrderElement node) {
|
||||
IOrderLineGroup orderLineGroup = asOrderLineGroup(tree.getParent(node));
|
||||
OrderLineGroup orderLineGroup = asOrderLineGroup(tree.getParent(node));
|
||||
orderLineGroup.up(node);
|
||||
tree.up(node);
|
||||
}
|
||||
|
||||
public void down(OrderElement node) {
|
||||
IOrderLineGroup orderLineGroup = asOrderLineGroup(tree.getParent(node));
|
||||
OrderLineGroup orderLineGroup = asOrderLineGroup(tree.getParent(node));
|
||||
orderLineGroup.down(node);
|
||||
tree.down(node);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -49,7 +49,6 @@ import org.navalplanner.business.labels.entities.Label;
|
|||
import org.navalplanner.business.orders.daos.IOrderDAO;
|
||||
import org.navalplanner.business.orders.daos.IOrderElementDAO;
|
||||
import org.navalplanner.business.orders.entities.HoursGroup;
|
||||
import org.navalplanner.business.orders.entities.IOrderLineGroup;
|
||||
import org.navalplanner.business.orders.entities.Order;
|
||||
import org.navalplanner.business.orders.entities.OrderElement;
|
||||
import org.navalplanner.business.orders.entities.OrderLine;
|
||||
|
|
@ -406,7 +405,7 @@ public class OrderModel implements IOrderModel {
|
|||
}
|
||||
|
||||
@Override
|
||||
public IOrderLineGroup getOrder() {
|
||||
public OrderLineGroup getOrder() {
|
||||
return order;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue