use of org.asqatasun.entity.parameterization.ParameterElement in project Asqatasun by Asqatasun.
the class ParameterElementDAOImpl method findParameterElementFromCode.
@Override
public ParameterElement findParameterElementFromCode(String parameterElementCode) {
Query query = entityManager.createQuery("SELECT pe FROM " + getEntityClass().getName() + " pe" + " WHERE pe.parameterElementCode = :parameterElementCode");
query.setParameter("parameterElementCode", parameterElementCode);
try {
return (ParameterElement) query.getSingleResult();
} catch (NoResultException nre) {
return null;
} catch (NonUniqueResultException nure) {
return null;
}
}
use of org.asqatasun.entity.parameterization.ParameterElement in project Asqatasun by Asqatasun.
the class AbstractRuleImplementationTestCase method createParameter.
/**
*
* @param familyValue
* @param elementValue
* @param value
* @return
*/
protected Parameter createParameter(String familyValue, String elementValue, String value) {
ParameterFamily parameterFamily = PARAMETER_FAMILY_FACTORY.create();
parameterFamily.setParameterFamilyCode(familyValue);
ParameterElement parameterElement = PARAMETER_ELEMENT_FACTORY.create();
parameterElement.setParameterFamily(parameterFamily);
parameterElement.setParameterElementCode(elementValue);
Parameter parameter = PARAMETER_FACTORY.create();
parameter.setValue(value);
parameter.setParameterElement(parameterElement);
return parameter;
}
use of org.asqatasun.entity.parameterization.ParameterElement in project Asqatasun by Asqatasun.
the class ParameterDataServiceDecoratorImpl method getParameterSetFromOptionElementSet.
@Override
public Collection<Parameter> getParameterSetFromOptionElementSet(Collection<OptionElement> optionElementSet) {
Set<Parameter> paramSet = new HashSet<>();
for (OptionElement optionElement : optionElementSet) {
ParameterElement pe = parameterElementDataService.getParameterElement(optionElement.getOption().getCode());
if (pe != null) {
Parameter p = decoratedParameterDataService.getParameter(pe, optionElement.getValue());
p = saveOrUpdate(p);
paramSet.add(p);
}
}
return paramSet;
}
use of org.asqatasun.entity.parameterization.ParameterElement in project Asqatasun by Asqatasun.
the class ParameterDataServiceImplTest method getParameter.
private Parameter getParameter(String family, String element, String value) {
ParameterFamily pf = new ParameterFamilyImpl();
pf.setParameterFamilyCode(family);
//ELEMENT1
ParameterElement pe = new ParameterElementImpl();
pe.setParameterElementCode(element);
Parameter p = new ParameterImpl();
p.setParameterElement(pe);
p.setValue(value);
return p;
}
use of org.asqatasun.entity.parameterization.ParameterElement in project Asqatasun by Asqatasun.
the class ParameterDAOImplTest method testFindParameter.
public void testFindParameter() {
ParameterElement paramElement = parameterElementDAO.read(Long.valueOf(1));
Parameter param = parameterDAO.findParameter(paramElement, "0");
assertNull(param);
for (int i = 1; i < 5; i++) {
param = parameterDAO.findParameter(paramElement, "Value" + i);
assertEquals(i, param.getId().intValue());
}
paramElement = parameterElementDAO.read(Long.valueOf(2));
param = parameterDAO.findParameter(paramElement, "4");
assertNull(param);
for (int i = 5; i < 9; i++) {
param = parameterDAO.findParameter(paramElement, "Value" + i);
assertEquals(i, param.getId().intValue());
}
}
Aggregations