Search in sources :

Example 6 with ParameterElement

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;
    }
}
Also used : NonUniqueResultException(javax.persistence.NonUniqueResultException) Query(javax.persistence.Query) ParameterElement(org.asqatasun.entity.parameterization.ParameterElement) NoResultException(javax.persistence.NoResultException)

Example 7 with ParameterElement

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;
}
Also used : ParameterFamily(org.asqatasun.entity.parameterization.ParameterFamily) Parameter(org.asqatasun.entity.parameterization.Parameter) ParameterElement(org.asqatasun.entity.parameterization.ParameterElement)

Example 8 with ParameterElement

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;
}
Also used : OptionElement(org.asqatasun.webapp.entity.option.OptionElement) Parameter(org.asqatasun.entity.parameterization.Parameter) ParameterElement(org.asqatasun.entity.parameterization.ParameterElement) HashSet(java.util.HashSet)

Example 9 with ParameterElement

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;
}
Also used : ParameterFamily(org.asqatasun.entity.parameterization.ParameterFamily) ParameterImpl(org.asqatasun.entity.parameterization.ParameterImpl) Parameter(org.asqatasun.entity.parameterization.Parameter) ParameterElement(org.asqatasun.entity.parameterization.ParameterElement) ParameterFamilyImpl(org.asqatasun.entity.parameterization.ParameterFamilyImpl) ParameterElementImpl(org.asqatasun.entity.parameterization.ParameterElementImpl)

Example 10 with ParameterElement

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());
    }
}
Also used : Parameter(org.asqatasun.entity.parameterization.Parameter) ParameterElement(org.asqatasun.entity.parameterization.ParameterElement)

Aggregations

ParameterElement (org.asqatasun.entity.parameterization.ParameterElement)11 Parameter (org.asqatasun.entity.parameterization.Parameter)9 ParameterElementImpl (org.asqatasun.entity.parameterization.ParameterElementImpl)2 ParameterFamily (org.asqatasun.entity.parameterization.ParameterFamily)2 HashSet (java.util.HashSet)1 NoResultException (javax.persistence.NoResultException)1 NonUniqueResultException (javax.persistence.NonUniqueResultException)1 Query (javax.persistence.Query)1 ParameterFamilyImpl (org.asqatasun.entity.parameterization.ParameterFamilyImpl)1 ParameterImpl (org.asqatasun.entity.parameterization.ParameterImpl)1 ParameterDataService (org.asqatasun.entity.service.parameterization.ParameterDataService)1 WebResourceDataService (org.asqatasun.entity.service.subject.WebResourceDataService)1 OptionElement (org.asqatasun.webapp.entity.option.OptionElement)1 StatisticsDataService (org.asqatasun.webapp.entity.service.statistics.StatisticsDataService)1