Skip to content

Commit

Permalink
issue #264
Browse files Browse the repository at this point in the history
  • Loading branch information
wowasa committed Nov 10, 2024
1 parent 2a20a95 commit 843451e
Show file tree
Hide file tree
Showing 22 changed files with 198 additions and 166 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class HeaderReport {
@XmlElement
public long numWithSchemaLocation;
@XmlElement
public long numSchemaCRResident;
public long numSchemaCrResident;
@XmlElement
public long numWithMdProfile;
@XmlElement
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class InstanceHeaderReport {
@XmlElement
public String schemaLocation;
@XmlElement
public boolean isCRResident;
public boolean isCrResident;
@XmlElement
public String mdProfile;
@XmlElement
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ public static class Profile {
public String getId() {
return report.headerReport.getId();
};
@XmlAttribute
public boolean isPublic() { return report.headerReport.isPublic(); }
@XmlAttribute
public boolean isCrResident() { return report.headerReport.isCrResident(); }
@XmlElement
public String getName() {
return report.headerReport.getName();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,12 @@
import lombok.NoArgsConstructor;
import lombok.RequiredArgsConstructor;

import java.io.Serializable;

/**
*
*/
@XmlRootElement
@XmlAccessorType(XmlAccessType.NONE)
@XmlType(propOrder = {"id", "schemaLocation", "name", "description", "cmdiVersion", "status", "public"})
@XmlType(propOrder = {"id", "schemaLocation", "name", "description", "cmdiVersion", "status", "public", "crResident"})
@NoArgsConstructor(force = true)
@RequiredArgsConstructor
public class ProfileHeaderReport {
Expand Down Expand Up @@ -57,4 +55,6 @@ public String getCmdiVersion() {
public boolean isPublic() {
return header.isPublic();
}
@XmlElement
public boolean isCrResident() { return header.isCrResident(); }
}
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOEx
*/
public synchronized void addReport(CollectionReport collectionReport, CMDInstanceReport instanceReport) {

if (instanceReport.details.size() > 0) {//only add a record if there're details to report
if (!instanceReport.details.isEmpty()) {//only add a record if there're details to report

collectionReport.recordDetails.add(new RecordDetail(instanceReport.fileReport.location, instanceReport.details));
}
Expand Down Expand Up @@ -188,8 +188,8 @@ public synchronized void addReport(CollectionReport collectionReport, CMDInstanc
if (instanceReport.instanceHeaderReport.schemaLocation != null) {
collectionReport.headerReport.numWithSchemaLocation++;
}
if (instanceReport.instanceHeaderReport.isCRResident) {
collectionReport.headerReport.numSchemaCRResident++;
if (instanceReport.instanceHeaderReport.isCrResident) {
collectionReport.headerReport.numSchemaCrResident++;
}
if (instanceReport.instanceHeaderReport.mdProfile != null) {
collectionReport.headerReport.numWithMdProfile++;
Expand All @@ -214,7 +214,7 @@ public synchronized void addReport(CollectionReport collectionReport, CMDInstanc
collectionReport.resProxyReport.totNumOfResourcesWithMime += instanceReport.resProxyReport.numOfResourcesWithMime;
collectionReport.resProxyReport.totNumOfResourcesWithReference += instanceReport.resProxyReport.numOfResourcesWithReference;

if (instanceReport.resProxyReport.invalidReferences.size() > 0) {
if (!instanceReport.resProxyReport.invalidReferences.isEmpty()) {
collectionReport.resProxyReport.invalidReferences.add(new InvalidReference(
instanceReport.fileReport.location, instanceReport.resProxyReport.invalidReferences));
}
Expand Down Expand Up @@ -252,7 +252,6 @@ private void calculateAverages(CollectionReport collectionReport) {

this.mdSelfLinks.entrySet()
.stream()
.filter(entrySet -> entrySet.getValue().size() > 1)
.forEach(entrySet -> {
if(entrySet.getValue().size() == 1){ //link is unique
collectionReport.headerReport.numWithUniqueMdSelflink++;
Expand All @@ -262,7 +261,7 @@ private void calculateAverages(CollectionReport collectionReport) {
}
});
// adding score for unique selflinks
collectionReport.profileReport.aggregatedScore += collectionReport.headerReport.numWithUniqueMdSelflink;
collectionReport.headerReport.aggregatedScore += collectionReport.headerReport.numWithUniqueMdSelflink;

// lincheckerReport

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ else if(facetValuesMap.containsKey("curation_noNamespaceSchemaLocation") && !fac

instanceReport.instanceHeaderReport.score++; // availability of schemaLocation

if(instanceReport.instanceHeaderReport.isCRResident = crService.isSchemaCRResident(instanceReport.instanceHeaderReport.schemaLocation)) {
if(instanceReport.instanceHeaderReport.isCrResident) {

instanceReport.instanceHeaderReport.score++; // CRResidence
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public void process(CMDProfile profile, CMDProfileReport report) throws MalFunct
report.details.add(new Detail(Severity.FATAL,"concept" , "can't parse profile '" + profile.getSchemaLocation() + "'"));
log.debug("can't parse profile '{}'", profile.getSchemaLocation());

report.headerReport = new ProfileHeaderReport(new ProfileHeader("n/a", profile.getSchemaLocation(), "n/a", "n/a", "n/a", "n/a", false));
report.headerReport = new ProfileHeaderReport(new ProfileHeader("n/a", profile.getSchemaLocation(), "n/a", "n/a", "n/a", "n/a", false, false));

return;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
<tr>
<th>Id</th>
<th>Name</th>
<th>(P)ublic<br />(C)R resident</th>
<th>Score</th>
<th>Collection Usage</th>
<th>Instance Usage</th>
Expand Down Expand Up @@ -59,6 +60,10 @@
<td>
<xsl:value-of select="name"/>
</td>
<td>
<xsl:if test="@public">P</xsl:if>
<xsl:if test="@crResident">C</xsl:if>
</td>
<td>
<xsl:value-of select="format-number(score,'0.00')"/>
</td>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,14 @@
</td>
</tr>
</xsl:if>
<tr>
<th>Public</th>
<td><xsl:value-of select="./headerReport/public" /></td>
</tr>
<tr>
<th>CR resident</th>
<td><xsl:value-of select="./headerReport/crResident" /></td>
</tr>
</table>
<hr />
<details>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@
</p>
<p>
Number of files where schemaLocation is CR resident:
<xsl:value-of select="format-number(numSchemaCRResident, '###,##0')"/>
<xsl:value-of select="format-number(numSchemaCrResident, '###,##0')"/>
</p>
<p>
Number of files with MdProfile:
Expand All @@ -318,7 +318,7 @@

<xsl:if test="./duplicatedMDSelfLinks/duplicatedMDSelfLink">

<h2 id="duplicatedMDSelfLinks">Duplicated MDSelfLinks:</h2>
<h3 id="duplicatedMDSelfLinks">Duplicated MDSelfLinks:</h3>

<table class="reportTable">
<thead>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@
</p>
<p>
Number of files where schemaLocation is CR resident:
<xsl:value-of select="format-number(numSchemaCRResident, '###,##0')"/>
<xsl:value-of select="format-number(numSchemaCrResident, '###,##0')"/>
</p>
<p>
Number of files with MdProfile:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ public interface CRService {

boolean isPublicSchema(String schemaLocation) throws PPHCacheException;

boolean isSchemaCRResident(String schemaLocation);

Stream<String> getPublicSchemaLocations() throws PPHCacheException;

String getIdFromSchemaLocation(String schemaLocation);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,8 @@
@Service
public class CRServiceImpl implements CRService {

public static final String PROFILE_PREFIX = "clarin.eu:cr1:";
public static final String PROFILE_ID_FORMAT = "clarin\\.eu:cr1:p_[0-9]+";
public static final Pattern PROFILE_ID_PATTERN = Pattern.compile(PROFILE_ID_FORMAT);
public final Pattern CR_REST_PATTERN;

private final CRConfig crConfig;
private final CRCache crCache;
Expand All @@ -40,10 +38,6 @@ public CRServiceImpl(CRConfig crConfig, CRCache crCache) {
this.crConfig = crConfig;

this.crCache = crCache;

String CR_REST = crConfig.getRestApi().replaceFirst("http(s)?", "(http|https)").replaceFirst("/1\\..+", "/.+");

this.CR_REST_PATTERN = Pattern.compile(CR_REST);
}


Expand Down Expand Up @@ -80,11 +74,6 @@ public boolean isPublicSchema(String schemaLocation) throws PPHCacheException {
return this.crCache.getPublicSchemaLocations().contains(schemaLocation);
}

@Override
public boolean isSchemaCRResident(String schemaLocation) {
return CR_REST_PATTERN.matcher(schemaLocation).matches();
}

@Override
public Stream<String> getPublicSchemaLocations() throws PPHCacheException {

Expand Down
Loading

0 comments on commit 843451e

Please sign in to comment.