Skip to content

Commit

Permalink
Simpler model, fully automated xsd generation.
Browse files Browse the repository at this point in the history
  • Loading branch information
simonharrer committed Jan 5, 2017
1 parent 214d3ec commit c559e00
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 23 deletions.
6 changes: 3 additions & 3 deletions loader/src/main/java/loader/PEBLMergerMain.java
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,9 @@ private static void merge(PEBL peblSource, PEBL peblTarget, Path newRelativeData
e.getFiles().clear();
e.getFiles().addAll(files);

final List<Path> logFiles = e.getLogFiles().stream().map(newRelativeDataFolder::relativize).collect(Collectors.toList());
e.getLogFiles().clear();
e.getLogFiles().addAll(logFiles);
final List<Path> logFiles = e.getLogs().stream().map(newRelativeDataFolder::relativize).collect(Collectors.toList());
e.getLogs().clear();
e.getLogs().addAll(logFiles);

final Optional<TestResult> testResultOptional = peblTarget.result.testResults.stream().filter(tr -> tr.getId().equals(e.getId())).findAny();
if(testResultOptional.isPresent()) {
Expand Down
6 changes: 3 additions & 3 deletions loader/src/main/java/loader/PEBLStoreFilesAlongMain.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,15 @@ static void copyFilesRelative(PEBL pebl, Path path) {
t.getFiles().clear();
t.getFiles().addAll(files);

final List<Path> logFiles = t.getLogFiles()
final List<Path> logFiles = t.getLogs()
.stream()
.map(file -> copyAndGetRelativePath(id, file, s -> "testResults/" + s + "/logFiles", parent))
.collect(Collectors.toList());

assertNoDuplicates(id, files);

t.getLogFiles().clear();
t.getLogFiles().addAll(logFiles);
t.getLogs().clear();
t.getLogs().addAll(logFiles);
});
}

Expand Down
2 changes: 1 addition & 1 deletion pebl/doc/result-test-result.puml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ package "" {

class TestResult {
files : List<String>
logFiles : List<String>
logs : List<String>
deploymentPackage : String
extensions : Map<String, String>
}
Expand Down
12 changes: 6 additions & 6 deletions pebl/src/main/java/pebl/result/test/TestResult.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ public class TestResult implements HasExtensions, HasId {
@XmlAttribute(required = true)
private final String tool;

@XmlElement(name = "logFiles")
@XmlElement(name = "logs")
@XmlList
private final List<Path> logFiles;
private final List<Path> logs;

@XmlElement(required = true)
private final Path deploymentPackage;
Expand Down Expand Up @@ -72,7 +72,7 @@ public class TestResult implements HasExtensions, HasId {
public TestResult(Test test,
Engine engine,
String tool,
List<Path> logFiles,
List<Path> logs,
Path deploymentPackage,
List<Path> files,
List<Measurement> measurements,
Expand All @@ -81,7 +81,7 @@ public TestResult(Test test,
this.test = test;
this.engine = engine;
this.tool = tool;
this.logFiles = new ArrayList<>(logFiles);
this.logs = new ArrayList<>(logs);
this.deploymentPackage = deploymentPackage;
this.files = new ArrayList<>(files);
this.measurements = new LinkedList<>(measurements);
Expand All @@ -101,8 +101,8 @@ public String getTool() {
return tool;
}

public List<Path> getLogFiles() {
return logFiles;
public List<Path> getLogs() {
return logs;
}

public Path getDeploymentPackage() {
Expand Down
14 changes: 7 additions & 7 deletions pebl/src/main/java/pebl/xsd/PEBL.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public void assertLinksWork() {
});
result.testResults.forEach(e -> {
e.getFiles().stream().filter(missing.or(relative)).forEach(unlinked::add);
e.getLogFiles().stream().filter(missing.or(relative)).forEach(unlinked::add);
e.getLogs().stream().filter(missing.or(relative)).forEach(unlinked::add);
});

if(unlinked.size() > 0) {
Expand Down Expand Up @@ -120,13 +120,13 @@ private void makeFilesAbsolute(Path workingDirectory) {
e.getFiles().clear();
e.getFiles().addAll(files);

final List<Path> logFiles = e.getLogFiles()
final List<Path> logFiles = e.getLogs()
.stream()
.map(workingDirectory::resolve)
.map(Path::toAbsolutePath)
.collect(Collectors.toList());
e.getLogFiles().clear();
e.getLogFiles().addAll(logFiles);
e.getLogs().clear();
e.getLogs().addAll(logFiles);
});
}

Expand Down Expand Up @@ -155,13 +155,13 @@ public void makeFilesRelative(Path workingDirectory) {
e.getFiles().clear();
e.getFiles().addAll(files);

final List<Path> logFiles = e.getLogFiles()
final List<Path> logFiles = e.getLogs()
.stream()
.map(Path::toAbsolutePath)
.map(workingDirectory::relativize)
.collect(Collectors.toList());
e.getLogFiles().clear();
e.getLogFiles().addAll(logFiles);
e.getLogs().clear();
e.getLogs().addAll(logFiles);
});
}

Expand Down
11 changes: 10 additions & 1 deletion pebl/src/main/java/pebl/xsd/SchemaGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@

import java.io.File;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.List;
import java.util.stream.Collectors;

import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
Expand Down Expand Up @@ -54,7 +58,12 @@ public Result createOutput(String uri, String suggestedFileName) throws IOExcept

};
jc.generateSchema(sor);
return xsd.toPath();
final Path xsdPath = xsd.toPath();

final List<String> lines = Files.readAllLines(xsdPath, StandardCharsets.UTF_8);
Files.write(xsdPath, lines.stream().map(s -> s.replace("##other", "##any")).collect(Collectors.toList()), StandardCharsets.UTF_8);

return xsdPath;
}

}
2 changes: 1 addition & 1 deletion pebl/src/main/resources/pebl/pebl.json
Original file line number Diff line number Diff line change
Expand Up @@ -1611,7 +1611,7 @@
"tool" : {
"type" : "string"
},
"logFiles" : {
"logs" : {
"type" : "array",
"items" : {
"type" : "string"
Expand Down
2 changes: 1 addition & 1 deletion pebl/src/main/resources/pebl/pebl.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,7 @@
</xsd:complexType>
<xsd:complexType name="testResult">
<xsd:sequence>
<xsd:element name="logFiles" minOccurs="0">
<xsd:element name="logs" minOccurs="0">
<xsd:simpleType>
<xsd:list itemType="xsd:string"/>
</xsd:simpleType>
Expand Down

0 comments on commit c559e00

Please sign in to comment.