       1 /*
       2  * $Id$
       3  *
       4  * Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved.
       5  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       6  *
       7  * This code is free software; you can redistribute it and/or modify it
       8  * under the terms of the GNU General Public License version 2 only, as
       9  * published by the Free Software Foundation.  Oracle designates this
      10  * particular file as subject to the "Classpath" exception as provided
      11  * by Oracle in the LICENSE file that accompanied this code.
      12  *
      13  * This code is distributed in the hope that it will be useful, but WITHOUT
      14  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
      15  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
      16  * version 2 for more details (a copy is included in the LICENSE file that
      17  * accompanied this code).
      18  *
      19  * You should have received a copy of the GNU General Public License version
      20  * 2 along with this work; if not, write to the Free Software Foundation,
      21  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
      22  *
      23  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
      24  * or visit www.oracle.com if you need additional information or have any
      25  * questions.
      26  */
      27 package com.sun.javatest.cof;
      28
      29 import java.util.ArrayList;
      30 import java.util.Date;
      31 import java.util.LinkedHashMap;
      32 import java.util.List;
      33
      34 public class Report extends COFItem {
      35         static final String COF_SCHEMA = "http://qare.sfbay.sun.com/projects/COF/2003/2_0_2/Schema";
      36
      37         static final String COF_SCHEMA_LOCATION = "http://hestia.sfbay.sun.com/projects/COF/2003/2_0_2/Schema/COF2_0_2.xsd";
      38
      39         static final String VERSION = "2.0.2";
      40
      41         static final LinkedHashMap xmlAttributes;
      42
      43         static final LinkedHashMap xmlElements;
      44
      45         static String xmlTagName;
      46
      47         private static final String XSI_NS = "http://www.w3.org/2001/XMLSchema-instance";
      48
      49         static {
      50                 xmlElements = new LinkedHashMap();
      51                 xmlAttributes = new LinkedHashMap();
      52                 xmlElements.put("date", "date");
      53                 xmlElements.put("version", "version");
      54                 xmlElements.put("environments", "environments");
      55                 xmlElements.put("swentities", "swentities");
      56                 xmlElements.put("applications", "applications");
      57                 xmlElements.put("operator", "operator");
      58                 xmlElements.put("harness", "harness");
      59                 xmlElements.put("testsuites", "testsuites");
      60                 xmlElements.put("annotations", "annotations");
      61                 xmlAttributes.put("xsiNS", "xmlns:xsi");
      62                 xmlAttributes.put("cofNS", "xmlns:cof");
      63                 xmlAttributes.put("targetNS", "xmlns");
      64                 xmlAttributes.put("schemaLocation", "xsi:schemaLocation");
      65                 xmlTagName = "report";
      66
      67         }
      68
      69         //    @XmlAttribute
      70         protected String analysis;
      71
      72         //    @XmlElement(namespace = "http://qare.sfbay.sun.com/projects/COF/2003/2_0_2/Schema", required = true)
      73         protected COFReportAnnotations annotations;
      74
      75         //    @XmlAnyElement
      76         protected List/*<Element>*/any;
      77
      78         //    @XmlElement(namespace = "http://qare.sfbay.sun.com/projects/COF/2003/2_0_2/Schema", required = true)
      79         protected COFApplications applications;
      80
      81         //  @XmlElement(namespace = "http://qare.sfbay.sun.com/projects/COF/2003/2_0_2/Schema", required = true, type = String.class)
      82         protected Date date;
      83
      84         //    @XmlElement(namespace = "http://qare.sfbay.sun.com/projects/COF/2003/2_0_2/Schema", required = true)
      85         protected COFEnvironments environments;
      86
      87         //    @XmlElement(namespace = "http://qare.sfbay.sun.com/projects/COF/2003/2_0_2/Schema")
      88         protected String harness;
      89
      90         //    @XmlElement(namespace = "http://qare.sfbay.sun.com/projects/COF/2003/2_0_2/Schema")
      91         protected String operator;
      92
      93         //    @XmlElement(namespace = "http://qare.sfbay.sun.com/projects/COF/2003/2_0_2/Schema")
      94         protected COFSWEntities swentities;
      95
      96         //    @XmlElement(namespace = "http://qare.sfbay.sun.com/projects/COF/2003/2_0_2/Schema", required = true)
      97         protected COFTestSuites testsuites;
      98
      99         //    @XmlElement(namespace = "http://qare.sfbay.sun.com/projects/COF/2003/2_0_2/Schema", required = true)
     100         protected String version;
     101
     102         Report() {
     103                 setDate(new Date());
     104                 setVersion(VERSION);
     105                 setAnnotations(new COFReportAnnotations());
     106         }
     107
     108         Report(COFEnvironment env, COFTestSuite ts) {
     109                 this();
     110                 getEnvironments().getEnvironment().add(env);
     111                 getTestsuites().getTestsuite().add(ts);
     112         }
     113
     114         Report(COFEnvironment[] envs, COFTestSuite ts) {
     115                 this();
     116         for (int i = 0; i < envs.length; i++) {
     117             getEnvironments().getEnvironment().add(envs[i]);
     118         }
     119                 getTestsuites().getTestsuite().add(ts);
     120         }
     121
     122         void addEnvironment(COFEnvironment env) {
     123                 getEnvironments().getEnvironment().add(env);
     124         }
     125
     126         void addTestSuite(COFTestSuite ts) {
     127                 getTestsuites().getTestsuite().add(ts);
     128         }
     129
     130         /**
     131          * Gets the value of the analysis property.
     132          *
     133          * @return
     134          *     possible object is
     135          *     {@link String }
     136          *
     137          */
     138         public String getAnalysis() {
     139                 if (analysis == null) {
     140                         return "accept";
     141                 } else {
     142                         return analysis;
     143                 }
     144         }
     145
     146         /**
     147          * Gets the value of the annotations property.
     148          *
     149          * @return
     150          *     possible object is
     151          *     {@link COFReportAnnotations }
     152          *
     153          */
     154         public COFReportAnnotations getAnnotations() {
     155                 return annotations;
     156         }
     157
     158         /**
     159          * Gets the value of the any property.
     160          *
     161          * <p>
     162          * This accessor method returns a reference to the live list,
     163          * not a snapshot. Therefore any modification you make to the
     164          * returned list will be present inside the JAXB object.
     165          * This is why there is not a <CODE>set</CODE> method for the any property.
     166          *
     167          * <p>
     168          * For example, to add a new item, do as follows:
     169          * <pre>
     170          *    getAny().add(newItem);
     171          * </pre>
     172          *
     173          *
     174          * <p>
     175          * Objects of the following type(s) are allowed in the list
     176          * {@link Element }
     177          *
     178          *
     179          */
     180         public List/*<Element>*/getAny() {
     181                 if (any == null) {
     182                         any = new ArrayList/*<Element>*/();
     183                 }
     184                 return this.any;
     185         }
     186
     187         /**
     188          * Gets the value of the applications property.
     189          */
     190         public COFApplications getApplications() {
     191                 return applications;
     192         }
     193
     194         /**
     195          * @return Returns the cofNS.
     196          */
     197         public String getCofNS() {
     198                 return COF_SCHEMA;
     199         }
     200
     201         /**
     202          * Gets the value of the date property.
     203          *
     204          * @return
     205          *     possible object is
     206          *     {@link String }
     207          *
     208          */
     209         public Date getDate() {
     210                 return date;
     211         }
     212
     213         /**
     214          * Gets the value of the environments property.
     215          *
     216          * @return
     217          *     possible object is
     218          *     {@link Environments }
     219          *
     220          */
     221         public COFEnvironments getEnvironments() {
     222                 if (environments == null)
     223                         environments = new COFEnvironments();
     224                 return environments;
     225         }
     226
     227         /**
     228          * Gets the value of the harness property.
     229          *
     230          * @return
     231          *     possible object is
     232          *     {@link String }
     233          *
     234          */
     235         public String getHarness() {
     236                 return harness;
     237         }
     238
     239         LinkedHashMap getItemAttributes() {
     240                 return xmlAttributes;
     241         }
     242
     243         LinkedHashMap getItemElements() {
     244                 return xmlElements;
     245         }
     246
     247         String getItemTagName() {
     248                 return xmlTagName;
     249         }
     250
     251         /**
     252          * Gets the value of the operator property.
     253          *
     254          * @return
     255          *     possible object is
     256          *     {@link String }
     257          *
     258          */
     259         public String getOperator() {
     260                 return operator;
     261         }
     262
     263         /**
     264          * @return Returns the schemaLocation.
     265          */
     266         public String getSchemaLocation() {
     267                 return COF_SCHEMA + " " + COF_SCHEMA_LOCATION;
     268         }
     269
     270         /**
     271          * Gets the value of the swentities property.
     272          *
     273          * @return
     274          *     possible object is
     275          *     {@link COFSWEntities }
     276          *
     277          */
     278         public COFSWEntities getSwentities() {
     279                 return swentities;
     280         }
     281
     282         /**
     283          * @return Returns the targetNS.
     284          */
     285         public String getTargetNS() {
     286                 return COF_SCHEMA;
     287         }
     288
     289         /**
     290          * Gets the value of the testsuites property.
     291          *
     292          * @return
     293          *     possible object is
     294          *     {@link TestSuites }
     295          *
     296          */
     297         public COFTestSuites getTestsuites() {
     298                 if (testsuites == null)
     299                         testsuites = new COFTestSuites();
     300                 return testsuites;
     301         }
     302
     303         /**
     304          * Gets the value of the version property.
     305          *
     306          * @return
     307          *     possible object is
     308          *     {@link String }
     309          *
     310          */
     311         public String getVersion() {
     312                 return version;
     313         }
     314
     315         /**
     316          * @return Returns the xsiNS.
     317          */
     318         public String getXsiNS() {
     319                 return XSI_NS;
     320         }
     321
     322         /**
     323          * Sets the value of the analysis property.
     324          *
     325          * @param value
     326          *     allowed object is
     327          *     {@link String }
     328          *
     329          */
     330         public void setAnalysis(String value) {
     331                 this.analysis = value;
     332         }
     333
     334         /**
     335          * Sets the value of the annotations property.
     336          *
     337          * @param value
     338          *     allowed object is
     339          *     {@link COFReportAnnotations }
     340          *
     341          */
     342         public void setAnnotations(COFReportAnnotations value) {
     343                 this.annotations = value;
     344         }
     345
     346         /**
     347          * Sets the value of the date property.
     348          *
     349          * @param value
     350          *     allowed object is
     351          *     {@link String }
     352          *
     353          */
     354         public void setDate(Date value) {
     355                 this.date = value;
     356         }
     357
     358         /**
     359          * Sets the value of the environments property.
     360          *
     361          * @param value
     362          *     allowed object is
     363          *     {@link Environments }
     364          *
     365          */
     366         public void setEnvironments(COFEnvironments value) {
     367                 this.environments = value;
     368         }
     369
     370         /**
     371          * Sets the value of the harness property.
     372          *
     373          * @param value
     374          *     allowed object is
     375          *     {@link String }
     376          *
     377          */
     378         public void setHarness(String value) {
     379                 this.harness = value;
     380         }
     381
     382         /**
     383          * Sets the value of the operator property.
     384          *
     385          * @param value
     386          *     allowed object is
     387          *     {@link String }
     388          *
     389          */
     390         public void setOperator(String value) {
     391                 this.operator = value;
     392         }
     393
     394         /**
     395          * Sets the value of the swentities property.
     396          *
     397          * @param value
     398          *     allowed object is
     399          *     {@link COFSWEntities }
     400          *
     401          */
     402         public void setSwentities(COFSWEntities value) {
     403                 this.swentities = value;
     404         }
     405
     406         public void setApplications(COFApplications value) {
     407                 this.applications = value;
     408         }
     409         /**
     410          * Sets the value of the testsuites property.
     411          *
     412          * @param value
     413          *     allowed object is
     414          *     {@link TestSuites }
     415          *
     416          */
     417         public void setTestsuites(COFTestSuites value) {
     418                 this.testsuites = value;
     419         }
     420
     421         /**
     422          * Sets the value of the version property.
     423          *
     424          * @param value
     425          *     allowed object is
     426          *     {@link String }
     427          *
     428          */
     429         public void setVersion(String value) {
     430                 this.version = value;
     431         }
     432 }