BigDecimal piecePrice = price != null ? price : piece.getPrice();
BigDecimal pieceValueAddedTaxPercentage = valueAddedTaxPercentage != null
? valueAddedTaxPercentage : piece.getValueAddedTaxPercentage();
if (piece instanceof CatalogDoorOrWindow) {
CatalogDoorOrWindow opening = (CatalogDoorOrWindow)piece;
piece = new CatalogDoorOrWindow(pieceId, pieceName, pieceDescription,
pieceIcon, opening.getPlanIcon(), pieceModel,
pieceWidth, pieceDepth, pieceHeight, pieceElevation, pieceMovable,
opening.getWallThickness(), opening.getWallDistance(), opening.getSashes(),
pieceModelRotation, pieceCreator, pieceResizable, pieceDeformable, piece.isTexturable(),
piecePrice, pieceValueAddedTaxPercentage);
} else if (piece instanceof CatalogLight) {
CatalogLight light = (CatalogLight)piece;
piece = new CatalogLight(pieceId, pieceName, pieceDescription,
pieceIcon, light.getPlanIcon(), pieceModel,
pieceWidth, pieceDepth, pieceHeight, pieceElevation, pieceMovable, light.getLightSources(),
pieceModelRotation, pieceCreator, pieceResizable, pieceDeformable, piece.isTexturable(),
piecePrice, pieceValueAddedTaxPercentage);
} else {
if (doorOrWindow != null && doorOrWindow) {
piece = new CatalogDoorOrWindow(pieceId, pieceName, pieceDescription,
pieceIcon, piece.getPlanIcon(), pieceModel,
pieceWidth, pieceDepth, pieceHeight, pieceElevation, pieceMovable,
1, 0, new Sash [0],
pieceModelRotation, pieceCreator, pieceResizable, pieceDeformable, piece.isTexturable(),
piecePrice, pieceValueAddedTaxPercentage);