More extra data
This commit is contained in:
parent
625b023733
commit
22064c8c7c
5 changed files with 51 additions and 5 deletions
|
|
@ -21,6 +21,8 @@ public final class ExtraBuilder
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create an empty builder to create an {@link ExtraObject}.
|
* Create an empty builder to create an {@link ExtraObject}.
|
||||||
|
* It will be already pointing to the root object and values can be added
|
||||||
|
* to it.
|
||||||
*/
|
*/
|
||||||
public ExtraBuilder() {
|
public ExtraBuilder() {
|
||||||
this.path = new ArrayList<ExtraData>();
|
this.path = new ArrayList<ExtraData>();
|
||||||
|
|
@ -198,6 +200,28 @@ public final class ExtraBuilder
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a value to the current array.
|
||||||
|
* @param value The value to add.
|
||||||
|
* @throws IllegalStateException When not currently building an array.
|
||||||
|
* @throws IllegalArgumentException When not building an array of Integers.
|
||||||
|
*/
|
||||||
|
public void add(int value) throws IllegalStateException {
|
||||||
|
this.checkCurrentArray();
|
||||||
|
this.currentArray.addValue(new ExtraInt(this.currentArray.size(), value));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a value to the current object.
|
||||||
|
* @param field The name of the field that holds the value.
|
||||||
|
* @param value The value to add.
|
||||||
|
* @throws IllegalStateException When not currently building an object.
|
||||||
|
*/
|
||||||
|
public void add(String field, int value) throws IllegalStateException {
|
||||||
|
this.checkCurrentObject();
|
||||||
|
this.currentObject.setValue(new ExtraInt(field, value));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stop building extra data and get the final object.
|
* Stop building extra data and get the final object.
|
||||||
* Once close is called, no other operation can be done.
|
* Once close is called, no other operation can be done.
|
||||||
|
|
|
||||||
|
|
@ -8,5 +8,9 @@
|
||||||
* values. All values of {@link org.pasteque.coreutil.extra.ExtraData}
|
* values. All values of {@link org.pasteque.coreutil.extra.ExtraData}
|
||||||
* implementations are non-null. When the value is null, use an explicit
|
* implementations are non-null. When the value is null, use an explicit
|
||||||
* {@link org.pasteque.coreutil.extra.ExtraNull}.</p>
|
* {@link org.pasteque.coreutil.extra.ExtraNull}.</p>
|
||||||
|
* <p>Extra objects will be found only in the major classes and their
|
||||||
|
* associated DTO from coreutil. Other packages will have the semantic values
|
||||||
|
* instead and convert them to extra data only when creating a major version
|
||||||
|
* of itself through transition interfaces.</p>
|
||||||
*/
|
*/
|
||||||
package org.pasteque.coreutil.extra;
|
package org.pasteque.coreutil.extra;
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package org.pasteque.major.domain;
|
package org.pasteque.major.domain;
|
||||||
|
|
||||||
import org.pasteque.coreutil.datatransfer.dto.CashRegisterDTO;
|
import org.pasteque.coreutil.datatransfer.dto.CashRegisterDTO;
|
||||||
|
import org.pasteque.coreutil.extra.ExtraObject;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>Model for a cash register. Tickets are associated to a cash register
|
* <p>Model for a cash register. Tickets are associated to a cash register
|
||||||
|
|
@ -14,6 +15,8 @@ public class MajorCashRegister
|
||||||
private String label;
|
private String label;
|
||||||
/** {@see getNextTicketNumber()} */
|
/** {@see getNextTicketNumber()} */
|
||||||
private int nextTicketNumber;
|
private int nextTicketNumber;
|
||||||
|
/** See {@link getExtra()}. */
|
||||||
|
private ExtraObject extra;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create from all fields.
|
* Create from all fields.
|
||||||
|
|
@ -21,24 +24,28 @@ public class MajorCashRegister
|
||||||
* @param label See {@link getLabel()}.
|
* @param label See {@link getLabel()}.
|
||||||
* @param nextTicketNumber The number to assign to the next ticket
|
* @param nextTicketNumber The number to assign to the next ticket
|
||||||
* from this cash register.
|
* from this cash register.
|
||||||
|
* @param extra See {@link getExtra()}.
|
||||||
*/
|
*/
|
||||||
public MajorCashRegister(
|
public MajorCashRegister(
|
||||||
String reference,
|
String reference,
|
||||||
String label,
|
String label,
|
||||||
int nextTicketNumber) {
|
int nextTicketNumber,
|
||||||
|
ExtraObject extra) {
|
||||||
this.reference = reference;
|
this.reference = reference;
|
||||||
this.label = label;
|
this.label = label;
|
||||||
this.nextTicketNumber = nextTicketNumber;
|
this.nextTicketNumber = nextTicketNumber;
|
||||||
|
this.extra = extra;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create from a DTO. All data are copied to break references.
|
* Create from a DTO.
|
||||||
* @param dto The DTO to convert.
|
* @param dto The DTO to convert.
|
||||||
*/
|
*/
|
||||||
public MajorCashRegister(CashRegisterDTO dto) {
|
public MajorCashRegister(CashRegisterDTO dto) {
|
||||||
this.reference = new String(dto.getReference());
|
this.reference = dto.getReference();
|
||||||
this.label = new String(dto.getLabel());
|
this.label = dto.getLabel();
|
||||||
this.nextTicketNumber = dto.getNextTicketNumber();
|
this.nextTicketNumber = dto.getNextTicketNumber();
|
||||||
|
this.extra = dto.getExtra();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -77,4 +84,12 @@ public class MajorCashRegister
|
||||||
/* package */ final void revertNextTicketNumber() {
|
/* package */ final void revertNextTicketNumber() {
|
||||||
this.nextTicketNumber--;
|
this.nextTicketNumber--;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get all other data.
|
||||||
|
* @return The root object of extra data.
|
||||||
|
*/
|
||||||
|
public final ExtraObject getExtra() {
|
||||||
|
return this.extra;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,7 @@ public final class MajorOrder implements OrderTransition
|
||||||
private final Price2 finalTaxedPrice;
|
private final Price2 finalTaxedPrice;
|
||||||
private final ImmutableList<MajorLine> lines;
|
private final ImmutableList<MajorLine> lines;
|
||||||
private final Discount discount;
|
private final Discount discount;
|
||||||
|
/** See {@link getExtra()}. */
|
||||||
private final ExtraObject extra;
|
private final ExtraObject extra;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ package org.pasteque.major.domain;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import org.pasteque.coreutil.extra.ExtraObject;
|
||||||
import org.pasteque.coreutil.constants.FiscalTicketType;
|
import org.pasteque.coreutil.constants.FiscalTicketType;
|
||||||
import org.pasteque.coreutil.datatransfer.dto.FiscalTicketDTO;
|
import org.pasteque.coreutil.datatransfer.dto.FiscalTicketDTO;
|
||||||
|
|
||||||
|
|
@ -23,7 +24,8 @@ public final class MajorZTicket
|
||||||
MajorCashSession session,
|
MajorCashSession session,
|
||||||
Date closeDate,
|
Date closeDate,
|
||||||
int closeType,
|
int closeType,
|
||||||
List<Movement> endAmounts) {
|
List<Movement> endAmounts,
|
||||||
|
ExtraObject extra) {
|
||||||
// TODO: not implemented
|
// TODO: not implemented
|
||||||
throw new UnsupportedOperationException("Not implemented yet");
|
throw new UnsupportedOperationException("Not implemented yet");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue