use of org.asqatasun.entity.option.Option in project Asqatasun by Asqatasun.
the class OptionDAO method findOptionFromCode.
public Option findOptionFromCode(String optionCode) {
Query query = entityManager.createQuery("SELECT o FROM " + getEntityClass().getName() + " o" + " WHERE o.code = :optionCode");
query.setParameter("optionCode", optionCode);
try {
return (Option) query.getSingleResult();
} catch (NoResultException | NonUniqueResultException nre) {
return null;
}
}
use of org.asqatasun.entity.option.Option in project Asqatasun by Asqatasun.
the class ChangeTestWeightCommandFactory method updateUserTestWeight.
/**
* @param user
* @param changeTestWeightCommand
*/
public void updateUserTestWeight(User user, ChangeTestWeightCommand changeTestWeightCommand) {
Collection<OptionElementImpl> userOptionElementSet = optionElementDataService.getOptionElementFromUser(user);
// first we need to remove the option elements associated with the user
// that are going to be updated
Iterator<OptionElementImpl> iter = userOptionElementSet.iterator();
// testWeightMap.
while (iter.hasNext()) {
OptionElementImpl oe = iter.next();
if (changeTestWeightCommand.getTestWeightMap().containsKey(oe.getOption().getCode()) && !StringUtils.isEmpty(changeTestWeightCommand.getTestWeightMap().get(oe.getOption().getCode()))) {
iter.remove();
}
}
for (Map.Entry<String, String> entry : changeTestWeightCommand.getTestWeightMap().entrySet()) {
if (!StringUtils.isEmpty(entry.getValue())) {
String value = entry.getValue().replaceAll(",", ".");
Option option = optionDataService.getOption(entry.getKey());
OptionElementImpl oe = optionElementDataService.getOptionElementFromValueAndOption(value, option);
if (oe == null) {
oe = optionElementDataService.create();
oe.setOption(option);
oe.setValue(value);
optionElementDataService.saveOrUpdate(oe);
}
userOptionElementSet.add(oe);
}
}
user.addAllOptionElement(userOptionElementSet);
userDataService.saveOrUpdate(user);
}
use of org.asqatasun.entity.option.Option in project Asqatasun by Asqatasun.
the class CreateContractCommandFactory method init.
@PostConstruct
private void init() {
referentialList = referentialDataService.findAll();
LoggerFactory.getLogger(this.getClass()).debug("All referentials" + referentialList.size());
referentialList.forEach((referential) -> LoggerFactory.getLogger(this.getClass()).debug(referential.getCode()));
functionalityList = functionalityDataService.findAll();
for (Option option : optionDataService.findAll()) {
if (option.getCode().equals(DOMAIN_OPTION_CODE)) {
contractUrlOption = option;
} else {
optionList.add(option);
}
}
}
use of org.asqatasun.entity.option.Option in project Asqatasun by Asqatasun.
the class CreateContractCommandFactory method addOptionToCommand.
/**
* @param ccc
* @param contract
*/
private void addOptionToCommand(CreateContractCommand ccc, Contract contract) {
Map<String, String> optionMap = new LinkedHashMap<>();
for (Option option : optionList) {
optionMap.put(option.getCode(), getValueFromOptionElementCollection(contract.getOptionElementSet(), option));
}
ccc.setOptionMap(optionMap);
}
use of org.asqatasun.entity.option.Option in project Asqatasun by Asqatasun.
the class CreateContractCommandFactory method addNewOptionsToCommand.
/**
* @param ccc
*/
private void addNewOptionsToCommand(CreateContractCommand ccc) {
Map<String, String> optionMap = new LinkedHashMap<String, String>();
for (Option option : optionList) {
if (!option.getCode().equals(DOMAIN_OPTION_CODE)) {
optionMap.put(option.getCode(), "");
}
}
ccc.setOptionMap(optionMap);
}
Aggregations