Create new default progress type TIMESHEETS

The new progress type is read-only, so a new field to mark it in AdvanceType has
been added and used in the UI accordingly.

FEA: ItEr77S12AdaptPlanningAccordingTimesheets
This commit is contained in:
Manuel Rego Casasnovas 2012-10-30 10:28:09 +01:00
parent 4adc1ec71f
commit e4bd4b980f
7 changed files with 87 additions and 11 deletions

View file

@ -36,16 +36,26 @@ public enum PredefinedAdvancedTypes {
UNITS("units", new BigDecimal(Integer.MAX_VALUE),
new BigDecimal(1), false, false),
SUBCONTRACTOR("subcontractor",
new BigDecimal(100), new BigDecimal(0.01), true, false);
new BigDecimal(100), new BigDecimal(0.01), true, false),
TIMESHEETS("timesheets",
new BigDecimal(100), new BigDecimal(0.01), true, false, true);
private PredefinedAdvancedTypes(String name, BigDecimal defaultMaxValue,
BigDecimal precision, boolean percentage, boolean qualityForm) {
this(name, defaultMaxValue, precision, percentage, qualityForm, false);
}
private PredefinedAdvancedTypes(String name, BigDecimal defaultMaxValue,
BigDecimal precision, boolean percentage, boolean qualityForm,
boolean readOnly) {
this.name = name;
this.defaultMaxValue = defaultMaxValue.setScale(4,
BigDecimal.ROUND_HALF_UP);
this.unitPrecision = precision.setScale(4, BigDecimal.ROUND_HALF_UP);
this.percentage = percentage;
this.qualityForm = qualityForm;
this.readOnly = readOnly;
}
private final String name;
@ -58,9 +68,13 @@ public enum PredefinedAdvancedTypes {
private final boolean qualityForm;
private final boolean readOnly;
public AdvanceType createType() {
return AdvanceType.create(name, defaultMaxValue, false, unitPrecision,
true, percentage, qualityForm);
AdvanceType advanceType = AdvanceType.create(name, defaultMaxValue,
false, unitPrecision, true, percentage, qualityForm);
advanceType.setReadOnly(readOnly);
return advanceType;
}
public String getTypeName() {

View file

@ -86,6 +86,8 @@ public class AdvanceType extends BaseEntity implements IHumanIdentifiable{
private IAdvanceTypeDAO avanceTypeDAO = Registry.getAdvanceTypeDao();
private boolean readOnly = false;
/**
* Constructor for hibernate. Do not use!
*/
@ -271,4 +273,12 @@ public class AdvanceType extends BaseEntity implements IHumanIdentifiable{
return true;
}
public void setReadOnly(boolean readOnly) {
this.readOnly = readOnly;
}
public boolean isReadOnly() {
return readOnly;
}
}

View file

@ -87,4 +87,20 @@
</addColumn>
</changeSet>
<changeSet id="add-new-column-read_only-to-advance_type" author="mrego">
<comment>
Add new column read_only with default value FALSE to advance_type
table.
</comment>
<addColumn tableName="advance_type">
<column name="read_only" type="BOOLEAN" />
</addColumn>
<addDefaultValue tableName="advance_type" columnName="read_only"
defaultValueBoolean="FALSE" />
<addNotNullConstraint tableName="advance_type"
columnName="read_only"
defaultNullValue="FALSE"
columnDataType="BOOLEAN" />
</changeSet>
</databaseChangeLog>

View file

@ -23,6 +23,7 @@
<property name="percentage" access="field"/>
<property name="qualityForm" access="field"
column="quality_form" />
<property name="readOnly" column="read_only" />
</class>

View file

@ -99,6 +99,8 @@ public interface IManageOrderElementAdvancesModel {
public boolean isQualityForm(AdvanceAssignment advance);
public boolean isReadOnly(AdvanceAssignment advance);
public boolean lessThanPreviousMeasurements();
public boolean hasConsolidatedAdvances(AdvanceAssignment advance);
@ -134,4 +136,5 @@ public interface IManageOrderElementAdvancesModel {
Boolean isAlreadyReportedProgressWith(LocalDate date);
}

View file

@ -366,7 +366,10 @@ public class ManageOrderElementAdvancesController extends
if (advance.getAdvanceType() != null) {
isQualityForm = manageOrderElementAdvancesModel
.isQualityForm(advance);
if (manageOrderElementAdvancesModel
readOnlyAdvance = manageOrderElementAdvancesModel
.isReadOnly(advance);
if (!readOnlyAdvance
&& manageOrderElementAdvancesModel
.isSubcontratedAdvanceTypeAndSubcontratedTask(advance)) {
readOnlyAdvance = true;
}
@ -375,12 +378,12 @@ public class ManageOrderElementAdvancesController extends
if ((advance instanceof DirectAdvanceAssignment)
&& ((DirectAdvanceAssignment) advance)
.getAdvanceMeasurements().isEmpty()
&& !isQualityForm) {
&& !isQualityForm && !readOnlyAdvance) {
appendComboboxAdvanceType(listItem);
} else {
appendLabelAdvanceType(listItem);
}
appendDecimalBoxMaxValue(listItem, isQualityForm);
appendDecimalBoxMaxValue(listItem, isQualityForm || readOnlyAdvance);
appendDecimalBoxValue(listItem);
appendLabelPercentage(listItem);
appendDateBoxDate(listItem);
@ -401,7 +404,8 @@ public class ManageOrderElementAdvancesController extends
for(AdvanceType advanceType : listAdvanceType){
if (!advanceType.getUnitName().equals(
PredefinedAdvancedTypes.CHILDREN.getTypeName())
&& !advanceType.isQualityForm()) {
&& !advanceType.isQualityForm()
&& !advanceType.isReadOnly()) {
Comboitem comboItem = new Comboitem();
comboItem.setValue(advanceType);
comboItem.setLabel(advanceType.getUnitName());
@ -461,7 +465,7 @@ public class ManageOrderElementAdvancesController extends
}
private void appendDecimalBoxMaxValue(final Listitem listItem,
boolean isQualityForm) {
boolean isQualityFormOrReadOnly) {
final AdvanceAssignment advanceAssignment = (AdvanceAssignment) listItem
.getValue();
final Decimalbox maxValue = new Decimalbox();
@ -469,7 +473,7 @@ public class ManageOrderElementAdvancesController extends
final DirectAdvanceAssignment directAdvanceAssignment;
if ((advanceAssignment instanceof IndirectAdvanceAssignment)
|| isQualityForm
|| isQualityFormOrReadOnly
|| (advanceAssignment.getAdvanceType() != null && advanceAssignment
.getAdvanceType().getPercentage())
|| manageOrderElementAdvancesModel
@ -708,6 +712,11 @@ public class ManageOrderElementAdvancesController extends
addMeasurementButton.setDisabled(true);
addMeasurementButton
.setTooltiptext(_("Progress that are reported by quality forms can not be modified"));
} else if ((advance.getAdvanceType() != null)
&& (advance.getAdvanceType().isReadOnly())) {
addMeasurementButton.setDisabled(true);
addMeasurementButton
.setTooltiptext(_("This progress type cannot be modified"));
} else if (advance instanceof IndirectAdvanceAssignment) {
addMeasurementButton.setDisabled(true);
addMeasurementButton
@ -739,6 +748,11 @@ public class ManageOrderElementAdvancesController extends
removeButton.setDisabled(true);
removeButton
.setTooltiptext(_("Progress that are reported by quality forms cannot be modified"));
} else if ((advance.getAdvanceType() != null)
&& (advance.getAdvanceType().isReadOnly())) {
removeButton.setDisabled(true);
removeButton
.setTooltiptext(_("This progress type cannot be modified"));
} else if (advance instanceof IndirectAdvanceAssignment) {
removeButton.setDisabled(true);
removeButton
@ -1219,6 +1233,11 @@ public class ManageOrderElementAdvancesController extends
removeButton.setDisabled(true);
removeButton
.setTooltiptext(_("Progress measurements that are reported by quality forms cannot be removed"));
} else if ((advance.getAdvanceType() != null)
&& (advance.getAdvanceType().isReadOnly())) {
removeButton.setDisabled(true);
removeButton
.setTooltiptext(_("This progress type cannot cannot be removed"));
} else if (advance.isFake()) {
removeButton.setDisabled(true);
removeButton

View file

@ -161,7 +161,8 @@ public class ManageOrderElementAdvancesModel implements
for (AdvanceAssignment advance : listAdvanceAssignmentsCopy) {
if ((!listAdvanceAssignments.contains(advance))
&& (advance instanceof DirectAdvanceAssignment)
&& (!advance.getAdvanceType().isQualityForm())) {
&& (!advance.getAdvanceType().isQualityForm())
&& (!advance.getAdvanceType().isReadOnly())) {
listAdvanceAssignments.add(advance);
}
}
@ -337,7 +338,8 @@ public class ManageOrderElementAdvancesModel implements
for (AdvanceType advanceType : this.listAdvanceTypes) {
if ((advanceType.getUnitName()
.equals(PredefinedAdvancedTypes.CHILDREN.getTypeName()))
|| (advanceType.isQualityForm())) {
|| (advanceType.isQualityForm())
|| advanceType.isReadOnly()) {
continue;
}
if (existsAdvanceTypeAlreadyInThisOrderElement(advanceType)) {
@ -412,6 +414,9 @@ public class ManageOrderElementAdvancesModel implements
if (advanceType.isQualityForm()) {
return true;
}
if (advanceType.isReadOnly()) {
return true;
}
}
if(isIndirectAdvanceAssignment){
@ -764,6 +769,14 @@ public class ManageOrderElementAdvancesModel implements
return advanceType.isQualityForm();
}
@Override
@Transactional(readOnly = true)
public boolean isReadOnly(AdvanceAssignment advance) {
AdvanceType advanceType = advance.getAdvanceType();
advanceTypeDAO.reattach(advanceType);
return advanceType.isReadOnly();
}
@Override
@Transactional(readOnly = true)
public boolean findIndirectConsolidation(