<commit_before>/*
 * Tanaguru - Automated webpage assessment
 * Copyright (C) 2008-2011  Open-S Company
 *
 * This file is part of Tanaguru.
 *
 * Tanaguru is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * Contact us by mail: open-s AT open-s DOT com
 */
package org.opens.tgol.entity.decorator.tanaguru.subject;

import org.opens.tanaguru.sdk.entity.service.AbstractGenericDataService;
import org.opens.tgol.util.HttpStatusCodeFamily;
import org.opens.tgol.entity.dao.statistics.StatisticsDAO;
import org.opens.tgol.entity.dao.tanaguru.subject.TgolWebResourceDAO;
import org.opens.tgol.presentation.data.PageResult;
import java.util.Collection;
import java.util.List;
import org.opens.tanaguru.entity.audit.Audit;
import org.opens.tanaguru.entity.audit.ProcessResult;
import org.opens.tanaguru.entity.audit.TestSolution;
import org.opens.tanaguru.entity.reference.Scope;
import org.opens.tanaguru.entity.reference.Theme;
import org.opens.tanaguru.entity.service.subject.WebResourceDataService;
import org.opens.tanaguru.entity.subject.Page;
import org.opens.tanaguru.entity.subject.Site;
import org.opens.tanaguru.entity.subject.WebResource;
import org.springframework.beans.factory.annotation.Autowired;

/**
 *
 * @author jkowalczyk
 */
