Search in sources :

Example 51 with Parameter

use of org.asqatasun.entity.parameterization.Parameter in project Asqatasun by Asqatasun.

the class ParameterDAOImpl method findDefaultParameterSet.

/**
 * The database has to contain only one default parameter value for a given
 * parameter element. The control is made on application-side. The first
 * encountered default value is considered as the default value.
 *
 * @return
 *      the default parameter set.
 */
@Override
public Set<Parameter> findDefaultParameterSet() {
    Set<Parameter> paramSet = new LinkedHashSet<>();
    Set<String> paramElementSet = new HashSet<>();
    Query query = entityManager.createQuery("SELECT p FROM " + getEntityClass().getName() + " p" + " WHERE p.isDefaultParameterValue = :isDefault");
    query.setParameter("isDefault", true);
    try {
        for (Parameter parameter : (List<Parameter>) query.getResultList()) {
            String paramElement = parameter.getParameterElement().getParameterElementCode();
            if (!paramElementSet.contains(paramElement)) {
                paramSet.add(parameter);
            }
            paramElementSet.add(paramElement);
        }
        return paramSet;
    } catch (NoResultException nre) {
        return paramSet;
    }
}
Also used : Query(javax.persistence.Query) Parameter(org.asqatasun.entity.parameterization.Parameter) NoResultException(javax.persistence.NoResultException)

Example 52 with Parameter

use of org.asqatasun.entity.parameterization.Parameter in project Asqatasun by Asqatasun.

the class AnalyserImplTest method testComputeRawMark.

public void testComputeRawMark() {
    WebResourceStatisticsFactory webResourceStatisticsFactory = new WebResourceStatisticsFactoryImpl();
    WebResourceStatisticsDataService webResourceStatisticsDataService = new WebResourceStatisticsDataServiceImpl();
    webResourceStatisticsDataService.setEntityFactory(webResourceStatisticsFactory);
    AnalyserImpl analyser = new AnalyserImpl(null, null, null, webResourceStatisticsDataService, null, null, null, new ArrayList<Parameter>(), 1);
    WebResourceStatistics wrStats = analyser.getWebResourceStatisticsDataService().create();
    wrStats.setNbOfPassed(0);
    wrStats.setNbOfFailed(0);
    wrStats.setNbOfNmi(0);
    // wrStats.setWeightedPassed(BigDecimal.valueOf(Double.valueOf("0.0")));
    wrStats.setWeightedFailed(BigDecimal.valueOf(Double.valueOf("0.0")));
    wrStats.setWeightedNmi(BigDecimal.valueOf(Double.valueOf("21.1")));
    wrStats.setWeightedNa(BigDecimal.valueOf(Double.valueOf("114.2")));
    assertEquals(Double.valueOf(0).floatValue(), analyser.computeRawMark(wrStats).getRawMark());
    // wrStats.setWeightedPassed(BigDecimal.valueOf(Double.valueOf("44.0")));
    // assertEquals(Double.valueOf(100).floatValue(), analyser.computeRawMark(wrStats).getRawMark().floatValue());
    // wrStats.setWeightedPassed(BigDecimal.valueOf(Double.valueOf("0")));
    wrStats.setWeightedFailed(BigDecimal.valueOf(Double.valueOf("44.0")));
    assertEquals(Double.valueOf(0).floatValue(), analyser.computeRawMark(wrStats).getRawMark());
    wrStats.setNbOfPassed(45);
    wrStats.setNbOfFailed(84541);
    wrStats.setNbOfNmi(97541);
    // wrStats.setWeightedPassed(BigDecimal.valueOf(Double.valueOf("10.4")));
    wrStats.setWeightedFailed(BigDecimal.valueOf(Double.valueOf("44.8")));
    wrStats.setWeightedNmi(BigDecimal.valueOf(Double.valueOf("21.1")));
    wrStats.setWeightedNa(BigDecimal.valueOf(Double.valueOf("114.2")));
    assertEquals(Double.valueOf(50.11).floatValue(), analyser.computeRawMark(wrStats).getRawMark());
    // the nmi value is not taken into account
    wrStats.setWeightedNmi(BigDecimal.valueOf(Double.valueOf("1.1")));
    wrStats.setWeightedNa(BigDecimal.valueOf(Double.valueOf("134.4")));
    assertEquals(Double.valueOf(50.11).floatValue(), analyser.computeRawMark(wrStats).getRawMark());
    wrStats.setWeightedPassed(BigDecimal.valueOf(Double.valueOf("50.4")));
    wrStats.setWeightedFailed(BigDecimal.valueOf(Double.valueOf("24.8")));
    assertEquals(Double.valueOf(64.47).floatValue(), analyser.computeRawMark(wrStats).getRawMark());
}
Also used : WebResourceStatisticsFactory(org.asqatasun.entity.statistics.factory.WebResourceStatisticsFactory) WebResourceStatisticsDataServiceImpl(org.asqatasun.entity.service.statistics.WebResourceStatisticsDataServiceImpl) Parameter(org.asqatasun.entity.parameterization.Parameter) WebResourceStatisticsDataService(org.asqatasun.entity.service.statistics.WebResourceStatisticsDataService) WebResourceStatistics(org.asqatasun.entity.statistics.WebResourceStatistics) WebResourceStatisticsFactoryImpl(org.asqatasun.entity.statistics.factory.WebResourceStatisticsFactoryImpl)

