Search in sources :

Example 6 with DomElement

use of org.asqatasun.rules.domelement.DomElement in project Asqatasun by Asqatasun.

the class Rgaa22Rule07111 method doSelect.

@Override
protected void doSelect(Collection<DomElement> domElements, SSPHandler sspHandler) {
    for (DomElement domElement : domElements) {
        if (domElement.isFocusable()) {
            Element el = DomElementExtractor.getElementFromDomElement(domElement, sspHandler);
            treatFocusableElement(el, domElement, getElements());
        }
    }
}
Also used : DomElement(org.asqatasun.rules.domelement.DomElement) DomElement(org.asqatasun.rules.domelement.DomElement) Element(org.jsoup.nodes.Element)

Example 7 with DomElement

use of org.asqatasun.rules.domelement.DomElement in project Asqatasun by Asqatasun.

the class DomElementExtractor method getDomElementFromJson.

/**
     * 
     * @param element
     * @return an instance of DomElement
     * @throws JSONException 
     */
private static DomElement getDomElementFromJson(JSONObject element) throws JSONException {
    Iterator<String> keys = element.keys();
    DomElement domElement = new DomElement();
    while (keys.hasNext()) {
        String key = keys.next();
        try {
            domElement.addProperty(key, element.get(key).toString());
        } catch (Exception e) {
        }
    }
    return domElement;
}
Also used : DomElement(org.asqatasun.rules.domelement.DomElement) JSONException(org.json.JSONException) NoResultException(javax.persistence.NoResultException)

Example 8 with DomElement

use of org.asqatasun.rules.domelement.DomElement in project Asqatasun by Asqatasun.

the class DomElementExtractor method extractDomElements.

/**
     * 
     * @param sspHandler
     * @return a collection of instanciated DomElement
     * @throws NoResultException 
     */
public static Collection<DomElement> extractDomElements(SSPHandler sspHandler) throws NoResultException {
    String ppr = sspHandler.getPreProcessResult(COLOR_EXTRACTOR_PRE_PROCESS_RESULT_KEY, sspHandler.getPage());
    Collection<DomElement> domElements = new ArrayList<>();
    JSONArray json;
    try {
        json = new JSONArray(ppr);
        for (int i = 0; i < json.length(); i++) {
            domElements.add(getDomElementFromJson(new JSONObject(json.get(i).toString())));
        }
    } catch (JSONException ex) {
        LOGGER.warn(ex);
    }
    return domElements;
}
Also used : DomElement(org.asqatasun.rules.domelement.DomElement) JSONObject(org.json.JSONObject) ArrayList(java.util.ArrayList) JSONArray(org.json.JSONArray) JSONException(org.json.JSONException)

Example 9 with DomElement

use of org.asqatasun.rules.domelement.DomElement in project Asqatasun by Asqatasun.

the class Rgaa32016Rule100701 method doSelect.

@Override
protected void doSelect(Collection<DomElement> domElements, SSPHandler sspHandler) {
    for (DomElement domElement : domElements) {
        if (domElement.isFocusable()) {
            Element el = DomElementExtractor.getElementFromDomElement(domElement, sspHandler);
            treatFocusableElement(el, domElement, getElements());
        }
    }
}
Also used : DomElement(org.asqatasun.rules.domelement.DomElement) DomElement(org.asqatasun.rules.domelement.DomElement) Element(org.jsoup.nodes.Element)

Aggregations

DomElement (org.asqatasun.rules.domelement.DomElement)9 Element (org.jsoup.nodes.Element)6 EvidenceElement (org.asqatasun.entity.audit.EvidenceElement)2 TestSolution (org.asqatasun.entity.audit.TestSolution)2 JSONException (org.json.JSONException)2 DecimalFormat (java.text.DecimalFormat)1 DecimalFormatSymbols (java.text.DecimalFormatSymbols)1 ArrayList (java.util.ArrayList)1 NoResultException (javax.persistence.NoResultException)1 ContrastCheckerParseResultException (org.asqatasun.rules.elementchecker.contrast.exception.ContrastCheckerParseResultException)1 JSONArray (org.json.JSONArray)1 JSONObject (org.json.JSONObject)1