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;
}
}
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());
}
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;
}
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;
}
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);
}
Aggregations