|
1 | 1 | package eu.clarin.cmdi.curation.report; |
2 | 2 |
|
| 3 | +import eu.clarin.cmdi.curation.utils.TimeUtils; |
3 | 4 | import eu.clarin.cmdi.curation.xml.XMLMarshaller; |
4 | 5 |
|
5 | 6 | import java.io.OutputStream; |
|
18 | 19 | public class CollectionsReport implements Report<CollectionsReport> { |
19 | 20 |
|
20 | 21 | // private static final Logger logger = LoggerFactory.getLogger(CollectionsReport.class); |
21 | | - |
22 | | - @XmlElement(name = "collection") |
23 | | - private List<Collection> collections = new ArrayList<Collection>(); |
24 | | - |
25 | | - @Override |
26 | | - public void setParentName(String parentName) { |
27 | | - |
28 | | - } |
29 | | - |
30 | | - @Override |
31 | | - public String getParentName() { |
32 | | - |
33 | | - return null; |
34 | | - } |
35 | | - |
36 | | - @Override |
37 | | - public String getName() { |
38 | | - |
39 | | - return "CollectionsReport"; |
40 | | - } |
41 | | - |
42 | | - @Override |
43 | | - public boolean isValid() { |
44 | | - |
45 | | - return false; |
46 | | - } |
47 | | - |
48 | | - @Override |
49 | | - public void addSegmentScore(Score segmentScore) { |
50 | | - |
51 | | - |
52 | | - } |
53 | | - |
54 | | - @Override |
55 | | - public void toXML(OutputStream os) { |
56 | | - XMLMarshaller<CollectionsReport> instanceMarshaller = new |
57 | | - XMLMarshaller<>(CollectionsReport.class); |
58 | | - instanceMarshaller.marshal(this, os); |
59 | | - } |
60 | | - |
61 | | - @Override |
62 | | - public void mergeWithParent(CollectionsReport parentReport) { |
63 | | - |
64 | | - |
65 | | - } |
66 | | - |
67 | | - public void addReport(Report<?> report) { |
68 | | - if (report instanceof CollectionReport) { |
69 | | - this.collections.add(new Collection((CollectionReport) report)); |
70 | | - } |
71 | | - } |
72 | | - |
73 | | - |
74 | | - @XmlRootElement |
75 | | - @XmlAccessorType(XmlAccessType.FIELD) |
76 | | - public static class Collection { |
77 | | - @XmlAttribute |
78 | | - private String name; |
79 | | - @XmlElement |
80 | | - private String reportName; |
81 | | - @XmlElement |
82 | | - private double scorePercentage; |
83 | | - @XmlElement |
84 | | - private long numOfFiles; |
85 | | - @XmlElement |
86 | | - private int numOfProfiles; |
87 | | - @XmlElement |
88 | | - private int numOfUniqueLinks; |
89 | | - @XmlElement |
90 | | - private int numOfCheckedLinks; |
91 | | - @XmlElement |
92 | | - private double ratioOfValidLinks; |
93 | | - @XmlElement |
94 | | - private double avgNumOfResProxies; |
95 | | - @XmlElement |
96 | | - private int numOfResProxies; |
97 | | - @XmlElement |
98 | | - private double ratioOfValidRecords; |
99 | | - @XmlElement |
100 | | - private double avgNumOfEmptyXMLElements; |
101 | | - @XmlElement |
102 | | - private double avgFacetCoverage; |
103 | | - |
104 | | - @XmlElementWrapper(name = "facets") |
105 | | - @XmlElement(name = "facet") |
106 | | - private List<Facet> facets = new ArrayList<Facet>(); |
107 | | - |
108 | | - public Collection() { |
109 | | - |
110 | | - } |
111 | | - |
112 | | - public Collection(CollectionReport report) { |
113 | | - this.name = report.getName(); |
114 | | - this.reportName = report.getName(); |
115 | | - this.scorePercentage = report.scorePercentage; |
116 | | - this.numOfFiles = report.fileReport.numOfFiles; |
117 | | - this.numOfProfiles = report.headerReport.profiles.totNumOfProfiles; |
118 | | - this.numOfUniqueLinks = report.urlReport.totNumOfUniqueLinks; |
119 | | - this.numOfCheckedLinks = report.urlReport.totNumOfCheckedLinks; |
120 | | - this.ratioOfValidLinks = report.urlReport.ratioOfValidLinks; |
121 | | - this.avgNumOfResProxies = report.resProxyReport.avgNumOfResProxies; |
122 | | - this.numOfResProxies = report.resProxyReport.totNumOfResProxies; |
123 | | - this.ratioOfValidRecords = report.xmlValidationReport.ratioOfValidRecords; |
124 | | - this.avgNumOfEmptyXMLElements = report.xmlPopulatedReport.avgXMLEmptyElement; |
125 | | - this.avgFacetCoverage = report.facetReport.coverage; |
126 | | - |
127 | | - report.facetReport.facet.forEach(f -> this.facets.add(new Facet(f.name, f.coverage))); |
128 | | - } |
129 | | - |
130 | | - } |
131 | | - |
132 | | - @XmlRootElement |
133 | | - @XmlAccessorType(XmlAccessType.FIELD) |
134 | | - public static class Facet { |
135 | | - @XmlAttribute |
136 | | - private String name; |
137 | | - @XmlElement |
138 | | - private double avgCoverage; |
139 | | - |
140 | | - public Facet() { |
141 | | - |
142 | | - } |
143 | | - |
144 | | - public Facet(String name, double avgCoverage) { |
145 | | - this.name = name; |
146 | | - this.avgCoverage = avgCoverage; |
147 | | - } |
148 | | - } |
| 22 | + @XmlAttribute(name = "creation-time") |
| 23 | + public String creationTime = TimeUtils.humanizeToDate(System.currentTimeMillis()); |
| 24 | + |
| 25 | + @XmlElement(name = "collection") |
| 26 | + private List<Collection> collections = new ArrayList<Collection>(); |
| 27 | + |
| 28 | + @Override |
| 29 | + public void setParentName(String parentName) { |
| 30 | + |
| 31 | + } |
| 32 | + |
| 33 | + @Override |
| 34 | + public String getParentName() { |
| 35 | + |
| 36 | + return null; |
| 37 | + } |
| 38 | + |
| 39 | + @Override |
| 40 | + public String getName() { |
| 41 | + |
| 42 | + return "CollectionsReport"; |
| 43 | + } |
| 44 | + |
| 45 | + @Override |
| 46 | + public boolean isValid() { |
| 47 | + |
| 48 | + return false; |
| 49 | + } |
| 50 | + |
| 51 | + @Override |
| 52 | + public void addSegmentScore(Score segmentScore) { |
| 53 | + |
| 54 | + } |
| 55 | + |
| 56 | + @Override |
| 57 | + public void toXML(OutputStream os) { |
| 58 | + XMLMarshaller<CollectionsReport> instanceMarshaller = new XMLMarshaller<>(CollectionsReport.class); |
| 59 | + instanceMarshaller.marshal(this, os); |
| 60 | + } |
| 61 | + |
| 62 | + @Override |
| 63 | + public void mergeWithParent(CollectionsReport parentReport) { |
| 64 | + |
| 65 | + } |
| 66 | + |
| 67 | + public void addReport(Report<?> report) { |
| 68 | + if (report instanceof CollectionReport) { |
| 69 | + this.collections.add(new Collection((CollectionReport) report)); |
| 70 | + } |
| 71 | + } |
| 72 | + |
| 73 | + @XmlRootElement |
| 74 | + @XmlAccessorType(XmlAccessType.FIELD) |
| 75 | + public static class Collection { |
| 76 | + @XmlAttribute |
| 77 | + private String name; |
| 78 | + @XmlElement |
| 79 | + private String reportName; |
| 80 | + @XmlElement |
| 81 | + private double scorePercentage; |
| 82 | + @XmlElement |
| 83 | + private long numOfFiles; |
| 84 | + @XmlElement |
| 85 | + private int numOfProfiles; |
| 86 | + @XmlElement |
| 87 | + private int numOfUniqueLinks; |
| 88 | + @XmlElement |
| 89 | + private int numOfCheckedLinks; |
| 90 | + @XmlElement |
| 91 | + private double ratioOfValidLinks; |
| 92 | + @XmlElement |
| 93 | + private double avgNumOfResProxies; |
| 94 | + @XmlElement |
| 95 | + private int numOfResProxies; |
| 96 | + @XmlElement |
| 97 | + private double ratioOfValidRecords; |
| 98 | + @XmlElement |
| 99 | + private double avgNumOfEmptyXMLElements; |
| 100 | + @XmlElement |
| 101 | + private double avgFacetCoverage; |
| 102 | + |
| 103 | + @XmlElementWrapper(name = "facets") |
| 104 | + @XmlElement(name = "facet") |
| 105 | + private List<Facet> facets = new ArrayList<Facet>(); |
| 106 | + |
| 107 | + public Collection() { |
| 108 | + |
| 109 | + } |
| 110 | + |
| 111 | + public Collection(CollectionReport report) { |
| 112 | + this.name = report.getName(); |
| 113 | + this.reportName = report.getName(); |
| 114 | + this.scorePercentage = report.scorePercentage; |
| 115 | + this.numOfFiles = report.fileReport.numOfFiles; |
| 116 | + this.numOfProfiles = report.headerReport.profiles.totNumOfProfiles; |
| 117 | + this.numOfUniqueLinks = report.urlReport.totNumOfUniqueLinks; |
| 118 | + this.numOfCheckedLinks = report.urlReport.totNumOfCheckedLinks; |
| 119 | + this.ratioOfValidLinks = report.urlReport.ratioOfValidLinks; |
| 120 | + this.avgNumOfResProxies = report.resProxyReport.avgNumOfResProxies; |
| 121 | + this.numOfResProxies = report.resProxyReport.totNumOfResProxies; |
| 122 | + this.ratioOfValidRecords = report.xmlValidationReport.ratioOfValidRecords; |
| 123 | + this.avgNumOfEmptyXMLElements = report.xmlPopulatedReport.avgXMLEmptyElement; |
| 124 | + this.avgFacetCoverage = report.facetReport.coverage; |
| 125 | + |
| 126 | + report.facetReport.facet.forEach(f -> this.facets.add(new Facet(f.name, f.coverage))); |
| 127 | + } |
| 128 | + |
| 129 | + } |
| 130 | + |
| 131 | + @XmlRootElement |
| 132 | + @XmlAccessorType(XmlAccessType.FIELD) |
| 133 | + public static class Facet { |
| 134 | + @XmlAttribute |
| 135 | + private String name; |
| 136 | + @XmlElement |
| 137 | + private double avgCoverage; |
| 138 | + |
| 139 | + public Facet() { |
| 140 | + |
| 141 | + } |
| 142 | + |
| 143 | + public Facet(String name, double avgCoverage) { |
| 144 | + this.name = name; |
| 145 | + this.avgCoverage = avgCoverage; |
| 146 | + } |
| 147 | + } |
149 | 148 | } |
0 commit comments