bug 1633 fixed

This commit is contained in:
Vova Perebykivskiy 2015-09-08 10:28:00 +03:00 committed by Jeroen Baten
parent 17ef953a86
commit 7531b75ac0
4 changed files with 17 additions and 11 deletions

4
.gitignore vendored
View file

@ -10,6 +10,10 @@ ganttzk/target
.project .project
.settings/ .settings/
# ignore IDEA configuration files
.idea
*.iml
#ignore patches files #ignore patches files
*.patch *.patch

View file

@ -105,6 +105,7 @@ public abstract class IntegrationEntity extends BaseEntity {
* with the same code. This method is a Template method that calls on * with the same code. This method is a Template method that calls on
* the private method <code>findIntegrationEntityDAO</code>, which in turn * the private method <code>findIntegrationEntityDAO</code>, which in turn
* calls on the abstract method <code>getIntegrationEntityDAO()</code>. * calls on the abstract method <code>getIntegrationEntityDAO()</code>.
* Code of entity looks like: "WORK_REPORT_0001"
*/ */
@AssertTrue(message="code is already used") @AssertTrue(message="code is already used")
public boolean isUniqueCodeConstraint() { public boolean isUniqueCodeConstraint() {

View file

@ -110,16 +110,13 @@ public class EntitySequenceDAO extends
for (int i = 0; i < 5; i++) { for (int i = 0; i < 5; i++) {
try { try {
String code; String code;
Integer cont = 0;
EntitySequence entitySequence = getActiveEntitySequence(entityName); EntitySequence entitySequence = getActiveEntitySequence(entityName);
do { do {
entitySequence.incrementLastValue(); entitySequence.incrementLastValue();
code = entitySequence.getCode(); code = entitySequence.getCode();
cont++;
} while (entityName.getIntegrationEntityDAO() } while (entityName.getIntegrationEntityDAO()
.existsByCode(code) .existsByCode(code));
&& cont < 100);
save(entitySequence); save(entitySequence);
return code; return code;

View file

@ -440,19 +440,23 @@ public class WorkReport extends IntegrationEntity implements
public void generateWorkReportLineCodes(int numberOfDigits) { public void generateWorkReportLineCodes(int numberOfDigits) {
for (WorkReportLine line : this.getWorkReportLines()) { for (WorkReportLine line : this.getWorkReportLines()) {
if ((line.getCode() == null) || (line.getCode().isEmpty())
|| (!line.getCode().startsWith(this.getCode()))) { if ((line.getCode() == null) || (line.getCode().isEmpty()) ||
(!line.getCode().startsWith(this.getCode()))) {
this.incrementLastWorkReportLineSequenceCode(); this.incrementLastWorkReportLineSequenceCode();
String lineCode = EntitySequence.formatValue(numberOfDigits,
this.getLastWorkReportLineSequenceCode()); String lineCode = EntitySequence.formatValue(
line.setCode(this.getCode() numberOfDigits, this.getLastWorkReportLineSequenceCode());
+ EntitySequence.CODE_SEPARATOR_CHILDREN + lineCode);
line.setCode(this.getCode() +
EntitySequence.CODE_SEPARATOR_CHILDREN + lineCode);
} }
} }
} }
public void incrementLastWorkReportLineSequenceCode() { public void incrementLastWorkReportLineSequenceCode() {
if(lastWorkReportLineSequenceCode==null){ if(lastWorkReportLineSequenceCode == null){
lastWorkReportLineSequenceCode = 0; lastWorkReportLineSequenceCode = 0;
} }
lastWorkReportLineSequenceCode++; lastWorkReportLineSequenceCode++;