public class WebResourceDataServiceDecoratorImpl extends AbstractGenericDataService<WebResource, Long>
        implements WebResourceDataServiceDecorator{

    private WebResourceDataService decoratedWebResourceDataService; // the WebResourceDataService instance being decorated
    private StatisticsDAO statisticsDAO;

    @Autowired
    public WebResourceDataServiceDecoratorImpl (
            WebResourceDataService decoratedWebResourceDataService,
            StatisticsDAO statisticsDAO) {
        this.decoratedWebResourceDataService = decoratedWebResourceDataService;
        this.statisticsDAO = statisticsDAO;
    }

    @Override
    public Long getParentWebResourceId(Long webresourceId) {
        return ((TgolWebResourceDAO)entityDao).retrieveParentWebResourceId(webresourceId);
    }

    @Override
    public Page createPage(String pageURL) {
        return decoratedWebResourceDataService.createPage(pageURL);
    }

    @Override
    public Site createSite(String siteURL) {
        return decoratedWebResourceDataService.createSite(siteURL);
    }

    @Override
    public WebResource getByUrl(String url) {
        return decoratedWebResourceDataService.getByUrl(url);
    }

    @Override
    public WebResource read(Long key) {
        return decoratedWebResourceDataService.read(key);
    }

    @Override
    public Collection<? extends Object> getFailedWebResourceSortedByTest(
            WebResource webResource,
            Audit audit,
            int nbOfResult) {
        return statisticsDAO.findFailedWebResourceSortedByTest(
                    webResource, 
                    audit,
                    nbOfResult);
    }

    @Override
    public Collection<? extends Object> getFailedWebResourceSortedByOccurrence(
            WebResource webResource,
            Audit audit,
            int nbOfResult) {
        return statisticsDAO.findFailedWebResourceSortedByOccurrence(
                    webResource, 
                    audit,
                    nbOfResult);
    }

    @Override
    public Collection<? extends Object> getFailedTestByOccurrence(
            WebResource webResource,
            Audit audit,
            int nbOfResult) {
        return statisticsDAO.findFailedTestByOccurrence(
                    webResource,
                    audit, 
                    nbOfResult);
    }

    @Override
    public WebResource ligthRead(Long webResourceId) {
        return ((TgolWebResourceDAO)entityDao).ligthRead(webResourceId);
    }

    @Override
    public WebResource deepRead(Long webResourceId) {
        return this.read(webResourceId);
    }

    @Override
    public Long getResultCountByResultType(
            WebResource webResource,
            Audit audit, 
            TestSolution testSolution) {
        return statisticsDAO.findResultCountByResultType(
                webResource,
                audit, 
                testSolution);
    }

    @Override
    public Collection<? extends Object> getResultCountByResultTypeAndTheme(
            WebResource webResource,
            Audit audit,
            TestSolution testSolution,
            int nb0fResult) {
        return statisticsDAO.findResultCountByResultTypeAndTheme(
                webResource,
                audit, 
                testSolution,
                nb0fResult);
    }

    @Override
    public Long getChildWebResourceCount(WebResource parentWebresource) {
        return ((TgolWebResourceDAO)entityDao).retrieveChildWebResourceCount(
                parentWebresource);
    }

    @Override
    public Collection<ProcessResult> getProcessResultListByWebResourceAndScope(WebResource webResource, Scope scope) {
        return ((TgolWebResourceDAO)entityDao).
                retrieveProcessResultListByWebResourceAndScope(webResource, scope);
    }

    @Override
    public Long getResultCountByResultTypeAndTheme(
            WebResource webResource,
            Audit audit,
            TestSolution testSolution,
            Theme theme) {
        return statisticsDAO.findResultCountByResultTypeAndTheme(
            webResource,audit,testSolution,theme);
    }
<commit_msg>Feature #255 : tgol-si : Add a console to sort results in the result page (WebResourceDataServiceDecorator implementation)<commit_after>/*
 * Tanaguru - Automated webpage assessment
 * Copyright (C) 2008-2011  Open-S Company
 *
 * This file is part of Tanaguru.
 *
 * Tanaguru is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * Contact us by mail: open-s AT open-s DOT com
 */
package org.opens.tgol.entity.decorator.tanaguru.subject;

import org.opens.tanaguru.sdk.entity.service.AbstractGenericDataService;
import org.opens.tgol.util.HttpStatusCodeFamily;
import org.opens.tgol.entity.dao.statistics.StatisticsDAO;
import org.opens.tgol.entity.dao.tanaguru.subject.TgolWebResourceDAO;
import org.opens.tgol.presentation.data.PageResult;
import java.util.Collection;
import java.util.List;
import org.opens.tanaguru.entity.audit.Audit;
import org.opens.tanaguru.entity.audit.ProcessResult;
import org.opens.tanaguru.entity.audit.TestSolution;
import org.opens.tanaguru.entity.reference.Scope;
import org.opens.tanaguru.entity.reference.Theme;
import org.opens.tanaguru.entity.service.subject.WebResourceDataService;
import org.opens.tanaguru.entity.subject.Page;
import org.opens.tanaguru.entity.subject.Site;
import org.opens.tanaguru.entity.subject.WebResource;
import org.springframework.beans.factory.annotation.Autowired;

/**
 *
 * @author jkowalczyk
 */
public class WebResourceDataServiceDecoratorImpl extends AbstractGenericDataService<WebResource, Long>
        implements WebResourceDataServiceDecorator{

    private WebResourceDataService decoratedWebResourceDataService; // the WebResourceDataService instance being decorated
    private StatisticsDAO statisticsDAO;

    @Autowired
    public WebResourceDataServiceDecoratorImpl (
            WebResourceDataService decoratedWebResourceDataService,
            StatisticsDAO statisticsDAO) {
        this.decoratedWebResourceDataService = decoratedWebResourceDataService;
        this.statisticsDAO = statisticsDAO;
    }

    @Override
    public Long getParentWebResourceId(Long webresourceId) {
        return ((TgolWebResourceDAO)entityDao).retrieveParentWebResourceId(webresourceId);
    }

    @Override
    public Page createPage(String pageURL) {
        return decoratedWebResourceDataService.createPage(pageURL);
    }

    @Override
    public Site createSite(String siteURL) {
        return decoratedWebResourceDataService.createSite(siteURL);
    }

    @Override
    public WebResource getByUrl(String url) {
        return decoratedWebResourceDataService.getByUrl(url);
    }

    @Override
    public WebResource read(Long key) {
        return decoratedWebResourceDataService.read(key);
    }

    @Override
    public Collection<? extends Object> getFailedWebResourceSortedByTest(
            WebResource webResource,
            Audit audit,
            int nbOfResult) {
        return statisticsDAO.findFailedWebResourceSortedByTest(
                    webResource, 
                    audit,
                    nbOfResult);
    }

    @Override
    public Collection<? extends Object> getFailedWebResourceSortedByOccurrence(
            WebResource webResource,
            Audit audit,
            int nbOfResult) {
        return statisticsDAO.findFailedWebResourceSortedByOccurrence(
                    webResource, 
                    audit,
                    nbOfResult);
    }

    @Override
    public Collection<? extends Object> getFailedTestByOccurrence(
            WebResource webResource,
            Audit audit,
            int nbOfResult) {
        return statisticsDAO.findFailedTestByOccurrence(
                    webResource,
                    audit, 
                    nbOfResult);
    }

    @Override
    public WebResource ligthRead(Long webResourceId) {
        return ((TgolWebResourceDAO)entityDao).ligthRead(webResourceId);
    }

    @Override
    public WebResource deepRead(Long webResourceId) {
        return this.read(webResourceId);
    }

    @Override
    public Long getResultCountByResultType(
            WebResource webResource,
            Audit audit, 
            TestSolution testSolution) {
        return statisticsDAO.findResultCountByResultType(
                webResource,
                audit, 
                testSolution);
    }

    @Override
    public Collection<? extends Object> getResultCountByResultTypeAndTheme(
            WebResource webResource,
            Audit audit,
            TestSolution testSolution,
            int nb0fResult) {
        return statisticsDAO.findResultCountByResultTypeAndTheme(
                webResource,
                audit, 
                testSolution,
                nb0fResult);
    }

    @Override
    public Long getChildWebResourceCount(WebResource parentWebresource) {
        return ((TgolWebResourceDAO)entityDao).retrieveChildWebResourceCount(
                parentWebresource);
    }

    @Override
    public Collection<ProcessResult> getProcessResultListByWebResourceAndScope(WebResource webResource, Scope scope) {
        return ((TgolWebResourceDAO)entityDao).
                retrieveProcessResultListByWebResourceAndScope(webResource, scope);
    }

    @Override
    public Collection<ProcessResult> getProcessResultListByWebResourceAndScope(
            WebResource webResource,
            Scope scope,
            String theme,
            String testSolution) {
        return ((TgolWebResourceDAO)entityDao).
                retrieveProcessResultListByWebResourceAndScope(
                    webResource,
                    scope,
                    theme,
                    testSolution);
    }

    @Override
    public Long getResultCountByResultTypeAndTheme(
            WebResource webResource,
            Audit audit,
            TestSolution testSolution,
            Theme theme) {
        return statisticsDAO.findResultCountByResultTypeAndTheme(
            webResource,audit,testSolution,theme);
    }

{'fraction_non_alphanumeric': 0.06401977198437375, 'fraction_numerical': 0.00199314358606394, 'mean_word_length': 2.797759612473509, 'pattern_counts': {'":': 0, '<': 18, '<?xml version=': 0, '>': 18, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5147932', 'n_tokens_mistral': 3325, 'n_tokens_neox': 3202, 'n_words': 759}