import org.blueoxygen.postila.materialmanagement.materialmanagementrules.entity.UnitOfMeasure;
public class SaveUOM extends UOMForm {
public String execute(){
UnitOfMeasure uom;
if(getUnitOfMeasure().getId() != null || !"".equalsIgnoreCase(getUnitOfMeasure().getId())){
uom = new UnitOfMeasure();
logInfo = new LogInformation();
logInfo.setCreateBy(sessionCredentials.getCurrentUser().getId());
logInfo.setCreateDate(new Timestamp(System.currentTimeMillis()));
} else {
uom = (UnitOfMeasure) manager.getById(UnitOfMeasure.class, getUnitOfMeasure().getId());
logInfo = new LogInformation();
}
logInfo.setActiveFlag(getActive());
logInfo.setLastUpdateBy(sessionCredentials.getCurrentUser().getId());
logInfo.setLastUpdateDate(new Timestamp(System.currentTimeMillis()));
uom.setLogInformation(logInfo);
uom.setCode(getUnitOfMeasure().getCode());
uom.setSymbol(getUnitOfMeasure().getCode());
uom.setName(getUnitOfMeasure().getName());
uom.setPdefault(getUnitOfMeasure().getPdefault());
uom.setStandardPrecision(getUnitOfMeasure().getStandardPrecision());
uom.setCostingPrecision(getUnitOfMeasure().getCostingPrecision());
manager.save(uom);
setUnitOfMeasure(uom);
return SUCCESS;
}