Search in sources :

Example 16 with Parameter

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

the class AuditLauncherController method getAuditScenarioParameterSet.

/**
 * The default parameter set embeds a depth value that corresponds to the
 * site audit. We need here to replace this parameter by a parameter value
 * equals to 0.
 *
 * @return
 */
private Set<Parameter> getAuditScenarioParameterSet() {
    Set<Parameter> scenarioParamSet = getDefaultParamSet();
    Set<Parameter> parameterToRemove = new HashSet<>();
    for (Parameter param : scenarioParamSet) {
        if (StringUtils.equals(param.getParameterElement().getParameterElementCode(), TgolKeyStore.DEPTH_PARAM_KEY) || StringUtils.equals(param.getParameterElement().getParameterElementCode(), TgolKeyStore.MAX_DOCUMENT_PARAM_KEY) || StringUtils.equals(param.getParameterElement().getParameterElementCode(), TgolKeyStore.MAX_DURATION_PARAM_KEY) || StringUtils.equals(param.getParameterElement().getParameterElementCode(), TgolKeyStore.EXCLUSION_URL_LIST_PARAM_KEY)) {
            parameterToRemove.add(param);
        }
    }
    scenarioParamSet.removeAll(parameterToRemove);
    return scenarioParamSet;
}
Also used : Parameter(org.asqatasun.entity.parameterization.Parameter)

Example 17 with Parameter

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

the class AuditLauncherController method getAuditPageParameterSet.

/**
 * The default parameter set embeds a depth value that corresponds to the
 * site audit. We need here to replace this parameter by a parameter value
 * equals to 0.
 *
 * @return
 */
private Set<Parameter> getAuditPageParameterSet(int nbOfPages) {
    Set<Parameter> paramSet = new HashSet<>();
    ParameterElement depthParameterElement = parameterElementDataService.getParameterElement(TgolKeyStore.DEPTH_PARAM_KEY);
    ParameterElement maxDocParameterElement = parameterElementDataService.getParameterElement(TgolKeyStore.MAX_DOCUMENT_PARAM_KEY);
    Parameter depthParameter = parameterDataService.getParameter(depthParameterElement, TgolKeyStore.DEPTH_PAGE_PARAM_VALUE);
    Parameter maxDocParameter = parameterDataService.getParameter(maxDocParameterElement, String.valueOf(nbOfPages));
    paramSet.add(depthParameter);
    paramSet.add(maxDocParameter);
    return parameterDataService.updateParameterSet(getDefaultParamSet(), paramSet);
}
Also used : Parameter(org.asqatasun.entity.parameterization.Parameter) ParameterElement(org.asqatasun.entity.parameterization.ParameterElement)

Example 18 with Parameter

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

the class AuditLauncherController method getUserParamSet.

/**
 * This method gets the default parameters for an audit and eventually
 * override some of them in case of contract restriction.
 *
 * @param auditSetUpCommand
 * @param contractId
 * @param nbOfPages
 * @param url
 * @return
 */
private Set<Parameter> getUserParamSet(AuditSetUpCommand auditSetUpCommand, Long contractId, int nbOfPages, String url) {
    Set<Parameter> paramSet;
    Set<Parameter> userParamSet = new HashSet<>();
    if (auditSetUpCommand != null) {
        // parameter set
        if (auditSetUpCommand.getScope().equals(ScopeEnum.SCENARIO)) {
            paramSet = getAuditScenarioParameterSet();
        } else if (!auditSetUpCommand.getScope().equals(ScopeEnum.DOMAIN)) {
            paramSet = getAuditPageParameterSet(nbOfPages);
        } else {
            paramSet = getDefaultParamSet();
        }
        for (Map.Entry<String, String> entry : auditSetUpCommand.getAuditParameter().entrySet()) {
            Parameter param = parameterDataService.getParameter(parameterElementMap.get(entry.getKey()), entry.getValue());
            userParamSet.add(param);
        }
        paramSet = parameterDataService.updateParameterSet(paramSet, userParamSet);
        paramSet = setLevelParameter(paramSet, auditSetUpCommand.getLevel());
    } else {
        paramSet = getDefaultParamSet();
        Collection<OptionElementImpl> optionElementSet = contractDataService.read(contractId).getOptionElementSet();
        for (Parameter param : paramSet) {
            for (OptionElementImpl optionElement : optionElementSet) {
                if (optionElement.getOption().getCode().equalsIgnoreCase(param.getParameterElement().getParameterElementCode())) {
                    param = parameterDataService.getParameter(param.getParameterElement(), optionElement.getValue());
                    break;
                }
            }
            userParamSet.add(param);
        }
        paramSet = parameterDataService.updateParameterSet(paramSet, userParamSet);
    }
    return (auditSetUpCommand.getLevel() != null) ? setUserParameters(paramSet, auditSetUpCommand.getLevel().split(";")[0]) : paramSet;
}
Also used : OptionElementImpl(org.asqatasun.entity.option.OptionElementImpl) Parameter(org.asqatasun.entity.parameterization.Parameter)

Example 19 with Parameter

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

the class AuditStatisticsFactory method getAuditParameters.

/**
 * Retrieves all the parameters of the audit and prepares the data depending
 * on the wished displayed parameters of the view.
 *
 * @param audit
 * @param parametersToDisplay
 * @return
 */
private Map<String, String> getAuditParameters(Audit audit, Map<String, String> parametersToDisplay) {
    Map<String, String> auditParameters = new LinkedHashMap();
    Set<Parameter> auditParamSet = parameterDataService.getParameterSetFromAudit(audit);
    // the parameter management has been integrated
    if (auditParamSet.isEmpty()) {
        return auditParameters;
    }
    for (Map.Entry<String, String> entry : parametersToDisplay.entrySet()) {
        for (Parameter param : auditParamSet) {
            if (entry.getKey().equals(param.getParameterElement().getParameterElementCode())) {
                auditParameters.put(entry.getValue(), param.getValue());
            }
        }
    }
    if (!parametersToDisplay.isEmpty()) {
        auditParameters.put(TgolKeyStore.REFERENTIAL_PARAM_KEY, parameterDataService.getReferentialKeyFromAudit(audit));
    }
    return auditParameters;
}
Also used : Parameter(org.asqatasun.entity.parameterization.Parameter)

Example 20 with Parameter

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

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