Example 53 with Parameter

use of org.asqatasun.entity.parameterization.Parameter 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 54 with Parameter

use of org.asqatasun.entity.parameterization.Parameter in project Asqatasun by Asqatasun.

the class ParameterDataServiceImpl method getParameterSetFromOptionElementSet.

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 = getParameter(pe, optionElement.getValue());
            p = saveOrUpdate(p);
            paramSet.add(p);
        }
    }
    return paramSet;
}
Also used : OptionElement(org.asqatasun.entity.option.OptionElement) Parameter(org.asqatasun.entity.parameterization.Parameter) ParameterElement(org.asqatasun.entity.parameterization.ParameterElement) HashSet(java.util.HashSet)

Example 55 with Parameter

use of org.asqatasun.entity.parameterization.Parameter in project Asqatasun by Asqatasun.

the class ParameterDataServiceImpl method getParameterSetFromAuditLevel.

@Override
public Set<Parameter> getParameterSetFromAuditLevel(String ref, String level) {
    if (ref.equalsIgnoreCase(RGAA22_REF) || ref.equalsIgnoreCase(RGAA30_REF) || ref.equalsIgnoreCase(RGAA40_REF)) {
        if (level.equalsIgnoreCase(BRONZE_LEVEL)) {
            level = A_LEVEL;
        } else if (level.equalsIgnoreCase(SILVER_LEVEL)) {
            level = AA_LEVEL;
        } else if (level.equalsIgnoreCase(GOLD_LEVEL)) {
            level = AAA_LEVEL;
        }
    }
    if (level.equalsIgnoreCase(BRONZE_LEVEL) || level.equalsIgnoreCase(A_LEVEL)) {
        level = LEVEL_1;
    } else if (level.equalsIgnoreCase(SILVER_LEVEL) || level.equalsIgnoreCase(AA_LEVEL)) {
        level = LEVEL_2;
    } else if (level.equalsIgnoreCase(GOLD_LEVEL) || level.equalsIgnoreCase(AAA_LEVEL)) {
        level = LEVEL_3;
    }
    ParameterElement levelParameterElement = parameterElementDataService.getParameterElement(LEVEL_PARAMETER_ELEMENT_CODE);
    Parameter levelParameter = getParameter(levelParameterElement, ref + ";" + level);
    Set<Parameter> paramSet = getDefaultParameterSet();
    return updateParameter(paramSet, levelParameter);
}
Also used : Parameter(org.asqatasun.entity.parameterization.Parameter) ParameterElement(org.asqatasun.entity.parameterization.ParameterElement)

Aggregations

Parameter (org.asqatasun.entity.parameterization.Parameter)59 ParameterElement (org.asqatasun.entity.parameterization.ParameterElement)13 Audit (org.asqatasun.entity.audit.Audit)8 ParameterImpl (org.asqatasun.entity.parameterization.ParameterImpl)6 NoResultException (javax.persistence.NoResultException)5 Query (javax.persistence.Query)5 HashSet (java.util.HashSet)4 AuditCommand (org.asqatasun.service.command.AuditCommand)4 AuditCommandFactory (org.asqatasun.service.command.factory.AuditCommandFactory)4 Test (org.junit.Test)4 File (java.io.File)3 IOException (java.io.IOException)3 Crawler (org.asqatasun.crawler.Crawler)3 ParameterElementImpl (org.asqatasun.entity.parameterization.ParameterElementImpl)3 LinkedHashSet (java.util.LinkedHashSet)2 ParameterFamily (org.asqatasun.entity.parameterization.ParameterFamily)2 WebResourceStatisticsDataService (org.asqatasun.entity.service.statistics.WebResourceStatisticsDataService)2 WebResourceStatisticsDataServiceImpl (org.asqatasun.entity.service.statistics.WebResourceStatisticsDataServiceImpl)2 WebResourceStatistics (org.asqatasun.entity.statistics.WebResourceStatistics)2 WebResourceStatisticsFactory (org.asqatasun.entity.statistics.factory.WebResourceStatisticsFactory)2