String categoryIdStr = element.getAttributeValue("categoryId");
String quantityStr = element.getAttributeValue("quantity");
String typeStr = element.getAttributeValue("type");
if (productIdStr != null) {
Expression expression = (Expression) StandardExpressions.getExpressionParser(args.getConfiguration())
.parseExpression(args.getConfiguration(), args, productIdStr);
Object productId = expression.execute(args.getConfiguration(), args);
if (productId instanceof BigDecimal) {
productId = new Long(((BigDecimal) productId).toPlainString());
}
relatedProductDTO.setProductId((Long) productId);
}
if (categoryIdStr != null) {
Expression expression = (Expression) StandardExpressions.getExpressionParser(args.getConfiguration())
.parseExpression(args.getConfiguration(), args, categoryIdStr);
Object categoryId = expression.execute(args.getConfiguration(), args);
if (categoryId instanceof BigDecimal) {
categoryId = new Long(((BigDecimal) categoryId).toPlainString());
}
relatedProductDTO.setCategoryId((Long) categoryId);
}
if (quantityStr != null) {
Expression expression = (Expression) StandardExpressions.getExpressionParser(args.getConfiguration())
.parseExpression(args.getConfiguration(), args, quantityStr);
Object quantityExp = expression.execute(args.getConfiguration(), args);
int quantity = 0;
if (quantityExp instanceof String) {
quantity = Integer.parseInt((String)quantityExp);
} else {
quantity = ((BigDecimal)expression.execute(args.getConfiguration(), args)).intValue();
}
relatedProductDTO.setQuantity(quantity);
}
if (typeStr != null ) {
Expression expression = (Expression) StandardExpressions.getExpressionParser(args.getConfiguration())
.parseExpression(args.getConfiguration(), args, typeStr);
Object typeExp = expression.execute(args.getConfiguration(), args);
if (typeExp instanceof String && RelatedProductTypeEnum.getInstance((String)typeExp) != null) {
relatedProductDTO.setType(RelatedProductTypeEnum.getInstance((String)typeExp));
}
}