Implement filtering by criteria
Pending to remove children with invalidated criteria from the calculation of the data for the containers. FEA: ItEr77S09WBSReport
This commit is contained in:
parent
cdc733ce8d
commit
242cfa8e35
2 changed files with 42 additions and 1 deletions
|
|
@ -64,6 +64,7 @@ import org.libreplan.business.qualityforms.entities.TaskQualityForm;
|
|||
import org.libreplan.business.requirements.entities.CriterionRequirement;
|
||||
import org.libreplan.business.requirements.entities.DirectCriterionRequirement;
|
||||
import org.libreplan.business.requirements.entities.IndirectCriterionRequirement;
|
||||
import org.libreplan.business.resources.entities.Criterion;
|
||||
import org.libreplan.business.scenarios.entities.OrderVersion;
|
||||
import org.libreplan.business.scenarios.entities.Scenario;
|
||||
import org.libreplan.business.templates.entities.OrderElementTemplate;
|
||||
|
|
@ -1268,6 +1269,26 @@ public abstract class OrderElement extends IntegrationEntity implements
|
|||
return matches == labels.size();
|
||||
}
|
||||
|
||||
public boolean containsCriterion(String code) {
|
||||
for (CriterionRequirement criterionRequirement : getDirectCriterionRequirement()) {
|
||||
if (criterionRequirement.getCriterion().getCode().equals(code)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean containsCriteria(Set<Criterion> criteria) {
|
||||
Integer matches = 0;
|
||||
for (Criterion criterion : criteria) {
|
||||
if (containsCriterion(criterion.getCode())) {
|
||||
matches++;
|
||||
}
|
||||
}
|
||||
return matches == criteria.size();
|
||||
}
|
||||
|
||||
public boolean containsMaterialAssignment(String materialCode) {
|
||||
for (MaterialAssignment materialAssignment : getMaterialAssignments()) {
|
||||
if (materialAssignment.getMaterial().getCode().equals(materialCode)) {
|
||||
|
|
|
|||
|
|
@ -97,6 +97,7 @@ public class ProjectStatusReportModel implements IProjectStatusReportModel {
|
|||
|
||||
List<OrderElement> orderElements = order.getAllChildren();
|
||||
orderElements = filterBySelectedLabels(orderElements);
|
||||
orderElements = filterBySelectedCriteria(orderElements);
|
||||
|
||||
for (OrderElement child : orderElements) {
|
||||
dtos.add(calculateDTO(child));
|
||||
|
|
@ -118,7 +119,7 @@ public class ProjectStatusReportModel implements IProjectStatusReportModel {
|
|||
|
||||
private void calculateTotalDTO(Order order,
|
||||
List<ProjectStatusReportDTO> dtos) {
|
||||
if (getSelectedLabels().isEmpty()) {
|
||||
if (isNotFiltering()) {
|
||||
totalDTO = calculateDTO(order);
|
||||
} else {
|
||||
EffortDuration estimatedHours = EffortDuration.zero();
|
||||
|
|
@ -149,6 +150,10 @@ public class ProjectStatusReportModel implements IProjectStatusReportModel {
|
|||
}
|
||||
}
|
||||
|
||||
private boolean isNotFiltering() {
|
||||
return selectedLabels.isEmpty() && selectedCriteria.isEmpty();
|
||||
}
|
||||
|
||||
private List<OrderElement> filterBySelectedLabels(
|
||||
List<OrderElement> orderElements) {
|
||||
if (selectedLabels.isEmpty()) {
|
||||
|
|
@ -164,6 +169,21 @@ public class ProjectStatusReportModel implements IProjectStatusReportModel {
|
|||
return result;
|
||||
}
|
||||
|
||||
private List<OrderElement> filterBySelectedCriteria(
|
||||
List<OrderElement> orderElements) {
|
||||
if (selectedCriteria.isEmpty()) {
|
||||
return orderElements;
|
||||
}
|
||||
|
||||
List<OrderElement> result = new ArrayList<OrderElement>();
|
||||
for (OrderElement orderElement : orderElements) {
|
||||
if (orderElement.containsCriteria(selectedCriteria)) {
|
||||
result.add(orderElement);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private EffortDuration addIfNotNull(EffortDuration total,
|
||||
EffortDuration other) {
|
||||
if (other == null) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue