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