Commit c9e3a8d589f4860e007084cd5940ed4a95b31b9c

Authored by lyandro.santana
1 parent 82942b98

Correção de conteudo

git-svn-id: https://svn.bento.ifrs.edu.br/default/ASES/ASES%20-%20Web/ASES%20-%20Web/Fontes/avaliador-api@10241 c2178572-b5ca-4887-91d2-9e3a90c7d55b
src/main/java/br/com/checker/emag/OccurrenceClassification.java
... ... @@ -6,8 +6,8 @@ public enum OccurrenceClassification {
6 6  
7 7 MARK("2.1","Marcação",1,9),
8 8 BEHAVIOR("2.2","Comportamento",10,15),
9   - CONTENT_INFORMATION("2.3","Conteúdo/Informação",16,27),
10   - PRESENTATION_DESIGN("2.4","Apresentação / Design",28,32),
  9 + CONTENT_INFORMATION("2.3","Conteúdo/Informação",16,28),
  10 + PRESENTATION_DESIGN("2.4","Apresentação / Design",29,32),
11 11 MULTIMEDIA("2.5","Multimídia",33,37),
12 12 FORM("2.6","Formulários",38,45);
13 13  
... ...
src/main/java/br/com/checker/emag/core/BehaviorEvaluation.java
... ... @@ -180,15 +180,20 @@ List<Occurrence> occurrences = new ArrayList<Occurrence>();
180 180 occurrences.add(this.buildOccurrence("2.2", false, applet.toString(), applet, "4"));
181 181 }
182 182  
183   -
184 183 for (Element object : getDocument().getAllElements("object")) {
185   - for(Element elemnet : object.getChildElements()){
186   - if(!elemnet.getName().equals("param")){
187   - occurrences.add(this.buildOccurrence("2.2", true, object.toString(), object, "2"));
  184 + boolean isParam = false;
  185 +
  186 + for(Element element : object.getChildElements()){
  187 + if(element.getName().equals("param")){
  188 + isParam = true;
188 189 }
189 190 }
  191 +
  192 + if(!isParam)
  193 + occurrences.add(this.buildOccurrence("2.2", true, object.toString(), object, "2"));
190 194 }
191 195  
  196 +
192 197  
193 198 /*for (Element object : getDocument().getAllElements("object")) {
194 199  
... ...
src/main/java/br/com/checker/emag/core/ContentEvaluation.java
... ... @@ -37,6 +37,7 @@ public class ContentEvaluation extends Evaluation{
37 37 public SpecificRecommendation recommendation25() { return new EvaluationRecommendation25();}
38 38 public SpecificRecommendation recommendation26() { return new EvaluationRecommendation26();}
39 39 public SpecificRecommendation recommendation27() { return new EvaluationRecommendation27();}
  40 + public SpecificRecommendation recommendation28() { return new EvaluationRecommendation28();}
40 41  
41 42 }
42 43  
... ... @@ -73,7 +74,9 @@ public class ContentEvaluation extends Evaluation{
73 74 protected static class EvaluationRecommendation27 extends ContentRecommendation{
74 75 protected List<Occurrence> check() { return getEvaluation().checkRecommendation27();}
75 76 }
76   -
  77 + protected static class EvaluationRecommendation28 extends ContentRecommendation{
  78 + protected List<Occurrence> check() { return getEvaluation().checkRecommendation28();}
  79 + }
77 80  
78 81 public List<Occurrence> check() {
79 82 getOccurrences().clear();
... ... @@ -88,6 +91,7 @@ public class ContentEvaluation extends Evaluation{
88 91 getOccurrences().addAll(checkRecommendation25());
89 92 getOccurrences().addAll(checkRecommendation26());
90 93 getOccurrences().addAll(checkRecommendation27());
  94 + getOccurrences().addAll(checkRecommendation28());
91 95  
92 96 return getOccurrences();
93 97 }
... ... @@ -103,21 +107,30 @@ public class ContentEvaluation extends Evaluation{
103 107 Attribute xmlLang = html.getAttributes().get("xml:lang");
104 108 Attribute xmlns = html.getAttributes().get("xmlns");
105 109  
106   - if (lang == null && xmlLang == null) {
107   - occurrences.add(this.buildOccurrence("3.1", true, html.toString(), html, "1"));
  110 + String tagHtml = getDocument().getFirstStartTag("html").toString();
  111 +
  112 + if ( html.getAttributes().get("lang") == null){
  113 + occurrences.add(this.buildOccurrence("3.1", true, tagHtml, html, "1"));
  114 + }
  115 +
  116 + if (lang == null && (xmlLang != null || xmlns != null)) {
  117 + occurrences.add(this.buildOccurrence("3.1", false, tagHtml, html, "2"));
108 118 } else if (lang != null && lang.getValue().isEmpty()) {
109   - occurrences.add(this.buildOccurrence("3.1", true, html.toString(), html, "1"));
  119 + occurrences.add(this.buildOccurrence("3.1", false, tagHtml, html, "2"));
110 120 } else if (xmlLang != null && xmlLang.getValue().isEmpty()) {
111   - occurrences.add(this.buildOccurrence("3.1", true, html.toString(), html, "1"));
  121 + occurrences.add(this.buildOccurrence("3.1", false, tagHtml, html, "2"));
  122 + }else if (xmlns != null && xmlns.getValue().isEmpty()) {
  123 + occurrences.add(this.buildOccurrence("3.1", false, tagHtml, html, "2"));
112 124 }
113 125  
114   - if (xmlLang == null && xmlns != null) {
115   - occurrences.add(this.buildOccurrence("3.1", true, html.toString(), html, "2"));
  126 + /*if (lang == null && xmlns != null) {
  127 + occurrences.add(this.buildOccurrence("3.1", false, html.toString(), html, "2"));
116 128 } else if (xmlns != null && xmlLang.getValue().isEmpty()) {
117   - occurrences.add(this.buildOccurrence("3.1", true, html.toString(), html, "2"));
  129 + occurrences.add(this.buildOccurrence("3.1", false, html.toString(), html, "2"));
118 130 } else if (xmlns != null && xmlns.getValue().isEmpty()) {
119   - occurrences.add(this.buildOccurrence("3.1", true, html.toString(), html, "2"));
  131 + occurrences.add(this.buildOccurrence("3.1", false, html.toString(), html, "2"));
120 132 }
  133 +*/
121 134 }
122 135  
123 136 return occurrences;
... ... @@ -128,11 +141,14 @@ public class ContentEvaluation extends Evaluation{
128 141 List<Occurrence> occurrences = new ArrayList<Occurrence>();
129 142  
130 143 for (Element element : getDocument().getAllElements()) {
131   -
132 144 if(!element.getName().equals("html")){
133   - if(element.getAttributeValue("lang") != null)
134   - occurrences.add(this.buildOccurrence("3.2", false, element.toString(), element, "1"));
135   -
  145 +
  146 + if(element.getName().equals("a") && element.getAttributeValue("href") != null){
  147 + if(element.getAttributeValue("href").contains("/?lang=")){
  148 + occurrences.add(this.buildOccurrence("3.2", false, element.toString(), element, "1"));
  149 + }
  150 + }else if(element.getAttributeValue("lang") != null)
  151 + occurrences.add(this.buildOccurrence("3.2", false, element.toString(), element, "1"));
136 152 }
137 153 }
138 154  
... ... @@ -329,7 +345,7 @@ public class ContentEvaluation extends Evaluation{
329 345  
330 346 for (Element img : getDocument().getAllElements("img")) {
331 347 Attribute altAtt = img.getAttributes().get("alt");
332   - if (altAtt != null) {
  348 + if (altAtt != null && !altAtt.getValue().isEmpty()) {
333 349 if(aMap.containsKey(altAtt.getValue())){
334 350 Attribute srcAtt = img.getAttributes().get("src");
335 351 if(srcAtt != null){
... ... @@ -359,16 +375,30 @@ public class ContentEvaluation extends Evaluation{
359 375 private List<Occurrence> checkRecommendation23() {
360 376 List<Occurrence> occurrences = new ArrayList<Occurrence>();
361 377  
  378 + boolean isMap = false;
  379 +
362 380 for (Element table : getDocument().getAllElements("img")) {
363 381  
364 382 Attribute usemap = table.getAttributes().get("usemap");
365 383 Attribute alt = table.getAttributes().get("alt");
366   -
367   - if (usemap != null && alt == null)
  384 +
  385 + if (usemap != null && (alt == null || alt.getValue().isEmpty())){
368 386 occurrences.add(this.buildOccurrence("3.7", true, table.toString(), table, "1"));
  387 + isMap = true;
  388 + }
369 389  
370 390 }
371 391  
  392 + if(isMap)
  393 + for (Element map : getDocument().getAllElements("map")) {
  394 + for (Element area :map.getAllElements("area")) {
  395 + Attribute alt = area.getAttributes().get("alt");
  396 + if(alt == null || alt.getValue().isEmpty())
  397 + occurrences.add(this.buildOccurrence("3.7", true, map.toString(), map, "1"));
  398 + }
  399 + }
  400 +
  401 +
372 402 return occurrences;
373 403 }
374 404  
... ... @@ -397,8 +427,23 @@ public class ContentEvaluation extends Evaluation{
397 427 private List<Occurrence> checkRecommendation26() {
398 428 List<Occurrence> occurrences = new ArrayList<Occurrence>();
399 429  
  430 + /*for (Element table : getDocument().getAllElements("table")) {
  431 + occurrences.add(buildOccurrence("3.10", false, table.toString(), table, "1"));
  432 + }*/
  433 +
  434 + for (Element table : getDocument().getAllElements("table")) {
  435 + for(Element caption : table.getAllElements("caption")){
  436 + if(caption == null)
  437 + occurrences.add(buildOccurrence("3.10", false, table.toString(), table, "2"));
  438 + else if(caption.isEmpty())
  439 + occurrences.add(buildOccurrence("3.10", false, table.toString(), table, "2"));
  440 + }
  441 + }
  442 +
  443 +
400 444 for (Element table : getDocument().getAllElements("table")) {
401 445 Attribute summary = table.getAttributes().get("summary");
  446 +
402 447 boolean THusaScope = false;
403 448 boolean THusaId = false;
404 449 boolean THusaHeaders = false;
... ... @@ -408,9 +453,10 @@ public class ContentEvaluation extends Evaluation{
408 453 boolean usaThead = false;
409 454 boolean usaTfoot = false;
410 455 boolean usaTbody = false;
  456 +
411 457  
412 458 if (summary == null || summary.getValue().equals(""))
413   - occurrences.add(buildOccurrence("3.10", true, table.toString(), table, "1"));
  459 + occurrences.add(buildOccurrence("3.10", false, table.toString(), table, "2"));
414 460  
415 461 for (Element thead : table.getAllElements("thead")) {
416 462 if (thead != null)
... ... @@ -428,8 +474,10 @@ public class ContentEvaluation extends Evaluation{
428 474 }
429 475  
430 476 if(!usaThead && !usaTbody && !usaTfoot){
431   -
432   - for (Element th : table.getAllElements("th")) {
  477 +
  478 + occurrences.add(this.buildOccurrence("3.10", true, table.getAllStartTags("table").get(0).toString(), table, "1"));
  479 +
  480 + /*for (Element th : table.getAllElements("th")) {
433 481 Attribute scope = th.getAttributes().get("scope");
434 482 Attribute headers = th.getAttributes().get("headers");
435 483 Attribute id = th.getAttributes().get("id");
... ... @@ -461,7 +509,7 @@ public class ContentEvaluation extends Evaluation{
461 509 if(!TDusaScope && !TDusaHeaders && !TDusaId){
462 510 occurrences.add(this.buildOccurrence("3.10", true, td.toString(), td, "1"));
463 511 }
464   - }
  512 + }*/
465 513  
466 514 }
467 515 }
... ... @@ -473,11 +521,11 @@ public class ContentEvaluation extends Evaluation{
473 521 private List<Occurrence> checkRecommendation27() {
474 522 List<Occurrence> occurrences = new ArrayList<Occurrence>();
475 523  
476   - String reg = "<p.*?>(.*)<\/p.*?>";
  524 + //String reg = "<p.*?>(.*)<\/p.*?>";
477 525  
478 526 for (Element paragrafo : getDocument().getAllElements("p")) {
479 527  
480   - Pattern p = Pattern.compile(reg,Pattern.CASE_INSENSITIVE);
  528 + /* Pattern p = Pattern.compile(reg,Pattern.CASE_INSENSITIVE);
481 529 Matcher m = p.matcher(paragrafo);
482 530  
483 531 while(m.find()){
... ... @@ -485,11 +533,44 @@ public class ContentEvaluation extends Evaluation{
485 533  
486 534 if(conteudoParagrafo.length() > 1000)
487 535 occurrences.add(this.buildOccurrence("3.11", false, paragrafo.toString(), paragrafo, "1"));
488   - }
  536 + }*/
  537 +
  538 +
  539 + if(paragrafo.getContent().length() > 1000)
  540 + occurrences.add(this.buildOccurrence("3.11", false, paragrafo.toString(), paragrafo, "1"));
489 541  
490 542 String align = paragrafo.getAttributeValue("align");
491 543 if("justify".equals(align))
492 544 occurrences.add(this.buildOccurrence("3.11", true, paragrafo.toString(), paragrafo, "2"));
  545 +
  546 + String style = paragrafo.getAttributeValue("style");
  547 + if(style != null && style.contains("text-align:justify"))
  548 + occurrences.add(this.buildOccurrence("3.11", true, paragrafo.toString(), paragrafo, "2"));
  549 + }
  550 +
  551 +
  552 + for (Element tags : getDocument().getAllElements()) {
  553 + if(!tags.getName().equals("p")){
  554 + String style = tags.getAttributeValue("style");
  555 + if(style != null && style.contains("text-align:justify"))
  556 + occurrences.add(this.buildOccurrence("3.11", true, tags.toString(), tags, "3"));
  557 + }
  558 +
  559 + }
  560 + return occurrences;
  561 + }
  562 +
  563 + private List<Occurrence> checkRecommendation28() {
  564 + List<Occurrence> occurrences = new ArrayList<Occurrence>();
  565 +
  566 + for (Element abbr : getDocument().getAllElements("abbr")) {
  567 + Attribute title = abbr.getAttributes().get("title");
  568 + if(title == null || title.getValue().equals(""))
  569 + occurrences.add(buildOccurrence("3.12", true, abbr.toString(), abbr, "1"));
  570 +
  571 +
  572 + if(abbr.getContent() == null)
  573 + occurrences.add(buildOccurrence("3.12", true, abbr.toString(), abbr, "1"));
493 574 }
494 575  
495 576 return occurrences;
... ...
src/main/java/br/com/checker/emag/core/PresentationEvaluation.java
... ... @@ -19,16 +19,13 @@ public class PresentationEvaluation extends Evaluation{
19 19 @Override
20 20 protected PresentationEvaluation with(Source document) { return new PresentationEvaluation(document); }
21 21  
22   - public SpecificRecommendation recommendation28() { return new EvaluationRecommendation28();}
23 22 public SpecificRecommendation recommendation29() { return new EvaluationRecommendation29();}
24 23 public SpecificRecommendation recommendation30() { return new EvaluationRecommendation30();}
25 24 public SpecificRecommendation recommendation31() { return new EvaluationRecommendation31();}
26 25 public SpecificRecommendation recommendation32() { return new EvaluationRecommendation32();}
27 26 }
28 27  
29   - protected static class EvaluationRecommendation28 extends PresentationRecommendation{
30   - protected List<Occurrence> check() { return getEvaluation().checkRecommendation28();}
31   - }
  28 +
32 29 protected static class EvaluationRecommendation29 extends PresentationRecommendation{
33 30 protected List<Occurrence> check() { return getEvaluation().checkRecommendation29();}
34 31 }
... ... @@ -45,7 +42,6 @@ public class PresentationEvaluation extends Evaluation{
45 42  
46 43 public List<Occurrence> check() {
47 44 getOccurrences().clear();
48   - getOccurrences().addAll(checkRecommendation28());
49 45 getOccurrences().addAll(checkRecommendation29());
50 46 getOccurrences().addAll(checkRecommendation30());
51 47 getOccurrences().addAll(checkRecommendation31());
... ... @@ -54,18 +50,7 @@ public class PresentationEvaluation extends Evaluation{
54 50 return getOccurrences();
55 51 }
56 52  
57   - private List<Occurrence> checkRecommendation28() {
58   - List<Occurrence> occurrences = new ArrayList<Occurrence>();
59   -
60   - for (Element abbr : getDocument().getAllElements("abbr")) {
61   - Attribute title = abbr.getAttributes().get("title");
62   - if(title == null || title.getValue().equals(""))
63   - occurrences.add(buildOccurrence("3.12", true, abbr.toString(), abbr, "1"));
64   -
65   - }
66   -
67   - return occurrences;
68   - }
  53 +
69 54  
70 55 private List<Occurrence> checkRecommendation29() {
71 56 List<Occurrence> occurrences = new ArrayList<Occurrence>();
... ...